Cantera  3.1.0a1
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 if (!ready()) {
37 throw CanteraError("PressureController::updateMassFlowRate",
38 "Device is not ready; some parameters have not been set.");
39 }
40 double mdot = m_coeff;
41 double delta_P = in().pressure() - out().pressure();
42 if (m_pfunc) {
43 mdot *= m_pfunc->eval(delta_P);
44 } else {
45 mdot *= delta_P;
46 }
47 m_primary->updateMassFlowRate(time);
48 mdot += m_primary->massFlowRate();
49 m_mdot = std::max(mdot, 0.0);
50}
51
53{
54 if (!ready()) {
55 throw CanteraError("Valve::updateMassFlowRate",
56 "Device is not ready; some parameters have not been set.");
57 }
58 double mdot = m_coeff;
59 if (m_tfunc) {
60 mdot *= m_tfunc->eval(time);
61 }
62 double delta_P = in().pressure() - out().pressure();
63 if (m_pfunc) {
64 mdot *= m_pfunc->eval(delta_P);
65 } else {
66 mdot *= delta_P;
67 }
68 m_mdot = std::max(mdot, 0.0);
69}
70
71}
Base class for exceptions thrown by Cantera classes.
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:28
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 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