Algorithmcore
Strong stability preserving Runge-Kutta methods
Also called SSP Runge-Kutta methods, TVD Runge-Kutta methods.
Explicit Runge-Kutta methods that are convex combinations of forward Euler steps, so they keep the TVD or positivity property under a scaled CFL limit.
- Time
- O(K s^2 M) worst
- Space
- O(s M) extra
- Counts
- evaluations K s worst
- Where
- K = the number of time steps; M = the number of unknowns of the semidiscrete system; s = the number of stages
- Model
- Real RAM
- Properties
- deterministicexplicit
- Evidence
- Proof sketchCode in 1 languages
- Origin
- C. W. Shu, S. Osher, S. Gottlieb, E. Tadmor, D. I. Ketcheson, 1988
Strong stability preserving (SSP) Runge-Kutta methods are explicit Runge-Kutta methods for the system that a spatial discretization of a conservation law gives by the method of lines. Each stage is a convex combination of forward Euler steps. So if forward Euler keeps a convex property for , such as a TVD bound, a maximum principle or positive density, the SSP method keeps it for , where is the SSP coefficient of the method. The SSP methods reach higher order in time without losing the nonlinear stability that a limiter gives the space discretization. The classical fourth-order method is not SSP: its coefficient is 0.
In plain words
A shock-capturing scheme is often built so that one simple time step, the forward Euler step, never creates new wiggles if the step is small enough. But that simple step is only first order accurate in time. A higher-order Runge-Kutta method mixes several evaluations, and some mixtures do create wiggles even when each simple step would not. SSP methods use only mixtures with positive weights that add up to one. Each stage is then an average of simple steps. An average of results that have no new wiggles has no new wiggles either. The price is a smaller allowed step for some methods, and a limit on the order.
The problem
Given , a convex functional (a norm, the total variation, or the indicator of a convex set), and a step such that for all , find an explicit time stepping method of order that keeps for a step with as large as possible.
The algorithm
A method with stages is given in Shu-Osher form by lower triangular tables and with .
SSP-RK-STEP(u, Δt, L, α, β)- 1
y_0 ← u - 2
for i ← 1 to s do - 3
y_i ← Σ over k < i of (α_ik y_k + Δt β_ik L(y_k)) ▷ each L(y_k) is computed once - 4
return y_s SSP-COEFFICIENT(α, β)- 5
if some α_ik < 0 or β_ik < 0 then return 0 - 6
return the minimum of α_ik/β_ik over all β_ik > 0
The methods on this page, with :
- SSPRK(2,2) (): , . This is Heun's method.
- SSPRK(3,3) (, Shu and Osher 1988): , , .
- SSPRK(10,4) (, Ketcheson 2008): for ; ; for ; .
The effective coefficient compares methods with different numbers of stages at equal cost: it is for SSPRK(2,2), for SSPRK(3,3) and for SSPRK(10,4).
Example
One step by hand. Take upwind advection with on 4 periodic points. Forward Euler is TVD and keeps the values in for . With SSPRK(2,2), and , the first stage is . The forward Euler step from is , and the average with gives
The values stay in , the sum stays 1, and the total variation falls from 2 to .
Observed orders (measurement, with the code on this page). Error at for , , exact :
| method | last ratio | |||
|---|---|---|---|---|
| forward Euler | 1.829e-2 | 8.895e-3 | 4.389e-3 | 2.03 |
| SSPRK(2,2) | 6.712e-4 | 1.621e-4 | 3.979e-5 | 4.07 |
| SSPRK(3,3) | 3.497e-5 | 4.137e-6 | 5.026e-7 | 8.23 |
| SSPRK(10,4) | 3.321e-8 | 2.096e-9 | 1.315e-10 | 15.94 |
A second-order method that is not SSP (measurement). Gottlieb and Shu (1998) give the second-order method , , which has a negative coefficient. Take Burgers' equation on 40 periodic cells with , a MUSCL space discretization with minmod slopes and the Godunov flux, the data on cells 0 to 19 and on cells 20 to 39, and . In 26 steps the total variation of that method rises from 3 to 3.1398, and the maximum rises to 1.0699. SSPRK(2,2) with the same and the same step keeps the total variation at 3 and the values in .
Correctness
The proof is in proofs/correctness.md. Theorem: if all and are nonnegative and , each stage is , a convex combination of forward Euler steps of size at most . Convexity and induction over the stages give for . The proof also checks the coefficients and the orders of SSPRK(2,2) and SSPRK(3,3) from the Butcher conditions, and shows that for every explicit method with stages. The order of SSPRK(10,4) is cited and measured.
Proof: An SSP Runge-Kutta step keeps every convex bound of forward Euler for dt at most C dt_FEfull
Setting. The semidiscrete system is in . Let be a convex functional, for example a norm, the total variation seminorm , or the maximum . Assume that forward Euler is strongly stable for this functional up to a step :
An explicit method in Shu-Osher form with stages computes (line L1), then for (line L2)
and returns (line L4). The code computes each once, before it is first used, and then forms the sums exactly as written. Consistency requires for each , because a constant state with must stay constant.
The SSP coefficient (lines L5 and L6). If some or , then . Otherwise , with when some has .
Theorem 1 (strong stability). Assume , , , and . Then (FE) implies for all .
Proof. We show by induction on ; the case is trivial. Let be the set of with . Since , implies , so the terms with are zero, and
The weights , , are positive and sum to 1, so this is a convex combination of forward Euler steps. Each step has size . By convexity, then (FE), then the induction hypothesis,
The same argument keeps any convex set invariant: if forward Euler maps a convex set (for example the states with positive density and pressure) into itself for , the SSP step does so for .
Theorem 2 (coefficients and orders of the four methods).
| method | order | |
|---|---|---|
| forward Euler | 1 | 1 |
| SSPRK(2,2) | 1 | 2 |
| SSPRK(3,3) | 1 | 3 |
| SSPRK(10,4) | 6 | 4 |
Proof. The values of follow from the tables by lines L5 and L6. In SSPRK(2,2) every ratio is 1. In SSPRK(3,3) the nonzero pairs are , and . In SSPRK(10,4) every nonzero is times its ; the weights and have .
For the order, eliminate the intermediate stages to get the Butcher form. SSPRK(2,2) gives nodes and weights , so and : order 2. For SSPRK(3,3), , and , with . So , , and . The four conditions for order 3 hold:
For SSPRK(10,4) the order is cited from Ketcheson (2008); the tests on this page measure order 4 on a nonlinear ODE.
Theorem 3 (upper bound ). For an explicit method with stages, order at least 1 and , .
Proof. Apply the method to with , and set . Because ,
is a polynomial in with nonnegative coefficients. By induction, each stage is a polynomial in of degree at most with nonnegative coefficients, and its value at is . So the stability function is with and . Order at least 1 gives , and . So .
So the effective coefficient is at most 1. SSPRK(10,4) has , and SSPRK(3,3) has .
Cited barriers, not proved here. No explicit Runge-Kutta method with four stages and order four has (Gottlieb and Shu 1998). No explicit Runge-Kutta method of order five or more has (Ruuth and Spiteri 2002). The classical fourth-order method in Shu-Osher form has and a pair with , so lines L5 and L6 return 0 for it.
What the result does not say. Theorem 1 transfers a property that forward Euler has; it does not create one. The time step bound is sufficient, not necessary: for a particular a larger step can still keep the bound. And a method with can still keep the bound for some problems; the counterexample in the tests shows a second-order method with a negative coefficient that does not.
Complexity
Theorem: one step evaluates once per stage, times, and forms the stage sums in operations in the general form. For the methods above most are zero, and the sums cost . The general form stores all stages, memory. Many SSP methods, SSPRK(10,4) among them, have low-storage forms with two or three registers of size (Ketcheson 2008). In practice the cost of dominates.
Properties
- Convex combination of forward Euler steps, so any convex bound of forward Euler is kept: TVD, maximum principle, positivity, an entropy inequality of a fully discrete form.
- Sufficient, not necessary. is a guarantee. For a given a larger step may still keep the bound.
- Order barriers (theorems, cited). No four-stage fourth-order explicit method has (Gottlieb and Shu 1998), and no explicit method of order five or more has (Ruuth and Spiteri 2002).
- for explicit methods with stages, so the effective coefficient is at most 1.
- Optimal methods. SSPRK(2,2) and SSPRK(3,3) have the largest among methods with as many stages as their order (Gottlieb and Shu 1998).
Variants and improvements
- More stages. SSPRK(s,2) with and SSPRK(s,3) methods with larger effective coefficients, and SSPRK(10,4) for order four.
- Low-storage forms. Only two or three arrays of size , important for large 3D runs.
- Multistep and multistep multistage SSP methods, and implicit SSP methods. Implicit SSP methods also have bounded , so they do not allow arbitrarily large steps.
- Downwind operators. Methods with negative need a second operator that is stable backward in time. They avoid some of the order barriers, at the cost of a second operator.
- With limiters. WENO, MUSCL and the Runge-Kutta discontinuous Galerkin method use SSP time stepping, and a positivity-preserving limiter relies on it.
When to use it
Use an SSP method whenever the space discretization is proved TVD, monotone or positive only for forward Euler: limited finite volume schemes, WENO, DG with a limiter. SSPRK(3,3) is the usual default. SSPRK(10,4) gives order four with a larger stable step per evaluation. For smooth problems without limiters, where no nonlinear bound is needed, a method with a large stability region, such as classical RK4, can be more efficient.
Pitfalls
- A non-SSP method with a TVD space discretization. The bound can fail, as in the example. Classical RK4 and many embedded pairs have .
- The wrong step limit. The guarantee is , where is the forward Euler limit of the space discretization, for example of the CFL limit for MUSCL with minmod. It is not the linear stability limit.
- Boundary conditions inside the stages. Apply the boundary conditions at each stage time, or the order drops near the boundary.
- Time-dependent sources. Evaluate at the stage times , not at .
- The effective coefficient. Compare methods by , not by : SSPRK(10,4) allows a step six times larger but costs ten evaluations.
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.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/strong-stability-preserving-runge-kutta/. The authors are listed in prov/4YEW5E.jsonl.
"""Explicit SSP Runge-Kutta methods in Shu-Osher form for the semidiscrete system u' = L(u).
A method with s stages has lower triangular tables alpha and beta, where row i - 1 holds the
coefficients of stage i on the stages 0, ..., i - 1:
y_0 = u, y_i = sum over k < i of (alpha[i-1][k] y_k + dt beta[i-1][k] L(y_k)), u_new = y_s.
States are lists of numbers. The arithmetic is generic, so Fraction data give exact results.
"""
from fractions import Fraction as Fr
def shu_osher_step(u: list, rhs, dt, alpha: list, beta: list) -> list:
"""One step of the method with tables alpha and beta. Each L(y_k) is computed once."""
ys = [list(u)] # @line L1
ls = []
for i in range(1, len(alpha) + 1): # @line L2
ls.append(rhs(ys[i - 1]))
a, b = alpha[i - 1], beta[i - 1]
y = [0] * len(u)
for k in range(i): # @line L3
if a[k] or b[k]:
y = [yv + a[k] * yk + dt * b[k] * lk for yv, yk, lk in zip(y, ys[k], ls[k])]
ys.append(y)
return ys[-1] # @line L4
def ssp_coefficient(alpha: list, beta: list):
"""The SSP coefficient C of a Shu-Osher form: min of alpha/beta over beta > 0, and 0 if any entry is negative."""
c = None
for a_row, b_row in zip(alpha, beta):
for a, b in zip(a_row, b_row):
if a < 0 or b < 0: # @line L5
return Fr(0)
if b > 0: # @line L6
c = a / b if c is None else min(c, a / b)
return c
def _ssprk104():
s = Fr(1, 6)
alpha = [[Fr(0)] * i for i in range(1, 11)]
beta = [[Fr(0)] * i for i in range(1, 11)]
for i in (1, 2, 3, 4, 6, 7, 8, 9):
alpha[i - 1][i - 1], beta[i - 1][i - 1] = Fr(1), s
alpha[4][0], alpha[4][4], beta[4][4] = Fr(3, 5), Fr(2, 5), Fr(2, 5) * s
alpha[9][0], alpha[9][4], alpha[9][9] = Fr(1, 25), Fr(9, 25), Fr(3, 5)
beta[9][4], beta[9][9] = Fr(9, 25) * s, Fr(3, 5) * s
return alpha, beta
# name: (alpha, beta, order)
METHODS = {
"forward-euler": ([[Fr(1)]], [[Fr(1)]], 1),
"ssprk22": ([[Fr(1)], [Fr(1, 2), Fr(1, 2)]], [[Fr(1)], [Fr(0), Fr(1, 2)]], 2),
"ssprk33": (
[[Fr(1)], [Fr(3, 4), Fr(1, 4)], [Fr(1, 3), Fr(0), Fr(2, 3)]],
[[Fr(1)], [Fr(0), Fr(1, 4)], [Fr(0), Fr(0), Fr(2, 3)]],
3,
),
"ssprk104": _ssprk104() + (4,),
}
def integrate(u0: list, rhs, dt, steps: int, method: str = "ssprk33") -> list:
"""Take the given number of steps of a method from METHODS."""
alpha, beta, _ = METHODS[method]
if not isinstance(dt, Fr):
alpha = [[float(a) for a in row] for row in alpha]
beta = [[float(b) for b in row] for row in beta]
u = list(u0)
for _ in range(steps):
u = shu_osher_step(u, rhs, dt, alpha, beta)
return u
test_strong_stability_preserving_runge_kutta.py 104 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/strong-stability-preserving-runge-kutta/. The authors are listed in prov/4YEW5E.jsonl.
import random
from fractions import Fraction as Fr
from strong_stability_preserving_runge_kutta import METHODS, integrate, shu_osher_step, ssp_coefficient
# Classical RK4 in Shu-Osher form. It has a negative alpha, so its SSP coefficient is 0.
RK4_ALPHA = [[Fr(1)], [Fr(1), Fr(0)], [Fr(1), Fr(0), Fr(0)], [Fr(-1, 3), Fr(1, 3), Fr(2, 3), Fr(1, 3)]]
RK4_BETA = [[Fr(1, 2)], [Fr(0), Fr(1, 2)], [Fr(0), Fr(0), Fr(1)], [Fr(0), Fr(0), Fr(0), Fr(1, 6)]]
def total_variation(u):
return sum(abs(u[j] - u[j - 1]) for j in range(len(u)))
def test_ssp_coefficients() -> None:
expected = {"forward-euler": 1, "ssprk22": 1, "ssprk33": 1, "ssprk104": 6}
for name, (alpha, beta, _) in METHODS.items():
assert ssp_coefficient(alpha, beta) == expected[name]
assert all(sum(row) == 1 for row in alpha) # each stage is consistent
assert ssp_coefficient(RK4_ALPHA, RK4_BETA) == 0
def test_stability_polynomials_exactly() -> None:
# On u' = z u one step multiplies u by R(z); for s = p <= 4 stages R is the Taylor polynomial of e^z.
for name, p in (("forward-euler", 1), ("ssprk22", 2), ("ssprk33", 3)):
alpha, beta, _ = METHODS[name]
for z in (Fr(-3, 2), Fr(-1, 3), Fr(2, 7)):
r = shu_osher_step([Fr(1)], lambda v: [z * v[0]], Fr(1), alpha, beta)[0]
taylor, term = Fr(0), Fr(1)
for k in range(p + 1):
taylor += term
term = term * z / (k + 1)
assert r == taylor
r4 = shu_osher_step([Fr(1)], lambda v: [Fr(-1, 2) * v[0]], Fr(1), RK4_ALPHA, RK4_BETA)[0]
assert r4 == 1 - Fr(1, 2) + Fr(1, 8) - Fr(1, 48) + Fr(1, 384)
def test_observed_orders_on_a_nonlinear_ode() -> None:
# u' = -u^2, u(0) = 1, exact u(1) = 1/2. Halving dt divides the error by about 2^p.
for name, (_, _, p) in METHODS.items():
errs = [abs(integrate([1.0], lambda v: [-v[0] * v[0]], 1.0 / n, n, name)[0] - 0.5) for n in (10, 20, 40)]
for e0, e1 in zip(errs, errs[1:]):
assert 0.85 * 2**p < e0 / e1 < 1.25 * 2**p
def upwind(u):
# u_t + u_x = 0, periodic, dx = 1: forward Euler with this L is TVD for dt <= 1.
return [-(u[j] - u[j - 1]) for j in range(len(u))]
def test_tvd_up_to_the_ssp_time_step() -> None:
rng = random.Random(11)
u0 = [rng.uniform(-1, 1) for _ in range(30)]
for name, dt in (("ssprk22", 1.0), ("ssprk33", 1.0), ("ssprk104", 6.0)):
u = list(u0)
tv = total_variation(u)
for _ in range(40):
u = integrate(u, upwind, dt, 1, name)
assert total_variation(u) <= tv + 1e-12
tv = total_variation(u)
def minmod(a, b):
return 0.0 if a * b <= 0 else (a if abs(a) < abs(b) else b)
def burgers_muscl(u):
"""Burgers' equation, MUSCL with minmod slopes and the Godunov flux, periodic, dx = 1."""
f = lambda v: v * v / 2
def godunov(a, b):
if a <= b:
return 0.0 if a < 0 < b else min(f(a), f(b))
return max(f(a), f(b))
m = len(u)
s = [minmod(u[(j + 1) % m] - u[j], u[j] - u[j - 1]) for j in range(m)]
flux = [godunov(u[j] + s[j] / 2, u[(j + 1) % m] - s[(j + 1) % m] / 2) for j in range(m)]
return [-(flux[j] - flux[j - 1]) for j in range(m)]
def gottlieb_shu_rk2(u, rhs, dt):
"""A second-order RK method with a negative coefficient (Gottlieb and Shu 1998)."""
l0 = rhs(u)
u1 = [a - 20 * dt * b for a, b in zip(u, l0)]
l1 = rhs(u1)
return [a + dt * (41 / 40 * b - 1 / 40 * c) for a, b, c in zip(u, l0, l1)]
def test_non_ssp_rk2_creates_oscillations_and_ssprk22_does_not() -> None:
u0 = [1.0 if j < 20 else -0.5 for j in range(40)]
dt = 0.3
bad, good = list(u0), list(u0)
tv_bad, tv_good = [], []
for _ in range(26):
bad = gottlieb_shu_rk2(bad, burgers_muscl, dt)
good = integrate(good, burgers_muscl, dt, 1, "ssprk22")
tv_bad.append(total_variation(bad))
tv_good.append(total_variation(good))
assert max(tv_good) <= 3 + 1e-12 and max(good) <= 1 + 1e-12
assert max(tv_bad) > 3.1 and max(bad) > 1.03
History
Shu and Osher (1988) wrote explicit Runge-Kutta methods as convex combinations of forward Euler steps and gave the third-order TVD method that is now SSPRK(3,3). Gottlieb and Shu (1998) found the optimal second- and third-order methods and proved that no four-stage fourth-order method has a positive coefficient. Gottlieb, Shu and Tadmor (2001) introduced the name strong stability preserving. Ruuth and Spiteri (2002) proved the order barrier for explicit methods, and Ketcheson (2008) gave efficient low-storage methods such as SSPRK(10,4). The book by Gottlieb, Ketcheson and Shu (2011) collects the theory.
References
- Chi-Wang Shu and Stanley Osher, Efficient implementation of essentially non-oscillatory shock-capturing schemes, Journal of Computational Physics 77(2) (1988) 439-471, the Shu-Osher form and the third-order TVD Runge-Kutta method
- Sigal Gottlieb and Chi-Wang Shu, Total variation diminishing Runge-Kutta schemes, Mathematics of Computation 67(221) (1998) 73-85, optimal second- and third-order methods, no four-stage fourth-order method with a positive SSP coefficient, the example of a non-TVD second-order method
- Sigal Gottlieb, Chi-Wang Shu and Eitan Tadmor, Strong stability-preserving high-order time discretization methods, SIAM Review 43(1) (2001) 89-112, survey, the name strong stability preserving
- Steven J. Ruuth and Raymond J. Spiteri, Two barriers on strong-stability-preserving time discretization methods, Journal of Scientific Computing 17 (2002) 211-220, no explicit SSP Runge-Kutta method of order five with a positive SSP coefficient
- David I. Ketcheson, Highly efficient strong stability-preserving Runge-Kutta methods with low-storage implementations, SIAM Journal on Scientific Computing 30(4) (2008) 2113-2136, the ten-stage fourth-order method SSPRK(10,4) with SSP coefficient 6 and its low-storage form
- Sigal Gottlieb, David Ketcheson and Chi-Wang Shu, Strong Stability Preserving Runge-Kutta and Multistep Time Discretizations, World Scientific, 2011, the SSP coefficient, optimal explicit methods, order barriers
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 4YEW5E Edit this page History Report an error Markdown