20 "Incompatible phase type provided");
22 Reactor::setThermoMgr(thermo);
25 void IdealGasReactor::getInitialConditions(
double t0,
size_t leny,
double* y)
28 cout <<
"Error: reactor is empty." << endl;
31 m_thermo->restoreState(m_state);
34 m_mass = m_thermo->density() * m_vol;
41 y[2] = m_thermo->temperature();
44 m_thermo->getMassFractions(y+3);
48 getSurfaceInitialConditions(y + m_nsp + 3);
51 void IdealGasReactor::initialize(doublereal t0)
53 Reactor::initialize(t0);
54 m_uk.resize(m_nsp, 0.0);
57 void IdealGasReactor::updateState(doublereal* y)
59 for (
size_t i = 0; i < m_nv; i++) {
61 "y[" +
int2str(i) +
"] is not finite");
69 m_thermo->setMassFractions_NoNorm(y+3);
70 m_thermo->setState_TR(y[2], m_mass / m_vol);
71 updateSurfaceState(y + m_nsp + 3);
74 m_enthalpy = m_thermo->enthalpy_mass();
75 m_pressure = m_thermo->pressure();
76 m_intEnergy = m_thermo->intEnergy_mass();
77 m_thermo->saveState(m_state);
80 void IdealGasReactor::evalEqs(doublereal time, doublereal* y,
81 doublereal* ydot, doublereal* params)
85 double* dYdt = ydot + 3;
87 m_thermo->restoreState(m_state);
88 applySensitivity(params);
89 m_thermo->getPartialMolarIntEnergies(&m_uk[0]);
90 const vector_fp& mw = m_thermo->molecularWeights();
91 const doublereal* Y = m_thermo->massFractions();
94 m_kin->getNetProductionRates(&m_wdot[0]);
98 double mdot_surf = evalSurfaces(time, ydot + m_nsp + 3);
102 mcvdTdt += - m_pressure * m_vdot - m_Q;
104 for (
size_t n = 0; n < m_nsp; n++) {
106 mcvdTdt -= m_wdot[n] * m_uk[n] * m_vol;
107 mcvdTdt -= m_sdot[n] * m_uk[n];
109 dYdt[n] = (m_wdot[n] * m_vol + m_sdot[n]) * mw[n] / m_mass;
111 dYdt[n] -= Y[n] * mdot_surf / m_mass;
115 for (
size_t i = 0; i < m_outlet.size(); i++) {
116 double mdot_out = m_outlet[i]->massFlowRate(time);
118 mcvdTdt -= mdot_out * m_pressure * m_vol / m_mass;
122 for (
size_t i = 0; i < m_inlet.size(); i++) {
123 double mdot_in = m_inlet[i]->massFlowRate(time);
125 mcvdTdt += m_inlet[i]->enthalpy_mass() * mdot_in;
126 for (
size_t n = 0; n < m_nsp; n++) {
127 double mdot_spec = m_inlet[i]->outletSpeciesMassFlowRate(n);
129 dYdt[n] += (mdot_spec - mdot_in * Y[n]) / m_mass;
133 mcvdTdt -= m_uk[n] / mw[n] * mdot_spec;
140 ydot[2] = mcvdTdt / (m_mass * m_thermo->cv_mass());
145 for (
size_t i = 0; i < m_nv; i++) {
147 "ydot[" +
int2str(i) +
"] is not finite");
150 resetSensitivity(params);
153 size_t IdealGasReactor::componentIndex(
const string& nm)
const
155 size_t k = speciesIndex(nm);
158 }
else if (nm ==
"m" || nm ==
"mass") {
160 }
else if (nm ==
"V" || nm ==
"volume") {
162 }
else if (nm ==
"T" || nm ==
"temperature") {
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Header file for class Wall.
const size_t npos
index returned by functions to indicate "no position"
#define AssertFinite(expr, procedure, message)
Throw an exception if the specified exception is not a finite number.
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: