8 #include "cantera/zeroD/IdealGasConstPressureReactor.h"
16 void IdealGasConstPressureReactor::setThermoMgr(
ThermoPhase& thermo)
22 "Incompatible phase type provided");
24 Reactor::setThermoMgr(thermo);
28 void IdealGasConstPressureReactor::getInitialConditions(
double t0,
size_t leny,
33 "Error: reactor is empty.");
35 m_thermo->restoreState(m_state);
38 y[0] = m_thermo->density() * m_vol;
41 y[1] = m_thermo->temperature();
44 m_thermo->getMassFractions(y+2);
48 getSurfaceInitialConditions(y + m_nsp + 2);
51 void IdealGasConstPressureReactor::initialize(doublereal t0)
53 ConstPressureReactor::initialize(t0);
54 m_hk.resize(m_nsp, 0.0);
57 void IdealGasConstPressureReactor::updateState(doublereal* y)
63 m_thermo->setMassFractions_NoNorm(y+2);
64 m_thermo->setState_TP(y[1], m_pressure);
65 m_vol = m_mass / m_thermo->density();
66 updateSurfaceState(y + m_nsp + 2);
69 m_enthalpy = m_thermo->enthalpy_mass();
70 m_intEnergy = m_thermo->intEnergy_mass();
71 m_thermo->saveState(m_state);
74 void IdealGasConstPressureReactor::evalEqs(doublereal time, doublereal* y,
75 doublereal* ydot, doublereal* params)
79 double* dYdt = ydot + 2;
81 m_thermo->restoreState(m_state);
82 applySensitivity(params);
84 double mdot_surf = evalSurfaces(time, ydot + m_nsp + 2);
87 m_thermo->getPartialMolarEnthalpies(&m_hk[0]);
88 const vector_fp& mw = m_thermo->molecularWeights();
89 const doublereal* Y = m_thermo->massFractions();
92 m_kin->getNetProductionRates(&m_wdot[0]);
98 for (
size_t n = 0; n < m_nsp; n++) {
100 mcpdTdt -= m_wdot[n] * m_hk[n] * m_vol;
101 mcpdTdt -= m_sdot[n] * m_hk[n];
103 dYdt[n] = (m_wdot[n] * m_vol + m_sdot[n]) * mw[n] / m_mass;
105 dYdt[n] -= Y[n] * mdot_surf / m_mass;
109 for (
size_t i = 0; i < m_outlet.size(); i++) {
110 dmdt -= m_outlet[i]->massFlowRate(time);
114 for (
size_t i = 0; i < m_inlet.size(); i++) {
115 double mdot_in = m_inlet[i]->massFlowRate(time);
117 mcpdTdt += m_inlet[i]->enthalpy_mass() * mdot_in;
118 for (
size_t n = 0; n < m_nsp; n++) {
119 double mdot_spec = m_inlet[i]->outletSpeciesMassFlowRate(n);
121 dYdt[n] += (mdot_spec - mdot_in * Y[n]) / m_mass;
122 mcpdTdt -= m_hk[n] / mw[n] * mdot_spec;
128 ydot[1] = mcpdTdt / (m_mass * m_thermo->cp_mass());
133 resetSensitivity(params);
136 size_t IdealGasConstPressureReactor::componentIndex(
const string& nm)
const
138 size_t k = speciesIndex(nm);
141 }
else if (nm ==
"m" || nm ==
"mass") {
143 }
else if (nm ==
"T" || nm ==
"temperature") {
const size_t npos
index returned by functions to indicate "no position"
Base class for a phase with thermodynamic properties.
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.
virtual int eosType() const
Equation of state type flag.
const int cIdealGas
Equation of state types: