Techniqueresearch
Entropy stable schemes
Also called entropy conservative flux.
Schemes whose flux is an entropy conservative flux in Tadmor's sense plus dissipation in the entropy variables, so the discrete solution obeys an entropy inequality for every mesh.
An entropy stable scheme is a conservative scheme for a hyperbolic system that satisfies a discrete form of the entropy inequality on every mesh, not only in the limit. The construction, due to Tadmor (1987), has two parts. The first is an entropy conservative two-point flux , defined by the condition , where are the entropy variables and is the entropy potential. With the semi-discrete scheme conserves the total entropy exactly. The second part adds dissipation in the entropy variables, with symmetric positive semidefinite, which makes the total entropy decrease at a known rate. The same idea, with summation-by-parts operators, gives entropy stable DG and spectral element methods of high order.
In plain words
Physical flows with shocks lose a quantity called entropy (in the mathematical sign convention used here) and never gain it. Many good schemes can still gain it in rare cases and then compute a wrong solution or blow up. An entropy stable scheme is built so that this cannot happen. First it uses a special flux between two cells, chosen so that the scheme moves entropy around without creating or destroying any. That flux alone is too clean: at a shock it produces large wiggles, because the entropy has nowhere to go. So a second, small term is added that can only remove entropy, and that is largest where neighbouring cells differ the most. The result is a scheme whose entropy is guaranteed to go down, with a rate you can compute.
When it applies
- The system has a convex entropy with entropy flux , . Most systems from physics have one: the Euler equations ( with the specific entropy), the shallow water equations (the total energy), MHD and the scalar laws ( for Burgers).
- The scheme is in conservation form, so it can be written with face fluxes.
- You want robustness that does not depend on tuning: under-resolved turbulence, long runs, strong shocks, high order schemes that are unstable because of aliasing.
Entropy stability is a semi-discrete property. A fully discrete scheme keeps it only with an entropy stable time integrator; with explicit Runge-Kutta methods the error in the entropy is and is usually much smaller than the dissipation.
The template
On a periodic grid with cells of width and averages , write and .
ENTROPY-STABLE-SCHEME(u, Δx)- 1
choose a convex entropy pair (U, q); set v ← U'(u) and ψ ← v·f(u) - q(u) - 2
pick an entropy conservative flux F* with (v_R - v_L)·F* = ψ_R - ψ_L - 3
F_(j+1/2) ← F*(u_j, u_(j+1)) - ½ D_(j+1/2) (v_(j+1) - v_j), D symmetric, D ≥ 0 - 4
du_j/dt ← -(F_(j+1/2) - F_(j-1/2)) / Δx; advance in time with an SSP Runge-Kutta method
The key identity is discrete summation by parts. On a periodic grid,
With each term is , and the sum telescopes to . With the dissipation of L3 the sum is (theorem). On a nonperiodic grid the boundary terms remain, and boundary conditions must be chosen so they have the right sign.
Tadmor's path integral gives one entropy conservative flux for any system: . It is exact but needs quadrature, so practical schemes use closed forms such as the Ismail-Roe flux for the Euler equations, built from logarithmic means of the density and of . A common choice for is the largest wave speed times the matrix , a Rusanov-type dissipation, or a Roe-type matrix with scaled eigenvectors.
Classic examples
- Godunov's method: its flux is an E-flux, so it is entropy stable, and it can be written as the entropy conservative flux plus a nonnegative dissipation (exercise 2).
- Burgers' equation: the simplest case, worked out below, with and a quadratic entropy conservative flux.
- Shallow water equations: the total energy is the entropy, and the entropy conservative flux uses arithmetic means only (exercise 1).
- Euler equations: the Ismail-Roe flux with logarithmic means, plus matrix dissipation.
- Discontinuous Galerkin method: flux differencing with a two-point entropy conservative flux on Gauss-Lobatto nodes gives entropy stable DG of any order.
Burgers' equation by hand. For take , so , and . The condition gives
which is also Tadmor's path integral . For , : , and indeed . With the entropy stable flux is , and this face removes entropy at the rate . The arithmetic mean is not entropy conservative: it does not satisfy the condition.
A shock forms (measurement). Burgers with on , 100 cells, SSP-RK3 with . A shock forms at . Total entropy , initially , and the largest :
| | EC: entropy | EC: | ES: entropy | ES: | |---|---|---|---|---| | 0.1 | 0.250000 | 0.9999 | 0.245215 | 0.9813 | | 0.3 | 0.249998 | 1.8220 | 0.170048 | 0.9197 | | 0.5 | 0.249997 | 1.5339 | 0.092046 | 0.7053 |
The entropy conservative scheme keeps the total entropy to about , the error of the time integrator, so after the shock it has no way to lose the entropy the exact solution loses, and it puts that energy into oscillations with values far outside the initial range. The entropy stable scheme decays as the exact solution does and keeps . Before the shock, at with on 64 cells, the entropy error of the EC scheme with SSP-RK3 is , and for : a factor 8 per halving, third order in .
Euler equations. Ismail and Roe (2009) give an entropy conservative flux for the Euler equations in closed form, with the entropy . Adding a matrix dissipation built from the eigenvectors of the Jacobian, scaled so that acts on the entropy variables, gives an entropy stable flux that behaves like the Roe flux but has no entropy violating expansion shocks.
Variations
- TeCNO schemes (Fjordholm, Mishra and Tadmor 2012). High-order entropy conservative fluxes made from linear combinations of two-point fluxes, plus dissipation applied to ENO reconstructions of the scaled entropy variables. The sign property of ENO makes the dissipation entropy stable at any order.
- Entropy stable DG and spectral element methods. Flux differencing with a two-point entropy conservative flux inside each element, written with summation-by-parts operators on Gauss-Lobatto nodes, gives a discrete entropy inequality for any polynomial degree.
- Kinetic energy preserving fluxes, which also keep the discrete kinetic energy balance for the Euler equations and are popular in turbulence simulation.
- Entropy stable time integration. Relaxation Runge-Kutta methods change the step length slightly so that the fully discrete entropy satisfies the inequality too.
- Entropy fixes such as the Harten-Hyman fix for the Roe flux are a weaker, local remedy: they remove expansion shocks but do not give a global inequality.
Pitfalls
- Entropy conservative alone at shocks. Without dissipation the scheme oscillates at every shock, as in the table. The EC flux is the base, not the scheme.
- Dissipation in the wrong variables. The dissipation must act on the jump of with a positive semidefinite matrix. Adding in conserved variables is entropy stable for Burgers, where , but not in general for systems.
- Path integral by quadrature. A crude quadrature of Tadmor's integral breaks the identity . Use a closed form, or enough points for the integrand.
- Logarithmic means near equal states. The Ismail-Roe flux uses , which loses accuracy when . Use the series expansion there.
- Entropy stability is not positivity. An entropy stable Euler scheme can still produce negative density or pressure near vacuum, where the entropy variables are not defined. Combine it with a positivity-preserving limiter.
- Expecting accuracy. Entropy stability is a stability property. It does not make a first-order scheme accurate, and it does not prevent small oscillations of higher order schemes.
Code
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.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/entropy-stable-scheme/. The authors are listed in prov/0A1T0M.jsonl.
"""Entropy conservative and entropy stable finite volume fluxes for Burgers' equation.
Equation u_t + (u^2 / 2)_x = 0 on a periodic grid of M cells. Entropy pair U(u) = u^2 / 2,
q(u) = u^3 / 3, entropy variable v = U'(u) = u, potential psi = v f(u) - q(u) = u^3 / 6.
Tadmor's entropy conservative flux satisfies (v_R - v_L) F* = psi_R - psi_L; adding the
dissipation -(1/2) D (v_R - v_L) with D >= 0 gives an entropy stable flux. Values may be
floats or fractions.Fraction (exact arithmetic for the entropy identities).
Precondition: M >= 2 cells, dx > 0. Cost: Theta(M) per evaluation of the right side.
"""
from typing import Callable, List
def entropy(u):
"""U(u) = u^2 / 2, v(u) = u and psi(u) = u^3 / 6 for Burgers."""
return u * u / 2, u, u ** 3 / 6 # @line L1
def ec_flux(ul, ur):
"""Tadmor's entropy conservative flux (ul^2 + ul ur + ur^2) / 6."""
return (ul * ul + ul * ur + ur * ur) / 6 # @line L2
def es_flux(ul, ur):
"""Entropy conservative flux plus Rusanov-type dissipation in the entropy variable."""
d = max(abs(ul), abs(ur))
return ec_flux(ul, ur) - d * (ur - ul) / 2 # @line L3
def central_flux(ul, ur):
"""Arithmetic mean of f, for comparison (neither entropy conservative nor stable)."""
return (ul * ul + ur * ur) / 4
def residual(u: List, dx, flux: Callable) -> List:
"""R_j = -(F_{j+1/2} - F_{j-1/2}) / dx on a periodic grid."""
M = len(u)
F = [flux(u[j], u[(j + 1) % M]) for j in range(M)]
return [-(F[j] - F[j - 1]) / dx for j in range(M)] # @line L4
def entropy_rate(u: List, dx, flux: Callable):
"""d/dt of the total entropy sum_j U(u_j) dx for the semi-discrete scheme."""
return sum(v * r for v, r in zip(u, residual(u, dx, flux))) * dx
def total_entropy(u: List, dx):
return sum(x * x / 2 for x in u) * dx
def solve(u: List[float], dx: float, dt: float, T: float, flux: Callable) -> List[float]:
"""SSP-RK3 in time from 0 to T; the last step is shortened."""
if not dx > 0 or not dt > 0:
raise ValueError("dx and dt must be positive")
t = 0.0
while t < T - 1e-14:
h = min(dt, T - t)
a = [x + h * r for x, r in zip(u, residual(u, dx, flux))]
b = [0.75 * x + 0.25 * (y + h * r) for x, y, r in zip(u, a, residual(a, dx, flux))]
u = [x / 3 + 2 / 3 * (y + h * r) for x, y, r in zip(u, b, residual(b, dx, flux))]
t += h
return u
test_entropy_stable_scheme.py 101 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/entropy-stable-scheme/. The authors are listed in prov/0A1T0M.jsonl.
import math
import random
from fractions import Fraction as Fr
import pytest
from entropy_stable_scheme import (
central_flux, ec_flux, entropy, entropy_rate, es_flux, residual, solve, total_entropy,
)
def rand_fr(rng):
return Fr(rng.randint(-40, 40), rng.randint(1, 12))
def test_tadmor_condition_holds_exactly():
rng = random.Random(1)
for _ in range(200):
ul, ur = rand_fr(rng), rand_fr(rng)
_, vl, pl = entropy(ul)
_, vr, pr = entropy(ur)
assert (vr - vl) * ec_flux(ul, ur) == pr - pl
def test_ec_flux_is_tadmors_path_integral():
# F* = integral over theta in [0, 1] of f(u(v_L + theta (v_R - v_L))); Simpson is exact here.
rng = random.Random(2)
f = lambda u: u * u / 2
for _ in range(50):
ul, ur = rand_fr(rng), rand_fr(rng)
mid = (ul + ur) / 2
simpson = (f(ul) + 4 * f(mid) + f(ur)) / 6
assert ec_flux(ul, ur) == simpson
def test_fluxes_are_consistent():
for u in (Fr(-3, 2), Fr(0), Fr(7, 5)):
assert ec_flux(u, u) == u * u / 2
assert es_flux(u, u) == u * u / 2
def test_hand_example():
assert ec_flux(Fr(1), Fr(0)) == Fr(1, 6)
assert es_flux(Fr(1), Fr(0)) == Fr(2, 3)
def test_semi_discrete_entropy_rate_is_exactly_zero_for_the_ec_flux():
rng = random.Random(3)
for M in (2, 5, 17):
u = [rand_fr(rng) for _ in range(M)]
assert entropy_rate(u, Fr(1, M), ec_flux) == 0
assert sum(residual(u, Fr(1, M), ec_flux)) == 0 # conservation
def test_semi_discrete_entropy_rate_of_the_es_flux_is_the_dissipation():
rng = random.Random(4)
for M in (3, 8, 20):
u = [rand_fr(rng) for _ in range(M)]
dx = Fr(1, M)
diss = -sum(max(abs(u[j]), abs(u[(j + 1) % M])) * (u[(j + 1) % M] - u[j]) ** 2
for j in range(M)) / 2
rate = entropy_rate(u, dx, es_flux)
assert rate == diss
assert rate <= 0
def test_central_flux_is_not_entropy_conservative():
u = [Fr(1), Fr(0), Fr(-1), Fr(2)]
assert entropy_rate(u, Fr(1, 4), central_flux) != 0
def test_fully_discrete_ec_entropy_drift_is_small_and_shrinks_with_dt():
M = 64
dx = 1.0 / M
u0 = [0.5 + 0.25 * math.sin(2 * math.pi * (j + 0.5) * dx) for j in range(M)]
s0 = total_entropy(u0, dx)
drift = []
for c in (0.4, 0.2):
u = solve(list(u0), dx, c * dx, 0.2, ec_flux)
drift.append(abs(total_entropy(u, dx) - s0))
assert drift[0] < 1e-6 and drift[1] < drift[0] / 4
def test_es_scheme_captures_a_shock_without_new_extrema_but_ec_oscillates():
M = 100
dx = 1.0 / M
u0 = [math.sin(2 * math.pi * (j + 0.5) * dx) for j in range(M)]
es = solve(list(u0), dx, 0.2 * dx, 0.3, es_flux)
ec = solve(list(u0), dx, 0.2 * dx, 0.3, ec_flux)
assert max(abs(x) for x in es) <= 1.0
assert total_entropy(es, dx) < total_entropy(u0, dx) - 0.05
assert max(abs(x) for x in ec) > 1.5
assert abs(total_entropy(ec, dx) - total_entropy(u0, dx)) < 1e-4
def test_rejects_bad_steps():
with pytest.raises(ValueError):
solve([0.0, 1.0], 0.5, 0.0, 1.0, es_flux)
Exercises
- For the shallow water equations with entropy , compute and and check that , with bars for arithmetic means of the two states, is entropy conservative.
- Show that for a scalar law with every flux of the form with is entropy stable, and that Godunov's flux for Burgers is of this form with .
- Prove that the semi-discrete entropy conservative scheme on a periodic grid also conserves , and explain why both conservation laws together force oscillations after a shock forms.
References
- Eitan Tadmor, The numerical viscosity of entropy stable schemes for systems of conservation laws. I, Mathematics of Computation 49(179) (1987) 91-103, entropy conservative fluxes, the comparison of numerical viscosities, entropy stability of three-point schemes
- Eitan Tadmor, Entropy stability theory for difference approximations of nonlinear conservation laws and related time-dependent problems, Acta Numerica 12 (2003) 451-512, the survey of the theory, entropy variables, the path integral form of the entropy conservative flux
- Ulrik S. Fjordholm, Siddhartha Mishra and Eitan Tadmor, Arbitrarily high-order accurate entropy stable essentially nonoscillatory schemes for systems of conservation laws, SIAM Journal on Numerical Analysis 50(2) (2012) 544-573, high-order entropy conservative fluxes, the sign property of ENO reconstruction, the TeCNO schemes
- Farzad Ismail and Philip L. Roe, Affordable, entropy-consistent Euler flux functions II: entropy production at shocks, Journal of Computational Physics 228(15) (2009) 5410-5436, an entropy conservative flux for the Euler equations in closed form, with logarithmic means
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag 0A1T0M Edit this page History Report an error Markdown