Cantera  2.1.2
Wall.h
Go to the documentation of this file.
1 /**
2  * @file Wall.h
3  * Header file for class Wall.
4  */
5 // Copyright 2001-2004 California Institute of Technology
6 
7 #ifndef CT_WALL_H
8 #define CT_WALL_H
9 
10 #include "cantera/base/ct_defs.h"
12 #include "cantera/numerics/Func1.h"
13 
14 namespace Cantera
15 {
16 
17 // forward references
18 class ReactorBase;
19 class Kinetics;
20 class Func1;
21 class SurfPhase;
22 
23 //! Represents a wall between between two ReactorBase objects.
24 /*!
25  * Walls can move (changing the volume of the adjacent reactors), allow heat
26  * transfer between reactors, and provide a location for surface reactions to
27  * take place.
28  */
29 class Wall
30 {
31 public:
32  Wall();
33 
34  virtual ~Wall() {}
35 
36  //! Rate of volume change (m^3/s) for the adjacent reactors.
37  /*! The volume rate of change is given by
38  * \f[ \dot V = K A (P_{left} - P_{right}) + F(t) \f]
39  * where *K* is the specified expansion rate coefficient, *A* is the wall
40  * area, and *F(t)* is a specified function of time. Positive values for
41  * `vdot` correspond to increases in the volume of reactor on left, and
42  * decreases in the volume of the reactor on the right.
43  */
44  virtual doublereal vdot(doublereal t);
45 
46  //! Heat flow rate through the wall (W).
47  /*!
48  * The heat flux is given by
49  * \f[ Q = h A (T_{left} - T_{right}) + A G(t) \f]
50  * where *h* is the heat transfer coefficient, *A* is the wall area, and
51  * *G(t)* is a specified function of time. Positive values denote a flux
52  * from left to right.
53  */
54  virtual doublereal Q(doublereal t);
55 
56  //! Area in m^2.
57  doublereal area() {
58  return m_area;
59  }
60 
61  //! Set the area [m^2].
62  void setArea(doublereal a) {
63  m_area = a;
64  }
65 
66  //! Get the area [m^2]
67  double getArea() const {
68  return m_area;
69  }
70 
71  void setThermalResistance(doublereal Rth) {
72  m_rrth = 1.0/Rth;
73  }
74 
75  //! Set the overall heat transfer coefficient [W/m^2/K].
76  void setHeatTransferCoeff(doublereal U) {
77  m_rrth = U;
78  }
79 
80  //! Get the overall heat transfer coefficient [W/m^2/K].
81  double getHeatTransferCoeff() const {
82  return m_rrth;
83  }
84 
85  //! Set the emissivity.
86  void setEmissivity(doublereal epsilon) {
87  if (epsilon > 1.0 || epsilon < 0.0)
88  throw Cantera::CanteraError("Wall::setEmissivity",
89  "emissivity must be between 0.0 and 1.0");
90  m_emiss = epsilon;
91  }
92 
93  double getEmissivity() const {
94  return m_emiss;
95  }
96 
97  //! Set the wall velocity to a specified function of time
99  if (f) {
100  m_vf = f;
101  }
102  }
103 
104  //! Set the expansion rate coefficient.
105  void setExpansionRateCoeff(doublereal k) {
106  m_k = k;
107  }
108 
109  //! Get the expansion rate coefficient
110  double getExpansionRateCoeff() const {
111  return m_k;
112  }
113 
114  //! Specify the heat flux function \f$ q_0(t) \f$.
116  m_qf = q;
117  }
118 
119  //! Install the wall between two reactors or reservoirs
120  bool install(ReactorBase& leftReactor, ReactorBase& rightReactor);
121 
122  //! Called just before the start of integration
123  virtual void initialize();
124 
125  //! True if the wall is correctly configured and ready to use.
126  virtual bool ready() {
127  return (m_left != 0 && m_right != 0);
128  }
129 
130  //! Return a reference to the Reactor or Reservoir to the left
131  //! of the wall.
132  ReactorBase& left() const {
133  return *m_left;
134  }
135 
136  //! Return a reference to the Reactor or Reservoir to the
137  //! right of the wall.
138  const ReactorBase& right() {
139  return *m_right;
140  }
141 
142  //! Specify the heterogeneous reaction mechanisms for each side of the
143  //! wall. Passing a null pointer indicates that there is no reaction
144  //! mechanism for the corresponding wall surface.
145  void setKinetics(Cantera::Kinetics* leftMechanism,
146  Cantera::Kinetics* rightMechanism);
147 
148  //! Return a pointer to the surface phase object for the left
149  //! (`leftright=0`) or right (`leftright=1`) wall surface.
150  Cantera::SurfPhase* surface(int leftright) {
151  return m_surf[leftright];
152  }
153 
154  //! Return a pointer to the surface kinetics object for the left
155  //! (`leftright=0`) or right (`leftright=1`) wall surface.
156  Cantera::Kinetics* kinetics(int leftright) {
157  return m_chem[leftright];
158  }
159 
160  //! Set the surface coverages on the left (`leftright = 0`) or right
161  //! (`leftright = 1`) surface to the values in array `cov`.
162  void setCoverages(int leftright, const doublereal* cov);
163 
164  //! Write the coverages of the left or right surface into array `cov`.
165  void getCoverages(int leftright, doublereal* cov);
166 
167  //! Set the coverages in the surface phase object to the
168  //! values for this wall surface.
169  void syncCoverages(int leftright);
170 
171  //! Number of sensitivity parameters associated with reactions on the left
172  //! (`lr = 0`) or right (`lr = 1`) side of the wall.
173  size_t nSensParams(int lr) const {
174  if (lr == 0) {
175  return m_pleft.size();
176  } else {
177  return m_pright.size();
178  }
179  }
180  void addSensitivityReaction(int leftright, size_t rxn);
181  void setSensitivityParameters(int lr, double* params);
182  void resetSensitivityParameters(int lr);
183 
184 protected:
185  ReactorBase* m_left;
186  ReactorBase* m_right;
187  Cantera::Kinetics* m_chem[2];
188  Cantera::SurfPhase* m_surf[2];
189  size_t m_nsp[2];
190  doublereal m_area, m_k, m_rrth;
191  doublereal m_emiss;
192  Cantera::Func1* m_vf;
193  Cantera::Func1* m_qf;
194  Cantera::vector_fp m_leftcov, m_rightcov;
195 
196  std::vector<size_t> m_pleft, m_pright;
197  Cantera::vector_fp m_leftmult_save, m_rightmult_save;
198 };
199 
200 }
201 
202 #endif
virtual bool ready()
True if the wall is correctly configured and ready to use.
Definition: Wall.h:126
const ReactorBase & right()
Return a reference to the Reactor or Reservoir to the right of the wall.
Definition: Wall.h:138
Cantera::Kinetics * kinetics(int leftright)
Return a pointer to the surface kinetics object for the left (leftright=0) or right (leftright=1) wal...
Definition: Wall.h:156
virtual doublereal Q(doublereal t)
Heat flow rate through the wall (W).
Definition: Wall.cpp:81
bool install(ReactorBase &leftReactor, ReactorBase &rightReactor)
Install the wall between two reactors or reservoirs.
Definition: Wall.cpp:22
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
void setKinetics(Cantera::Kinetics *leftMechanism, Cantera::Kinetics *rightMechanism)
Specify the heterogeneous reaction mechanisms for each side of the wall.
Definition: Wall.cpp:41
size_t nSensParams(int lr) const
Number of sensitivity parameters associated with reactions on the left (lr = 0) or right (lr = 1) sid...
Definition: Wall.h:173
void setHeatTransferCoeff(doublereal U)
Set the overall heat transfer coefficient [W/m^2/K].
Definition: Wall.h:76
doublereal area()
Area in m^2.
Definition: Wall.h:57
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
Represents a wall between between two ReactorBase objects.
Definition: Wall.h:29
void setCoverages(int leftright, const doublereal *cov)
Set the surface coverages on the left (leftright = 0) or right (leftright = 1) surface to the values ...
Definition: Wall.cpp:96
Public interface for kinetics managers.
Definition: Kinetics.h:131
Base class for 'functor' classes that evaluate a function of one variable.
Definition: Func1.h:45
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
Base class for stirred reactors.
Definition: ReactorBase.h:30
void setEmissivity(doublereal epsilon)
Set the emissivity.
Definition: Wall.h:86
double getHeatTransferCoeff() const
Get the overall heat transfer coefficient [W/m^2/K].
Definition: Wall.h:81
void syncCoverages(int leftright)
Set the coverages in the surface phase object to the values for this wall surface.
Definition: Wall.cpp:114
Cantera::SurfPhase * surface(int leftright)
Return a pointer to the surface phase object for the left (leftright=0) or right (leftright=1) wall s...
Definition: Wall.h:150
double getExpansionRateCoeff() const
Get the expansion rate coefficient.
Definition: Wall.h:110
void setVelocity(Cantera::Func1 *f=0)
Set the wall velocity to a specified function of time.
Definition: Wall.h:98
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
virtual doublereal vdot(doublereal t)
Rate of volume change (m^3/s) for the adjacent reactors.
Definition: Wall.cpp:71
double getArea() const
Get the area [m^2].
Definition: Wall.h:67
void setExpansionRateCoeff(doublereal k)
Set the expansion rate coefficient.
Definition: Wall.h:105
ReactorBase & left() const
Return a reference to the Reactor or Reservoir to the left of the wall.
Definition: Wall.h:132
void getCoverages(int leftright, doublereal *cov)
Write the coverages of the left or right surface into array cov.
Definition: Wall.cpp:105
virtual void initialize()
Called just before the start of integration.
Definition: Wall.cpp:35
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
void setHeatFlux(Cantera::Func1 *q)
Specify the heat flux function .
Definition: Wall.h:115
void setArea(doublereal a)
Set the area [m^2].
Definition: Wall.h:62