Cantera  2.4.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  FlowDevice(const FlowDevice&) = delete;
36  FlowDevice& operator=(const FlowDevice&) = delete;
37 
38  //! Return an integer indicating the type of flow device
39  int type() {
40  return m_type;
41  }
42 
43  //! Mass flow rate (kg/s).
44  doublereal massFlowRate(double time = -999.0) {
45  if (time != -999.0) {
46  updateMassFlowRate(time);
47  }
48  return m_mdot;
49  }
50 
51  //! Update the mass flow rate at time 'time'. This must be overloaded in
52  //! subclassess to update m_mdot.
53  virtual void updateMassFlowRate(doublereal time) {}
54 
55  //! Mass flow rate (kg/s) of outlet species k. Returns zero if this species
56  //! is not present in the upstream mixture.
57  doublereal outletSpeciesMassFlowRate(size_t k);
58 
59  //! specific enthalpy
60  doublereal enthalpy_mass();
61 
62  //! Install a flow device between two reactors.
63  /*!
64  * @param in Upstream reactor.
65  * @param out Downstream reactor.
66  */
68 
69  virtual bool ready() {
70  return (m_in != 0 && m_out != 0);
71  }
72 
73  //! Return a reference to the upstream reactor.
74  ReactorBase& in() const {
75  return *m_in;
76  }
77 
78  //! Return a const reference to the downstream reactor.
79  const ReactorBase& out() const {
80  return *m_out;
81  }
82 
83  //! set parameters. Generic function used only in the Matlab interface. From
84  //! Python or C++, device-specific functions like Valve::setPressureCoeff
85  //! should be used instead.
86  virtual void setParameters(int n, const double* coeffs) {
87  m_coeffs.resize(n);
88  std::copy(coeffs, coeffs + n, m_coeffs.begin());
89  }
90 
91  //! Set a function of a single variable that is used in determining the
92  //! mass flow rate through the device. The meaning of this function
93  //! depends on the parameterization of the derived type.
94  void setFunction(Func1* f);
95 
96  //! Set the fixed mass flow rate (kg/s) through the flow device.
97  void setMassFlowRate(doublereal mdot) {
98  m_mdot = mdot;
99  }
100 
101 protected:
102  doublereal m_mdot;
103  Func1* m_func;
104  vector_fp m_coeffs;
105  int m_type;
106 
107 private:
108  size_t m_nspin, m_nspout;
109  ReactorBase* m_in;
110  ReactorBase* m_out;
111  std::vector<size_t> m_in2out, m_out2in;
112 };
113 
114 }
115 
116 #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:86
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:79
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:97
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:39
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:44
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:53
Contains declarations for string manipulation functions within Cantera.
ReactorBase & in() const
Return a reference to the upstream reactor.
Definition: FlowDevice.h:74
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8