Cantera  4.0.0a2
Loading...
Searching...
No Matches
Flow1D.h
Go to the documentation of this file.
1//! @file Flow1D.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_FLOW1D_H
7#define CT_FLOW1D_H
8
9#include "Domain1D.h"
10#include "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
439 bool hasAnalyticJacobian(size_t j, size_t n) const override;
440 void evalJacobianAnalytic(span<const double> xGlobal, SystemJacobian& jac) override;
441 void checkAnalyticJacobian() const override;
442
443protected:
444 AnyMap getMeta() const override;
445 void setMeta(const AnyMap& state) override;
446
447 //! @name Updates of cached properties
448 //! These methods are called by eval() to update cached properties and data that are
449 //! used for the evaluation of the governing equations.
450 //! @{
451
452 /**
453 * Update the thermodynamic properties from point j0 to point j1
454 * (inclusive), based on solution x.
455 *
456 * The gas state is set to be consistent with the solution at the
457 * points from j0 to j1.
458 *
459 * Properties that are computed and cached are:
460 * * #m_rho (density)
461 * * #m_wtm (mean molecular weight)
462 * * #m_cp (specific heat capacity)
463 * * #m_hk (species specific enthalpies)
464 * * #m_wdot (species production rates)
465 */
466 void updateThermo(span<const double> x, size_t j0, size_t j1) {
467 for (size_t j = j0; j <= j1; j++) {
468 setGas(x,j);
469 m_rho[j] = m_thermo->density();
471 m_cp[j] = m_thermo->cp_mass();
472 m_thermo->getPartialMolarEnthalpies(span<double>(&m_hk(0, j), m_nsp));
473 m_kin->getNetProductionRates(span<double>(&m_wdot(0, j), m_nsp));
474 }
475 }
476
477 /**
478 * Update the transport properties at grid points in the range from `j0`
479 * to `j1`, based on solution `x`. Evaluates the solution at the midpoint
480 * between `j` and `j + 1` to compute the transport properties. For example,
481 * the viscosity at element `j` is the viscosity evaluated at the midpoint
482 * between `j` and `j + 1`.
483 */
484 virtual void updateTransport(span<const double> x, size_t j0, size_t j1);
485
486 //! Update the diffusive mass fluxes.
487 virtual void updateDiffFluxes(span<const double> x, size_t j0, size_t j1);
488
489 //! Update the properties (thermo, transport, and diffusion flux).
490 //! This function is called in eval after the points which need
491 //! to be updated are defined.
492 virtual void updateProperties(size_t jg, span<const double> x,
493 size_t jmin, size_t jmax);
494
495 /**
496 * Computes the radiative heat loss vector over points jmin to jmax and stores
497 * the data in the qdotRadiation variable.
498 *
499 * The simple radiation model used was established by Liu and Rogg
500 * @cite liu1991. This model considers the radiation of CO2 and H2O.
501 *
502 * This model uses the optically thin limit and the gray-gas approximation to
503 * simply calculate a volume specified heat flux out of the Planck absorption
504 * coefficients, the boundary emissivities and the temperature. Polynomial lines
505 * calculate the species Planck coefficients for H2O and CO2. The data for the
506 * lines are taken from the RADCAL program @cite RADCAL.
507 * The coefficients for the polynomials are taken from
508 * [TNF Workshop](https://tnfworkshop.org/radiation/) material.
509 */
510 void computeRadiation(span<const double> x, size_t jmin, size_t jmax);
511
512 //! Planck-mean absorption polynomial factor for radiating species @p s
513 //! (0: CO2, 1: H2O) at grid point @p j. Returns
514 //! @f$ k_{P,s} / (P \cdot X_s) @f$, that is, the polynomial value divided
515 //! by the reference pressure (OneAtm).
516 double radiationPolyFactor(span<const double> x, size_t j, int s) const;
517
518 //! @}
519
520 //! @name Governing Equations
521 //! Methods called by eval() to calculate residuals for individual governing
522 //! equations.
523 //! @{
524
525 /**
526 * Evaluate the continuity equation residual.
527 *
528 * @f[
529 * \frac{d(\rho u)}{dz} + 2\rho V = 0
530 * @f]
531 *
532 * Axisymmetric flame:
533 * The continuity equation propagates information from right-to-left.
534 * The @f$ \rho u @f$ at point 0 is dependent on @f$ \rho u @f$ at point 1,
535 * but not on @f$ \dot{m} @f$ from the inlet.
536 *
537 * Freely-propagating flame:
538 * The continuity equation propagates information away from a fixed temperature
539 * point that is set in the domain.
540 *
541 * Unstrained flame:
542 * A specified mass flux; the main example being burner-stabilized flames.
543 *
544 * The default boundary condition for the continuity equation is
545 * (@f$ u = 0 @f$) at the right boundary. Because the equation is a first order
546 * equation, only one boundary condition is needed.
547 *
548 * @param[in] x Local domain state vector, includes variables like temperature,
549 * density, etc.
550 * @param[out] rsd Local domain residual vector that stores the continuity
551 * equation residuals.
552 * @param[out] diag Local domain diagonal matrix that controls whether an entry
553 * has a time-derivative (used by the solver).
554 * @param[in] rdt Reciprocal of the timestep.
555 * @param[in] jmin The index for the starting point in the local domain grid.
556 * @param[in] jmax The index for the ending point in the local domain grid.
557 */
558 virtual void evalContinuity(span<const double> x, span<double> rsd, span<int> diag,
559 double rdt, size_t jmin, size_t jmax);
560
561 /**
562 * Evaluate the momentum equation residual.
563 *
564 * @f[
565 * \rho u \frac{dV}{dz} + \rho V^2 =
566 * \frac{d}{dz}\left( \mu \frac{dV}{dz} \right) - \Lambda
567 * @f]
568 *
569 * The radial momentum equation is used for axisymmetric flows, and incorporates
570 * terms for time and spatial variations of radial velocity (@f$ V @f$). The
571 * default boundary condition is zero radial velocity (@f$ V @f$) at the left
572 * and right boundary.
573 *
574 * For argument explanation, see evalContinuity().
575 */
576 virtual void evalMomentum(span<const double> x, span<double> rsd, span<int> diag,
577 double rdt, size_t jmin, size_t jmax);
578
579 /**
580 * Evaluate the radial pressure gradient equation residual.
581 *
582 * @f[
583 * \frac{d\Lambda}{dz} = 0
584 * @f]
585 *
586 * The radial pressure gradient @f$ \Lambda @f$ serves as an eigenvalue that allows
587 * the momentum and continuity equations to be simultaneously satisfied in
588 * axisymmetric flows. This equation propagates information from
589 * left-to-right. The default boundary condition is @f$ \Lambda = 0 @f$
590 * at the left boundary. The equation is first order and so only one
591 * boundary condition is needed.
592 *
593 * For argument explanation, see evalContinuity().
594 */
595 virtual void evalLambda(span<const double> x, span<double> rsd, span<int> diag,
596 double rdt, size_t jmin, size_t jmax);
597
598 /**
599 * Evaluate the energy equation residual.
600 *
601 * @f[
602 * \rho c_p u \frac{dT}{dz} =
603 * \frac{d}{dz}\left( \Lambda \frac{dT}{dz} \right)
604 * - \sum_k h_kW_k\dot{\omega}_k
605 * - \sum_k j_k \frac{dh_k}{dz}
606 * @f]
607 *
608 * The energy equation includes contributions from
609 * chemical reactions and diffusion. Default is zero temperature (@f$ T @f$)
610 * at the left and right boundaries. These boundary values are updated by the
611 * specific boundary object connected to the domain.
612 *
613 * For argument explanation, see evalContinuity().
614 */
615 virtual void evalEnergy(span<const double> x, span<double> rsd, span<int> diag,
616 double rdt, size_t jmin, size_t jmax);
617
618 /**
619 * Evaluate the species equations' residuals.
620 *
621 * @f[
622 * \rho u \frac{dY_k}{dz} + \frac{dj_k}{dz} = W_k\dot{\omega}_k
623 * @f]
624 *
625 * The species equations include terms for temporal and spatial variations
626 * of species mass fractions (@f$ Y_k @f$). The default boundary condition is zero
627 * flux for species at the left and right boundary.
628 *
629 * For argument explanation, see evalContinuity().
630 */
631 virtual void evalSpecies(span<const double> x, span<double> rsd, span<int> diag,
632 double rdt, size_t jmin, size_t jmax);
633
634 /**
635 * Evaluate the electric field equation residual to be zero everywhere.
636 *
637 * The electric field equation is implemented in the IonFlow class. The default
638 * boundary condition is zero electric field (@f$ E @f$) at the boundary,
639 * and @f$ E @f$ is zero within the domain.
640 *
641 * For argument explanation, see evalContinuity().
642 */
643 virtual void evalElectricField(span<const double> x, span<double> rsd,
644 span<int> diag, double rdt, size_t jmin,
645 size_t jmax);
646
647 //! @} End of Governing Equations
648
649 /**
650 * Evaluate the oxidizer axial velocity equation residual.
651 *
652 * The function calculates the oxidizer axial velocity equation as
653 * @f[
654 * \frac{dU_{o}}{dz} = 0
655 * @f]
656 *
657 * This equation serves as a dummy equation that is used only in the context of
658 * two-point flame control, and serves as the way for two interior control points to
659 * be specified while maintaining block tridiagonal structure. The default boundary
660 * condition is @f$ U_o = 0 @f$ at the right and zero flux at the left boundary.
661 *
662 * For argument explanation, see evalContinuity().
663 */
664 virtual void evalUo(span<const double> x, span<double> rsd, span<int> diag,
665 double rdt, size_t jmin, size_t jmax);
666
667 //! @name Solution components
668 //! @{
669
670 //! Get the temperature at point `j` from the local state vector `x`.
671 double T(span<const double> x, size_t j) const {
672 return x[index(c_offset_T, j)];
673 }
674 //! Get the temperature at point `j` from the local state vector `x`.
675 double& T(span<double> x, size_t j) {
676 return x[index(c_offset_T, j)];
677 }
678
679 //! Get the temperature at point `j` from the previous time step.
680 double T_prev(size_t j) const {
681 return prevSoln(c_offset_T, j);
682 }
683
684 //! Get the axial mass flux [kg/m²/s] at point `j` from the local state vector `x`.
685 double rho_u(span<const double> x, size_t j) const {
686 return m_rho[j]*x[index(c_offset_U, j)];
687 }
688
689 //! Get the axial velocity [m/s] at point `j` from the local state vector `x`.
690 double u(span<const double> x, size_t j) const {
691 return x[index(c_offset_U, j)];
692 }
693
694 //! Get the spread rate (tangential velocity gradient) [1/s] at point `j` from the
695 //! local state vector `x`.
696 double V(span<const double> x, size_t j) const {
697 return x[index(c_offset_V, j)];
698 }
699
700 //! Get the spread rate [1/s] at point `j` from the previous time step.
701 double V_prev(size_t j) const {
702 return prevSoln(c_offset_V, j);
703 }
704
705 //! Get the radial pressure gradient [N/m⁴] at point `j` from the local state vector
706 //! `x`
707 double Lambda(span<const double> x, size_t j) const {
708 return x[index(c_offset_L, j)];
709 }
710
711 //! Get the oxidizer inlet velocity [m/s] linked to point `j` from the local state
712 //! vector `x`.
713 //!
714 //! @see evalUo()
715 double Uo(span<const double> x, size_t j) const {
716 return x[index(c_offset_Uo, j)];
717 }
718
719 //! Get the mass fraction of species `k` at point `j` from the local state vector
720 //! `x`.
721 double Y(span<const double> x, size_t k, size_t j) const {
722 return x[index(c_offset_Y + k, j)];
723 }
724
725 //! Get the mass fraction of species `k` at point `j` from the local state vector
726 //! `x`.
727 double& Y(span<double> x, size_t k, size_t j) {
728 return x[index(c_offset_Y + k, j)];
729 }
730
731 //! Get the array of mass fractions at point `j` from the local state vector `x`.
732 span<double> Y(span<double> x, size_t j) {
733 return span<double>(&x[index(c_offset_Y, j)], m_nsp);
734 }
735 span<const double> Y(span<const double> x, size_t j) {
736 return span<const double>(&x[index(c_offset_Y, j)], m_nsp);
737 }
738
739 //! Get the mass fraction of species `k` at point `j` from the previous time step.
740 double Y_prev(size_t k, size_t j) const {
741 return prevSoln(c_offset_Y + k, j);
742 }
743
744 //! Get the mole fraction of species `k` at point `j` from the local state vector
745 //! `x`.
746 double X(span<const double> x, size_t k, size_t j) const {
747 return m_wtm[j]*Y(x,k,j)/m_wt[k];
748 }
749
750 //! Get the diffusive mass flux [kg/m²/s] of species `k` at point `j`
751 double flux(size_t k, size_t j) const {
752 return m_flux(k, j);
753 }
754 //! @}
755
756 //! @name Convective spatial derivatives
757 //!
758 //! These methods use upwind differencing to calculate spatial derivatives
759 //! for velocity, species mass fractions, and temperature. Upwind differencing
760 //! is a numerical discretization method that considers the direction of the
761 //! flow to improve stability.
762 //! @{
763
764 /**
765 * Calculates the spatial derivative of velocity V with respect to z at point j
766 * using upwind differencing.
767 *
768 * For more details on the upwinding scheme, see the
769 * [science reference documentation](../reference/onedim/discretization.html#upwinding).
770 *
771 * @f[
772 * \frac{\partial V}{\partial z} \bigg|_{j} \approx \frac{V_{\ell} -
773 * V_{\ell-1}}{z_{\ell} - z_{\ell-1}}
774 * @f]
775 *
776 * Where the value of @f$ \ell @f$ is determined by the sign of the axial velocity.
777 * If the axial velocity is positive, the value of @f$ \ell @f$ is j. If the axial
778 * velocity is negative, the value of @f$ \ell @f$ is j + 1. A positive velocity
779 * means that the flow is moving left-to-right.
780 *
781 * @param[in] x The local domain state vector.
782 * @param[in] j The grid point index at which the derivative is computed.
783 */
784 double dVdz(span<const double> x, size_t j) const {
785 size_t jloc = (u(x, j) > 0.0 ? j : j + 1);
786 return (V(x, jloc) - V(x, jloc-1))/m_dz[jloc-1];
787 }
788
789 /**
790 * Calculates the spatial derivative of the species mass fraction @f$ Y_k @f$ with
791 * respect to z for species k at point j using upwind differencing.
792 *
793 * For details on the upwinding scheme, see dVdz().
794 *
795 * @param[in] x The local domain state vector.
796 * @param[in] k The species index.
797 * @param[in] j The grid point index at which the derivative is computed.
798 */
799 double dYdz(span<const double> x, size_t k, size_t j) const {
800 size_t jloc = (u(x, j) > 0.0 ? j : j + 1);
801 return (Y(x, k, jloc) - Y(x, k, jloc-1))/m_dz[jloc-1];
802 }
803
804 /**
805 * Calculates the spatial derivative of temperature T with respect to z at point
806 * j using upwind differencing.
807 *
808 * For details on the upwinding scheme, see dVdz().
809 *
810 * @param[in] x The local domain state vector.
811 * @param[in] j The grid point index at which the derivative is computed.
812 */
813 double dTdz(span<const double> x, size_t j) const {
814 size_t jloc = (u(x, j) > 0.0 ? j : j + 1);
815 return (T(x, jloc) - T(x, jloc-1))/m_dz[jloc-1];
816 }
817 //! @}
818
819 /**
820 * Compute the shear term from the momentum equation using a central
821 * three-point differencing scheme.
822 *
823 * The term to be discretized is:
824 * @f[
825 * \frac{d}{dz}\left(\mu \frac{dV}{dz}\right)
826 * @f]
827 *
828 * For more details on the discretization scheme used for the second derivative,
829 * see the
830 * [documentation](../reference/onedim/discretization.html#second-derivative-term).
831 *
832 * @f[
833 * \frac{d}{dz}\left(\mu \frac{dV}{dz}\right) \approx
834 * \frac{\mu_{j+1/2} \frac{V_{j+1} - V_j}{z_{j+1} - z_j} -
835 * \mu_{j-1/2} \frac{V_j - V_{j-1}}{z_j - z_{j-1}}}{\frac{z_{j+1} - z_{j-1}}{2}}
836 * @f]
837 *
838 * @param[in] x The local domain state vector.
839 * @param[in] j The grid point index at which the derivative is computed.
840 */
841 double shear(span<const double> x, size_t j) const {
842 double A_left = m_visc[j-1]*(V(x, j) - V(x, j-1)) / (z(j) - z(j-1));
843 double A_right = m_visc[j]*(V(x, j+1) - V(x, j)) / (z(j+1) - z(j));
844 return 2.0*(A_right - A_left) / (z(j+1) - z(j-1));
845 }
846
847 /**
848 * Compute the conduction term from the energy equation using a central
849 * three-point differencing scheme.
850 *
851 * For the details about the discretization, see shear().
852 *
853 * @param[in] x The local domain state vector.
854 * @param[in] j The grid point index at which the derivative is computed.
855 */
856 double conduction(span<const double> x, size_t j) const {
857 double A_left = m_tcon[j-1]*(T(x, j) - T(x, j-1)) / (z(j) - z(j-1));
858 double A_right = m_tcon[j]*(T(x, j+1) - T(x, j)) / (z(j+1) - z(j));
859 return -2.0*(A_right - A_left) / (z(j+1) - z(j-1));
860 }
861
862 /**
863 * Array access mapping for a 3D array stored in a 1D vector. Used for
864 * accessing data in the #m_multidiff member variable.
865 *
866 * @param[in] k First species index.
867 * @param[in] j The grid point index.
868 * @param[in] m The second species index.
869 */
870 size_t mindex(size_t k, size_t j, size_t m) {
871 return m*m_nsp*m_nsp + m_nsp*j + k;
872 }
873
874 /**
875 * Compute the spatial derivative of species specific molar enthalpies using upwind
876 * differencing. Updates all species molar enthalpies for all species at point j.
877 * Updates the #m_dhk_dz 2D array.
878 *
879 * For details on the upwinding scheme, see dVdz().
880 *
881 * @param[in] x The local domain state vector.
882 * @param[in] j The index at which the derivative is computed.
883 */
884 virtual void grad_hk(span<const double> x, size_t j);
885
886 //---------------------------------------------------------
887 // member data
888 //---------------------------------------------------------
889
890 //! Grid spacing. Element `j` holds the value of `z(j+1) - z(j)`.
891 vector<double> m_dz;
892
893 // mixture thermo properties
894 vector<double> m_rho; //!< Density at each grid point
895 vector<double> m_wtm; //!< Mean molecular weight at each grid point
896 vector<double> m_wt; //!< Molecular weight of each species
897 vector<double> m_cp; //!< Specific heat capacity at each grid point
898
899 // transport properties
900 vector<double> m_visc; //!< Dynamic viscosity at each grid point [Pa∙s]
901 vector<double> m_tcon; //!< Thermal conductivity at each grid point [W/m/K]
902
903 //! Coefficient used in diffusion calculations for each species at each grid point.
904 //!
905 //! The value stored is different depending on the transport model (multicomponent
906 //! versus mixture averaged) and flux gradient basis (mass or molar). Vector size is
907 //! #m_nsp × #m_points, where `m_diff[k + j*m_nsp]` contains the value for species
908 //! `k` at point `j`.
909 vector<double> m_diff;
910
911 //! Vector of size #m_nsp × #m_nsp × #m_points for saving multicomponent
912 //! diffusion coefficients. Order of elements is defined by mindex().
913 vector<double> m_multidiff;
914
915 //! Array of size #m_nsp by #m_points for saving thermal diffusion coefficients
917
918 //! Array of size #m_nsp by #m_points for saving diffusive mass fluxes
920
921 //! Array of size #m_nsp by #m_points for saving molar enthalpies
923
924 //! Array of size #m_nsp by #m_points-1 for saving enthalpy fluxes
926
927 //! Array of size #m_nsp by #m_points for saving species production rates
929
930 //---------- analytic Jacobian machinery (see evalJacobianAnalytic) ----------
931 //! `true` if analytic Jacobian columns are supported for the current
932 //! configuration (set lazily; see usingAnalyticJacobian()).
933 //! -1: unprobed, 0: no, 1: yes. Mutable because the capability probe runs
934 //! lazily from the const hasAnalyticJacobian()/usingAnalyticJacobian()
935 //! queries that the FD column-skip loop issues before evalJacobianAnalytic().
936 mutable int m_analyticJacCapable = -1;
937
938 //! Sparse dwdot/dC (∂ω̇_k/∂C_m) at one point; pattern built on first fill and
939 //! reused across points/calls by Kinetics::netProductionRates_ddCi(jac).
940 mutable Eigen::SparseMatrix<double> m_ddC;
941 vector<double> m_dwdY; //!< dense dwdot/dY at one point, column-major K×K
942 //! d(F_k(p-1))/dY_m(p) and d(F_k(p))/dY_m(p), column-major K×K. When
943 //! computing the Jacobian column for grid point p, only the derivatives of
944 //! the two adjacent midpoint fluxes with respect to Y at p are needed.
945 vector<double> m_dFm_dYp;
946 vector<double> m_dF0_dYp;
947 vector<double> m_jacBlockWork; //!< per-(row, col-point) accumulation block (K×K)
948 vector<double> m_jacXwork; //!< mole fractions at two interval endpoints (2K)
949 vector<double> m_jacColWork; //!< concentrations / energy-row accumulator (K)
950 vector<double> m_jacCpWork; //!< species heat capacities (K)
951
952 //! `true` if analytic Y-columns are active for this domain
953 bool usingAnalyticJacobian() const;
954
955 //! `true` if the analytic Jacobian is requested, either explicitly
956 //! (`jacobian_mode == "analytic"`) or by the default (`"auto"`).
957 bool analyticRequested() const {
958 return m_jacobianMode == "auto" || m_jacobianMode == "analytic";
959 }
960
961 //! `true` if this flow domain type provides analytic Jacobian species
962 //! columns consistent with its residual. Subclasses that override the
963 //! species residual or diffusive-flux physics without supplying matching
964 //! analytic derivatives (e.g. IonFlow) return `false`, so the analytic
965 //! Jacobian is not used for them.
966 virtual bool analyticJacobianSupported() const { return true; }
967
968 //! Probe (once) whether the kinetics object supports the composition
969 //! derivatives required for the analytic Jacobian, caching the result in
970 //! #m_analyticJacCapable. Safe to call from const query methods.
971 void probeAnalyticJacobian() const;
972
973 //! Chain rule: fill m_dwdY from m_ddC at point j (state already set by caller)
974 void computeWdotDerivatives(size_t j);
975
976 //! d(F_k(q))/dY_m(q) (AtQ=true) or d(F_k(q))/dY_m(q+1) (AtQ=false),
977 //! K×K column-major. Computes only the requested endpoint derivative,
978 //! using frozen diffusion prefactors from m_diff.
979 template <bool AtQ>
980 void fluxJacobian(span<const double> x, size_t q, span<double> out);
981
982 //! Add species-row Jacobian entries for grid point p
983 void addSpeciesJacEntries(span<const double> x, size_t p, SystemJacobian& jac);
984
985 //! Add energy-row Jacobian entries for grid point p
986 void addEnergyJacEntries(span<const double> x, size_t p, SystemJacobian& jac);
987
988 //! Add continuity- and momentum-row Jacobian entries for grid point p
989 void addFlowJacEntries(span<const double> x, size_t p, SystemJacobian& jac);
990
991 size_t m_nsp; //!< Number of species in the mechanism
992
993 //! Phase object used for calculating thermodynamic properties
995
996 //! Kinetics object used for calculating species production rates
997 Kinetics* m_kin = nullptr;
998
999 //! Transport object used for calculating transport properties
1000 Transport* m_trans = nullptr;
1001
1002 //! Emissivity of the surface to the left of the domain. Used for calculating
1003 //! radiative heat loss.
1004 double m_epsilon_left = 0.0;
1005
1006 //! Emissivity of the surface to the right of the domain. Used for calculating
1007 //! radiative heat loss.
1008 double m_epsilon_right = 0.0;
1009
1010 //! Indices within the ThermoPhase of the radiating species. First index is
1011 //! for CO2, second is for H2O.
1012 vector<size_t> m_kRadiating;
1013
1014 //! @name flags
1015 //! @{
1016
1017 //! For each point in the domain, `true` if energy equation is solved or `false` if
1018 //! temperature is held constant.
1019 //! @see doEnergy, fixTemperature
1020 vector<bool> m_do_energy;
1021
1022 //! `true` if the Soret diffusion term should be calculated.
1023 bool m_do_soret = false;
1024
1025 //! Determines whether diffusive fluxes are computed using gradients of mass
1026 //! fraction or mole fraction.
1027 //! @see setFluxGradientBasis, fluxGradientBasis
1028 ThermoBasis m_fluxGradientBasis = ThermoBasis::molar;
1029
1030 //! `true` if transport fluxes are computed using the multicomponent diffusion
1031 //! coefficients, or `false` if mixture-averaged diffusion coefficients are used.
1033
1034 //! Determines whether radiative heat loss is calculated.
1035 //! @see enableRadiation, radiationEnabled, computeRadiation
1036 bool m_do_radiation = false;
1037
1038 //! Determines whether the viscosity term in the momentum equation is calculated
1039 //! @see setViscosityFlag, setFreeFlow, setAxisymmetricFlow, setUnstrainedFlow,
1040 //! updateTransport, shear
1042
1043 //! Flag that is `true` for freely propagating flames anchored by a temperature
1044 //! fixed point.
1045 //! @see setFreeFlow, setAxisymmetricFlow, setUnstrainedFlow
1047
1048 //! Flag that is `true` for counterflow configurations that use the pressure
1049 //! eigenvalue @f$ \Lambda @f$ in the radial momentum equation.
1050 //! @see setFreeFlow, setAxisymmetricFlow, setUnstrainedFlow
1052
1053 //! Flag for activating two-point flame control
1054 bool m_twoPointControl = false;
1055 //! @}
1056
1057 //! radiative heat loss vector
1058 vector<double> m_qdotRadiation;
1059
1060 // fixed T and Y values
1061 //! Fixed values of the temperature at each grid point that are used when solving
1062 //! with the energy equation disabled.
1063 //!
1064 //! Values are interpolated from profiles specified with the setFixedTempProfile
1065 //! method as part of _finalize().
1066 vector<double> m_fixedtemp;
1067
1068 //! Relative coordinates used to specify a fixed temperature profile.
1069 //!
1070 //! 0 corresponds to the left edge of the domain and 1 corresponds to the right edge
1071 //! of the domain. Length is the same as the #m_tfix array.
1072 //! @see setFixedTempProfile, _finalize
1073 vector<double> m_zfix;
1074
1075 //! Fixed temperature values at the relative coordinates specified in #m_zfix.
1076 //! @see setFixedTempProfile, _finalize
1077 vector<double> m_tfix;
1078
1079 //! Index of species with a large mass fraction at the left boundary, for which the
1080 //! mass fraction may be calculated as 1 minus the sum of the other mass fractions
1081 size_t m_kExcessLeft = 0;
1082
1083 //! Index of species with a large mass fraction at the right boundary, for which the
1084 //! mass fraction may be calculated as 1 minus the sum of the other mass fractions
1085 size_t m_kExcessRight = 0;
1086
1087 //! Location of the left control point when two-point control is enabled
1088 double m_zLeft = Undef;
1089
1090 //! Temperature of the left control point when two-point control is enabled
1091 double m_tLeft = Undef;
1092
1093 //! Location of the right control point when two-point control is enabled
1094 double m_zRight = Undef;
1095
1096 //! Temperature of the right control point when two-point control is enabled
1097 double m_tRight = Undef;
1098
1099public:
1100 //! Location of the point where temperature is fixed
1101 double m_zfixed = Undef;
1102
1103 //! Temperature at the point used to fix the flame location
1104 double m_tfixed = -1.0;
1105
1106private:
1107 //! Holds the average of the species mass fractions between grid points j and j+1.
1108 //! Used when building a gas state at the grid midpoints for evaluating transport
1109 //! properties at the midpoints.
1110 vector<double> m_ybar;
1111};
1112
1113}
1114
1115#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:30
string m_jacobianMode
see setJacobianMode()
Definition Domain1D.h:769
vector< double > values(const string &component) const
Retrieve component values.
Definition Domain1D.h:424
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
Definition Domain1D.h:648
double m_press
pressure [Pa]
Definition Domain1D.h:728
virtual double value(const string &component) const
Set a single component value at a boundary.
Definition Domain1D.h:400
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
Definition Domain1D.h:625
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:390
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:580
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
Definition Flow1D.h:47
void fluxJacobian(span< const double > x, size_t q, span< double > out)
d(F_k(q))/dY_m(q) (AtQ=true) or d(F_k(q))/dY_m(q+1) (AtQ=false), K×K column-major.
Definition Flow1D.cpp:1566
void setLeftControlPointTemperature(double temperature)
Sets the temperature of the left control point.
Definition Flow1D.cpp:1348
virtual void updateDiffFluxes(span< const double > x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
Definition Flow1D.cpp:441
ThermoPhase * m_thermo
Phase object used for calculating thermodynamic properties.
Definition Flow1D.h:994
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:1363
bool usingAnalyticJacobian() const
true if analytic Y-columns are active for this domain
Definition Flow1D.cpp:1466
vector< double > m_zfix
Relative coordinates used to specify a fixed temperature profile.
Definition Flow1D.h:1073
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:666
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:707
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:198
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:1081
void setMeta(const AnyMap &state) override
Retrieve meta data.
Definition Flow1D.cpp:1160
double m_zLeft
Location of the left control point when two-point control is enabled.
Definition Flow1D.h:1088
void fixTemperature(size_t j=npos)
Specify that the the temperature should be held fixed at point j.
Definition Flow1D.cpp:1285
vector< double > m_tfix
Fixed temperature values at the relative coordinates specified in m_zfix.
Definition Flow1D.h:1077
void setRightControlPointCoordinate(double z_right)
Sets the coordinate of the right control point.
Definition Flow1D.cpp:1418
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:326
double leftEmissivity() const
Return emissivity at left boundary.
Definition Flow1D.h:287
vector< double > m_dFm_dYp
d(F_k(p-1))/dY_m(p) and d(F_k(p))/dY_m(p), column-major K×K.
Definition Flow1D.h:945
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:680
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:1023
Kinetics * m_kin
Kinetics object used for calculating species production rates.
Definition Flow1D.h:997
vector< double > m_qdotRadiation
radiative heat loss vector
Definition Flow1D.h:1058
size_t componentIndex(const string &name, bool checkAlias=true) const override
Index of component with name name.
Definition Flow1D.cpp:838
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:715
double m_tLeft
Temperature of the left control point when two-point control is enabled.
Definition Flow1D.h:1091
void setRightControlPointTemperature(double temperature)
Sets the temperature of the right control point.
Definition Flow1D.cpp:1403
virtual bool doElectricField() const
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
Definition Flow1D.cpp:1265
bool hasComponent(const string &name, bool checkAlias=true) const override
Check whether the Domain contains a component.
Definition Flow1D.cpp:858
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:696
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:365
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
Definition Flow1D.cpp:153
void setValues(const string &component, span< const double > values) override
Specify component values.
Definition Flow1D.cpp:979
void addFlowJacEntries(span< const double > x, size_t p, SystemJacobian &jac)
Add continuity- and momentum-row Jacobian entries for grid point p.
Definition Flow1D.cpp:1823
void checkAnalyticJacobian() const override
Validate that an explicitly requested analytic Jacobian (jacobian_mode == "analytic") can be used for...
Definition Flow1D.cpp:1477
bool m_usesLambda
Flag that is true for counterflow configurations that use the pressure eigenvalue in the radial mome...
Definition Flow1D.h:1051
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:1066
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:856
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:623
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:897
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:788
void enableTwoPointControl(bool twoPointControl)
Sets the status of the two-point control.
Definition Flow1D.cpp:1428
void addSpeciesJacEntries(span< const double > x, size_t p, SystemJacobian &jac)
Add species-row Jacobian entries for grid point p.
Definition Flow1D.cpp:1646
double m_tRight
Temperature of the right control point when two-point control is enabled.
Definition Flow1D.h:1097
void setBoundaryEmissivities(double e_left, double e_right)
Set the emissivities for the boundary values.
Definition Flow1D.cpp:1271
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:1028
void addEnergyJacEntries(span< const double > x, size_t p, SystemJacobian &jac)
Add energy-row Jacobian entries for grid point p.
Definition Flow1D.cpp:1726
void setFluxGradientBasis(ThermoBasis fluxGradientBasis)
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
Definition Flow1D.cpp:236
shared_ptr< SolutionArray > toArray(bool normalize=false) override
Save the state of this domain to a SolutionArray.
Definition Flow1D.cpp:1072
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:1229
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:262
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:748
vector< double > m_rho
Density at each grid point.
Definition Flow1D.h:894
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:685
void _setTransport(shared_ptr< Transport > trans) override
Update transport model to existing instance.
Definition Flow1D.cpp:133
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:1020
double m_epsilon_right
Emissivity of the surface to the right of the domain.
Definition Flow1D.h:1008
vector< double > m_tcon
Thermal conductivity at each grid point [W/m/K].
Definition Flow1D.h:901
vector< double > m_diff
Coefficient used in diffusion calculations for each species at each grid point.
Definition Flow1D.h:909
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:740
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:721
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:891
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:671
Array2D m_flux
Array of size m_nsp by m_points for saving diffusive mass fluxes.
Definition Flow1D.h:919
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:813
ThermoBasis fluxGradientBasis() const
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
Definition Flow1D.h:119
int m_analyticJacCapable
true if analytic Jacobian columns are supported for the current configuration (set lazily; see usingA...
Definition Flow1D.h:936
vector< double > m_visc
Dynamic viscosity at each grid point [Pa∙s].
Definition Flow1D.h:900
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:784
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:732
double m_epsilon_left
Emissivity of the surface to the left of the domain.
Definition Flow1D.h:1004
Transport * m_trans
Transport object used for calculating transport properties.
Definition Flow1D.h:1000
double m_tfixed
Temperature at the point used to fix the flame location.
Definition Flow1D.h:1104
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:876
vector< double > m_jacBlockWork
per-(row, col-point) accumulation block (K×K)
Definition Flow1D.h:947
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:503
Array2D m_wdot
Array of size m_nsp by m_points for saving species production rates.
Definition Flow1D.h:928
Array2D m_hk
Array of size m_nsp by m_points for saving molar enthalpies.
Definition Flow1D.h:922
void _setKinetics(shared_ptr< Kinetics > kin) override
Update transport model to existing instance.
Definition Flow1D.cpp:127
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:799
void setFreeFlow()
Set flow configuration for freely-propagating flames, using an internal point with a fixed temperatur...
Definition Flow1D.h:192
vector< double > m_dwdY
dense dwdot/dY at one point, column-major K×K
Definition Flow1D.h:941
void computeWdotDerivatives(size_t j)
Chain rule: fill m_dwdY from m_ddC at point j (state already set by caller)
Definition Flow1D.cpp:1541
virtual bool analyticJacobianSupported() const
true if this flow domain type provides analytic Jacobian species columns consistent with its residual...
Definition Flow1D.h:966
vector< double > m_jacXwork
mole fractions at two interval endpoints (2K)
Definition Flow1D.h:948
void getValues(const string &component, span< double > values) const override
Retrieve component values.
Definition Flow1D.cpp:958
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
Definition Flow1D.cpp:1115
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:389
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:751
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:870
void updateState(size_t loc) override
Update state at given location to state of associated Solution object.
Definition Flow1D.cpp:942
bool m_do_multicomponent
true if transport fluxes are computed using the multicomponent diffusion coefficients,...
Definition Flow1D.h:1032
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:701
Eigen::SparseMatrix< double > m_ddC
Sparse dwdot/dC (∂ω̇_k/∂C_m) at one point; pattern built on first fill and reused across points/calls...
Definition Flow1D.h:940
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:727
bool hasAnalyticJacobian(size_t j, size_t n) const override
Returns true if this domain computes the Jacobian column for component n at (domain-local) grid point...
Definition Flow1D.cpp:1512
vector< double > m_wt
Molecular weight of each species.
Definition Flow1D.h:896
void show(span< const double > x) override
Print the solution.
Definition Flow1D.cpp:797
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:587
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:1046
Array2D m_dhk_dz
Array of size m_nsp by m_points-1 for saving enthalpy fluxes.
Definition Flow1D.h:925
vector< double > m_wtm
Mean molecular weight at each grid point.
Definition Flow1D.h:895
vector< double > m_multidiff
Vector of size m_nsp × m_nsp × m_points for saving multicomponent diffusion coefficients.
Definition Flow1D.h:913
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:1054
double m_zfixed
Location of the point where temperature is fixed.
Definition Flow1D.h:1101
size_t m_nsp
Number of species in the mechanism.
Definition Flow1D.h:991
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:530
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:690
double & T(span< double > x, size_t j)
Get the temperature at point j from the local state vector x.
Definition Flow1D.h:675
void setProfile(const string &component, span< const double > pos, span< const double > values) override
Specify a profile for a component.
Definition Flow1D.cpp:1021
void getResiduals(const string &component, span< double > values) const override
Retrieve internal work array values for a component.
Definition Flow1D.cpp:1000
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:841
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:274
double leftControlPointCoordinate() const
Returns the z-coordinate of the left control point.
Definition Flow1D.cpp:1333
AnyMap getMeta() const override
Retrieve meta data.
Definition Flow1D.cpp:891
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:746
double radiationPolyFactor(span< const double > x, size_t j, int s) const
Planck-mean absorption polynomial factor for radiating species s (0: CO2, 1: H2O) at grid point j.
Definition Flow1D.cpp:487
bool analyticRequested() const
true if the analytic Jacobian is requested, either explicitly (jacobian_mode == "analytic") or by the...
Definition Flow1D.h:957
double leftControlPointTemperature() const
Returns the temperature at the left control point.
Definition Flow1D.cpp:1318
string componentName(size_t n) const override
Name of component n. May be overloaded.
Definition Flow1D.cpp:814
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:466
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:213
vector< double > m_jacColWork
concentrations / energy-row accumulator (K)
Definition Flow1D.h:949
string transportModel() const
Retrieve transport model.
Definition Flow1D.cpp:232
double rightControlPointCoordinate() const
Returns the z-coordinate of the right control point.
Definition Flow1D.cpp:1388
Array2D m_dthermal
Array of size m_nsp by m_points for saving thermal diffusion coefficients.
Definition Flow1D.h:916
void evalJacobianAnalytic(span< const double > xGlobal, SystemJacobian &jac) override
Add this domain's analytic Jacobian entries (for columns claimed by hasAnalyticJacobian()) to jac via...
Definition Flow1D.cpp:1517
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:708
vector< double > m_jacCpWork
species heat capacities (K)
Definition Flow1D.h:950
string domainType() const override
Domain type flag.
Definition Flow1D.cpp:117
void _getInitialSoln(span< double > x) override
Write the initial solution estimate into array x.
Definition Flow1D.cpp:246
bool m_dovisc
Determines whether the viscosity term in the momentum equation is calculated.
Definition Flow1D.h:1041
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:1094
virtual void solveElectricField()
Set to solve electric field in a point (used by IonFlow specialization)
Definition Flow1D.cpp:1253
virtual void fixElectricField()
Set to fix voltage in a point (used by IonFlow specialization)
Definition Flow1D.cpp:1259
void probeAnalyticJacobian() const
Probe (once) whether the kinetics object supports the composition derivatives required for the analyt...
Definition Flow1D.cpp:1446
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:1085
vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
Definition Flow1D.h:1012
void setTransportModel(const string &model) override
Set transport model by name.
Definition Flow1D.cpp:222
void setFlatProfile(const string &component, double value) override
Specify a flat profile for a component.
Definition Flow1D.cpp:1054
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:255
double rightControlPointTemperature() const
Returns the temperature at the right control point.
Definition Flow1D.cpp:1373
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:1110
bool m_do_radiation
Determines whether radiative heat loss is calculated.
Definition Flow1D.h:1036
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:1309
Public interface for kinetics managers.
Definition Kinetics.h:124
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:677
virtual double density() const
Density (kg/m^3).
Definition Phase.h:611
Abstract base class representing Jacobian matrices and preconditioners used in nonlinear solvers.
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.