Cantera  3.1.0a2
Loading...
Searching...
No Matches
Flow1D.h
Go to the documentation of this file.
1//! @file Flow1D.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_FLOW1D_H
7#define CT_FLOW1D_H
8
9#include "Domain1D.h"
10#include "cantera/base/Array.h"
14
15namespace Cantera
16{
17
18//------------------------------------------
19// constants
20//------------------------------------------
21
22//! Offsets of solution components in the 1D solution array.
24{
25 c_offset_U //! axial velocity [m/s]
26 , c_offset_V //! strain rate
27 , c_offset_T //! temperature [kelvin]
28 , c_offset_L //! (1/r)dP/dr
29 , c_offset_E //! electric field
30 , c_offset_Uo //! oxidizer axial velocity [m/s]
31 , c_offset_Y //! mass fractions
32};
33
34class Transport;
35
36//! @defgroup flowGroup Flow Domains
37//! One-dimensional flow domains.
38//! @ingroup onedGroup
39
40/**
41 * This class represents 1D flow domains that satisfy the one-dimensional
42 * similarity solution for chemically-reacting, axisymmetric flows.
43 * @ingroup flowGroup
44 */
45class Flow1D : public Domain1D
46{
47public:
48 //--------------------------------
49 // construction and destruction
50 //--------------------------------
51
52 //! Create a new flow domain.
53 //! @param ph Object representing the gas phase. This object will be used
54 //! to evaluate all thermodynamic, kinetic, and transport properties.
55 //! @param nsp Number of species.
56 //! @param points Initial number of grid points
57 Flow1D(ThermoPhase* ph = 0, size_t nsp = 1, size_t points = 1);
58
59 //! Delegating constructor
60 Flow1D(shared_ptr<ThermoPhase> th, size_t nsp = 1, size_t points = 1);
61
62 //! Create a new flow domain.
63 //! @param sol Solution object used to evaluate all thermodynamic, kinetic, and
64 //! transport properties
65 //! @param id name of flow domain
66 //! @param points initial number of grid points
67 Flow1D(shared_ptr<Solution> sol, const string& id="", size_t points=1);
68
69 ~Flow1D();
70
71 string domainType() const override;
72
73 //! @name Problem Specification
74 //! @{
75
76 void setupGrid(size_t n, const double* z) override;
77
78 void resetBadValues(double* xg) override;
79
80 ThermoPhase& phase() {
81 return *m_thermo;
82 }
83
84 Kinetics& kinetics() {
85 return *m_kin;
86 }
87
88 void setKinetics(shared_ptr<Kinetics> kin) override;
89
90 void setTransport(shared_ptr<Transport> trans) override;
91
92 //! Set the transport model
93 //! @since New in %Cantera 3.0.
94 void setTransportModel(const string& trans);
95
96 //! Retrieve transport model
97 //! @since New in %Cantera 3.0.
98 string transportModel() const;
99
100 //! Enable thermal diffusion, also known as Soret diffusion.
101 //! Requires that multicomponent transport properties be
102 //! enabled to carry out calculations.
103 void enableSoret(bool withSoret) {
104 m_do_soret = withSoret;
105 }
106 bool withSoret() const {
107 return m_do_soret;
108 }
109
110 //! Compute species diffusive fluxes with respect to
111 //! their mass fraction gradients (fluxGradientBasis = ThermoBasis::mass)
112 //! or mole fraction gradients (fluxGradientBasis = ThermoBasis::molar, default)
113 //! when using the mixture-averaged transport model.
114 //! @param fluxGradientBasis set flux computation to mass or mole basis
115 //! @since New in %Cantera 3.1.
117
118 //! Compute species diffusive fluxes with respect to
119 //! their mass fraction gradients (fluxGradientBasis = ThermoBasis::mass)
120 //! or mole fraction gradients (fluxGradientBasis = ThermoBasis::molar, default)
121 //! when using the mixture-averaged transport model.
122 //! @return the basis used for flux computation (mass or mole fraction gradients)
123 //! @since New in %Cantera 3.1.
125 return m_fluxGradientBasis;
126 }
127
128 //! Set the pressure. Since the flow equations are for the limit of small
129 //! Mach number, the pressure is very nearly constant throughout the flow.
130 void setPressure(double p) {
131 m_press = p;
132 }
133
134 //! The current pressure [Pa].
135 double pressure() const {
136 return m_press;
137 }
138
139 //! Write the initial solution estimate into array x.
140 void _getInitialSoln(double* x) override;
141
142 void _finalize(const double* x) override;
143
144 //! Sometimes it is desired to carry out the simulation using a specified
145 //! temperature profile, rather than computing it by solving the energy
146 //! equation. This method specifies this profile.
147 void setFixedTempProfile(vector<double>& zfixed, vector<double>& tfixed) {
148 m_zfix = zfixed;
149 m_tfix = tfixed;
150 }
151
152 /**
153 * Set the temperature fixed point at grid point j, and disable the energy
154 * equation so that the solution will be held to this value.
155 */
156 void setTemperature(size_t j, double t) {
157 m_fixedtemp[j] = t;
158 m_do_energy[j] = false;
159 }
160
161 //! The fixed temperature value at point j.
162 double T_fixed(size_t j) const {
163 return m_fixedtemp[j];
164 }
165
166 //! @}
167
168 string componentName(size_t n) const override;
169
170 size_t componentIndex(const string& name) const override;
171
172 //! Returns true if the specified component is an active part of the solver state
173 virtual bool componentActive(size_t n) const;
174
175 void show(const double* x) override;
176
177 shared_ptr<SolutionArray> asArray(const double* soln) const override;
178 void fromArray(SolutionArray& arr, double* soln) override;
179
180 //! Set flow configuration for freely-propagating flames, using an internal point
181 //! with a fixed temperature as the condition to determine the inlet mass flux.
182 void setFreeFlow() {
183 m_dovisc = false;
184 m_isFree = true;
185 m_usesLambda = false;
186 }
187
188 //! Set flow configuration for axisymmetric counterflow flames, using specified
189 //! inlet mass fluxes.
191 m_dovisc = true;
192 m_isFree = false;
193 m_usesLambda = true;
194 }
195
196 //! Set flow configuration for burner-stabilized flames, using specified inlet mass
197 //! fluxes.
199 m_dovisc = false;
200 m_isFree = false;
201 m_usesLambda = false;
202 }
203
204 void solveEnergyEqn(size_t j=npos);
205
206 //! Get the solving stage (used by IonFlow specialization)
207 //! @since New in %Cantera 3.0
208 virtual size_t getSolvingStage() const;
209
210 //! Solving stage mode for handling ionized species (used by IonFlow specialization)
211 //! - @c stage=1: the fluxes of charged species are set to zero
212 //! - @c stage=2: the electric field equation is solved, and the drift flux for
213 //! ionized species is evaluated
214 virtual void setSolvingStage(const size_t stage);
215
216 //! Set to solve electric field in a point (used by IonFlow specialization)
217 virtual void solveElectricField(size_t j=npos);
218
219 //! Set to fix voltage in a point (used by IonFlow specialization)
220 virtual void fixElectricField(size_t j=npos);
221
222 //! Retrieve flag indicating whether electric field is solved or not (used by
223 //! IonFlow specialization)
224 virtual bool doElectricField(size_t j) const;
225
226 //! Turn radiation on / off.
227 void enableRadiation(bool doRadiation) {
228 m_do_radiation = doRadiation;
229 }
230
231 //! Returns `true` if the radiation term in the energy equation is enabled
232 bool radiationEnabled() const {
233 return m_do_radiation;
234 }
235
236 //! Return radiative heat loss at grid point j
237 double radiativeHeatLoss(size_t j) const {
238 return m_qdotRadiation[j];
239 }
240
241 //! Set the emissivities for the boundary values
242 /*!
243 * Reads the emissivities for the left and right boundary values in the
244 * radiative term and writes them into the variables, which are used for the
245 * calculation.
246 */
247 void setBoundaryEmissivities(double e_left, double e_right);
248
249 //! Return emissivity at left boundary
250 double leftEmissivity() const {
251 return m_epsilon_left;
252 }
253
254 //! Return emissivity at right boundary
255 double rightEmissivity() const {
256 return m_epsilon_right;
257 }
258
259 void fixTemperature(size_t j=npos);
260
261 /**
262 * @name Two-Point control method
263 *
264 * In this method two control points are designated in the 1D domain, and the value
265 * of the temperature at these points is fixed. The values of the control points are
266 * imposed and thus serve as a boundary condition that affects the solution of the
267 * governing equations in the 1D domain. The imposition of fixed points in the
268 * domain means that the original set of governing equations' boundary conditions
269 * would over-determine the problem. Thus, the boundary conditions are changed to
270 * reflect the fact that the control points are serving as internal boundary
271 * conditions.
272 *
273 * The imposition of the two internal boundary conditions requires that two other
274 * boundary conditions be changed. The first is the boundary condition for the
275 * continuity equation at the left boundary, which is changed to be a value that is
276 * derived from the solution at the left boundary. The second is the continuity
277 * boundary condition at the right boundary, which is also determined from the flow
278 * solution by using the oxidizer axial velocity equation variable to compute the
279 * mass flux at the right boundary.
280 *
281 * This method is based on the work of Nishioka et al. @cite nishioka1996 .
282 */
283 //! @{
284
285 //! Returns the temperature at the left control point
286 double leftControlPointTemperature() const;
287
288 //! Returns the z-coordinate of the left control point
289 double leftControlPointCoordinate() const;
290
291 //! Sets the temperature of the left control point
292 void setLeftControlPointTemperature(double temperature);
293
294 //! Sets the coordinate of the left control point
295 void setLeftControlPointCoordinate(double z_left);
296
297 //! Returns the temperature at the right control point
298 double rightControlPointTemperature() const;
299
300 //! Returns the z-coordinate of the right control point
301 double rightControlPointCoordinate() const;
302
303 //! Sets the temperature of the right control point
304 void setRightControlPointTemperature(double temperature);
305
306 //! Sets the coordinate of the right control point
307 void setRightControlPointCoordinate(double z_right);
308
309 //! Sets the status of the two-point control
310 void enableTwoPointControl(bool twoPointControl);
311
312 //! Returns the status of the two-point control
314 return m_twoPointControl;
315 }
316 //! @}
317
318 bool doEnergy(size_t j) {
319 return m_do_energy[j];
320 }
321
322 //! Change the grid size. Called after grid refinement.
323 void resize(size_t components, size_t points) override;
324
325 //! Set the gas object state to be consistent with the solution at point j.
326 void setGas(const double* x, size_t j);
327
328 //! Set the gas state to be consistent with the solution at the midpoint
329 //! between j and j + 1.
330 void setGasAtMidpoint(const double* x, size_t j);
331
332 double density(size_t j) const {
333 return m_rho[j];
334 }
335
336 /**
337 * Retrieve flag indicating whether flow is freely propagating.
338 * The flow is unstrained and the axial mass flow rate is not specified.
339 * For free flame propagation, the axial velocity is determined by the solver.
340 * @since New in %Cantera 3.0
341 */
342 bool isFree() const {
343 return m_isFree;
344 }
345
346 /**
347 * Retrieve flag indicating whether flow uses radial momentum.
348 * If `true`, radial momentum equation for @f$ V @f$ as well as
349 * @f$ d\Lambda/dz = 0 @f$ are solved; if `false`, @f$ \Lambda(z) = 0 @f$ and
350 * @f$ V(z) = 0 @f$ by definition.
351 * @since New in %Cantera 3.0
352 */
353 bool isStrained() const {
354 return m_usesLambda;
355 }
356
357 void setViscosityFlag(bool dovisc) {
358 m_dovisc = dovisc;
359 }
360
361 /**
362 * Evaluate the residual functions for axisymmetric stagnation flow.
363 * If jGlobal == npos, the residual function is evaluated at all grid points.
364 * Otherwise, the residual function is only evaluated at grid points j-1, j,
365 * and j+1. This option is used to efficiently evaluate the Jacobian numerically.
366 *
367 * These residuals at all the boundary grid points are evaluated using a default
368 * boundary condition that may be modified by a boundary object that is attached
369 * to the domain. The boundary object connected will modify these equations by
370 * subtracting the boundary object's values for V, T, mdot, etc. As a result,
371 * these residual equations will force the solution variables to the values of
372 * the connected boundary object.
373 *
374 * @param jGlobal Global grid point at which to update the residual
375 * @param[in] xGlobal Global state vector
376 * @param[out] rsdGlobal Global residual vector
377 * @param[out] diagGlobal Global boolean mask indicating whether each solution
378 * component has a time derivative (1) or not (0).
379 * @param[in] rdt Reciprocal of the timestep (`rdt=0` implies steady-state.)
380 */
381 void eval(size_t jGlobal, double* xGlobal, double* rsdGlobal,
382 integer* diagGlobal, double rdt) override;
383
384 //! Index of the species on the left boundary with the largest mass fraction
385 size_t leftExcessSpecies() const {
386 return m_kExcessLeft;
387 }
388
389 //! Index of the species on the right boundary with the largest mass fraction
390 size_t rightExcessSpecies() const {
391 return m_kExcessRight;
392 }
393
394protected:
395 AnyMap getMeta() const override;
396 void setMeta(const AnyMap& state) override;
397
398 //! @name Updates of cached properties
399 //! These methods are called by eval() to update cached properties and data that are
400 //! used for the evaluation of the governing equations.
401 //! @{
402
403 /**
404 * Update the thermodynamic properties from point j0 to point j1
405 * (inclusive), based on solution x.
406 *
407 * The gas state is set to be consistent with the solution at the
408 * points from j0 to j1.
409 *
410 * Properties that are computed and cached are:
411 * * #m_rho (density)
412 * * #m_wtm (mean molecular weight)
413 * * #m_cp (specific heat capacity)
414 * * #m_hk (species specific enthalpies)
415 * * #m_wdot (species production rates)
416 */
417 void updateThermo(const double* x, size_t j0, size_t j1) {
418 for (size_t j = j0; j <= j1; j++) {
419 setGas(x,j);
420 m_rho[j] = m_thermo->density();
421 m_wtm[j] = m_thermo->meanMolecularWeight();
422 m_cp[j] = m_thermo->cp_mass();
423 m_thermo->getPartialMolarEnthalpies(&m_hk(0, j));
424 m_kin->getNetProductionRates(&m_wdot(0, j));
425 }
426 }
427
428 //! Update the transport properties at grid points in the range from `j0`
429 //! to `j1`, based on solution `x`.
430 virtual void updateTransport(double* x, size_t j0, size_t j1);
431
432 //! Update the diffusive mass fluxes.
433 virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
434
435 //! Update the properties (thermo, transport, and diffusion flux).
436 //! This function is called in eval after the points which need
437 //! to be updated are defined.
438 virtual void updateProperties(size_t jg, double* x, size_t jmin, size_t jmax);
439
440 /**
441 * Computes the radiative heat loss vector over points jmin to jmax and stores
442 * the data in the qdotRadiation variable.
443 *
444 * The simple radiation model used was established by Liu and Rogg
445 * @cite liu1991. This model considers the radiation of CO2 and H2O.
446 *
447 * This model uses the optically thin limit and the gray-gas approximation to
448 * simply calculate a volume specified heat flux out of the Planck absorption
449 * coefficients, the boundary emissivities and the temperature. Polynomial lines
450 * calculate the species Planck coefficients for H2O and CO2. The data for the
451 * lines are taken from the RADCAL program @cite RADCAL.
452 * The coefficients for the polynomials are taken from
453 * [TNF Workshop](https://tnfworkshop.org/radiation/) material.
454 */
455 void computeRadiation(double* x, size_t jmin, size_t jmax);
456
457 //! @}
458
459 //! @name Governing Equations
460 //! Methods called by eval() to calculate residuals for individual governing
461 //! equations.
462
463 /**
464 * Evaluate the continuity equation residual.
465 *
466 * This function calculates the residual of the continuity equation
467 * @f[
468 * \frac{d(\rho u)}{dz} + 2\rho V = 0
469 * @f]
470 *
471 * Axisymmetric flame:
472 * The continuity equation propagates information from right-to-left.
473 * The @f$ \rho u @f$ at point 0 is dependent on @f$ \rho u @f$ at point 1,
474 * but not on @f$ \dot{m} @f$ from the inlet.
475 *
476 * Freely-propagating flame:
477 * The continuity equation propagates information away from a fixed temperature
478 * point that is set in the domain.
479 *
480 * Unstrained flame:
481 * A specified mass flux; the main example being burner-stabilized flames.
482 *
483 * The default boundary condition for the continuity equation is
484 * (@f$ u = 0 @f$) at the left and right boundary.
485 *
486 * @param[in] x Local domain state vector, includes variables like temperature,
487 * density, etc.
488 * @param[out] rsd Local domain residual vector that stores the continuity
489 * equation residuals.
490 * @param[out] diag Local domain diagonal matrix that controls whether an entry
491 * has a time-derivative (used by the solver).
492 * @param[in] rdt Reciprocal of the timestep.
493 * @param[in] jmin The index for the starting point in the local domain grid.
494 * @param[in] jmax The index for the ending point in the local domain grid.
495 */
496 virtual void evalContinuity(double* x, double* rsd, int* diag,
497 double rdt, size_t jmin, size_t jmax);
498
499 /**
500 * Evaluate the momentum equation residual.
501 *
502 * The function calculates the radial momentum equation defined as
503 * @f[
504 * \rho u \frac{dV}{dz} + \rho V^2 =
505 * \frac{d}{dz}\left( \mu \frac{dV}{dz} \right) - \Lambda
506 * @f]
507 *
508 * The radial momentum equation is used for axisymmetric flows, and incorporates
509 * terms for time and spatial variations of radial velocity (@f$ V @f$). The
510 * default boundary condition is zero radial velocity (@f$ V @f$) at the left
511 * and right boundary.
512 *
513 * For argument explanation, see evalContinuity().
514 */
515 virtual void evalMomentum(double* x, double* rsd, int* diag,
516 double rdt, size_t jmin, size_t jmax);
517
518 /**
519 * Evaluate the lambda equation residual.
520 *
521 * The function calculates the lambda equation as
522 * @f[
523 * \frac{d\Lambda}{dz} = 0
524 * @f]
525 *
526 * The lambda equation serves as an eigenvalue that allows the momentum
527 * equation and continuity equations to be simultaneously satisfied in
528 * axisymmetric flows. The lambda equation propagates information from
529 * left-to-right. The default boundary condition is @f$ \Lambda = 0 @f$
530 * at the left and zero flux at the right boundary.
531 *
532 * For argument explanation, see evalContinuity().
533 */
534 virtual void evalLambda(double* x, double* rsd, int* diag,
535 double rdt, size_t jmin, size_t jmax);
536
537 /**
538 * Evaluate the energy equation residual.
539 *
540 * The function calculates the energy equation:
541 * @f[
542 * \rho c_p u \frac{dT}{dz} =
543 * \frac{d}{dz}\left( \lambda \frac{dT}{dz} \right)
544 * - \sum_k h_kW_k\dot{\omega}_k
545 * - \sum_k j_k \frac{dh_k}{dz}
546 * @f]
547 *
548 * The energy equation includes contributions from
549 * chemical reactions and diffusion. Default is zero temperature (@f$ T @f$)
550 * at the left and right boundaries. These boundary values are updated by the
551 * specific boundary object connected to the domain.
552 *
553 * For argument explanation, see evalContinuity().
554 */
555 virtual void evalEnergy(double* x, double* rsd, int* diag,
556 double rdt, size_t jmin, size_t jmax);
557
558 /**
559 * Evaluate the species equations' residuals.
560 *
561 * The function calculates the species equations as
562 * @f[
563 * \rho u \frac{dY_k}{dz} + \frac{dj_k}{dz} = W_k\dot{\omega}_k
564 * @f]
565 *
566 * The species equations include terms for temporal and spatial variations
567 * of species mass fractions (@f$ Y_k @f$). The default boundary condition is zero
568 * flux for species at the left and right boundary.
569 *
570 * For argument explanation, see evalContinuity().
571 */
572 virtual void evalSpecies(double* x, double* rsd, int* diag,
573 double rdt, size_t jmin, size_t jmax);
574
575 /**
576 * Evaluate the electric field equation residual to be zero everywhere.
577 *
578 * The electric field equation is implemented in the IonFlow class. The default
579 * boundary condition is zero electric field (@f$ E @f$) at the boundary,
580 * and @f$ E @f$ is zero within the domain.
581 *
582 * For argument explanation, see evalContinuity().
583 */
584 virtual void evalElectricField(double* x, double* rsd, int* diag,
585 double rdt, size_t jmin, size_t jmax);
586
587 //! @} End of Governing Equations
588
589 //! Alternate version of evalContinuity with legacy signature.
590 //! Implemented by StFlow; included here to prevent compiler warnings about shadowed
591 //! virtual functions.
592 //! @deprecated To be removed after Cantera 3.1.
593 virtual void evalContinuity(size_t j, double* x, double* r, int* diag, double rdt);
594
595 /**
596 * Evaluate the oxidizer axial velocity equation residual.
597 *
598 * The function calculates the oxidizer axial velocity equation as
599 * @f[
600 * \frac{dU_{o}}{dz} = 0
601 * @f]
602 *
603 * This equation serves as a dummy equation that is used only in the context of
604 * two-point flame control, and serves as the way for two interior control points to
605 * be specified while maintaining block tridiagonal structure. The default boundary
606 * condition is @f$ U_o = 0 @f$ at the right and zero flux at the left boundary.
607 *
608 * For argument explanation, see evalContinuity().
609 */
610 virtual void evalUo(double* x, double* rsd, int* diag,
611 double rdt, size_t jmin, size_t jmax);
612
613 //! @name Solution components
614 //! @{
615
616 double T(const double* x, size_t j) const {
617 return x[index(c_offset_T, j)];
618 }
619 double& T(double* x, size_t j) {
620 return x[index(c_offset_T, j)];
621 }
622 double T_prev(size_t j) const {
623 return prevSoln(c_offset_T, j);
624 }
625
626 double rho_u(const double* x, size_t j) const {
627 return m_rho[j]*x[index(c_offset_U, j)];
628 }
629
630 double u(const double* x, size_t j) const {
631 return x[index(c_offset_U, j)];
632 }
633
634 double V(const double* x, size_t j) const {
635 return x[index(c_offset_V, j)];
636 }
637 double V_prev(size_t j) const {
638 return prevSoln(c_offset_V, j);
639 }
640
641 double lambda(const double* x, size_t j) const {
642 return x[index(c_offset_L, j)];
643 }
644
645 //! Solution component for oxidizer velocity, @see evalUo
646 double Uo(const double* x, size_t j) const {
647 return x[index(c_offset_Uo, j)];
648 }
649
650 double Y(const double* x, size_t k, size_t j) const {
651 return x[index(c_offset_Y + k, j)];
652 }
653
654 double& Y(double* x, size_t k, size_t j) {
655 return x[index(c_offset_Y + k, j)];
656 }
657
658 double Y_prev(size_t k, size_t j) const {
659 return prevSoln(c_offset_Y + k, j);
660 }
661
662 double X(const double* x, size_t k, size_t j) const {
663 return m_wtm[j]*Y(x,k,j)/m_wt[k];
664 }
665
666 double flux(size_t k, size_t j) const {
667 return m_flux(k, j);
668 }
669 //! @}
670
671 //! @name Convective spatial derivatives
672 //!
673 //! These use upwind differencing, assuming u(z) is negative
674 //! @{
675 double dVdz(const double* x, size_t j) const {
676 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
677 return (V(x,jloc) - V(x,jloc-1))/m_dz[jloc-1];
678 }
679
680 double dYdz(const double* x, size_t k, size_t j) const {
681 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
682 return (Y(x,k,jloc) - Y(x,k,jloc-1))/m_dz[jloc-1];
683 }
684
685 double dTdz(const double* x, size_t j) const {
686 size_t jloc = (u(x,j) > 0.0 ? j : j + 1);
687 return (T(x,jloc) - T(x,jloc-1))/m_dz[jloc-1];
688 }
689 //! @}
690
691 double shear(const double* x, size_t j) const {
692 double c1 = m_visc[j-1]*(V(x,j) - V(x,j-1));
693 double c2 = m_visc[j]*(V(x,j+1) - V(x,j));
694 return 2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1));
695 }
696
697 double divHeatFlux(const double* x, size_t j) const {
698 double c1 = m_tcon[j-1]*(T(x,j) - T(x,j-1));
699 double c2 = m_tcon[j]*(T(x,j+1) - T(x,j));
700 return -2.0*(c2/(z(j+1) - z(j)) - c1/(z(j) - z(j-1)))/(z(j+1) - z(j-1));
701 }
702
703 size_t mindex(size_t k, size_t j, size_t m) {
704 return m*m_nsp*m_nsp + m_nsp*j + k;
705 }
706
707 //! Get the gradient of species specific molar enthalpies
708 virtual void grad_hk(const double* x, size_t j);
709
710 //---------------------------------------------------------
711 // member data
712 //---------------------------------------------------------
713
714 double m_press = -1.0; // pressure
715
716 // grid parameters
717 vector<double> m_dz;
718
719 // mixture thermo properties
720 vector<double> m_rho; //!< Vector of size #m_nsp to cache densities
721 vector<double> m_wtm; //!< Vector of size #m_nsp to cache mean molecular weights
722
723 // species thermo properties
724 vector<double> m_wt;
725 vector<double> m_cp; //!< Vector of size #m_nsp to cache specific heat capacities
726
727 // transport properties
728 vector<double> m_visc;
729 vector<double> m_tcon;
730 //! Array of size #m_nsp by #m_points for saving density times diffusion
731 //! coefficient times species molar mass divided by mean molecular weight
732 vector<double> m_diff;
733 vector<double> m_multidiff;
734 Array2D m_dthermal;
735 Array2D m_flux;
736
737 //! Array of size #m_nsp by #m_points for saving molar enthalpies
739
740 //! Array of size #m_nsp by #m_points-1 for saving enthalpy fluxes
742
743 //! Array of size #m_nsp by #m_points for saving species production rates
745
746 size_t m_nsp; //!< Number of species in the mechanism
747
748 ThermoPhase* m_thermo = nullptr;
749 Kinetics* m_kin = nullptr;
750 Transport* m_trans = nullptr;
751
752 // boundary emissivities for the radiation calculations
753 double m_epsilon_left = 0.0;
754 double m_epsilon_right = 0.0;
755
756 //! Indices within the ThermoPhase of the radiating species. First index is
757 //! for CO2, second is for H2O.
758 vector<size_t> m_kRadiating;
759
760 // flags
761 vector<bool> m_do_energy;
762 bool m_do_soret = false;
763 ThermoBasis m_fluxGradientBasis = ThermoBasis::molar;
764 vector<bool> m_do_species;
765 bool m_do_multicomponent = false;
766
767 //! flag for the radiative heat loss
768 bool m_do_radiation = false;
769
770 //! radiative heat loss vector
771 vector<double> m_qdotRadiation;
772
773 // fixed T and Y values
774 vector<double> m_fixedtemp;
775 vector<double> m_zfix;
776 vector<double> m_tfix;
777
778 //! Index of species with a large mass fraction at each boundary, for which
779 //! the mass fraction may be calculated as 1 minus the sum of the other mass
780 //! fractions
781 size_t m_kExcessLeft = 0;
782 size_t m_kExcessRight = 0;
783
784 bool m_dovisc;
785 bool m_isFree;
786 bool m_usesLambda;
787
788 //! Flag for activating two-point flame control
789 bool m_twoPointControl = false;
790
791 //! Location of the left control point when two-point control is enabled
792 double m_zLeft = Undef;
793
794 //! Temperature of the left control point when two-point control is enabled
795 double m_tLeft = Undef;
796
797 //! Location of the right control point when two-point control is enabled
798 double m_zRight = Undef;
799
800 //! Temperature of the right control point when two-point control is enabled
801 double m_tRight = Undef;
802
803public:
804 //! Location of the point where temperature is fixed
805 double m_zfixed = Undef;
806
807 //! Temperature at the point used to fix the flame location
808 double m_tfixed = -1.0;
809
810private:
811 vector<double> m_ybar;
812};
813
814}
815
816#endif
Header file for class Cantera::Array2D.
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
Base class for one-dimensional domains.
Definition Domain1D.h:28
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Definition Domain1D.h:439
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition Flow1D.h:46
void setLeftControlPointTemperature(double temperature)
Sets the temperature of the left control point.
Definition Flow1D.cpp:1197
void eval(size_t jGlobal, double *xGlobal, double *rsdGlobal, integer *diagGlobal, double rdt) override
Evaluate the residual functions for axisymmetric stagnation flow.
Definition Flow1D.cpp:308
void setTemperature(size_t j, double t)
Set the temperature fixed point at grid point j, and disable the energy equation so that the solution...
Definition Flow1D.h:156
void setLeftControlPointCoordinate(double z_left)
Sets the coordinate of the left control point.
Definition Flow1D.cpp:1212
size_t m_kExcessLeft
Index of species with a large mass fraction at each boundary, for which the mass fraction may be calc...
Definition Flow1D.h:781
void setMeta(const AnyMap &state) override
Retrieve meta data.
Definition Flow1D.cpp:986
double m_zLeft
Location of the left control point when two-point control is enabled.
Definition Flow1D.h:792
void setTransportModel(const string &trans)
Set the transport model.
Definition Flow1D.cpp:213
void setRightControlPointCoordinate(double z_right)
Sets the coordinate of the right control point.
Definition Flow1D.cpp:1267
double leftEmissivity() const
Return emissivity at left boundary.
Definition Flow1D.h:250
void setTransport(shared_ptr< Transport > trans) override
Set transport model to existing instance.
Definition Flow1D.cpp:142
void setUnstrainedFlow()
Set flow configuration for burner-stabilized flames, using specified inlet mass fluxes.
Definition Flow1D.h:198
void setKinetics(shared_ptr< Kinetics > kin) override
Set the kinetics manager.
Definition Flow1D.cpp:136
void resetBadValues(double *xg) override
When called, this function should reset "bad" values in the state vector such as negative species con...
Definition Flow1D.cpp:203
bool twoPointControlEnabled() const
Returns the status of the two-point control.
Definition Flow1D.h:313
size_t rightExcessSpecies() const
Index of the species on the right boundary with the largest mass fraction.
Definition Flow1D.h:390
vector< double > m_qdotRadiation
radiative heat loss vector
Definition Flow1D.h:771
virtual void evalMomentum(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the momentum equation residual.
Definition Flow1D.cpp:571
double pressure() const
The current pressure [Pa].
Definition Flow1D.h:135
void updateThermo(const double *x, size_t j0, size_t j1)
Update the thermodynamic properties from point j0 to point j1 (inclusive), based on solution x.
Definition Flow1D.h:417
double m_tLeft
Temperature of the left control point when two-point control is enabled.
Definition Flow1D.h:795
void setRightControlPointTemperature(double temperature)
Sets the temperature of the right control point.
Definition Flow1D.cpp:1252
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
Definition Flow1D.cpp:162
void enableSoret(bool withSoret)
Enable thermal diffusion, also known as Soret diffusion.
Definition Flow1D.h:103
void setFixedTempProfile(vector< double > &zfixed, vector< double > &tfixed)
Sometimes it is desired to carry out the simulation using a specified temperature profile,...
Definition Flow1D.h:147
virtual void evalContinuity(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the continuity equation residual.
Definition Flow1D.cpp:512
vector< double > m_cp
Vector of size m_nsp to cache specific heat capacities.
Definition Flow1D.h:725
void enableTwoPointControl(bool twoPointControl)
Sets the status of the two-point control.
Definition Flow1D.cpp:1277
double m_tRight
Temperature of the right control point when two-point control is enabled.
Definition Flow1D.h:801
void setBoundaryEmissivities(double e_left, double e_right)
Set the emissivities for the boundary values.
Definition Flow1D.cpp:1116
void setFluxGradientBasis(ThermoBasis fluxGradientBasis)
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
Definition Flow1D.cpp:222
virtual void evalEnergy(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the energy equation residual.
Definition Flow1D.cpp:646
void enableRadiation(bool doRadiation)
Turn radiation on / off.
Definition Flow1D.h:227
vector< double > m_rho
Vector of size m_nsp to cache densities.
Definition Flow1D.h:720
vector< double > m_diff
Array of size m_nsp by m_points for saving density times diffusion coefficient times species molar ma...
Definition Flow1D.h:732
shared_ptr< SolutionArray > asArray(const double *soln) const override
Save the state of this domain as a SolutionArray.
Definition Flow1D.cpp:922
size_t componentIndex(const string &name) const override
index of component with name name.
Definition Flow1D.cpp:821
double rightEmissivity() const
Return emissivity at right boundary.
Definition Flow1D.h:255
void setGas(const double *x, size_t j)
Set the gas object state to be consistent with the solution at point j.
Definition Flow1D.cpp:241
ThermoBasis fluxGradientBasis() const
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
Definition Flow1D.h:124
double Uo(const double *x, size_t j) const
Solution component for oxidizer velocity,.
Definition Flow1D.h:646
double m_tfixed
Temperature at the point used to fix the flame location.
Definition Flow1D.h:808
bool radiationEnabled() const
Returns true if the radiation term in the energy equation is enabled.
Definition Flow1D.h:232
virtual bool componentActive(size_t n) const
Returns true if the specified component is an active part of the solver state.
Definition Flow1D.cpp:846
Array2D m_wdot
Array of size m_nsp by m_points for saving species production rates.
Definition Flow1D.h:744
Array2D m_hk
Array of size m_nsp by m_points for saving molar enthalpies.
Definition Flow1D.h:738
void setFreeFlow()
Set flow configuration for freely-propagating flames, using an internal point with a fixed temperatur...
Definition Flow1D.h:182
virtual bool doElectricField(size_t j) const
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
Definition Flow1D.cpp:1110
virtual void evalSpecies(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the species equations' residuals.
Definition Flow1D.cpp:726
void setupGrid(size_t n, const double *z) override
called to set up initial grid, and after grid refinement
Definition Flow1D.cpp:188
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
Definition Flow1D.h:385
Array2D m_dhk_dz
Array of size m_nsp by m_points-1 for saving enthalpy fluxes.
Definition Flow1D.h:741
virtual void evalElectricField(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the electric field equation residual to be zero everywhere.
Definition Flow1D.cpp:765
vector< double > m_wtm
Vector of size m_nsp to cache mean molecular weights.
Definition Flow1D.h:721
double radiativeHeatLoss(size_t j) const
Return radiative heat loss at grid point j.
Definition Flow1D.h:237
bool m_twoPointControl
Flag for activating two-point flame control.
Definition Flow1D.h:789
double m_zfixed
Location of the point where temperature is fixed.
Definition Flow1D.h:805
void _finalize(const double *x) override
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
Definition Flow1D.cpp:261
virtual size_t getSolvingStage() const
Get the solving stage (used by IonFlow specialization)
Definition Flow1D.cpp:1086
size_t m_nsp
Number of species in the mechanism.
Definition Flow1D.h:746
virtual void evalLambda(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the lambda equation residual.
Definition Flow1D.cpp:603
void fromArray(SolutionArray &arr, double *soln) override
Restore the solution for this domain from a SolutionArray.
Definition Flow1D.cpp:956
double leftControlPointCoordinate() const
Returns the z-coordinate of the left control point.
Definition Flow1D.cpp:1182
AnyMap getMeta() const override
Retrieve meta data.
Definition Flow1D.cpp:862
virtual void updateDiffFluxes(const double *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
Definition Flow1D.cpp:419
double leftControlPointTemperature() const
Returns the temperature at the left control point.
Definition Flow1D.cpp:1167
string componentName(size_t n) const override
Name of the nth component. May be overloaded.
Definition Flow1D.cpp:797
bool isFree() const
Retrieve flag indicating whether flow is freely propagating.
Definition Flow1D.h:342
void setGasAtMidpoint(const double *x, size_t j)
Set the gas state to be consistent with the solution at the midpoint between j and j + 1.
Definition Flow1D.cpp:249
virtual void grad_hk(const double *x, size_t j)
Get the gradient of species specific molar enthalpies.
Definition Flow1D.cpp:1154
bool isStrained() const
Retrieve flag indicating whether flow uses radial momentum.
Definition Flow1D.h:353
string transportModel() const
Retrieve transport model.
Definition Flow1D.cpp:218
double rightControlPointCoordinate() const
Returns the z-coordinate of the right control point.
Definition Flow1D.cpp:1237
void computeRadiation(double *x, size_t jmin, size_t jmax)
Computes the radiative heat loss vector over points jmin to jmax and stores the data in the qdotRadia...
Definition Flow1D.cpp:465
virtual void updateProperties(size_t jg, double *x, size_t jmin, size_t jmax)
Update the properties (thermo, transport, and diffusion flux).
Definition Flow1D.cpp:347
virtual void evalUo(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the oxidizer axial velocity equation residual.
Definition Flow1D.cpp:684
string domainType() const override
Domain type flag.
Definition Flow1D.cpp:126
void show(const double *x) override
Print the solution.
Definition Flow1D.cpp:780
virtual void setSolvingStage(const size_t stage)
Solving stage mode for handling ionized species (used by IonFlow specialization)
Definition Flow1D.cpp:1092
void setPressure(double p)
Set the pressure.
Definition Flow1D.h:130
virtual void fixElectricField(size_t j=npos)
Set to fix voltage in a point (used by IonFlow specialization)
Definition Flow1D.cpp:1104
void setAxisymmetricFlow()
Set flow configuration for axisymmetric counterflow flames, using specified inlet mass fluxes.
Definition Flow1D.h:190
virtual void updateTransport(double *x, size_t j0, size_t j1)
Update the transport properties at grid points in the range from j0 to j1, based on solution x.
Definition Flow1D.cpp:371
double m_zRight
Location of the right control point when two-point control is enabled.
Definition Flow1D.h:798
virtual void solveElectricField(size_t j=npos)
Set to solve electric field in a point (used by IonFlow specialization)
Definition Flow1D.cpp:1098
void _getInitialSoln(double *x) override
Write the initial solution estimate into array x.
Definition Flow1D.cpp:232
vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
Definition Flow1D.h:758
double rightControlPointTemperature() const
Returns the temperature at the right control point.
Definition Flow1D.cpp:1222
double T_fixed(size_t j) const
The fixed temperature value at point j.
Definition Flow1D.h:162
bool m_do_radiation
flag for the radiative heat loss
Definition Flow1D.h:768
Public interface for kinetics managers.
Definition Kinetics.h:125
virtual void getNetProductionRates(double *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
Definition Kinetics.cpp:363
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
Definition Phase.h:655
virtual double density() const
Density (kg/m^3).
Definition Phase.h:587
A container class holding arrays of state information.
Base class for a phase with thermodynamic properties.
virtual void getPartialMolarEnthalpies(double *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
double cp_mass() const
Specific heat at constant pressure. Units: J/kg/K.
Base class for transport property managers.
Definition Transport.h:72
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition ct_defs.h:164
offset
Offsets of solution components in the 1D solution array.
Definition Flow1D.h:24
@ c_offset_U
axial velocity [m/s]
Definition Flow1D.h:25
@ c_offset_L
(1/r)dP/dr
Definition Flow1D.h:28
@ c_offset_V
strain rate
Definition Flow1D.h:26
@ c_offset_E
electric field
Definition Flow1D.h:29
@ c_offset_Y
mass fractions
Definition Flow1D.h:31
@ c_offset_Uo
oxidizer axial velocity [m/s]
Definition Flow1D.h:30
@ c_offset_T
temperature [kelvin]
Definition Flow1D.h:27
ThermoBasis
Differentiate between mole fractions and mass fractions for input mixture composition.