Species Transport and Reaction Mechanisms
using Rasmah
using LinearAlgebraOverview
Species transport carries each chemical species by advection and diffusion, and a reaction mechanism couples them through source terms. Rasmah provides the multi-species advection–diffusion solve, the modified-Arrhenius reaction rate, and the mass-conserving rate-of-production for a mechanism. The thermodynamic side (NASA polynomials, mixture transport) is in the combustion chemistry tutorial.
Multi-species advection–diffusion
A manufactured 3D field c = sin πx sin πy sin πz is transported by a unit velocity with diffusivity D; the solver recovers it from its source:
m = tetrahedralize_box(1.0, 1.0, 1.0, 8, 8, 8)
cexact(x) = sin(π * x[1]) * sin(π * x[2]) * sin(π * x[3])
S(x) = 3π^2 * cexact(x) + π * cos(π * x[1]) * sin(π * x[2]) * sin(π * x[3])
U = FESpace(m, ReferenceFE(3, 1))
fixed = Int[]
for i in 1:U.nnodes
x = U.nodes[:, i]
(x[1] < 1e-12 || x[1] > 1 - 1e-12 || x[2] < 1e-12 || x[2] > 1 - 1e-12 ||
x[3] < 1e-12 || x[3] > 1 - 1e-12) && push!(fixed, i)
end
c1, = species_transport_solve(m, x -> [1.0, 0.0, 0.0], [1.0], [S]; fixed=fixed)
err = maximum(abs(c1[i] - cexact(U.nodes[:, i])) for i in 1:U.nnodes if i ∉ fixed)
println("max error = ", round(err, digits=5), " (manufactured solution)")max error = 0.02607 (manufactured solution)
Reaction mechanisms
The modified-Arrhenius rate k = A T^β exp(−E_a/(RT)) and the mass-conserving rate-of-production of a mechanism:
# 2H2 + O2 → 2H2O, element-balanced
r = Reaction([-2.0, -1.0, 2.0], 1.0, 0.0, 0.0)
ω = rate_of_production([1.0, 1.0, 0.0], 1000.0, [r]; W=[2.0, 32.0, 18.0])
println("ω = ", ω, " Σ W_i ω_i = ", round(sum([2.0, 32.0, 18.0] .* ω), digits=12), " (mass conserved)")ω = [-2.0, -1.0, 2.0] Σ W_i ω_i = 0.0 (mass conserved)
Next steps
- Combustion chemistry for the thermodynamics and flamelets behind these source terms.
- Multiphase flow for the dispersed-phase analogue.
