Cantera  2.5.1
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 "Reactor.h"
10 
11 namespace Cantera
12 {
13 
14 //! Adiabatic flow in a constant-area duct.
15 class FlowReactor : public Reactor
16 {
17 public:
18  FlowReactor();
19 
20  virtual std::string typeStr() const {
21  return "FlowReactor";
22  }
23 
24  /*!
25  * @deprecated To be changed after Cantera 2.5.
26  */
27  virtual int type() const {
28  warn_deprecated("FlowReactor::type",
29  "To be changed after Cantera 2.5. "
30  "Return string instead of magic number; use "
31  "FlowReactor::typeStr during transition");
32  return FlowReactorType;
33  }
34 
35  virtual void getState(doublereal* y);
36 
37  virtual void initialize(doublereal t0 = 0.0);
38  virtual void evalEqs(doublereal t, doublereal* y,
39  doublereal* ydot, doublereal* params);
40  virtual void updateState(doublereal* y);
41 
42  void setMassFlowRate(doublereal mdot) {
43  m_rho0 = m_thermo->density();
44  m_speed = mdot/m_rho0;
45  m_speed0 = m_speed;
46  m_T = m_thermo->temperature();
47  m_P0 = m_thermo->pressure() + m_rho0*m_speed*m_speed;
48  m_h0 = m_thermo->enthalpy_mass() + 0.5*m_speed*m_speed;
49  }
50 
51  void setTimeConstant(doublereal tau) {
52  m_fctr = 1.0/tau;
53  }
54 
55  double speed() const {
56  return m_speed;
57  }
58  double distance() const {
59  return m_dist;
60  }
61 
62  //! Return the index in the solution vector for this reactor of the
63  //! component named *nm*. Possible values for *nm* are "X" (position),
64  //! "U", the name of a homogeneous phase species, or the name of a surface
65  //! species.
66  virtual size_t componentIndex(const std::string& nm) const;
67 
68 protected:
69  doublereal m_speed, m_dist, m_T;
70  doublereal m_fctr;
71  doublereal m_rho0, m_speed0, m_P0, m_h0;
72 };
73 }
74 
75 #endif
Adiabatic flow in a constant-area duct.
Definition: FlowReactor.h:16
virtual size_t componentIndex(const std::string &nm) const
Return the index in the solution vector for this reactor of the component named nm.
Definition: FlowReactor.cpp:96
virtual void updateState(doublereal *y)
Set the state of the reactor to correspond to the state vector y.
Definition: FlowReactor.cpp:46
virtual std::string typeStr() const
String indicating the reactor model implemented.
Definition: FlowReactor.h:20
virtual void getState(doublereal *y)
Get the the current state of the reactor.
Definition: FlowReactor.cpp:26
virtual int type() const
Definition: FlowReactor.h:27
virtual void initialize(doublereal t0=0.0)
Initialize the reactor.
Definition: FlowReactor.cpp:40
virtual void evalEqs(doublereal t, doublereal *y, doublereal *ydot, doublereal *params)
Definition: FlowReactor.cpp:69
virtual double density() const
Density (kg/m^3).
Definition: Phase.h:685
doublereal temperature() const
Temperature (K).
Definition: Phase.h:667
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Definition: Phase.h:679
Class Reactor is a general-purpose class for stirred reactors.
Definition: Reactor.h:38
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
Definition: ThermoPhase.h:742
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264