Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

7. Advection in two dimensions by Strang splitting, with diffusion and reaction

School of Engineering, Nazarbayev University

Real environmental and chemical-engineering flows, such as an atmospheric pollutant plume dispersing in an oblique crosswind while undergoing photochemical decay, or a dye patch swirling inside a 2-D vortex, transport scalars simultaneously across multiple spatial dimensions and competing physical mechanisms. Applying 1-D TVD limiters naively one coordinate at a time (XX then YY, Lie splitting) degrades temporal accuracy to O(Δt)O(\Delta t) whenever directional transport operators fail to commute ([Lx,Ly]≠0[\mathcal{L}_x, \mathcal{L}_y] \neq 0). In this lecture we upgrade 1-D TVD advection to second-order 2-D Strang operator splitting (X/2X/2–YY–X/2X/2, tvd_advection.advect_2d_strang_periodic) for incompressible solid-body rotation, and solve steady 2-D finite-volume convection–diffusion–reaction plumes (convection_diffusion.fvm_convection_diffusion_2d_steady) across Péclet and Damköhler regimes.

Learning objectives

  1. Derive the Baker–Campbell–Hausdorff commutator error distinguishing first-order Lie (XX–YY) splitting from second-order symmetric Strang (X/2X/2–YY–X/2X/2) splitting.

  2. Simulate 2-D incompressible solid-body vortex rotation via tvd_advection.advect_2d_strang_periodic, showing exact mass conservation and [0,1][0, 1] boundedness.

  3. Formulate and solve steady 2-D finite-volume convection–diffusion–reaction transport uϕx+vϕy=Γ∇2ϕ−kϕ+Su\phi_x + v\phi_y = \Gamma\nabla^2\phi - k\phi + S (convection_diffusion.fvm_convection_diffusion_2d_steady).

  4. Quantify Péclet (Pe\mathrm{Pe}) and Damköhler (Da\mathrm{Da}) plume regimes, audit central-difference M-matrix failure at PeΔ>2\mathrm{Pe}_{\Delta} > 2, and implement a time-reversible 2-D swirling deformation benchmark.

Time: about 60 min

1. Dimensional Operator Splitting & 2-D Solid-Body Rotation

Consider 2-D incompressible scalar advection ∇⋅u=∂xu+∂yv=0\nabla \cdot \mathbf{u} = \partial_x u + \partial_y v = 0 where u=u(y)u = u(y) and v=v(x)v = v(x) (encompassing shear layers and solid-body rotation u(y)=−ω(y−y0)u(y) = -\omega(y - y_0), v(x)=+ω(x−x0)v(x) = +\omega(x - x_0)):

∂q∂t+∂(u(y) q)∂x+∂(v(x) q)∂y=0⟺∂q∂t=(Lx+Ly)q(1.1)\frac{\partial q}{\partial t} + \frac{\partial (u(y)\,q)}{\partial x} + \frac{\partial (v(x)\,q)}{\partial y} = 0 \quad\Longleftrightarrow\quad \frac{\partial q}{\partial t} = (\mathcal{L}_x + \mathcal{L}_y) q \tag{1.1}

Even for linear operators, Lx=−u(y)∂x\mathcal{L}_x = -u(y)\partial_x and Ly=−v(x)∂y\mathcal{L}_y = -v(x)\partial_y do not commute because [Lx,Ly]q=(u(y)v′(x)∂y−v(x)u′(y)∂x)q≠0[\mathcal{L}_x, \mathcal{L}_y]q = \bigl(u(y)v'(x)\partial_y - v(x)u'(y)\partial_x\bigr)q \neq 0. By the Baker–Campbell–Hausdorff expansion:

  1. Lie–Trotter (XX–YY) Splitting: SLie(Δt)=eΔtLyeΔtLx=eΔt(Lx+Ly)+Δt22[Ly,Lx]+O(Δt3)  ⟹  \mathcal{S}_{\mathrm{Lie}}(\Delta t) = e^{\Delta t \mathcal{L}_y} e^{\Delta t \mathcal{L}_x} = e^{\Delta t(\mathcal{L}_x + \mathcal{L}_y) + \frac{\Delta t^2}{2}[\mathcal{L}_y, \mathcal{L}_x] + O(\Delta t^3)} \implies global error O(Δt)O(\Delta t).

  2. Strang (1968) Symmetric (X/2X/2–YY–X/2X/2) Splitting:

SStrang(Δt)=eΔt2Lx eΔtLy eΔt2Lx=eΔt(Lx+Ly)+O(Δt3)  ⟹  global error O(Δt2)(1.2)\mathcal{S}_{\mathrm{Strang}}(\Delta t) = e^{\frac{\Delta t}{2}\mathcal{L}_x}\,e^{\Delta t \mathcal{L}_y}\,e^{\frac{\Delta t}{2}\mathcal{L}_x} = e^{\Delta t(\mathcal{L}_x + \mathcal{L}_y) + O(\Delta t^3)} \implies \text{global error } O(\Delta t^2) \tag{1.2}

Because each 1-D sweep in tvd_advection.advect_2d_strang_periodic is a conservative TVD flux-difference step along a constant-velocity row or column, the composite 2-D Strang step preserves discrete total mass ∑i,jqi,jΔxΔy\sum_{i,j} q_{i,j}\Delta x\Delta y to rounding error and guarantees positivity and [0,1][0, 1] boundedness without dimensional CFL degradation.


Demonstration 1: 2-D Solid-Body Vortex Rotation via Strang-Split TVD Transport
==============================================================================
Limiter      |  Mass Drift |      Min q | Peak q_max | L2 Error (1 rev)
----------------------------------------------------------------------
upwind       |    0.00e+00 |  +3.46e-06 |     0.2339 |          0.07519
minmod       |    0.00e+00 |  +5.12e-12 |     0.5822 |          0.03360
van_leer     |    6.94e-18 |  +5.21e-16 |     0.7486 |          0.01689
superbee     |    6.94e-18 |  +9.38e-17 |     0.8919 |          0.00800
<Figure size 1155x462 with 4 Axes>

Figure 7.1. A cosine bell after one full rotation on a 64×6464 \times 64 grid. (a) First-order upwind. (b) Strang splitting with the van Leer limiter. The dashed contours show the initial condition.

What Demonstration 1 shows. After a full 360∘360^\circ solid-body rotation on a 64×6464\times 64 mesh, first-order upwind lowers the peak of the cosine bell to qmax⁡=0.23q_{\max} = 0.23 (a loss of 77%77\%), whereas Strang-split van_leer and superbee keep 0.75 and 0.89 of the peak and the circular shape (white dashed contours show exact t=0t=0 reference) while holding mass conservation to <10−15< 10^{-15} and strict non-negativity q≥0q \geq 0.


2. Quantitative Verification of Lie O(Δt)O(\Delta t) vs. Strang O(Δt2)O(\Delta t^2) Splitting

We verify Equation (1.2) directly on a pair of non-commuting linear transport–reaction operators dydt=(A+B)y\frac{d\mathbf{y}}{dt} = (\mathbf{A} + \mathbf{B})\mathbf{y} (where [A,B]≠0[\mathbf{A}, \mathbf{B}] \neq \mathbf{0} mimics coupled directional advection and cross-stream shear/reaction). Because we can compute the exact matrix exponential via spectral/Taylor series to rounding error, refining Δt=T/M\Delta t = T / M isolates the pure operator-splitting error free of spatial discretization error.


Demonstration 2: Baker-Campbell-Hausdorff Order Verification — Lie O(dt) vs Strang O(dt^2)
==========================================================================================
Commutator ||[A, B]|| = 3.0274
Observed global order: Lie (X-Y) = 0.9987 vs Strang (X/2-Y-X/2) = 2.0000
At M=128 steps: Lie error = 3.993e-03 vs Strang error = 2.908e-06
<Figure size 748x440 with 1 Axes>

Figure 7.2. Error of Lie splitting and of Strang splitting against the time step for two operators that do not commute; the fitted slopes are 1 and 2.

What Demonstration 2 shows. Symmetric Strang splitting achieves an observed order of 2.00, and at M=128M = 128 its error is about 1400 times smaller than that of Lie splitting, at virtually identical cost (since consecutive interior half-steps eΔt2LxeΔt2Lxe^{\frac{\Delta t}{2}\mathcal{L}_x} e^{\frac{\Delta t}{2}\mathcal{L}_x} share the same cost structure as a single XX–YY cycle).


3. Steady 2-D Plume Convection–Diffusion–Reaction (fvm_convection_diffusion_2d_steady)

Now consider steady transport of a dissolved chemical species or thermal plume ϕ(x,y)\phi(x, y) on Ω=[0,Lx]×[0,Ly]\Omega = [0, L_x]\times[0, L_y] with crosswind (u,v)(u, v), diffusivity Γ>0\Gamma > 0, first-order reaction rate constant k≥0 [s−1]k \geq 0\ [\mathrm{s}^{-1}], and volumetric source S(x,y)S(x, y):

u∂ϕ∂x+v∂ϕ∂y=Γ(∂2ϕ∂x2+∂2ϕ∂y2)−kϕ+S(x,y)(3.1)u\frac{\partial \phi}{\partial x} + v\frac{\partial \phi}{\partial y} = \Gamma\left(\frac{\partial^2 \phi}{\partial x^2} + \frac{\partial^2 \phi}{\partial y^2}\right) - k\phi + S(x, y) \tag{3.1}

Integrating over a finite-volume cell ΔV=ΔxΔy\Delta V = \Delta x \Delta y with Patankar’s generalized Péclet conductance anb=D A(∣PeΔ∣)+max⁡(±F,0)a_{nb} = D\,A(|\mathrm{Pe}_{\Delta}|) + \max(\pm F, 0) yields a positive-coefficient 5-point linear system:

aPϕi,j=aWϕi−1,j+aEϕi+1,j+aSϕi,j−1+aNϕi,j+1+Si,jΔV,aP=aW+aE+aS+aN+k ΔV(3.2)a_P \phi_{i,j} = a_W \phi_{i-1,j} + a_E \phi_{i+1,j} + a_S \phi_{i,j-1} + a_N \phi_{i,j+1} + S_{i,j}\Delta V, \qquad a_P = a_W + a_E + a_S + a_N + k\,\Delta V \tag{3.2}

Adding linear decay +k ΔV>0+k\,\Delta V > 0 directly strengthens diagonal dominance of aPa_P, accelerating Red–Black SOR convergence while attenuating the downstream plume. Two dimensionless groups govern Equation (3.1):

Pe=∥u∥LΓ(convection / diffusion),DaI=kL∥u∥(reaction / convection)(3.3)\mathrm{Pe} = \frac{\|\mathbf{u}\| L}{\Gamma} \quad\text{(convection / diffusion)}, \qquad \mathrm{Da}_{\mathrm{I}} = \frac{k L}{\|\mathbf{u}\|} \quad\text{(reaction / convection)} \tag{3.3}

Demonstration 3: Steady 2-D Chemical Plume in an Oblique Crosswind (Da_I Sweep)
===============================================================================
Global Peclet Pe = 53.67
 k [1/s] |     Da_I |  SOR Iters |  Final Resid |   Peak phi |   Mean phi
------------------------------------------------------------------------
    0.00 |    0.000 |        120 |     2.03e-13 |     1.9701 |    0.37120
    2.50 |    1.863 |        100 |     4.89e-13 |     1.6560 |    0.17885
   10.00 |    7.454 |         60 |     8.88e-12 |     1.1576 |    0.05643
<Figure size 1166x462 with 4 Axes>

Figure 7.3. Steady plume from a source in a uniform diagonal flow, computed with the power-law scheme. (a) Without reaction. (b) With a first-order reaction; the titles give the rate constant and the Damköhler number.

What Demonstration 3 shows. At Pe≈53.7\mathrm{Pe} \approx 53.7 and DaI=0\mathrm{Da}_{\mathrm{I}} = 0, the non-reactive plume stretches diagonally along the (1.2,0.6)(1.2, 0.6) wind vector right up to the outflow walls, whereas at DaI=7.45\mathrm{Da}_{\mathrm{I}} = 7.45 (k=10 s−1k = 10\ \mathrm{s}^{-1}) chemical reaction consumes the species within a reaction penetration length ℓrxn∼∥u∥/k≈0.13 m\ell_{\mathrm{rxn}} \sim \|\mathbf{u}\|/k \approx 0.13\ \mathrm{m}, and reduces Red–Black SOR iterations because +kΔV+k\Delta V boosts diagonal dominance.


4. Péclet Thermal Boundary Layers

What happens when hot fluid enters from the left wall (ϕleft=1\phi_{\mathrm{left}} = 1, other walls held cold at ϕ=0\phi = 0) with zero source/reaction (S=k=0S = k = 0) as diffusivity Γ\Gamma drops across two orders of magnitude (Pex=uLx/Γ∈{5,25,125}\mathrm{Pe}_x = u L_x / \Gamma \in \{5, 25, 125\})? We compare Patankar’s power_law against exponential and upwind schemes across boundary-layer thinning δT∼Lx/Pex\delta_T \sim L_x / \mathrm{Pe}_x.


Demonstration 4: Peclet Sensitivity of 2-D Outflow Boundary-Layer Thickness
===========================================================================
Pe =    5.0 (Pe_cell = 0.125) | phi(0.5, 0.5) =  0.56374 | max |PowerLaw - Exp| = 2.071e-05
Pe =   25.0 (Pe_cell = 0.625) | phi(0.5, 0.5) =  0.96289 | max |PowerLaw - Exp| = 1.054e-03
Pe =  125.0 (Pe_cell = 3.125) | phi(0.5, 0.5) =  1.00000 | max |PowerLaw - Exp| = 5.263e-03

Inside the algorithm

Demonstration 4 shows that the fifth-power approximation A(∣Pe∣)=max⁡(0,(1−0.1∣Pe∣)5)A(|\mathrm{Pe}|) = \max\bigl(0, (1 - 0.1|\mathrm{Pe}|)^5\bigr) (power_law) tracks the exact analytical conductance A(∣Pe∣)=∣Pe∣/(e∣Pe∣−1)A(|\mathrm{Pe}|) = |\mathrm{Pe}|/(e^{|\mathrm{Pe}|}-1) (exponential) within 5×10−35\times 10^{-3} at the three Péclet numbers tested, without evaluating exponentials.

Below we inspect convection_diffusion.fvm_convection_diffusion_2d_steady and verify exact global integral species conservation:

Φleft+Φright+Φbottom+Φtop⏟Net outward boundary flux+∑i,jk ϕi,jΔV=∑i,jSi,jΔV\underbrace{\Phi_{\mathrm{left}} + \Phi_{\mathrm{right}} + \Phi_{\mathrm{bottom}} + \Phi_{\mathrm{top}}}_{\text{Net outward boundary flux}} + \sum_{i,j} k\,\phi_{i,j}\Delta V = \sum_{i,j} S_{i,j}\Delta V

Check against the library


Inside the Algorithm: Global Species Conservation check of fvm_convection_diffusion_2d_steady
=============================================================================================
def fvm_convection_diffusion_2d_steady(
    nx: int,
    ny: int,
    Lx: float,
    Ly: float,
    u_vel: float,
    v_vel: float,
    Gamma: float,
    source: float | np.ndarray = 0.0,
    k_react: float = 0.0,
    bc_walls: dict | None = None,
    scheme: str = "power_law",
    tol: float = 1e-10,
    max_iter: int = 5000,
) -> dict:
    """Solve 2-D steady FVM convection-diffusion-reaction u*phi_x + v*phi_y = Gamma*lap(phi) - k*phi + S."""
    if nx < 3 or ny < 3 or Lx <= 0.0 or Ly <= 0.0 or Gamma <= 0.0 or k_react < 0.0:
        raise ValueError("Require nx, ny >= 3, Lx, Ly, Gamma > 0, and k_react >= 0.")
    dx = float(Lx) / int(nx)
    dy = float(Ly) / int(ny)
    xc = (np.arange(nx, dtype=float) + 0.5) * dx
    yc = (np.arange(ny, dtype=float) + 0.5) * dy

    bcs = {"left": 0.0, "right": 0.0, "bottom": 0.0, "top": 0.0}
    if bc_walls is not None:
        bcs.update(bc_walls)

    fx = float(u_vel) * dy
    fy = float(v_vel) * dx
    dx_cond = float(Gamma) * dy / dx
    dy_cond = float(Gamma) * dx / dy

    ax_wt = _peclet_weighting_A(abs(fx / dx_cond), scheme)
    ay_wt = _peclet_weighting_A(abs(fy / dy_cond), scheme)
    aw = dx_cond * ax_wt + max(fx, 0.0)
    ae = dx_cond * ax_wt + max(-fx, 0.0)
    as_s = dy_cond * ay_wt + max(fy, 0.0)
    an = dy_cond * ay_wt + max(-fy, 0.0)

    # Boundary half-cell conductances:
    ax_b = _peclet_weighting_A(0.5 * abs(fx / dx_cond), scheme)
    ay_b = _peclet_weighting_A(0.5 * abs(fy / dy_cond), scheme)
    aw_b = 2.0 * dx_cond * ax_b + max(fx, 0.0)
    ae_b = 2.0 * dx_cond * ax_b + max(-fx, 0.0)
    as_b = 2.0 * dy_cond * ay_b + max(fy, 0.0)
    an_b = 2.0 * dy_cond * ay_b + max(-fy, 0.0)

    src = np.full((nx, ny), float(source), dtype=float) if np.ndim(source) == 0 else np.asarray(source, dtype=float)
    vol = dx * dy

    aw_mat = np.full((nx, ny), aw, dtype=float)
    ae_mat = np.full((nx, ny), ae, dtype=float)
    as_mat = np.full((nx, ny), as_s, dtype=float)
    an_mat = np.full((nx, ny), an, dtype=float)
    aw_mat[0, :] = 0.0
    ae_mat[-1, :] = 0.0
    as_mat[:, 0] = 0.0
    an_mat[:, -1] = 0.0

    ap_mat = aw_mat + ae_mat + as_mat + an_mat + float(k_react) * vol
    b_rhs = src * vol
    ap_mat[0, :] += aw_b
    b_rhs[0, :] += aw_b * float(bcs["left"])
    ap_mat[-1, :] += ae_b
    b_rhs[-1, :] += ae_b * float(bcs["right"])
    ap_mat[:, 0] += as_b
    b_rhs[:, 0] += as_b * float(bcs["bottom"])
    ap_mat[:, -1] += an_b
    b_rhs[:, -1] += an_b * float(bcs["top"])

    phi = np.zeros((nx, ny), dtype=float)
    ii, jj = np.meshgrid(np.arange(nx), np.arange(ny), indexing="ij")
    red = (ii + jj) % 2 == 0
    black = ~red
    omega = 1.35

    res_hist = []
    for it in range(1, max_iter + 1):
        for mask in (red, black):
            nb_sum = np.zeros_like(phi)
            nb_sum[1:, :] += aw_mat[1:, :] * phi[:-1, :]
            nb_sum[:-1, :] += ae_mat[:-1, :] * phi[1:, :]
            nb_sum[:, 1:] += as_mat[:, 1:] * phi[:, :-1]
            nb_sum[:, :-1] += an_mat[:, :-1] * phi[:, 1:]
            phi_gs = (nb_sum + b_rhs) / ap_mat
            phi[mask] = (1.0 - omega) * phi[mask] + omega * phi_gs[mask]
        if it % 20 == 0 or it == 1:
            nb_all = np.zeros_like(phi)
            nb_all[1:, :] += aw_mat[1:, :] * phi[:-1, :]
            nb_all[:-1, :] += ae_mat[:-1, :] * phi[1:, :]
            nb_all[:, 1:] += as_mat[:, 1:] * phi[:, :-1]
            nb_all[:, :-1] += an_mat[:, :-1] * phi[:, 1:]
            res = float(np.max(np.abs(ap_mat * phi - nb_all - b_rhs)))
            res_hist.append(res)
            if res < tol:
                break

    return {
        "xc": xc,
        "yc": yc,
        "phi": phi,
        "iterations": it,
        "residual_history": np.array(res_hist, dtype=float),
    }

Net inward wall flux = -0.417372, Source = +2.000000, Reaction sink = +1.582628
Global species conservation residual = 1.532e-11

Exercises

Worked solutions are in 07_solutions.ipynb. The cell below the list is a short self-check to start from.

  1. Verify a result. Verify fvm_convection_diffusion_2d_steady (u=v=0u=v=0, Γ=0.08\Gamma = 0.08, k=2.5k = 2.5, homogeneous Dirichlet walls on [0,1]2[0, 1]^2) against the exact eigenfunction ϕexact(x,y)=sin⁡(πx)sin⁡(πy)2π2Γ+k\phi_{\mathrm{exact}}(x, y) = \frac{\sin(\pi x)\sin(\pi y)}{2\pi^2 \Gamma + k} across N∈{16,32,64}N \in \{16, 32, 64\}, asserting O(h2)O(h^2) error convergence.

  2. Find how it fails. Demonstrate cell-Péclet breakdown of scheme='central' at PeΔx=5.0>2\mathrm{Pe}_{\Delta x} = 5.0 > 2: show direct-solve unphysical undershoots in fvm_convection_diffusion_1d (bounded_no_overshoot == False) and iterative SOR divergence in fvm_convection_diffusion_2d_steady(..., max_iter=80), while power_law and exponential converge monotonically in [0,1][0, 1].

  3. Implement it yourself. Implement advect_2d_swirl_reversible(q_init, dx, dy, T, n_steps, limiter) using midpoint-evaluated Strang splitting for u(y,t)=sin⁡(2πy)cos⁡(πt/T)u(y, t) = \sin(2\pi y)\cos(\pi t / T) and v(x,t)=sin⁡(2πx)cos⁡(πt/T)v(x, t) = \sin(2\pi x)\cos(\pi t / T) on [0,1)2[0, 1)^2. Verify strong filament deformation at t=T/2t = T/2 and compare t=Tt = T unmixing error across upwind, van_leer, and superbee.


Self-check for the exercises
============================
2-D Strang mass conservation, positivity, and steady plume checks passed
All checks passed.