Cantera 2.6.0

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