Cantera  2.0
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 "PID_Controller.h"
15 #include "cantera/numerics/Func1.h"
16 
17 namespace Cantera
18 {
19 /**
20  * A class for mass flow controllers. The mass flow rate is constant,
21  * independent of any other parameters.
22  */
24 {
25 public:
26 
28  m_type = MFC_Type;
29  }
30 
31  virtual ~MassFlowController() {}
32 
33  virtual bool ready() {
34  return FlowDevice::ready() && m_mdot >= 0.0;
35  }
36 
37  /// If a function of time has been specified for
38  /// mdot, then update the stored mass flow rate.
39  /// Otherwise, mdot is a constant, and does not need
40  /// updating.
41  virtual void updateMassFlowRate(doublereal time) {
42  if (m_func) {
43  m_mdot = m_func->eval(time);
44  }
45  if (m_mdot < 0.0) {
46  m_mdot = 0.0;
47  }
48  }
49 
50 protected:
51 
52 private:
53 };
54 
55 /**
56  * A class for mass flow controllers. The mass flow rate is constant,
57  * independent of any other parameters.
58  */
60 {
61 public:
62 
63  PressureController() : FlowDevice(), m_master(0) {
64  m_type = PressureController_Type;
65  }
66 
67  virtual ~PressureController() {}
68 
69  virtual bool ready() {
70  return FlowDevice::ready() && m_master != 0;
71  }
72 
73  void setMaster(FlowDevice* master) {
74  m_master = master;
75  }
76 
77  virtual void updateMassFlowRate(doublereal time) {
78  doublereal master_mdot = m_master->massFlowRate(time);
79  m_mdot = master_mdot + m_coeffs[0]*(in().pressure() -
80  out().pressure());
81  if (m_mdot < 0.0) {
82  m_mdot = 0.0;
83  }
84  }
85 
86 protected:
87  FlowDevice* m_master;
88 
89 private:
90 };
91 
92 
93 /// Valve objects supply a mass flow rate that is a function of the
94 /// pressure drop across the valve. The default behavior is a linearly
95 /// proportional to the pressure difference. Note that
96 /// real valves do not have this behavior, so this class
97 /// does not model real, physical valves.
98 class Valve : public FlowDevice
99 {
100 public:
101 
102  Valve() : FlowDevice() {
103  m_type = Valve_Type;
104  }
105 
106  virtual ~Valve() {}
107 
108  virtual bool ready() {
109  return FlowDevice::ready() && m_coeffs.size() >= 1;
110  }
111 
112  /// Compute the currrent mass flow rate, based on
113  /// the pressure difference.
114  virtual void updateMassFlowRate(doublereal time) {
115  double delta_P = in().pressure() - out().pressure();
116  if (m_func) {
117  m_mdot = m_func->eval(delta_P);
118  } else {
119  m_mdot = m_coeffs[0]*delta_P;
120  }
121  if (m_mdot < 0.0) {
122  m_mdot = 0.0;
123  }
124  }
125 
126 protected:
127 
128 private:
129 };
130 
131 }
132 #endif
133