Cantera  3.0.0
Loading...
Searching...
No Matches
flowControllers.cpp
Go to the documentation of this file.
1//! @file flowControllers.cpp
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
9
10namespace Cantera
11{
12
14{
15 if (m_tfunc) {
16 delete m_tfunc;
17 }
18 m_coeff = mdot;
19}
20
22{
23 if (!ready()) {
24 throw CanteraError("MassFlowController::updateMassFlowRate",
25 "Device is not ready; some parameters have not been set.");
26 }
27 double mdot = m_coeff;
28 if (m_tfunc) {
29 mdot *= m_tfunc->eval(time);
30 }
31 m_mdot = std::max(mdot, 0.0);
32}
33
35{
36 warn_deprecated("PressureController::setMaster",
37 "To be removed after Cantera 3.0; replaced by setPrimary.");
38 m_primary = master;
39}
40
42{
43 if (!ready()) {
44 throw CanteraError("PressureController::updateMassFlowRate",
45 "Device is not ready; some parameters have not been set.");
46 }
47 double mdot = m_coeff;
48 double delta_P = in().pressure() - out().pressure();
49 if (m_pfunc) {
50 mdot *= m_pfunc->eval(delta_P);
51 } else {
52 mdot *= delta_P;
53 }
54 m_primary->updateMassFlowRate(time);
55 mdot += m_primary->massFlowRate();
56 m_mdot = std::max(mdot, 0.0);
57}
58
60{
61 if (!ready()) {
62 throw CanteraError("Valve::updateMassFlowRate",
63 "Device is not ready; some parameters have not been set.");
64 }
65 double mdot = m_coeff;
66 if (m_tfunc) {
67 mdot *= m_tfunc->eval(time);
68 }
69 double delta_P = in().pressure() - out().pressure();
70 if (m_pfunc) {
71 mdot *= m_pfunc->eval(delta_P);
72 } else {
73 mdot *= delta_P;
74 }
75 m_mdot = std::max(mdot, 0.0);
76}
77
78}
Base class for exceptions thrown by Cantera classes.
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition FlowDevice.h:24
Func1 * m_tfunc
Function set by setTimeFunction; used by updateMassFlowRate.
Definition FlowDevice.h:124
double m_coeff
Coefficient set by derived classes; used by updateMassFlowRate.
Definition FlowDevice.h:127
ReactorBase & in() const
Return a reference to the upstream reactor.
Definition FlowDevice.h:71
double massFlowRate()
Mass flow rate (kg/s).
Definition FlowDevice.h:39
const ReactorBase & out() const
Return a const reference to the downstream reactor.
Definition FlowDevice.h:76
virtual void updateMassFlowRate(double time)
Update the mass flow rate at time 'time'.
Definition FlowDevice.h:50
Func1 * m_pfunc
Function set by setPressureFunction; used by updateMassFlowRate.
Definition FlowDevice.h:121
virtual double eval(double t) const
Evaluate the function.
Definition Func1.cpp:61
void setMassFlowRate(double mdot)
Set the fixed mass flow rate (kg/s) through the mass flow controller.
void updateMassFlowRate(double time) override
If a function of time has been specified for mdot, then update the stored mass flow rate.
void setMaster(FlowDevice *master)
void updateMassFlowRate(double time) override
Update the mass flow rate at time 'time'.
double pressure() const
Returns the current pressure (Pa) of the reactor.
void updateMassFlowRate(double time) override
Compute the current mass flow rate, based on the pressure difference.
Some flow devices derived from class FlowDevice.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926