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