Cantera  2.4.0
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 http://www.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 int type() const {
21  return FlowReactorType;
22  }
23 
24  virtual void getState(doublereal* y);
25 
26  virtual void initialize(doublereal t0 = 0.0);
27  virtual void evalEqs(doublereal t, doublereal* y,
28  doublereal* ydot, doublereal* params);
29  virtual void updateState(doublereal* y);
30 
31  void setMassFlowRate(doublereal mdot) {
32  m_rho0 = m_thermo->density();
33  m_speed = mdot/m_rho0;
34  m_speed0 = m_speed;
35  m_T = m_thermo->temperature();
36  m_P0 = m_thermo->pressure() + m_rho0*m_speed*m_speed;
37  m_h0 = m_thermo->enthalpy_mass() + 0.5*m_speed*m_speed;
38  }
39 
40  void setTimeConstant(doublereal tau) {
41  m_fctr = 1.0/tau;
42  }
43 
44  double speed() const {
45  return m_speed;
46  }
47  double distance() const {
48  return m_dist;
49  }
50 
51  //! Return the index in the solution vector for this reactor of the
52  //! component named *nm*. Possible values for *nm* are "X" (position),
53  //! "U", the name of a homogeneous phase species, or the name of a surface
54  //! species.
55  virtual size_t componentIndex(const std::string& nm) const;
56 
57 protected:
58  doublereal m_speed, m_dist, m_T;
59  doublereal m_fctr;
60  doublereal m_rho0, m_speed0, m_P0, m_h0;
61 };
62 }
63 
64 #endif
virtual void getState(doublereal *y)
Get the the current state of the reactor.
Definition: FlowReactor.cpp:26
doublereal temperature() const
Temperature (K).
Definition: Phase.h:601
virtual void updateState(doublereal *y)
Set the state of the reactor to correspond to the state vector y.
Definition: FlowReactor.cpp:46
Adiabatic flow in a constant-area duct.
Definition: FlowReactor.h:15
virtual doublereal density() const
Density (kg/m^3).
Definition: Phase.h:607
doublereal enthalpy_mass() const
Specific enthalpy. Units: J/kg.
Definition: ThermoPhase.h:714
virtual int type() const
Return a constant indicating the type of this Reactor.
Definition: FlowReactor.h:20
virtual void evalEqs(doublereal t, doublereal *y, doublereal *ydot, doublereal *params)
Definition: FlowReactor.cpp:69
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
Definition: ThermoPhase.h:245
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
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
virtual void initialize(doublereal t0=0.0)
Initialize the reactor.
Definition: FlowReactor.cpp:40
Class Reactor is a general-purpose class for stirred reactors.
Definition: Reactor.h:37