17ConstPressureReactor::ConstPressureReactor(shared_ptr<Solution> sol,
23ConstPressureReactor::ConstPressureReactor(shared_ptr<Solution> sol,
bool clone,
25 : Reactor(sol, clone, name)
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.subspan(2,
m_nsp));
49 m_thermo->setMassFractions_NoNorm(y.subspan(2,
m_nsp));
61 double& dmdt = RHS[0];
62 auto mdYdt = RHS.subspan(2);
69 auto mw = m_thermo->molecularWeights();
70 auto Y = m_thermo->massFractions();
78 for (
size_t k = 0; k <
m_nsp; 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();
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();
137 if (nm ==
"enthalpy") {
141 return m_thermo->speciesIndex(nm) + 2;
143 throw CanteraError(
"ConstPressureReactor::componentIndex",
144 "Component '{}' not found", nm);
153 }
else if (k >= 2 && k <
neq()) {
154 return m_thermo->speciesName(k - 2);
156 throw IndexError(
"ConstPressureReactor::componentName",
"component", k,
m_nv);
164 }
else if (k >= 2 && k <
m_nv) {
168 "Index {} is out of bounds.", k);
177 }
else if (k >= 2 && k <
m_nv) {
181 "Index {} is out of bounds.", k);
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.
Class ConstPressureReactor is a class for constant-pressure reactors.
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.
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].
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...