18ConstPressureMoleReactor::ConstPressureMoleReactor(shared_ptr<Solution> sol,
20 : ConstPressureMoleReactor(sol, true, name)
24ConstPressureMoleReactor::ConstPressureMoleReactor(shared_ptr<Solution> sol,
bool clone,
26 : MoleReactor(sol, clone, name)
31void ConstPressureMoleReactor::getState(
double* y)
34 m_mass = m_thermo->density() * m_vol;
36 y[0] = m_thermo->enthalpy_mass() * m_thermo->density() * m_vol;
41void ConstPressureMoleReactor::updateState(
double* y)
46 setMassFromMoles(y + m_sidx);
47 m_thermo->setMolesNoTruncate(y + m_sidx);
49 m_thermo->setState_HP(y[0] / m_mass, m_pressure);
51 m_thermo->setPressure(m_pressure);
53 m_vol = m_mass / m_thermo->density();
54 updateConnected(
false);
57void ConstPressureMoleReactor::eval(
double time,
double* LHS,
double* RHS)
59 double* dndt = RHS + m_sidx;
62 updateSurfaceProductionRates();
64 const vector<double>& imw = m_thermo->inverseMolecularWeights();
67 m_kin->getNetProductionRates(&m_wdot[0]);
74 dHdt += m_thermo->intrinsicHeating() * m_vol;
77 for (
size_t n = 0; n < m_nsp; n++) {
79 dndt[n] = m_wdot[n] * m_vol + m_sdot[n];
83 for (
auto outlet : m_outlet) {
85 dHdt -= outlet->massFlowRate() * m_enthalpy;
87 for (
size_t n = 0; n < m_nsp; n++) {
88 dndt[n] -= outlet->outletSpeciesMassFlowRate(n) * imw[n];
93 for (
auto inlet : m_inlet) {
95 dHdt += inlet->enthalpy_mass() * inlet->massFlowRate();
97 for (
size_t n = 0; n < m_nsp; n++) {
98 dndt[n] += inlet->outletSpeciesMassFlowRate(n) * imw[n];
109void ConstPressureMoleReactor::evalSteady(
double t,
double* LHS,
double* RHS)
112 RHS[1] = m_mass - m_initialMass;
115vector<size_t> ConstPressureMoleReactor::initializeSteady()
117 m_initialMass = m_mass;
121size_t ConstPressureMoleReactor::componentIndex(
const string& nm)
const
123 if (nm ==
"enthalpy") {
127 return m_thermo->speciesIndex(nm) + m_sidx;
129 throw CanteraError(
"ConstPressureMoleReactor::componentIndex",
130 "Component '{}' not found", nm);
134string ConstPressureMoleReactor::componentName(
size_t k) {
137 }
else if (k >= m_sidx && k < neq()) {
138 return m_thermo->speciesName(k - m_sidx);
140 throw IndexError(
"ConstPressureMoleReactor::componentName",
141 "component", k, m_nv);
145double ConstPressureMoleReactor::upperBound(
size_t k)
const {
150double ConstPressureMoleReactor::lowerBound(
size_t k)
const {
153 }
else if (k >= 1 && k < m_nv) {
156 throw CanteraError(
"ConstPressureMoleReactor::lowerBound",
"Index {} is out of bounds.", k);
160void ConstPressureMoleReactor::resetBadValues(
double* y) {
161 for (
size_t k = m_sidx; k < m_nv; k++) {
162 y[k] = std::max(y[k], 0.0);
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header file for class ReactorSurface.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Header file for base class WallBase.
Base class for exceptions thrown by Cantera classes.
An array index is out of range.
Namespace for the Cantera kernel.
const double Tiny
Small number to compare differences of mole fractions against.
const double BigNumber
largest number to compare to inf.
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...