20FlowReactor::FlowReactor(shared_ptr<Solution> sol,
const string& name)
25FlowReactor::FlowReactor(shared_ptr<Solution> sol,
bool clone,
const string& name)
26 : IdealGasReactor(sol, clone, name)
29 m_rho = m_thermo->density();
38 auto mw = m_thermo->molecularWeights();
41 y[0] = m_thermo->density();
45 "Set mass flow rate before initializing reactor");
52 y[2] = m_thermo->pressure();
55 y[3] = m_thermo->temperature();
65 std::fill(ydot.begin(), ydot.end(), 0.0);
79 a(0, 0) = -
GasConstant * m_thermo->temperature() / m_thermo->meanMolecularWeight();
82 for (
size_t i = 0; i <
m_nsp; ++i) {
96 double cp_mass = m_thermo->cp_mass();
100 for (
size_t i = 0; i <
m_nsp; ++i) {
108 for (
size_t i = 0; i <
m_nsp; ++i) {
121 ydot[2] = -
m_u * h_sk_wk;
131 m_thermo->getPartialMolarEnthalpies(
m_hk);
132 for (
size_t i = 0; i <
m_nsp; ++i) {
141 for (
size_t i = 0; i <
m_nsp; ++i) {
147 solve(a, ydot, 1, 0);
156 m_thermo->setState_TP(y[3], y[2]);
161 m_rho = m_thermo->density();
172 span<const double> ydot, span<double> residual)
175 auto mw = m_thermo->molecularWeights();
177 for (
size_t i = 0; i <
m_nsp; ++i) {
180 m_thermo->getPartialMolarEnthalpies(
m_hk);
187 double drhodz = ydot[0];
188 double dudz = ydot[1];
189 double dPdz = ydot[2];
190 double dTdz = ydot[3];
193 residual[0] =
m_rho - m_thermo->density();
197 residual[1] =
m_u * drhodz +
m_rho * dudz - sk_wk;
202 residual[2] =
m_rho *
m_u * dudz +
m_u * sk_wk + dPdz;
212 double cp_mass = m_thermo->cp_mass();
213 residual[3] =
m_rho *
m_u * cp_mass * dTdz;
214 for (
size_t i = 0; i <
m_nsp; ++i) {
224 for (
size_t i = 0; i <
m_nsp; ++i) {
235 for (
size_t i = 0; i <
m_nsp; ++i) {
242 std::fill(constraints.begin(), constraints.end(), 1.0);
247 if (nm ==
"density") {
249 }
else if (nm ==
"speed") {
251 }
else if (nm ==
"pressure") {
253 }
else if (nm ==
"temperature") {
257 return m_thermo->speciesIndex(nm) +
m_offset_Y;
260 "Component '{}' not found", nm);
273 return "temperature";
274 }
else if (k >= 4 && k <
neq()) {
275 return m_thermo->speciesName(k - 4);
277 throw IndexError(
"FlowReactor::componentName",
"component", k,
m_nv);
Headers for the DenseMatrix object, which deals with dense rectangular matrices and description of th...
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 class ThermoPhase, the base class for phases with thermodynamic properties,...
Base class for exceptions thrown by Cantera classes.
A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operat...
Adiabatic flow in a constant-area duct with homogeneous and heterogeneous reactions.
double m_area
reactor area [m^2]
double area() const override
The cross-sectional area of the reactor [m²].
const size_t m_offset_Y
offset to the species equations
void setMassFlowRate(double mdot)
Set the mass flow rate through the reactor [kg/s].
double m_u
Axial velocity [m/s]. Second component of the state vector.
size_t componentIndex(const string &nm) const override
Return the index in the solution vector for this reactor of the component named nm.
void getConstraints(span< double > constraints) override
Given a vector of length neq(), mark which variables should be considered algebraic constraints.
void evalDae(double t, span< const double > y, span< const double > ydot, span< double > residual) override
Evaluate the reactor governing equations.
double m_rho
Density [kg/m^3]. First component of the state vector.
string componentName(size_t k) override
Return the name of the solution component with index i.
void setArea(double area) override
Sets the area of the reactor [m²].
void updateState(span< const double > y) override
Set the state of the reactor to correspond to the state vector y.
vector< double > m_hk
temporary storage for species partial molar enthalpies
void getStateDae(span< double > y, span< double > ydot) override
Get the current state and derivative vector of the reactor for a DAE solver.
An array index is out of range.
size_t neq()
Number of equations (state variables) for this reactor.
size_t m_nv
Number of state variables for this reactor.
size_t m_nsp
Number of homogeneous species in the mixture.
Kinetics * m_kin
Pointer to the homogeneous Kinetics object that handles the reactions.
vector< double > m_wdot
Species net molar production rates.
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].
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
void solve(DenseMatrix &A, span< double > b, size_t nrhs, size_t ldb)
Solve Ax = b. Array b is overwritten on exit with x.