Cantera 2.6.0

Boundary1D.h
Go to the documentation of this file.
1/**
2 * @file Boundary1D.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 https://cantera.org/license.txt for license and copyright information.
9
10#ifndef CT_BOUNDARY1D_H
11#define CT_BOUNDARY1D_H
12
13#include "Domain1D.h"
14#include "cantera/thermo/SurfPhase.h"
15#include "cantera/kinetics/InterfaceKinetics.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 Boundary1D : public Domain1D
36{
37 public:
38 Boundary1D();
39
40 virtual void init() {
41 _init(1);
42 }
43
44 /// Set the temperature.
45 virtual void setTemperature(double t) {
46 m_temp = t;
47 }
48
49 /// Temperature [K].
50 virtual double 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("Boundary1D::setMoleFractions");
61 }
62
63 /// Set the mole fractions by specifying an array.
64 virtual void setMoleFractions(const double* xin) {
65 throw NotImplementedError("Boundary1D::setMoleFractions");
66 }
67
68 /// Mass fraction of species k.
69 virtual double massFraction(size_t k) {
70 throw NotImplementedError("Boundary1D::massFraction");
71 }
72
73 /// Set the total mass flow rate.
74 virtual void setMdot(double mdot) {
75 m_mdot = mdot;
76 }
77
78 /// The total mass flow rate [kg/m2/s].
79 virtual double mdot() {
80 return m_mdot;
81 }
82
83 virtual void setupGrid(size_t n, const double* 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 double m_temp, m_mdot;
97};
98
99
100/**
101 * An inlet.
102 * @ingroup onedim
103 */
104 class Inlet1D : public Boundary1D
105{
106 public:
107 Inlet1D();
108
109 /// set spreading rate
110 virtual void setSpreadRate(double 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 double* xin);
128 virtual double massFraction(size_t k) {
129 return m_yin[k];
130 }
131 virtual void init();
132 virtual void eval(size_t jg, double* xg, double* rg,
133 integer* diagg, double rdt);
134 virtual XML_Node& save(XML_Node& o, const double* const soln);
135 virtual void restore(const XML_Node& dom, double* soln, int loglevel);
136 virtual AnyMap serialize(const double* soln) const;
137 virtual void restore(const AnyMap& state, double* soln, int loglevel);
138
139 protected:
140 int m_ilr;
141 double m_V0;
142 size_t m_nsp;
143 vector_fp m_yin;
144 std::string m_xstr;
145 StFlow* m_flow;
146};
147
148/**
149 * A terminator that does nothing.
150 * @ingroup onedim
151 */
152 class Empty1D : public Boundary1D
153{
154 public:
155 Empty1D() : Boundary1D() {
156 m_type = cEmptyType;
157 }
158
159 virtual void showSolution(const double* x) {}
160
161 virtual void init();
162
163 virtual void eval(size_t jg, double* xg, double* rg,
164 integer* diagg, double rdt);
165
166 virtual XML_Node& save(XML_Node& o, const double* const soln);
167 virtual void restore(const XML_Node& dom, double* soln, int loglevel);
168 virtual AnyMap serialize(const double* soln) const;
169};
170
171/**
172 * A symmetry plane. The axial velocity u = 0, and all other components have
173 * zero axial gradients.
174 * @ingroup onedim
175 */
176 class Symm1D : public Boundary1D
177{
178 public:
179 Symm1D() : Boundary1D() {
180 m_type = cSymmType;
181 }
182
183 virtual void init();
184
185 virtual void eval(size_t jg, double* xg, double* rg,
186 integer* diagg, double rdt);
187
188 virtual XML_Node& save(XML_Node& o, const double* const soln);
189 virtual void restore(const XML_Node& dom, double* soln, int loglevel);
190 virtual AnyMap serialize(const double* soln) const;
191};
192
193
194/**
195 * An outlet.
196 * @ingroup onedim
197 */
198 class Outlet1D : public Boundary1D
199{
200 public:
201 Outlet1D() : Boundary1D() {
202 m_type = cOutletType;
203 }
204
205 virtual void init();
206
207 virtual void eval(size_t jg, double* xg, double* rg,
208 integer* diagg, double rdt);
209
210 virtual XML_Node& save(XML_Node& o, const double* const soln);
211 virtual void restore(const XML_Node& dom, double* soln, int loglevel);
212 virtual AnyMap serialize(const double* soln) const;
213};
214
215
216/**
217 * An outlet with specified composition.
218 * @ingroup onedim
219 */
220 class OutletRes1D : public Boundary1D
221{
222 public:
223 OutletRes1D();
224
225 virtual void showSolution(const double* x) {}
226
227 virtual size_t nSpecies() {
228 return m_nsp;
229 }
230
231 virtual void setMoleFractions(const std::string& xin);
232 virtual void setMoleFractions(const double* xin);
233 virtual double massFraction(size_t k) {
234 return m_yres[k];
235 }
236 virtual void init();
237 virtual void eval(size_t jg, double* xg, double* rg,
238 integer* diagg, double rdt);
239 virtual XML_Node& save(XML_Node& o, const double* const soln);
240 virtual void restore(const XML_Node& dom, double* soln, int loglevel);
241 virtual AnyMap serialize(const double* soln) const;
242 virtual void restore(const AnyMap& state, double* soln, int loglevel);
243
244 protected:
245 size_t m_nsp;
246 vector_fp m_yres;
247 std::string m_xstr;
248 StFlow* m_flow;
249};
250
251/**
252 * A non-reacting surface. The axial velocity is zero (impermeable), as is the
253 * transverse velocity (no slip). The temperature is specified, and a zero flux
254 * condition is imposed for the species.
255 * @ingroup onedim
256 */
257 class Surf1D : public Boundary1D
258{
259 public:
260 Surf1D() : Boundary1D() {
261 m_type = cSurfType;
262 }
263
264 virtual void init();
265
266 virtual void eval(size_t jg, double* xg, double* rg,
267 integer* diagg, double rdt);
268
269 virtual XML_Node& save(XML_Node& o, const double* const soln);
270 virtual void restore(const XML_Node& dom, double* soln, int loglevel);
271 virtual AnyMap serialize(const double* soln) const;
272 virtual void restore(const AnyMap& state, double* soln, int loglevel);
273
274 virtual void showSolution_s(std::ostream& s, const double* x);
275
276 virtual void showSolution(const double* x);
277};
278
279/**
280 * A reacting surface.
281 * @ingroup onedim
282 */
283 class ReactingSurf1D : public Boundary1D
284{
285 public:
286 ReactingSurf1D();
287
288 void setKineticsMgr(InterfaceKinetics* kin);
289
290 void enableCoverageEquations(bool docov) {
291 m_enabled = docov;
292 }
293
294 bool coverageEnabled() {
295 return m_enabled;
296 }
297
298 virtual std::string componentName(size_t n) const;
299
300 virtual void init();
301 virtual void resetBadValues(double* xg);
302
303 virtual void eval(size_t jg, double* xg, double* rg,
304 integer* diagg, double rdt);
305
306 virtual XML_Node& save(XML_Node& o, const double* const soln);
307 virtual void restore(const XML_Node& dom, double* soln, int loglevel);
308 virtual AnyMap serialize(const double* soln) const;
309 virtual void restore(const AnyMap& state, double* soln, int loglevel);
310
311 virtual void _getInitialSoln(double* x) {
312 m_sphase->getCoverages(x);
313 }
314
315 virtual void _finalize(const double* x) {
316 std::copy(x, x+m_nsp, m_fixed_cov.begin());
317 }
318
319 virtual void showSolution(const double* x);
320
321 protected:
322 InterfaceKinetics* m_kin;
323 SurfPhase* m_sphase;
324 size_t m_surfindex, m_nsp;
325 bool m_enabled;
326 vector_fp m_work;
327 vector_fp m_fixed_cov;
328};
329
330}
331
332#endif
Domain1D.h
InterfaceKinetics.h
StFlow.h
SurfPhase.h
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
Cantera::Boundary1D
The base class for boundaries between one-dimensional spatial domains.
Definition: Boundary1D.h:36
Cantera::Boundary1D::setMdot
virtual void setMdot(double mdot)
Set the total mass flow rate.
Definition: Boundary1D.h:74
Cantera::Boundary1D::setupGrid
virtual void setupGrid(size_t n, const double *z)
called to set up initial grid, and after grid refinement
Definition: Boundary1D.h:83
Cantera::Boundary1D::setMoleFractions
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
Definition: Boundary1D.h:59
Cantera::Boundary1D::temperature
virtual double temperature()
Temperature [K].
Definition: Boundary1D.h:50
Cantera::Boundary1D::init
virtual void init()
Definition: Boundary1D.h:40
Cantera::Boundary1D::setTemperature
virtual void setTemperature(double t)
Set the temperature.
Definition: Boundary1D.h:45
Cantera::Boundary1D::setMoleFractions
virtual void setMoleFractions(const double *xin)
Set the mole fractions by specifying an array.
Definition: Boundary1D.h:64
Cantera::Boundary1D::mdot
virtual double mdot()
The total mass flow rate [kg/m2/s].
Definition: Boundary1D.h:79
Cantera::Boundary1D::massFraction
virtual double massFraction(size_t k)
Mass fraction of species k.
Definition: Boundary1D.h:69
Cantera::Domain1D
Base class for one-dimensional domains.
Definition: Domain1D.h:38
Cantera::Domain1D::needJacUpdate
void needJacUpdate()
Definition: Domain1D.cpp:110
Cantera::Empty1D
A terminator that does nothing.
Definition: Boundary1D.h:153
Cantera::Empty1D::init
virtual void init()
Definition: Boundary1D.cpp:296
Cantera::Empty1D::serialize
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:319
Cantera::Empty1D::save
virtual XML_Node & save(XML_Node &o, const double *const soln)
Save the current solution for this domain into an XML_Node.
Definition: Boundary1D.cpp:306
Cantera::Empty1D::showSolution
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.h:159
Cantera::Empty1D::eval
virtual void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt)
Evaluate the residual function at point j.
Definition: Boundary1D.cpp:301
Cantera::Empty1D::restore
virtual void restore(const XML_Node &dom, double *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Boundary1D.cpp:313
Cantera::Inlet1D
An inlet.
Definition: Boundary1D.h:105
Cantera::Inlet1D::init
virtual void init()
Definition: Boundary1D.cpp:134
Cantera::Inlet1D::setMoleFractions
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
Definition: Boundary1D.cpp:115
Cantera::Inlet1D::serialize
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:255
Cantera::Inlet1D::save
virtual XML_Node & save(XML_Node &o, const double *const soln)
Save the current solution for this domain into an XML_Node.
Definition: Boundary1D.cpp:222
Cantera::Inlet1D::showSolution
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.cpp:99
Cantera::Inlet1D::eval
virtual void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt)
Evaluate the residual function at point j.
Definition: Boundary1D.cpp:161
Cantera::Inlet1D::setSpreadRate
virtual void setSpreadRate(double V0)
set spreading rate
Definition: Boundary1D.h:110
Cantera::Inlet1D::massFraction
virtual double massFraction(size_t k)
Mass fraction of species k.
Definition: Boundary1D.h:128
Cantera::Inlet1D::restore
virtual void restore(const XML_Node &dom, double *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Boundary1D.cpp:235
Cantera::Inlet1D::spreadRate
virtual double spreadRate()
spreading rate
Definition: Boundary1D.h:116
Cantera::InterfaceKinetics
A kinetics manager for heterogeneous reaction mechanisms.
Definition: InterfaceKinetics.h:58
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
Cantera::Outlet1D
An outlet.
Definition: Boundary1D.h:199
Cantera::Outlet1D::init
virtual void init()
Definition: Boundary1D.cpp:402
Cantera::Outlet1D::serialize
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:476
Cantera::Outlet1D::save
virtual XML_Node & save(XML_Node &o, const double *const soln)
Save the current solution for this domain into an XML_Node.
Definition: Boundary1D.cpp:463
Cantera::Outlet1D::eval
virtual void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt)
Evaluate the residual function at point j.
Definition: Boundary1D.cpp:414
Cantera::Outlet1D::restore
virtual void restore(const XML_Node &dom, double *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Boundary1D.cpp:470
Cantera::OutletRes1D
An outlet with specified composition.
Definition: Boundary1D.h:221
Cantera::OutletRes1D::init
virtual void init()
Definition: Boundary1D.cpp:504
Cantera::OutletRes1D::setMoleFractions
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
Definition: Boundary1D.cpp:485
Cantera::OutletRes1D::serialize
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:612
Cantera::OutletRes1D::save
virtual XML_Node & save(XML_Node &o, const double *const soln)
Save the current solution for this domain into an XML_Node.
Definition: Boundary1D.cpp:581
Cantera::OutletRes1D::showSolution
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.h:225
Cantera::OutletRes1D::eval
virtual void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt)
Evaluate the residual function at point j.
Definition: Boundary1D.cpp:525
Cantera::OutletRes1D::massFraction
virtual double massFraction(size_t k)
Mass fraction of species k.
Definition: Boundary1D.h:233
Cantera::OutletRes1D::restore
virtual void restore(const XML_Node &dom, double *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Boundary1D.cpp:593
Cantera::ReactingSurf1D
A reacting surface.
Definition: Boundary1D.h:284
Cantera::ReactingSurf1D::init
virtual void init()
Definition: Boundary1D.cpp:750
Cantera::ReactingSurf1D::serialize
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:886
Cantera::ReactingSurf1D::save
virtual XML_Node & save(XML_Node &o, const double *const soln)
Save the current solution for this domain into an XML_Node.
Definition: Boundary1D.cpp:853
Cantera::ReactingSurf1D::_finalize
virtual void _finalize(const double *x)
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
Definition: Boundary1D.h:315
Cantera::ReactingSurf1D::componentName
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
Definition: Boundary1D.cpp:741
Cantera::ReactingSurf1D::showSolution
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.cpp:925
Cantera::ReactingSurf1D::eval
virtual void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt)
Evaluate the residual function at point j.
Definition: Boundary1D.cpp:769
Cantera::ReactingSurf1D::resetBadValues
virtual void resetBadValues(double *xg)
Definition: Boundary1D.cpp:763
Cantera::ReactingSurf1D::_getInitialSoln
virtual void _getInitialSoln(double *x)
Writes some or all initial solution values into the global solution array, beginning at the location ...
Definition: Boundary1D.h:311
Cantera::ReactingSurf1D::restore
virtual void restore(const XML_Node &dom, double *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Boundary1D.cpp:865
Cantera::StFlow
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition: StFlow.h:37
Cantera::Surf1D
A non-reacting surface.
Definition: Boundary1D.h:258
Cantera::Surf1D::init
virtual void init()
Definition: Boundary1D.cpp:652
Cantera::Surf1D::serialize
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:697
Cantera::Surf1D::save
virtual XML_Node & save(XML_Node &o, const double *const soln)
Save the current solution for this domain into an XML_Node.
Definition: Boundary1D.cpp:682
Cantera::Surf1D::showSolution
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.cpp:717
Cantera::Surf1D::eval
virtual void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt)
Evaluate the residual function at point j.
Definition: Boundary1D.cpp:657
Cantera::Surf1D::restore
virtual void restore(const XML_Node &dom, double *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Boundary1D.cpp:690
Cantera::SurfPhase
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:125
Cantera::SurfPhase::getCoverages
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:277
Cantera::Symm1D
A symmetry plane.
Definition: Boundary1D.h:177
Cantera::Symm1D::init
virtual void init()
Definition: Boundary1D.cpp:328
Cantera::Symm1D::serialize
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:385
Cantera::Symm1D::save
virtual XML_Node & save(XML_Node &o, const double *const soln)
Save the current solution for this domain into an XML_Node.
Definition: Boundary1D.cpp:372
Cantera::Symm1D::eval
virtual void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt)
Evaluate the residual function at point j.
Definition: Boundary1D.cpp:333
Cantera::Symm1D::restore
virtual void restore(const XML_Node &dom, double *soln, int loglevel)
Restore the solution for this domain from an XML_Node.
Definition: Boundary1D.cpp:379
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Cantera::XML_Node
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::vector_fp
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:184