Algorithm Search⌘K

Algorithmadvanced

Implicit Monte Carlo

Also called Fleck-Cummings method.

Solves thermal radiation transport coupled to a material energy equation by Monte Carlo, treating part of the absorption and reemission as effective scattering so large time steps stay stable.

Time
O(S N K) average
Space
O(N) extra
Where
K = the mean number of collisions per particle and step; N = the number of particles per time step; S = the number of time steps
Properties
conservativerandomizednot exactiterativerandomized
Origin
Joseph A. Fleck, Jr., J. D. Cummings, 1971

Implicit Monte Carlo (IMC) solves the equations of thermal radiation: the radiative transfer equation for the photon intensity, coupled to an energy equation for the material that absorbs and emits the photons. The coupling is stiff, because the emission grows like T4T^4 and the material can absorb and reemit energy many times in one time step. A Monte Carlo method that takes the emission from the temperature at the start of the step (explicit coupling) oscillates and can give negative temperatures for large steps. Fleck and Cummings linearized the emission in time, which gives a factor f=1/(1+βcσΔt)f = 1/(1 + \beta c \sigma \Delta t), the Fleck factor: in each step only the fraction ff of the absorptions is real, and the rest is replaced by effective scattering, absorption and immediate reemission in the same step. The particles are then followed as in analog Monte Carlo transport with a modified medium. The method is a semi-implicit time discretization in the spirit of the backward Euler method for a stiff problem, not an exact one. It is placed in particle transport, next to neutron Monte Carlo, because the transport part is the same random walk.

In plain words

Hot matter glows, and the light it gives off heats other matter, which glows in turn. Light moves very fast and the glow grows very quickly with temperature, so a simulation with long time steps can go wrong: cold matter takes in so much light in one step that it gets hotter than its source, and then it sends out too much in the next step.

Implicit Monte Carlo fixes this with a guess about the future. It estimates how much of the light that the matter takes in during the step will come out again before the step ends. That part is not stored as heat. Instead, the light simply bounces on, like a scattering. Only the rest heats the matter. The steps then stay calm, even when they are long.

The problem

In the grey case (one frequency group), the radiation intensity I(r,Ω,t)I(r, \Omega, t) and the material temperature T(r,t)T(r, t) obey

1c∂I∂t+Ω⋅∇I+σI=σ acT44π,cv∂T∂t=σ(∫I dΩ−acT4),\frac{1}{c}\frac{\partial I}{\partial t} + \Omega \cdot \nabla I + \sigma I = \frac{\sigma\, a c T^4}{4\pi}, \qquad c_v \frac{\partial T}{\partial t} = \sigma\Big(\int I\, d\Omega - a c T^4\Big),

where cc is the speed of light, aa the radiation constant, σ\sigma the absorption opacity in cm−1\mathrm{cm}^{-1} (which depends on TT) and cvc_v the heat capacity per unit volume. The radiation energy density is Er=1c∫I dΩE_r = \frac{1}{c}\int I\, d\Omega, and the equilibrium value is Er=aT4E_r = a T^4. Real problems add frequency dependence, physical scattering, material motion and boundaries. The model problem of this page is an infinite uniform zone, where space and direction drop out:

dErdt=cσ(aT4−Er),cvdTdt=cσ(Er−aT4),\frac{dE_r}{dt} = c\sigma (a T^4 - E_r), \qquad c_v \frac{dT}{dt} = c\sigma(E_r - a T^4),

and Er+cvTE_r + c_v T is constant. Its solution tends to the equilibrium with aT4+cvT=Er(0)+cvT(0)a T^4 + c_v T = E_r(0) + c_v T(0), and the maximum principle holds: T(t)T(t) stays between the smallest and the largest of T(0)T(0) and the radiation temperature (Er(0)/a)1/4(E_r(0)/a)^{1/4}.

The algorithm

  1. IMC-STEP(T, census, Δt) ▷ census: list of particle energies; data frozen at T
  2. 1β ← 4 a T³ / c_v, f ← 1 / (1 + β c σ Δt) ▷ the Fleck factor
  3. 2E_em ← f c σ a T⁴ Δt; emit particles with this total energy, birth times uniform in the step
  4. 3for each particle (w, t_left) of the census and of the emission do
  5. 4loop
  6. 5d ← -ln(ξ)/σ; if d ≥ c t_left then put w in the new census; break
  7. 6t_left ← t_left - d/c
  8. 7with probability f: E_abs ← E_abs + w; break ▷ real absorption
  9. 8otherwise effective scattering: a new isotropic direction, go on
  10. 9T ← T + (E_abs - E_em) / c_v ▷ material energy balance
  11. 10(one zone only) merge the census into equal-weight particles

Line L1 freezes the data at the start of the step. Line L2 emits the energy that the linearized material equation predicts. In a code with space, line L2 also samples the position and an isotropic direction, and line L5 compares the distance to collision with the distances to census and to the faces of the cell. Lines L7 and L8 split each collision into a real absorption with probability ff and an effective scattering with probability 1−f1 - f. Line L9 is exact energy bookkeeping: every unit of energy that left the material in line L2 and did not come back in line L7 is in the census or has left the system. Codes often replace line L7 with continuous absorption, a weight reduction along the path in the manner of implicit capture, which lowers the noise of the absorbed energy.

Where the Fleck factor comes from. Write u=aT4u = a T^4 for the equilibrium radiation energy density. The material equation gives du/dt=β cσ(Er−u)du/dt = \beta\, c\sigma(E_r - u) with β=du/d(cvT)=4aT3/cv\beta = du/d(c_v T) = 4aT^3/c_v. A backward Euler step with β\beta frozen, un+1=un+βcσΔt(Er−un+1)u^{n+1} = u^n + \beta c\sigma \Delta t (E_r - u^{n+1}), gives un+1=fun+(1−f)Eru^{n+1} = f u^n + (1 - f) E_r. Putting this uu into the emission term of the radiation equation gives

dErdt=cσfun−cσfEr,\frac{dE_r}{dt} = c\sigma f u^n - c\sigma f E_r,

an emission fcσunf c \sigma u^n, an absorption with opacity fσf\sigma, and the remaining opacity (1−f)σ(1 - f)\sigma as scattering. This is what lines L2, L7 and L8 implement.

Example

The Fleck factor by hand. With a=c=σ=cv=1a = c = \sigma = c_v = 1, T=1T = 1 and Δt=0.25\Delta t = 0.25: β=4\beta = 4, f=1/(1+4⋅0.25)=0.5f = 1/(1 + 4 \cdot 0.25) = 0.5 and Eem=0.5⋅0.25=0.125E_{\mathrm{em}} = 0.5 \cdot 0.25 = 0.125. Half of the collisions in the step are real absorptions.

Explicit coupling against IMC. Start with T=1T = 1 and Er=0E_r = 0 in the same units, so the equilibrium has T+T4=1T + T^4 = 1, T=0.7245T = 0.7245. Take Δt=5\Delta t = 5. The table gives the expected temperature after each step (the mean of the Monte Carlo step, computed in closed form). The explicit method is the same algorithm with f=1f = 1.

step explicit, f=1f = 1 IMC
1 0.0067 0.7881
2 0.9933 0.7236
3 0.0330 0.7246
4 0.9935 0.7245
5 0.0323 0.7245

The explicit method emits 5 units of energy in the first step from a material that holds 1, takes most of it back, and then swings between hot and cold. IMC goes to the equilibrium in two steps.

Accuracy in time. Start with T=0.1T = 0.1 and Er=1E_r = 1, so T+T4=1.1T + T^4 = 1.1 and the equilibrium is T=0.7623T = 0.7623. With 2000 particles per step (random.Random(3)), against an accurate ODE solution:

tt exact TT IMC, Δt=0.2\Delta t = 0.2 IMC, Δt=1\Delta t = 1
1 0.6737 0.6698 0.7384
2 0.7561 0.7545 0.7574
4 0.7623 0.7675 0.7595

With Δt=1\Delta t = 1 the material heats too fast in the first step: the frozen data are a first-order approximation in time.

A violation of the maximum principle. With the same start and one step of Δt=100\Delta t = 100: β=0.004\beta = 0.004, f=1/1.4=0.714f = 1/1.4 = 0.714, Eem=0.00714E_{\mathrm{em}} = 0.00714, and almost all radiation is absorbed. The expected temperature after the step is 1.09991.0999, and the run gives 1.09991.0999. The material is now hotter than the radiation that heated it, whose temperature was 1. The exact solution never exceeds 1. This is the effect that Larsen and Mercier analysed: the frozen β=4aT3/cv\beta = 4aT^3/c_v at the cold start temperature greatly underestimates the emission during the step.

Correctness

Three claims are theorems. First, total energy is conserved exactly in every step: line L9 adds to the material the absorbed energy minus the emitted energy, and every particle energy is either absorbed, in the census or gone through a boundary. Second, the algorithm is an unbiased Monte Carlo solution of the time-discrete problem defined by the frozen Fleck factor: in one zone, the expected census energy after a step is Ere−fcσΔt+aT4(1−e−fcσΔt)E_r e^{-f c\sigma \Delta t} + a T^4 (1 - e^{-f c\sigma \Delta t}), which the tests check. Third, the Fleck factor is the exact result of the backward Euler linearization above. The proofs are below.

What is not a theorem is the accuracy of the time-discrete problem. The linearization is first order in Δt\Delta t, and with large steps it can violate the maximum principle, as Larsen and Mercier proved and as the example shows. They also showed that the maximum principle holds when the time step is small enough. IMC is widely described as stable for large time steps; this is a property observed in practice and supported by analysis of the linearized problem, not a proof of unconditional stability for the nonlinear one.

Proof: Implicit Monte Carlo conserves energy and solves the time-discrete Fleck-Cummings problemfull

We assume exact arithmetic and exact independent uniform random numbers. We prove three things: the Fleck factor is the result of a backward Euler linearization, one step conserves energy exactly, and in one zone the expected census energy is the solution of the time-discrete equation. The accuracy of the time discretization is not a theorem of this page; Larsen and Mercier (1987), cited on the page, prove a maximum principle for small time steps and show that it can fail for large ones.

Lemma 1 (the Fleck factor). Let u=aT4u = aT^4 and β=4aTn3/cv\beta = 4aT_n^3/c_v, frozen at the start of the step. The backward Euler step un+1=un+βcσΔt (Er−un+1)u^{n+1} = u^n + \beta c\sigma\Delta t\,(E_r - u^{n+1}) of the linearized material equation du/dt=βcσ(Er−u)du/dt = \beta c\sigma (E_r - u) gives un+1=fun+(1−f)Eru^{n+1} = f u^n + (1 - f) E_r with f=1/(1+βcσΔt)f = 1/(1 + \beta c\sigma\Delta t).

Proof. The material equation is cv dT/dt=cσ(Er−u)c_v\, dT/dt = c\sigma(E_r - u). By the chain rule du/dt=(du/dT)(dT/dt)=4aT3⋅cσ(Er−u)/cvdu/dt = (du/dT)(dT/dt) = 4aT^3 \cdot c\sigma(E_r - u)/c_v, which is βcσ(Er−u)\beta c\sigma(E_r - u) with β\beta frozen at TnT_n. The backward Euler step gives un+1(1+βcσΔt)=un+βcσΔt Eru^{n+1}(1 + \beta c\sigma\Delta t) = u^n + \beta c\sigma\Delta t\, E_r. Divide by 1+βcσΔt1 + \beta c\sigma\Delta t and use βcσΔt f=1−f\beta c\sigma\Delta t\, f = 1 - f. □\square

Putting un+1u^{n+1} in place of aT4aT^4 in the emission term cσaT4c\sigma aT^4 of the radiation equation gives cσfun+cσ(1−f)Erc\sigma f u^n + c\sigma(1 - f)E_r. The second term equals the part cσ(1−f)Erc\sigma(1 - f)E_r of the absorption cσErc\sigma E_r, so the two cancel as a scattering with opacity (1−f)σ(1 - f)\sigma, and what remains is the emission fcσunf c\sigma u^n and the absorption with opacity fσf\sigma. The time-discrete problem of IMC is the transport problem over the step with these frozen coefficients.

Lemma 2 (each collision). At a collision, line L7 absorbs the particle with probability ff, and line L8 keeps it with probability 1−f1 - f. So the distance to the next real absorption, measured along the path, is exponential with rate fσf\sigma, and the particle moves at speed cc between collisions.

Proof. Collisions happen at the rate σ\sigma along the path by line L5. Thinning a Poisson process of rate σ\sigma by independent coin flips with probability ff gives a Poisson process of rate fσf\sigma. In one zone the direction plays no role. □\square

Theorem 1 (energy conservation). Let Em=cvTE_m = c_v T be the material energy, EcE_c the energy in the census and EoutE_{\mathrm{out}} the energy that left through boundaries. After a step, Em+Ec+EoutE_m + E_c + E_{\mathrm{out}} equals its value before the step.

Proof. Every particle of the old census and of the emission ends the step in exactly one of three ways: absorbed in line L7, put in the new census in line L5, or (in a code with space) gone through a boundary. Line L8 does not change the weight. So the energy of the old census plus EemE_{\mathrm{em}} equals EabsE_{\mathrm{abs}} plus the new census energy plus the energy that left. Line L9 changes EmE_m by Eabs−EemE_{\mathrm{abs}} - E_{\mathrm{em}}. Adding the two equalities gives the claim. Line L10 replaces the census by particles with the same total weight. ■\blacksquare

Theorem 2 (the expected step in one zone). In an infinite uniform zone, with old census energy ErE_r and emission Eem=fcσunΔtE_{\mathrm{em}} = f c\sigma u^n\Delta t at uniform birth times, the expected new census energy is

Ere−fcσΔt+un(1−e−fcσΔt),E_r e^{-f c\sigma\Delta t} + u^n\big(1 - e^{-f c\sigma\Delta t}\big),

which is the exact solution at time Δt\Delta t of dE/dt=fcσ(un−E)dE/dt = f c\sigma(u^n - E), E(0)=ErE(0) = E_r. The expected new temperature follows from Theorem 1: cvTn+1=cvTn+Er−E[new census]c_v T^{n+1} = c_v T^n + E_r - E[\text{new census}] in expectation.

Proof. By Lemma 2 a particle with time τ\tau left in the step survives to census with probability e−fcστe^{-f c\sigma\tau}, because it travels the distance cτc\tau. The old census particles have τ=Δt\tau = \Delta t, which gives the first term. An emitted particle born at time ss, uniform in [0,Δt][0, \Delta t], has τ=Δt−s\tau = \Delta t - s, also uniform. So the expected surviving emitted energy is

Eem1Δt∫0Δte−fcστ dτ=fcσun⋅1−e−fcσΔtfcσ=un(1−e−fcσΔt).E_{\mathrm{em}} \frac{1}{\Delta t}\int_0^{\Delta t} e^{-f c\sigma\tau}\, d\tau = f c\sigma u^n \cdot \frac{1 - e^{-f c\sigma\Delta t}}{f c\sigma} = u^n\big(1 - e^{-f c\sigma\Delta t}\big).

By linearity of expectation, the expected census energy is the sum. The ODE solution is checked by substitution. ■\blacksquare

Consequences. The radiation part of the step is solved exactly in expectation, and the only errors are the statistical noise and the frozen coefficients β\beta, ff and unu^n, which make the method first order in Δt\Delta t. For a large step, fcσΔt=cσΔt/(1+βcσΔt)f c\sigma\Delta t = c\sigma\Delta t/(1 + \beta c\sigma\Delta t) tends to 1/β1/\beta, so the expected census energy tends to Ere−1/β+un(1−e−1/β)E_r e^{-1/\beta} + u^n(1 - e^{-1/\beta}), a bounded combination, instead of the explicit emission cσunΔtc\sigma u^n\Delta t, which grows without bound. This is why the explicit step with f=1f = 1 oscillates in the example and the IMC step does not. When β\beta is small (a cold material), e−1/βe^{-1/\beta} is tiny and almost all of ErE_r is absorbed, so the material can end hotter than the radiation: the maximum principle fails, as Larsen and Mercier showed.

Complexity

Each step costs O(NK)O(N K) for NN particles with KK collisions each in the step, plus O(N)O(N) for emission and census. In an optically thick zone with a large step, ff is small and cσΔtc\sigma\Delta t is large, so a particle has about cσΔtc\sigma\Delta t effective scatterings before it is absorbed or reaches census: KK grows like cσΔtc\sigma\Delta t, which is the main cost of IMC in thick, hot regions. Remedies are random walk acceleration, which replaces many small scatterings by a jump from the diffusion solution, and hybrid methods that use diffusion in thick cells. The space is O(N)O(N) for the census.

Properties

  • Conservative. The total energy of radiation and matter is conserved to rounding in each step.
  • Stable in practice. The step can be much longer than the explicit limit of about 1/(cσβ)1/(c\sigma\beta), with no oscillation in the usual problems.
  • Not monotone. The maximum principle can fail for large steps.
  • First order in time. The frozen data and the linearization give an error of order Δt\Delta t.
  • Monte Carlo noise. The temperature carries noise from the absorbed energy, and the noise feeds back into the next step through β\beta, ff and the emission.

Variants and improvements

  • The time-centring parameter. Fleck and Cummings allow a parameter α\alpha in [1/2,1][1/2, 1] in the linearization, with f=1/(1+αβcσΔt)f = 1/(1 + \alpha \beta c\sigma\Delta t); α=1\alpha = 1 is the common choice.
  • Frequency dependence. With multigroup or continuous frequency, the emission spectrum is the Planck function, and effective scattering changes the frequency as well as the direction.
  • Random walk and diffusion acceleration. Replace many effective scatterings in a thick cell by one step of the diffusion solution, as in the diffusion approximation, or use implicit Monte Carlo diffusion in thick regions.
  • Implicit Monte Carlo with better time discretization. Iterating the step with updated β\beta, or using a different linearization, reduces the violations of the maximum principle at extra cost.
  • Symbolic IMC and other implicit methods. Other schemes, such as the symbolic implicit Monte Carlo of Brooks, treat the emission implicitly in a different way, with different trade-offs.

When to use it

Use IMC for time-dependent thermal radiation problems in which transport effects matter: inertial confinement fusion, astrophysics, high energy density experiments, radiation through optically thin and thick regions together. Where the medium is optically thick everywhere, a diffusion solver is much cheaper. Choose the time step with the maximum principle in mind: a step that the explicit limit forbids is fine, but a step over which the temperature changes by a large factor is not.

Pitfalls

  • Overheating with large steps. A cold material next to a hot radiation field can end the step hotter than the field. Limit the relative change of TT per step.
  • Noise in cold regions. With few particles in a cell, the absorbed energy is noisy, and the temperature can fluctuate strongly; continuous absorption lowers this noise.
  • Teleportation error. In a code with space, emitting particles uniformly in a cell with a steep temperature gradient moves energy too far, and gives wrong wave speeds in thick media. Sample the emission position from a reconstructed T4T^4 profile.
  • The census count. The number of census particles grows from step to step. Population control (combining in a cell, or Russian roulette) must conserve energy.
  • Merging in space. Merging census particles of different positions or directions changes the solution. The merge of line L10 is valid only in one zone with no space or direction.

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.

implicit_monte_carlo.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/implicit-monte-carlo/. The authors are listed in prov/CX3297.jsonl.
"""Implicit Monte Carlo (Fleck and Cummings) for grey radiation in one zone.

The zone is infinite and uniform, so space and direction drop out. The
radiation energy density E_r and the material temperature T obey

    dE_r/dt     = c sigma (a T^4 - E_r),
    c_v dT/dt   = c sigma (E_r - a T^4),

and E_r + c_v T is constant. One IMC step of size dt freezes the
temperature-dependent data at the start of the step and uses the Fleck
factor

    beta = 4 a T^3 / c_v,   f = 1 / (1 + beta c sigma dt).

During the step the material emits f c sigma a T^4 per unit time. A
radiation particle collides at rate c sigma; at a collision it is
absorbed with probability f, and with probability 1 - f it goes on as if
scattered ("effective scattering"). Particles that reach the end of the
step go to census. The material energy changes by the absorbed energy
minus the emitted energy, so the total energy is conserved exactly.

Since this zone has no space or direction, the census can be merged into
equal-weight particles without loss; a code with space cannot do that.
"""

import math


def uniform_open(rng) -> float:
    return 1.0 - rng.random()


def imc_step(temp, census, dt, n_emit, rng, a=1.0, c=1.0, sigma=1.0, cv=1.0, n_census=None):
    """One IMC step. census is a list of particle energies.

    Returns (new temperature, new census list, info dict).
    """
    beta = 4.0 * a * temp ** 3 / cv  # @line L1
    f = 1.0 / (1.0 + beta * c * sigma * dt)
    e_emit = f * c * sigma * a * temp ** 4 * dt  # @line L2
    particles = [(w, dt) for w in census]
    if n_emit > 0 and e_emit > 0.0:
        w = e_emit / n_emit
        particles += [(w, dt * (1.0 - rng.random())) for _ in range(n_emit)]  # time left after birth
    e_abs = 0.0
    out = []
    for w, t_left in particles:  # @line L3
        while True:  # @line L4
            d_coll = -math.log(uniform_open(rng)) / sigma
            if d_coll >= c * t_left:  # @line L5
                out.append(w)
                break
            t_left -= d_coll / c  # @line L6
            if rng.random() < f:  # @line L7
                e_abs += w
                break
            continue  # @line L8 (effective scattering: the particle goes on)
    new_temp = temp + (e_abs - e_emit) / cv  # @line L9
    if n_census is not None and len(out) > n_census:  # @line L10
        total = sum(out)
        out = [total / n_census] * n_census
    info = {"f": f, "emitted": e_emit, "absorbed": e_abs, "launched_w2": sum(w * w for w, _ in particles)}
    return new_temp, out, info


def expected_census(e_r, temp, dt, a=1.0, c=1.0, sigma=1.0, cv=1.0):
    """Exact mean radiation energy after one IMC step (the step's own linear model)."""
    beta = 4.0 * a * temp ** 3 / cv
    f = 1.0 / (1.0 + beta * c * sigma * dt)
    x = f * c * sigma * dt
    return e_r * math.exp(-x) + a * temp ** 4 * (1.0 - math.exp(-x))


def equilibrium_temperature(total, a=1.0, cv=1.0):
    """Solve a T^4 + c_v T = total by bisection."""
    lo, hi = 0.0, max(total / cv, (total / a) ** 0.25)
    for _ in range(200):
        mid = 0.5 * (lo + hi)
        if a * mid ** 4 + cv * mid < total:
            lo = mid
        else:
            hi = mid
    return 0.5 * (lo + hi)
test_implicit_monte_carlo.py 57 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/implicit-monte-carlo/. The authors are listed in prov/CX3297.jsonl.
import math
import random

import pytest

from implicit_monte_carlo import equilibrium_temperature, expected_census, imc_step


def test_fleck_factor_by_hand():
    # T = 1, a = c = sigma = c_v = 1, dt = 0.25: beta = 4, f = 1 / (1 + 1) = 0.5.
    _, _, info = imc_step(1.0, [], 0.25, 10, random.Random(0))
    assert info["f"] == pytest.approx(0.5)
    assert info["emitted"] == pytest.approx(0.5 * 0.25)


def test_energy_is_conserved_exactly():
    rng = random.Random(1)
    temp, census = 0.1, [1.0 / 500] * 500
    total = temp + sum(census)
    for _ in range(20):
        temp, census, _ = imc_step(temp, census, 0.3, 500, rng, n_census=500)
        assert temp + sum(census) == pytest.approx(total, rel=1e-12)


@pytest.mark.parametrize("temp,e_r,dt", [(0.1, 1.0, 0.5), (0.8, 0.2, 0.2), (1.0, 1.0, 2.0)])
def test_one_step_mean(temp, e_r, dt):
    n = 6000
    census = [e_r / n] * n
    _, out, info = imc_step(temp, census, dt, n, random.Random(2))
    exact = expected_census(e_r, temp, dt)
    # Each particle reaches census or not, so the variance is at most sum(w^2) / 4.
    bound = 4.0 * math.sqrt(info["launched_w2"] / 4.0)
    assert abs(sum(out) - exact) < bound


def test_relaxes_to_equilibrium():
    rng = random.Random(3)
    temp, census = 0.1, [1.0 / 400] * 400
    t_eq = equilibrium_temperature(1.0 + 0.1)
    assert t_eq + t_eq ** 4 == pytest.approx(1.1)
    for _ in range(60):
        temp, census, _ = imc_step(temp, census, 0.2, 400, rng, n_census=400)
    assert temp == pytest.approx(t_eq, abs=0.03)
    assert sum(census) == pytest.approx(t_eq ** 4, abs=0.03)


def test_large_step_overshoots():
    # With dt = 100 the frozen Fleck factor lets the cold material absorb almost all
    # the radiation in one step: T jumps above the radiation temperature 1.
    temp, census = 0.1, [1.0 / 2000] * 2000
    expected_t = 0.1 + 1.0 - expected_census(1.0, 0.1, 100.0)
    new_t, _, _ = imc_step(temp, census, 100.0, 2000, random.Random(4))
    assert expected_t > 1.09
    assert new_t == pytest.approx(expected_t, abs=0.01)
    assert new_t > 1.0

History

Joseph Fleck and J. D. Cummings at the Lawrence Radiation Laboratory published the method in 1971, with frequency dependence and the effective scattering interpretation. It became the standard Monte Carlo method for thermal radiation in the codes of the US national laboratories. Larsen and Mercier analysed it in 1987 and proved that it satisfies a maximum principle for small enough time steps and can violate it for large ones. Wollaber's 2016 review describes four decades of analysis and variants, including acceleration methods for thick media and corrections for the teleportation error.

References

  1. J. A. Fleck, Jr. and J. D. Cummings, An implicit Monte Carlo scheme for calculating time and frequency dependent nonlinear radiation transport, Journal of Computational Physics 8(3), 1971, 313-342, the time discretization of the coupled equations, the Fleck factor and effective scattering
  2. Edward W. Larsen and Bertrand Mercier, Analysis of a Monte Carlo method for nonlinear radiative transfer, Journal of Computational Physics 71(1), 1987, 50-64, the maximum principle, which holds for small time steps and can fail for large ones
  3. Allan B. Wollaber, Four decades of implicit Monte Carlo, Journal of Computational and Theoretical Transport 45(1-2), 2016, 1-70, a review of the method, its derivation, its accuracy and its variants

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.average
  • 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