Cantera  3.1.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
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
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 //! Sets the area of the reactor [m^2]
66 void setArea(double area);
67
68 //! The ratio of the reactor's surface area to volume ratio [m^-1]
69 //! @note If the surface area to volume ratio is unspecified by the user,
70 //! this will be calculated assuming the reactor is a cylinder.
71 double surfaceAreaToVolumeRatio() const;
72
73 //! Set the reactor's surface area to volume ratio [m^-1]
74 void setSurfaceAreaToVolumeRatio(double sa_to_vol) {
75 m_sa_to_vol = sa_to_vol;
76 }
77
78 //! Get the steady state tolerances used to determine the initial state for
79 //! surface coverages
80 double inletSurfaceAtol() const {
81 return m_ss_atol;
82 }
83
84 //! Set the steady state tolerances used to determine the initial state for
85 //! surface coverages
86 void setInletSurfaceAtol(double atol) {
87 m_ss_atol = atol;
88 }
89
90 //! Get the steady state tolerances used to determine the initial state for
91 //! surface coverages
92 double inletSurfaceRtol() const {
93 return m_ss_rtol;
94 }
95
96 //! Set the steady state tolerances used to determine the initial state for
97 //! surface coverages
98 void setInletSurfaceRtol(double rtol) {
99 m_ss_rtol = rtol;
100 }
101
102 //! Get the steady state tolerances used to determine the initial state for
103 //! surface coverages
104 double inletSurfaceMaxSteps() const {
105 return m_max_ss_steps;
106 }
107
108 //! Set the steady state tolerances used to determine the initial state for
109 //! surface coverages
110 void setInletSurfaceMaxSteps(int max_steps) {
111 m_max_ss_steps = max_steps;
112 }
113
114 //! Get the steady state tolerances used to determine the initial state for
115 //! surface coverages
118 }
119
120 //! Set the steady state tolerances used to determine the initial state for
121 //! surface coverages
123 m_max_ss_error_fails = max_fails;
124 }
125
126 //! Return the index in the solution vector for this reactor of the component named
127 //! *nm*. Possible values for *nm* are "density", "speed", "pressure",
128 //! "temperature", the name of a homogeneous phase species, or the name of a surface
129 //! species.
130 size_t componentIndex(const string& nm) const override;
131
132 string componentName(size_t k) override;
133
134 void updateSurfaceState(double* y) override;
135
136protected:
137 //! Density [kg/m^3]. First component of the state vector.
138 double m_rho = NAN;
139 //! Axial velocity [m/s]. Second component of the state vector.
140 double m_u = -1.0;
141 //! Pressure [Pa]. Third component of the state vector.
142 double m_P = NAN;
143 //! Temperature [K]. Fourth component of the state vector.
144 double m_T = NAN;
145 //! offset to the species equations
146 const size_t m_offset_Y = 4;
147 //! reactor area [m^2]
148 double m_area = 1.0;
149 //! reactor surface area to volume ratio [m^-1]
150 double m_sa_to_vol = -1.0;
151 //! temporary storage for surface species production rates
152 vector<double> m_sdot_temp;
153 //! temporary storage for species partial molar enthalpies
154 vector<double> m_hk;
155 //! steady-state relative tolerance, used to determine initial surface coverages
156 double m_ss_rtol = 1e-7;
157 //! steady-state absolute tolerance, used to determine initial surface coverages
158 double m_ss_atol = 1e-14;
159 //! maximum number of steady-state coverage integrator-steps
160 int m_max_ss_steps = 20000;
161 //! maximum number of steady-state integrator error test failures
163};
164}
165
166#endif
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:80
vector< double > m_sdot_temp
temporary storage for surface species production rates
void setInletSurfaceAtol(double atol)
Set the steady state tolerances used to determine the initial state for surface coverages.
Definition FlowReactor.h:86
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 area() const
The cross-sectional area of the reactor [m^2].
Definition FlowReactor.h:61
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
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:56
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.
Definition FlowReactor.h:92
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:74
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.
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 correspond to the state of 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.
Definition FlowReactor.h:98
void initialize(double t0=0.0) override
Initialize the reactor.
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
void setArea(double area)
Sets the area of the reactor [m^2].
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