Cantera  3.1.0
Loading...
Searching...
No Matches
Wall.h
Go to the documentation of this file.
1//! @file Wall.h Header file for base class WallBase.
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_WALL_H
7#define CT_WALL_H
8
11
12namespace Cantera
13{
14
15class Func1;
16
17/**
18 * Base class for 'walls' (walls, pistons, etc.) connecting reactors.
19 * @ingroup wallGroup
20 */
22{
23public:
24 WallBase(const string& name="(none)") : m_name(name) {}
25
26 virtual ~WallBase() {}
27 WallBase(const WallBase&) = delete;
28 WallBase& operator=(const WallBase&) = delete;
29
30 //! String indicating the wall model implemented. Usually
31 //! corresponds to the name of the derived class.
32 virtual string type() const {
33 return "WallBase";
34 }
35
36 //! Retrieve wall name.
37 string name() const {
38 return m_name;
39 }
40
41 //! Set wall name.
42 void setName(const string& name) {
43 m_name = name;
44 }
45
46 //! Set the default name of a wall. Returns `false` if it was previously set.
47 bool setDefaultName(map<string, int>& counts);
48
49 //! Rate of volume change (m^3/s) for the adjacent reactors at current reactor
50 //! network time.
51 /*!
52 * This method is called by Reactor::evalWalls(). Base class method
53 * does nothing (that is, constant volume), but may be overloaded.
54 * @since New in %Cantera 3.0.
55 */
56 virtual double expansionRate() {
57 return 0.0;
58 }
59
60 //! Heat flow rate through the wall (W) at current reactor network time.
61 /*!
62 * This method is called by Reactor::evalWalls(). Base class method
63 * does nothing (that is, an adiabatic wall), but may be overloaded.
64 * @since New in %Cantera 3.0.
65 */
66 virtual double heatRate() {
67 return 0.0;
68 }
69
70 //! Area in (m^2).
71 double area() {
72 return m_area;
73 }
74
75 //! Set the area [m^2].
76 virtual void setArea(double a);
77
78 //! Install the wall between two reactors or reservoirs
79 bool install(ReactorBase& leftReactor, ReactorBase& rightReactor);
80
81 //! Called just before the start of integration
82 virtual void initialize() {}
83
84 //! True if the wall is correctly configured and ready to use.
85 virtual bool ready() {
86 return (m_left != 0 && m_right != 0);
87 }
88
89 //! Return a reference to the Reactor or Reservoir to the left of the wall.
90 ReactorBase& left() const {
91 return *m_left;
92 }
93
94 //! Return a reference to the Reactor or Reservoir to the right of the wall.
96 return *m_right;
97 }
98
99 //! Set current reactor network time
100 /*!
101 * @since New in %Cantera 3.0.
102 */
103 void setSimTime(double time) {
104 m_time = time;
105 }
106
107protected:
108 string m_name; //!< Wall name.
109 bool m_defaultNameSet = false; //!< `true` if default name has been previously set.
110
111 ReactorBase* m_left = nullptr;
112 ReactorBase* m_right = nullptr;
113
114 //! current reactor network time
115 double m_time = 0.0;
116
117 double m_area = 1.0;
118};
119
120//! Represents a wall between between two ReactorBase objects.
121/*!
122 * Walls can move (changing the volume of the adjacent reactors) and allow heat
123 * transfer between reactors.
124 * @ingroup wallGroup
125 */
126class Wall : public WallBase
127{
128public:
129 using WallBase::WallBase; // inherit constructors
130
131 //! String indicating the wall model implemented. Usually
132 //! corresponds to the name of the derived class.
133 string type() const override {
134 return "Wall";
135 }
136
137 //! Wall velocity @f$ v(t) @f$ at current reactor network time.
138 //! @since New in %Cantera 3.0.
139 double velocity() const;
140
141 //! Set the wall velocity to a specified function of time, @f$ v(t) @f$.
142 void setVelocity(Func1* f=0) {
143 if (f) {
144 m_vf = f;
145 }
146 }
147
148 //! Rate of volume change (m^3/s) for the adjacent reactors.
149 /*!
150 * The volume rate of change is given by
151 * @f[
152 * \dot V = K A (P_{left} - P_{right}) + F(t)
153 * @f]
154 * where *K* is the specified expansion rate coefficient, *A* is the wall area,
155 * and and *F(t)* is a specified function evaluated at the current network time.
156 * Positive values for `expansionRate` correspond to increases in the volume of
157 * reactor on left, and decreases in the volume of the reactor on the right.
158 * @since New in %Cantera 3.0.
159 */
160 double expansionRate() override;
161
162 //! Heat flux function @f$ q_0(t) @f$ evaluated at current reactor network time.
163 //! @since New in %Cantera 3.0.
164 double heatFlux() const;
165
166 //! Specify the heat flux function @f$ q_0(t) @f$.
168 m_qf = q;
169 }
170
171 //! Heat flow rate through the wall (W).
172 /*!
173 * The heat flux is given by
174 * @f[
175 * Q = h A (T_{left} - T_{right}) + A G(t)
176 * @f]
177 * where *h* is the heat transfer coefficient, *A* is the wall area, and
178 * *G(t)* is a specified function of time evaluated at the current network
179 * time. Positive values denote a flux from left to right.
180 * @since New in %Cantera 3.0.
181 */
182 double heatRate() override;
183
184 void setThermalResistance(double Rth) {
185 m_rrth = 1.0/Rth;
186 }
187
188 //! Set the overall heat transfer coefficient [W/m^2/K].
189 void setHeatTransferCoeff(double U) {
190 m_rrth = U;
191 }
192
193 //! Get the overall heat transfer coefficient [W/m^2/K].
194 double getHeatTransferCoeff() const {
195 return m_rrth;
196 }
197
198 //! Set the emissivity.
199 void setEmissivity(double epsilon) {
200 if (epsilon > 1.0 || epsilon < 0.0) {
201 throw CanteraError("WallBase::setEmissivity",
202 "emissivity must be between 0.0 and 1.0");
203 }
204 m_emiss = epsilon;
205 }
206
207 //! Get the emissivity.
208 double getEmissivity() const {
209 return m_emiss;
210 }
211
212 //! Set the expansion rate coefficient.
213 void setExpansionRateCoeff(double k) {
214 m_k = k;
215 }
216
217 //! Get the expansion rate coefficient
218 double getExpansionRateCoeff() const {
219 return m_k;
220 }
221
222protected:
223
224 //! expansion rate coefficient
225 double m_k = 0.0;
226
227 //! heat transfer coefficient
228 double m_rrth = 0.0;
229
230 //! emissivity
231 double m_emiss = 0.0;
232
233 //! Velocity function
234 Func1* m_vf = nullptr;
235
236 //! Heat flux function
237 Func1* m_qf = nullptr;
238};
239
240}
241
242#endif
Base class for exceptions thrown by Cantera classes.
Base class for 'functor' classes that evaluate a function of one variable.
Definition Func1.h:75
Base class for stirred reactors.
Definition ReactorBase.h:49
Base class for 'walls' (walls, pistons, etc.) connecting reactors.
Definition Wall.h:22
bool install(ReactorBase &leftReactor, ReactorBase &rightReactor)
Install the wall between two reactors or reservoirs.
Definition Wall.cpp:26
virtual bool ready()
True if the wall is correctly configured and ready to use.
Definition Wall.h:85
virtual double expansionRate()
Rate of volume change (m^3/s) for the adjacent reactors at current reactor network time.
Definition Wall.h:56
bool m_defaultNameSet
true if default name has been previously set.
Definition Wall.h:109
virtual string type() const
String indicating the wall model implemented.
Definition Wall.h:32
double m_time
current reactor network time
Definition Wall.h:115
ReactorBase & left() const
Return a reference to the Reactor or Reservoir to the left of the wall.
Definition Wall.h:90
bool setDefaultName(map< string, int > &counts)
Set the default name of a wall. Returns false if it was previously set.
Definition Wall.cpp:13
void setSimTime(double time)
Set current reactor network time.
Definition Wall.h:103
ReactorBase & right()
Return a reference to the Reactor or Reservoir to the right of the wall.
Definition Wall.h:95
void setName(const string &name)
Set wall name.
Definition Wall.h:42
virtual void initialize()
Called just before the start of integration.
Definition Wall.h:82
double area()
Area in (m^2).
Definition Wall.h:71
virtual void setArea(double a)
Set the area [m^2].
Definition Wall.cpp:39
virtual double heatRate()
Heat flow rate through the wall (W) at current reactor network time.
Definition Wall.h:66
string m_name
Wall name.
Definition Wall.h:108
string name() const
Retrieve wall name.
Definition Wall.h:37
Represents a wall between between two ReactorBase objects.
Definition Wall.h:127
Func1 * m_vf
Velocity function.
Definition Wall.h:234
double getHeatTransferCoeff() const
Get the overall heat transfer coefficient [W/m^2/K].
Definition Wall.h:194
string type() const override
String indicating the wall model implemented.
Definition Wall.h:133
double heatFlux() const
Heat flux function evaluated at current reactor network time.
Definition Wall.cpp:64
void setExpansionRateCoeff(double k)
Set the expansion rate coefficient.
Definition Wall.h:213
void setEmissivity(double epsilon)
Set the emissivity.
Definition Wall.h:199
double heatRate() override
Heat flow rate through the wall (W).
Definition Wall.cpp:71
void setHeatFlux(Func1 *q)
Specify the heat flux function .
Definition Wall.h:167
double m_rrth
heat transfer coefficient
Definition Wall.h:228
double getExpansionRateCoeff() const
Get the expansion rate coefficient.
Definition Wall.h:218
Func1 * m_qf
Heat flux function.
Definition Wall.h:237
double m_k
expansion rate coefficient
Definition Wall.h:225
double getEmissivity() const
Get the emissivity.
Definition Wall.h:208
double velocity() const
Wall velocity at current reactor network time.
Definition Wall.cpp:43
double expansionRate() override
Rate of volume change (m^3/s) for the adjacent reactors.
Definition Wall.cpp:50
double m_emiss
emissivity
Definition Wall.h:231
void setVelocity(Func1 *f=0)
Set the wall velocity to a specified function of time, .
Definition Wall.h:142
void setHeatTransferCoeff(double U)
Set the overall heat transfer coefficient [W/m^2/K].
Definition Wall.h:189
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595