Cantera  3.1.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 * @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 void setTimeFunction(Func1* g) override {
87 throw NotImplementedError("PressureController::setTimeFunction");
88 }
89
90 //! Set the proportionality constant between pressure drop and mass flow
91 //! rate
92 /*!
93 * *c* has units of kg/s/Pa. The mass flow rate is computed as:
94 * @f[\dot{m} = \dot{m}_{primary} + c f(\Delta P) @f]
95 * where *f* is a functions of pressure drop that is set by
96 * `setPressureFunction`. If no functions is specified, the mass flow
97 * rate defaults to:
98 * @f[\dot{m} = \dot{m}_{primary} + c \Delta P @f]
99 */
100 void setPressureCoeff(double c) {
101 m_coeff = c;
102 }
103
104 //! Get the pressure coefficient.
106 return m_coeff;
107 }
108
109 void updateMassFlowRate(double time) override;
110
111protected:
112 FlowDevice* m_primary = nullptr;
113};
114
115//! Supply a mass flow rate that is a function of the pressure drop across the
116//! valve.
117/*!
118 * The default behavior is a linearly proportional to the pressure difference.
119 * Note that real valves do not have this behavior, so this class does not
120 * model real, physical valves.
121 * @ingroup flowDeviceGroup
122 */
123class Valve : public FlowDevice
124{
125public:
126 Valve() = default;
127
128 string type() const override {
129 return "Valve";
130 }
131
132 //! Set the proportionality constant between pressure drop and mass flow
133 //! rate
134 /*!
135 * *c* has units of kg/s/Pa. The mass flow rate is computed as:
136 * @f[\dot{m} = c g(t) f(\Delta P) @f]
137 * where *g* and *f* are functions of time and pressure drop that are set
138 * by `setTimeFunction` and `setPressureFunction`, respectively. If no functions are
139 * specified, the mass flow rate defaults to:
140 * @f[\dot{m} = c \Delta P @f]
141 */
142 void setValveCoeff(double c) {
143 m_coeff = c;
144 }
145
146 //! Get the valve coefficient.
147 double getValveCoeff() {
148 return m_coeff;
149 }
150
151 //! Compute the current mass flow rate, based on the pressure difference.
152 void updateMassFlowRate(double time) override;
153};
154
155}
156#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:75
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 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