Reactor Net segmentation error

74 views
Skip to first unread message

anurag surapaneni

unread,
Feb 20, 2019, 9:08:48 AM2/20/19
to Cantera Users' Group
Hey, 

I am trying to use a vector of pointers for my gas objects and reactor objects. I am then adding all the reactors to a reactor network which I am advancing in time. However I get a segmentation fault. I also tried the same exercise by having one reactor per reactor network which is working. I would like any possible help in this regard.

I am using cantera 2.4 on a intel compiler (icc)

Thank You 

#include "cantera/thermo.h"
#include <iostream>
#include "cantera/IdealGasMix.h"
#include "cantera/zerodim.h"
#include "vector"

std::vector<std::unique_ptr<Cantera::IdealGasMix>> gas;
std::vector<std::unique_ptr<Cantera::IdealGasConstPressureReactor>> React;
std::vector<std::unique_ptr<Cantera::ReactorNet>> net;
 void run()
{
   int nsp;
   int n;
   double p = 101325;
   double temp = 1000;
   int n_size = 1000;

 net.emplace_back(new Cantera::ReactorNet);
   
for (int i=0; i<n_size; i++) {
        React.emplace_back(new Cantera::IdealGasConstPressureReactor);
        gas.emplace_back(new Cantera::IdealGasMix("gri30.xml"));
}
    nsp = gas[0]->nSpecies();
    Cantera::vector_fp x(nsp, 0.0);
    x[gas[0]->speciesIndex("CH4")] = 1.0;
    x[gas[0]->speciesIndex("O2")] = 2;
    x[gas[0]->speciesIndex("N2")] = 7.52;
    for (int i=0; i<n_size; i++) {
    gas[i]->setState_TPY(temp,p,x.data());
    React[i]->insert(*gas[i]);
    net[0]->addReactor(*React[i]);
      }
    net[0]->advance(0.002);
   n = net[0]->neq();
   std::cout <<  n << "\n";
  }

void main()
{
run();
}

The error is Segmentation fault (core dumped)


Ray Speth

unread,
Feb 22, 2019, 10:35:51 AM2/22/19
to Cantera Users' Group
Hi,

The method for solving a reactor network used by Cantera involves constructing the N x N Jacobian matrix for the system of equations, where N is the number of variables in the system. In this case, you've defined a system with 55000 variables, so the size of this matrix weighs in at a rather hefty 24 GB. The segfault is a consequence of being unable to allocate an array to hold this matrix.

Regards,
Ray
Reply all
Reply to author
Forward
0 new messages