Cantera  3.2.0a5
Loading...
Searching...
No Matches
FlowReactor.h
Go to the documentation of this file.
1//! @file FlowReactor.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_FLOWREACTOR_H
7#define CT_FLOWREACTOR_H
8
9#include "IdealGasReactor.h"
10
11namespace Cantera
12{
13
14//! Adiabatic flow in a constant-area duct with homogeneous and heterogeneous reactions
15//! @ingroup reactorGroup
17{
18public:
19 using IdealGasReactor::IdealGasReactor; // inherit constructors
20
21 string type() const override {
22 return "FlowReactor";
23 }
24
25 bool isOde() const override {
26 return false;
27 }
28
29 bool timeIsIndependent() const override {
30 return false;
31 }
32
33 //! Not implemented; FlowReactor implements getStateDae() instead.
34 void getState(double* y) override {
35 throw NotImplementedError("FlowReactor::getState");
36 }
37
38 void getStateDae(double* y, double* ydot) override;
39 void initialize(double t0=0.0) override;
40 void syncState() override;
41 void updateState(double* y) override;
42
43 //! Not implemented; FlowReactor implements evalDae() instead.
44 void eval(double t, double* LHS, double* RHS) override {
45 throw NotImplementedError("FlowReactor::eval");
46 }
47
48 void evalDae(double t, double* y, double* ydot, double* residual) override;
49
50 void getConstraints(double* constraints) override;
51 vector<size_t> steadyConstraints() const override {
52 throw CanteraError("FlowReactor::steadyConstraints",
53 "FlowReactor is not compatible with time-dependent steady-state solver.");
54 }
55
56 //! Mass flow rate through the reactor [kg/s]
57 double massFlowRate() {
58 return m_u * m_rho * m_area;
59 }
60
61 //! Set the mass flow rate through the reactor [kg/s]
62 void setMassFlowRate(double mdot);
63
64 //! The current gas speed in the reactor [m/s]
65 double speed() const {
66 return m_u;
67 }
68
69 //! The cross-sectional area of the reactor [m²]
70 double area() const override {
71 return m_area;
72 }
73
74 //! Sets the area of the reactor [m²]
75 void setArea(double area) override;
76
77 //! The ratio of the reactor's surface area to volume ratio [m^-1]
78 //! @note If the surface area to volume ratio is unspecified by the user,
79 //! this will be calculated assuming the reactor is a cylinder.
80 double surfaceAreaToVolumeRatio() const;
81
82 //! Set the reactor's surface area to volume ratio [m^-1]
83 void setSurfaceAreaToVolumeRatio(double sa_to_vol) {
84 m_sa_to_vol = sa_to_vol;
85 }
86
87 //! Get the steady state tolerances used to determine the initial state for
88 //! surface coverages
89 double inletSurfaceAtol() const {
90 return m_ss_atol;
91 }
92
93 //! Set the steady state tolerances used to determine the initial state for
94 //! surface coverages
95 void setInletSurfaceAtol(double atol) {
96 m_ss_atol = atol;
97 }
98
99 //! Get the steady state tolerances used to determine the initial state for
100 //! surface coverages
101 double inletSurfaceRtol() const {
102 return m_ss_rtol;
103 }
104
105 //! Set the steady state tolerances used to determine the initial state for
106 //! surface coverages
107 void setInletSurfaceRtol(double rtol) {
108 m_ss_rtol = rtol;
109 }
110
111 //! Get the steady state tolerances used to determine the initial state for
112 //! surface coverages
113 double inletSurfaceMaxSteps() const {
114 return m_max_ss_steps;
115 }
116
117 //! Set the steady state tolerances used to determine the initial state for
118 //! surface coverages
119 void setInletSurfaceMaxSteps(int max_steps) {
120 m_max_ss_steps = max_steps;
121 }
122
123 //! Get the steady state tolerances used to determine the initial state for
124 //! surface coverages
127 }
128
129 //! Set the steady state tolerances used to determine the initial state for
130 //! surface coverages
132 m_max_ss_error_fails = max_fails;
133 }
134
135 //! Return the index in the solution vector for this reactor of the component named
136 //! *nm*. Possible values for *nm* are "density", "speed", "pressure",
137 //! "temperature", the name of a homogeneous phase species, or the name of a surface
138 //! species.
139 size_t componentIndex(const string& nm) const override;
140
141 string componentName(size_t k) override;
142
143 void updateSurfaceState(double* y) override;
144
145protected:
146 //! Density [kg/m^3]. First component of the state vector.
147 double m_rho = NAN;
148 //! Axial velocity [m/s]. Second component of the state vector.
149 double m_u = -1.0;
150 //! Pressure [Pa]. Third component of the state vector.
151 double m_P = NAN;
152 //! Temperature [K]. Fourth component of the state vector.
153 double m_T = NAN;
154 //! offset to the species equations
155 const size_t m_offset_Y = 4;
156 //! reactor area [m^2]
157 double m_area = 1.0;
158 //! reactor surface area to volume ratio [m^-1]
159 double m_sa_to_vol = -1.0;
160 //! temporary storage for surface species production rates
161 vector<double> m_sdot_temp;
162 //! temporary storage for species partial molar enthalpies
163 vector<double> m_hk;
164 //! steady-state relative tolerance, used to determine initial surface coverages
165 double m_ss_rtol = 1e-7;
166 //! steady-state absolute tolerance, used to determine initial surface coverages
167 double m_ss_atol = 1e-14;
168 //! maximum number of steady-state coverage integrator-steps
169 int m_max_ss_steps = 20000;
170 //! maximum number of steady-state integrator error test failures
172};
173}
174
175#endif
Base class for exceptions thrown by Cantera classes.
Adiabatic flow in a constant-area duct with homogeneous and heterogeneous reactions.
Definition FlowReactor.h:17
double m_area
reactor area [m^2]
double inletSurfaceAtol() const
Get the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:89
vector< double > m_sdot_temp
temporary storage for surface species production rates
double area() const override
The cross-sectional area of the reactor [m²].
Definition FlowReactor.h:70
void setInletSurfaceAtol(double atol)
Set the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:95
const size_t m_offset_Y
offset to the species equations
bool isOde() const override
Indicate whether the governing equations for this reactor type are a system of ODEs or DAEs.
Definition FlowReactor.h:25
double surfaceAreaToVolumeRatio() const
The ratio of the reactor's surface area to volume ratio [m^-1].
void setMassFlowRate(double mdot)
Set the mass flow rate through the reactor [kg/s].
double inletSurfaceMaxSteps() const
Get the steady state tolerances used to determine the initial state for surface coverages.
double m_ss_rtol
steady-state relative tolerance, used to determine initial surface coverages
double inletSurfaceMaxErrorFailures() const
Get the steady state tolerances used to determine the initial state for surface coverages.
int m_max_ss_error_fails
maximum number of steady-state integrator error test failures
void setInletSurfaceMaxErrorFailures(int max_fails)
Set the steady state tolerances used to determine the initial state for surface coverages.
void getConstraints(double *constraints) override
Given a vector of length neq(), mark which variables should be considered algebraic constraints.
bool timeIsIndependent() const override
Indicates whether the governing equations for this reactor are functions of time or a spatial variabl...
Definition FlowReactor.h:29
vector< size_t > steadyConstraints() const override
Get the indices of equations that are algebraic constraints when solving the steady-state problem.
Definition FlowReactor.h:51
void eval(double t, double *LHS, double *RHS) override
Not implemented; FlowReactor implements evalDae() instead.
Definition FlowReactor.h:44
double speed() const
The current gas speed in the reactor [m/s].
Definition FlowReactor.h:65
string type() const override
String indicating the reactor model implemented.
Definition FlowReactor.h:21
double inletSurfaceRtol() const
Get the steady state tolerances used to determine the initial state for surface coverages.
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 getStateDae(double *y, double *ydot) override
Get the current state and derivative vector of the reactor for a DAE solver.
void setSurfaceAreaToVolumeRatio(double sa_to_vol)
Set the reactor's surface area to volume ratio [m^-1].
Definition FlowReactor.h:83
int m_max_ss_steps
maximum number of steady-state coverage integrator-steps
void setInletSurfaceMaxSteps(int max_steps)
Set the steady state tolerances used to determine the initial state for surface coverages.
double massFlowRate()
Mass flow rate through the reactor [kg/s].
Definition FlowReactor.h:57
void getState(double *y) override
Not implemented; FlowReactor implements getStateDae() instead.
Definition FlowReactor.h:34
double m_rho
Density [kg/m^3]. First component of the state vector.
void evalDae(double t, double *y, double *ydot, double *residual) override
Evaluate the reactor governing equations.
string componentName(size_t k) override
Return the name of the solution component with index i.
void syncState() override
Set the state of the reactor to the associated ThermoPhase object.
void updateState(double *y) override
Set the state of the reactor to correspond to the state vector y.
void setInletSurfaceRtol(double rtol)
Set the steady state tolerances used to determine the initial state for surface coverages.
void initialize(double t0=0.0) override
Initialize the reactor.
void setArea(double area) override
Sets the area of the reactor [m²].
void updateSurfaceState(double *y) override
Update the state of SurfPhase objects attached to this reactor.
double m_P
Pressure [Pa]. Third component of the state vector.
double m_T
Temperature [K]. Fourth component of the state vector.
double m_sa_to_vol
reactor surface area to volume ratio [m^-1]
double m_ss_atol
steady-state absolute tolerance, used to determine initial surface coverages
vector< double > m_hk
temporary storage for species partial molar enthalpies
Class IdealGasReactor is a class for stirred reactors that is specifically optimized for ideal gases.
An error indicating that an unimplemented function has been called.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595