Cantera  3.0.0
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 * @ingroup flowDeviceGroup
19 */
21{
22public:
23 MassFlowController() = default;
24
25 string type() const override {
26 return "MassFlowController";
27 }
28
29 //! Set the fixed mass flow rate (kg/s) through the mass flow controller.
30 void setMassFlowRate(double mdot);
31
32 //! Set the mass flow coefficient.
33 /*!
34 * *m* has units of kg/s. The mass flow rate is computed as:
35 * @f[\dot{m} = m g(t) @f]
36 * where *g* is a function of time that is set by `setTimeFunction`.
37 * If no function is specified, the mass flow rate defaults to:
38 * @f[\dot{m} = m @f]
39 */
40 void setMassFlowCoeff(double m) {
41 m_coeff = m;
42 }
43
44 //! Get the mass flow coefficient.
46 return m_coeff;
47 }
48
49 void setPressureFunction(Func1* f) override {
50 throw NotImplementedError("MassFlowController::setPressureFunction");
51 }
52
53 //! If a function of time has been specified for mdot, then update the
54 //! stored mass flow rate. Otherwise, mdot is a constant, and does not
55 //! need updating.
56 void updateMassFlowRate(double time) override;
57};
58
59/**
60 * A class for flow controllers where the flow rate is equal to the flow rate
61 * of a primary mass flow controller plus a correction proportional to the
62 * pressure difference between the inlet and outlet.
63 * @ingroup flowDeviceGroup
64 */
66{
67public:
68 PressureController() = default;
69
70 string type() const override {
71 return "PressureController";
72 }
73
74 bool ready() override {
75 return FlowDevice::ready() && m_primary != 0;
76 }
77
78 //! Set the primary mass flow controller.
79 /*!
80 * @since New in %Cantera 3.0.
81 */
82 void setPrimary(FlowDevice* primary) {
83 m_primary = primary;
84 }
85
86 //! @deprecated To be removed after %Cantera 3.0; replaced by setPrimary().
87 void setMaster(FlowDevice* master);
88
89 void setTimeFunction(Func1* g) override {
90 throw NotImplementedError("PressureController::setTimeFunction");
91 }
92
93 //! Set the proportionality constant between pressure drop and mass flow
94 //! rate
95 /*!
96 * *c* has units of kg/s/Pa. The mass flow rate is computed as:
97 * @f[\dot{m} = \dot{m}_{primary} + c f(\Delta P) @f]
98 * where *f* is a functions of pressure drop that is set by
99 * `setPressureFunction`. If no functions is specified, the mass flow
100 * rate defaults to:
101 * @f[\dot{m} = \dot{m}_{primary} + c \Delta P @f]
102 */
103 void setPressureCoeff(double c) {
104 m_coeff = c;
105 }
106
107 //! Get the pressure coefficient.
109 return m_coeff;
110 }
111
112 void updateMassFlowRate(double time) override;
113
114protected:
115 FlowDevice* m_primary = nullptr;
116};
117
118//! Supply a mass flow rate that is a function of the pressure drop across the
119//! valve.
120/*!
121 * The default behavior is a linearly proportional to the pressure difference.
122 * Note that real valves do not have this behavior, so this class does not
123 * model real, physical valves.
124 * @ingroup flowDeviceGroup
125 */
126class Valve : public FlowDevice
127{
128public:
129 Valve() = default;
130
131 string type() const override {
132 return "Valve";
133 }
134
135 //! Set the proportionality constant between pressure drop and mass flow
136 //! rate
137 /*!
138 * *c* has units of kg/s/Pa. The mass flow rate is computed as:
139 * @f[\dot{m} = c g(t) f(\Delta P) @f]
140 * where *g* and *f* are functions of time and pressure drop that are set
141 * by `setTimeFunction` and `setPressureFunction`, respectively. If no functions are
142 * specified, the mass flow rate defaults to:
143 * @f[\dot{m} = c \Delta P @f]
144 */
145 void setValveCoeff(double c) {
146 m_coeff = c;
147 }
148
149 //! Get the valve coefficient.
150 double getValveCoeff() {
151 return m_coeff;
152 }
153
154 //! Compute the current mass flow rate, based on the pressure difference.
155 void updateMassFlowRate(double time) override;
156};
157
158}
159#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:127
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:96
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.
string type() const override
String indicating the flow device 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.
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 setMaster(FlowDevice *master)
void setPrimary(FlowDevice *primary)
Set the primary mass flow controller.
string type() const override
String indicating the flow device implemented.
double getPressureCoeff()
Get the pressure coefficient.
void setPressureCoeff(double c)
Set the proportionality constant between pressure drop and 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'.
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 flow device 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:564