Skip to content

The gravity force ​

IDGroupMilestoneBackendsFigureRegression
GV-1, GV-2, GV-3, GV-6, GV-7 (G1)External gravityM7 (#73)CPU, FNLyes—

Case and scope ​

G1 adds the gravity sources: momentum ρg, and the energy from the face mass fluxes. Three properties must hold by construction and are checked to round-off; a fourth is about robustness:

  • free fall is exact (GV-1): a uniform gas in a periodic box falls freely, ρu=ρgt, E=E0+ρg2t2/2, ρ unchanged. A momentum or energy source with a wrong weight fails it;
  • a closed box conserves its mass and total energy (GV-3): the gas falls onto the floor and sloshes; mass and E+ρΦ (Φ=−g⋅x; since G2a the invariant W, see below) stay constant while E alone exchanges with ρΦ. A cell-centred energy source ρu⋅g would fail it;
  • scaling covariance (GV-6): the run with the scale-invariant WENO weights is the same run in other units, bit for bit, as #49 established without gravity;
  • the positivity limiter keeps the run alive where the gas falls toward vacuum (box2d-lim, box2d-stiff).

GV-2 reports the spurious flow of the unbalanced scheme on an atmosphere at rest, the baseline of the well-balanced mode; GV-7 compares the backends.

Models and numerics ​

ItemChoiceCode
Equationscompressible Euler, ideal gas, γ=1.4; box2d-mhd: ideal MHD with EGLM (glm_ch = 3, glm_alpha = 0.18, glm_damping_length = 1)models, EGLM
Momentum sourceρig at the cell centreadd_gravity_sources, adam_flume_cpu_object.F90; add_gravity_sources_dev, adam_flume_fnl_kernels.F90
Energy sourceG1: the face form 12∑dgd(Fd,i−1/2ρ+Fd,i+1/2ρ) from the mass fluxes of the continuity equation (Mikami et al. 2008, Mullen et al. 2021); since G2a plus its fourth-order correction (energy order)add_gravity_sources, compute_gravity_correction, adam_flume_cpu_object.F90
Positivity limiter (option B)positivity_limiter = cell (box2d-lim, box2d-stiff, box2d-mhd): the backbone takes ρg and the time-centred energy ρg⋅(u+gΔt/2); the face-form excess is limited by Λcompute_positivity_factors, adam_flume_cpu_positivity_kernels_agnostic.INC; add_gravity_limited_correction, limit_positivity, adam_flume_cpu_object.F90; numerics
Input checksa gravity component along a null direction and immersed solids are refused; the stiffness $\mathbf g
SpaceWENO5 (weno-u-5) flux splitting on characteristic variables (weno); GV-6 with weights = sicompute_residuals_weno, adam_flume_cpu_object.F90; numerics
TimeSSP Runge–Kutta, 3 stages (runge-kutta-ssp-33), CFL 0.4adam_rk_object.F90
Boundariesperiodic; wall-inviscid (mirrored ghosts); hydrostatic (GV-2)set_boundary_conditions, adam_flume_cpu_object.F90; adam_flume_bc_object.F90; boundary conditions
FNL backendthe same kernels on the deviceadam_flume_fnl_object.F90, adam_flume_fnl_kernels.F90

Initial and boundary conditions ​

Common to every leg: [0,1]2, quadtree, 4×4 blocks of 82 cells (N=32) unless stated, two uniform levels, ngc = 4, null z (extrapolation), np 2, CFL 0.4, γ=1.4. The G1 cases start from the uniform state ρ=1, p=1 at rest under g=(0,−1).

LegCaseStatex facesy facesRun
GV-1freefall2duniformperiodicperiodic50 steps
GV-3box2duniformperiodicwall-inviscid200 steps
GV-3box2d-mhduniform, EGLM, B=(0.5,0,0), limiter onperiodicwall-inviscid200 steps
limiterbox2d-limp=0.05, limiter onperiodicwall-inviscid300 steps
limiterbox2d-stiffp=10−3, limiter on (gΔt≈4.5c)periodicwall-inviscid200 steps
GV-2iso2d with the forceisothermal atmosphere, ρ1=p1=1 at the originperiodichydrostaticto t=0.5, N=32,64,128 (8, 16, 32 cells per block)
GV-6box2d, weights = siuniformperiodicwall-inviscid100 steps, against its input rescaled: lengths by 22, velocities by 2−1, density by 4−2
GV-7box2d, box2d-mhd on FNLas aboveas above

Checkpoints every 10 steps (GV-3 asserts every one of them).

Input files ​

FileRole
src/tests/flume/verification/gravity/make_atmosphere.pywrites each case (freefall2d, box2d, box2d-mhd, box2d-lim, box2d-stiff, iso2d; --cells, --cfl, --time-max, --weights, --steps)
src/tests/flume/verification/gravity/check.shruns the legs (--legs LIST, e.g. gv1,gv3,limiter,gv2; the force legs unless --no-force; --scaling adds gv6 (GV-6); --agree TAG for GV-7, which needs the legs gv3, gv8, gv10, gv4c; --keep)
src/tests/flume/verification/gravity/atmosphere_oracle.pyfreefall (GV-1, 10−12), energy (GV-3, 10−12; --report-total for the limiter cases), rest (GV-2), agree (GV-7, 10−10)
src/tests/flume/verification/scaling/scaling.pyGV-6: rescale --j 2 --k -1 --m -2 and compare
src/tests/flume/verification/make_doc_runs.sh (group gravity)re-runs freefall2d, box2d, box2d-mhd with their checkpoints
src/tests/flume/verification/make_doc_figures.py (fig_gravity_force)draws the figure
bash
cd src/tests/flume/verification/gravity
./check.sh --np 2 --cases iso2d --scaling --keep                         # CPU: G0 iso2d, the force legs, GV-6
FLUME_EXE=$PWD/../../../../../exe/adam_flume_fnl ./check.sh --np 2 --cases iso2d --keep \
   --agree adam_flume_cpu                                                # FNL, and GV-7 against the CPU runs

Results ​

GV (G1): free fall, the energy budget of the closed boxes and the settled box2d

Left, GV-1 free fall; centre, the GV-3 energy budget over the whole run; right, box2d settled after 200 steps.

Drawn with the current scheme (G2a's fourth-order energy source). Left, GV-1: the momentum of the periodic box follows ρgt, with a pointwise error of one or two units in the last place. Centre, GV-3 over the whole run: the mass and W stay at round-off, while the plain E+ρΦ drifts to 3⋅10−5 (box2d) through the O(Δx2) wall-row term of G2a; E alone (not drawn) exchanges 3.8 per cent with ρΦ. Right, box2d after 200 steps: the uniform gas has settled into a stratification, ρ from 1.58 at the floor to 0.42 under the lid.

As measured at G1 (the face-form energy source; CPU, FNL the same by GV-7):

LegAssertedBoundCPUFNL
GV-1ρ, ρu, E against the exact free fall10−12ρ exact, ρu 2.2⋅10−16, E 5.6⋅10−16the same
GV-3 box2dmass and E+ρΦ constant at every checkpoint10−12mass 1.1⋅10−14, E+ρΦ 1.3⋅10−14 (E alone moves 3.8⋅10−2)the same
GV-3 box2d-mhdas above10−128.4⋅10−15, 7.5⋅10−15 (E 1.8⋅10−2)the same
box2d-limcompletes, mass conserved; E+ρΦ reported10−12 (mass)74 304 faces limited, no inadmissible backbone, mass 1.0⋅10−14, E+ρΦ 4.4⋅10−7the same
box2d-stiffas above10−12 (mass)324 424 faces limited, 32 inadmissible backbones, mass 1.2⋅10−14, E+ρΦ 1.6⋅10−2the same
GV-2$\max\mathbf u/c$ at N=32,64,128, reported—
GV-6weights = si against the rescaled inputbitwisebitwisebitwise
GV-7FNL against CPU, per field10−10—box2d ≤9.3⋅10−14, box2d-mhd ≤9.3⋅10−14

GV-7 scales a vector component by its vector's largest component: ρu is zero by symmetry and holds round-off only. GV-2 runs a mild stratification (scale height 1 on the unit box).

Re-measured with the fourth-order energy source of G2a (the current scheme; CPU and FNL):

LegAssertedBoundCPU and FNL
GV-1as above10−12unchanged (uniform state: the correction is zero)
GV-3 box2dmass and W10−12mass 7.7⋅10−15, W 7.7⋅10−15 (the plain E+ρΦ 3.3⋅10−5, the wall term)
GV-3 box2d-mhdmass and W10−121.2⋅10−14, 6.1⋅10−15 (plain sum 1.6⋅10−5)
box2d-limcompletes, mass conserved; W reported10−12 (mass)107 984 faces limited (the correction is a high-order cell source inside Λ), no inadmissible backbone, mass 9.4⋅10−15, W 1.2⋅10−6 (limited cells only)
box2d-stiffas above10−12 (mass)runs, mass 1.2⋅10−14
GV-2reported—unchanged
GV-6, NV-5bitwisebitwisebitwise
GV-7FNL against CPU, per field10−10≤7.9⋅10−14

Related cases: the order of the energy source (G2a, the correction and the invariant W); the well-balanced mode removes the GV-2 flow; positivity limiter and scaling covariance without gravity; the same box through the potential path of self-gravity in SV-1.

Findings ​

  • The total energy. With the face-form energy source the conserved total is E+ρΦ to round-off at every checkpoint, while E alone moves by per cent. Since G2a the exactly conserved total at reflecting walls is W, E+ρΦ plus an O(Δx2) wall-row term (energy order); GV-3 asserts W and reports the plain sum.
  • The limiter and gravity (owner decision: option B). The first form put the face-form energy into the backbone. A cell beside a wall then gets half of the face form (the wall face carries no mass) while its momentum gains the whole ρgΔt: the stage takes about 12ρ|u||g|Δt out of its internal energy, which near vacuum is negative. box2d-lim died at step 128 and box2d-stiff at step 1 (every backbone inadmissible), with and without the limiter. Option B gives the backbone the time-centred energy ρg⋅(u+gΔt/2), which leaves its internal energy unchanged, and limits the face-form excess with Λ; both cases then run. The stiff case's 32 inadmissible backbones come from the fluxes, not from gravity.
  • In the limited cases E+ρΦ (since G2a W) is exact only where the limiter does not act; it is reported, not asserted.
  • box2d-stiff is the stiff regime: gΔt is about 4.5 times the sound speed. No time-step bound is imposed for gravity; the regime is logged at the first step.
  • GV-2 is the unbalanced baseline of the well-balanced mode: the spurious Mach number of an atmosphere at rest falls with N but is not zero.