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"
16#include "StFlow.h"
17
18namespace Cantera
19{
20
21const int LeftInlet = 1;
22const 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 */
35class Boundary1D : public Domain1D
36{
37public:
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
85protected:
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 */
104class Inlet1D : public Boundary1D
105{
106public:
107 Inlet1D();
108
109 /// set spreading rate
110 virtual void setSpreadRate(double V0) {
111 m_V0 = V0;
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
139protected:
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 */
152class Empty1D : public Boundary1D
153{
154public:
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 */
176class Symm1D : public Boundary1D
177{
178public:
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 */
198class Outlet1D : public Boundary1D
199{
200public:
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 */
221{
222public:
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
244protected:
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 */
257class Surf1D : public Boundary1D
258{
259public:
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 */
284{
285public:
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
321protected:
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
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase,...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
The base class for boundaries between one-dimensional spatial domains.
Definition: Boundary1D.h:36
virtual void setMdot(double mdot)
Set the total mass flow rate.
Definition: Boundary1D.h:74
virtual void setupGrid(size_t n, const double *z)
called to set up initial grid, and after grid refinement
Definition: Boundary1D.h:83
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
Definition: Boundary1D.h:59
virtual double temperature()
Temperature [K].
Definition: Boundary1D.h:50
virtual void init()
Definition: Boundary1D.h:40
virtual void setTemperature(double t)
Set the temperature.
Definition: Boundary1D.h:45
virtual void setMoleFractions(const double *xin)
Set the mole fractions by specifying an array.
Definition: Boundary1D.h:64
virtual double mdot()
The total mass flow rate [kg/m2/s].
Definition: Boundary1D.h:79
virtual double massFraction(size_t k)
Mass fraction of species k.
Definition: Boundary1D.h:69
Base class for one-dimensional domains.
Definition: Domain1D.h:38
void needJacUpdate()
Definition: Domain1D.cpp:110
A terminator that does nothing.
Definition: Boundary1D.h:153
virtual void init()
Definition: Boundary1D.cpp:296
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:319
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
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.h:159
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
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
virtual void init()
Definition: Boundary1D.cpp:134
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
Definition: Boundary1D.cpp:115
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:255
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
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.cpp:99
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
virtual void setSpreadRate(double V0)
set spreading rate
Definition: Boundary1D.h:110
virtual double massFraction(size_t k)
Mass fraction of species k.
Definition: Boundary1D.h:128
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
virtual double spreadRate()
spreading rate
Definition: Boundary1D.h:116
A kinetics manager for heterogeneous reaction mechanisms.
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
An outlet.
Definition: Boundary1D.h:199
virtual void init()
Definition: Boundary1D.cpp:402
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:476
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
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
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
An outlet with specified composition.
Definition: Boundary1D.h:221
virtual void init()
Definition: Boundary1D.cpp:504
virtual void setMoleFractions(const std::string &xin)
Set the mole fractions by specifying a std::string.
Definition: Boundary1D.cpp:485
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:612
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
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.h:225
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
virtual double massFraction(size_t k)
Mass fraction of species k.
Definition: Boundary1D.h:233
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
A reacting surface.
Definition: Boundary1D.h:284
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:886
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
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
virtual std::string componentName(size_t n) const
Name of the nth component. May be overloaded.
Definition: Boundary1D.cpp:741
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.cpp:925
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
virtual void resetBadValues(double *xg)
Definition: Boundary1D.cpp:763
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
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
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition: StFlow.h:37
A non-reacting surface.
Definition: Boundary1D.h:258
virtual void init()
Definition: Boundary1D.cpp:652
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:697
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
virtual void showSolution(const double *x)
Print the solution.
Definition: Boundary1D.cpp:717
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
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
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:125
void getCoverages(doublereal *theta) const
Return a vector of surface coverages.
Definition: SurfPhase.cpp:277
A symmetry plane.
Definition: Boundary1D.h:177
virtual void init()
Definition: Boundary1D.cpp:328
virtual AnyMap serialize(const double *soln) const
Save the state of this domain as an AnyMap.
Definition: Boundary1D.cpp:385
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
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
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
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
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