Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlowDevice.h
Go to the documentation of this file.
1 /**
2  * @file FlowDevice.h
3  */
4 
5 // Copyright 2001 California Institute of Technology
6 
7 #ifndef CT_FLOWDEVICE_H
8 #define CT_FLOWDEVICE_H
9 
10 #include "cantera/base/ct_defs.h"
11 #include "cantera/base/global.h"
13 
14 namespace Cantera
15 {
16 class Func1;
17 class ReactorBase; // forward reference
18 
19 const int MFC_Type = 1;
20 const int PressureController_Type = 2;
21 const int Valve_Type = 3;
22 
23 /**
24  * Base class for 'flow devices' (valves, pressure regulators, etc.)
25  * connecting reactors.
26  * @ingroup reactor0
27  */
29 {
30 public:
31  FlowDevice() : m_mdot(0.0), m_func(0), m_type(0),
32  m_nspin(0), m_nspout(0),
33  m_in(0), m_out(0) {}
34 
35  virtual ~FlowDevice() {}
36 
37  //! Return an integer indicating the type of flow device
38  int type() {
39  return m_type;
40  }
41 
42  /*!
43  * Mass flow rate (kg/s).
44  */
45  doublereal massFlowRate(double time = -999.0) {
46  if (time != -999.0) {
47  updateMassFlowRate(time);
48  }
49  return m_mdot;
50  }
51 
52  //! Update the mass flow rate at time 'time'. This must be overloaded in
53  //! subclassess to update m_mdot.
54  virtual void updateMassFlowRate(doublereal time) {}
55 
56  /*!
57  * Mass flow rate (kg/s) of outlet species k. Returns zero if this species
58  * is not present in the upstream mixture.
59  */
60  doublereal outletSpeciesMassFlowRate(size_t k);
61 
62  //! specific enthalpy
63  doublereal enthalpy_mass();
64 
65  /**
66  * Install a flow device between two reactors.
67  * @param in Upstream reactor.
68  * @param out Downstream reactor.
69  */
71 
72  virtual bool ready() {
73  return (m_in != 0 && m_out != 0);
74  }
75 
76  //! Return a reference to the upstream reactor.
77  ReactorBase& in() const {
78  return *m_in;
79  }
80 
81  //! Return a const reference to the downstream reactor.
82  const ReactorBase& out() const {
83  return *m_out;
84  }
85 
86  //! set parameters
87  virtual void setParameters(int n, doublereal* coeffs) {
88  m_coeffs.resize(n);
89  std::copy(coeffs, coeffs + n, m_coeffs.begin());
90  }
91 
92  //! Set a function of a single variable that is used in determining the
93  //! mass flow rate through the device. The meaning of this function
94  //! depends on the parameterization of the derived type.
95  void setFunction(Cantera::Func1* f);
96 
97  //! Set the fixed mass flow rate (kg/s) through the flow device.
98  void setMassFlowRate(doublereal mdot) {
99  m_mdot = mdot;
100  }
101 
102 protected:
103  doublereal m_mdot;
104  Cantera::Func1* m_func;
105  vector_fp m_coeffs;
106  int m_type;
107 
108 private:
109  size_t m_nspin, m_nspout;
110  ReactorBase* m_in;
111  ReactorBase* m_out;
112  std::vector<size_t> m_in2out, m_out2in;
113 };
114 
115 }
116 
117 #endif
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:28
void setFunction(Cantera::Func1 *f)
Set a function of a single variable that is used in determining the mass flow rate through the device...
Definition: FlowDevice.cpp:40
const ReactorBase & out() const
Return a const reference to the downstream reactor.
Definition: FlowDevice.h:82
doublereal enthalpy_mass()
specific enthalpy
Definition: FlowDevice.cpp:57
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, (see Input File Handling, Diagnostic Output, and Writing messages to the screen).
void setMassFlowRate(doublereal mdot)
Set the fixed mass flow rate (kg/s) through the flow device.
Definition: FlowDevice.h:98
virtual void setParameters(int n, doublereal *coeffs)
set parameters
Definition: FlowDevice.h:87
Base class for 'functor' classes that evaluate a function of one variable.
Definition: Func1.h:41
ReactorBase & in() const
Return a reference to the upstream reactor.
Definition: FlowDevice.h:77
int type()
Return an integer indicating the type of flow device.
Definition: FlowDevice.h:38
Base class for stirred reactors.
Definition: ReactorBase.h:30
doublereal outletSpeciesMassFlowRate(size_t k)
Definition: FlowDevice.cpp:45
bool install(ReactorBase &in, ReactorBase &out)
Install a flow device between two reactors.
Definition: FlowDevice.cpp:9
doublereal massFlowRate(double time=-999.0)
Definition: FlowDevice.h:45
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
virtual void updateMassFlowRate(doublereal time)
Update the mass flow rate at time 'time'.
Definition: FlowDevice.h:54
Contains declarations for string manipulation functions within Cantera.