| Cantera 3.0.0

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
11 namespace Cantera
12{
13
14//! Adiabatic flow in a constant-area duct with homogeneous and heterogeneous reactions
15//! @ingroup reactorGroup
16 class FlowReactor : public IdealGasReactor
17{
18 public:
19 FlowReactor() = default;
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
52 //! Set the mass flow rate through the reactor [kg/s]
53 void setMassFlowRate(double mdot);
54
55 //! The current gas speed in the reactor [m/s]
56 double speed() const {
57 return m_u;
58 }
59
60 //! The cross-sectional area of the reactor [m^2]
61 double area() const {
62 return m_area;
63 }
64
65 //! @deprecated To be removed after %Cantera 3.0. Access distance through the
66 //! ReactorNet object
67 double distance() const;
68
69 //! Sets the area of the reactor [m^2]
70 void setArea(double area);
71
72 //! The ratio of the reactor's surface area to volume ratio [m^-1]
73 //! @note If the surface area to volume ratio is unspecified by the user,
74 //! this will be calculated assuming the reactor is a cylinder.
75 double surfaceAreaToVolumeRatio() const;
76
77 //! Set the reactor's surface area to volume ratio [m^-1]
78 void setSurfaceAreaToVolumeRatio(double sa_to_vol) {
79 m_sa_to_vol = sa_to_vol;
80 }
81
82 //! Get the steady state tolerances used to determine the initial state for
83 //! surface coverages
84 double inletSurfaceAtol() const {
85 return m_ss_atol;
86 }
87
88 //! Set the steady state tolerances used to determine the initial state for
89 //! surface coverages
90 void setInletSurfaceAtol(double atol) {
91 m_ss_atol = atol;
92 }
93
94 //! Get the steady state tolerances used to determine the initial state for
95 //! surface coverages
96 double inletSurfaceRtol() const {
97 return m_ss_rtol;
98 }
99
100 //! Set the steady state tolerances used to determine the initial state for
101 //! surface coverages
102 void setInletSurfaceRtol(double rtol) {
103 m_ss_rtol = rtol;
104 }
105
106 //! Get the steady state tolerances used to determine the initial state for
107 //! surface coverages
108 double inletSurfaceMaxSteps() const {
109 return m_max_ss_steps;
110 }
111
112 //! Set the steady state tolerances used to determine the initial state for
113 //! surface coverages
114 void setInletSurfaceMaxSteps(int max_steps) {
115 m_max_ss_steps = max_steps;
116 }
117
118 //! Get the steady state tolerances used to determine the initial state for
119 //! surface coverages
120 double inletSurfaceMaxErrorFailures() const {
121 return m_max_ss_error_fails;
122 }
123
124 //! Set the steady state tolerances used to determine the initial state for
125 //! surface coverages
126 void setInletSurfaceMaxErrorFailures(int max_fails) {
127 m_max_ss_error_fails = max_fails;
128 }
129
130 //! Return the index in the solution vector for this reactor of the component named
131 //! *nm*. Possible values for *nm* are "density", "speed", "pressure",
132 //! "temperature", the name of a homogeneous phase species, or the name of a surface
133 //! species.
134 size_t componentIndex(const string& nm) const override;
135
136 string componentName(size_t k) override;
137
138 void updateSurfaceState(double* y) override;
139
140 protected:
141 //! Density [kg/m^3]. First component of the state vector.
142 double m_rho = NAN;
143 //! Axial velocity [m/s]. Second component of the state vector.
144 double m_u = -1.0;
145 //! Pressure [Pa]. Third component of the state vector.
146 double m_P = NAN;
147 //! Temperature [K]. Fourth component of the state vector.
148 double m_T = NAN;
149 //! offset to the species equations
150 const size_t m_offset_Y = 4;
151 //! reactor area [m^2]
152 double m_area = 1.0;
153 //! reactor surface area to volume ratio [m^-1]
154 double m_sa_to_vol = -1.0;
155 //! temporary storage for surface species production rates
156 vector<double> m_sdot_temp;
157 //! temporary storage for species partial molar enthalpies
158 vector<double> m_hk;
159 //! steady-state relative tolerance, used to determine initial surface coverages
160 double m_ss_rtol = 1e-7;
161 //! steady-state absolute tolerance, used to determine initial surface coverages
162 double m_ss_atol = 1e-14;
163 //! maximum number of steady-state coverage integrator-steps
164 int m_max_ss_steps = 20000;
165 //! maximum number of steady-state integrator error test failures
166 int m_max_ss_error_fails = 10;
167};
168}
169
170#endif
IdealGasReactor.h
Cantera::FlowReactor
Adiabatic flow in a constant-area duct with homogeneous and heterogeneous reactions.
Definition FlowReactor.h:17
Cantera::FlowReactor::m_area
double m_area
reactor area [m^2]
Definition FlowReactor.h:152
Cantera::FlowReactor::inletSurfaceAtol
double inletSurfaceAtol() const
Get the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:84
Cantera::FlowReactor::m_sdot_temp
vector< double > m_sdot_temp
temporary storage for surface species production rates
Definition FlowReactor.h:156
Cantera::FlowReactor::setInletSurfaceAtol
void setInletSurfaceAtol(double atol)
Set the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:90
Cantera::FlowReactor::m_offset_Y
const size_t m_offset_Y
offset to the species equations
Definition FlowReactor.h:150
Cantera::FlowReactor::isOde
bool isOde() const override
Indicate whether the governing equations for this reactor type are a system of ODEs or DAEs.
Definition FlowReactor.h:25
Cantera::FlowReactor::area
double area() const
The cross-sectional area of the reactor [m^2].
Definition FlowReactor.h:61
Cantera::FlowReactor::surfaceAreaToVolumeRatio
double surfaceAreaToVolumeRatio() const
The ratio of the reactor's surface area to volume ratio [m^-1].
Definition FlowReactor.cpp:233
Cantera::FlowReactor::setMassFlowRate
void setMassFlowRate(double mdot)
Set the mass flow rate through the reactor [kg/s].
Definition FlowReactor.cpp:210
Cantera::FlowReactor::inletSurfaceMaxSteps
double inletSurfaceMaxSteps() const
Get the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:108
Cantera::FlowReactor::m_ss_rtol
double m_ss_rtol
steady-state relative tolerance, used to determine initial surface coverages
Definition FlowReactor.h:160
Cantera::FlowReactor::inletSurfaceMaxErrorFailures
double inletSurfaceMaxErrorFailures() const
Get the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:120
Cantera::FlowReactor::m_max_ss_error_fails
int m_max_ss_error_fails
maximum number of steady-state integrator error test failures
Definition FlowReactor.h:166
Cantera::FlowReactor::setInletSurfaceMaxErrorFailures
void setInletSurfaceMaxErrorFailures(int max_fails)
Set the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:126
Cantera::FlowReactor::getConstraints
void getConstraints(double *constraints) override
Given a vector of length neq(), mark which variables should be considered algebraic constraints.
Definition FlowReactor.cpp:346
Cantera::FlowReactor::timeIsIndependent
bool timeIsIndependent() const override
Indicates whether the governing equations for this reactor are functions of time or a spatial variabl...
Definition FlowReactor.h:29
Cantera::FlowReactor::eval
void eval(double t, double *LHS, double *RHS) override
Not implemented; FlowReactor implements evalDae() instead.
Definition FlowReactor.h:44
Cantera::FlowReactor::speed
double speed() const
The current gas speed in the reactor [m/s].
Definition FlowReactor.h:56
Cantera::FlowReactor::type
string type() const override
String indicating the reactor model implemented.
Definition FlowReactor.h:21
Cantera::FlowReactor::inletSurfaceRtol
double inletSurfaceRtol() const
Get the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:96
Cantera::FlowReactor::m_u
double m_u
Axial velocity [m/s]. Second component of the state vector.
Definition FlowReactor.h:144
Cantera::FlowReactor::componentIndex
size_t componentIndex(const string &nm) const override
Return the index in the solution vector for this reactor of the component named nm.
Definition FlowReactor.cpp:353
Cantera::FlowReactor::distance
double distance() const
Definition FlowReactor.cpp:216
Cantera::FlowReactor::getStateDae
void getStateDae(double *y, double *ydot) override
Get the current state and derivative vector of the reactor for a DAE solver.
Definition FlowReactor.cpp:20
Cantera::FlowReactor::setSurfaceAreaToVolumeRatio
void setSurfaceAreaToVolumeRatio(double sa_to_vol)
Set the reactor's surface area to volume ratio [m^-1].
Definition FlowReactor.h:78
Cantera::FlowReactor::m_max_ss_steps
int m_max_ss_steps
maximum number of steady-state coverage integrator-steps
Definition FlowReactor.h:164
Cantera::FlowReactor::setInletSurfaceMaxSteps
void setInletSurfaceMaxSteps(int max_steps)
Set the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:114
Cantera::FlowReactor::getState
void getState(double *y) override
Not implemented; FlowReactor implements getStateDAE() instead.
Definition FlowReactor.h:34
Cantera::FlowReactor::m_rho
double m_rho
Density [kg/m^3]. First component of the state vector.
Definition FlowReactor.h:142
Cantera::FlowReactor::evalDae
void evalDae(double t, double *y, double *ydot, double *residual) override
Evaluate the reactor governing equations.
Definition FlowReactor.cpp:257
Cantera::FlowReactor::componentName
string componentName(size_t k) override
Return the name of the solution component with index i.
Definition FlowReactor.cpp:371
Cantera::FlowReactor::syncState
void syncState() override
Set the state of the reactor to correspond to the state of the associated ThermoPhase object.
Definition FlowReactor.cpp:185
Cantera::FlowReactor::updateState
void updateState(double *y) override
Set the state of the reactor to correspond to the state vector y.
Definition FlowReactor.cpp:193
Cantera::FlowReactor::setInletSurfaceRtol
void setInletSurfaceRtol(double rtol)
Set the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:102
Cantera::FlowReactor::initialize
void initialize(double t0=0.0) override
Initialize the reactor.
Definition FlowReactor.cpp:155
Cantera::FlowReactor::updateSurfaceState
void updateSurfaceState(double *y) override
Update the state of SurfPhase objects attached to this reactor.
Definition FlowReactor.cpp:244
Cantera::FlowReactor::m_P
double m_P
Pressure [Pa]. Third component of the state vector.
Definition FlowReactor.h:146
Cantera::FlowReactor::m_T
double m_T
Temperature [K]. Fourth component of the state vector.
Definition FlowReactor.h:148
Cantera::FlowReactor::m_sa_to_vol
double m_sa_to_vol
reactor surface area to volume ratio [m^-1]
Definition FlowReactor.h:154
Cantera::FlowReactor::m_ss_atol
double m_ss_atol
steady-state absolute tolerance, used to determine initial surface coverages
Definition FlowReactor.h:162
Cantera::FlowReactor::m_hk
vector< double > m_hk
temporary storage for species partial molar enthalpies
Definition FlowReactor.h:158
Cantera::FlowReactor::setArea
void setArea(double area)
Sets the area of the reactor [m^2].
Definition FlowReactor.cpp:227
Cantera::IdealGasReactor
Class IdealGasReactor is a class for stirred reactors that is specifically optimized for ideal gases.
Definition IdealGasReactor.h:21
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition ctexceptions.h:195
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564