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