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