Cantera  3.3.0a1
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(shared_ptr<Func1> f) override {
57 throw NotImplementedError("MassFlowController::setPressureFunction");
58 }
59
60 //! If a function of time has been specified for mdot, then update the
61 //! stored mass flow rate. Otherwise, mdot is a constant, and does not
62 //! need updating.
63 void updateMassFlowRate(double time) override;
64};
65
66/**
67 * A class for flow controllers where the flow rate is equal to the flow rate
68 * of a primary mass flow controller plus a correction proportional to the
69 * pressure difference between the inlet and outlet.
70 *
71 * The device coefficient *c* sets the proportionality constant between pressure drop
72 * and mass flow rate and has units of kg/s/Pa. The mass flow rate is computed as:
73 * @f[\dot{m} = \dot{m}_{primary} + c f(\Delta P) @f]
74 * where *f* is a functions of pressure drop that is set by
75 * `setPressureFunction`. If no functions is specified, the mass flow
76 * rate defaults to:
77 * @f[\dot{m} = \dot{m}_{primary} + c \Delta P @f]
78 *
79 * @ingroup connectorGroup
80 */
82{
83public:
84 using FlowDevice::FlowDevice; // inherit constructors
85
86 string type() const override {
87 return "PressureController";
88 }
89
90 bool ready() override {
91 return FlowDevice::ready() && m_primary != 0;
92 }
93
94 void setPrimary(shared_ptr<ConnectorNode> primary) override;
95
96 void setTimeFunction(shared_ptr<Func1> f) override {
97 throw NotImplementedError("PressureController::setTimeFunction");
98 }
99
100 //! Set the proportionality constant between pressure drop and mass flow rate.
101 void setPressureCoeff(double c) {
102 m_coeff = c;
103 }
104
105 //! Get the pressure coefficient.
107 return m_coeff;
108 }
109
110 void updateMassFlowRate(double time) override;
111
112protected:
113 FlowDevice* m_primary = nullptr;
114};
115
116//! Supply a mass flow rate that is a function of the pressure drop across the 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 *
122 * The device coefficient *c* sets the proportionality constant between pressure drop
123 * and mass flow rate and has units of kg/s/Pa. The mass flow rate is computed as:
124 * @f[\dot{m} = c g(t) f(\Delta P) @f]
125 * where *g* and *f* are functions of time and pressure drop that are set
126 * by `setTimeFunction` and `setPressureFunction`, respectively. If no functions are
127 * specified, the mass flow rate defaults to:
128 * @f[\dot{m} = c \Delta P @f]
129 *
130 * @ingroup connectorGroup
131 */
132class Valve : public FlowDevice
133{
134public:
135 using FlowDevice::FlowDevice; // inherit constructors
136
137 string type() const override {
138 return "Valve";
139 }
140
141 //! Set the proportionality constant between pressure drop and mass flow rate.
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:25
double m_coeff
Coefficient set by derived classes; used by updateMassFlowRate.
Definition FlowDevice.h:153
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 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...
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 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