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