19 if (thermo.
type() !=
"IdealGas") {
21 "Incompatible phase type provided");
23 Reactor::setThermoMgr(thermo);
26 void IdealGasReactor::getState(
double* y)
30 "Error: reactor is empty.");
32 m_thermo->restoreState(m_state);
35 m_mass = m_thermo->density() * m_vol;
42 y[2] = m_thermo->temperature();
45 m_thermo->getMassFractions(y+3);
49 getSurfaceInitialConditions(y + m_nsp + 3);
52 void IdealGasReactor::initialize(doublereal t0)
54 Reactor::initialize(t0);
55 m_uk.resize(m_nsp, 0.0);
58 void IdealGasReactor::updateState(doublereal* y)
65 m_thermo->setMassFractions_NoNorm(y+3);
66 m_thermo->setState_TR(y[2], m_mass / m_vol);
67 updateSurfaceState(y + m_nsp + 3);
68 updateConnected(
true);
71 void IdealGasReactor::evalEqs(doublereal time, doublereal* y,
72 doublereal* ydot, doublereal* params)
76 double* dYdt = ydot + 3;
79 applySensitivity(params);
80 m_thermo->restoreState(m_state);
81 m_thermo->getPartialMolarIntEnergies(&m_uk[0]);
82 const vector_fp& mw = m_thermo->molecularWeights();
83 const doublereal* Y = m_thermo->massFractions();
86 m_kin->getNetProductionRates(&m_wdot[0]);
89 double mdot_surf = evalSurfaces(time, ydot + m_nsp + 3);
93 mcvdTdt += - m_pressure * m_vdot - m_Q;
95 for (
size_t n = 0; n < m_nsp; n++) {
97 mcvdTdt -= m_wdot[n] * m_uk[n] * m_vol;
98 mcvdTdt -= m_sdot[n] * m_uk[n];
100 dYdt[n] = (m_wdot[n] * m_vol + m_sdot[n]) * mw[n] / m_mass;
102 dYdt[n] -= Y[n] * mdot_surf / m_mass;
106 for (
auto outlet : m_outlet) {
107 double mdot = outlet->massFlowRate();
109 mcvdTdt -= mdot * m_pressure * m_vol / m_mass;
113 for (
auto inlet : m_inlet) {
114 double mdot = inlet->massFlowRate();
116 mcvdTdt += inlet->enthalpy_mass() * mdot;
117 for (
size_t n = 0; n < m_nsp; n++) {
118 double mdot_spec = inlet->outletSpeciesMassFlowRate(n);
120 dYdt[n] += (mdot_spec - mdot * Y[n]) / m_mass;
124 mcvdTdt -= m_uk[n] / mw[n] * mdot_spec;
131 ydot[2] = mcvdTdt / (m_mass * m_thermo->cv_mass());
136 resetSensitivity(params);
139 size_t IdealGasReactor::componentIndex(
const string& nm)
const
141 size_t k = speciesIndex(nm);
144 }
else if (nm ==
"mass") {
146 }
else if (nm ==
"volume") {
148 }
else if (nm ==
"temperature") {
155 std::string IdealGasReactor::componentName(
size_t k) {
157 return "temperature";
159 return Reactor::componentName(k);
Header file for base class WallBase.
Base class for exceptions thrown by Cantera classes.
Base class for a phase with thermodynamic properties.
virtual std::string type() const
String indicating the thermodynamic model implemented.
const size_t npos
index returned by functions to indicate "no position"
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.