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