Algorithm Search⌘K

Algorithmcore

Flux vector splitting

Also called Steger-Warming splitting, van Leer flux splitting.

Splits the flux into parts with nonnegative and nonpositive eigenvalues and upwinds each part, with no Riemann solver.

Time
O(m M K) worst
Space
O(m M) extra
Where
K = the number of time steps (O(M) for a fixed end time and Courant number); M = the number of cells; m = the number of conserved components
Properties
conservativedeterministicexplicitnot keeps stationary contact
Origin
Joseph L. Steger, R. F. Warming, Bram van Leer, 1981

Flux vector splitting builds an upwind finite volume flux without solving a Riemann problem. It writes the physical flux as a sum F(U)=F+(U)+F−(U)F(U) = F^+(U) + F^-(U), where F+F^+ carries only waves that move right and F−F^- only waves that move left. At each face it takes the right-moving part from the left cell and the left-moving part from the right cell: Fj+1/2=F+(Uj)+F−(Uj+1)F_{j+1/2} = F^+(U_j) + F^-(U_{j+1}). Steger and Warming (1981) split by the signs of the eigenvalues. Van Leer (1982) split by polynomials in the Mach number, so that the parts are smooth at the sonic points. Both give first order schemes that are cheap and robust. They smear contacts, even contacts at rest, because the splitting treats each side alone and never sees the jump.

In plain words

At a cell face, some information flows right and some flows left. Flux vector splitting asks each cell on its own: how much of your flux goes right and how much goes left? The face then takes the right-going part of the left cell and the left-going part of the right cell, and adds them. No cell needs to know about its neighbor, so there is no Riemann problem to solve. When the gas moves faster than sound, everything goes one way and the scheme is plain upwinding. The price is that a jump between two cells is never seen as one wave, so contacts get blurred.

The problem

Given cell averages UjnU_j^n of the Euler equations Ut+F(U)x=0U_t + F(U)_x = 0 with U=(ρ,ρu,E)U = (\rho, \rho u, E), F(U)=(ρu,ρu2+p,u(E+p))F(U) = (\rho u, \rho u^2 + p, u(E + p)), E=p/(γ−1)+ρu2/2E = p/(\gamma - 1) + \rho u^2/2, c=γp/ρc = \sqrt{\gamma p/\rho}, H=(E+p)/ρH = (E + p)/\rho and γ=1.4\gamma = 1.4, compute face fluxes that make the conservative update Ujn+1=Ujn−ΔtΔx(Fj+1/2−Fj−1/2)U_j^{n+1} = U_j^n - \frac{\Delta t}{\Delta x}(F_{j+1/2} - F_{j-1/2}) consistent and stable, using only the state of each cell to form its part. The Mach number is M=u/cM = u/c, and x±=(x±∣x∣)/2x^\pm = (x \pm |x|)/2.

The algorithm

  1. STEGER-WARMING(U)
  2. 1λ <- (u - c, u, u + c); r_1 <- (1, u - c, H - uc); r_2 <- (1, u, u²/2); r_3 <- (1, u + c, H + uc)
  3. 2return F^± <- (ρ/(2γ)) (λ_1^± r_1 + 2(γ-1) λ_2^± r_2 + λ_3^± r_3)
  4. VAN-LEER(U)
  5. 3if M ≥ 1: return (F(U), 0); if M ≤ -1: return (0, F(U))
  6. 4m^± <- ± ρc (M ± 1)²/4
  7. 5return F^± <- m^± (1, ((γ-1)u ± 2c)/γ, ((γ-1)u ± 2c)²/(2(γ²-1)))
  8. FVS-FLUX(U_L, U_R)
  9. 6return F^+(U_L) + F^-(U_R)
  10. FV-STEP(U, Δt, Δx)
  11. 7add one ghost cell on each side (copy for outflow, wrap for periodic)
  12. 8for each face j+1/2: F_{j+1/2} <- FVS-FLUX(U_j, U_{j+1})
  13. 9for each cell j: U_j <- U_j - (Δt/Δx)(F_{j+1/2} - F_{j-1/2})

Lines L1 and L2 use the fact that the Euler flux is homogeneous of degree one, so F(U)=A(U)UF(U) = A(U)U, and that U=ρ2γr1+ρ(γ−1)γr2+ρ2γr3U = \frac{\rho}{2\gamma}r_1 + \frac{\rho(\gamma - 1)}{\gamma}r_2 + \frac{\rho}{2\gamma}r_3. Splitting each eigenvalue into its positive and negative parts splits FF. Line L3 makes supersonic flow pure upwinding. Lines L4 and L5 are van Leer's quadratic parts, which join the supersonic values with a matching slope at M=±1M = \pm 1.

Example

The flux by hand. At the face of Sod's shock tube, WL=(ρ,u,p)=(1,0,1)W_L = (\rho, u, p) = (1, 0, 1) and WR=(0.125,0,0.1)W_R = (0.125, 0, 0.1), both states are at rest, so M=0M = 0 on both sides. With cL=1.18322c_L = 1.18322 and cR=1.05830c_R = 1.05830:

  • Steger-Warming: F±=(±ρc2γ,p2,±ρc32γ(γ−1))F^\pm = \big(\pm\frac{\rho c}{2\gamma}, \frac{p}{2}, \pm\frac{\rho c^3}{2\gamma(\gamma - 1)}\big), so F+(UL)=(0.422577,0.5,1.479020)F^+(U_L) = (0.422577, 0.5, 1.479020), F−(UR)=(−0.047246,0.05,−0.132288)F^-(U_R) = (-0.047246, 0.05, -0.132288) and the face flux is (0.375332,0.55,1.346732)(0.375332, 0.55, 1.346732).
  • Van Leer: F±=(±ρc4,p2,±ρc32(γ2−1))F^\pm = \big(\pm\frac{\rho c}{4}, \frac{p}{2}, \pm\frac{\rho c^3}{2(\gamma^2 - 1)}\big), so F+(UL)=(0.295804,0.5,0.862762)F^+(U_L) = (0.295804, 0.5, 0.862762), F−(UR)=(−0.033072,0.05,−0.077168)F^-(U_R) = (-0.033072, 0.05, -0.077168) and the face flux is (0.262732,0.55,0.785594)(0.262732, 0.55, 0.785594).

The exact Godunov flux is (0.395391,0.669837,1.154038)(0.395391, 0.669837, 1.154038) (see the exact Riemann solver). Both splittings give the momentum flux (pL+pR)/2=0.55(p_L + p_R)/2 = 0.55, because each side sees only its own pressure.

Sod's tube. On [0,1][0, 1] with the jump at x=0.5x = 0.5, outflow boundaries and Courant number 0.9, the scheme runs to t=0.2t = 0.2. The table gives the L1L^1 error of the density against the exact cell averages (a 16-point midpoint rule in each cell), measured with the code on this page.

cells MM steps Steger-Warming van Leer
50 24 0.02564 0.02070
100 48 0.01881 0.01457
200 97 0.01268 0.00967

For comparison, the Roe solver gives 0.00886 on 97 steps with 100 cells. The splittings are more diffusive, mostly at the contact.

A smooth wave. The density wave ρ=1+0.2sin⁡(2π(x−t))\rho = 1 + 0.2\sin(2\pi(x - t)), u=1u = 1, p=1p = 1 on a periodic grid is an exact solution. At t=0.1t = 0.1 the van Leer errors for M=25,50,100,200M = 25, 50, 100, 200 are 0.0055880.005588, 0.0027630.002763, 0.0013850.001385 and 0.0006930.000693, and the Steger-Warming errors are 0.0040710.004071, 0.0019700.001970, 0.0009810.000981 and 0.0004890.000489. Both have order 1.00 at the finest pair.

A contact at rest. Take ρ=1\rho = 1 for x<0.5x < 0.5 and ρ=0.125\rho = 0.125 for x>0.5x > 0.5, with u=0u = 0 and p=1p = 1. The van Leer mass flux at the jump is (ρLcL−ρRcR)/4=0.191221(\rho_L c_L - \rho_R c_R)/4 = 0.191221, not zero. With 100 cells, after 47 steps (t=0.1t = 0.1), the densities in cells 47 to 54 are 0.928,0.836,0.709,0.568,0.440,0.337,0.263,0.2120.928, 0.836, 0.709, 0.568, 0.440, 0.337, 0.263, 0.212, and a velocity of up to 0.036 has appeared. Roe and HLLC keep this state exactly.

Correctness

The proof is in proofs/correctness.md. Theorem: both splittings satisfy F+(U)+F−(U)=F(U)F^+(U) + F^-(U) = F(U), so the face flux is consistent, and the scheme is conservative; by the Lax-Wendroff theorem, a limit of the scheme is a weak solution. The Steger-Warming parts are F±=A±UF^\pm = A^\pm U, where A±A^\pm has the eigenvalues λk±\lambda_k^\pm. The van Leer parts are continuous with continuous first derivatives at M=±1M = \pm 1, because the subsonic F∓F^\mp has the factor (M∓1)2(M \mp 1)^2. For a scalar law f=f++f−f = f^+ + f^- with f+f^+ nondecreasing and f−f^- nonincreasing, the scheme is monotone and TVD when λsup⁡(f+′−f−′)≤1\lambda\sup(f^{+\prime} - f^{-\prime}) \le 1.

Proof: The Steger-Warming and van Leer splittings add up to the Euler flux, the van Leer parts are smooth at the sonic points, and the scalar splitting scheme is TVDfull

Setting. The scheme stores cell averages UjnU_j^n on a uniform grid with width Δx\Delta x and steps Ujn+1=Ujn−λ(Fj+1/2−Fj−1/2)U_j^{n+1} = U_j^n - \lambda(F_{j+1/2} - F_{j-1/2}) with λ=Δt/Δx\lambda = \Delta t/\Delta x (line L9). The face flux is Fj+1/2=F+(Uj)+F−(Uj+1)F_{j+1/2} = F^+(U_j) + F^-(U_{j+1}) (line L6). For the Euler equations, U=(ρ,ρu,E)U = (\rho, \rho u, E), p=(γ−1)(E−12ρu2)p = (\gamma - 1)(E - \frac12\rho u^2), c=γp/ρc = \sqrt{\gamma p/\rho}, H=(E+p)/ρH = (E + p)/\rho and M=u/cM = u/c. The eigenvalues of the Jacobian A(U)=∂F/∂UA(U) = \partial F/\partial U are λ1=u−c\lambda_1 = u - c, λ2=u\lambda_2 = u, λ3=u+c\lambda_3 = u + c, with right eigenvectors r1=(1,u−c,H−uc)r_1 = (1, u - c, H - uc), r2=(1,u,12u2)r_2 = (1, u, \frac12 u^2) and r3=(1,u+c,H+uc)r_3 = (1, u + c, H + uc). For a real number xx, x+=max⁡(x,0)x^+ = \max(x, 0) and x−=min⁡(x,0)x^- = \min(x, 0).

Lemma 1 (the state in eigenvector coordinates). U=w1r1+w2r2+w3r3U = w_1 r_1 + w_2 r_2 + w_3 r_3 with w1=w3=ρ/(2γ)w_1 = w_3 = \rho/(2\gamma) and w2=ρ(γ−1)/γw_2 = \rho(\gamma - 1)/\gamma.

Proof. Mass: 2ρ/(2γ)+ρ(γ−1)/γ=ρ2\rho/(2\gamma) + \rho(\gamma - 1)/\gamma = \rho. Momentum: ρ2γ((u−c)+(u+c))+ρ(γ−1)γu=ρu\frac{\rho}{2\gamma}\big((u - c) + (u + c)\big) + \frac{\rho(\gamma - 1)}{\gamma}u = \rho u. Energy: ρ2γ⋅2H+ρ(γ−1)γ⋅u22\frac{\rho}{2\gamma}\cdot 2H + \frac{\rho(\gamma - 1)}{\gamma}\cdot\frac{u^2}{2}. Here ρH=E+p=γpγ−1+12ρu2\rho H = E + p = \frac{\gamma p}{\gamma - 1} + \frac12\rho u^2, so ρH/γ=pγ−1+ρu22γ\rho H/\gamma = \frac{p}{\gamma - 1} + \frac{\rho u^2}{2\gamma}. Adding (γ−1)ρu22γ\frac{(\gamma - 1)\rho u^2}{2\gamma} gives pγ−1+12ρu2=E\frac{p}{\gamma - 1} + \frac12\rho u^2 = E. □\square

Lemma 2 (homogeneity). F(sU)=sF(U)F(sU) = sF(U) for s>0s > 0, and F(U)=A(U)UF(U) = A(U)U.

Proof. Scaling UU by ss scales ρ\rho, ρu\rho u, EE and pp by ss and leaves uu unchanged. Each flux component, ρu\rho u, ρu2+p\rho u^2 + p and u(E+p)u(E + p), is then scaled by ss. Differentiating F(sU)=sF(U)F(sU) = sF(U) with respect to ss at s=1s = 1 gives A(U)U=F(U)A(U)U = F(U) (Euler's theorem on homogeneous functions). □\square

Theorem 1 (Steger-Warming). Let F±(U)=∑kλk±wkrkF^\pm(U) = \sum_k \lambda_k^\pm w_k r_k (lines L1 and L2). Then F++F−=FF^+ + F^- = F, F±=A±UF^\pm = A^\pm U with A±=RΛ±R−1A^\pm = R\Lambda^\pm R^{-1}, the eigenvalues of A+A^+ are λk+≥0\lambda_k^+ \ge 0 and those of A−A^- are λk−≤0\lambda_k^- \le 0. If u≥cu \ge c then F+=FF^+ = F and F−=0F^- = 0, and if u≤−cu \le -c then F+=0F^+ = 0 and F−=FF^- = F.

Proof. By Lemma 1 and Ark=λkrkAr_k = \lambda_k r_k, AU=∑kλkwkrkA U = \sum_k \lambda_k w_k r_k, and by Lemma 2 this is F(U)F(U). Since λk++λk−=λk\lambda_k^+ + \lambda_k^- = \lambda_k for each kk, F++F−=∑kλkwkrk=FF^+ + F^- = \sum_k \lambda_k w_k r_k = F. The matrix RΛ±R−1R\Lambda^\pm R^{-1} maps U=∑kwkrkU = \sum_k w_k r_k to ∑kλk±wkrk=F±\sum_k \lambda_k^\pm w_k r_k = F^\pm, and its eigenvalues are the entries of Λ±\Lambda^\pm. If u≥cu \ge c, all three λk≥0\lambda_k \ge 0, so λk+=λk\lambda_k^+ = \lambda_k and λk−=0\lambda_k^- = 0, which gives F+=FF^+ = F and F−=0F^- = 0. The case u≤−cu \le -c is the mirror. □\square

Written out, F±=ρ2γ(λ1±+2(γ−1)λ2±+λ3±, (u−c)λ1±+2(γ−1)uλ2±+(u+c)λ3±, (H−uc)λ1±+(γ−1)u2λ2±+(H+uc)λ3±)F^\pm = \frac{\rho}{2\gamma}\big(\lambda_1^\pm + 2(\gamma - 1)\lambda_2^\pm + \lambda_3^\pm,\ (u - c)\lambda_1^\pm + 2(\gamma - 1)u\lambda_2^\pm + (u + c)\lambda_3^\pm,\ (H - uc)\lambda_1^\pm + (\gamma - 1)u^2\lambda_2^\pm + (H + uc)\lambda_3^\pm\big). The map x↦x+x \mapsto x^+ has a kink at x=0x = 0, so F±F^\pm is continuous but its derivative jumps where u=±cu = \pm c or u=0u = 0.

Theorem 2 (van Leer). For ∣M∣<1|M| < 1 let

F±=±ρc4(M±1)2(1, (γ−1)u±2cγ, ((γ−1)u±2c)22(γ2−1))F^\pm = \pm\frac{\rho c}{4}(M \pm 1)^2\Big(1,\ \frac{(\gamma - 1)u \pm 2c}{\gamma},\ \frac{((\gamma - 1)u \pm 2c)^2}{2(\gamma^2 - 1)}\Big)

(lines L4 and L5), and for ∣M∣≥1|M| \ge 1 let the parts be as in Theorem 1 (line L3). Then F++F−=FF^+ + F^- = F for every state, and F+F^+ and F−F^- are continuous with continuous first derivatives across M=1M = 1 and M=−1M = -1.

Proof. Write a=(γ−1)ua = (\gamma - 1)u, X=(M+1)(a+2c)X = (M + 1)(a + 2c) and Y=(M−1)(a−2c)Y = (M - 1)(a - 2c).

Mass: ρc4((M+1)2−(M−1)2)=ρc4⋅4M=ρu\frac{\rho c}{4}\big((M + 1)^2 - (M - 1)^2\big) = \frac{\rho c}{4}\cdot 4M = \rho u.

Momentum: ρc4γ((M+1)2(a+2c)−(M−1)2(a−2c))\frac{\rho c}{4\gamma}\big((M + 1)^2(a + 2c) - (M - 1)^2(a - 2c)\big). The bracket is a⋅4M+2c((M+1)2+(M−1)2)=4aM+4c(M2+1)a\cdot 4M + 2c\big((M + 1)^2 + (M - 1)^2\big) = 4aM + 4c(M^2 + 1). So the sum is ργ((γ−1)u2+u2+c2)=ρu2+ρc2/γ=ρu2+p\frac{\rho}{\gamma}\big((\gamma - 1)u^2 + u^2 + c^2\big) = \rho u^2 + \rho c^2/\gamma = \rho u^2 + p.

Energy: ρc8(γ2−1)(X2−Y2)\frac{\rho c}{8(\gamma^2 - 1)}(X^2 - Y^2). Expanding, X−Y=2a+4cM=2(γ+1)uX - Y = 2a + 4cM = 2(\gamma + 1)u and X+Y=2aM+4cX + Y = 2aM + 4c. So X2−Y2=4(γ+1)u((γ−1)uM+2c)X^2 - Y^2 = 4(\gamma + 1)u\big((\gamma - 1)uM + 2c\big), and the sum is ρcu2(γ−1)((γ−1)uM+2c)=ρu2(γ−1)((γ−1)u2+2c2)=ρu(12u2+c2γ−1)=ρuH=u(E+p)\frac{\rho c u}{2(\gamma - 1)}\big((\gamma - 1)uM + 2c\big) = \frac{\rho u}{2(\gamma - 1)}\big((\gamma - 1)u^2 + 2c^2\big) = \rho u\big(\tfrac12 u^2 + \tfrac{c^2}{\gamma - 1}\big) = \rho u H = u(E + p).

So F++F−=FF^+ + F^- = F for ∣M∣<1|M| < 1, and by Theorem 1 also for ∣M∣≥1|M| \ge 1. At M=1M = 1, the subsonic F−F^- is the product of (M−1)2(M - 1)^2 and a smooth function of (ρ,u,c)(\rho, u, c), so F−F^- and its first derivatives are zero there. The supersonic F−F^- is identically zero, so F−F^- is C1C^1 across M=1M = 1. Then F+=F−F−F^+ = F - F^- is C1C^1 there too, because FF is smooth. The case M=−1M = -1 is the mirror, with (M+1)2(M + 1)^2 in F+F^+. □\square

Theorem 3 (consistency and conservation). For both splittings, Fj+1/2=F(U)F_{j+1/2} = F(U) when Uj=Uj+1=UU_j = U_{j+1} = U, and on a periodic grid the sums ∑jUj\sum_j U_j are kept. So, by the Lax-Wendroff theorem, a limit that the scheme converges to boundedly in Lloc1L^1_{loc} is a weak solution.

Proof. Consistency is F+(U)+F−(U)=F(U)F^+(U) + F^-(U) = F(U), which is Theorems 1 and 2. Conservation: each face flux enters cell jj with the factor −λ-\lambda and cell j+1j + 1 with +λ+\lambda, so the sum over a periodic grid telescopes. □\square

Theorem 4 (scalar law: TVD). Let f=f++f−f = f^+ + f^- with f+f^+ nondecreasing, f−f^- nonincreasing, both Lipschitz, and let Fj+1/2=f+(uj)+f−(uj+1)F_{j+1/2} = f^+(u_j) + f^-(u_{j+1}). If λsup⁡(f+′−f−′)≤1\lambda \sup(f^{+\prime} - f^{-\prime}) \le 1, then the scheme does not increase ∑j∣uj+1−uj∣\sum_j |u_{j+1} - u_j|, and it is monotone.

Proof. With Δj+1/2=uj+1−uj\Delta_{j+1/2} = u_{j+1} - u_j,

ujn+1=uj−λ(f+(uj)−f+(uj−1))−λ(f−(uj+1)−f−(uj))=uj−Cj−1/2Δj−1/2+Dj+1/2Δj+1/2,u_j^{n+1} = u_j - \lambda\big(f^+(u_j) - f^+(u_{j-1})\big) - \lambda\big(f^-(u_{j+1}) - f^-(u_j)\big) = u_j - C_{j-1/2}\Delta_{j-1/2} + D_{j+1/2}\Delta_{j+1/2},

where Cj−1/2=λf+(uj)−f+(uj−1)Δj−1/2≥0C_{j-1/2} = \lambda\frac{f^+(u_j) - f^+(u_{j-1})}{\Delta_{j-1/2}} \ge 0 and Dj+1/2=−λf−(uj+1)−f−(uj)Δj+1/2≥0D_{j+1/2} = -\lambda\frac{f^-(u_{j+1}) - f^-(u_j)}{\Delta_{j+1/2}} \ge 0 (read as 0 when the difference is 0). Then Cj+1/2+Dj+1/2=λ(f+−f−)(uj+1)−(f+−f−)(uj)Δj+1/2≤λsup⁡(f+′−f−′)≤1C_{j+1/2} + D_{j+1/2} = \lambda\frac{(f^+ - f^-)(u_{j+1}) - (f^+ - f^-)(u_j)}{\Delta_{j+1/2}} \le \lambda\sup(f^{+\prime} - f^{-\prime}) \le 1. By Harten's lemma (Harten 1983), the total variation does not increase. Monotone: the update H(uj−1,uj,uj+1)H(u_{j-1}, u_j, u_{j+1}) is nondecreasing in uj−1u_{j-1} (since f+f^+ is nondecreasing), in uj+1u_{j+1} (since f−f^- is nonincreasing), and in uju_j, because uj↦uj−λ(f+−f−)(uj)u_j \mapsto u_j - \lambda(f^+ - f^-)(u_j) has slope 1−λ(f+′−f−′)≥01 - \lambda(f^{+\prime} - f^{-\prime}) \ge 0. □\square

For Burgers' equation the choice f+=(u+)2/2f^+ = (u^+)^2/2, f−=(u−)2/2f^- = (u^-)^2/2 has f+′−f−′=∣u∣f^{+\prime} - f^{-\prime} = |u|, so the condition is λmax⁡∣u∣≤1\lambda\max|u| \le 1. The test runs this case with λmax⁡∣u∣=0.9\lambda\max|u| = 0.9 on random data and checks that the total variation does not increase in 40 steps. Monotone schemes converge to the entropy solution (Crandall and Majda 1980).

Proposition 5 (a contact at rest is not kept). Let WL=(ρL,0,p)W_L = (\rho_L, 0, p) and WR=(ρR,0,p)W_R = (\rho_R, 0, p) with ρL≠ρR\rho_L \ne \rho_R. The van Leer mass flux at the face is (ρLcL−ρRcR)/4(\rho_L c_L - \rho_R c_R)/4 and the Steger-Warming one is (ρLcL−ρRcR)/(2γ)(\rho_L c_L - \rho_R c_R)/(2\gamma). Both are nonzero, so the exact steady solution is not a steady solution of the scheme.

Proof. At M=0M = 0, the van Leer mass parts are ±ρc/4\pm\rho c/4, and the Steger-Warming parts are ρ2γ(λ1±+λ3±)=±ρc2γ\frac{\rho}{2\gamma}(\lambda_1^\pm + \lambda_3^\pm) = \pm\frac{\rho c}{2\gamma}. So the face mass flux is the difference of the two ρc\rho c values times 14\frac14 or 12γ\frac{1}{2\gamma}. With equal pressures, ρc=γpρ\rho c = \sqrt{\gamma p \rho} is strictly increasing in ρ\rho, so ρLcL≠ρRcR\rho_L c_L \ne \rho_R c_R. □\square

Complexity

Theorem, in the real-RAM model: each split costs O(m)O(m) operations and one square root per cell, for mm conserved components, and each cell is split once per step, not once per face. One step costs O(mM)O(mM) and the memory is O(mM)O(mM). To reach a fixed time at a fixed Courant number takes O(M)O(M) steps, so O(mM2)O(mM^2) in all. There is no iteration, no Roe average and no eigenvector of a two-state matrix.

Properties

  • First order. The measured order on the smooth wave is 1.00.
  • Upwind for supersonic flow. If M≥1M \ge 1 on both sides, the face flux is F(UL)F(U_L), as in the upwind scheme.
  • Smooth parts (van Leer). The van Leer parts are C1C^1 in UU. The Jacobian of F+F^+ has the eigenvalue 0 for ∣M∣<1|M| < 1, and the test checks that the other two eigenvalues are not negative by the signs of the characteristic polynomial. Van Leer chose this so that a steady shock has at most two cells inside it.
  • Kinks (Steger-Warming). The Steger-Warming parts have a kink where an eigenvalue is zero, at u=0u = 0 and u=±cu = \pm c. This can give small glitches at sonic points.
  • Smears contacts and shear. A contact at rest is not a steady state of the scheme (Proposition 5 in the proof). This is the main weakness, and it is worse for viscous flows, where a boundary layer is a shear layer.
  • One cell at a time. Each split depends on one state only, which makes the scheme easy to vectorize and easy to make implicit, since ∂F±/∂U\partial F^\pm/\partial U is available in closed form.

Variants and improvements

  • AUSM. The AUSM scheme splits the flux into a convective part and a pressure part, and upwinds the convective part with one interface Mach number. It keeps contacts much sharper.
  • Hänel's variant. Taking the energy part of van Leer's flux with the total enthalpy, FE±=m±HF_E^\pm = m^\pm H, keeps HH constant across a steady flow. It is a common change for steady aerodynamics (Toro 2009, Chapter 8).
  • High order. Use the split fluxes on reconstructed values from MUSCL, or split the flux at each point and reconstruct F+F^+ and F−F^- separately, as in finite difference WENO codes. The local Lax-Friedrichs splitting F±=12(F±sU)F^\pm = \frac12(F \pm sU) is the usual choice there.
  • Riemann solvers. The Roe, HLL and HLLC fluxes use both states together. They cost more per face but keep contacts sharper.

When to use it

Use flux vector splitting when the flux must be cheap and robust, when the scheme is implicit and needs simple flux Jacobians, or as the flux inside a finite difference WENO code. Do not use it at first order for flows where contacts, shear layers or boundary layers must stay sharp. For those, use AUSM, HLLC or Roe.

Pitfalls

  • Expecting a sharp contact. Proposition 5 in the proof shows that even a contact at rest moves mass across the face. The smearing is a property of the method.
  • Steger-Warming glitches. At a sonic point the Steger-Warming parts are not differentiable, and a small kink can appear in a transonic rarefaction. Van Leer's splitting avoids this.
  • Splitting a non-homogeneous flux. The identity F=AUF = AU holds for the ideal gas law. For a general equation of state it can fail, and ∑kλk±wkrk\sum_k \lambda_k^\pm w_k r_k then does not add up to FF. Check F++F−=FF^+ + F^- = F before using a splitting.
  • The time step. The Courant condition must use max⁡(∣u∣+c)\max(|u| + c) over all cells. A split with λmax⁡(f+′−f−′)>1\lambda\max(f^{+\prime} - f^{-\prime}) > 1 loses the TVD bound.
  • Mixing up the sides. The face flux is F+(UL)+F−(UR)F^+(U_L) + F^-(U_R). Taking F+(UR)F^+(U_R) gives a downwind scheme that blows up.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

flux_vector_splitting.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/flux-vector-splitting/. The authors are listed in prov/6X7CE5.jsonl.

"""Flux vector splitting for the 1D Euler equations: Steger-Warming (1981) and van Leer (1982).

The flux is written as F(U) = F+(U) + F-(U), where F+ has only nonnegative and F- only
nonpositive wave speeds. The face flux is F+(U_L) + F-(U_R): each part is taken from the
side it comes from.
"""

from math import sqrt

GAMMA = 1.4


def prim_to_cons(w, g=GAMMA):
    rho, u, p = w
    return (rho, rho * u, p / (g - 1.0) + 0.5 * rho * u * u)


def cons_to_prim(q, g=GAMMA):
    rho, m, e = q
    u = m / rho
    return (rho, u, (g - 1.0) * (e - 0.5 * m * u))


def euler_flux(q, g=GAMMA):
    rho, m, e = q
    u = m / rho
    p = (g - 1.0) * (e - 0.5 * m * u)
    return (m, m * u + p, u * (e + p))


def steger_warming(q, g=GAMMA):
    """Return (F+, F-) of Steger and Warming: the eigenvalues split by sign."""
    rho, u, p = cons_to_prim(q, g)
    c = sqrt(g * p / rho)
    h = (q[2] + p) / rho
    lam = (u - c, u, u + c)  # @line L1
    vecs = ((1.0, u - c, h - u * c), (1.0, u, 0.5 * u * u), (1.0, u + c, h + u * c))
    weights = (rho / (2.0 * g), rho * (g - 1.0) / g, rho / (2.0 * g))  # U = sum of weights[k] vecs[k]
    parts = []
    for sign in (1.0, -1.0):
        lp = [0.5 * (x + sign * abs(x)) for x in lam]
        parts.append(tuple(sum(lp[k] * weights[k] * vecs[k][i] for k in range(3)) for i in range(3)))  # @line L2
    return parts[0], parts[1]


def van_leer(q, g=GAMMA):
    """Return (F+, F-) of van Leer: polynomials in the Mach number, smooth at M = -1 and M = 1."""
    rho, u, p = cons_to_prim(q, g)
    c = sqrt(g * p / rho)
    mach = u / c
    if mach >= 1.0:  # @line L3
        return euler_flux(q, g), (0.0, 0.0, 0.0)
    if mach <= -1.0:
        return (0.0, 0.0, 0.0), euler_flux(q, g)
    parts = []
    for sign in (1.0, -1.0):
        mass = sign * 0.25 * rho * c * (mach + sign) ** 2  # @line L4
        a = (g - 1.0) * u + sign * 2.0 * c
        parts.append((mass, mass * a / g, mass * a * a / (2.0 * (g * g - 1.0))))  # @line L5
    return parts[0], parts[1]


def fvs_flux(ql, qr, split=van_leer, g=GAMMA):
    """The face flux F+(U_L) + F-(U_R)."""
    fp, _ = split(ql, g)
    _, fm = split(qr, g)
    return tuple(a + b for a, b in zip(fp, fm))  # @line L6


def fvs_scalar(ul, ur, fplus, fminus):
    """The same idea for a scalar law f = f+ + f- with f+ nondecreasing and f- nonincreasing."""
    return fplus(ul) + fminus(ur)


def step(cells, dt, dx, flux, periodic=False):
    """One forward Euler step of the conservative scheme with one ghost cell on each side."""
    ext = ([cells[-1]] + list(cells) + [cells[0]]) if periodic else ([cells[0]] + list(cells) + [cells[-1]])  # @line L7
    faces = [flux(ext[j], ext[j + 1]) for j in range(len(ext) - 1)]  # @line L8
    lam = dt / dx
    if isinstance(cells[0], tuple):
        return [tuple(q - lam * (b - a) for q, a, b in zip(cells[j], faces[j], faces[j + 1])) for j in range(len(cells))]  # @line L9
    return [cells[j] - lam * (faces[j + 1] - faces[j]) for j in range(len(cells))]


def solve_euler(cells, dx, t_end, cfl=0.9, g=GAMMA, periodic=False, split=van_leer):
    """March to t_end with dt = cfl dx / max(|u| + c). Returns (cells, number of steps)."""
    t, n = 0.0, 0
    flux = lambda a, b: fvs_flux(a, b, split, g)
    while t < t_end - 1e-14:
        smax = 0.0
        for q in cells:
            rho, u, p = cons_to_prim(q, g)
            smax = max(smax, abs(u) + sqrt(g * p / rho))
        dt = min(cfl * dx / smax, t_end - t)
        cells = step(cells, dt, dx, flux, periodic)
        t += dt
        n += 1
    return cells, n
test_flux_vector_splitting.py 206 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/flux-vector-splitting/. The authors are listed in prov/6X7CE5.jsonl.

import random
from math import cos, log2, pi, sqrt

from flux_vector_splitting import (
    cons_to_prim,
    euler_flux,
    fvs_flux,
    fvs_scalar,
    prim_to_cons,
    solve_euler,
    step,
    steger_warming,
    van_leer,
)

SOD = ((1.0, 0.0, 1.0), (0.125, 0.0, 0.1))
G = 1.4


def exact_solution(left, right, g=1.4):
    """Reference: the exact Riemann solution. Returns a function of xi = x / t giving (rho, u, p)."""
    (rl, ul, pl), (rr, ur, pr) = left, right
    cl, cr = sqrt(g * pl / rl), sqrt(g * pr / rr)
    z = (g - 1.0) / (2.0 * g)

    def fk(p, rk, pk, ck):
        if p > pk:
            return (p - pk) * sqrt(2.0 / ((g + 1.0) * rk) / (p + (g - 1.0) / (g + 1.0) * pk))
        return 2.0 * ck / (g - 1.0) * ((p / pk) ** z - 1.0)

    lo, hi = 1e-12, 1e4
    for _ in range(200):
        mid = 0.5 * (lo + hi)
        if fk(mid, rl, pl, cl) + fk(mid, rr, pr, cr) + ur - ul > 0.0:
            hi = mid
        else:
            lo = mid
    ps = 0.5 * (lo + hi)
    us = 0.5 * (ul + ur) + 0.5 * (fk(ps, rr, pr, cr) - fk(ps, rl, pl, cl))

    def sample(xi):
        rk, uk, pk, ck, sg = (rl, ul, pl, cl, 1.0) if xi <= us else (rr, ur, pr, cr, -1.0)
        xs, uss, uks = sg * xi, sg * us, sg * uk
        if ps > pk:
            if xs <= uks - ck * sqrt((g + 1.0) / (2.0 * g) * ps / pk + z):
                return (rk, uk, pk)
            r, gg = ps / pk, (g - 1.0) / (g + 1.0)
            return (rk * (r + gg) / (gg * r + 1.0), us, ps)
        if xs <= uks - ck:
            return (rk, uk, pk)
        if xs >= uss - ck * (ps / pk) ** z:
            return (rk * (ps / pk) ** (1.0 / g), us, ps)
        w = 2.0 / (g + 1.0) + (g - 1.0) / ((g + 1.0) * ck) * (uks - xs)
        return (rk * w ** (2.0 / (g - 1.0)), sg * 2.0 / (g + 1.0) * (ck + 0.5 * (g - 1.0) * uks + xs), pk * w ** (2.0 * g / (g - 1.0)))

    return sample


def sod_l1(m, split, t=0.2):
    """L1 error of the density against exact cell averages (16-point midpoint rule per cell)."""
    sample = exact_solution(*SOD)
    cells = [prim_to_cons(SOD[0] if (j + 0.5) / m < 0.5 else SOD[1]) for j in range(m)]
    cells, _ = solve_euler(cells, 1.0 / m, t, split=split)
    err = 0.0
    for j, q in enumerate(cells):
        ex = sum(sample(((j + (k + 0.5) / 16) / m - 0.5) / t)[0] for k in range(16)) / 16
        err += abs(q[0] - ex) / m
    return err


def density_wave(m, t):
    """Exact cell averages of rho = 1 + 0.2 sin(2 pi (x - t)), with u = 1 and p = 1."""
    dx = 1.0 / m
    return [1.0 + 0.2 * (cos(2 * pi * (j * dx - t)) - cos(2 * pi * ((j + 1) * dx - t))) / (2 * pi * dx) for j in range(m)]


def random_state(rng, umax=2.0):
    return prim_to_cons((rng.uniform(0.1, 2), rng.uniform(-umax, umax), rng.uniform(0.1, 2)))


def close(a, b, tol=1e-12):
    return all(abs(x - y) <= tol * (1.0 + abs(y)) for x, y in zip(a, b))


def jacobian(f, q, h=1e-6):
    cols = []
    for k in range(3):
        a, b = list(q), list(q)
        a[k] += h
        b[k] -= h
        cols.append([(x - y) / (2 * h) for x, y in zip(f(tuple(a)), f(tuple(b)))])
    return [[cols[j][i] for j in range(3)] for i in range(3)]


def char_poly(a):
    """Trace, sum of principal 2 by 2 minors, determinant: lambda^3 - t lambda^2 + s lambda - d."""
    t = a[0][0] + a[1][1] + a[2][2]
    s = sum(a[i][i] * a[j][j] - a[i][j] * a[j][i] for i in range(3) for j in range(i + 1, 3))
    d = a[0][0] * (a[1][1] * a[2][2] - a[1][2] * a[2][1]) - a[0][1] * (a[1][0] * a[2][2] - a[1][2] * a[2][0]) + a[0][2] * (a[1][0] * a[2][1] - a[1][1] * a[2][0])
    return t, s, d


def test_sod_interface_by_hand() -> None:
    ql, qr = prim_to_cons(SOD[0]), prim_to_cons(SOD[1])
    cl, cr = sqrt(G), sqrt(G * 0.1 / 0.125)
    # at u = 0: Steger-Warming gives rho c / (2 gamma) and rho c^3 / (2 gamma (gamma - 1)); van Leer rho c / 4 and rho c^3 / (2 (gamma^2 - 1))
    sw = ((cl - 0.125 * cr) / (2 * G), 0.55, (cl**3 - 0.125 * cr**3) / (2 * G * (G - 1)))
    vl = ((cl - 0.125 * cr) / 4, 0.55, (cl**3 - 0.125 * cr**3) / (2 * (G * G - 1)))
    assert close(fvs_flux(ql, qr, steger_warming), sw) and close(fvs_flux(ql, qr, van_leer), vl)
    assert abs(sw[0] - 0.375332) < 1e-6 and abs(vl[0] - 0.262732) < 1e-6 and abs(vl[2] - 0.785594) < 1e-6


def test_the_parts_add_up_to_the_flux() -> None:
    rng = random.Random(7)
    for _ in range(200):
        q = random_state(rng, 4.0)
        for split in (steger_warming, van_leer):
            fp, fm = split(q)
            assert close(tuple(a + b for a, b in zip(fp, fm)), euler_flux(q))
            assert close(fvs_flux(q, q, split), euler_flux(q))


def test_steger_warming_is_homogeneous() -> None:
    rng = random.Random(8)
    for _ in range(50):
        q, s = random_state(rng), rng.uniform(0.2, 5.0)
        sq = tuple(s * x for x in q)
        assert close(euler_flux(sq), tuple(s * x for x in euler_flux(q)))
        assert close(steger_warming(sq)[0], tuple(s * x for x in steger_warming(q)[0]))


def test_supersonic_flow_is_pure_upwind() -> None:
    rng = random.Random(9)
    for _ in range(50):
        rho, p = rng.uniform(0.1, 2), rng.uniform(0.1, 2)
        u = sqrt(G * p / rho) * rng.uniform(1.0, 3.0)
        q = prim_to_cons((rho, u, p))
        for split in (steger_warming, van_leer):
            fp, fm = split(q)
            assert close(fp, euler_flux(q)) and all(abs(x) < 1e-12 for x in fm)
            qm = prim_to_cons((rho, -u, p))
            assert close(split(qm)[1], euler_flux(qm)) and all(abs(x) < 1e-12 for x in split(qm)[0])


def test_van_leer_parts_are_smooth_at_the_sonic_point() -> None:
    for eps in (1e-2, 1e-3, 1e-4):
        q = prim_to_cons((1.0, (1.0 - eps) * sqrt(G), 1.0))
        assert max(abs(x) for x in van_leer(q)[1]) < 3.0 * eps * eps  # F- vanishes to second order at M = 1


def test_van_leer_jacobian_has_one_zero_eigenvalue() -> None:
    rng = random.Random(10)
    for _ in range(30):
        rho, p = rng.uniform(0.3, 2), rng.uniform(0.3, 2)
        q = prim_to_cons((rho, rng.uniform(-0.95, 0.95) * sqrt(G * p / rho), p))
        tp, sp, dp = char_poly(jacobian(lambda z: van_leer(z)[0], q))
        tm, sm, dm = char_poly(jacobian(lambda z: van_leer(z)[1], q))
        assert abs(dp) < 1e-6 and abs(dm) < 1e-6  # one eigenvalue is 0
        assert tp > 0 and sp > -1e-8 and tm < 0 and sm > -1e-8  # the other two: >= 0 for F+, <= 0 for F-


def test_a_contact_at_rest_is_smeared() -> None:
    a, b = prim_to_cons((1.0, 0.0, 1.0)), prim_to_cons((0.125, 0.0, 1.0))
    assert abs(fvs_flux(a, b)[0] - (sqrt(G) - 0.125 * sqrt(G / 0.125)) / 4) < 1e-12  # mass crosses the face
    cells, _ = solve_euler([a if j < 50 else b for j in range(100)], 0.01, 0.1)
    assert max(abs(cons_to_prim(q)[1]) for q in cells) > 0.02  # a velocity appears where there should be none
    assert sum(1 for q in cells if 0.2 < q[0] < 0.9) >= 5


def test_burgers_splitting_is_tvd() -> None:
    fp, fm = (lambda v: max(v, 0.0) ** 2 / 2), (lambda v: min(v, 0.0) ** 2 / 2)
    rng = random.Random(11)
    u = [rng.uniform(-1, 1) for _ in range(80)]
    tv = lambda w: sum(abs(w[j + 1] - w[j]) for j in range(len(w) - 1))
    for _ in range(40):
        before = tv(u)
        dx = 1.0 / 80
        u = step(u, 0.9 * dx / max(abs(v) for v in u), dx, lambda a, b: fvs_scalar(a, b, fp, fm))  # lam (f+' - f-') <= 0.9
        assert tv(u) <= before + 1e-12


def test_sod_converges() -> None:
    e100, e200 = sod_l1(100, van_leer), sod_l1(200, van_leer)
    s200 = sod_l1(200, steger_warming)
    assert e100 < 0.016 and e200 < 0.011 and s200 < 0.014 and e200 < s200


def test_first_order_on_a_smooth_wave() -> None:
    errs = []
    for m in (25, 50, 100):
        cells = [prim_to_cons((r, 1.0, 1.0)) for r in density_wave(m, 0.0)]
        out, _ = solve_euler(cells, 1.0 / m, 0.1, periodic=True)
        errs.append(sum(abs(q[0] - e) for q, e in zip(out, density_wave(m, 0.1))) / m)
    orders = [log2(errs[i] / errs[i + 1]) for i in range(2)]
    assert all(0.9 < o < 1.1 for o in orders)


def test_conservation_on_a_periodic_grid() -> None:
    rng = random.Random(12)
    cells = [random_state(rng, 0.5) for _ in range(40)]
    out, _ = solve_euler(cells, 1.0 / 40, 0.05, periodic=True, split=steger_warming)
    for i in range(3):
        assert abs(sum(q[i] for q in out) - sum(q[i] for q in cells)) < 1e-11

History

Sanders and Prendergast had used a kinetic splitting for astrophysical flows in 1974. Steger and Warming (1981) gave the splitting of the Euler flux by the signs of the eigenvalues, based on the homogeneity of the flux, and used it in implicit finite difference schemes. Van Leer (1982) pointed out the kinks of that splitting at sonic points and gave a splitting by polynomials in the Mach number that is continuously differentiable. Liou and Steffen (1993) later split the convective and pressure parts apart, which led to the AUSM family.

References

  1. Joseph L. Steger and R. F. Warming, Flux vector splitting of the inviscid gasdynamic equations with application to finite-difference methods, Journal of Computational Physics 40(2) (1981) 263-293, the splitting by the signs of the eigenvalues and the homogeneity property F = A U; doi:10.1016/0021-9991(81)90210-2
  2. Bram van Leer, Flux-vector splitting for the Euler equations, in Eighth International Conference on Numerical Methods in Fluid Dynamics, Lecture Notes in Physics 170, Springer, 1982, 507-512, the splitting by polynomials in the Mach number, smooth at the sonic points; doi:10.1007/3-540-11948-5_66
  3. Eleuterio F. Toro, Riemann Solvers and Numerical Methods for Fluid Dynamics, third edition, Springer, 2009, Chapter 8 (the flux vector splitting approach, with the Steger-Warming and van Leer splittings)
  4. Ami Harten, High resolution schemes for hyperbolic conservation laws, Journal of Computational Physics 49 (1983) 357-393, the incremental form and the lemma on TVD coefficients; doi:10.1016/0021-9991(83)90136-5
  5. Michael G. Crandall and Andrew Majda, Monotone difference approximations for scalar conservation laws, Mathematics of Computation 34 (1980) 1-21, convergence of monotone schemes to the entropy solution

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example