Cantera  2.3.0
Inlet1D.h
Go to the documentation of this file.
1 /**
2  * @file Inlet1D.h
3  *
4  * Boundary objects for one-dimensional simulations.
5  */
6 
7 // This file is part of Cantera. See License.txt in the top-level directory or
8 // at http://www.cantera.org/license.txt for license and copyright information.
9 
10 #ifndef CT_BDRY1D_H
11 #define CT_BDRY1D_H
12 
13 #include "Domain1D.h"
16 #include "StFlow.h"
17 
18 namespace Cantera
19 {
20 
21 const int LeftInlet = 1;
22 const int RightInlet = -1;
23 
24 /**
25  * The base class for boundaries between one-dimensional spatial domains. The
26  * boundary may have its own internal variables, such as surface species
27  * coverages.
28  *
29  * The boundary types are an inlet, an outlet, a symmetry plane, and a surface.
30  *
31  * The public methods are all virtual, and the base class implementations throw
32  * exceptions.
33  * @ingroup onedim
34  */
35 class Bdry1D : public Domain1D
36 {
37 public:
38  Bdry1D();
39 
40  virtual void init() {
41  _init(1);
42  }
43 
44  /// Set the temperature.
45  virtual void setTemperature(doublereal t) {
46  m_temp = t;
47  }
48 
49  /// Temperature [K].
50  virtual doublereal temperature() {
51  return m_temp;
52  }
53 
54  virtual size_t nSpecies() {
55  return 0;
56  }
57 
58  /// Set the mole fractions by specifying a std::string.
59  virtual void setMoleFractions(const std::string& xin) {
60  throw NotImplementedError("Bdry1D::setMoleFractions");
61  }
62 
63  /// Set the mole fractions by specifying an array.
64  virtual void setMoleFractions(const doublereal* xin) {
65  throw NotImplementedError("Bdry1D::setMoleFractions");
66  }
67 
68  /// Mass fraction of species k.
69  virtual doublereal massFraction(size_t k) {
70  throw NotImplementedError("Bdry1D::massFraction");
71  }
72 
73  /// Set the total mass flow rate.
74  virtual void setMdot(doublereal mdot) {
75  m_mdot = mdot;
76  }
77 
78  /// The total mass flow rate [kg/m2/s].
79  virtual doublereal mdot() {
80  return m_mdot;
81  }
82 
83  virtual void setupGrid(size_t n, const doublereal* z) {}
84 
85 protected:
86  void _init(size_t n);
87 
88  StFlow* m_flow_left, *m_flow_right;
89  size_t m_ilr, m_left_nv, m_right_nv;
90  size_t m_left_loc, m_right_loc;
91  size_t m_left_points;
92  size_t m_left_nsp, m_right_nsp;
93  size_t m_sp_left, m_sp_right;
94  size_t m_start_left, m_start_right;
95  ThermoPhase* m_phase_left, *m_phase_right;
96  doublereal m_temp, m_mdot;
97 };
98 
99 
100 /**
101  * An inlet.
102  * @ingroup onedim
103  */
104 class Inlet1D : public Bdry1D
105 {
106 public:
107  Inlet1D();
108 
109  /// set spreading rate
110  virtual void setSpreadRate(doublereal V0) {
111  m_V0 = V0;
112  needJacUpdate();
113  }
114 
115  /// spreading rate
116  virtual double spreadRate() {
117  return m_V0;
118  }
119 
120  virtual void showSolution(const double* x);
121 
122  virtual size_t nSpecies() {
123  return m_nsp;
124  }
125 
126  virtual void setMoleFractions(const std::string& xin);
127  virtual void setMoleFractions(const doublereal* xin);
128  virtual doublereal massFraction(size_t k) {
129  return m_yin[k];
130  }
131  virtual void init();
132  virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
133  integer* diagg, doublereal rdt);
134  virtual XML_Node& save(XML_Node& o, const doublereal* const soln);
135  virtual void restore(const XML_Node& dom, doublereal* soln, int loglevel);
136 
137 protected:
138  int m_ilr;
139  doublereal m_V0;
140  size_t m_nsp;
141  vector_fp m_yin;
142  std::string m_xstr;
143  StFlow* m_flow;
144 };
145 
146 /**
147  * A terminator that does nothing.
148  * @ingroup onedim
149  */
150 class Empty1D : public Bdry1D
151 {
152 public:
153  Empty1D() : Bdry1D() {
154  m_type = cEmptyType;
155  }
156 
157  virtual void showSolution(const doublereal* x) {}
158 
159  virtual void init();
160 
161  virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
162  integer* diagg, doublereal rdt);
163 
164  virtual XML_Node& save(XML_Node& o, const doublereal* const soln);
165  virtual void restore(const XML_Node& dom, doublereal* soln, int loglevel);
166 };
167 
168 /**
169  * A symmetry plane. The axial velocity u = 0, and all other components have
170  * zero axial gradients.
171  * @ingroup onedim
172  */
173 class Symm1D : public Bdry1D
174 {
175 public:
176  Symm1D() : Bdry1D() {
177  m_type = cSymmType;
178  }
179 
180  virtual void init();
181 
182  virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
183  integer* diagg, doublereal rdt);
184 
185  virtual XML_Node& save(XML_Node& o, const doublereal* const soln);
186  virtual void restore(const XML_Node& dom, doublereal* soln, int loglevel);
187 };
188 
189 
190 /**
191  * An outlet.
192  * @ingroup onedim
193  */
194 class Outlet1D : public Bdry1D
195 {
196 public:
197  Outlet1D() : Bdry1D() {
198  m_type = cOutletType;
199  }
200 
201  virtual void init();
202 
203  virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
204  integer* diagg, doublereal rdt);
205 
206  virtual XML_Node& save(XML_Node& o, const doublereal* const soln);
207  virtual void restore(const XML_Node& dom, doublereal* soln, int loglevel);
208 };
209 
210 
211 /**
212  * An outlet with specified composition.
213  * @ingroup onedim
214  */
215 class OutletRes1D : public Bdry1D
216 {
217 public:
218  OutletRes1D();
219 
220  virtual void showSolution(const doublereal* x) {}
221 
222  virtual size_t nSpecies() {
223  return m_nsp;
224  }
225 
226  virtual void setMoleFractions(const std::string& xin);
227  virtual void setMoleFractions(const doublereal* xin);
228  virtual doublereal massFraction(size_t k) {
229  return m_yres[k];
230  }
231  virtual void init();
232  virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
233  integer* diagg, doublereal rdt);
234  virtual XML_Node& save(XML_Node& o, const doublereal* const soln);
235  virtual void restore(const XML_Node& dom, doublereal* soln, int loglevel);
236 
237 protected:
238  size_t m_nsp;
239  vector_fp m_yres;
240  std::string m_xstr;
241  StFlow* m_flow;
242 };
243 
244 /**
245  * A non-reacting surface. The axial velocity is zero (impermeable), as is the
246  * transverse velocity (no slip). The temperature is specified, and a zero flux
247  * condition is imposed for the species.
248  * @ingroup onedim
249  */
250 class Surf1D : public Bdry1D
251 {
252 public:
253  Surf1D() : Bdry1D() {
254  m_type = cSurfType;
255  }
256 
257  virtual void init();
258 
259  virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
260  integer* diagg, doublereal rdt);
261 
262  virtual XML_Node& save(XML_Node& o, const doublereal* const soln);
263  virtual void restore(const XML_Node& dom, doublereal* soln, int loglevel);
264 
265  virtual void showSolution_s(std::ostream& s, const double* x);
266 
267  virtual void showSolution(const doublereal* x) {
268  writelog(" Temperature: {:10.4g} K \n\n", m_temp);
269  }
270 };
271 
272 /**
273  * A reacting surface.
274  * @ingroup onedim
275  */
276 class ReactingSurf1D : public Bdry1D
277 {
278 public:
279  ReactingSurf1D();
280 
281  void setKineticsMgr(InterfaceKinetics* kin);
282 
283  void enableCoverageEquations(bool docov) {
284  m_enabled = docov;
285  }
286 
287  virtual std::string componentName(size_t n) const;
288 
289  virtual void init();
290  virtual void resetBadValues(double* xg);
291 
292  virtual void eval(size_t jg, doublereal* xg, doublereal* rg,
293  integer* diagg, doublereal rdt);
294 
295  virtual XML_Node& save(XML_Node& o, const doublereal* const soln);
296  virtual void restore(const XML_Node& dom, doublereal* soln, int loglevel);
297 
298  virtual void _getInitialSoln(doublereal* x) {
299  m_sphase->getCoverages(x);
300  }
301 
302  virtual void _finalize(const doublereal* x) {
303  std::copy(x, x+m_nsp, m_fixed_cov.begin());
304  }
305 
306  virtual void showSolution(const doublereal* x);
307 
308 protected:
309  InterfaceKinetics* m_kin;
310  SurfPhase* m_sphase;
311  size_t m_surfindex, m_nsp;
312  bool m_enabled;
313  vector_fp m_work;
314  vector_fp m_fixed_cov;
315 };
316 
317 }
318 
319 #endif
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
virtual doublereal mdot()
The total mass flow rate [kg/m2/s].
Definition: Inlet1D.h:79
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition: StFlow.h:35
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:193
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
A symmetry plane.
Definition: Inlet1D.h:173
virtual void showSolution(const doublereal *x)
Print the solution.
Definition: Inlet1D.h:267
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
A reacting surface.
Definition: Inlet1D.h:276
void writelog(const std::string &fmt, const Args &... args)
Write a formatted message to the screen.
Definition: global.h:179
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
Definition: Inlet1D.h:59
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
virtual void init()
virtual void setTemperature(doublereal t)
Set the temperature.
Definition: Inlet1D.h:45
virtual doublereal massFraction(size_t k)
Mass fraction of species k.
Definition: Inlet1D.h:228
virtual void showSolution(const doublereal *x)
Print the solution.
Definition: Inlet1D.h:220
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual void init()
Definition: Inlet1D.h:40
A terminator that does nothing.
Definition: Inlet1D.h:150
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual doublereal massFraction(size_t k)
Mass fraction of species k.
Definition: Inlet1D.h:69
virtual doublereal temperature()
Temperature [K].
Definition: Inlet1D.h:50
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual void init()
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual void showSolution(const double *x)
Print the solution.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
An inlet.
Definition: Inlet1D.h:104
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void _getInitialSoln(doublereal *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
Definition: Inlet1D.h:298
Base class for one-dimensional domains.
Definition: Domain1D.h:36
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual void showSolution(const doublereal *x)
Print the solution.
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:290
virtual void init()
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
A kinetics manager for heterogeneous reaction mechanisms.
An outlet.
Definition: Inlet1D.h:194
virtual void setMdot(doublereal mdot)
Set the total mass flow rate.
Definition: Inlet1D.h:74
virtual void setSpreadRate(doublereal V0)
set spreading rate
Definition: Inlet1D.h:110
virtual void setupGrid(size_t n, const doublereal *z)
called to set up initial grid, and after grid refinement
Definition: Inlet1D.h:83
An outlet with specified composition.
Definition: Inlet1D.h:215
virtual double spreadRate()
spreading rate
Definition: Inlet1D.h:116
The base class for boundaries between one-dimensional spatial domains.
Definition: Inlet1D.h:35
virtual void setMoleFractions(const doublereal *xin)
Set the mole fractions by specifying an array.
Definition: Inlet1D.h:64
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
A non-reacting surface.
Definition: Inlet1D.h:250
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
virtual void init()
virtual void showSolution(const doublereal *x)
Print the solution.
Definition: Inlet1D.h:157
virtual void eval(size_t jg, doublereal *xg, doublereal *rg, integer *diagg, doublereal rdt)
Evaluate the residual function at point j.
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:157
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void init()
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
virtual void _finalize(const doublereal *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate...
Definition: Inlet1D.h:302
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
void needJacUpdate()
Definition: Domain1D.cpp:104
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual XML_Node & save(XML_Node &o, const doublereal *const soln)
Save the current solution for this domain into an XML_Node.
virtual doublereal massFraction(size_t k)
Mass fraction of species k.
Definition: Inlet1D.h:128
virtual void init()
virtual void restore(const XML_Node &dom, doublereal *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
virtual void resetBadValues(double *xg)