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