Algorithmadvanced
Coarse projective integration
Also called equation-free method.
Runs short bursts of a fine simulator, estimates the time derivative of coarse variables, and takes a large projective step with no coarse equation.
- Time
- Θ(n (k + 1) s) worst
- Space
- Θ(d) extra
- Where
- d = the size of the fine state; k = the number of healing steps per outer step; n = the number of outer steps; s = the cost of one micro step
- Model
- Real RAM
- Properties
- deterministicequation freeexplicitfirst order
- Evidence
- Proof sketchCode in 1 languages
- Origin
- C. William Gear, Ioannis G. Kevrekidis, 2003
Coarse projective integration advances the coarse variables of a fine simulator, such as a molecular dynamics, kinetic Monte Carlo or lattice Boltzmann code, over long times without a closed equation for them. Each outer step builds a fine state from the coarse state, runs the fine simulator for a short burst, estimates the time derivative of the coarse variables from the end of the burst, and extrapolates them over a much longer interval. The fine simulator is used as a black box and only for a fraction of the time interval. The method works when the coarse variables evolve slowly and all other variables relax quickly to values set by them, which is a gap in the spectrum of time scales. It is the time stepper of the equation-free method of Kevrekidis, Gear and coauthors.
In plain words
Suppose a detailed simulation is correct but too slow to run for the whole time of interest, and only a few averages of it matter. The averages change slowly. Coarse projective integration runs the detailed simulation for a short time, looks at how fast the averages change at the end, and jumps ahead along that trend for a long time. Then it builds a new detailed state that matches the averages and repeats. The first part of each burst is wasted on purpose: the new state is not quite right, and the quick details need time to settle before the trend can be read.
The problem
Given a fine simulator that advances a fine state by a micro step , a restriction that maps a fine state to coarse variables , a lifting that maps coarse variables to a fine state with , a start value and a final time, approximate the coarse variables of the fine evolution with far fewer micro steps than the whole interval needs. The method assumes that after a short time the coarse variables evolve by a closed equation , which is not known.
The algorithm
CPI(X, lift, micro step Φ of length δt, restrict, k, M, n)- 1
for outer step = 1 .. n do - 2
u ← lift(X) - 3
run k + 1 micro steps u ← Φ(u), and record X_k and X_{k+1}, the restrictions after steps k and k + 1 - 4
s ← (X_{k+1} - X_k) / δt ▷ estimate of the coarse time derivative - 5
X ← X_{k+1} + M δt s ▷ projective step - 6
return X
The first micro steps of line L3 heal the lift: they let the fine variables that the lift did not set correctly relax to the slow manifold. Line L4 is a finite difference estimate of on the slow manifold, and line L5 is a forward Euler step with it. An outer step advances the time by and costs micro steps, so the saving is the factor . For a stochastic simulator, line L3 runs an ensemble, and the restriction averages over it. The derivative of line L4 is then estimated by a least squares fit over the last few micro steps.
When the fine simulator is an ODE solver for and the lift and the restriction are the identity, the method is projective forward Euler. On with , one outer step multiplies by the amplification polynomial
Example
Take with , where is the rotation by radians, and . Forward Euler is stable only for . The fast Euler factor is , and the slow factor is .
- Stability needs enough healing steps. With , an outer step covers for . The fast factor is , and the slow factor is against the exact . After 10 outer steps, and the exact solution is , which is an error of . With , , and 10 outer steps give .
- First order. With and outer steps , and (, , ), the errors at are , and . Plain forward Euler with 1960 steps has error ; projective Euler with uses 360 micro steps.
- Coarse variables and lifting. Take , , with the coarse variable . The variable relaxes quickly to near , and then decays at the slow rate . With the lift , and , the coarse error at is . With the poor lift and outer steps of , the error is , , and for , , and . Without healing, does not move at all, because the first micro step sees .
Correctness
The proof treats projective forward Euler on a linear system with real negative eigenvalues. One outer step is , so each eigenvector component evolves by itself. A fast component with is not amplified if : the projection can multiply it by at most , and the healing steps damp it by . For a slow component, with , so after outer steps up to time the error is at most times the size of the component, with : the method is first order in the outer step. The stability region in the plane is the union of a region near of size about and a region near , which makes the method suited to a gap in the spectrum and not to a continuous spread of time scales.
For a general fine simulator, the argument holds on the slow manifold. The proof page explains why the lifting error adds a term at every outer step, which the example shows as the remaining error of the poor lift.
Proof: Projective forward Euler is stable for stiff linear systems with enough inner steps and first order accurate in the outer stepfull
We prove the properties of projective forward Euler, the case of the page where the lift and the restriction are the identity and the micro step is forward Euler, for the linear system , in exact arithmetic. Let be the micro step, the number of healing steps, the projection factor, and the length of an outer step. Assume with diagonal, and write for the Euler matrix.
Lemma 1 (one outer step). One outer step maps to , with the polynomial
So the eigenvector components evolve independently: the component on the eigenvalue is multiplied by .
Proof. Line L3 applies to a total of times, so and . Lines L4 and L5 give . Since , .
With , , so the method is plain forward Euler, as the tests check.
Lemma 2 (damping of the fast modes). If and , then .
Proof. .
So a fast mode with is not amplified if . The modes are damped by the inner steps, which forward Euler can take stably, and the projection over cannot amplify them by more than the factor , which the damping steps cancel. For and the condition is ; the example of the page shows stable and unstable.
Lemma 3 (consistency for the slow modes). Let be real with and . Then
Proof. For , , by Taylor's theorem with remainder and . Also for . Since and , these give . With , , and because . Then
whose modulus is at most . Finally .
Theorem. Let all eigenvalues of be real and negative, split into slow ones with and , and fast ones with and . Let be the result of outer steps and . Then
where is the slow eigenvalue of largest modulus and the fast one of smallest modulus. So the error in the slow modes is of first order in , and the fast modes stay bounded and decay.
Proof. In the eigenvector coordinates , Lemma 1 gives , and the exact solution has . For a slow mode let and ; both have modulus at most 1 by Lemma 3, so
For a fast mode, , and by Lemma 2. The bound on each coordinate holds for the maximum norm of relative to that of ; multiply by the condition number of to return to .
For a normal , as in the example of the page, is orthogonal and the condition number is 1.
The coarse case. With a fine simulator and a coarse restriction, the same argument applies when the fine dynamics has a slow manifold that is parametrized by the coarse variables: after the healing steps, the fine state is close to the slow manifold, and the outer step is a projective Euler step for the coarse dynamics on it. The lift adds an error at every outer step that the healing steps reduce only to the size of the deviation of the slow dynamics during the healing, so it adds a term proportional to the number of outer steps. We do not prove a bound for this case.
Complexity
In the real RAM model, each outer step runs micro steps of cost , plus a lift and two restrictions, which cost for a fine state of size when they are simple. So outer steps cost , against for running the fine simulator over the same time. The extra space is for the current fine state. A stochastic simulator multiplies the cost by the ensemble size that the derivative estimate needs.
Properties
- Equation free. The coarse equation is never written down. It is evaluated through the fine simulator.
- Explicit. Each outer step uses only forward runs of the fine simulator, so any existing code can be wrapped without changes.
- First order. Projective forward Euler is first order in the outer step. Higher order outer integrators use several projective derivative estimates.
- Split stability region. The method is stable for modes near and near and unstable between them.
Variants and improvements
- Higher order outer integrators. Projective Runge-Kutta and Adams methods use derivative estimates from several bursts.
- Telescopic projective integration. Nest projective steps inside projective steps to treat several gaps in the spectrum.
- Patch dynamics and the gap-tooth scheme. Run the fine simulator only in small patches of space as well as for short bursts of time, and interpolate the coarse fields between them.
- Coarse fixed points and bifurcations. Use the coarse time stepper of lines L2 and L3 with Newton-Krylov methods or Newton's method for systems to find coarse steady states and their stability, without a coarse equation.
- Constrained runs for lifting. Choose the unset fine variables by running the fine simulator with the coarse variables held fixed, so that the lift starts near the slow manifold.
When to use it
Use coarse projective integration when a trusted fine simulator exists, the quantities of interest are a few coarse variables, and there is a clear separation between their slow evolution and the fast relaxation of everything else, but no closed coarse equation is known. Typical cases are kinetic Monte Carlo or molecular dynamics of a reaction, agent-based models and lattice Boltzmann codes. For an ODE whose equations are known, a stiff implicit solver is usually better. If there is no gap in the time scales, the derivative estimate of line L4 is not a function of the coarse state alone and the method does not apply.
Pitfalls
- Too few healing steps. If is larger than about , the fast modes are amplified at every outer step and the solution blows up, as in the example with .
- A poor lift. The lifting error returns at every outer step. Healing reduces it but does not remove the drift of the slow variables during the healing, so the error grows with the number of outer steps.
- Noise in the derivative. For a stochastic simulator, the noise of is divided by and multiplied by , so the projective step amplifies it by . The ensemble must be large or the derivative must be fitted over many micro steps.
- Wrong coarse variables. If the chosen coarse variables do not close, there is no slow manifold parametrized by them, and the derivative depends on the hidden variables.
- Oscillatory fast modes. Fast modes with large imaginary parts may lie outside the region near even after healing, if the micro step does not damp them.
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/coarse-projective-integration/. The authors are listed in prov/6HJ81K.jsonl.
"""Coarse projective integration (Gear and Kevrekidis 2003).
A fine simulator advances a fine state u by micro steps of length dt. The
coarse variables are X = restrict(u), and lift(X) builds a fine state with
the given coarse variables. One outer step:
lift X to u, run k + 1 micro steps, restrict after steps k and k + 1,
estimate the coarse slope s = (X_{k+1} - X_k) / dt, and set
X = X_{k+1} + M dt s.
An outer step advances the coarse time by (M + k + 1) dt and costs k + 1
micro steps. With lift and restrict the identity and a forward Euler micro
step, the method is projective forward Euler.
"""
def coarse_projective_integration(X0, lift, micro_step, restrict, dt, k, M, n):
"""n outer steps of coarse projective integration from the coarse state X0.
micro_step(u, dt) returns the fine state after one micro step. Returns the
coarse state after n outer steps, at time n (M + k + 1) dt.
"""
X = list(X0)
for _ in range(n): # @line L1
u = lift(X) # @line L2
Xk = None
for j in range(k + 1): # @line L3
if j == k:
Xk = restrict(u) # @line L3
u = micro_step(u, dt) # @line L3
Xk1 = restrict(u) # @line L3
s = [(b - a) / dt for a, b in zip(Xk, Xk1)] # @line L4
X = [b + M * dt * c for b, c in zip(Xk1, s)] # @line L5
return X # @line L6
def euler_step(f):
"""The forward Euler micro step for y' = f(y)."""
def step(y, dt):
return [a + dt * b for a, b in zip(y, f(y))]
return step
def projective_forward_euler(f, y0, h, k, M, n):
"""Projective forward Euler: identity lift and restriction, Euler micro steps."""
return coarse_projective_integration(y0, list, euler_step(f), list, h, k, M, n)
def euler(f, y0, h, steps):
"""Plain forward Euler, the full micro simulation for comparison."""
step = euler_step(f)
y = list(y0)
for _ in range(steps):
y = step(y, h)
return y
def amplification(zeta, k, M):
"""The factor of one outer step on a mode with Euler factor zeta = 1 + h lambda."""
return ((M + 1) * zeta - M) * zeta ** k
test_coarse_projective_integration.py 102 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/coarse-projective-integration/. The authors are listed in prov/6HJ81K.jsonl.
import math
import random
from coarse_projective_integration import (
amplification,
coarse_projective_integration,
euler,
euler_step,
projective_forward_euler,
)
H = 5e-4
TH = 0.3
C, S = math.cos(TH), math.sin(TH)
LAM = (-1.0, -1000.0)
A = [
[C * C * LAM[0] + S * S * LAM[1], C * S * (LAM[0] - LAM[1])],
[C * S * (LAM[0] - LAM[1]), S * S * LAM[0] + C * C * LAM[1]],
]
def stiff(y):
return [A[0][0] * y[0] + A[0][1] * y[1], A[1][0] * y[0] + A[1][1] * y[1]]
def stiff_exact(y0, t):
p = (C * y0[0] + S * y0[1]) * math.exp(LAM[0] * t)
q = (-S * y0[0] + C * y0[1]) * math.exp(LAM[1] * t)
return [C * p - S * q, S * p + C * q]
def dist(u, v):
return math.hypot(u[0] - v[0], u[1] - v[1])
def test_one_outer_step_multiplies_a_mode_by_the_amplification_factor():
rng = random.Random(3)
for _ in range(20):
lam = -rng.uniform(0.1, 3000)
k, M = rng.randint(0, 10), rng.randint(0, 200)
y = projective_forward_euler(lambda y: [lam * y[0]], [1.0], H, k, M, 1)
assert abs(y[0] - amplification(1 + H * lam, k, M)) < 1e-12 * max(1.0, abs(y[0]))
def test_no_projection_is_plain_forward_euler():
y0 = [1.0, -0.5]
for k in (0, 3):
y = projective_forward_euler(stiff, y0, H, k, 0, 7)
assert dist(y, euler(stiff, y0, H, 7 * (k + 1))) < 1e-14
def test_enough_inner_steps_make_a_long_projective_step_stable():
y0 = [1.0, 1.0]
M, n = 100, 10
T = n * (M + 9) * H
assert abs(amplification(1 + H * LAM[1], 8, M)) < 0.2
y = projective_forward_euler(stiff, y0, H, 8, M, n)
assert dist(y, stiff_exact(y0, T)) < 0.02
assert abs(amplification(1 + H * LAM[1], 4, M)) > 3
y = projective_forward_euler(stiff, y0, H, 4, M, n)
assert math.hypot(*y) > 1e3
def test_the_error_is_first_order_in_the_outer_step():
y0 = [1.0, 1.0]
errors = []
for M, n in ((40, 40), (89, 20), (187, 10)):
# outer steps 49 h, 98 h and 196 h, all ending at T = 0.98
y = projective_forward_euler(stiff, y0, H, 8, M, n)
errors.append(dist(y, stiff_exact(y0, n * (M + 9) * H)))
assert errors[0] < 0.005
for e1, e2 in zip(errors, errors[1:]):
assert 1.8 < e2 / e1 < 2.6
def test_coarse_lifting_errors_heal_during_the_inner_steps():
lam = 1000.0
calls = [0]
def fine(u):
calls[0] += 1
return [-u[1], lam * (u[0] - u[1])]
mu = (-lam + math.sqrt(lam * lam - 4 * lam)) / 2
ref = math.exp(mu * 0.98)
def restrict(u):
return [u[0]]
errors = []
for k in (0, 2, 4, 8):
M = 48 - k
X = coarse_projective_integration([1.0], lambda X: [X[0], 0.0], euler_step(fine), restrict, H, k, M, 40)
errors.append(abs(X[0] - ref))
for e1, e2 in zip(errors, errors[1:]):
assert e2 < e1 / 2
calls[0] = 0
X = coarse_projective_integration([1.0], lambda X: [X[0], X[0]], euler_step(fine), restrict, H, 8, 40, 40)
assert abs(X[0] - ref) < 0.005
assert calls[0] == 40 * 9
History
Gear and Kevrekidis introduced projective integration in 2003 as an explicit method for stiff systems whose eigenvalues have a gap, and analyzed the stability region of projective forward Euler. In the same year Kevrekidis, Gear, Hyman, Kevrekidis, Runborg and Theodoropoulos described the equation-free framework, in which the coarse time stepper built from lifting, a short fine simulation and restriction is used for projective integration, coarse fixed point computation and bifurcation analysis. Later work added telescopic and higher order projective methods, patch dynamics in space and analysis for stochastic simulators.
References
- C. William Gear and Ioannis G. Kevrekidis, Projective methods for stiff differential equations, problems with gaps in their eigenvalue spectrum, SIAM Journal on Scientific Computing 24(4), 2003, 1091-1106, projective forward Euler, its amplification polynomial and the shape of its stability region for stiff systems with a gap in the spectrum
- Ioannis G. Kevrekidis, C. William Gear, James M. Hyman, Panagiotis G. Kevrekidis, Olof Runborg and Constantinos Theodoropoulos, Equation-free, coarse-grained multiscale computation, enabling microscopic simulators to perform system-level analysis, Communications in Mathematical Sciences 1(4), 2003, 715-762, the coarse time stepper built from lifting, short micro simulation and restriction, and its use for coarse projective integration
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 6HJ81K Edit this page History Report an error Markdown