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