Cantera  3.2.0a2
Loading...
Searching...
No Matches
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 *
19 * The device coefficient *c* specifies the mass flow coefficient with units of kg/s.
20 * The mass flow rate is computed as:
21 * @f[\dot{m} = c g(t) @f]
22 * where *g* is a function of time that is set by `setTimeFunction`.
23 * If no function is specified, the mass flow rate defaults to:
24 * @f[\dot{m} = c @f]
25 *
26 * @ingroup connectorGroup
27 */
29{
30public:
31 using FlowDevice::FlowDevice; // inherit constructors
32
33 string type() const override {
34 return "MassFlowController";
35 }
36
37 void setMassFlowRate(double mdot) override;
38
39 //! Set the mass flow coefficient.
40 /*!
41 * *m* has units of kg/s. The mass flow rate is computed as:
42 *
43 * where *g* is a function of time that is set by `setTimeFunction`.
44 * If no function is specified, the mass flow rate defaults to:
45 * @f[\dot{m} = m @f]
46 */
47 void setMassFlowCoeff(double m) {
48 m_coeff = m;
49 }
50
51 //! Get the mass flow coefficient.
53 return m_coeff;
54 }
55
56 void setPressureFunction(Func1* f) override {
57 throw NotImplementedError("MassFlowController::setPressureFunction");
58 }
59
60 void setPressureFunction(shared_ptr<Func1> f) override {
61 throw NotImplementedError("MassFlowController::setPressureFunction");
62 }
63
64 //! If a function of time has been specified for mdot, then update the
65 //! stored mass flow rate. Otherwise, mdot is a constant, and does not
66 //! need updating.
67 void updateMassFlowRate(double time) override;
68};
69
70/**
71 * A class for flow controllers where the flow rate is equal to the flow rate
72 * of a primary mass flow controller plus a correction proportional to the
73 * pressure difference between the inlet and outlet.
74 *
75 * The device coefficient *c* sets the proportionality constant between pressure drop
76 * and mass flow rate and has units of kg/s/Pa. The mass flow rate is computed as:
77 * @f[\dot{m} = \dot{m}_{primary} + c f(\Delta P) @f]
78 * where *f* is a functions of pressure drop that is set by
79 * `setPressureFunction`. If no functions is specified, the mass flow
80 * rate defaults to:
81 * @f[\dot{m} = \dot{m}_{primary} + c \Delta P @f]
82 *
83 * @ingroup connectorGroup
84 */
86{
87public:
88 using FlowDevice::FlowDevice; // inherit constructors
89
90 string type() const override {
91 return "PressureController";
92 }
93
94 bool ready() override {
95 return FlowDevice::ready() && m_primary != 0;
96 }
97
98 void setPrimary(shared_ptr<ConnectorNode> primary) override;
99
100 //! Set the primary mass flow controller.
101 //! @since New in %Cantera 3.0.
102 //! @deprecated To be removed after %Cantera 3.2. Replaceable by version using
103 //! shared pointer.
104 void setPrimary(FlowDevice* primary) {
105 warn_deprecated("PressureController::setPrimary",
106 "To be removed after %Cantera 3.2. Replaceable by version "
107 "using shared pointer.");
108 m_primary = primary;
109 }
110
111 void setTimeFunction(Func1* g) override {
112 throw NotImplementedError("PressureController::setTimeFunction");
113 }
114
115 void setTimeFunction(shared_ptr<Func1> f) override {
116 throw NotImplementedError("PressureController::setTimeFunction");
117 }
118
119 //! Set the proportionality constant between pressure drop and mass flow rate.
120 void setPressureCoeff(double c) {
121 m_coeff = c;
122 }
123
124 //! Get the pressure coefficient.
126 return m_coeff;
127 }
128
129 void updateMassFlowRate(double time) override;
130
131protected:
132 FlowDevice* m_primary = nullptr;
133};
134
135//! Supply a mass flow rate that is a function of the pressure drop across the valve.
136/*!
137 * The default behavior is a linearly proportional to the pressure difference.
138 * Note that real valves do not have this behavior, so this class does not
139 * model real, physical valves.
140 *
141 * The device coefficient *c* sets the proportionality constant between pressure drop
142 * and mass flow rate and 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 * @ingroup connectorGroup
150 */
151class Valve : public FlowDevice
152{
153public:
154 using FlowDevice::FlowDevice; // inherit constructors
155
156 string type() const override {
157 return "Valve";
158 }
159
160 //! Set the proportionality constant between pressure drop and mass flow rate.
161 void setValveCoeff(double c) {
162 m_coeff = c;
163 }
164
165 //! Get the valve coefficient.
166 double getValveCoeff() {
167 return m_coeff;
168 }
169
170 //! Compute the current mass flow rate, based on the pressure difference.
171 void updateMassFlowRate(double time) override;
172};
173
174}
175#endif
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition FlowDevice.h:25
double m_coeff
Coefficient set by derived classes; used by updateMassFlowRate.
Definition FlowDevice.h:176
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:75
A class for mass flow controllers.
void setMassFlowCoeff(double m)
Set the mass flow coefficient.
void setPressureFunction(shared_ptr< Func1 > f) override
Set a function of pressure to modify the pressure response.
string type() const override
String indicating the connector implemented.
double getMassFlowCoeff()
Get the mass flow coefficient.
void setPressureFunction(Func1 *f) override
Set a function of pressure that is used in determining the mass flow rate through the device.
void updateMassFlowRate(double time) override
If a function of time has been specified for mdot, then update the stored mass flow rate.
void setMassFlowRate(double mdot) override
Set the fixed mass flow rate (kg/s) through a flow device.
An error indicating that an unimplemented function has been called.
A class for flow controllers where the flow rate is equal to the flow rate of a primary mass flow con...
void setPrimary(FlowDevice *primary)
Set the primary mass flow controller.
string type() const override
String indicating the connector implemented.
double getPressureCoeff()
Get the pressure coefficient.
void setPressureCoeff(double c)
Set the proportionality constant between pressure drop and mass flow rate.
void setTimeFunction(shared_ptr< Func1 > f) override
Set a function of time to modulate the mass flow rate.
void setTimeFunction(Func1 *g) override
Set a function of time that is used in determining the mass flow rate through the device.
void updateMassFlowRate(double time) override
Update the mass flow rate at time 'time'.
void setPrimary(shared_ptr< ConnectorNode > primary) override
Set the primary mass flow controller.
Supply a mass flow rate that is a function of the pressure drop across the valve.
void setValveCoeff(double c)
Set the proportionality constant between pressure drop and mass flow rate.
string type() const override
String indicating the connector implemented.
double getValveCoeff()
Get the valve coefficient.
void updateMassFlowRate(double time) override
Compute the current mass flow rate, based on the pressure difference.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1997