Premixed flame¶
A flat premixed flame burns into its fresh mixture at the laminar flame
speed S_L, set by the balance of chemistry and molecular transport. This
tutorial computes freely propagating hydrogen-air flames with detailed
chemistry and mixture-averaged transport, first at stoichiometry and then
from lean to rich, and compares their flame speeds and structure with
Cantera's one-dimensional FreeFlame solver, which uses the same mechanism
and transport model.
You will use: gas mixtures from a Cantera mechanism, finite-rate chemistry,
initial conditions as expressions of x, an inflow with a composition, a
pressure outlet, and a Python script that writes Mallard input files. Files:
tutorials/premixed_flame/. Setup:
Tutorials.
1. Geometry and the reference flame¶
Mallard solves the flame in its own frame: fresh H2/air at 300 K and 1 atm enters a strip on the left at the flame speed and burnt gas leaves on the right, so a flame at S_L stays in place. The strip runs from 6 thermal thicknesses δ upstream of the flame to 9 downstream, where δ = (T_b − T_u) / max dT/dx is the thermal thickness of Cantera's flame.
flame_setup.py computes
Cantera's flame and writes the run around it. Cantera discretizes convection
with first-order upwind differences, so its flame speed depends on its grid
(on its usual grid of slope = curve = 0.02, S_L at φ = 0.6 is 1.3% low): the
script solves the flame on a grid of slope = curve = 0.01, then on that grid
doubled twice, and extrapolates S_L from the two doubled grids, where the
error halves with each doubling.
mkdir -p run/premixed_flame && cd run/premixed_flame
python3 $MALLARD/tutorials/premixed_flame/flame_setup.py 1.0 .
phi = 1: S_L = 2.33108 m/s, T_b = 2386.8 K, delta = 0.3283 mm; 300 cells over 4.9252 mm, t_stop = 0.5634 ms
It writes reference.csv (Cantera's profiles of velocity, temperature, heat
release and the H2, O2, H2O and OH mass fractions), input.toml and
mesh.sh. The input for φ = 1 is also in the repository,
tutorials/premixed_flame/input.toml.
2. Mesh¶
strip.geo is a rectangle of
n quadrilaterals along x and one across, ten times longer across than along
so the faces across the strip do not limit the time step, with the boundary
zones inlet, outlet and sides. mesh.sh runs it with the length and
cell count of this flame, 20 cells per δ:
3. Input file¶
| Table | In this case |
|---|---|
[run] |
Four flame times δ / S_L, at CFL 1 |
[mesh] |
strip.msh |
[initialize] |
analytical: temperature, velocity and mole fractions blend from the fresh to the burnt gas of Cantera's flame along c(x) = (1 + tanh(2 (x − x_f) / δ)) / 2, with N2 as the balance species; the mole fractions are a subtable, [initialize.X], one expression per species |
[[boundaries]] |
inlet: inlet_state at S_L, 300 K, 1 atm and the fresh composition X; outlet: outlet_pressure at 1 atm; sides: symmetry, which makes the strip one-dimensional |
[numerics] |
HLLC, SSPRK3, MUSCL |
[physics] |
navier_stokes, gas = "mixture", mechanism = "../../mechanisms/h2o2.yaml" (9 species, 29 reactions; the path is relative to the run directory), transport = "mixture_averaged"; see gas mixtures |
[chemistry] |
Strang splitting with the Rosenbrock integrator, rtol = 1e-6, atol = 1e-10; see finite-rate chemistry |
[[write_data]] |
Every 0.1 flame time: density, velocity, pressure, temperature, heat release, mass fractions (Y_*) and production rates (OMEGA_*) |
The tanh profile is only a start: the flame builds its own structure within
a flame time. Starting from Cantera's solution instead (as
examples/premixed_flame does, through a restart file) shortens that
transient but needs a restart file written by a script; expressions keep
this input self-contained.
4. Run¶
The strip is small, so one thread is enough (73,000 steps, about 4 minutes on one core; the chemistry takes 56% of the time):
On two MPI ranks each takes half the strip, with the same results bit for bit:
The progress rows add, for mixtures, the minimum and maximum temperature, and with chemistry the share of cells whose reactors were integrated in the last half step and the most sub-steps any cell took.
5. Monitor¶
In a steady flame the fuel consumed per unit area, divided by the density and the fuel mass fraction of the fresh gas, is the flame speed, whatever the frame. This consumption speed needs only one snapshot, so it can follow the run:
prints it for every snapshot written so far, with the flame's position,
thermal thickness and displacement speed (from the motion of the flame), and
writes them to flame/flame.csv; see
mallard post flame.
The thickness comes out 7% below Cantera's because the strip's burnt gas,
at 2231 K, has not reached the equilibrium 2379 K: the largest temperature
gradient, which it also prints, agrees within 0.6%, and
--burnt-temperature 2379.43 measures the thickness against Cantera's T_b.
plot_flame.py draws it:
The flame settles after about two and a half flame times; the comparison averages over the last one.
6. Post-process and compare¶
plot_flame.py results also prints the flame speed over the last flame time
and plots the final profiles against Cantera's, aligned at the maximum of
dT/dx:
From lean to rich¶
flame_setup.py writes the same run for any equivalence ratio. Lean flames
are slower and thicker, and their transient from the tanh start is longer:
give them more flame times.
cd ..
for phi in 0.6 0.8 1.2 1.4; do
times=$(case $phi in 0.6) echo 10;; 0.8) echo 8;; *) echo 4;; esac)
python3 $MALLARD/tutorials/premixed_flame/flame_setup.py $phi phi$phi --flame-times $times
(cd phi$phi && sh mesh.sh && $MALLARD/build/src/mallard -i input.toml --kokkos-num-threads=1 > run.log)
done
python3 $MALLARD/tutorials/premixed_flame/plot_flame.py results premixed_flame phi0.6 phi0.8 phi1.2 phi1.4 --out .
(the runs are independent: start them side by side on a multi-core machine).
With several runs, plot_flame.py results compares their flame speeds:
| φ | Cantera S_L (m/s) | Mallard S_c (m/s) | Error |
|---|---|---|---|
| 0.6 | 0.8198 | 0.8176 | −0.27% |
| 0.8 | 1.6611 | 1.6579 | −0.19% |
| 1.0 | 2.3311 | 2.3291 | −0.09% |
| 1.2 | 2.7772 | 2.7820 | +0.17% |
| 1.4 | 3.0287 | 3.0314 | +0.09% |
The rich and stoichiometric flames settle within three flame times, the flame at φ = 0.8 within five and the flame at φ = 0.6 (392,000 steps, about 20 minutes on one core) within nine. All are within 0.3% of Cantera's.
How much of that is resolution shows at φ = 0.6 with --cells-per-delta 10
and 40 (--flame-times 20; 10 cells, run to 40 flame times, settles from
about nine like the others):
| Cells per δ | 10 | 20 | 40 |
|---|---|---|---|
| S_c error, flame times 15-20 | −1.35% | −0.31% | −0.08% |
The error falls by 4.5 times per doubling of the cells, as for a second-order scheme, toward about −0.01%: at 20 cells per δ the remaining 0.3% is the discretization. At 10 cells the flame keeps slowing very slightly, from −1.33% at 20 flame times to −1.40% at 40.
7. Things to try¶
- Resolution.
--cells-per-delta 10or40inflame_setup.py, and compare the flame speeds. - Transport.
transport = "unity_lewis"in[physics]against Cantera'sunity-Lewis-numbermodel (changetransport_modelinflame_setup.py): the structure of the lean flames changes most, since hydrogen diffuses much faster than heat. - Soret effect.
soret = truein[physics]adds thermal diffusion of the light species (Cantera:flame.soret_enabled = True). - Two dimensions.
examples/flame_2dwrinkles a lean flame in a periodic channel and shows what differential diffusion does to it.