Cantera  4.0.0a1
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(shared_ptr<Solution> sol, const string& name="(none)");
20 FlowReactor(shared_ptr<Solution> sol, bool clone, const string& name="(none)");
21
22 string type() const override {
23 return "FlowReactor";
24 }
25
26 bool isOde() const override {
27 return false;
28 }
29
30 bool timeIsIndependent() const override {
31 return false;
32 }
33
34 //! Not implemented; FlowReactor implements getStateDae() instead.
35 void getState(double* y) override {
36 throw NotImplementedError("FlowReactor::getState");
37 }
38
39 void getStateDae(double* y, double* ydot) override;
40 void updateState(double* y) override;
41
42 //! Not implemented; FlowReactor implements evalDae() instead.
43 void eval(double t, double* LHS, double* RHS) override {
44 throw NotImplementedError("FlowReactor::eval");
45 }
46
47 void evalDae(double t, double* y, double* ydot, double* residual) override;
48
49 void getConstraints(double* constraints) override;
50 vector<size_t> initializeSteady() override {
51 throw CanteraError("FlowReactor::initializeSteady",
52 "FlowReactor is not compatible with time-dependent steady-state solver.");
53 }
54
55 //! Mass flow rate through the reactor [kg/s]
56 double massFlowRate() {
57 return m_u * m_rho * m_area;
58 }
59
60 //! Set the mass flow rate through the reactor [kg/s]
61 void setMassFlowRate(double mdot);
62
63 //! The current gas speed in the reactor [m/s]
64 double speed() const {
65 return m_u;
66 }
67
68 //! The cross-sectional area of the reactor [m²]
69 double area() const override {
70 return m_area;
71 }
72
73 //! Sets the area of the reactor [m²]
74 void setArea(double area) override;
75
76 //! Return the index in the solution vector for this reactor of the component named
77 //! *nm*. Possible values for *nm* are "density", "speed", "pressure",
78 //! "temperature" or the name of a homogeneous phase species.
79 size_t componentIndex(const string& nm) const override;
80
81 string componentName(size_t k) override;
82
83protected:
84 //! Density [kg/m^3]. First component of the state vector.
85 double m_rho = NAN;
86 //! Axial velocity [m/s]. Second component of the state vector.
87 double m_u = -1.0;
88 //! offset to the species equations
89 const size_t m_offset_Y = 4;
90 //! reactor area [m^2]
91 double m_area = 1.0;
92 //! temporary storage for species partial molar enthalpies
93 vector<double> m_hk;
94};
95
96}
97
98#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]
Definition FlowReactor.h:91
double area() const override
The cross-sectional area of the reactor [m²].
Definition FlowReactor.h:69
const size_t m_offset_Y
offset to the species equations
Definition FlowReactor.h:89
bool isOde() const override
Indicate whether the governing equations for this reactor type are a system of ODEs or DAEs.
Definition FlowReactor.h:26
void setMassFlowRate(double mdot)
Set the mass flow rate through the reactor [kg/s].
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:30
void eval(double t, double *LHS, double *RHS) override
Not implemented; FlowReactor implements evalDae() instead.
Definition FlowReactor.h:43
double speed() const
The current gas speed in the reactor [m/s].
Definition FlowReactor.h:64
string type() const override
String indicating the reactor model implemented.
Definition FlowReactor.h:22
double m_u
Axial velocity [m/s]. Second component of the state vector.
Definition FlowReactor.h:87
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.
double massFlowRate()
Mass flow rate through the reactor [kg/s].
Definition FlowReactor.h:56
void getState(double *y) override
Not implemented; FlowReactor implements getStateDae() instead.
Definition FlowReactor.h:35
vector< size_t > initializeSteady() override
Initialize the reactor before solving a steady-state problem.
Definition FlowReactor.h:50
double m_rho
Density [kg/m^3]. First component of the state vector.
Definition FlowReactor.h:85
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 updateState(double *y) override
Set the state of the reactor to correspond to the state vector y.
void setArea(double area) override
Sets the area of the reactor [m²].
vector< double > m_hk
temporary storage for species partial molar enthalpies
Definition FlowReactor.h:93
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.
string name() const
Return the name of this reactor.
Definition ReactorBase.h:81
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595