16 void ConstPressureReactor::getInitialConditions(
double t0,
size_t leny,
double* y)
20 "Error: reactor is empty.");
22 m_thermo->restoreState(m_state);
25 y[0] = m_thermo->density() * m_vol;
28 y[1] = m_thermo->enthalpy_mass() * m_thermo->density() * m_vol;
31 m_thermo->getMassFractions(y+2);
35 getSurfaceInitialConditions(y + m_nsp + 2);
38 void ConstPressureReactor::initialize(doublereal t0)
40 Reactor::initialize(t0);
44 void ConstPressureReactor::updateState(doublereal* y)
50 m_thermo->setMassFractions_NoNorm(y+2);
52 m_thermo->setState_HP(y[1]/m_mass, m_pressure, 1.0e-4);
54 m_thermo->setPressure(m_pressure);
56 m_vol = m_mass / m_thermo->density();
57 updateSurfaceState(y + m_nsp + 2);
60 m_enthalpy = m_thermo->enthalpy_mass();
61 m_intEnergy = m_thermo->intEnergy_mass();
62 m_thermo->saveState(m_state);
65 void ConstPressureReactor::evalEqs(doublereal time, doublereal* y,
66 doublereal* ydot, doublereal* params)
69 double* dYdt = ydot + 2;
71 m_thermo->restoreState(m_state);
72 applySensitivity(params);
74 double mdot_surf = evalSurfaces(time, ydot + m_nsp + 2);
77 const vector_fp& mw = m_thermo->molecularWeights();
78 const doublereal* Y = m_thermo->massFractions();
81 m_kin->getNetProductionRates(&m_wdot[0]);
84 for (
size_t k = 0; k < m_nsp; k++) {
86 dYdt[k] = (m_wdot[k] * m_vol + m_sdot[k]) * mw[k] / m_mass;
88 dYdt[k] -= Y[k] * mdot_surf / m_mass;
95 for (
size_t i = 0; i < m_outlet.size(); i++) {
96 double mdot_out = m_outlet[i]->massFlowRate(time);
98 dHdt -= mdot_out * m_enthalpy;
102 for (
size_t i = 0; i < m_inlet.size(); i++) {
103 double mdot_in = m_inlet[i]->massFlowRate(time);
105 for (
size_t n = 0; n < m_nsp; n++) {
106 double mdot_spec = m_inlet[i]->outletSpeciesMassFlowRate(n);
108 dYdt[n] += (mdot_spec - mdot_in * Y[n]) / m_mass;
110 dHdt += mdot_in * m_inlet[i]->enthalpy_mass();
121 resetSensitivity(params);
124 size_t ConstPressureReactor::componentIndex(
const string& nm)
const
126 size_t k = speciesIndex(nm);
129 }
else if (nm ==
"m" || nm ==
"mass") {
131 }
else if (nm ==
"H" || nm ==
"enthalpy") {
const size_t npos
index returned by functions to indicate "no position"
Base class for exceptions thrown by Cantera classes.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.