Cantera  2.5.1
flowControllers.h
Go to the documentation of this file.
1 //! @file flowControllers.h Some flow devices derived from class FlowDevice.
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_FLOWCONTR_H
7 #define CT_FLOWCONTR_H
8 
9 #include "FlowDevice.h"
11 
12 namespace Cantera
13 {
14 
15 /**
16  * A class for mass flow controllers. The mass flow rate is constant or
17  * specified as a function of time..
18  */
20 {
21 public:
23 
24  virtual std::string typeStr() const {
25  return "MassFlowController";
26  }
27 
28  //! Set the fixed mass flow rate (kg/s) through the mass flow controller.
29  void setMassFlowRate(double mdot);
30 
31  //! Set the mass flow coefficient.
32  /*!
33  * *m* has units of kg/s. The mass flow rate is computed as:
34  * \f[\dot{m} = m g(t) \f]
35  * where *g* is a function of time that is set by `setTimeFunction`.
36  * If no function is specified, the mass flow rate defaults to:
37  * \f[\dot{m} = m \f]
38  */
39  void setMassFlowCoeff(double m) {
40  m_coeff = m;
41  }
42 
43  //! Get the mass flow coefficient.
44  double getMassFlowCoeff() {
45  return m_coeff;
46  }
47 
48  virtual void setPressureFunction(Func1* f) {
49  throw NotImplementedError("MassFlowController::setPressureFunction");
50  }
51 
52  /// If a function of time has been specified for mdot, then update the
53  /// stored mass flow rate. Otherwise, mdot is a constant, and does not
54  /// need updating.
55  virtual void updateMassFlowRate(double time);
56 };
57 
58 /**
59  * A class for flow controllers where the flow rate is equal to the flow rate
60  * of a "master" mass flow controller plus a correction proportional to the
61  * pressure difference between the inlet and outlet.
62  */
64 {
65 public:
67 
68  virtual std::string typeStr() const {
69  return "PressureController";
70  }
71 
72  virtual bool ready() {
73  return FlowDevice::ready() && m_master != 0;
74  }
75 
76  void setMaster(FlowDevice* master) {
77  m_master = master;
78  }
79 
80  virtual void setTimeFunction(Func1* g) {
81  throw NotImplementedError("PressureController::setTimeFunction");
82  }
83 
84  //! Set the proportionality constant between pressure drop and mass flow
85  //! rate
86  /*!
87  * *c* has units of kg/s/Pa. The mass flow rate is computed as:
88  * \f[\dot{m} = \dot{m}_{master} + c f(\Delta P) \f]
89  * where *f* is a functions of pressure drop that is set by
90  * `setPressureFunction`. If no functions is specified, the mass flow
91  * rate defaults to:
92  * \f[\dot{m} = \dot{m}_{master} + c \Delta P \f]
93  */
94  void setPressureCoeff(double c) {
95  m_coeff = c;
96  }
97 
98  //! Get the pressure coefficient.
99  double getPressureCoeff() {
100  return m_coeff;
101  }
102 
103  virtual void updateMassFlowRate(double time);
104 
105 protected:
106  FlowDevice* m_master;
107 };
108 
109 //! Supply a mass flow rate that is a function of the pressure drop across the
110 //! valve.
111 /*!
112  * The default behavior is a linearly proportional to the pressure difference.
113  * Note that real valves do not have this behavior, so this class does not
114  * model real, physical valves.
115  */
116 class Valve : public FlowDevice
117 {
118 public:
119  Valve();
120 
121  virtual std::string typeStr() const {
122  return "Valve";
123  }
124 
125  //! Set the proportionality constant between pressure drop and mass flow
126  //! rate
127  /*!
128  * *c* has units of kg/s/Pa. The mass flow rate is computed as:
129  * \f[\dot{m} = c \Delta P \f]
130  */
131  //! @deprecated To be removed after Cantera 2.5.
132  void setPressureCoeff(double c) {
133  warn_deprecated("Valve::setPressureCoeff",
134  "To be removed after Cantera 2.5. "
135  "Use Valve::setValveCoeff instead.");
136  m_coeff = c;
137  }
138 
139  //! Set the proportionality constant between pressure drop and mass flow
140  //! rate
141  /*!
142  * *c* has units of kg/s/Pa. The mass flow rate is computed as:
143  * \f[\dot{m} = c g(t) f(\Delta P) \f]
144  * where *g* and *f* are functions of time and pressure drop that are set
145  * by `setTimeFunction` and `setPressureFunction`, respectively. If no functions are
146  * specified, the mass flow rate defaults to:
147  * \f[\dot{m} = c \Delta P \f]
148  */
149  void setValveCoeff(double c) {
150  m_coeff = c;
151  }
152 
153  //! Get the valve coefficient.
154  double getValveCoeff() {
155  return m_coeff;
156  }
157 
158  /// Compute the currrent mass flow rate, based on the pressure difference.
159  virtual void updateMassFlowRate(double time);
160 };
161 
162 }
163 #endif
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:31
double m_coeff
Coefficient set by derived classes; used by updateMassFlowRate.
Definition: FlowDevice.h:165
Base class for 'functor' classes that evaluate a function of one variable.
Definition: Func1.h:44
A class for mass flow controllers.
void setMassFlowCoeff(double m)
Set the mass flow coefficient.
void setMassFlowRate(double mdot)
Set the fixed mass flow rate (kg/s) through the mass flow controller.
virtual std::string typeStr() const
String indicating the flow device implemented.
virtual void updateMassFlowRate(double time)
If a function of time has been specified for mdot, then update the stored mass flow rate.
double getMassFlowCoeff()
Get the mass flow coefficient.
virtual void setPressureFunction(Func1 *f)
Set a function of pressure that is used in determining the mass flow rate through the device.
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
A class for flow controllers where the flow rate is equal to the flow rate of a "master" mass flow co...
virtual std::string typeStr() const
String indicating the flow device implemented.
virtual void updateMassFlowRate(double time)
Update the mass flow rate at time 'time'.
virtual void setTimeFunction(Func1 *g)
Set a function of time that is used in determining the mass flow rate through the device.
double getPressureCoeff()
Get the pressure coefficient.
void setPressureCoeff(double c)
Set the proportionality constant between pressure drop and mass flow rate.
Supply a mass flow rate that is a function of the pressure drop across the valve.
virtual std::string typeStr() const
String indicating the flow device implemented.
void setValveCoeff(double c)
Set the proportionality constant between pressure drop and mass flow rate.
double getValveCoeff()
Get the valve coefficient.
virtual void updateMassFlowRate(double time)
Compute the currrent mass flow rate, based on the pressure difference.
void setPressureCoeff(double c)
Set the proportionality constant between pressure drop and mass flow rate.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
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