Cantera 2.6.0
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
12
13namespace Cantera
14{
15
16class Kinetics;
17class SurfPhase;
18class Func1;
19
20/**
21 * Base class for 'walls' (walls, pistons, etc.) connecting reactors.
22 * @ingroup ZeroD
23 */
25{
26public:
27 WallBase();
28
29 virtual ~WallBase() {}
30 WallBase(const WallBase&) = delete;
31 WallBase& operator=(const WallBase&) = delete;
32
33 //! String indicating the wall model implemented. Usually
34 //! corresponds to the name of the derived class.
35 virtual std::string type() const {
36 return "WallBase";
37 }
38
39 //! Rate of volume change (m^3/s) for the adjacent reactors.
40 /*!
41 * This method is called by Reactor::evalWalls(). Base class method
42 * does nothing (that is, constant volume), but may be overloaded.
43 */
44 virtual double vdot(double t) {
45 return 0.0;
46 }
47
48 //! Heat flow rate through the wall (W).
49 /*!
50 * This method is called by Reactor::evalWalls(). Base class method
51 * does nothing (that is, an adiabatic wall), but may be overloaded.
52 */
53 virtual double Q(double t) {
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
86protected:
87 ReactorBase* m_left;
88 ReactorBase* m_right;
89
90 std::vector<ReactorSurface> m_surf;
91
92 double m_area;
93};
94
95//! Represents a wall between between two ReactorBase objects.
96/*!
97 * Walls can move (changing the volume of the adjacent reactors) and allow heat
98 * transfer between reactors.
99 */
100class Wall : public WallBase
101{
102public:
103 Wall();
104
105 //! String indicating the wall model implemented. Usually
106 //! corresponds to the name of the derived class.
107 virtual std::string type() const {
108 return "Wall";
109 }
110
111 //! Set the wall velocity to a specified function of time, \f$ v(t) \f$.
112 void setVelocity(Func1* f=0) {
113 if (f) {
114 m_vf = f;
115 }
116 }
117
118 //! Rate of volume change (m^3/s) for the adjacent reactors.
119 /*!
120 * The volume rate of change is given by
121 * \f[
122 * \dot V = K A (P_{left} - P_{right}) + F(t)
123 * \f]
124 * where *K* is the specified expansion rate coefficient, *A* is the wall
125 * area, and *F(t)* is a specified function of time. Positive values for
126 * `vdot` correspond to increases in the volume of reactor on left, and
127 * decreases in the volume of the reactor on the right.
128 */
129 virtual double vdot(double t);
130
131 //! Specify the heat flux function \f$ q_0(t) \f$.
133 m_qf = q;
134 }
135
136 //! Heat flow rate through the wall (W).
137 /*!
138 * The heat flux is given by
139 * \f[
140 * Q = h A (T_{left} - T_{right}) + A G(t)
141 * \f]
142 * where *h* is the heat transfer coefficient, *A* is the wall area, and
143 * *G(t)* is a specified function of time. Positive values denote a flux
144 * from left to right.
145 */
146 virtual double Q(double t);
147
148 void setThermalResistance(double Rth) {
149 m_rrth = 1.0/Rth;
150 }
151
152 //! Set the overall heat transfer coefficient [W/m^2/K].
153 void setHeatTransferCoeff(double U) {
154 m_rrth = U;
155 }
156
157 //! Get the overall heat transfer coefficient [W/m^2/K].
158 double getHeatTransferCoeff() const {
159 return m_rrth;
160 }
161
162 //! Set the emissivity.
163 void setEmissivity(double epsilon) {
164 if (epsilon > 1.0 || epsilon < 0.0) {
165 throw CanteraError("WallBase::setEmissivity",
166 "emissivity must be between 0.0 and 1.0");
167 }
168 m_emiss = epsilon;
169 }
170
171 //! Get the emissivity.
172 double getEmissivity() const {
173 return m_emiss;
174 }
175
176 //! Set the expansion rate coefficient.
177 void setExpansionRateCoeff(double k) {
178 m_k = k;
179 }
180
181 //! Get the expansion rate coefficient
182 double getExpansionRateCoeff() const {
183 return m_k;
184 }
185
186protected:
187
188 //! expansion rate coefficient
189 double m_k;
190
191 //! heat transfer coefficient
192 double m_rrth;
193
194 //! emissivity
195 double m_emiss;
196
197 //! Velocity function
199
200 //! Heat flux function
202};
203
204}
205
206#endif
Header file for class ReactorSurface.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
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
Base class for 'walls' (walls, pistons, etc.) connecting reactors.
Definition: Wall.h:25
bool install(ReactorBase &leftReactor, ReactorBase &rightReactor)
Install the wall between two reactors or reservoirs.
Definition: Wall.cpp:16
virtual bool ready()
True if the wall is correctly configured and ready to use.
Definition: Wall.h:72
ReactorBase & left() const
Return a reference to the Reactor or Reservoir to the left of the wall.
Definition: Wall.h:77
virtual void initialize()
Called just before the start of integration.
Definition: Wall.h:69
virtual double vdot(double t)
Rate of volume change (m^3/s) for the adjacent reactors.
Definition: Wall.h:44
double area()
Area in (m^2).
Definition: Wall.h:58
virtual void setArea(double a)
Set the area [m^2].
Definition: Wall.cpp:31
virtual double Q(double t)
Heat flow rate through the wall (W).
Definition: Wall.h:53
virtual std::string type() const
String indicating the wall model implemented.
Definition: Wall.h:35
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:101
Func1 * m_vf
Velocity function.
Definition: Wall.h:198
double getHeatTransferCoeff() const
Get the overall heat transfer coefficient [W/m^2/K].
Definition: Wall.h:158
void setExpansionRateCoeff(double k)
Set the expansion rate coefficient.
Definition: Wall.h:177
void setEmissivity(double epsilon)
Set the emissivity.
Definition: Wall.h:163
void setHeatFlux(Func1 *q)
Specify the heat flux function .
Definition: Wall.h:132
double m_rrth
heat transfer coefficient
Definition: Wall.h:192
double getExpansionRateCoeff() const
Get the expansion rate coefficient.
Definition: Wall.h:182
Func1 * m_qf
Heat flux function.
Definition: Wall.h:201
virtual std::string type() const
String indicating the wall model implemented.
Definition: Wall.h:107
double m_k
expansion rate coefficient
Definition: Wall.h:189
double getEmissivity() const
Get the emissivity.
Definition: Wall.h:172
double m_emiss
emissivity
Definition: Wall.h:195
void setVelocity(Func1 *f=0)
Set the wall velocity to a specified function of time, .
Definition: Wall.h:112
void setHeatTransferCoeff(double U)
Set the overall heat transfer coefficient [W/m^2/K].
Definition: Wall.h:153
virtual double Q(double t)
Heat flow rate through the wall (W).
Definition: Wall.cpp:49
virtual double vdot(double t)
Rate of volume change (m^3/s) for the adjacent reactors.
Definition: Wall.cpp:39
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Namespace for the Cantera kernel.
Definition: AnyMap.h:29