6#include "cantera/zeroD/IdealGasConstPressureReactor.h"
19 throw CanteraError(
"IdealGasConstPressureReactor::getState",
20 "Error: reactor is empty.");
22 m_thermo->restoreState(m_state);
25 y[0] = m_thermo->density() *
m_vol;
28 y[1] = m_thermo->temperature();
31 m_thermo->getMassFractions(y+2);
42 if (m_thermo->type() !=
"ideal-gas") {
43 throw CanteraError(
"IdealGasConstPressureReactor::initialize",
44 "Incompatible phase type '{}' provided", m_thermo->type());
55 m_thermo->setMassFractions_NoNorm(y+2);
64 double& dmdt = RHS[0];
65 double& mcpdTdt = RHS[1];
66 double* mdYdt = RHS + 2;
73 m_thermo->restoreState(m_state);
74 const vector<double>& mw = m_thermo->molecularWeights();
75 const double* Y = m_thermo->massFractions();
81 m_thermo->getPartialMolarEnthalpies(&
m_hk[0]);
90 for (
size_t n = 0; n <
m_nsp; n++) {
97 mdYdt[n] -= Y[n] * mdot_surf;
103 for (
auto outlet : m_outlet) {
104 dmdt -=
outlet->massFlowRate();
108 for (
auto inlet : m_inlet) {
109 double mdot =
inlet->massFlowRate();
111 mcpdTdt +=
inlet->enthalpy_mass() * mdot;
112 for (
size_t n = 0; n <
m_nsp; n++) {
113 double mdot_spec =
inlet->outletSpeciesMassFlowRate(n);
115 mdYdt[n] += mdot_spec - mdot * Y[n];
116 mcpdTdt -=
m_hk[n] / mw[n] * mdot_spec;
121 LHS[1] =
m_mass * m_thermo->cp_mass();
130 throw CanteraError(
"IdealGasConstPressureReactor::steadyConstraints",
131 "Steady state solver cannot currently be used with "
132 " IdealGasConstPressureReactor when reactor surfaces are present.\n"
133 "See https://github.com/Cantera/enhancements/issues/234");
147 if (nm ==
"temperature") {
153 throw CanteraError(
"IdealGasConstPressureReactor::componentIndex",
154 "Component '{}' not found", nm);
160 return "temperature";
170 return 1.5 * m_thermo->maxTemp();
180 return 0.5 * m_thermo->minTemp();
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
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.
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 initialize(double t0=0.0) override
Initialize the reactor.
double upperBound(size_t k) const override
Get the upper bound on the k-th component of the local state vector.
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.
vector< double > m_hk
Species molar enthalpies.
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.
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.
bool energyEnabled() const override
Returns true if solution of the energy equation is enabled.
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.
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.
double dot(InputIter x_begin, InputIter x_end, InputIter2 y_begin)
Function that calculates a templated inner product.
Namespace for the Cantera kernel.
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...