Cantera  3.1.0a1
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() = default;
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 //! Rate of volume change (m^3/s) for the adjacent reactors.
37 /*!
38 * This method is called by Reactor::evalWalls(). Base class method
39 * does nothing (that is, constant volume), but may be overloaded.
40 * @deprecated Still used by traditional MATLAB toolbox; replaceable by expansionRate.
41 */
42 virtual double vdot(double t) {
43 warn_deprecated("WallBase::vdot",
44 "To be removed; replaceable by 'expansionRate'.");
45 return 0.0;
46 }
47
48 //! Rate of volume change (m^3/s) for the adjacent reactors at current reactor
49 //! network time.
50 /*!
51 * This method is called by Reactor::evalWalls(). Base class method
52 * does nothing (that is, constant volume), but may be overloaded.
53 * @since New in %Cantera 3.0.
54 */
55 virtual double expansionRate() {
56 return 0.0;
57 }
58
59 //! Heat flow rate through the wall (W).
60 /*!
61 * This method is called by Reactor::evalWalls(). Base class method
62 * does nothing (that is, an adiabatic wall), but may be overloaded.
63 * @deprecated Still used by traditional MATLAB toolbox; replaceable by heatRate.
64 */
65 virtual double Q(double t) {
66 warn_deprecated("WallBase::Q",
67 "To be removed; replaceable by 'heatRate'.");
68 return 0.0;
69 }
70
71 //! Heat flow rate through the wall (W) at current reactor network time.
72 /*!
73 * This method is called by Reactor::evalWalls(). Base class method
74 * does nothing (that is, an adiabatic wall), but may be overloaded.
75 * @since New in %Cantera 3.0.
76 */
77 virtual double heatRate() {
78 return 0.0;
79 }
80
81 //! Area in (m^2).
82 double area() {
83 return m_area;
84 }
85
86 //! Set the area [m^2].
87 virtual void setArea(double a);
88
89 //! Install the wall between two reactors or reservoirs
90 bool install(ReactorBase& leftReactor, ReactorBase& rightReactor);
91
92 //! Called just before the start of integration
93 virtual void initialize() {}
94
95 //! True if the wall is correctly configured and ready to use.
96 virtual bool ready() {
97 return (m_left != 0 && m_right != 0);
98 }
99
100 //! Return a reference to the Reactor or Reservoir to the left of the wall.
101 ReactorBase& left() const {
102 return *m_left;
103 }
104
105 //! Return a reference to the Reactor or Reservoir to the right of the wall.
107 return *m_right;
108 }
109
110 //! Set current reactor network time
111 /*!
112 * @since New in %Cantera 3.0.
113 */
114 void setSimTime(double time) {
115 m_time = time;
116 }
117
118protected:
119 ReactorBase* m_left = nullptr;
120 ReactorBase* m_right = nullptr;
121
122 //! current reactor network time
123 double m_time = 0.0;
124
125 double m_area = 1.0;
126};
127
128//! Represents a wall between between two ReactorBase objects.
129/*!
130 * Walls can move (changing the volume of the adjacent reactors) and allow heat
131 * transfer between reactors.
132 * @ingroup wallGroup
133 */
134class Wall : public WallBase
135{
136public:
137 Wall() = default;
138
139 //! String indicating the wall model implemented. Usually
140 //! corresponds to the name of the derived class.
141 string type() const override {
142 return "Wall";
143 }
144
145 //! Wall velocity @f$ v(t) @f$ at current reactor network time.
146 //! @since New in %Cantera 3.0.
147 double velocity() const;
148
149 //! Set the wall velocity to a specified function of time, @f$ v(t) @f$.
150 void setVelocity(Func1* f=0) {
151 if (f) {
152 m_vf = f;
153 }
154 }
155
156 //! Rate of volume change (m^3/s) for the adjacent reactors.
157 /*!
158 * The volume rate of change is given by
159 * @f[
160 * \dot V = K A (P_{left} - P_{right}) + F(t)
161 * @f]
162 * where *K* is the specified expansion rate coefficient, *A* is the wall
163 * area, and *F(t)* is a specified function of time. Positive values for
164 * `vdot` correspond to increases in the volume of reactor on left, and
165 * decreases in the volume of the reactor on the right.
166 * @deprecated Still used by traditional MATLAB toolbox; replaceable by
167 * expansionRate.
168 */
169 double vdot(double t) override;
170
171 //! Rate of volume change (m^3/s) for the adjacent reactors.
172 /*!
173 * The volume rate of change is given by
174 * @f[
175 * \dot V = K A (P_{left} - P_{right}) + F(t)
176 * @f]
177 * where *K* is the specified expansion rate coefficient, *A* is the wall area,
178 * and and *F(t)* is a specified function evaluated at the current network time.
179 * Positive values for `expansionRate` correspond to increases in the volume of
180 * reactor on left, and decreases in the volume of the reactor on the right.
181 * @since New in %Cantera 3.0.
182 */
183 double expansionRate() override;
184
185 //! Heat flux function @f$ q_0(t) @f$ evaluated at current reactor network time.
186 //! @since New in %Cantera 3.0.
187 double heatFlux() const;
188
189 //! Specify the heat flux function @f$ q_0(t) @f$.
191 m_qf = q;
192 }
193
194 //! Heat flow rate through the wall (W).
195 /*!
196 * The heat flux is given by
197 * @f[
198 * Q = h A (T_{left} - T_{right}) + A G(t)
199 * @f]
200 * where *h* is the heat transfer coefficient, *A* is the wall area, and
201 * *G(t)* is a specified function of time. Positive values denote a flux
202 * from left to right.
203 * @deprecated Still used by traditional MATLAB toolbox; replaceable by heatRate.
204 */
205 double Q(double t) override;
206
207 //! Heat flow rate through the wall (W).
208 /*!
209 * The heat flux is given by
210 * @f[
211 * Q = h A (T_{left} - T_{right}) + A G(t)
212 * @f]
213 * where *h* is the heat transfer coefficient, *A* is the wall area, and
214 * *G(t)* is a specified function of time evaluated at the current network
215 * time. Positive values denote a flux from left to right.
216 * @since New in %Cantera 3.0.
217 */
218 double heatRate() override;
219
220 void setThermalResistance(double Rth) {
221 m_rrth = 1.0/Rth;
222 }
223
224 //! Set the overall heat transfer coefficient [W/m^2/K].
225 void setHeatTransferCoeff(double U) {
226 m_rrth = U;
227 }
228
229 //! Get the overall heat transfer coefficient [W/m^2/K].
230 double getHeatTransferCoeff() const {
231 return m_rrth;
232 }
233
234 //! Set the emissivity.
235 void setEmissivity(double epsilon) {
236 if (epsilon > 1.0 || epsilon < 0.0) {
237 throw CanteraError("WallBase::setEmissivity",
238 "emissivity must be between 0.0 and 1.0");
239 }
240 m_emiss = epsilon;
241 }
242
243 //! Get the emissivity.
244 double getEmissivity() const {
245 return m_emiss;
246 }
247
248 //! Set the expansion rate coefficient.
249 void setExpansionRateCoeff(double k) {
250 m_k = k;
251 }
252
253 //! Get the expansion rate coefficient
254 double getExpansionRateCoeff() const {
255 return m_k;
256 }
257
258protected:
259
260 //! expansion rate coefficient
261 double m_k = 0.0;
262
263 //! heat transfer coefficient
264 double m_rrth = 0.0;
265
266 //! emissivity
267 double m_emiss = 0.0;
268
269 //! Velocity function
270 Func1* m_vf = nullptr;
271
272 //! Heat flux function
273 Func1* m_qf = nullptr;
274};
275
276}
277
278#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:51
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:13
virtual bool ready()
True if the wall is correctly configured and ready to use.
Definition Wall.h:96
virtual double expansionRate()
Rate of volume change (m^3/s) for the adjacent reactors at current reactor network time.
Definition Wall.h:55
virtual string type() const
String indicating the wall model implemented.
Definition Wall.h:32
double m_time
current reactor network time
Definition Wall.h:123
ReactorBase & left() const
Return a reference to the Reactor or Reservoir to the left of the wall.
Definition Wall.h:101
void setSimTime(double time)
Set current reactor network time.
Definition Wall.h:114
virtual void initialize()
Called just before the start of integration.
Definition Wall.h:93
virtual double vdot(double t)
Rate of volume change (m^3/s) for the adjacent reactors.
Definition Wall.h:42
double area()
Area in (m^2).
Definition Wall.h:82
virtual void setArea(double a)
Set the area [m^2].
Definition Wall.cpp:26
virtual double Q(double t)
Heat flow rate through the wall (W).
Definition Wall.h:65
virtual double heatRate()
Heat flow rate through the wall (W) at current reactor network time.
Definition Wall.h:77
const ReactorBase & right()
Return a reference to the Reactor or Reservoir to the right of the wall.
Definition Wall.h:106
Represents a wall between between two ReactorBase objects.
Definition Wall.h:135
Func1 * m_vf
Velocity function.
Definition Wall.h:270
double getHeatTransferCoeff() const
Get the overall heat transfer coefficient [W/m^2/K].
Definition Wall.h:230
string type() const override
String indicating the wall model implemented.
Definition Wall.h:141
double heatFlux() const
Heat flux function evaluated at current reactor network time.
Definition Wall.cpp:66
double vdot(double t) override
Rate of volume change (m^3/s) for the adjacent reactors.
Definition Wall.cpp:37
void setExpansionRateCoeff(double k)
Set the expansion rate coefficient.
Definition Wall.h:249
void setEmissivity(double epsilon)
Set the emissivity.
Definition Wall.h:235
double heatRate() override
Heat flow rate through the wall (W).
Definition Wall.cpp:94
void setHeatFlux(Func1 *q)
Specify the heat flux function .
Definition Wall.h:190
double m_rrth
heat transfer coefficient
Definition Wall.h:264
double getExpansionRateCoeff() const
Get the expansion rate coefficient.
Definition Wall.h:254
Func1 * m_qf
Heat flux function.
Definition Wall.h:273
double m_k
expansion rate coefficient
Definition Wall.h:261
double Q(double t) override
Heat flow rate through the wall (W).
Definition Wall.cpp:73
double getEmissivity() const
Get the emissivity.
Definition Wall.h:244
double velocity() const
Wall velocity at current reactor network time.
Definition Wall.cpp:30
double expansionRate() override
Rate of volume change (m^3/s) for the adjacent reactors.
Definition Wall.cpp:52
double m_emiss
emissivity
Definition Wall.h:267
void setVelocity(Func1 *f=0)
Set the wall velocity to a specified function of time, .
Definition Wall.h:150
void setHeatTransferCoeff(double U)
Set the overall heat transfer coefficient [W/m^2/K].
Definition Wall.h:225
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
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