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