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
11namespace Cantera
12{
13
14//! Adiabatic flow in a constant-area duct with homogeneous and heterogeneous reactions
15//! @ingroup reactorGroup
17{
18public:
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
122 }
123
124 //! Set the steady state tolerances used to determine the initial state for
125 //! surface coverages
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
140protected:
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
167};
168}
169
170#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:84
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:90
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:96
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.
double distance() const
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:78
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.
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:564