18ConstPressureMoleReactor::ConstPressureMoleReactor(shared_ptr<Solution> sol,
24ConstPressureMoleReactor::ConstPressureMoleReactor(shared_ptr<Solution> sol,
bool clone,
26 : MoleReactor(sol, clone, name)
36 y[0] = m_thermo->enthalpy_mass() * m_thermo->density() *
m_vol;
47 m_thermo->setMolesNoTruncate(y.subspan(m_sidx,
m_nsp));
59 auto dndt = RHS.subspan(m_sidx);
64 auto imw = m_thermo->inverseMolecularWeights();
74 dHdt += m_thermo->intrinsicHeating() *
m_vol;
77 for (
size_t n = 0; n <
m_nsp; n++) {
83 for (
auto outlet : m_outlet) {
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];
123 if (nm ==
"enthalpy") {
127 return m_thermo->speciesIndex(nm) + m_sidx;
129 throw CanteraError(
"ConstPressureMoleReactor::componentIndex",
130 "Component '{}' not found", nm);
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);
153 }
else if (k >= 1 && k <
m_nv) {
156 throw CanteraError(
"ConstPressureMoleReactor::lowerBound",
"Index {} is out of bounds.", k);
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.
ConstPressureMoleReactor is a class for constant-pressure reactors which use a state of moles.
double upperBound(size_t k) const override
Get the upper bound on the k-th component of the local state vector.
void resetBadValues(span< double > y) override
Reset physically or mathematically problematic values, such as negative species concentrations.
void eval(double t, span< double > LHS, span< double > RHS) override
Evaluate the reactor governing equations.
void evalSteady(double t, span< double > LHS, span< double > RHS) override
Evaluate the governing equations with modifications for the steady-state solver.
size_t componentIndex(const string &nm) const override
Return the index in the solution vector for this reactor of the component named nm.
double m_initialMass
Initial mass [kg]; used for steady-state calculations.
vector< size_t > initializeSteady() override
Initialize the reactor before solving a steady-state problem.
double lowerBound(size_t k) const override
Get the lower bound on the k-th component of the local state vector.
string componentName(size_t k) override
Return the name of the solution component with index i.
void updateState(span< const double > y) override
Set the state of the reactor to correspond to the state vector y.
void getState(span< double > y) override
Get the current state of the reactor.
An array index is out of range.
void getMoles(span< double > y)
Get moles of the system from mass fractions stored by thermo object.
void setMassFromMoles(span< const double > y)
Set internal mass variable based on moles given.
FlowDevice & outlet(size_t n=0)
Return a reference to the n-th outlet FlowDevice connected to this reactor.
double m_pressure
Current pressure in the reactor [Pa].
size_t neq()
Number of equations (state variables) for this reactor.
size_t m_nv
Number of state variables for this reactor.
FlowDevice & inlet(size_t n=0)
Return a reference to the n-th inlet FlowDevice connected to this reactor.
double m_vol
Current volume of the reactor [m^3].
double m_mass
Current mass of the reactor [kg].
size_t m_nsp
Number of homogeneous species in the mixture.
double m_enthalpy
Current specific enthalpy of the reactor [J/kg].
virtual void updateConnected(bool updatePressure)
Update state information needed by connected reactors, flow devices, and walls.
void evalWalls(double t) override
Evaluate terms related to Walls.
Kinetics * m_kin
Pointer to the homogeneous Kinetics object that handles the reactions.
vector< double > m_wdot
Species net molar production rates.
double m_Qdot
net heat transfer into the reactor, through walls [W]
void updateSurfaceProductionRates()
Update m_sdot to reflect current production rates of bulk phase species due to reactions on adjacent ...
vector< double > m_sdot
Total production rate of bulk phase species on surfaces [kmol/s].
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...