Cantera  2.3.0
FlowDevice.h
Go to the documentation of this file.
1 //! @file FlowDevice.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_FLOWDEVICE_H
7 #define CT_FLOWDEVICE_H
8 
9 #include "cantera/base/ct_defs.h"
10 #include "cantera/base/global.h"
12 
13 namespace Cantera
14 {
15 class Func1;
16 class ReactorBase;
17 
18 const int MFC_Type = 1;
19 const int PressureController_Type = 2;
20 const int Valve_Type = 3;
21 
22 /**
23  * Base class for 'flow devices' (valves, pressure regulators, etc.)
24  * connecting reactors.
25  * @ingroup reactor0
26  */
28 {
29 public:
30  FlowDevice() : m_mdot(0.0), m_func(0), m_type(0),
31  m_nspin(0), m_nspout(0),
32  m_in(0), m_out(0) {}
33 
34  virtual ~FlowDevice() {}
35 
36  //! Return an integer indicating the type of flow device
37  int type() {
38  return m_type;
39  }
40 
41  //! Mass flow rate (kg/s).
42  doublereal massFlowRate(double time = -999.0) {
43  if (time != -999.0) {
44  updateMassFlowRate(time);
45  }
46  return m_mdot;
47  }
48 
49  //! Update the mass flow rate at time 'time'. This must be overloaded in
50  //! subclassess to update m_mdot.
51  virtual void updateMassFlowRate(doublereal time) {}
52 
53  //! Mass flow rate (kg/s) of outlet species k. Returns zero if this species
54  //! is not present in the upstream mixture.
55  doublereal outletSpeciesMassFlowRate(size_t k);
56 
57  //! specific enthalpy
58  doublereal enthalpy_mass();
59 
60  //! Install a flow device between two reactors.
61  /*!
62  * @param in Upstream reactor.
63  * @param out Downstream reactor.
64  */
66 
67  virtual bool ready() {
68  return (m_in != 0 && m_out != 0);
69  }
70 
71  //! Return a reference to the upstream reactor.
72  ReactorBase& in() const {
73  return *m_in;
74  }
75 
76  //! Return a const reference to the downstream reactor.
77  const ReactorBase& out() const {
78  return *m_out;
79  }
80 
81  //! set parameters. Generic function used only in the Matlab interface. From
82  //! Python or C++, device-specific functions like Valve::setPressureCoeff
83  //! should be used instead.
84  virtual void setParameters(int n, const double* coeffs) {
85  m_coeffs.resize(n);
86  std::copy(coeffs, coeffs + n, m_coeffs.begin());
87  }
88 
89  //! Set a function of a single variable that is used in determining the
90  //! mass flow rate through the device. The meaning of this function
91  //! depends on the parameterization of the derived type.
92  void setFunction(Func1* f);
93 
94  //! Set the fixed mass flow rate (kg/s) through the flow device.
95  void setMassFlowRate(doublereal mdot) {
96  m_mdot = mdot;
97  }
98 
99 protected:
100  doublereal m_mdot;
101  Func1* m_func;
102  vector_fp m_coeffs;
103  int m_type;
104 
105 private:
106  size_t m_nspin, m_nspout;
107  ReactorBase* m_in;
108  ReactorBase* m_out;
109  std::vector<size_t> m_in2out, m_out2in;
110 };
111 
112 }
113 
114 #endif
Base class for &#39;flow devices&#39; (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:27
virtual void setParameters(int n, const double *coeffs)
set parameters.
Definition: FlowDevice.h:84
doublereal enthalpy_mass()
specific enthalpy
Definition: FlowDevice.cpp:61
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
const ReactorBase & out() const
Return a const reference to the downstream reactor.
Definition: FlowDevice.h:77
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:95
Base class for &#39;functor&#39; classes that evaluate a function of one variable.
Definition: Func1.h:41
int type()
Return an integer indicating the type of flow device.
Definition: FlowDevice.h:37
Base class for stirred reactors.
Definition: ReactorBase.h:44
doublereal outletSpeciesMassFlowRate(size_t k)
Mass flow rate (kg/s) of outlet species k.
Definition: FlowDevice.cpp:49
bool install(ReactorBase &in, ReactorBase &out)
Install a flow device between two reactors.
Definition: FlowDevice.cpp:13
doublereal massFlowRate(double time=-999.0)
Mass flow rate (kg/s).
Definition: FlowDevice.h:42
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
void setFunction(Func1 *f)
Set a function of a single variable that is used in determining the mass flow rate through the device...
Definition: FlowDevice.cpp:44
virtual void updateMassFlowRate(doublereal time)
Update the mass flow rate at time &#39;time&#39;.
Definition: FlowDevice.h:51
Contains declarations for string manipulation functions within Cantera.
ReactorBase & in() const
Return a reference to the upstream reactor.
Definition: FlowDevice.h:72
Namespace for the Cantera kernel.
Definition: application.cpp:29