16 void ConstPressureReactor::getInitialConditions(
double t0,
size_t leny,
20 "Use getState instead. To be removed after Cantera 2.3.");
24 void ConstPressureReactor::getState(
double* y)
28 "Error: reactor is empty.");
30 m_thermo->restoreState(m_state);
33 y[0] = m_thermo->density() * m_vol;
36 y[1] = m_thermo->enthalpy_mass() * m_thermo->density() * m_vol;
39 m_thermo->getMassFractions(y+2);
43 getSurfaceInitialConditions(y + m_nsp + 2);
46 void ConstPressureReactor::initialize(doublereal t0)
48 Reactor::initialize(t0);
52 void ConstPressureReactor::updateState(doublereal* y)
58 m_thermo->setMassFractions_NoNorm(y+2);
60 m_thermo->setState_HP(y[1]/m_mass, m_pressure);
62 m_thermo->setPressure(m_pressure);
64 m_vol = m_mass / m_thermo->density();
65 updateSurfaceState(y + m_nsp + 2);
68 m_enthalpy = m_thermo->enthalpy_mass();
69 m_intEnergy = m_thermo->intEnergy_mass();
70 m_thermo->saveState(m_state);
73 void ConstPressureReactor::evalEqs(doublereal time, doublereal* y,
74 doublereal* ydot, doublereal* params)
77 double* dYdt = ydot + 2;
78 m_thermo->restoreState(m_state);
79 applySensitivity(params);
81 double mdot_surf = evalSurfaces(time, ydot + m_nsp + 2);
84 const vector_fp& mw = m_thermo->molecularWeights();
85 const doublereal* Y = m_thermo->massFractions();
88 m_kin->getNetProductionRates(&m_wdot[0]);
91 for (
size_t k = 0; k < m_nsp; k++) {
93 dYdt[k] = (m_wdot[k] * m_vol + m_sdot[k]) * mw[k] / m_mass;
95 dYdt[k] -= Y[k] * mdot_surf / m_mass;
102 for (
size_t i = 0; i < m_outlet.size(); i++) {
103 double mdot_out = m_outlet[i]->massFlowRate(time);
105 dHdt -= mdot_out * m_enthalpy;
109 for (
size_t i = 0; i < m_inlet.size(); i++) {
110 double mdot_in = m_inlet[i]->massFlowRate(time);
112 for (
size_t n = 0; n < m_nsp; n++) {
113 double mdot_spec = m_inlet[i]->outletSpeciesMassFlowRate(n);
115 dYdt[n] += (mdot_spec - mdot_in * Y[n]) / m_mass;
117 dHdt += mdot_in * m_inlet[i]->enthalpy_mass();
128 resetSensitivity(params);
131 size_t ConstPressureReactor::componentIndex(
const string& nm)
const 133 size_t k = speciesIndex(nm);
136 }
else if (nm ==
"m" || nm ==
"mass") {
139 "Using the name 'm' for mass is deprecated, and will be " 140 "disabled after Cantera 2.3. Use 'mass' instead.");
143 }
else if (nm ==
"H" || nm ==
"enthalpy") {
146 "Using the name 'H' for enthalpy is deprecated, and will be " 147 "disabled after Cantera 2.3. Use 'enthalpy' instead.");
155 std::string ConstPressureReactor::componentName(
size_t k) {
160 }
else if (k >= 2 && k < neq()) {
162 if (k < m_thermo->nSpecies()) {
163 return m_thermo->speciesName(k);
165 k -= m_thermo->nSpecies();
167 for (
auto& S : m_surfaces) {
169 if (k < th->nSpecies()) {
176 throw CanteraError(
"ConstPressureReactor::componentName",
177 "Index is out of bounds.");
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
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.
size_t nSpecies() const
Returns the number of species in the phase.
Base class for a phase with thermodynamic properties.
std::string speciesName(size_t k) const
Name of the species with index k.
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.
Namespace for the Cantera kernel.