17ConstPressureReactor::ConstPressureReactor(shared_ptr<Solution> sol,
19 : ConstPressureReactor(sol, true, name)
23ConstPressureReactor::ConstPressureReactor(shared_ptr<Solution> sol,
bool clone,
25 : Reactor(sol, clone, name)
30void ConstPressureReactor::getState(
double* y)
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);
43void ConstPressureReactor::updateState(
double* y)
49 m_thermo->setMassFractions_NoNorm(y+2);
51 m_thermo->setState_HP(y[1]/m_mass, m_pressure);
53 m_thermo->setPressure(m_pressure);
55 m_vol = m_mass / m_thermo->density();
56 updateConnected(
false);
59void ConstPressureReactor::eval(
double time,
double* LHS,
double* RHS)
61 double& dmdt = RHS[0];
62 double* mdYdt = RHS + 2;
67 updateSurfaceProductionRates();
69 const vector<double>& mw = m_thermo->molecularWeights();
70 const double* Y = m_thermo->massFractions();
71 double mdot_surf =
dot(m_sdot.begin(), m_sdot.end(), mw.begin());
75 m_kin->getNetProductionRates(&m_wdot[0]);
78 for (
size_t k = 0; k < m_nsp; k++) {
80 mdYdt[k] = (m_wdot[k] * m_vol + m_sdot[k]) * mw[k];
82 mdYdt[k] -= Y[k] * mdot_surf;
91 dHdt += m_thermo->intrinsicHeating() * m_vol;
95 for (
auto outlet : m_outlet) {
96 double mdot = outlet->massFlowRate();
98 dHdt -= mdot * m_enthalpy;
102 for (
auto inlet : m_inlet) {
103 double mdot = inlet->massFlowRate();
105 for (
size_t n = 0; n < m_nsp; n++) {
106 double mdot_spec = inlet->outletSpeciesMassFlowRate(n);
108 mdYdt[n] += mdot_spec - mdot * Y[n];
110 dHdt += mdot * inlet->enthalpy_mass();
120void ConstPressureReactor::evalSteady(
double t,
double* LHS,
double* RHS)
123 RHS[0] = m_mass - m_initialMass;
126vector<size_t> ConstPressureReactor::initializeSteady()
128 m_initialMass = m_mass;
132size_t ConstPressureReactor::componentIndex(
const string& nm)
const
137 if (nm ==
"enthalpy") {
141 return m_thermo->speciesIndex(nm) + 2;
143 throw CanteraError(
"ConstPressureReactor::componentIndex",
144 "Component '{}' not found", nm);
148string ConstPressureReactor::componentName(
size_t k) {
153 }
else if (k >= 2 && k < neq()) {
154 return m_thermo->speciesName(k - 2);
156 throw IndexError(
"ConstPressureReactor::componentName",
"component", k, m_nv);
159double ConstPressureReactor::upperBound(
size_t k)
const {
164 }
else if (k >= 2 && k < m_nv) {
168 "Index {} is out of bounds.", k);
172double ConstPressureReactor::lowerBound(
size_t k)
const {
177 }
else if (k >= 2 && k < m_nv) {
181 "Index {} is out of bounds.", k);
185void ConstPressureReactor::resetBadValues(
double* y) {
186 for (
size_t k = 2; k < m_nv; k++) {
187 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.
double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
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...