20 "Error: reactor is empty.");
22 m_thermo->restoreState(m_state);
32 y[2] = m_thermo->temperature();
35 m_thermo->getMassFractions(y+3);
46 if (m_thermo->type() !=
"ideal-gas") {
48 "Incompatible phase type '{}' provided", m_thermo->type());
61 m_thermo->setMassFractions_NoNorm(y+3);
69 double& dmdt = RHS[0];
70 double& mcvdTdt = RHS[2];
71 double* mdYdt = RHS + 3;
74 m_thermo->restoreState(m_state);
75 m_thermo->getPartialMolarIntEnergies(&
m_uk[0]);
76 const vector<double>& mw = m_thermo->molecularWeights();
77 const double* Y = m_thermo->massFractions();
90 for (
size_t n = 0; n <
m_nsp; n++) {
97 mdYdt[n] -= Y[n] * mdot_surf;
103 for (
auto outlet : m_outlet) {
104 double mdot =
outlet->massFlowRate();
110 for (
auto inlet : m_inlet) {
111 double mdot =
inlet->massFlowRate();
113 mcvdTdt +=
inlet->enthalpy_mass() * mdot;
114 for (
size_t n = 0; n <
m_nsp; n++) {
115 double mdot_spec =
inlet->outletSpeciesMassFlowRate(n);
117 mdYdt[n] += mdot_spec - mdot * Y[n];
121 mcvdTdt -=
m_uk[n] / mw[n] * mdot_spec;
127 LHS[2] =
m_mass * m_thermo->cv_mass();
136 throw CanteraError(
"IdealGasReactor::steadyConstraints",
137 "Steady state solver cannot currently be used with IdealGasReactor"
138 " when reactor surfaces are present.\n"
139 "See https://github.com/Cantera/enhancements/issues/234");
153 if (nm ==
"volume") {
156 if (nm ==
"temperature") {
163 "Component '{}' not found", nm);
169 return "temperature";
178 return 1.5 * m_thermo->maxTemp();
187 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,...
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.
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.
vector< double > m_uk
Species molar internal energies.
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.
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 double lowerBound(size_t k) const
Get the lower bound on the k-th component of the local state vector.
virtual string componentName(size_t k)
Return the name of the solution component with index i.
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]
virtual double upperBound(size_t k) const
Get the upper bound on the k-th component of the local state vector.
vector< double > m_sdot
Production rates of gas phase species on surfaces [kmol/s].
double m_vdot
net rate of volume change from moving walls [m^3/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.
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...