I am trying to model a gas turbine combustor using CANTERA and Visual C++ 2013; I will need plug flow reactors for the models of secondary and dilution zones. There is a class named FlowReactor in CANTERA, can it be used to model a plug flow reactor? If that's the case, are there any examples?
Before trying to figure out the code myself, I think getting help from someone who might have had the same problem might be a quicker solution.
I have tried to convert the example for perfectly stirred reactor to plug flow reactor with some minor changes as;
private: void pfr_tut()
{
cout << "Started" << endl;
// use reaction mechanism GRI-Mech 3.0
IdealGasMix gas("gri30.cti", "gri30");
int nsp = gas.nSpecies();
// create a reservoir for the premixed reactants' fuel composition
Reservoir inlet;
gas.setState_TPX(1000, 0.83 * OneAtm, "CH4:0.06, O2:0.2, N2:0.74");
inlet.insert(gas);
// to ignite the fuel/air mixture, we'll introduce a pulse of radicals.
// The steady-state behavior is independent of how we do this, so we'll
// just use a stream of pure atomic hydrogen.
gas.setState_TPX(300.0, 0.83 * OneAtm, "H:1.0");
Reservoir igniter;
igniter.insert(gas);
// create the plug flow reactor, and fill it in initially with N2
FlowReactor pfr; // not sure about this
pfr.insert(gas);
pfr.setInitialVolume(0.004);
// create a reservoir for the exhaust. The initial composition
// doesn't matter.
Reservoir exhaust;
exhaust.insert(gas);
// create and install the mass flow controllers. Controllers
// m1 is the inlet and m2 provides a short Gaussian pulse only to ignite the mixture
MassFlowController m1;
m1.install(inlet, pfr);
m1.setMassFlowRate(0.001);
// The igniter will use a Gaussian 'functor' object to specify the
// time-dependent igniter mass flow rate.
double A = 0.1;
double FWHM = 0.2;
double t0 = 1.0;
Gaussian igniter_mdot(A, t0, FWHM);
MassFlowController m2;
m2.install(igniter, pfr);
m2.setFunction(&igniter_mdot);
// put a valve on the exhaust line to regulate the pressure
Valve v;
v.install(pfr, exhaust);
double Kv = 1.0;
v.setParameters(1, &Kv);
// the simulation contains a plug flow reactor
ReactorNet sim;
sim.addReactor(&pfr); // Not sure about this either
// take single steps to 6 s, writing the results to a CSV file
// for later plotting.
double tfinal = 6.0;
double tnow = 0.0;
double tres;
int k;
std::ofstream f("combustor_cxx.csv");
f << " Time,Temperature,tres";
f << std::endl;
while (tnow < tfinal) {
tnow = sim.step(tfinal);
tres = pfr.mass() / v.massFlowRate();
f << tnow << ", "
<< pfr.temperature() << tres << ", ";
}
f << std::endl;
}
f.close();
cout << "Program Finished" << endl;
}
When the program runs i get the following error;
Started
Reactor Type: 3
Reactor Temperature: 300
Reactor Volume: 0.004
***********************************************************************
CanteraError thrown by setState_HPorUV (HP):
No convergence in 500 iterations
Target Enthalpy = -1.#IND
Current Pressure = -1.#IND
Starting Temperature = 2.09075e-005
Current Temperature = 50300.9
Current Enthalpy = -1.#IND
Current Delta T = 100
***********************************************************************
***********************************************************************
CanteraError thrown by setState_HPorUV (HP):
No convergence in 500 iterations
Target Enthalpy = -1.#IND
Current Pressure = -1.#IND
Starting Temperature = 50300.9
Current Temperature = 52999.1
Current Enthalpy = -1.#IND
Current Delta T = 100
***********************************************************************
***********************************************************************
CanteraError thrown by setState_HPorUV (HP):
No convergence in 500 iterations
Target Enthalpy = -1.#IND
Current Pressure = -1.#IND
Starting Temperature = 52999.1
Current Temperature = 52999.1
Current Enthalpy = -1.#IND
Current Delta T = 100
***********************************************************************
***********************************************************************
CanteraError thrown by setState_HPorUV (HP):
No convergence in 500 iterations
Target Enthalpy = -1.#IND
Current Pressure = -1.#IND
Starting Temperature = 52999.1
Current Temperature = 52999.1
Current Enthalpy = -1.#IND
Current Delta T = 100
***********************************************************************
[CVODES ERROR] CVode
At t = 0 repeated recoverable right-hand side function errors.
***********************************************************************
CanteraError thrown by CVodesIntegrator:
CVodes error encountered. Error code: -10
Components with largest weighted error estimates:
0: 0
1: 1.#QNAN
2: 1.#QNAN
3: 1.#QNAN
4: 1.#QNAN
5: 1.#QNAN
6: 1.#QNAN
7: 1.#QNAN
8: 1.#QNAN
9: 1.#QNAN
***********************************************************************
terminating...
Any help would be appreciated...