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