Skip to content

Physical models ​

FLUME solves the conservation laws of compressible flow in the form

∂q∂t+∑d=13∂Fd(q)∂xd=S(q),

with q the conservative state, Fd the flux along direction d and S the sources (GLM/EGLM damping, gravity and self-gravity, cooling, sinks, forcing). This page states the equations and the closures; their discretisation is on the numerical methods page and the keys are in the input reference.

[physics] physical_model (euler, euler-de, mhd-ideal), [physics] passive_scalars, [mhd] divergence_control and [eos] type select one of 13 models. The model fixes the state width nv and selects, on the host, the compute kernels compiled for that width; no kernel branches on the model.

Model[physics] physical_model[mhd] divergence_controlqnv
Compressible Eulereuler—(ρ,ρu,ρv,ρw,E)5
Euler with dual energyeuler-de—Euler + ρs6
Euler, euler-de with passive scalarseuler, euler-de + passive_scalars > 0—+ 4 slots ρsk9, 10
Ideal MHD with mixed GLM cleaningmhd-idealglm(ρ,ρu,ρv,ρw,E,Bx,By,Bz,ψ)9
Ideal MHD with EGLM cleaning (E includes ψ2/2)mhd-idealeglmas GLM9
Ideal MHD without divergence controlmhd-idealnonethe first 8 of the above8
Isothermal or barotropic Eulereuler + [eos] type—as Euler, energy slot inert5
Isothermal or barotropic ideal MHDmhd-ideal + [eos] typeglm, noneas MHD, energy slot inert9, 8

The gas is calorically perfect ([eos] type = ideal, the default) unless [eos] type is isothermal or barotropic, which apply to euler and mhd-ideal without passive scalars only. All models are inviscid by default. Viscosity, heat conduction and Ohmic resistivity (#65) are each given as a coefficient or as its dimensionless number (input). With a viscosity or a conductivity each model is its compressible Navier–Stokes form, and mhd-ideal with a resistivity is resistive MHD (Ohm's law E=−u×B+ηJ; dissipative terms). The subgrid-scale closures of large-eddy simulation are on the turbulence page.

Thermodynamics ​

The gas is defined by the specific heats at constant pressure and volume, [physics] cp, cv (J/(kg K)), or by their ratio alone, [physics] gamma, with the gas constant then 1 (code units):

γ=cpcv,R=cp−cv,p=ρRT,a=γpρ.

Air, the value of most inputs, is cp = 1040.004, cv = 742.86 (γ=1.4). The MHD verification problems use γ=5/3 or 2 (Brio–Wu). R enters only the temperature: the fluxes, eigensystems and Riemann solvers take γ alone.

Compressible Euler ​

∂∂t(ρρuE)+∇⋅(ρuρu⊗u+pI(E+p)u)=0,E=pγ−1+12ρ|u|2.

The flux along direction d (normal n=ed, normal velocity un=u⋅n) is Fd=ρun(1,u,H)+p(0,n,0) with the total specific enthalpy H=(E+p)/ρ.

Eigensystem ​

The characteristic decomposition used by the WENO schemes is written once for every direction: the tangents are taken cyclically, t1=emod(d,3)+1, t2=emod(d+1,3)+1, so a problem rotated from x to y or z runs the same arithmetic on permuted data. With b2=(γ−1)/a2 and b1=b2|u|2/2 the right (rk) and left (lk) eigenvectors are

kλkrklk
1un−a(1, u−an, H−aun)12(b1+un/a, −b2u−n/a, b2)
2un(1, u, |u|2/2)(1−b1, b2u, −b2)
3un(0, t1, u⋅t1)(−u⋅t1, t1, 0)
4un(0, t2, u⋅t2)(−u⋅t2, t2, 0)
5un+a(1, u+an, H+aun)12(b1−un/a, −b2u+n/a, b2)

evaluated at the Roe average of the two cells adjacent to the face (ρ-weighted velocity and enthalpy, a~2=(γ−1)(H~−|u~|2/2)). The unit test test_flume_euler_library checks LR=I, the homogeneity identity LF(q)=ΛLq and the rotation invariance on 10 000 random states in each direction.

Dual energy ​

physical_model = euler-de (#91) adds the advected entropy ρs, s=p/ργ, to the Euler state (nv=6):

∂t(ρs)+∇⋅(ρsu)=0,

a pure conservation law with no gravity source. Once per step each cell compares its internal energy e=E−|ρu|2/(2ρ) with ηE, η = [physics] dual_energy_eta (default 0.05; the cell-local test of Bryan et al. 2014):

  • in a cold cell, e<ηE, the entropy is a floor: e=max(e,es), es=ρsργ−1/(γ−1), and E is rebuilt from it;
  • then, everywhere, ρs follows e.

A cell below its adiabat was drained by the truncation error of the total-energy scheme in a cold supersonic flow, and the floor lifts it back. A cell above its adiabat was heated by a shock, which the advected entropy does not see, and it keeps its energy. The floor only adds energy, and the log reports it per step. A reset of the energy from the entropy, as in Cholla (Villasenor et al. 2021), would remove a cold shock's heat (DE). The runtime-AMR collapse of #88 reaches its end with dual energy (SV-17). Discretisation: numerics.

Passive scalars ​

[physics] passive_scalars = N (#92, 0<N≤4) selects the scalar variant of euler or euler-de: four more conserved variables ρsk, advected with the flow,

∂t(ρsk)+∇⋅(ρsku)=0.

The first N are set by the s1..sN keys of the initial-condition regions and of the inflows, the others are zero. The scalars do not act on the flow: the flow fields of a run with scalars are bitwise those of the same run without them. Discretisation: numerics.

Ideal MHD ​

In code units the magnetic permeability is absorbed into the field, B=BSI/μ0, so the magnetic pressure is |B|2/2 and the fluid variables keep the units of the input (units and scaling):

∂ρ∂t+∇⋅(ρu)=0,∂(ρu)∂t+∇⋅[ρu⊗u+pTI−B⊗B]=0,pT=p+12|B|2,∂E∂t+∇⋅[(E+pT)u−(u⋅B)B]=0,E=pγ−1+12ρ|u|2+12|B|2,∂B∂t+∇⋅(u⊗B−B⊗u)=0,∇⋅B=0.

The flux of Bj along n is unBj−Bnuj, so the Bn component of the flux vanishes identically: without a divergence-control term the normal field is transported only through the transverse fluxes. Every input field (region states, boundary states) is in code units: a field in Tesla must be divided by μ0, a Gaussian one by 4π, by the user.

Wave speeds. Along n the system has seven waves: un±cf (fast), un±cA (Alfvén), un±cs (slow) and un (entropy), with b2=|B|2/ρ, bn2=Bn2/ρ, cA=|bn| and

cf,s2=12(a2+b2±(a2+b2)2−4a2bn2).

FLUME evaluates the discriminant as (a2−b2)2+4a2bt2 (bt2=b2−bn2), a sum of non-negative terms that cannot become negative through round-off when B is aligned with n.

Eigensystem. The 7×7 core is the Roe–Balsara-normalised eigensystem of Stone et al. (2008, ApJS 178, appendix B), evaluated at the arithmetic average of the two face states (a physical state, so the Roe-matrix factors are X=0, Y=1), with Bn as a parameter. The degenerate states are handled explicitly: a vanishing transverse field (|Bt|≤10−12max(|B|,ρa)) and the triple umbilic (cf2−cs2≤10−12cf2). Every three-term sum (|u|2, |B|2, u⋅B) is summed in increasing order of its terms, so the result does not depend on the order of the components and rotated problems stay bitwise equal. The unit test test_flume_mhd_library checks the eigensystem, including the degenerate states.

Divergence control: mixed GLM ​

The induction equation preserves ∇⋅B=0 analytically but not discretely, and a divergence error acts as a spurious force parallel to B. With divergence_control = glm FLUME uses the mixed hyperbolic–parabolic cleaning of Dedner et al. (2002): a ninth variable ψ is coupled to the induction equation,

∂B∂t+∇⋅(u⊗B−B⊗u)+∇ψ=0,∂ψ∂t+ch2∇⋅B=−ch2cp2ψ,

so the Bn flux becomes ψ and the ψ flux ch2Bn: along each direction the pair (Bn,ψ) is a linear system with speeds ∓ch, decoupled from the seven MHD waves. The divergence error travels away at the constant cleaning speed ch and is damped at the rate

ch2cp2=αchL,

with glm_alpha =α and glm_damping_length =L (a length, or min-cell for the minimum cell spacing of the realm, as Mignone & Tzeferacos 2010; with runtime regridding the spacing of the finest level allowed, so that the damping rate does not change with the grid). ψ is not part of the energy (mixed GLM); the damping source is applied to ψ only. ch (glm_ch) is constant and uniform, and it bounds the time step (below). glm_ch_check warns or stops when the fastest wave |un|+cf outruns it. Keep ch just above that speed. Where the discrete div B is not small, as on the sheared flanks of magnetised Rayleigh–Taylor, the discretised cleaning amplifies small asymmetries at a rate that grows with ch. The cleaned equations themselves have no such mode (verification, #83).

The (Bn,ψ) system of one direction is solved exactly at a face by the Riemann solvers of weno-riemann (Dedner et al. 2002, eq. 42):

B~n=12(Bn,L+Bn,R)−ψR−ψL2ch,ψ~=12(ψL+ψR)−ch2(Bn,R−Bn,L).

divergence_control = none drops ψ (nv=8). It is a diagnostic variant: in multi-dimensional runs the divergence error grows unchecked (the magnetised vortex reaches a negative pressure), so production runs use glm.

Divergence control: EGLM ​

In the mixed GLM ψ changes Bn without appearing in the energy, so the change of magnetic energy is taken from the thermal pressure; at very low plasma β this makes the first-order update of high-order stage states inadmissible (the Balsara–Spicer blast fails, issue #47). divergence_control = eglm selects the ideal GLM-MHD of Derigs et al. (2018, eqs. 3.16–3.18), with ψ in field units and part of the energy:

E=pγ−1+ρ|u|22+|B|22+ψ22,

the Bn flux chψ, the ψ flux chBn, the energy flux augmented by chψBn, and the nonconservative sources

−(∇⋅B)(0, B, u⋅B, u, 0)−(u⋅∇ψ)(0, 0, ψ, 0, 1)

in the order (ρ,ρu,E,B,ψ). ∇⋅B and ∇ψ are centred differences of order 2S, the WENO order (second-order sources drop the Alfvén wave to order 2.26). The damping −α(ch/L)ψ uses the GLM keys and acts on ψ only, so the removed cleaning energy becomes heat. Density is conserved exactly; momentum, energy and B up to the O(∇⋅B) sources. In the flux splitting the (Bn,ψ) block has eigenvectors r=(1,∓1) at speeds ∓ch and the energy couples it to the core (r(E)=∓ψ, lk(ψ)=−ψlk(E)), so with ψ=0 the arithmetic of the core is that of GLM. With weno-riemann the (Bn,ψ) subsystem is solved exactly at the face in field units, B~n=12(BnL+BnR)−12(ψR−ψL), ψ~=12(ψL+ψR)−12(BnR−BnL); the Riemann solver sees the MHD states (energy without ψ2/2), and the energy flux gains chψ~B~n plus the cleaning energy carried by the mass flux, Fρψ~2/(2ρup) (a passive scalar, upwind density). Both schemes run EGLM.

Positivity floors ​

[mhd] rho_floor, p_floor (both ≥0; 0 disables) clip density and pressure after each stage, before the ghost exchange, and count the floored cells (global counters in the log). With the floors disabled, a non-positive state stops the run. Independently, every step checks the state for non-finite values and stops the run naming the first one.

Dissipative terms ​

With a viscosity or a conductivity in [physics] (input), Euler becomes the compressible Navier–Stokes system (#65), and so does each MHD model, which also takes an Ohmic resistivity. Each term is the divergence of a flux, added to the inviscid one in direction d:

Gdρui=−τdi,GdE=−uiτdi−k∂T∂xd,τ=μ(∇u+∇uT−23(∇⋅u)I),

with no bulk viscosity (Stokes hypothesis), T=p/(ρR), and the laws μ=μ0(T/Tref)ω, k=k0(T/Tref)ωk (ωk=ω when k comes from the Prandtl number, otherwise 0; the constant law is ω=0), or Sutherland's law μ=μ0(T/Tref)3/2(Tref+S)/(T+S).

Ohmic resistivity (MHD). With the magnetic diffusivity η and J=∇×B (code units), Ohm's law E=−u×B+ηJ in ∂tB=−∇×E and the Poynting flux E×B give

GdBi=−η(∂Bi∂xd−∂Bd∂xi),GdE=η(J×B)d=ηBj(∂Bd∂xj−∂Bj∂xd),

with GdE=∑iBiGdBi, so the field's energy loss is exactly the Ohmic heating η|J|2 that the internal energy receives. The field flux is the curl form, ϵidkηJk, not −η∂dBi: the two differ by η∇(∇⋅B), which is not zero under GLM, and the curl form keeps the resistive term out of the divergence constraint. The decay rate ηk2 is measured by VV-5.

Discretisation: numerics.

Isothermal and barotropic gases ​

[eos] (#100) replaces the ideal gas by a pressure that depends on the density alone, P=P(ρ). The energy equation drops out: the state keeps its Euler or MHD layout, and the energy slot ρE is inert (zero flux, zero source, eigenvalue 0) and stays at its initial 0. The auxiliary fields report p=P(ρ), T=P/ρ (with R=1), a=dP/dρ and H=0.

Isothermal (type = isothermal): P=c02ρ, the sound speed c0 everywhere. In direction n the waves are un−c0, the inert slot (0), un twice (the transverse velocities) and un+c0. The isothermal system has one wave between the acoustic ones, the contact, and it carries only the transverse velocity.

The isothermal Riemann problem is solved exactly with no energy equation: the shock jump u∗=uK∓c0(ρ∗/ρK−1)ρK/ρ∗ on the compressive side, the fan u∗=uK∓c0ln⁡(ρ∗/ρK) on the other. Two streams at Mach M compress to ρ∗=ρM12, M1 the Mach number in the frame of the shock. src/tests/flume/verification/eos/eos_oracle.py builds these solutions independently of the code, and the runs match them (EO).

Barotropic (type = barotropic): a continuous piecewise polytrope,

P=KkρΓk on ρk−1≤ρ<ρk,Kk+1=KkρkΓk−Γk+1,c2=dPdρ=ΓkPρ,

c2 the speed of the Jeans relation. The default table is that of Mathew & Federrath (2021, MNRAS 507, 2448), Γ=1,1.1,1.4,1.1,5/3, in cgs. Where Γ increases upward (a convex break) a rarefaction through the break splits into two fans with a plateau at the break density. Where it decreases, ρc drops and the system is not genuinely nonlinear there, so Riemann solutions crossing it contain composite waves. The schemes (entropy-satisfying fluxes) do not depend on convexity. The exact solver of the verification refuses such a law, and the default table, non-convex at its 1.4→1.1 break, is verified by self-convergence instead (EO barotropic).

Under gravity both gases take the momentum sources of the gamma-law gas, ρg (constant or from the cell potential, self-gravity included), and no energy source. Where the ideal gas reads cs2 or a thermal energy from the energy slot, these gases take them from the equation of state, with cs2=dP/dρ:

  • the Jeans marker's λJ=πcs2/(Gρ);
  • the sinks' threshold density πcs2/(4Gracc2);
  • the sinks' Jeans test |Egrav|>2Eth, with the virial thermal energy Eth=32∫PdV.

The ideal gas keeps its internal energy in the Jeans test; the two agree at γ=5/3. At γ→1 the internal energy ∫P/(γ−1)dV diverges (at γ=1.001 it is a thousand times the virial term), so the test could not pass, and the singular-isothermal-sphere runs of the gamma-law gas keep creation off.

Discretisation (eigensystem, Riemann fluxes, positivity): numerics.

Isothermal and barotropic MHD ​

With physical_model = mhd-ideal the two gases close ideal MHD without an energy equation, with the total pressure P(ρ)+|B|2/2 (Mignone 2007, J. Comput. Phys. 225, 1427, eqs. 1–6). The models keep the MHD layout (ρ,ρu,ρE,B[,ψ]), the energy slot inert. In direction n the six waves un∓cf, un∓ca, un∓cs act on (ρ,ρun,ρut1,ρut2,Bt1,Bt2); there is no entropy mode. The Jacobian holds the gas law only through a2=dP/dρ. The normal field is decoupled at speed 0, or forms the GLM pair (Bn,ψ) at ∓ch.

  • Floors: the [mhd] density and pressure floors are refused, since there is no pressure to floor.
  • Cleaning: GLM is the mixed GLM of the ideal MHD. EGLM is refused: its Derigs sources are built on the energy equation.
  • Gravity: it moves the momentum only, as for the Euler gases.

Discretisation: numerics; verification: EO MHD.

External gravity ​

A constant gravitational acceleration g ([gravity], input; #73) adds sources to every model, with the potential Φ=−g⋅x:

∂t(ρu)+⋯=ρg,∂tE+⋯=ρu⋅g,so that∂t(E+ρΦ)+∇⋅((E+pT+ρΦ)u−…)=0.
  • Momentum: ρig at the cell centre.
  • Energy: from the scheme's own mass fluxes Fρ, never from ρu at the centre (Mikami et al. 2008, Mullen et al. 2021): ∑dgd(−Fi−3/2ρ+13Fi−1/2ρ+13Fi+1/2ρ−Fi+3/2ρ)/24. A face's weights sum to one over the cells it touches, so ∑(E+ρΦ)V changes only by boundary fluxes, to round-off, with periodic boundaries and across block interfaces. The fluxes of a finite-difference scheme are point values of the primitive function of ρu, so the two-face average 12(Fi−1/2ρ+Fi+1/2ρ) is a second-order cell value and takes the whole scheme to second order; the four-face form is fourth order (verification). It reads the face beyond each block end, so it takes one more ghost layer, ngc >= S + 1.
  • Walls: at a wall-inviscid wall along g the source reads the mirrored face beyond the wall, and the exactly conserved total is ∑(E+ρΦ)V±∑gnΔxnρV/12 over the cells beside the wall (+ at the lower wall, − at the upper), which differs from the plain sum by O(Δx2).
  • Positivity limiter: the backbone carries the time-centred energy ρg⋅(u+gΔt/2), which leaves its internal energy unchanged, and the high-order excess of the source is limited with the fluxes by the cell factor Λ. Gravity never makes the backbone inadmissible (near vacuum, or with gΔt above the sound speed), and E+ρΦ stays exact wherever the limiter does not act.
  • Time step: no bound of its own. The first step logs |g|Δt2/(CFLhmin), at least the velocity gravity adds in a step over the fastest wave speed; near 1 or above, gravity is stiff.
  • Boundary: hydrostatic faces continue the isothermal equilibrium of the boundary cell into the ghosts.
  • Well-balanced mode ([gravity] equilibrium = atmosphere): the residual of the initial atmosphere at rest is computed with the run's own space operator once per grid (at the first step, after a restart, after every regrid) and subtracted from every residual (the deviation method of Edelmann et al. 2021, §4.3). The atmosphere is then an exact discrete steady state, on weno and weno-riemann, Euler and MHD, across 2:1 seams (the equilibrium's reflux is folded into its residual), and the scheme evolves the deviation from it. Without it a stratified atmosphere at rest drives a stationary flow of the truncation error's size (verification). It costs one more field and one residual evaluation per grid. The subtracted residual is outside the limiter's factor: it is the truncation error of the equilibrium, small against the state wherever the atmosphere is resolved.
  • Through a cell potential ([gravity] potential = linear, #81): the same field as the cell potential Φi=−g⋅xi, applied by the path self-gravity uses. The face gravity is −(Φi+1−Φi)/Δx, the cell gravity the mean of its two faces; the momentum gains ρi times the cell gravity, the energy 12∑d(gd,i+1/2Fi+1/2ρ+gd,i−1/2Fi−1/2ρ). That is the face form, second order, and ∑(E+ρΦ)V is conserved without a wall term. The hydrostatic ghosts take the potential drop, and the limiter the face and cell gravity. It is a test of that path (SV-1).

The equilibria FLUME builds are the isothermal-atmosphere, polytropic-atmosphere and rayleigh-taylor initial conditions (initial conditions).

Self-gravity ​

[gravity] self_gravity (#81) adds the gravity of the gas itself:

∇2Φ=4πG(ρ−ρ¯),∂t(ρu)+=−ρ∇Φ,∂tE+=−ρu⋅∇Φ,

with the mean density removed on a periodic domain (the Jeans swindle), or Φ→0 at infinity with isolated boundaries (poisson_bc = isolated). The discretisation is that of Mullen et al. (2021): Φ solves LhΦ=4πG(ρ−ρ¯) (periodic) or LhΦ=4πGρ (isolated) with the 7-point Laplacian (5-point in 2-D, periodic only), and enters through the potential path above (face gravity, cell gravity, the energy from the face mass fluxes). A constant g may be given too; it adds through its own kernels.

What is conserved, and why. The solvers are linear and symmetric, Φ=4πGKρ with K=KT (VK symmetric on AMR, below): the periodic one inverts Lh on the zero-mean modes, the isolated one convolves with an even kernel. Summed over the cells, the energy source is ∑iΦi(∇⋅Fρ)iV=−∑Φρ˙V, and W˙=12ddt(ρTKρ)=ΦTρ˙ because K is symmetric: the semi-discrete scheme conserves E+W, W=12∑ρΦV, exactly (with periodic boundaries or closed walls, where no mass flux crosses the boundary). The momentum source −∑ρg¯V vanishes because the centred difference of an even, translation-invariant kernel is antisymmetric. Neither needs the discrete Poisson equation to hold at round-off (the isolated residual is about 10−11); the symmetry is what counts. That holds exactly for the FFT solvers, which are fixed linear maps. The multigrid solver on AMR stops at a tolerance, so its K is symmetric, and E+W exact, only to that tolerance: the defect measured in situ is 1.7⋅10−11 at a tolerance of 10−12 (SV-13), the point Mullen et al. make (round-off conservation needs a round-off Poisson solution). The Runge–Kutta integration (one solve per stage, nothing time-averaged) leaves a drift of its own order in Δt; the positivity limiter's gravity energy correction (above) breaks the exchange wherever it acts.

The coupling is second order in space whatever the WENO order. A linear Jeans mode obeys ω2=c2k2−4πGρ0: a wavelength shorter than the Jeans length λJ=cπ/(Gρ0) oscillates, a longer one grows; an n = 1 polytrope star is an isolated equilibrium (verification).

Solvers. Every Runge–Kutta stage solves Φ from that stage's density, after the ghost update. poisson_solver = auto takes the FFT solver on a uniform grid and the multigrid solver on an AMR grid.

  • FFT (FFTW on the CPU, cuFFT on FNL; the *-fft build modes): distributed over the z-planes of the transform array, bitwise the same on every rank count, with Φ returned with every ghost layer filled. Periodic: each Fourier mode is divided by the eigenvalue of Lh, so the discrete residual is round-off. Isolated: the density sits in a zero-padded array of 2(N+ngc) cells per direction and is convolved with the lattice Green's function of Lh (Hockney–Eastwood), whose residual is about 10−13 per offset (scripts/lattice_green.py); the residual of Φ is that summed over the source, 2⋅10−11 of 4πGρ at 643, and the ghosts beyond the domain hold the free-space potential. On FNL the slab transform runs on each rank's GPU (adam_fnl_poisson_fft_object): cuFFT plane and line plans, the transposes packed on the device and exchanged by MPI_ALLTOALLV on device buffers (GPU-aware MPI, as the ghost exchange). The density and Φ cross the host every stage: the backend hands the solver a host copy of the density and gets Φ back on the host (solve_potential_gpu).
  • Multigrid (adam_poisson_mg_object): the composite Laplacian of the AMR leaves, flexible CG preconditioned by a V-cycle, its coarsest level solved by the FFT solver of the backend. On FNL (adam_fnl_poisson_mg_object) the FCG iteration and the V-cycle run on the device: the operators and work vectors stay there, the red-black Gauss–Seidel smoother runs one kernel per colour, the halo exchange is GPU-aware MPI_ALLTOALLV. The right-hand side, the coarsest level (through the host to cuFFT), the James step and the ghost fill's placement go through the host, and the potential returns to the host after each solve. On a uniform grid poisson_solver = multigrid is a check against fft; isolated boundaries use the symmetric James step (#87).

On AMR grids the composite Laplacian carries a mimetic mean flux across each 2:1 face, symmetric in the volume-weighted form and consistent (SV-9). The face gravity there is first order, the potential second order. The gravity work across each seam rides on the reflux, so E+W stays exact in the semi-discrete form; the fully discrete drift is first order in Δt with reflux_cadence = step and of the Runge–Kutta order with stage (SV-10). A runtime regrid changes W by a truncation-sized amount (SV-11). Isolated boundaries on AMR need every boundary leaf at the coarsest level. The derivation is on the developer page ghost fill and AMR gravity.

Limiter. With positivity_limiter = cell the limiter's gravity energy correction acts on the potential path too, so E+W stays exact only where the limiter does not act. A star in a light atmosphere (10−4 of its central density) needs the limiter at its surface and drifts by 2⋅10−3 of E+W over a free-fall time at 323, against 10−9 without it.

Log. The first step logs G, the free-fall time tff=3π/(32Gρmax) of the densest cell, Δt/tff (a warning above 0.1) and the wall time of one solve. The conservation history gains W=12∑ρΦdV and E_plus_W, the energy the scheme conserves.

Radiative cooling ​

[cooling] (#93) adds optically thin cooling to the hydrodynamic models,

∂t(ρe)=−n2Λ(T),n=ρ/m,T=p/(ρR),

at fixed ρ and ρu, with E lowered by the energy removed. Λ is the piecewise power law through the nodes (Tk,Λk), Λk(T/Tk)αk on [Tk,Tk+1]; above TN the last segment continues. T1 is a floor: below it nothing cools, and there is no heating.

With euler-de a cooled cell takes the entropy of its cooled energy, ρs=(γ−1)eρ1−γ: radiation lowers the entropy for real, and an entropy left on the old adiabat would let the next dual-energy floor lift a cold cooled cell back to it and undo the cooling.

The cooling itself is integrated exactly, so it sets no limit on the step. [cooling] dt_factor (default off) limits the step to dt_factor times the shortest cooling time tcool=ρe/(n2Λ), for runs that need the coupling with the dynamics resolved. The radiated energy is summed over the ranks; the conservation history adds it back to E (E_plus_radiated, constant to round-off). Discretisation: numerics.

Sink particles ​

[sinks] (#94) adds point masses that act on the gas through self-gravity only. It needs self-gravity and a hydrodynamic model.

Gravity. Each sink's mass is added to the density the Poisson solver sees, so the periodic and isolated boundaries and the AMR composite operator apply to the sinks as to the gas, and W=12∑ρtotΦdV includes them. A sink feels the gradient of Φ at its position. Through the mesh the sink gravity is softened at about two cells.

Creation (creation = .true.). Once per step a cell of the finest level present (with runtime regridding, of the finest level allowed) forms a sink when all of these hold, after Federrath et al. (2010):

  • its density exceeds ρthr=πcs2/(4Gracc2), with cs2=γp/ρ of the cell: a Jeans length of 2racc, racc = accretion_radius_cells cells;
  • no sink lies within racc;
  • the cell is a minimum of the potential over its control volume, the cells within racc (ties allowed: the 8 cells around a symmetric centre all qualify);
  • the flow converges along every principal axis (the symmetric velocity gradient is negative definite);
  • the volume is Jeans-unstable, |Egrav|>2Eth, with Egrav summed over the pairs of its cells;
  • the volume is bound, Egrav+Eth+Ekin<0, the kinetic energy relative to its centre of mass.

The candidates of every rank are taken deepest potential first, one per accretion radius. A static box above the threshold is not enough: at γ=1.4 a control volume at the threshold is Jeans-stable, |Egrav|/2Eth≈π2γ(γ−1)/10=0.55. Gas that compresses adiabatically with γ>4/3 never crosses the threshold (ρthr∝cs2 grows with ρ at γ=2): collapse needs cooling.

Accretion (accretion = .true.). A new sink has no mass. Every sink then takes, once per step, the gas above the threshold from the cells within its radius that is bound to it and falls in (12|u−vs|2−Gms/r<0, (u−vs)⋅(x−xs)<0), plus the cell that holds it and every cell of a new sink without the checks. A cell within several radii gives its gas to the most bound sink. The cell keeps its specific values: every conservative variable is scaled by ρthr/ρ (velocity, specific energy, passive scalars; the dual-energy entropy is rebuilt from the energy). The sink gains the mass and the momentum and moves to the centre of mass, so accretion conserves mass and momentum exactly.

Mergers (merging = .true.). Two sinks within an accretion radius that are bound and converging (12μ|Δv|2−Gm1m2/d<0, Δv⋅Δx<0) merge at their centre of mass, with their mass, momentum and mass-weighted acceleration (the pair's mutual pull cancels in it).

Runtime AMR. With runtime regridding ([amr] frequency > 0) the sinks live on the finest level allowed ([amr] max_level), as in Federrath et al. (2010): they form only there, and racc is in cells of that level for the whole run. At every regrid a block within racc+12frequency$ + 2$ cells of a sink (its accretion radius, the half cell a sink may move per step until the next regrid, its CIC stencil) is refined towards that level and never derefined, whatever the other markers vote. A sink formed on a coarser level would have its neighbourhood refined at the next regrid: the infall onto it prolongated and its threshold quadrupled from one step to the next. A collapse on runtime AMR needs regrid_prolongation = conservative-state (#88).

Discretisation (deposit, time stepping, backends): numerics.

Units and scaling ​

The equations above carry no dimensionless number. Take three references, a density ρ0, a length L0 and a velocity u0, and derive the others:

QuantityReference
timet0=L0/u0
pressure, energy densityp0=ρ0u02
magnetic field (BSI/μ0)B0=u0ρ0
GLM speed chu0
ψ, mixed GLMB0u0
ψ, EGLMB0
temperatureu02/R (R∗=1)

Dividing every variable by its reference, every term of the Euler and MHD systems, the GLM and EGLM terms and the GLM damping αch/L included, picks up the same factor, which cancels: the equations in the scaled variables are the same equations (Goedbloed & Poedts 2004, section 4.1.2). A run in SI, in cgs or in units of order 1 is the same run. PLUTO, Athena++, MPI-AMRVAC, BATS-R-US, FLASH and RAMSES solve the same μ0-absorbed form and treat units as a conversion.

What the invariance does not remove:

  • The parameters move into the data. The Mach number, the Alfvén Mach number and the plasma β live in the initial and boundary states; one reference speed can set only one of the flow, sound and Alfvén speeds to 1.
  • The temperature needs R, and later a reference temperature, once conduction, cooling or a temperature-dependent resistivity exist.
  • Gravity is not free: an external field brings gL0/u02=1/Fr2 (above), self-gravity Gρ0L02/u02 (#81); the dissipative terms bring the Reynolds, Prandtl, magnetic Reynolds and Lundquist numbers, each accepted in place of its coefficient (input).
  • The discrete scheme must be scale-free too. FLUME's is, apart from the classic WENO weights: their absolute ε stops the limiting at small magnitudes (numerics). With [weno] weights = si a run whose input is scaled by powers of two (lengths, velocities, density) equals the base run bit for bit (the scaling oracle, NV-4); the admissibility floor of the positivity limiter and the immersed-boundary cut spacing are relative.

FLUME uses the invariance in two ways. An input in physical units can carry a [reference] section: the values are divided by their references once, on the loaded file, and the solver runs on numbers of order 1, whatever the weights; output_units = dimensional writes the results back in the input units. Or the input runs as it is with weights = si. On Sod at an interstellar density both match the code-units run to 10−13, where the classic weights without the layer stop limiting (NV-6).

Time-step bound ​

The time step is the minimum over the realm of

Δt=CFLmaxcells∑d|ud|+cdΔxd,

with cd=a (Euler) or the fast speed along d (MHD), null directions excluded ([time] CFL). With GLM the cleaning waves add the bound Δt≤CFL/(chmax∑d1/Δxd). With dissipative terms each cell sum gains the diffusive part 2ν∑d1/Δxd2 (numerics).

Derived output fields ​

With [IO] save_auxiliary_fields = .true. the checkpoints also hold ρ,u,v,w,p,T,H,a (plus the specific entropy s with dual energy and the passive scalars s1..s4); MHD adds the copies Bx, By, Bz, the total pressure pt =pT, the plasma beta beta, the field magnitude bmag and the discrete divergence divb. Their exact definitions are on the input reference page.

References ​

  • Bryan G. L. et al. (2014), ENZO: an adaptive mesh refinement code for astrophysics, ApJS 211, 19, doi:10.1088/0067-0049/211/2/19.
  • Dedner A. et al. (2002), Hyperbolic divergence cleaning for the MHD equations, J. Comput. Phys. 175, 645–673.
  • Derigs D. et al. (2018), Ideal GLM-MHD: about the entropy consistent nine-wave magnetic field divergence diminishing ideal MHD equations, J. Comput. Phys. 364, 420–467.
  • Edelmann P. V. F. et al. (2021), Well-balanced treatment of gravity in astrophysical fluid dynamics simulations at low Mach numbers, Astron. Astrophys. 652, A53, doi:10.1051/0004-6361/202140653.
  • Federrath C., Banerjee R., Clark P. C., Klessen R. S. (2010), Modeling collapse and accretion in turbulent gas clouds: implementation and comparison of sink particles in AMR and SPH, ApJ 713, 269–290, doi:10.1088/0004-637X/713/1/269.
  • Goedbloed J. P., Poedts S. (2004), Principles of Magnetohydrodynamics, Cambridge University Press.
  • Hockney R. W., Eastwood J. W. (1988), Computer Simulation Using Particles, Adam Hilger, Bristol.
  • Mathew S. S., Federrath C. (2021), MNRAS 507, 2448.
  • Mignone A. (2007), A simple and accurate Riemann solver for isothermal MHD, J. Comput. Phys. 225, 1427–1441.
  • Mignone A., Tzeferacos P. (2010), A second-order unsplit Godunov scheme for cell-centered MHD: the CTU-GLM scheme, J. Comput. Phys. 229, 2117–2138.
  • Mikami H., Sato Y., Matsumoto T., Hanawa T. (2008), Astrophys. J. 683, 357, doi:10.1086/589759.
  • Mullen P. D., Hanawa T., Gammie C. F. (2021), An extension of the Athena++ framework for fully conservative self-gravitating hydrodynamics, Astrophys. J. Suppl. 252, 30, doi:10.3847/1538-4365/abcfbd.
  • Stone J. M. et al. (2008), Athena: a new code for astrophysical MHD, ApJS 178, 137–177.
  • Toro E. F. (2009), Riemann Solvers and Numerical Methods for Fluid Dynamics, 3rd ed., Springer.
  • Villasenor B., Robertson B., Madau P., Schneider E. (2021), Effects of photoionization and photoheating on Lyman-α forest properties from Cholla cosmological simulations, ApJ 912, 138, doi:10.3847/1538-4357/abed5a.