19 if (thermo.
type() !=
"IdealGas") {
21 "Incompatible phase type provided");
23 Reactor::setThermoMgr(thermo);
26 void IdealGasReactor::getInitialConditions(
double t0,
size_t leny,
double* y)
29 "Use getState instead. To be removed after Cantera 2.3.");
33 void IdealGasReactor::getState(
double* y)
37 "Error: reactor is empty.");
39 m_thermo->restoreState(m_state);
42 m_mass = m_thermo->density() * m_vol;
49 y[2] = m_thermo->temperature();
52 m_thermo->getMassFractions(y+3);
56 getSurfaceInitialConditions(y + m_nsp + 3);
59 void IdealGasReactor::initialize(doublereal t0)
61 Reactor::initialize(t0);
62 m_uk.resize(m_nsp, 0.0);
65 void IdealGasReactor::updateState(doublereal* y)
72 m_thermo->setMassFractions_NoNorm(y+3);
73 m_thermo->setState_TR(y[2], m_mass / m_vol);
74 updateSurfaceState(y + m_nsp + 3);
77 m_enthalpy = m_thermo->enthalpy_mass();
78 m_pressure = m_thermo->pressure();
79 m_intEnergy = m_thermo->intEnergy_mass();
80 m_thermo->saveState(m_state);
83 void IdealGasReactor::evalEqs(doublereal time, doublereal* y,
84 doublereal* ydot, doublereal* params)
88 double* dYdt = ydot + 3;
90 m_thermo->restoreState(m_state);
91 applySensitivity(params);
92 m_thermo->getPartialMolarIntEnergies(&m_uk[0]);
93 const vector_fp& mw = m_thermo->molecularWeights();
94 const doublereal* Y = m_thermo->massFractions();
97 m_kin->getNetProductionRates(&m_wdot[0]);
101 double mdot_surf = evalSurfaces(time, ydot + m_nsp + 3);
105 mcvdTdt += - m_pressure * m_vdot - m_Q;
107 for (
size_t n = 0; n < m_nsp; n++) {
109 mcvdTdt -= m_wdot[n] * m_uk[n] * m_vol;
110 mcvdTdt -= m_sdot[n] * m_uk[n];
112 dYdt[n] = (m_wdot[n] * m_vol + m_sdot[n]) * mw[n] / m_mass;
114 dYdt[n] -= Y[n] * mdot_surf / m_mass;
118 for (
size_t i = 0; i < m_outlet.size(); i++) {
119 double mdot_out = m_outlet[i]->massFlowRate(time);
121 mcvdTdt -= mdot_out * m_pressure * m_vol / m_mass;
125 for (
size_t i = 0; i < m_inlet.size(); i++) {
126 double mdot_in = m_inlet[i]->massFlowRate(time);
128 mcvdTdt += m_inlet[i]->enthalpy_mass() * mdot_in;
129 for (
size_t n = 0; n < m_nsp; n++) {
130 double mdot_spec = m_inlet[i]->outletSpeciesMassFlowRate(n);
132 dYdt[n] += (mdot_spec - mdot_in * Y[n]) / m_mass;
136 mcvdTdt -= m_uk[n] / mw[n] * mdot_spec;
143 ydot[2] = mcvdTdt / (m_mass * m_thermo->cv_mass());
148 resetSensitivity(params);
151 size_t IdealGasReactor::componentIndex(
const string& nm)
const 153 size_t k = speciesIndex(nm);
156 }
else if (nm ==
"m" || nm ==
"mass") {
159 "Using the name 'm' for mass is deprecated, and will be " 160 "disabled after Cantera 2.3. Use 'mass' instead.");
163 }
else if (nm ==
"V" || nm ==
"volume") {
166 "Using the name 'V' for volume is deprecated, and will be " 167 "disabled after Cantera 2.3. Use 'volume' instead.");
170 }
else if (nm ==
"T" || nm ==
"temperature") {
173 "Using the name 'T' for temperature is deprecated, and will be " 174 "disabled after Cantera 2.3. Use 'temperature' instead.");
182 std::string IdealGasReactor::componentName(
size_t k) {
184 return "temperature";
186 return Reactor::componentName(k);
Header file for class Wall.
const size_t npos
index returned by functions to indicate "no position"
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Base class for a phase with thermodynamic properties.
Base class for exceptions thrown by Cantera classes.
virtual std::string type() const
String indicating the thermodynamic model implemented.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Namespace for the Cantera kernel.