---
title: "Radiation transport"
---

Docstrings from `src/radiation_system.jl`, `src/riemann_radiation.jl`, `src/planck.jl`, `src/opacity.jl`.

## Exported

### `RadiationPhysics` {#RadiationPhysics}

Source: [`src/radiation_system.jl:4`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L4)

```julia
RadiationPhysics(; c, chat = c, a_rad, opacity,
                 groups = GREY, k_B = 1,
                 closure = LevermoreClosure(),
                 coupling = BracketedCoupling(),
                 dust = NoDust(),
                 beta_order = 1,
                 tolerance = 1e-9,
                 max_iterations = 100,
                 max_outer_iterations = 5)
```

Parameters of the two-moment (M1) radiation module, grey or multigroup.

  - `c`       : speed of light, in the same units as the rest of the problem.
  - `chat`    : reduced speed of light. Using `chat < c` relaxes the radiation
    CFL condition and leaves the *static* diffusion and free-streaming limits
    intact; it does change dynamic-diffusion problems, so only reduce it when
    the radiation transport is much faster than every other signal in the
    problem. With a `chat_limiter` other than the default this is the *nominal*
    reduction `phi0 c`: a floor on the local `chat` and the speed the time step
    is still set from, not the speed every cell runs at.
  - `chat_limiter` : an [`AbstractChatLimiter`](rsla.md#AbstractChatLimiter) making the reduced speed of
    light local. The default, [`ConstantChat`](rsla.md#ConstantChat), is the standard RSLA and a
    bit-for-bit no-op; [`StabilityBound`](rsla.md#StabilityBound) is the improved RSLA, which
    raises `chat` towards `c` in cells optically thick on the grid scale, where
    the RSLA equilibrates matter and radiation at the wrong temperature and
    where the implicit coupling supplies the damping that makes the full speed
    of light stable anyway.
  - `a_rad`   : radiation constant `4σ/c`, so that the equilibrium radiation
    energy density is `a_rad T⁴`.
  - `opacity` : an [`AbstractOpacity`](#AbstractOpacity).
  - `groups`  : a [`RadiationGroups`](#RadiationGroups). The default, [`GREY`](#GREY), is the
    single group spanning every frequency, and reproduces grey radiation exactly;
    `ngroups > 1` puts the whole radiation module on the multigroup path, from
    the state-vector length down to the coupling solver.
  - `k_B`     : Boltzmann constant. It is read *only* to turn a group edge into
    `x = energy_unit * edge / (k_B T)` for the Planck fractions, so it matters
    only when the group edges are in physical units -- pass `CGS.k_B` alongside
    `energy_unit = CGS.h_planck` for edges in Hz. A grey run computes no
    fractions and never reads it, and unit-free edges given directly in units of
    `k_B T` want the default `1`; wrong in either of those cases it costs
    nothing, wrong in the physical-units case it moves energy between groups.
  - `coupling` : the implicit matter-radiation solver used when `ngroups > 1`, an
    `AbstractCoupling` -- [`BracketedCoupling`](coupling.md#BracketedCoupling) (the default,
    allocation-free), [`QuokkaCoupling`](coupling.md#QuokkaCoupling) or [`AdaptiveCoupling`](coupling.md#AdaptiveCoupling). A
    grey run ignores it and uses [`radiation_source_step!`](coupling.md#radiation_source_step-bang)'s own 2×2
    Newton driver.
  - `dust`     : an [`AbstractDustModel`](coupling.md#AbstractDustModel). [`NoDust`](coupling.md#NoDust), the default,
    couples the radiation to the gas. [`BateKetoDust`](coupling.md#BateKetoDust) couples it to dust
    at its own temperature instead, and the dust to the gas by collisions; the
    `opacity` is then the dust's, the gas has none, and `coupling` must be
    [`BracketedCoupling`](coupling.md#BracketedCoupling). A grey run with dust goes through the
    multigroup driver, which handles one group unchanged.
  - `closure`  : [`LevermoreClosure`](#LevermoreClosure) (the M1 default) or
    [`EddingtonClosure`](#EddingtonClosure), which fixes `chi = 1/3`. Use the latter only to
    reproduce reference solutions derived under the P1 approximation; it cannot
    free-stream.
  - `beta_order` : `1` keeps the `O(v/c)` terms in the matter-radiation coupling
    (radiation force, work, and the comoving-frame corrections); `0` drops them,
    which is appropriate only for a static medium.
  - `tolerance`, `max_iterations`, `max_outer_iterations` : controls of the
    implicit coupling solve (see [`radiation_source_step!`](coupling.md#radiation_source_step-bang)).
  - `wavespeed_correction = false` : scale the HLL dissipation of the radiation
    *energy* at each face by `epsilon = min(1, 1/tau)`, with `tau` the harmonic
    mean of the two cells' flux-mean optical depths across the face (Skinner et
    al. 2019; optional in Quokka). In optically thick cells the HLL
    dissipation `sigma chat (E_R - E_L)/2` is a numerical diffusion far faster
    than the physical one, `c/(3 tau)`; the correction removes it. Allowed
    with the standard RSLA only: with a local `chat_limiter` the stability bound
    no longer holds. A face's correction is set by both cells beside it, so a
    thick cell bounded with its own correction can run at `phi = 1` behind an
    almost undamped face beside a thin one, and in a uniform medium the lowered
    dissipation lets modes near a quarter of the grid frequency grow wherever
    the radiation's inertia matters, which the checkerboard bound does not see
    (paper Sec. 3.2; `analysis/v2/check_wavespeed.py`).

### `ngroups` {#ngroups}

Source: [`src/radiation_system.jl:143`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L143)

```julia
ngroups(phys) -> Int
```

The number of frequency groups, a compile-time constant so every radiation
kernel specialises on it. One group is grey radiation and is the default.

Source: [`src/planck.jl:122`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L122)

```julia
ngroups(groups) -> Int
```

How many frequency groups. A compile-time constant, so kernels specialise on it.

### `LevermoreClosure` {#LevermoreClosure}

Source: [`src/riemann_radiation.jl:25`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L25)

```julia
LevermoreClosure()
```

The M1 closure of Levermore (1984),
`chi(f) = (3 + 4f²) / (5 + 2√(4 - 3f²))`. Interpolates between `1/3` in the
diffusion limit and `1` in the free-streaming limit, so radiation travels in
straight lines and casts shadows. The default.

### `EddingtonClosure` {#EddingtonClosure}

Source: [`src/riemann_radiation.jl:35`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L35)

```julia
EddingtonClosure()
```

The Eddington (P1) approximation, `chi = 1/3` for every `f`, which makes the
radiation pressure isotropic everywhere.

This is *not* a two-moment closure in the usual sense: it cannot free-stream and
will not cast a shadow. It is here because several semi-analytic reference
solutions are derived under it -- notably the Lowrie & Edwards (2008) radiative
shock -- so reproducing them requires matching the assumption.

### `planck_integral` {#planck_integral}

Source: [`src/planck.jl:16`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L16)

```julia
planck_integral(x) -> Real
```

The normalised incomplete Planck integral `P(x) = (15/pi^4) int_0^x t^3/(e^t-1) dt`,
so `P(0) = 0` and `P(Inf) = 1`. `x = h nu / (k_B T)` is frequency in units of the
thermal frequency.

This is the fraction of a blackbody's energy radiated below `nu`.

### `RadiationGroups` {#RadiationGroups}

Source: [`src/planck.jl:57`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L57)

```julia
RadiationGroups{NG}(edges; energy_unit = 1)
```

`NG` frequency groups defined by `NG + 1` monotonically increasing `edges`.

`energy_unit` converts an edge to an energy, so that `x = energy_unit * edge /
(k_B T)`: pass `CGS.h_planck` to give the edges in Hz, as
`Honghu.Problems.marshak_vaytet` does, or leave it at `1` to give them as
energies in whatever units `k_B` is in -- which for the unit-free test problems,
where `k_B = 1`, means directly in units of `T`.

The outermost edges are the integration limits, so the first group collects
everything below `edges[1]` and the last everything above `edges[end]` -- the
fractions always sum to exactly one, whatever the edges are. This matches
Quokka's `radBoundaries`, including that convention.

Source: [`src/planck.jl:99`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L99)

```julia
RadiationGroups(lo, hi, ngroups; energy_unit = 1, spacing = :log)
```

`ngroups` groups between `lo` and `hi`, spaced logarithmically (the usual choice,
since a Planck spectrum spans decades) or linearly.

### `planck_fractions` {#planck_fractions}

Source: [`src/planck.jl:147`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L147)

```julia
planck_fractions(groups, T_rad, k_B) -> SVec{NG}
```

The fraction of a blackbody at temperature `T_rad` falling in each group, summing
to exactly one.

The last group takes `1 - sum(rest)` rather than its own integral, so the sum is
one by construction no matter where the edges sit -- the same guarantee Quokka's
`ComputePlanckEnergyFractions` makes, and the reason total emitted energy is
conserved to round-off regardless of the group structure.

### `ConstantOpacity` {#ConstantOpacity}

Source: [`src/opacity.jl:80`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L80)

```julia
ConstantOpacity(kappa)
ConstantOpacity(; planck, energy = planck, flux = planck)
```

Opacity independent of density and temperature.

### `PowerLawOpacity` {#PowerLawOpacity}

Source: [`src/opacity.jl:103`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L103)

```julia
PowerLawOpacity(; kappa0, rho0 = 1.0, T0 = 1.0, m = 0.0, n = 0.0)
```

Opacity of the form `kappa = kappa0 (rho/rho0)^m (T/T0)^n`, applied to all three
means. Kramers-like laws are `m = 1, n = -3.5`; the classic Marshak-wave test
uses `n = -3`.

### `UserOpacity` {#UserOpacity}

Source: [`src/opacity.jl:139`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L139)

```julia
UserOpacity(f)
UserOpacity(; planck, energy = planck, flux = planck,
              dplanck_dT = nothing, denergy_dT = dplanck_dT)
```

Opacity defined by user callables `f(rho, T) -> kappa`.

`dplanck_dT` and `denergy_dT` are optional callables of the same signature
giving `dkappa/dT`. Supplying them makes the coupling's Newton Jacobian exact;
leaving them out substitutes zero, which costs iterations but not the root (see
[`dkappa_dT`](#dkappa_dT)).

### `FrequencyOpacity` {#FrequencyOpacity}

Source: [`src/opacity.jl:206`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L206)

```julia
FrequencyOpacity(f; grey = nothing, dkappa_dT = nothing, dgrey_dT = nothing)
```

Opacity from a callable `f(nu, rho, T) -> kappa`, evaluated at each group centre.

```julia
# Vaytet's nu^-2 law: kappa = 2000 (nu / 4e13)^-2 cm^2/g
FrequencyOpacity((nu, rho, T) -> 2000.0 * (nu / 4.0e13)^-2)
```

A frequency-dependent law has no single grey value, so the grey entry points
throw unless `grey` gives one explicitly. That is deliberate: silently
collapsing `kappa(nu)` to some arbitrary frequency is how a multigroup opacity
ends up quietly driving a single-group run.

`dkappa_dT(nu, rho, T)` and `dgrey_dT(rho, T)` are the optional temperature
derivatives, per group and grey respectively. They default to zero, which leaves
the coupling's Jacobian inexact -- costing Newton convergence rate, not the root
it converges to (see [`dkappa_dT`](#dkappa_dT)).

## Internals

### `nradvars` {#nradvars}

Source: [`src/radiation_system.jl:151`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L151)

```julia
nradvars(phys) -> Int
```

Length of the radiation state vector, `4 * ngroups`: an energy density and three
flux components per group.

### `gbase` {#gbase}

Source: [`src/radiation_system.jl:159`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L159)

```julia
gbase(g) -> Int
```

Index offset of group `g` in the radiation state vector, so that group `g`'s
energy density is at `gbase(g) + IERAD` and its `d` momentum at `gbase(g) + d + 1`.

Groups are stored contiguously, four components at a time, which is Quokka's
`radEnergy_index + numRadVarsPerGroup * g` layout. Keeping a group's components
adjacent means one group's Riemann problem reads one cache line, and it keeps
the momentum-index convention (`d + 1` within a group) that `fill_ghosts!`
relies on to serve hydro and radiation with one implementation.

### `amend_rad` {#amend_rad}

Source: [`src/radiation_system.jl:173`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L173)

```julia
amend_rad(er, Fx, Fy, Fz, c, erad_floor)
    -> (er, Fx, Fy, Fz, fx, fy, fz, repaired)
```

Project one radiation state onto the admissible set of the M1 closure: energy
density at or above the floor, and reduced flux `|F|/(cE)` strictly below one
(the flux is rescaled, preserving its direction). Also returns the reduced flux
components, which the caller usually wants anyway.

`repaired` is true when the state was inadmissible: an energy density below the
floor or NaN, or a flux that had to be rescaled. An energy density exactly at the
floor is admissible and is not counted, where it would otherwise be a "repair" in
every call for the dark cells of a photoionization run. The returned values are
the projection either way, and a caller that writes them back for a cell at the
floor, as [`enforce_rad_floors!`](#enforce_rad_floors-bang) does, leaves the energy as it was and
passes the flux through `(F / cE) cE`.

### `enforce_rad_floors!` {#enforce_rad_floors-bang}

Source: [`src/radiation_system.jl:219`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L219)

```julia
enforce_rad_floors!(R, phys, grid, floors) -> Int
```

Project the radiation state onto the admissible set of the M1 closure over the
whole array, ghost cells included (see [`amend_rad`](#amend_rad)). Returns the number
of cells repaired.

The radiation counterpart of [`enforce_floors!`](hydro.md#enforce_floors-bang), and separate from
[`rad_cons2prim!`](#rad_cons2prim-bang) for the same reason.

### `amend_rad_state!` {#amend_rad_state-bang}

Source: [`src/radiation_system.jl:235`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L235)

```julia
amend_rad_state!(R, phys, grid, floors) -> Int
```

Repair the radiation state of the *interior* cells in place. Used after each
implicit coupling solve of the IMEX scheme, so that every stage hands the next
transport step an admissible state -- not between the transport stage and the
solve, where the flux must be left alone (see [`floor_rad_energy!`](#floor_rad_energy-bang)). The
ghost cells are refilled from the boundary conditions before they are next read,
so there is no point touching them here.

### `floor_rad_energy!` {#floor_rad_energy-bang}

Source: [`src/radiation_system.jl:250`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L250)

```julia
floor_rad_energy!(R, U, chat, phys, grid, floors; bfield = nothing) -> Int
```

Hand the transport stage's radiation state to the implicit coupling solve
unchanged where the solve can absorb it, and floor the radiation energy only
where it cannot. Used after the explicit transport stages of the IMEX scheme,
before the solve; returns the number of cells floored.

Neither the flux nor the energy is limited where the solve can take the state.
In an optically thick cell run at a local CFL number far above one -- which is
what a local reduced speed of light does at `phi = 1` -- the transport stage
leaves `|F| >> cE`, and the solve, which divides the flux by
`1 + chat rho kappa_F dt >> 1`, is exactly what turns it into the diffusion flux
`-c grad E / (3 rho kappa_F)`. Clipping `|F|` to `cE` first threw that flux away:
on the thick hot spot of the paper's test it raised the IRSLA error from 0.0003%
to 0.80%, twice that of the standard RSLA. The same stage can also leave `E < 0`
where a thick cell at large `phi` borders cells at small `phi` across a steep
jump; raising `E` to the floor there adds energy every substep, and on an Ensman
shock resolved by 64 cells it made the IRSLA error 17 times that of the RSLA.

The solve conserves `e_int + sum_g E_g/phi_g` (with `phi_g = chat_g/c`) and
returns a positive temperature whenever that is positive, so a negative `E` is
left for it to absorb. Only a cell whose budget is not positive is floored, as
before; the full repair, [`amend_rad_state!`](#amend_rad_state-bang), runs after the solve.

### `rad_cons2prim!` {#rad_cons2prim-bang}

Source: [`src/radiation_system.jl:342`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L342)

```julia
rad_cons2prim!(rprim, R, phys, grid)
```

Fill the radiation primitives `(Erad, fx, fy, fz)` from the conserved state over
the whole array, ghost cells included.

`R` is **only read**; see [`cons2prim!`](hydro.md#cons2prim-bang) for why. Run
[`enforce_rad_floors!`](#enforce_rad_floors-bang) first if the state may be inadmissible — on an
admissible state the reduced flux this computes automatically satisfies
`|f| < 1`.

### `rad_fluxes!` {#rad_fluxes-bang}

Source: [`src/radiation_system.jl:375`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L375)

```julia
rad_fluxes!(flux, qL, qR, R, chat, phys, Val(D), grid)
```

Solve the HLL Riemann problem of the M1 system at every interface normal to
direction `D`.

`chat` is the per-cell, per-group reduced speed of light (see
[`update_chat!`](#update_chat-bang)), or `nothing`. An array is passed under the standard RSLA
and in the flux form of a local limiter (see [`flux_form`](rsla.md#flux_form)), and the
interface then uses the **minimum** of the two adjacent cells. In the flux form
that is the stable choice wherever `chat` varies: an optically thick cell may
locally run at the full speed of light, but letting it set the signal speed of a
flux into a transparent neighbour would impose a CFL-violating speed there,
where no source damping is available to control the resulting amplification.
`nothing` is passed in the default, time-derivative form of a local limiter: the
flux is then the unreduced one, at the true speed of light, and
[`scale_by_phi!`](#scale_by_phi-bang) multiplies each cell's update by its own `phi`
afterwards, so no interface value is needed.

As in the hydro sweep, an inadmissible reconstructed state (non-positive energy
density, or a reduced flux at or beyond the causal limit) falls back to the
piecewise-constant state of the adjoining cells.

### `scale_by_phi!` {#scale_by_phi-bang}

Source: [`src/radiation_system.jl:478`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L478)

```julia
scale_by_phi!(dR, chat, phys, grid)
```

Multiply each interior cell's radiation right-hand side by its own reduction
`chat_g/c`, group by group: the time-derivative form of a local reduced speed of
light (see [`flux_form`](rsla.md#flux_form)).

### `radiation_timestep` {#radiation_timestep}

Source: [`src/radiation_system.jl:503`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L503)

```julia
radiation_timestep(phys, grid, cfl)
```

Radiation CFL condition, `dt = cfl / (chat Σ_d 1/dx_d)` over the active
directions. Independent of the state because the M1 signal speed is bounded by
`chat`.

### `_grid_scales` {#_grid_scales}

Source: [`src/radiation_system.jl:525`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L525)

```julia
_grid_scales(grid) -> (dx_min, sum_d 1/dx_d, (1/dx_1, 1/dx_2, 1/dx_3))
```

The grid numbers the limiter needs, over the *active* directions only: the
smallest cell width (read by the fitting form), the reciprocal-width sum the CFL
number is built from (the same one `radiation_timestep` forms), and the
per-direction reciprocal widths, zero in an inactive direction.

A free function because both callers capture the result in a threaded closure,
and a variable assigned inside a loop in the enclosing scope would be boxed --
every cell would then allocate. That is not hypothetical: written inline it cost
54 bytes a cell.

### `_signal_sum` {#_signal_sum}

Source: [`src/radiation_system.jl:551`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L551)

```julia
_signal_sum(closure, R, i, j, k, g, c, inv3) -> sum_d sigma_d / dx_d
```

The HLL signal speed of group `g` in this cell along each active direction, as a
fraction of `chat`, divided by the cell width and summed: the rate at which one
explicit stage amplifies a grid-scale checkerboard, per unit `chat dt`.

`sigma_d = max(0.1, sqrt(T_dd))` is exactly the speed `m1_flux` hands the Riemann
solver along `d`: `1/sqrt(3)` in every direction where the radiation is
isotropic, and -- where it free-streams -- one along the beam and the `0.1` floor
across it. Using the closure's own speeds rather than the P1 value is what keeps
[`StabilityBound`](rsla.md#StabilityBound) honest in a free-streaming cell, which is exactly the
cell with no source damping to spare; using them *per direction* rather than
the largest of them keeps a beamed cell in two or three dimensions from being
bounded as if it beamed along every axis at once.

### `update_chiF!` {#update_chiF-bang}

Source: [`src/radiation_system.jl:590`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L590)

```julia
update_chiF!(chiF, U, eos, phys, grid, floors; bfield = nothing)
```

Fill the per-cell, per-group flux absorption coefficient `rho kappa_F` over the
whole array including ghost cells, for the wave-speed correction of
[`RadiationPhysics`](#RadiationPhysics).

### `update_chat!` {#update_chat-bang}

Source: [`src/radiation_system.jl:618`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L618)

```julia
update_chat!(chat, U, R, eos, phys, grid, floors, dt; update_momentum = true,
             bfield = nothing)
```

Fill the per-cell, per-group reduced speed of light `chat[g, i, j, k]` from the
current state, over the *whole* array including ghost cells.

Ghost cells are included because the transport step needs the limiter on both
sides of every interface, including the ones bounding the domain; the limiter is
purely local, so filling them costs one extra loop and no communication. `U` and
`R` must already have had their own ghost cells filled.

`update_momentum = false`, as for a run without hydrodynamics, means that the
coupling freezes the gas momentum: the gas then has no inertia to share with the
radiation, and the momentum block of [`StabilityBound`](rsla.md#StabilityBound) loses its cap `K_F`.

A [`ConstantChat`](rsla.md#ConstantChat) limiter -- the default -- dispatches to a no-op: the
array was filled with `phys.chat` when the simulation was built and cannot
change.

### `_radiation_inertia` {#_radiation_inertia}

Source: [`src/radiation_system.jl:672`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L672)

```julia
_radiation_inertia(cl, R, i, j, k, c, rho, ng) -> (1 + T_max) E / (rho c^2)
```

The ratio of the radiation to the gas inertia that caps the damping of the
momentum block in [`StabilityBound`](rsla.md#StabilityBound): `E` and the flux summed over the
`ng` groups, as for the heat capacity, and `T_max` the largest diagonal element
of the Eddington tensor of that total, the most restrictive momentum channel.

### `energy_exchange_dt` {#energy_exchange_dt}

Source: [`src/radiation_system.jl:761`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/radiation_system.jl#L761)

```julia
energy_exchange_dt(U, R, eos, phys, grid, xi, floors; bfield = nothing) -> dt
```

The longest substep at which every optically thick cell may run at `phi = 1`,
`dt = xi / (c max_i [4 a_rad T^3 / (rho c_v) * sum_d sigma_d/dx_d])` minimised
over interior cells. Requested by `StabilityBound(energy_step = true)`.

**Not a stability condition.** The standard RSLA and the stability-bound limiter
are both stable without it, at any radiation-to-gas pressure ratio. What it buys
is accuracy where radiation carries a large share of the heat capacity: there
the limiter's energy channel caps `phi` near `phi0/(sigma C_r)` at the RSLA step,
because with `K = hrat c dt chi_E` the damping `chi_E/(2 + K)` saturates at
`1/(hrat c dt)` and cannot overcome the transport amplification. Below this
step it can, by a margin `1 - xi`, and cells thick enough -- `chi_E / sum_d(1/dx_d)`
beyond about `2 sigma/(1 - xi)` -- reach `phi = 1` and the exact equations.

With hydrodynamics disabled the gas still exchanges heat with the radiation, so
unlike a radiation-*force* constraint this one does not switch off when the gas
cannot move.

### `AbstractClosure` {#AbstractClosure}

Source: [`src/riemann_radiation.jl:17`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L17)

```julia
AbstractClosure
```

Supertype for the closure that supplies the Eddington factor `chi(f)`:
[`LevermoreClosure`](#LevermoreClosure) or [`EddingtonClosure`](#EddingtonClosure).

### `eddington_factor` {#eddington_factor}

Source: [`src/riemann_radiation.jl:48`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L48)

```julia
eddington_factor([closure = LevermoreClosure()], f)
```

Eddington factor for the reduced flux `f = |F| / (c E)`.

### `EddingtonTensor` {#EddingtonTensor}

Source: [`src/riemann_radiation.jl:63`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L63)

```julia
EddingtonTensor(diag, aniso, n)
```

The Eddington tensor `T_ij = diag δ_ij + aniso n_i n_j` in factored form, where
`n` is the unit vector along the radiation flux. Index it as `T[i, j]`.

### `eddington_tensor` {#eddington_tensor}

Source: [`src/riemann_radiation.jl:75`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L75)

```julia
eddington_tensor([closure = LevermoreClosure()], fx, fy, fz) -> EddingtonTensor
```

Build the Eddington tensor from the reduced flux vector.

### `m1_flux` {#m1_flux}

Source: [`src/riemann_radiation.jl:95`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L95)

```julia
m1_flux(er, Fx, Fy, Fz, tedd, D) -> (SVec{4}, S)
```

Physical M1 flux normal to a face with normal direction `D` (before the reduced
speed-of-light rescaling), together with the normalised signal speed
`S = max(0.1, sqrt(T_DD))`.

The `0.1` floor mirrors Quokka: it keeps `S_L = S_R = 0` (and hence a `0/0`
flux) from occurring in cells where the Eddington tensor becomes degenerate.

### `hll_radiation` {#hll_radiation}

Source: [`src/riemann_radiation.jl:112`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/riemann_radiation.jl#L112)

```julia
hll_radiation(erL, FxL, FyL, FzL, erR, FxR, FyR, FzR, c, chat, Val(D),
              closure = LevermoreClosure()) -> SVec{4}
```

HLL flux of the grey M1 system across one interface with normal along direction
`D`. Components are `(energy, x-momentum, y-momentum, z-momentum)`.

### `GREY` {#GREY}

Source: [`src/planck.jl:119`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L119)

The single group spanning all frequencies, which reproduces grey radiation.

### `group_centers` {#group_centers}

Source: [`src/planck.jl:129`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L129)

```julia
group_centers(groups) -> SVec
```

The geometric mean of each group's edges, which is the frequency a
piecewise-constant opacity is evaluated at. Quokka's `ComputeBinCenterOpacity`
uses the same `sqrt(nu_g nu_{g+1})`.

An unbounded outer group has no geometric mean, so it falls back to its finite
edge -- the alternative is an opacity of zero or infinity in the group that
usually carries the least energy.

### `planck_fractions_dT` {#planck_fractions_dT}

Source: [`src/planck.jl:173`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/planck.jl#L173)

```julia
planck_fractions_dT(groups, T_rad, k_B) -> SVec{NG}
```

`d(fraction)/dT` for each group, by centred differences on a relative step.

The Jacobian of the coupling needs `d(a T^4 f_g)/dT = 4 a T^3 f_g + a T^4 f_g'`.
The second piece is what moves energy between groups as the gas heats, and
dropping it -- as an implementation that assumed fixed fractions would -- slows
the Newton iteration without changing where it converges.

### `AbstractOpacity` {#AbstractOpacity}

Source: [`src/opacity.jl:9`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L9)

```julia
AbstractOpacity
```

Supertype for opacity laws. A concrete subtype must implement

  - [`planck_opacity`](#planck_opacity)`(op, rho, T)`
  - [`energy_mean_opacity`](#energy_mean_opacity)`(op, rho, T)`
  - [`flux_mean_opacity`](#flux_mean_opacity)`(op, rho, T)`

each returning a *specific* opacity (cm² g⁻¹ in CGS), so that the absorption
coefficient is `rho * kappa`.

Optionally it may also implement [`dkappa_dT`](#dkappa_dT)`(op, rho, T)`, which makes
the matter-radiation coupling's Newton Jacobian exact. The default is zero,
which is exact for an opacity that does not depend on temperature and merely
slower for one that does.

### `planck_opacity` {#planck_opacity}

Source: [`src/opacity.jl:28`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L28)

```julia
planck_opacity(op, rho, T) -> kappa_P
```

The Planck-mean specific opacity of `op` at density `rho` and gas temperature
`T`. It weights thermal emission, the `rho kappa_P a_rad T^4` term of the
matter-radiation coupling. Part of the [`AbstractOpacity`](#AbstractOpacity) interface.

### `energy_mean_opacity` {#energy_mean_opacity}

Source: [`src/opacity.jl:37`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L37)

```julia
energy_mean_opacity(op, rho, T) -> kappa_E
```

The energy-mean specific opacity of `op` at density `rho` and gas temperature
`T`. It weights the absorption of the radiation energy, the `rho kappa_E E_rad`
term of the coupling. Part of the [`AbstractOpacity`](#AbstractOpacity) interface.

### `flux_mean_opacity` {#flux_mean_opacity}

Source: [`src/opacity.jl:46`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L46)

```julia
flux_mean_opacity(op, rho, T) -> kappa_F
```

The flux-mean specific opacity of `op` at density `rho` and gas temperature
`T`. It weights the damping of the radiation flux, `rho kappa_F F`, and so the
radiation force on the gas. Part of the [`AbstractOpacity`](#AbstractOpacity) interface.

### `dkappa_dT` {#dkappa_dT}

Source: [`src/opacity.jl:55`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L55)

```julia
dkappa_dT(op, rho, T) -> (dkappaP_dT, dkappaE_dT)
```

Temperature derivatives of the Planck- and energy-mean opacities.

The coupling solves `d E_g/dt = chat rho (kappa_P,g B_g(T) - kappa_E,g E_g)` by
Newton's method, so the exact Jacobian carries `dkappa_P/dT * B_g` and
`-dkappa_E/dT * E_g` alongside `kappa_P dB_g/dT`. Supplying these derivatives is
what makes it exact.

**The default is zero.** A zero derivative does not change where the iteration
converges -- the residual it is driven to zero is still the residual of the true
equations -- only how fast it gets there. So it is safe everywhere, and exact
wherever `kappa` is independent of `T`.

### `group_opacity` {#group_opacity}

Source: [`src/opacity.jl:182`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L182)

```julia
group_opacity(op, nu, rho, T) -> Real
```

The opacity of a frequency group centred on `nu`.

Defaults to the grey Planck mean, so any existing opacity law used with several
groups gives the same `kappa` in every group -- a genuine configuration, and the
one Vaytet et al. (2011) call the constant-opacity model. Override it for a law
that actually varies with frequency, or use [`FrequencyOpacity`](#FrequencyOpacity).

### `group_opacity_dT` {#group_opacity_dT}

Source: [`src/opacity.jl:194`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L194)

```julia
group_opacity_dT(op, nu, rho, T) -> Real
```

`dkappa/dT` of the group centred on `nu`: the companion of
[`group_opacity`](#group_opacity), and what the coupling's exact Jacobian needs.

Defaults to the grey Planck-mean derivative, which for the constant-opacity
model is the right answer in every group. Zero unless the law supplies one.

### `group_opacities` {#group_opacities}

Source: [`src/opacity.jl:260`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L260)

```julia
group_opacities(op, groups, rho, T) -> SVec{NG}
```

The opacity in each group, evaluated at the group centres.

With one group this is the grey Planck mean, so a single-group run goes down
exactly the path it did before multigroup existed.

### `group_opacities_dT` {#group_opacities_dT}

Source: [`src/opacity.jl:275`](https://github.com/chongchonghe/Honghu.jl/blob/e6bd095ecb38a1e27e4481cb8bbbcb062ea0ae9a/src/opacity.jl#L275)

```julia
group_opacities_dT(op, groups, rho, T) -> SVec{NG}
```

`dkappa/dT` in each group: [`group_opacities`](#group_opacities) differentiated with respect
to temperature, and the piece [`coupling_jacobian`](coupling.md#coupling_jacobian) needs to be exact.

Zero unless the opacity law supplies a derivative, which is exact for every
temperature-independent law and an approximation for the rest.

