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