Radiation transport
Markdown: this page · all pages in one file
Docstrings from src/radiation_system.jl, src/riemann_radiation.jl, src/planck.jl, src/opacity.jl.
Exported
RadiationPhysics
Source: src/radiation_system.jl:4
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. Usingchat < crelaxes 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 achat_limiterother than the default this is the nominal reductionphi0 c: a floor on the localchatand the speed the time step is still set from, not the speed every cell runs at.chat_limiter: anAbstractChatLimitermaking the reduced speed of light local. The default,ConstantChat, is the standard RSLA and a bit-for-bit no-op;StabilityBoundis the improved RSLA, which raiseschattowardscin 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 constant4σ/c, so that the equilibrium radiation energy density isa_rad T⁴.opacity: anAbstractOpacity.groups: aRadiationGroups. The default,GREY, is the single group spanning every frequency, and reproduces grey radiation exactly;ngroups > 1puts 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 intox = energy_unit * edge / (k_B T)for the Planck fractions, so it matters only when the group edges are in physical units – passCGS.k_Balongsideenergy_unit = CGS.h_planckfor edges in Hz. A grey run computes no fractions and never reads it, and unit-free edges given directly in units ofk_B Twant the default1; 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 whenngroups > 1, anAbstractCoupling–BracketedCoupling(the default, allocation-free),QuokkaCouplingorAdaptiveCoupling. A grey run ignores it and usesradiation_source_step!’s own 2×2 Newton driver.dust: anAbstractDustModel.NoDust, the default, couples the radiation to the gas.BateKetoDustcouples it to dust at its own temperature instead, and the dust to the gas by collisions; theopacityis then the dust’s, the gas has none, andcouplingmust beBracketedCoupling. A grey run with dust goes through the multigroup driver, which handles one group unchanged.closure:LevermoreClosure(the M1 default) orEddingtonClosure, which fixeschi = 1/3. Use the latter only to reproduce reference solutions derived under the P1 approximation; it cannot free-stream.beta_order:1keeps theO(v/c)terms in the matter-radiation coupling (radiation force, work, and the comoving-frame corrections);0drops them, which is appropriate only for a static medium.tolerance,max_iterations,max_outer_iterations: controls of the implicit coupling solve (seeradiation_source_step!).wavespeed_correction = false: scale the HLL dissipation of the radiation energy at each face byepsilon = min(1, 1/tau), withtauthe 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 dissipationsigma chat (E_R - E_L)/2is a numerical diffusion far faster than the physical one,c/(3 tau); the correction removes it. Allowed with the standard RSLA only: with a localchat_limiterthe 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 atphi = 1behind 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
Source: src/radiation_system.jl:143
ngroups(phys) -> IntThe 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
ngroups(groups) -> IntHow many frequency groups. A compile-time constant, so kernels specialise on it.
LevermoreClosure
Source: src/riemann_radiation.jl:25
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
Source: src/riemann_radiation.jl:35
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
Source: src/planck.jl:16
planck_integral(x) -> RealThe 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
Source: src/planck.jl:57
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
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
Source: src/planck.jl:147
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
Source: src/opacity.jl:80
ConstantOpacity(kappa)
ConstantOpacity(; planck, energy = planck, flux = planck)Opacity independent of density and temperature.
PowerLawOpacity
Source: src/opacity.jl:103
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
Source: src/opacity.jl:139
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).
FrequencyOpacity
Source: src/opacity.jl:206
FrequencyOpacity(f; grey = nothing, dkappa_dT = nothing, dgrey_dT = nothing)Opacity from a callable f(nu, rho, T) -> kappa, evaluated at each group centre.
# 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).
Internals
nradvars
Source: src/radiation_system.jl:151
nradvars(phys) -> IntLength of the radiation state vector, 4 * ngroups: an energy density and three flux components per group.
gbase
Source: src/radiation_system.jl:159
gbase(g) -> IntIndex 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
Source: src/radiation_system.jl:173
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! does, leaves the energy as it was and passes the flux through (F / cE) cE.
enforce_rad_floors!
Source: src/radiation_system.jl:219
enforce_rad_floors!(R, phys, grid, floors) -> IntProject the radiation state onto the admissible set of the M1 closure over the whole array, ghost cells included (see amend_rad). Returns the number of cells repaired.
The radiation counterpart of enforce_floors!, and separate from rad_cons2prim! for the same reason.
amend_rad_state!
Source: src/radiation_system.jl:235
amend_rad_state!(R, phys, grid, floors) -> IntRepair 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!). 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!
Source: src/radiation_system.jl:250
floor_rad_energy!(R, U, chat, phys, grid, floors; bfield = nothing) -> IntHand 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!, runs after the solve.
rad_cons2prim!
Source: src/radiation_system.jl:342
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! for why. Run enforce_rad_floors! first if the state may be inadmissible — on an admissible state the reduced flux this computes automatically satisfies |f| < 1.
rad_fluxes!
Source: src/radiation_system.jl:375
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!), or nothing. An array is passed under the standard RSLA and in the flux form of a local limiter (see 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! 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!
Source: src/radiation_system.jl:478
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).
radiation_timestep
Source: src/radiation_system.jl:503
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
Source: src/radiation_system.jl:525
_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
Source: src/radiation_system.jl:551
_signal_sum(closure, R, i, j, k, g, c, inv3) -> sum_d sigma_d / dx_dThe 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 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!
Source: src/radiation_system.jl:590
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.
update_chat!
Source: src/radiation_system.jl:618
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 loses its cap K_F.
A 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
Source: src/radiation_system.jl:672
_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: 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
Source: src/radiation_system.jl:761
energy_exchange_dt(U, R, eos, phys, grid, xi, floors; bfield = nothing) -> dtThe 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
Source: src/riemann_radiation.jl:17
AbstractClosureSupertype for the closure that supplies the Eddington factor chi(f): LevermoreClosure or EddingtonClosure.
eddington_factor
Source: src/riemann_radiation.jl:48
eddington_factor([closure = LevermoreClosure()], f)Eddington factor for the reduced flux f = |F| / (c E).
EddingtonTensor
Source: src/riemann_radiation.jl:63
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
Source: src/riemann_radiation.jl:75
eddington_tensor([closure = LevermoreClosure()], fx, fy, fz) -> EddingtonTensorBuild the Eddington tensor from the reduced flux vector.
m1_flux
Source: src/riemann_radiation.jl:95
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
Source: src/riemann_radiation.jl:112
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
Source: src/planck.jl:119
The single group spanning all frequencies, which reproduces grey radiation.
group_centers
Source: src/planck.jl:129
group_centers(groups) -> SVecThe 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
Source: src/planck.jl:173
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
Source: src/opacity.jl:9
AbstractOpacitySupertype for opacity laws. A concrete subtype must implement
planck_opacity(op, rho, T)energy_mean_opacity(op, rho, T)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(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
Source: src/opacity.jl:28
planck_opacity(op, rho, T) -> kappa_PThe 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 interface.
energy_mean_opacity
Source: src/opacity.jl:37
energy_mean_opacity(op, rho, T) -> kappa_EThe 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 interface.
flux_mean_opacity
Source: src/opacity.jl:46
flux_mean_opacity(op, rho, T) -> kappa_FThe 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 interface.
dkappa_dT
Source: src/opacity.jl:55
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
Source: src/opacity.jl:182
group_opacity(op, nu, rho, T) -> RealThe 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.
group_opacity_dT
Source: src/opacity.jl:194
group_opacity_dT(op, nu, rho, T) -> Realdkappa/dT of the group centred on nu: the companion of 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
Source: src/opacity.jl:260
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
Source: src/opacity.jl:275
group_opacities_dT(op, groups, rho, T) -> SVec{NG}dkappa/dT in each group: group_opacities differentiated with respect to temperature, and the piece 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.