| 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"
10#include "cantera/base/ctexceptions.h"
11
12 namespace 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 */
20 class MassFlowController : public FlowDevice
21{
22 public:
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.
45 double getMassFlowCoeff() {
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 */
65 class PressureController : public FlowDevice
66{
67 public:
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.
108 double getPressureCoeff() {
109 return m_coeff;
110 }
111
112 void updateMassFlowRate(double time) override;
113
114 protected:
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 */
126 class Valve : public FlowDevice
127{
128 public:
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
FlowDevice.h
Cantera::FlowDevice
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition FlowDevice.h:24
Cantera::FlowDevice::m_coeff
double m_coeff
Coefficient set by derived classes; used by updateMassFlowRate.
Definition FlowDevice.h:127
Cantera::Func1
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:96
Cantera::MassFlowController
A class for mass flow controllers.
Definition flowControllers.h:21
Cantera::MassFlowController::setMassFlowCoeff
void setMassFlowCoeff(double m)
Set the mass flow coefficient.
Definition flowControllers.h:40
Cantera::MassFlowController::setMassFlowRate
void setMassFlowRate(double mdot)
Set the fixed mass flow rate (kg/s) through the mass flow controller.
Definition flowControllers.cpp:13
Cantera::MassFlowController::type
string type() const override
String indicating the flow device implemented.
Definition flowControllers.h:25
Cantera::MassFlowController::getMassFlowCoeff
double getMassFlowCoeff()
Get the mass flow coefficient.
Definition flowControllers.h:45
Cantera::MassFlowController::setPressureFunction
void setPressureFunction(Func1 *f) override
Set a function of pressure that is used in determining the mass flow rate through the device.
Definition flowControllers.h:49
Cantera::MassFlowController::updateMassFlowRate
void updateMassFlowRate(double time) override
If a function of time has been specified for mdot, then update the stored mass flow rate.
Definition flowControllers.cpp:21
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition ctexceptions.h:195
Cantera::PressureController
A class for flow controllers where the flow rate is equal to the flow rate of a primary mass flow con...
Definition flowControllers.h:66
Cantera::PressureController::setMaster
void setMaster(FlowDevice *master)
Definition flowControllers.cpp:34
Cantera::PressureController::setPrimary
void setPrimary(FlowDevice *primary)
Set the primary mass flow controller.
Definition flowControllers.h:82
Cantera::PressureController::type
string type() const override
String indicating the flow device implemented.
Definition flowControllers.h:70
Cantera::PressureController::getPressureCoeff
double getPressureCoeff()
Get the pressure coefficient.
Definition flowControllers.h:108
Cantera::PressureController::setPressureCoeff
void setPressureCoeff(double c)
Set the proportionality constant between pressure drop and mass flow rate.
Definition flowControllers.h:103
Cantera::PressureController::setTimeFunction
void setTimeFunction(Func1 *g) override
Set a function of time that is used in determining the mass flow rate through the device.
Definition flowControllers.h:89
Cantera::PressureController::updateMassFlowRate
void updateMassFlowRate(double time) override
Update the mass flow rate at time 'time'.
Definition flowControllers.cpp:41
Cantera::Valve
Supply a mass flow rate that is a function of the pressure drop across the valve.
Definition flowControllers.h:127
Cantera::Valve::setValveCoeff
void setValveCoeff(double c)
Set the proportionality constant between pressure drop and mass flow rate.
Definition flowControllers.h:145
Cantera::Valve::type
string type() const override
String indicating the flow device implemented.
Definition flowControllers.h:131
Cantera::Valve::getValveCoeff
double getValveCoeff()
Get the valve coefficient.
Definition flowControllers.h:150
Cantera::Valve::updateMassFlowRate
void updateMassFlowRate(double time) override
Compute the current mass flow rate, based on the pressure difference.
Definition flowControllers.cpp:59
ctexceptions.h
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564