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