Cantera 2.6.0
FlowDevice.h
Go to the documentation of this file.
1//! @file FlowDevice.h
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_FLOWDEVICE_H
7#define CT_FLOWDEVICE_H
8
10#include "cantera/base/global.h"
12
13namespace Cantera
14{
15class Func1;
16class ReactorBase;
17
18/**
19 * Base class for 'flow devices' (valves, pressure regulators, etc.)
20 * connecting reactors.
21 * @ingroup ZeroD
22 */
24{
25public:
26 FlowDevice();
27
28 virtual ~FlowDevice() {}
29 FlowDevice(const FlowDevice&) = delete;
30 FlowDevice& operator=(const FlowDevice&) = delete;
31
32 //! String indicating the flow device implemented.
33 //! Usually corresponds to the name of the derived class.
34 //! @deprecated To be removed after Cantera 2.6. Use type() instead.
35 virtual std::string typeStr() const {
36 warn_deprecated("FlowDevice::typeStr",
37 "To be removed after Cantera 2.6. Use type() instead.");
38 return "FlowDevice";
39 }
40
41 //! String indicating the flow device implemented. Usually
42 //! corresponds to the name of the derived class.
43 virtual std::string type() const {
44 return "FlowDevice";
45 }
46
47 //! Mass flow rate (kg/s).
48 double massFlowRate() {
49 if (m_mdot == Undef) {
50 throw CanteraError("FlowDevice::massFlowRate",
51 "Flow device is not ready. Try initializing the reactor network.");
52 } else {
53 return m_mdot;
54 }
55 }
56
57 //! Update the mass flow rate at time 'time'. This must be overloaded in
58 //! subclassess to update m_mdot.
59 virtual void updateMassFlowRate(double time) {}
60
61 //! Mass flow rate (kg/s) of outlet species k. Returns zero if this species
62 //! is not present in the upstream mixture.
63 double outletSpeciesMassFlowRate(size_t k);
64
65 //! specific enthalpy
66 double enthalpy_mass();
67
68 //! Install a flow device between two reactors.
69 /*!
70 * @param in Upstream reactor.
71 * @param out Downstream reactor.
72 */
74
75 virtual bool ready() {
76 return (m_in != 0 && m_out != 0);
77 }
78
79 //! Return a reference to the upstream reactor.
80 ReactorBase& in() const {
81 return *m_in;
82 }
83
84 //! Return a const reference to the downstream reactor.
85 const ReactorBase& out() const {
86 return *m_out;
87 }
88
89 //! Set a function of pressure that is used in determining the
90 //! mass flow rate through the device. The evaluation of mass flow
91 //! depends on the derived flow device class.
92 virtual void setPressureFunction(Func1* f);
93
94 //! Set a function of time that is used in determining
95 //! the mass flow rate through the device. The evaluation of mass flow
96 //! depends on the derived flow device class.
97 virtual void setTimeFunction(Func1* g);
98
99protected:
100 double m_mdot;
101
102 //! Function set by setPressureFunction; used by updateMassFlowRate
104
105 //! Function set by setTimeFunction; used by updateMassFlowRate
107
108 //! Coefficient set by derived classes; used by updateMassFlowRate
109 double m_coeff;
110
111private:
112 size_t m_nspin, m_nspout;
113 ReactorBase* m_in;
114 ReactorBase* m_out;
115 std::vector<size_t> m_in2out, m_out2in;
116};
117
118}
119
120#endif
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.
Definition: FlowDevice.h:24
double outletSpeciesMassFlowRate(size_t k)
Mass flow rate (kg/s) of outlet species k.
Definition: FlowDevice.cpp:59
bool install(ReactorBase &in, ReactorBase &out)
Install a flow device between two reactors.
Definition: FlowDevice.cpp:18
virtual std::string typeStr() const
String indicating the flow device implemented.
Definition: FlowDevice.h:35
Func1 * m_tfunc
Function set by setTimeFunction; used by updateMassFlowRate.
Definition: FlowDevice.h:106
double m_coeff
Coefficient set by derived classes; used by updateMassFlowRate.
Definition: FlowDevice.h:109
double enthalpy_mass()
specific enthalpy
Definition: FlowDevice.cpp:71
ReactorBase & in() const
Return a reference to the upstream reactor.
Definition: FlowDevice.h:80
virtual void setPressureFunction(Func1 *f)
Set a function of pressure that is used in determining the mass flow rate through the device.
Definition: FlowDevice.cpp:49
double massFlowRate()
Mass flow rate (kg/s).
Definition: FlowDevice.h:48
const ReactorBase & out() const
Return a const reference to the downstream reactor.
Definition: FlowDevice.h:85
virtual std::string type() const
String indicating the flow device implemented.
Definition: FlowDevice.h:43
virtual void setTimeFunction(Func1 *g)
Set a function of time that is used in determining the mass flow rate through the device.
Definition: FlowDevice.cpp:54
virtual void updateMassFlowRate(double time)
Update the mass flow rate at time 'time'.
Definition: FlowDevice.h:59
Func1 * m_pfunc
Function set by setPressureFunction; used by updateMassFlowRate.
Definition: FlowDevice.h:103
Base class for 'functor' classes that evaluate a function of one variable.
Definition: Func1.h:44
Base class for stirred reactors.
Definition: ReactorBase.h:49
This file contains definitions of constants, types and terms that are used in internal routines and a...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles,...
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition: ct_defs.h:161
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