6 #include "cantera/zeroD/IdealGasConstPressureReactor.h" 14 void IdealGasConstPressureReactor::setThermoMgr(
ThermoPhase& thermo)
18 if (thermo.
type() !=
"IdealGas") {
20 "Incompatible phase type provided");
22 Reactor::setThermoMgr(thermo);
26 void IdealGasConstPressureReactor::getInitialConditions(
double t0,
size_t leny,
30 "Use getState instead. To be removed after Cantera 2.3.");
34 void IdealGasConstPressureReactor::getState(
double* y)
38 "Error: reactor is empty.");
40 m_thermo->restoreState(m_state);
43 y[0] = m_thermo->density() * m_vol;
46 y[1] = m_thermo->temperature();
49 m_thermo->getMassFractions(y+2);
53 getSurfaceInitialConditions(y + m_nsp + 2);
56 void IdealGasConstPressureReactor::initialize(doublereal t0)
58 ConstPressureReactor::initialize(t0);
59 m_hk.resize(m_nsp, 0.0);
62 void IdealGasConstPressureReactor::updateState(doublereal* y)
68 m_thermo->setMassFractions_NoNorm(y+2);
69 m_thermo->setState_TP(y[1], m_pressure);
70 m_vol = m_mass / m_thermo->density();
71 updateSurfaceState(y + m_nsp + 2);
74 m_enthalpy = m_thermo->enthalpy_mass();
75 m_intEnergy = m_thermo->intEnergy_mass();
76 m_thermo->saveState(m_state);
79 void IdealGasConstPressureReactor::evalEqs(doublereal time, doublereal* y,
80 doublereal* ydot, doublereal* params)
84 double* dYdt = ydot + 2;
86 m_thermo->restoreState(m_state);
87 applySensitivity(params);
89 double mdot_surf = evalSurfaces(time, ydot + m_nsp + 2);
92 m_thermo->getPartialMolarEnthalpies(&m_hk[0]);
93 const vector_fp& mw = m_thermo->molecularWeights();
94 const doublereal* Y = m_thermo->massFractions();
97 m_kin->getNetProductionRates(&m_wdot[0]);
103 for (
size_t n = 0; n < m_nsp; n++) {
105 mcpdTdt -= m_wdot[n] * m_hk[n] * m_vol;
106 mcpdTdt -= m_sdot[n] * m_hk[n];
108 dYdt[n] = (m_wdot[n] * m_vol + m_sdot[n]) * mw[n] / m_mass;
110 dYdt[n] -= Y[n] * mdot_surf / m_mass;
114 for (
size_t i = 0; i < m_outlet.size(); i++) {
115 dmdt -= m_outlet[i]->massFlowRate(time);
119 for (
size_t i = 0; i < m_inlet.size(); i++) {
120 double mdot_in = m_inlet[i]->massFlowRate(time);
122 mcpdTdt += m_inlet[i]->enthalpy_mass() * mdot_in;
123 for (
size_t n = 0; n < m_nsp; n++) {
124 double mdot_spec = m_inlet[i]->outletSpeciesMassFlowRate(n);
126 dYdt[n] += (mdot_spec - mdot_in * Y[n]) / m_mass;
127 mcpdTdt -= m_hk[n] / mw[n] * mdot_spec;
133 ydot[1] = mcpdTdt / (m_mass * m_thermo->cp_mass());
138 resetSensitivity(params);
141 size_t IdealGasConstPressureReactor::componentIndex(
const string& nm)
const 143 size_t k = speciesIndex(nm);
146 }
else if (nm ==
"m" || nm ==
"mass") {
149 "Using the name 'm' for mass is deprecated, and will be " 150 "disabled after Cantera 2.3. Use 'mass' instead.");
153 }
else if (nm ==
"T" || nm ==
"temperature") {
156 "Using the name 'T' for temperature is deprecated, and will be " 157 "disabled after Cantera 2.3. Use 'temperature' instead.");
165 std::string IdealGasConstPressureReactor::componentName(
size_t k) {
167 return "temperature";
169 return ConstPressureReactor::componentName(k);
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.