21 "Error: reactor is empty.");
23 m_thermo->restoreState(m_state);
26 y[0] = m_thermo->density() *
m_vol;
29 y[1] = m_thermo->enthalpy_mass() * m_thermo->density() *
m_vol;
32 m_thermo->getMassFractions(y+2);
51 m_thermo->setMassFractions_NoNorm(y+2);
64 double& dmdt = RHS[0];
65 double* mdYdt = RHS + 2;
71 m_thermo->restoreState(m_state);
72 const vector<double>& mw = m_thermo->molecularWeights();
73 const double* Y = m_thermo->massFractions();
83 for (
size_t k = 0; k <
m_nsp; k++) {
87 mdYdt[k] -= Y[k] * mdot_surf;
96 for (
auto outlet : m_outlet) {
97 double mdot =
outlet->massFlowRate();
103 for (
auto inlet : m_inlet) {
104 double mdot =
inlet->massFlowRate();
106 for (
size_t n = 0; n <
m_nsp; n++) {
107 double mdot_spec =
inlet->outletSpeciesMassFlowRate(n);
109 mdYdt[n] += mdot_spec - mdot * Y[n];
111 dHdt += mdot *
inlet->enthalpy_mass();
123 throw CanteraError(
"ConstPressureReactor::steadyConstraints",
124 "Steady state solver cannot currently be used with ConstPressureReactor"
125 " when reactor surfaces are present.\n"
126 "See https://github.com/Cantera/enhancements/issues/234");
136 if (nm ==
"enthalpy") {
142 throw CanteraError(
"ConstPressureReactor::componentIndex",
143 "Component '{}' not found", nm);
152 }
else if (k >= 2 && k <
neq()) {
154 if (k < m_thermo->nSpecies()) {
155 return m_thermo->speciesName(k);
157 k -= m_thermo->nSpecies();
159 for (
auto& S : m_surfaces) {
161 if (k < th->nSpecies()) {
168 throw IndexError(
"ConstPressureReactor::componentName",
"component", k, m_nv);
176 }
else if (k >= 2 && k < m_nv) {
180 "Index {} is out of bounds.", k);
189 }
else if (k >= 2 && k < m_nv) {
193 "Index {} is out of bounds.", k);
198 for (
size_t k = 2; k < m_nv; k++) {
199 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.
double upperBound(size_t k) const override
Get the upper bound on the k-th component of the local state vector.
void resetBadValues(double *y) override
Reset physically or mathematically problematic values, such as negative species concentrations.
vector< size_t > steadyConstraints() const override
Get the indices of equations that are algebraic constraints when solving the steady-state problem.
void eval(double t, double *LHS, double *RHS) override
Evaluate the reactor governing equations.
size_t componentIndex(const string &nm) const override
Return the index in the solution vector for this reactor of the component named nm.
void getState(double *y) override
Get the the current state of the reactor.
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(double *y) override
Set the state of the reactor to correspond to the state vector y.
void initialize(double t0=0.0) override
Initialize the reactor.
An array index is out of range.
size_t nSpecies() const
Returns the number of species in the phase.
string speciesName(size_t k) const
Name of the species with index k.
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].
virtual size_t nSurfs() const
Return the number of surfaces in a 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 evalSurfaces(double *LHS, double *RHS, double *sdot)
Evaluate terms related to surface reactions.
virtual void updateSurfaceState(double *y)
Update the state of SurfPhase objects attached to this reactor.
Kinetics * m_kin
Pointer to the homogeneous Kinetics object that handles the reactions.
vector< double > m_wdot
Species net molar production rates.
virtual void evalWalls(double t)
Evaluate terms related to Walls.
size_t neq()
Number of equations (state variables) for this reactor.
double m_Qdot
net heat transfer into the reactor, through walls [W]
vector< double > m_sdot
Production rates of gas phase species on surfaces [kmol/s].
virtual void getSurfaceInitialConditions(double *y)
Get initial conditions for SurfPhase objects attached to this reactor.
void initialize(double t0=0.0) override
Initialize the reactor.
virtual size_t speciesIndex(const string &nm) const
Return the index in the solution vector for this reactor of the species named nm, in either the homog...
virtual void updateConnected(bool updatePressure)
Update the state information needed by connected reactors, flow devices, and reactor walls.
Base class for a phase with thermodynamic properties.
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...