Cantera  3.1.0
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 //! Access the phase object used to compute thermodynamic properties for points in
81 //! this domain.
83 return *m_thermo;
84 }
85
86 //! Access the Kinetics object used to compute reaction rates for points in this
87 //! domain.
89 return *m_kin;
90 }
91
92 //! Set the Kinetics object used for reaction rate calculations.
93 void setKinetics(shared_ptr<Kinetics> kin) override;
94
95 //! Set the transport manager used for transport property calculations
96 void setTransport(shared_ptr<Transport> trans) override;
97
98 //! Set the transport model
99 //! @since New in %Cantera 3.0.
100 void setTransportModel(const string& trans);
101
102 //! Retrieve transport model
103 //! @since New in %Cantera 3.0.
104 string transportModel() const;
105
106 //! Enable thermal diffusion, also known as Soret diffusion.
107 //! Requires that multicomponent transport properties be
108 //! enabled to carry out calculations.
111 }
112
113 //! Indicates if thermal diffusion (Soret effect) term is being calculated.
114 bool withSoret() const {
115 return m_do_soret;
116 }
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 //! @param fluxGradientBasis set flux computation to mass or mole basis
123 //! @since New in %Cantera 3.1.
125
126 //! Compute species diffusive fluxes with respect to
127 //! their mass fraction gradients (fluxGradientBasis = ThermoBasis::mass)
128 //! or mole fraction gradients (fluxGradientBasis = ThermoBasis::molar, default)
129 //! when using the mixture-averaged transport model.
130 //! @return the basis used for flux computation (mass or mole fraction gradients)
131 //! @since New in %Cantera 3.1.
133 return m_fluxGradientBasis;
134 }
135
136 //! Set the pressure. Since the flow equations are for the limit of small
137 //! Mach number, the pressure is very nearly constant throughout the flow.
138 void setPressure(double p) {
139 m_press = p;
140 }
141
142 //! The current pressure [Pa].
143 double pressure() const {
144 return m_press;
145 }
146
147 //! Write the initial solution estimate into array x.
148 void _getInitialSoln(double* x) override;
149
150 void _finalize(const double* x) override;
151
152 //! Sometimes it is desired to carry out the simulation using a specified
153 //! temperature profile, rather than computing it by solving the energy
154 //! equation. This method specifies this profile.
155 void setFixedTempProfile(vector<double>& zfixed, vector<double>& tfixed) {
156 m_zfix = zfixed;
157 m_tfix = tfixed;
158 }
159
160 /**
161 * Set the temperature fixed point at grid point j, and disable the energy
162 * equation so that the solution will be held to this value.
163 */
164 void setTemperature(size_t j, double t) {
165 m_fixedtemp[j] = t;
166 m_do_energy[j] = false;
167 }
168
169 //! The fixed temperature value at point j.
170 double T_fixed(size_t j) const {
171 return m_fixedtemp[j];
172 }
173
174 //! @}
175
176 string componentName(size_t n) const override;
177
178 size_t componentIndex(const string& name) const override;
179
180 //! Returns true if the specified component is an active part of the solver state
181 virtual bool componentActive(size_t n) const;
182
183 void show(const double* x) override;
184
185 shared_ptr<SolutionArray> asArray(const double* soln) const override;
186 void fromArray(SolutionArray& arr, double* soln) override;
187
188 //! Set flow configuration for freely-propagating flames, using an internal point
189 //! with a fixed temperature as the condition to determine the inlet mass flux.
190 void setFreeFlow() {
191 m_dovisc = false;
192 m_isFree = true;
193 m_usesLambda = false;
194 }
195
196 //! Set flow configuration for axisymmetric counterflow flames, using specified
197 //! inlet mass fluxes.
199 m_dovisc = true;
200 m_isFree = false;
201 m_usesLambda = true;
202 }
203
204 //! Set flow configuration for burner-stabilized flames, using specified inlet mass
205 //! fluxes.
207 m_dovisc = false;
208 m_isFree = false;
209 m_usesLambda = false;
210 }
211
212 //! Specify that the energy equation should be solved at point `j`.
213 //! The converse of this method is fixTemperature().
214 //! @param j Point at which to enable the energy equation. `npos` means all points.
215 void solveEnergyEqn(size_t j=npos);
216
217 //! Get the solving stage (used by IonFlow specialization)
218 //! @since New in %Cantera 3.0
219 virtual size_t getSolvingStage() const;
220
221 //! Solving stage mode for handling ionized species (used by IonFlow specialization)
222 //! - @c stage=1: the fluxes of charged species are set to zero
223 //! - @c stage=2: the electric field equation is solved, and the drift flux for
224 //! ionized species is evaluated
225 virtual void setSolvingStage(const size_t stage);
226
227 //! Set to solve electric field in a point (used by IonFlow specialization)
228 virtual void solveElectricField(size_t j=npos);
229
230 //! Set to fix voltage in a point (used by IonFlow specialization)
231 virtual void fixElectricField(size_t j=npos);
232
233 //! Retrieve flag indicating whether electric field is solved or not (used by
234 //! IonFlow specialization)
235 virtual bool doElectricField(size_t j) const;
236
237 //! Turn radiation on / off.
238 void enableRadiation(bool doRadiation) {
239 m_do_radiation = doRadiation;
240 }
241
242 //! Returns `true` if the radiation term in the energy equation is enabled
243 bool radiationEnabled() const {
244 return m_do_radiation;
245 }
246
247 //! Return radiative heat loss at grid point j
248 double radiativeHeatLoss(size_t j) const {
249 return m_qdotRadiation[j];
250 }
251
252 //! Set the emissivities for the boundary values
253 /*!
254 * Reads the emissivities for the left and right boundary values in the
255 * radiative term and writes them into the variables, which are used for the
256 * calculation.
257 */
258 void setBoundaryEmissivities(double e_left, double e_right);
259
260 //! Return emissivity at left boundary
261 double leftEmissivity() const {
262 return m_epsilon_left;
263 }
264
265 //! Return emissivity at right boundary
266 double rightEmissivity() const {
267 return m_epsilon_right;
268 }
269
270 //! Specify that the the temperature should be held fixed at point `j`.
271 //! The converse of this method is enableEnergyEqn().
272 //! @param j Point at which to specify a fixed temperature. `npos` means all
273 //! points.
274 void fixTemperature(size_t j=npos);
275
276 /**
277 * @name Two-Point control method
278 *
279 * In this method two control points are designated in the 1D domain, and the value
280 * of the temperature at these points is fixed. The values of the control points are
281 * imposed and thus serve as a boundary condition that affects the solution of the
282 * governing equations in the 1D domain. The imposition of fixed points in the
283 * domain means that the original set of governing equations' boundary conditions
284 * would over-determine the problem. Thus, the boundary conditions are changed to
285 * reflect the fact that the control points are serving as internal boundary
286 * conditions.
287 *
288 * The imposition of the two internal boundary conditions requires that two other
289 * boundary conditions be changed. The first is the boundary condition for the
290 * continuity equation at the left boundary, which is changed to be a value that is
291 * derived from the solution at the left boundary. The second is the continuity
292 * boundary condition at the right boundary, which is also determined from the flow
293 * solution by using the oxidizer axial velocity equation variable to compute the
294 * mass flux at the right boundary.
295 *
296 * This method is based on the work of Nishioka et al. @cite nishioka1996 .
297 */
298 //! @{
299
300 //! Returns the temperature at the left control point
301 double leftControlPointTemperature() const;
302
303 //! Returns the z-coordinate of the left control point
304 double leftControlPointCoordinate() const;
305
306 //! Sets the temperature of the left control point
307 void setLeftControlPointTemperature(double temperature);
308
309 //! Sets the coordinate of the left control point
310 void setLeftControlPointCoordinate(double z_left);
311
312 //! Returns the temperature at the right control point
313 double rightControlPointTemperature() const;
314
315 //! Returns the z-coordinate of the right control point
316 double rightControlPointCoordinate() const;
317
318 //! Sets the temperature of the right control point
319 void setRightControlPointTemperature(double temperature);
320
321 //! Sets the coordinate of the right control point
322 void setRightControlPointCoordinate(double z_right);
323
324 //! Sets the status of the two-point control
325 void enableTwoPointControl(bool twoPointControl);
326
327 //! Returns the status of the two-point control
329 return m_twoPointControl;
330 }
331 //! @}
332
333 //! `true` if the energy equation is solved at point `j` or `false` if a fixed
334 //! temperature condition is imposed.
335 bool doEnergy(size_t j) {
336 return m_do_energy[j];
337 }
338
339 //! Change the grid size. Called after grid refinement.
340 void resize(size_t components, size_t points) override;
341
342 //! Set the gas object state to be consistent with the solution at point j.
343 void setGas(const double* x, size_t j);
344
345 //! Set the gas state to be consistent with the solution at the midpoint
346 //! between j and j + 1.
347 void setGasAtMidpoint(const double* x, size_t j);
348
349 //! Get the density [kg/m³] at point `j`
350 double density(size_t j) const {
351 return m_rho[j];
352 }
353
354 /**
355 * Retrieve flag indicating whether flow is freely propagating.
356 * The flow is unstrained and the axial mass flow rate is not specified.
357 * For free flame propagation, the axial velocity is determined by the solver.
358 * @since New in %Cantera 3.0
359 */
360 bool isFree() const {
361 return m_isFree;
362 }
363
364 /**
365 * Retrieve flag indicating whether flow uses radial momentum.
366 * If `true`, radial momentum equation for @f$ V @f$ as well as
367 * @f$ d\Lambda/dz = 0 @f$ are solved; if `false`, @f$ \Lambda(z) = 0 @f$ and
368 * @f$ V(z) = 0 @f$ by definition.
369 * @since New in %Cantera 3.0
370 */
371 bool isStrained() const {
372 return m_usesLambda;
373 }
374
375 //! Specify if the viscosity term should be included in the momentum equation
376 void setViscosityFlag(bool dovisc) {
377 m_dovisc = dovisc;
378 }
379
380 /**
381 * Evaluate the residual functions for axisymmetric stagnation flow.
382 * If jGlobal == npos, the residual function is evaluated at all grid points.
383 * Otherwise, the residual function is only evaluated at grid points j-1, j,
384 * and j+1. This option is used to efficiently evaluate the Jacobian numerically.
385 *
386 * These residuals at all the boundary grid points are evaluated using a default
387 * boundary condition that may be modified by a boundary object that is attached
388 * to the domain. The boundary object connected will modify these equations by
389 * subtracting the boundary object's values for V, T, mdot, etc. As a result,
390 * these residual equations will force the solution variables to the values of
391 * the connected boundary object.
392 *
393 * @param jGlobal Global grid point at which to update the residual
394 * @param[in] xGlobal Global state vector
395 * @param[out] rsdGlobal Global residual vector
396 * @param[out] diagGlobal Global boolean mask indicating whether each solution
397 * component has a time derivative (1) or not (0).
398 * @param[in] rdt Reciprocal of the timestep (`rdt=0` implies steady-state.)
399 */
400 void eval(size_t jGlobal, double* xGlobal, double* rsdGlobal,
401 integer* diagGlobal, double rdt) override;
402
403 //! Index of the species on the left boundary with the largest mass fraction
404 size_t leftExcessSpecies() const {
405 return m_kExcessLeft;
406 }
407
408 //! Index of the species on the right boundary with the largest mass fraction
409 size_t rightExcessSpecies() const {
410 return m_kExcessRight;
411 }
412
413protected:
414 AnyMap getMeta() const override;
415 void setMeta(const AnyMap& state) override;
416
417 //! @name Updates of cached properties
418 //! These methods are called by eval() to update cached properties and data that are
419 //! used for the evaluation of the governing equations.
420 //! @{
421
422 /**
423 * Update the thermodynamic properties from point j0 to point j1
424 * (inclusive), based on solution x.
425 *
426 * The gas state is set to be consistent with the solution at the
427 * points from j0 to j1.
428 *
429 * Properties that are computed and cached are:
430 * * #m_rho (density)
431 * * #m_wtm (mean molecular weight)
432 * * #m_cp (specific heat capacity)
433 * * #m_hk (species specific enthalpies)
434 * * #m_wdot (species production rates)
435 */
436 void updateThermo(const double* x, size_t j0, size_t j1) {
437 for (size_t j = j0; j <= j1; j++) {
438 setGas(x,j);
439 m_rho[j] = m_thermo->density();
441 m_cp[j] = m_thermo->cp_mass();
444 }
445 }
446
447 /**
448 * Update the transport properties at grid points in the range from `j0`
449 * to `j1`, based on solution `x`. Evaluates the solution at the midpoint
450 * between `j` and `j + 1` to compute the transport properties. For example,
451 * the viscosity at element `j` is the viscosity evaluated at the midpoint
452 * between `j` and `j + 1`.
453 */
454 virtual void updateTransport(double* x, size_t j0, size_t j1);
455
456 //! Update the diffusive mass fluxes.
457 virtual void updateDiffFluxes(const double* x, size_t j0, size_t j1);
458
459 //! Update the properties (thermo, transport, and diffusion flux).
460 //! This function is called in eval after the points which need
461 //! to be updated are defined.
462 virtual void updateProperties(size_t jg, double* x, size_t jmin, size_t jmax);
463
464 /**
465 * Computes the radiative heat loss vector over points jmin to jmax and stores
466 * the data in the qdotRadiation variable.
467 *
468 * The simple radiation model used was established by Liu and Rogg
469 * @cite liu1991. This model considers the radiation of CO2 and H2O.
470 *
471 * This model uses the optically thin limit and the gray-gas approximation to
472 * simply calculate a volume specified heat flux out of the Planck absorption
473 * coefficients, the boundary emissivities and the temperature. Polynomial lines
474 * calculate the species Planck coefficients for H2O and CO2. The data for the
475 * lines are taken from the RADCAL program @cite RADCAL.
476 * The coefficients for the polynomials are taken from
477 * [TNF Workshop](https://tnfworkshop.org/radiation/) material.
478 */
479 void computeRadiation(double* x, size_t jmin, size_t jmax);
480
481 //! @}
482
483 //! @name Governing Equations
484 //! Methods called by eval() to calculate residuals for individual governing
485 //! equations.
486 //! @{
487
488 /**
489 * Evaluate the continuity equation residual.
490 *
491 * @f[
492 * \frac{d(\rho u)}{dz} + 2\rho V = 0
493 * @f]
494 *
495 * Axisymmetric flame:
496 * The continuity equation propagates information from right-to-left.
497 * The @f$ \rho u @f$ at point 0 is dependent on @f$ \rho u @f$ at point 1,
498 * but not on @f$ \dot{m} @f$ from the inlet.
499 *
500 * Freely-propagating flame:
501 * The continuity equation propagates information away from a fixed temperature
502 * point that is set in the domain.
503 *
504 * Unstrained flame:
505 * A specified mass flux; the main example being burner-stabilized flames.
506 *
507 * The default boundary condition for the continuity equation is
508 * (@f$ u = 0 @f$) at the right boundary. Because the equation is a first order
509 * equation, only one boundary condition is needed.
510 *
511 * @param[in] x Local domain state vector, includes variables like temperature,
512 * density, etc.
513 * @param[out] rsd Local domain residual vector that stores the continuity
514 * equation residuals.
515 * @param[out] diag Local domain diagonal matrix that controls whether an entry
516 * has a time-derivative (used by the solver).
517 * @param[in] rdt Reciprocal of the timestep.
518 * @param[in] jmin The index for the starting point in the local domain grid.
519 * @param[in] jmax The index for the ending point in the local domain grid.
520 */
521 virtual void evalContinuity(double* x, double* rsd, int* diag,
522 double rdt, size_t jmin, size_t jmax);
523
524 /**
525 * Evaluate the momentum equation residual.
526 *
527 * @f[
528 * \rho u \frac{dV}{dz} + \rho V^2 =
529 * \frac{d}{dz}\left( \mu \frac{dV}{dz} \right) - \Lambda
530 * @f]
531 *
532 * The radial momentum equation is used for axisymmetric flows, and incorporates
533 * terms for time and spatial variations of radial velocity (@f$ V @f$). The
534 * default boundary condition is zero radial velocity (@f$ V @f$) at the left
535 * and right boundary.
536 *
537 * For argument explanation, see evalContinuity().
538 */
539 virtual void evalMomentum(double* x, double* rsd, int* diag,
540 double rdt, size_t jmin, size_t jmax);
541
542 /**
543 * Evaluate the lambda equation residual.
544 *
545 * @f[
546 * \frac{d\Lambda}{dz} = 0
547 * @f]
548 *
549 * The lambda equation serves as an eigenvalue that allows the momentum
550 * equation and continuity equations to be simultaneously satisfied in
551 * axisymmetric flows. The lambda equation propagates information from
552 * left-to-right. The default boundary condition is @f$ \Lambda = 0 @f$
553 * at the left boundary. The equation is first order and so only one
554 * boundary condition is needed.
555 *
556 * For argument explanation, see evalContinuity().
557 */
558 virtual void evalLambda(double* x, double* rsd, int* diag,
559 double rdt, size_t jmin, size_t jmax);
560
561 /**
562 * Evaluate the energy equation residual.
563 *
564 * @f[
565 * \rho c_p u \frac{dT}{dz} =
566 * \frac{d}{dz}\left( \lambda \frac{dT}{dz} \right)
567 * - \sum_k h_kW_k\dot{\omega}_k
568 * - \sum_k j_k \frac{dh_k}{dz}
569 * @f]
570 *
571 * The energy equation includes contributions from
572 * chemical reactions and diffusion. Default is zero temperature (@f$ T @f$)
573 * at the left and right boundaries. These boundary values are updated by the
574 * specific boundary object connected to the domain.
575 *
576 * For argument explanation, see evalContinuity().
577 */
578 virtual void evalEnergy(double* x, double* rsd, int* diag,
579 double rdt, size_t jmin, size_t jmax);
580
581 /**
582 * Evaluate the species equations' residuals.
583 *
584 * @f[
585 * \rho u \frac{dY_k}{dz} + \frac{dj_k}{dz} = W_k\dot{\omega}_k
586 * @f]
587 *
588 * The species equations include terms for temporal and spatial variations
589 * of species mass fractions (@f$ Y_k @f$). The default boundary condition is zero
590 * flux for species at the left and right boundary.
591 *
592 * For argument explanation, see evalContinuity().
593 */
594 virtual void evalSpecies(double* x, double* rsd, int* diag,
595 double rdt, size_t jmin, size_t jmax);
596
597 /**
598 * Evaluate the electric field equation residual to be zero everywhere.
599 *
600 * The electric field equation is implemented in the IonFlow class. The default
601 * boundary condition is zero electric field (@f$ E @f$) at the boundary,
602 * and @f$ E @f$ is zero within the domain.
603 *
604 * For argument explanation, see evalContinuity().
605 */
606 virtual void evalElectricField(double* x, double* rsd, int* diag,
607 double rdt, size_t jmin, size_t jmax);
608
609 //! @} End of Governing Equations
610
611 //! Alternate version of evalContinuity with legacy signature.
612 //! Implemented by StFlow; included here to prevent compiler warnings about shadowed
613 //! virtual functions.
614 //! @deprecated To be removed after %Cantera 3.1.
615 virtual void evalContinuity(size_t j, double* x, double* r, int* diag, double rdt);
616
617 /**
618 * Evaluate the oxidizer axial velocity equation residual.
619 *
620 * The function calculates the oxidizer axial velocity equation as
621 * @f[
622 * \frac{dU_{o}}{dz} = 0
623 * @f]
624 *
625 * This equation serves as a dummy equation that is used only in the context of
626 * two-point flame control, and serves as the way for two interior control points to
627 * be specified while maintaining block tridiagonal structure. The default boundary
628 * condition is @f$ U_o = 0 @f$ at the right and zero flux at the left boundary.
629 *
630 * For argument explanation, see evalContinuity().
631 */
632 virtual void evalUo(double* x, double* rsd, int* diag,
633 double rdt, size_t jmin, size_t jmax);
634
635 //! @name Solution components
636 //! @{
637
638 //! Get the temperature at point `j` from the local state vector `x`.
639 double T(const double* x, size_t j) const {
640 return x[index(c_offset_T, j)];
641 }
642 //! Get the temperature at point `j` from the local state vector `x`.
643 double& T(double* x, size_t j) {
644 return x[index(c_offset_T, j)];
645 }
646
647 //! Get the temperature at point `j` from the previous time step.
648 double T_prev(size_t j) const {
649 return prevSoln(c_offset_T, j);
650 }
651
652 //! Get the axial mass flux [kg/m²/s] at point `j` from the local state vector `x`.
653 double rho_u(const double* x, size_t j) const {
654 return m_rho[j]*x[index(c_offset_U, j)];
655 }
656
657 //! Get the axial velocity [m/s] at point `j` from the local state vector `x`.
658 double u(const double* x, size_t j) const {
659 return x[index(c_offset_U, j)];
660 }
661
662 //! Get the spread rate (tangential velocity gradient) [1/s] at point `j` from the
663 //! local state vector `x`.
664 double V(const double* x, size_t j) const {
665 return x[index(c_offset_V, j)];
666 }
667
668 //! Get the spread rate [1/s] at point `j` from the previous time step.
669 double V_prev(size_t j) const {
670 return prevSoln(c_offset_V, j);
671 }
672
673 //! Get the radial pressure gradient [N/m⁴] at point `j` from the local state vector
674 //! `x`
675 double lambda(const double* x, size_t j) const {
676 return x[index(c_offset_L, j)];
677 }
678
679 //! Get the oxidizer inlet velocity [m/s] linked to point `j` from the local state
680 //! vector `x`.
681 //!
682 //! @see evalUo()
683 double Uo(const double* x, size_t j) const {
684 return x[index(c_offset_Uo, j)];
685 }
686
687 //! Get the mass fraction of species `k` at point `j` from the local state vector
688 //! `x`.
689 double Y(const double* x, size_t k, size_t j) const {
690 return x[index(c_offset_Y + k, j)];
691 }
692
693 //! Get the mass fraction of species `k` at point `j` from the local state vector
694 //! `x`.
695 double& Y(double* x, size_t k, size_t j) {
696 return x[index(c_offset_Y + k, j)];
697 }
698
699 //! Get the mass fraction of species `k` at point `j` from the previous time step.
700 double Y_prev(size_t k, size_t j) const {
701 return prevSoln(c_offset_Y + k, j);
702 }
703
704 //! Get the mole fraction of species `k` at point `j` from the local state vector
705 //! `x`.
706 double X(const double* x, size_t k, size_t j) const {
707 return m_wtm[j]*Y(x,k,j)/m_wt[k];
708 }
709
710 //! Get the diffusive mass flux [kg/m²/s] of species `k` at point `j`
711 double flux(size_t k, size_t j) const {
712 return m_flux(k, j);
713 }
714 //! @}
715
716 //! @name Convective spatial derivatives
717 //!
718 //! These methods use upwind differencing to calculate spatial derivatives
719 //! for velocity, species mass fractions, and temperature. Upwind differencing
720 //! is a numerical discretization method that considers the direction of the
721 //! flow to improve stability.
722 //! @{
723
724 /**
725 * Calculates the spatial derivative of velocity V with respect to z at point j
726 * using upwind differencing.
727 *
728 * For more details on the upwinding scheme, see the
729 * [science reference documentation](../reference/onedim/discretization.html#upwinding).
730 *
731 * @f[
732 * \frac{\partial V}{\partial z} \bigg|_{j} \approx \frac{V_{\ell} -
733 * V_{\ell-1}}{z_{\ell} - z_{\ell-1}}
734 * @f]
735 *
736 * Where the value of @f$ \ell @f$ is determined by the sign of the axial velocity.
737 * If the axial velocity is positive, the value of @f$ \ell @f$ is j. If the axial
738 * velocity is negative, the value of @f$ \ell @f$ is j + 1. A positive velocity
739 * means that the flow is moving left-to-right.
740 *
741 * @param[in] x The local domain state vector.
742 * @param[in] j The grid point index at which the derivative is computed.
743 */
744 double dVdz(const double* x, size_t j) const {
745 size_t jloc = (u(x, j) > 0.0 ? j : j + 1);
746 return (V(x, jloc) - V(x, jloc-1))/m_dz[jloc-1];
747 }
748
749 /**
750 * Calculates the spatial derivative of the species mass fraction @f$ Y_k @f$ with
751 * respect to z for species k at point j using upwind differencing.
752 *
753 * For details on the upwinding scheme, see dVdz().
754 *
755 * @param[in] x The local domain state vector.
756 * @param[in] k The species index.
757 * @param[in] j The grid point index at which the derivative is computed.
758 */
759 double dYdz(const double* x, size_t k, size_t j) const {
760 size_t jloc = (u(x, j) > 0.0 ? j : j + 1);
761 return (Y(x, k, jloc) - Y(x, k, jloc-1))/m_dz[jloc-1];
762 }
763
764 /**
765 * Calculates the spatial derivative of temperature T with respect to z at point
766 * j using upwind differencing.
767 *
768 * For details on the upwinding scheme, see dVdz().
769 *
770 * @param[in] x The local domain state vector.
771 * @param[in] j The grid point index at which the derivative is computed.
772 */
773 double dTdz(const double* x, size_t j) const {
774 size_t jloc = (u(x, j) > 0.0 ? j : j + 1);
775 return (T(x, jloc) - T(x, jloc-1))/m_dz[jloc-1];
776 }
777 //! @}
778
779 /**
780 * Compute the shear term from the momentum equation using a central
781 * three-point differencing scheme.
782 *
783 * The term to be discretized is:
784 * @f[
785 * \frac{d}{dz}\left(\mu \frac{dV}{dz}\right)
786 * @f]
787 *
788 * For more details on the discretization scheme used for the second derivative,
789 * see the
790 * [documentation](../reference/onedim/discretization.html#second-derivative-term).
791 *
792 * @f[
793 * \frac{d}{dz}\left(\mu \frac{dV}{dz}\right) \approx
794 * \frac{\mu_{j+1/2} \frac{V_{j+1} - V_j}{z_{j+1} - z_j} -
795 * \mu_{j-1/2} \frac{V_j - V_{j-1}}{z_j - z_{j-1}}}{\frac{z_{j+1} - z_{j-1}}{2}}
796 * @f]
797 *
798 * @param[in] x The local domain state vector.
799 * @param[in] j The grid point index at which the derivative is computed.
800 */
801 double shear(const double* x, size_t j) const {
802 double A_left = m_visc[j-1]*(V(x, j) - V(x, j-1)) / (z(j) - z(j-1));
803 double A_right = m_visc[j]*(V(x, j+1) - V(x, j)) / (z(j+1) - z(j));
804 return 2.0*(A_right - A_left) / (z(j+1) - z(j-1));
805 }
806
807 /**
808 * Compute the conduction term from the energy equation using a central
809 * three-point differencing scheme.
810 *
811 * For the details about the discretization, see shear().
812 *
813 * @param[in] x The local domain state vector.
814 * @param[in] j The grid point index at which the derivative is computed.
815 */
816 double conduction(const double* x, size_t j) const {
817 double A_left = m_tcon[j-1]*(T(x, j) - T(x, j-1)) / (z(j) - z(j-1));
818 double A_right = m_tcon[j]*(T(x, j+1) - T(x, j)) / (z(j+1) - z(j));
819 return -2.0*(A_right - A_left) / (z(j+1) - z(j-1));
820 }
821
822 /**
823 * Array access mapping for a 3D array stored in a 1D vector. Used for
824 * accessing data in the #m_multidiff member variable.
825 *
826 * @param[in] k First species index.
827 * @param[in] j The grid point index.
828 * @param[in] m The second species index.
829 */
830 size_t mindex(size_t k, size_t j, size_t m) {
831 return m*m_nsp*m_nsp + m_nsp*j + k;
832 }
833
834 /**
835 * Compute the spatial derivative of species specific molar enthalpies using upwind
836 * differencing. Updates all species molar enthalpies for all species at point j.
837 * Updates the #m_dhk_dz 2D array.
838 *
839 * For details on the upwinding scheme, see dVdz().
840 *
841 * @param[in] x The local domain state vector.
842 * @param[in] j The index at which the derivative is computed.
843 */
844 virtual void grad_hk(const double* x, size_t j);
845
846 //---------------------------------------------------------
847 // member data
848 //---------------------------------------------------------
849
850 double m_press = -1.0; //!< pressure [Pa]
851
852 //! Grid spacing. Element `j` holds the value of `z(j+1) - z(j)`.
853 vector<double> m_dz;
854
855 // mixture thermo properties
856 vector<double> m_rho; //!< Density at each grid point
857 vector<double> m_wtm; //!< Mean molecular weight at each grid point
858 vector<double> m_wt; //!< Molecular weight of each species
859 vector<double> m_cp; //!< Specific heat capacity at each grid point
860
861 // transport properties
862 vector<double> m_visc; //!< Dynamic viscosity at each grid point [Pa∙s]
863 vector<double> m_tcon; //!< Thermal conductivity at each grid point [W/m/K]
864
865 //! Coefficient used in diffusion calculations for each species at each grid point.
866 //!
867 //! The value stored is different depending on the transport model (multicomponent
868 //! versus mixture averaged) and flux gradient basis (mass or molar). Vector size is
869 //! #m_nsp × #m_points, where `m_diff[k + j*m_nsp]` contains the value for species
870 //! `k` at point `j`.
871 vector<double> m_diff;
872
873 //! Vector of size #m_nsp × #m_nsp × #m_points for saving multicomponent
874 //! diffusion coefficients. Order of elements is defined by mindex().
875 vector<double> m_multidiff;
876
877 //! Array of size #m_nsp by #m_points for saving thermal diffusion coefficients
879
880 //! Array of size #m_nsp by #m_points for saving diffusive mass fluxes
882
883 //! Array of size #m_nsp by #m_points for saving molar enthalpies
885
886 //! Array of size #m_nsp by #m_points-1 for saving enthalpy fluxes
888
889 //! Array of size #m_nsp by #m_points for saving species production rates
891
892 size_t m_nsp; //!< Number of species in the mechanism
893
894 //! Phase object used for calculating thermodynamic properties
896
897 //! Kinetics object used for calculating species production rates
898 Kinetics* m_kin = nullptr;
899
900 //! Transport object used for calculating transport properties
901 Transport* m_trans = nullptr;
902
903 //! Emissivity of the surface to the left of the domain. Used for calculating
904 //! radiative heat loss.
905 double m_epsilon_left = 0.0;
906
907 //! Emissivity of the surface to the right of the domain. Used for calculating
908 //! radiative heat loss.
909 double m_epsilon_right = 0.0;
910
911 //! Indices within the ThermoPhase of the radiating species. First index is
912 //! for CO2, second is for H2O.
913 vector<size_t> m_kRadiating;
914
915 //! @name flags
916 //! @{
917
918 //! For each point in the domain, `true` if energy equation is solved or `false` if
919 //! temperature is held constant.
920 //! @see doEnergy, fixTemperature
921 vector<bool> m_do_energy;
922
923 //! `true` if the Soret diffusion term should be calculated.
924 bool m_do_soret = false;
925
926 //! Determines whether diffusive fluxes are computed using gradients of mass
927 //! fraction or mole fraction.
928 //! @see setFluxGradientBasis, fluxGradientBasis
929 ThermoBasis m_fluxGradientBasis = ThermoBasis::molar;
930
931 //! `true` if transport fluxes are computed using the multicomponent diffusion
932 //! coefficients, or `false` if mixture-averaged diffusion coefficients are used.
934
935 //! Determines whether radiative heat loss is calculated.
936 //! @see enableRadiation, radiationEnabled, computeRadiation
937 bool m_do_radiation = false;
938
939 //! Determines whether the viscosity term in the momentum equation is calculated
940 //! @see setViscosityFlag, setFreeFlow, setAxisymmetricFlow, setUnstrainedFlow,
941 //! updateTransport, shear
943
944 //! Flag that is `true` for freely propagating flames anchored by a temperature
945 //! fixed point.
946 //! @see setFreeFlow, setAxisymmetricFlow, setUnstrainedFlow
948
949 //! Flag that is `true` for counterflow configurations that use the pressure
950 //! eigenvalue @f$ \Lambda @f$ in the radial momentum equation.
951 //! @see setFreeFlow, setAxisymmetricFlow, setUnstrainedFlow
953
954 //! Flag for activating two-point flame control
955 bool m_twoPointControl = false;
956 //! @}
957
958 //! radiative heat loss vector
959 vector<double> m_qdotRadiation;
960
961 // fixed T and Y values
962 //! Fixed values of the temperature at each grid point that are used when solving
963 //! with the energy equation disabled.
964 //!
965 //! Values are interpolated from profiles specified with the setFixedTempProfile
966 //! method as part of _finalize().
967 vector<double> m_fixedtemp;
968
969 //! Relative coordinates used to specify a fixed temperature profile.
970 //!
971 //! 0 corresponds to the left edge of the domain and 1 corresponds to the right edge
972 //! of the domain. Length is the same as the #m_tfix array.
973 //! @see setFixedTempProfile, _finalize
974 vector<double> m_zfix;
975
976 //! Fixed temperature values at the relative coordinates specified in #m_zfix.
977 //! @see setFixedTempProfile, _finalize
978 vector<double> m_tfix;
979
980 //! Index of species with a large mass fraction at the left boundary, for which the
981 //! mass fraction may be calculated as 1 minus the sum of the other mass fractions
982 size_t m_kExcessLeft = 0;
983
984 //! Index of species with a large mass fraction at the right boundary, for which the
985 //! mass fraction may be calculated as 1 minus the sum of the other mass fractions
986 size_t m_kExcessRight = 0;
987
988 //! Location of the left control point when two-point control is enabled
989 double m_zLeft = Undef;
990
991 //! Temperature of the left control point when two-point control is enabled
992 double m_tLeft = Undef;
993
994 //! Location of the right control point when two-point control is enabled
995 double m_zRight = Undef;
996
997 //! Temperature of the right control point when two-point control is enabled
998 double m_tRight = Undef;
999
1000public:
1001 //! Location of the point where temperature is fixed
1002 double m_zfixed = Undef;
1003
1004 //! Temperature at the point used to fix the flame location
1005 double m_tfixed = -1.0;
1006
1007private:
1008 //! Holds the average of the species mass fractions between grid points j and j+1.
1009 //! Used when building a gas state at the grid midpoints for evaluating transport
1010 //! properties at the midpoints.
1011 vector<double> m_ybar;
1012};
1013
1014}
1015
1016#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:431
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:29
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
Definition Domain1D.h:499
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Definition Domain1D.h:469
size_t index(size_t n, size_t j) const
Returns the index of the solution vector, which corresponds to component n at grid point j.
Definition Domain1D.h:338
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition Flow1D.h:46
double dYdz(const double *x, size_t k, size_t j) const
Calculates the spatial derivative of the species mass fraction with respect to z for species k at po...
Definition Flow1D.h:759
void setLeftControlPointTemperature(double temperature)
Sets the temperature of the left control point.
Definition Flow1D.cpp:1177
ThermoPhase * m_thermo
Phase object used for calculating thermodynamic properties.
Definition Flow1D.h:895
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:305
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:164
void setLeftControlPointCoordinate(double z_left)
Sets the coordinate of the left control point.
Definition Flow1D.cpp:1192
double dTdz(const double *x, size_t j) const
Calculates the spatial derivative of temperature T with respect to z at point j using upwind differen...
Definition Flow1D.h:773
vector< double > m_zfix
Relative coordinates used to specify a fixed temperature profile.
Definition Flow1D.h:974
double density(size_t j) const
Get the density [kg/m³] at point j
Definition Flow1D.h:350
size_t m_kExcessLeft
Index of species with a large mass fraction at the left boundary, for which the mass fraction may be ...
Definition Flow1D.h:982
void setMeta(const AnyMap &state) override
Retrieve meta data.
Definition Flow1D.cpp:979
double m_zLeft
Location of the left control point when two-point control is enabled.
Definition Flow1D.h:989
void setTransportModel(const string &trans)
Set the transport model.
Definition Flow1D.cpp:210
void fixTemperature(size_t j=npos)
Specify that the the temperature should be held fixed at point j.
Definition Flow1D.cpp:1114
vector< double > m_tfix
Fixed temperature values at the relative coordinates specified in m_zfix.
Definition Flow1D.h:978
void setRightControlPointCoordinate(double z_right)
Sets the coordinate of the right control point.
Definition Flow1D.cpp:1247
double leftEmissivity() const
Return emissivity at left boundary.
Definition Flow1D.h:261
double X(const double *x, size_t k, size_t j) const
Get the mole fraction of species k at point j from the local state vector x.
Definition Flow1D.h:706
void setTransport(shared_ptr< Transport > trans) override
Set the transport manager used for transport property calculations.
Definition Flow1D.cpp:139
void setUnstrainedFlow()
Set flow configuration for burner-stabilized flames, using specified inlet mass fluxes.
Definition Flow1D.h:206
bool doEnergy(size_t j)
true if the energy equation is solved at point j or false if a fixed temperature condition is imposed...
Definition Flow1D.h:335
ThermoPhase & phase()
Access the phase object used to compute thermodynamic properties for points in this domain.
Definition Flow1D.h:82
void setKinetics(shared_ptr< Kinetics > kin) override
Set the Kinetics object used for reaction rate calculations.
Definition Flow1D.cpp:133
double T_prev(size_t j) const
Get the temperature at point j from the previous time step.
Definition Flow1D.h:648
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:200
bool twoPointControlEnabled() const
Returns the status of the two-point control.
Definition Flow1D.h:328
size_t rightExcessSpecies() const
Index of the species on the right boundary with the largest mass fraction.
Definition Flow1D.h:409
bool m_do_soret
true if the Soret diffusion term should be calculated.
Definition Flow1D.h:924
Kinetics * m_kin
Kinetics object used for calculating species production rates.
Definition Flow1D.h:898
vector< double > m_qdotRadiation
radiative heat loss vector
Definition Flow1D.h:959
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:566
double pressure() const
The current pressure [Pa].
Definition Flow1D.h:143
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:436
double m_tLeft
Temperature of the left control point when two-point control is enabled.
Definition Flow1D.h:992
void setRightControlPointTemperature(double temperature)
Sets the temperature of the right control point.
Definition Flow1D.cpp:1232
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
Definition Flow1D.cpp:159
double dVdz(const double *x, size_t j) const
Calculates the spatial derivative of velocity V with respect to z at point j using upwind differencin...
Definition Flow1D.h:744
bool m_usesLambda
Flag that is true for counterflow configurations that use the pressure eigenvalue in the radial mome...
Definition Flow1D.h:952
vector< double > m_fixedtemp
Fixed values of the temperature at each grid point that are used when solving with the energy equatio...
Definition Flow1D.h:967
void enableSoret(bool withSoret)
Enable thermal diffusion, also known as Soret diffusion.
Definition Flow1D.h:109
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:155
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:509
vector< double > m_cp
Specific heat capacity at each grid point.
Definition Flow1D.h:859
void enableTwoPointControl(bool twoPointControl)
Sets the status of the two-point control.
Definition Flow1D.cpp:1257
double m_tRight
Temperature of the right control point when two-point control is enabled.
Definition Flow1D.h:998
void setBoundaryEmissivities(double e_left, double e_right)
Set the emissivities for the boundary values.
Definition Flow1D.cpp:1100
double shear(const double *x, size_t j) const
Compute the shear term from the momentum equation using a central three-point differencing scheme.
Definition Flow1D.h:801
ThermoBasis m_fluxGradientBasis
Determines whether diffusive fluxes are computed using gradients of mass fraction or mole fraction.
Definition Flow1D.h:929
void setFluxGradientBasis(ThermoBasis fluxGradientBasis)
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
Definition Flow1D.cpp:219
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:645
void enableRadiation(bool doRadiation)
Turn radiation on / off.
Definition Flow1D.h:238
void solveEnergyEqn(size_t j=npos)
Specify that the energy equation should be solved at point j.
Definition Flow1D.cpp:1046
double & T(double *x, size_t j)
Get the temperature at point j from the local state vector x.
Definition Flow1D.h:643
vector< double > m_rho
Density at each grid point.
Definition Flow1D.h:856
vector< bool > m_do_energy
For each point in the domain, true if energy equation is solved or false if temperature is held const...
Definition Flow1D.h:921
double m_epsilon_right
Emissivity of the surface to the right of the domain.
Definition Flow1D.h:909
vector< double > m_tcon
Thermal conductivity at each grid point [W/m/K].
Definition Flow1D.h:863
vector< double > m_diff
Coefficient used in diffusion calculations for each species at each grid point.
Definition Flow1D.h:871
double Y_prev(size_t k, size_t j) const
Get the mass fraction of species k at point j from the previous time step.
Definition Flow1D.h:700
shared_ptr< SolutionArray > asArray(const double *soln) const override
Save the state of this domain as a SolutionArray.
Definition Flow1D.cpp:915
Kinetics & kinetics()
Access the Kinetics object used to compute reaction rates for points in this domain.
Definition Flow1D.h:88
size_t componentIndex(const string &name) const override
index of component with name name.
Definition Flow1D.cpp:823
vector< double > m_dz
Grid spacing. Element j holds the value of z(j+1) - z(j).
Definition Flow1D.h:853
double rightEmissivity() const
Return emissivity at right boundary.
Definition Flow1D.h:266
Array2D m_flux
Array of size m_nsp by m_points for saving diffusive mass fluxes.
Definition Flow1D.h:881
bool withSoret() const
Indicates if thermal diffusion (Soret effect) term is being calculated.
Definition Flow1D.h:114
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:238
ThermoBasis fluxGradientBasis() const
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
Definition Flow1D.h:132
vector< double > m_visc
Dynamic viscosity at each grid point [Pa∙s].
Definition Flow1D.h:862
double Uo(const double *x, size_t j) const
Get the oxidizer inlet velocity [m/s] linked to point j from the local state vector x.
Definition Flow1D.h:683
double m_epsilon_left
Emissivity of the surface to the left of the domain.
Definition Flow1D.h:905
Transport * m_trans
Transport object used for calculating transport properties.
Definition Flow1D.h:901
double m_tfixed
Temperature at the point used to fix the flame location.
Definition Flow1D.h:1005
bool radiationEnabled() const
Returns true if the radiation term in the energy equation is enabled.
Definition Flow1D.h:243
virtual bool componentActive(size_t n) const
Returns true if the specified component is an active part of the solver state.
Definition Flow1D.cpp:848
Array2D m_wdot
Array of size m_nsp by m_points for saving species production rates.
Definition Flow1D.h:890
double & Y(double *x, size_t k, size_t j)
Get the mass fraction of species k at point j from the local state vector x.
Definition Flow1D.h:695
Array2D m_hk
Array of size m_nsp by m_points for saving molar enthalpies.
Definition Flow1D.h:884
double m_press
pressure [Pa]
Definition Flow1D.h:850
void setFreeFlow()
Set flow configuration for freely-propagating flames, using an internal point with a fixed temperatur...
Definition Flow1D.h:190
double lambda(const double *x, size_t j) const
Get the radial pressure gradient [N/m⁴] at point j from the local state vector x
Definition Flow1D.h:675
virtual bool doElectricField(size_t j) const
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
Definition Flow1D.cpp:1094
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:727
double flux(size_t k, size_t j) const
Get the diffusive mass flux [kg/m²/s] of species k at point j
Definition Flow1D.h:711
size_t mindex(size_t k, size_t j, size_t m)
Array access mapping for a 3D array stored in a 1D vector.
Definition Flow1D.h:830
bool m_do_multicomponent
true if transport fluxes are computed using the multicomponent diffusion coefficients,...
Definition Flow1D.h:933
void setViscosityFlag(bool dovisc)
Specify if the viscosity term should be included in the momentum equation.
Definition Flow1D.h:376
double V_prev(size_t j) const
Get the spread rate [1/s] at point j from the previous time step.
Definition Flow1D.h:669
double conduction(const double *x, size_t j) const
Compute the conduction term from the energy equation using a central three-point differencing scheme.
Definition Flow1D.h:816
vector< double > m_wt
Molecular weight of each species.
Definition Flow1D.h:858
double Y(const double *x, size_t k, size_t j) const
Get the mass fraction of species k at point j from the local state vector x.
Definition Flow1D.h:689
void setupGrid(size_t n, const double *z) override
called to set up initial grid, and after grid refinement
Definition Flow1D.cpp:185
double T(const double *x, size_t j) const
Get the temperature at point j from the local state vector x.
Definition Flow1D.h:639
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
Definition Flow1D.h:404
bool m_isFree
Flag that is true for freely propagating flames anchored by a temperature fixed point.
Definition Flow1D.h:947
Array2D m_dhk_dz
Array of size m_nsp by m_points-1 for saving enthalpy fluxes.
Definition Flow1D.h:887
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:767
vector< double > m_wtm
Mean molecular weight at each grid point.
Definition Flow1D.h:857
vector< double > m_multidiff
Vector of size m_nsp × m_nsp × m_points for saving multicomponent diffusion coefficients.
Definition Flow1D.h:875
double radiativeHeatLoss(size_t j) const
Return radiative heat loss at grid point j.
Definition Flow1D.h:248
bool m_twoPointControl
Flag for activating two-point flame control.
Definition Flow1D.h:955
double m_zfixed
Location of the point where temperature is fixed.
Definition Flow1D.h:1002
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:258
virtual size_t getSolvingStage() const
Get the solving stage (used by IonFlow specialization)
Definition Flow1D.cpp:1070
size_t m_nsp
Number of species in the mechanism.
Definition Flow1D.h:892
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:602
double rho_u(const double *x, size_t j) const
Get the axial mass flux [kg/m²/s] at point j from the local state vector x.
Definition Flow1D.h:653
void fromArray(SolutionArray &arr, double *soln) override
Restore the solution for this domain from a SolutionArray.
Definition Flow1D.cpp:949
double leftControlPointCoordinate() const
Returns the z-coordinate of the left control point.
Definition Flow1D.cpp:1162
AnyMap getMeta() const override
Retrieve meta data.
Definition Flow1D.cpp:864
virtual void updateDiffFluxes(const double *x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
Definition Flow1D.cpp:416
double leftControlPointTemperature() const
Returns the temperature at the left control point.
Definition Flow1D.cpp:1147
string componentName(size_t n) const override
Name of component n. May be overloaded.
Definition Flow1D.cpp:799
bool isFree() const
Retrieve flag indicating whether flow is freely propagating.
Definition Flow1D.h:360
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:246
virtual void grad_hk(const double *x, size_t j)
Compute the spatial derivative of species specific molar enthalpies using upwind differencing.
Definition Flow1D.cpp:1138
bool isStrained() const
Retrieve flag indicating whether flow uses radial momentum.
Definition Flow1D.h:371
string transportModel() const
Retrieve transport model.
Definition Flow1D.cpp:215
double rightControlPointCoordinate() const
Returns the z-coordinate of the right control point.
Definition Flow1D.cpp:1217
double V(const double *x, size_t j) const
Get the spread rate (tangential velocity gradient) [1/s] at point j from the local state vector x.
Definition Flow1D.h:664
Array2D m_dthermal
Array of size m_nsp by m_points for saving thermal diffusion coefficients.
Definition Flow1D.h:878
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:462
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:344
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:687
string domainType() const override
Domain type flag.
Definition Flow1D.cpp:123
void show(const double *x) override
Print the solution.
Definition Flow1D.cpp:782
bool m_dovisc
Determines whether the viscosity term in the momentum equation is calculated.
Definition Flow1D.h:942
virtual void setSolvingStage(const size_t stage)
Solving stage mode for handling ionized species (used by IonFlow specialization)
Definition Flow1D.cpp:1076
void setPressure(double p)
Set the pressure.
Definition Flow1D.h:138
virtual void fixElectricField(size_t j=npos)
Set to fix voltage in a point (used by IonFlow specialization)
Definition Flow1D.cpp:1088
void setAxisymmetricFlow()
Set flow configuration for axisymmetric counterflow flames, using specified inlet mass fluxes.
Definition Flow1D.h:198
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:368
double m_zRight
Location of the right control point when two-point control is enabled.
Definition Flow1D.h:995
virtual void solveElectricField(size_t j=npos)
Set to solve electric field in a point (used by IonFlow specialization)
Definition Flow1D.cpp:1082
double u(const double *x, size_t j) const
Get the axial velocity [m/s] at point j from the local state vector x.
Definition Flow1D.h:658
size_t m_kExcessRight
Index of species with a large mass fraction at the right boundary, for which the mass fraction may be...
Definition Flow1D.h:986
void _getInitialSoln(double *x) override
Write the initial solution estimate into array x.
Definition Flow1D.cpp:229
vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
Definition Flow1D.h:913
double rightControlPointTemperature() const
Returns the temperature at the right control point.
Definition Flow1D.cpp:1202
double T_fixed(size_t j) const
The fixed temperature value at point j.
Definition Flow1D.h:170
vector< double > m_ybar
Holds the average of the species mass fractions between grid points j and j+1.
Definition Flow1D.h:1011
bool m_do_radiation
Determines whether radiative heat loss is calculated.
Definition Flow1D.h:937
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:413
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:595
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.