Cantera  2.0
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 class Wall
24 {
25 
26 public:
27 
28  /// Constructor
29  Wall();
30 
31  /// Destructor. Since Wall instances do not allocate memory,
32  /// the destructor does nothing.
33  virtual ~Wall() {}
34 
35 
36  /// Rate of volume change (kg/s). Positive value increases
37  /// volume of reactor on left, and decreases volume on right.
38  virtual doublereal vdot(doublereal t);
39 
40  /// Heat flow rate through the wall (W). Positive values
41  /// denote a flux from left to right.
42  virtual doublereal Q(doublereal t);
43 
44  /// Area in m^2.
45  doublereal area() {
46  return m_area;
47  }
48 
49  /// Set the area [m^2].
50  void setArea(doublereal a) {
51  m_area = a;
52  }
53 
54  void setThermalResistance(doublereal Rth) {
55  m_rrth = 1.0/Rth;
56  }
57 
58  /// Set the overall heat transfer coefficient [W/m^2/K].
59  void setHeatTransferCoeff(doublereal U) {
60  m_rrth = U;
61  }
62 
63  /// Set the emissivity.
64  void setEmissivity(doublereal epsilon) {
65  if (epsilon > 1.0 || epsilon < 0.0)
66  throw Cantera::CanteraError("Wall::setEmissivity",
67  "emissivity must be between 0.0 and 1.0");
68  m_emiss = epsilon;
69  }
70 
71  /** Set the piston velocity to a specified function. */
72  void setVelocity(Cantera::Func1* f=0) {
73  if (f) {
74  m_vf = f;
75  }
76  }
77 
78  /**
79  * Set the expansion rate coefficient.
80  */
81  void setExpansionRateCoeff(doublereal k) {
82  m_k = k;
83  }
84 
85 
86  /// Specify the heat flux function \f$ q_0(t) \f$.
87  void setHeatFlux(Cantera::Func1* q) {
88  m_qf = q;
89  }
90 
91  /// Install the wall between two reactors or reservoirs
92  bool install(ReactorBase& leftReactor, ReactorBase& rightReactor);
93 
94  /// True if the wall is correctly configured and ready to use.
95  virtual bool ready() {
96  return (m_left != 0 && m_right != 0);
97  }
98 
99  // int type() { return 0; }
100 
101 
102  /// Return a reference to the reactor or reservoir to the left
103  /// of the wall.
104  ReactorBase& left() const {
105  return *m_left;
106  }
107 
108  /// Return a reference to the reactor or reservoir to the
109  /// right of the wall.
110  const ReactorBase& right() {
111  return *m_right;
112  }
113 
114  // /// Set wall parameters.
115  //virtual void setParameters(int n, doublereal* coeffs) {
116  // m_coeffs.resize(n);
117  // copy(coeffs, coeffs + n, m_coeffs.begin());
118  //}
119 
120  // Specify the heterogeneous reaction mechanisms for each side
121  // of the wall.
122  void setKinetics(Cantera::Kinetics* leftMechanism,
123  Cantera::Kinetics* rightMechanism);
124 
125  /// Return a pointer to the surface phase object for the left
126  /// or right wall surface.
127  Cantera::SurfPhase* surface(int leftright) {
128  return m_surf[leftright];
129  }
130 
131  Cantera::Kinetics* kinetics(int leftright) {
132  return m_chem[leftright];
133  }
134 
135  /// Set the surface coverages on the left or right surface to
136  /// the values in array 'cov'.
137  void setCoverages(int leftright, const doublereal* cov);
138 
139  /// Write the coverages of the left or right surface into
140  /// array cov.
141  void getCoverages(int leftright, doublereal* cov);
142 
143  /// Set the coverages in the surface phase object to the
144  /// values for this wall surface.
145  void syncCoverages(int leftright);
146 
147 
148  size_t nSensParams(int lr) const {
149  if (lr == 0) {
150  return m_pleft.size();
151  } else {
152  return m_pright.size();
153  }
154  }
155  void addSensitivityReaction(int leftright, size_t rxn);
156  std::string sensitivityParamID(int leftright, size_t p) {
157  if (leftright == 0) {
158  return m_pname_left[p];
159  } else {
160  return m_pname_right[p];
161  }
162  }
163  void setSensitivityParameters(int lr, double* params);
164  void resetSensitivityParameters(int lr);
165 
166  // int componentIndex(string nm) const;
167 
168 protected:
169 
170  //vector_fp m_coeffs;
171 
172  ReactorBase* m_left;
173  ReactorBase* m_right;
174  Cantera::Kinetics* m_chem[2];
175  Cantera::SurfPhase* m_surf[2];
176  size_t m_nsp[2];
177  doublereal m_area, m_k, m_rrth;
178  doublereal m_emiss;
179  Cantera::Func1* m_vf;
180  Cantera::Func1* m_qf;
181  Cantera::vector_fp m_leftcov, m_rightcov;
182 
183  std::vector<size_t> m_pleft, m_pright;
184  Cantera::vector_fp m_leftmult_save, m_rightmult_save;
185  std::vector<std::string> m_pname_left, m_pname_right;
186 
187 private:
188 
189 };
190 
191 }
192 
193 #endif