Cantera  2.1.2
flowControllers.h
Go to the documentation of this file.
1 /**
2  * @file flowControllers.h
3  *
4  * Some flow devices derived from class FlowDevice.
5  */
6 
7 // Copyright 2001 California Institute of Technology
8 
9 #ifndef CT_FLOWCONTR_H
10 #define CT_FLOWCONTR_H
11 
12 #include "FlowDevice.h"
13 #include "ReactorBase.h"
14 #include "cantera/numerics/Func1.h"
15 
16 namespace Cantera
17 {
18 /**
19  * A class for mass flow controllers. The mass flow rate is constant or
20  * specified as a function of time..
21  */
23 {
24 public:
26  m_type = MFC_Type;
27  }
28 
29  virtual bool ready() {
30  return FlowDevice::ready() && m_mdot >= 0.0;
31  }
32 
33  /// If a function of time has been specified for mdot, then update the
34  /// stored mass flow rate. Otherwise, mdot is a constant, and does not
35  /// need updating.
36  virtual void updateMassFlowRate(doublereal time) {
37  if (m_func) {
38  m_mdot = m_func->eval(time);
39  }
40  if (m_mdot < 0.0) {
41  m_mdot = 0.0;
42  }
43  }
44 };
45 
46 /**
47  * A class for flow controllers where the flow rate is equal to the flow rate
48  * of a "master" mass flow controller plus a correction proportional to the
49  * pressure difference between the inlet and outlet.
50  */
52 {
53 public:
54  PressureController() : FlowDevice(), m_master(0) {
55  m_type = PressureController_Type;
56  }
57 
58  virtual bool ready() {
59  return FlowDevice::ready() && m_master != 0;
60  }
61 
62  void setMaster(FlowDevice* master) {
63  m_master = master;
64  }
65 
66  virtual void updateMassFlowRate(doublereal time) {
67  doublereal master_mdot = m_master->massFlowRate(time);
68  m_mdot = master_mdot + m_coeffs[0]*(in().pressure() -
69  out().pressure());
70  if (m_mdot < 0.0) {
71  m_mdot = 0.0;
72  }
73  }
74 
75 protected:
76  FlowDevice* m_master;
77 };
78 
79 //! Supply a mass flow rate that is a function of the pressure drop across the valve.
80 /*!
81  * The default behavior is a linearly proportional to the pressure difference.
82  * Note that real valves do not have this behavior, so this class does not
83  * model real, physical valves.
84  */
85 class Valve : public FlowDevice
86 {
87 public:
88  Valve() : FlowDevice() {
89  m_type = Valve_Type;
90  }
91 
92  virtual bool ready() {
93  return FlowDevice::ready() && m_coeffs.size() >= 1;
94  }
95 
96  /// Compute the currrent mass flow rate, based on the pressure difference.
97  virtual void updateMassFlowRate(doublereal time) {
98  double delta_P = in().pressure() - out().pressure();
99  if (m_func) {
100  m_mdot = m_func->eval(delta_P);
101  } else {
102  m_mdot = m_coeffs[0]*delta_P;
103  }
104  if (m_mdot < 0.0) {
105  m_mdot = 0.0;
106  }
107  }
108 };
109 
110 }
111 #endif
doublereal pressure() const
Returns the current pressure (Pa) of the reactor.
Definition: ReactorBase.h:179
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:28
Supply a mass flow rate that is a function of the pressure drop across the valve. ...
const ReactorBase & out() const
Return a const reference to the downstream reactor.
Definition: FlowDevice.h:82
A class for flow controllers where the flow rate is equal to the flow rate of a "master" mass flow co...
virtual doublereal eval(doublereal t) const
Evaluate the function.
Definition: Func1.cpp:62
virtual void updateMassFlowRate(doublereal time)
Update the mass flow rate at time 'time'.
virtual void updateMassFlowRate(doublereal time)
Compute the currrent mass flow rate, based on the pressure difference.
A class for mass flow controllers.
ReactorBase & in() const
Return a reference to the upstream reactor.
Definition: FlowDevice.h:77
doublereal massFlowRate(double time=-999.0)
Definition: FlowDevice.h:45
virtual void updateMassFlowRate(doublereal time)
If a function of time has been specified for mdot, then update the stored mass flow rate...