Skip to content

Gravity from a cell potential ​

IDGroupMilestoneBackendsFigureRegression
SV-1Self-gravityM8 (#81), P1CPU, FNLyes—

Case and scope ​

Self-gravity applies gravity through a cell potential Φ. That path must be right before a Poisson solver feeds it: add_potential_sources (face gravity −∂Φ/∂x, cell gravity the mean of the cell's two faces, momentum ρ times the cell gravity, energy from the face mass fluxes times the face gravity), the face and cell gravity in the positivity limiter, and the hydrostatic ghost from the potential drop −(Φghost−Φ1).

[gravity] potential = linear writes the constant g of M7 as Φ=−g⋅x and applies it through that path alone (the constant-g kernels get zero), so the M7 oracles apply unchanged.

What the case catches:

  • a wrong sign, spacing or face average in the potential sources: the free fall and the hydrostatic ghosts miss their exact values;
  • an energy source that is not the telescoping face form: the closed box loses E+ρΦ;
  • a change of the constant-g path: that path must stay bitwise as before, which the regression suite holds.

Models and numerics ​

ItemChoiceCode
Equationscompressible Euler, ideal gas, γ=1.4; iso2d-mhd, box2d-mhd: ideal MHD with EGLM cleaning (glm_ch 3, glm_alpha 0.18, glm_damping_length 1)models
Gravity[gravity] potential = linear: Φ=−g⋅x at the cell centres, ghosts includedset_potential, adam_flume_common_object.F90; load_from_file, adam_flume_gravity_object.F90
Potential sourcesface gravity, cell gravity, momentum, energy from the face mass fluxes (second order, no fourth-order correction)add_potential_sources, adam_flume_cpu_object.F90; add_potential_sources_dev, adam_flume_fnl_kernels.F90
SpaceWENO5 (weno-u-5) flux splitting on characteristic variablesnumerics
TimeSSP Runge–Kutta, 3 stages (runge-kutta-ssp-33), CFL 0.4; the wave2d ladder scales it as GV-9, 0.4(8/n)2/3 for n cells per block sideadam_rk_object.F90
Positivity limiter (box2d-lim, box2d-mhd)cell, with the face and cell gravity from Φlimit_positivity, adam_flume_cpu_object.F90; numerics
Hydrostatic ghoststhe potential drop g⋅s=−(Φghost−Φ1)set_boundary_conditions, adam_flume_cpu_object.F90; hydrostatic_ghost, adam_flume_bc_object.F90
FNL backendthe same path on the deviceadam_flume_fnl_object.F90

Initial and boundary conditions ​

The cases are those of M7 (gravity/make_atmosphere.py), written with --potential linear. Every case: the unit square, a quadtree of 4×4 blocks (two uniform levels), 4 ghost cells, 2 ranks.

Case (M7 origin)State, gravityBoundariesCells per block side, end
iso2d (G0)isothermal atmosphere, g=(0,−1) (IC); ghosts poisonedx periodic, y hydrostatic8; one step at CFL 10−30
iso2d-mhd (G0)iso2d with EGLM and B=(0.5,0.7,0.2)as iso2d8; one step
freefall2d (G1)uniform ρ=1, p=1 at rest (IC), g=(0,−1)periodic on every face8; 50 steps
box2d (G1)as freefall2dx periodic, y wall-inviscid8; 200 steps
box2d-mhd (G1)box2d with EGLM, B=(0.5,0,0), the limiter onas box2d8; 200 steps
box2d-lim (G1)box2d with p=0.05 and the positivity limiter (the gas falls away from the top wall toward vacuum)as box2d8; 300 steps
wave2d (G2a, GV-9)ρ=1+0.2sin⁡(2π(x+y)) (sine-wave, entropy mode), u0=(1,0.5), p=1, g=(−0.6,−0.8)periodic on every face8, 16, 32 (322 to 1282); t=0.2

The figure's closed box is box2d at 16 cells per block side (N=64) to t=0.2, checkpointed every 2 steps, once through each path.

Input files ​

FileRole
src/tests/flume/verification/gravity/make_atmosphere.pywrites the M7 cases; --potential linear selects the potential path
src/tests/flume/verification/selfgravity/check.shruns SV-1 (--np N, --legs LIST: iso2d, iso2d-mhd, freefall2d, box2d, box2d-mhd, box2d-lim, wave2d (the ladder), default all; --keep; FLUME_EXE selects the backend)
src/tests/flume/verification/gravity/atmosphere_oracle.pythe M7 oracles: profile, freefall, energy, wave
src/tests/flume/verification/make_doc_runs.sh, group selfgravitysv1-box2d-{uniform,linear}, sv1-wave-{uniform,linear}-{8,16,32}: both paths
src/tests/flume/verification/make_doc_figures.py, fig_selfgravity_potentialdraws the figure (--only selfgravity-potential)
bash
cd src/tests/flume/verification/selfgravity && ./check.sh                   # CPU
FLUME_EXE=$PWD/../../../../../exe/adam_flume_fnl ./check.sh                   # FNL
cd .. && ./make_doc_runs.sh <dir> selfgravity                               # the figure's runs
python3 make_doc_figures.py --out ../../../../docs/public/flume --runs <dir> --only selfgravity-potential

Results ​

SV-1: energy budget of the closed box through both paths, and the falling-wave errors against N

Left: the closed box at N=64, each path's conserved energy at round-off while E alone exchanges with ρΦ by up to 6⋅10−3. Right: the falling wave to t=0.2, second order through the potential path (5.0 and 4.6 through the constant path).

CaseAssertedBoundCPUFNL
iso2d, iso2d-mhdhydrostatic ghosts against the profile, relative10−132.2⋅10−162.2⋅10−16
freefall2dρu=ρgt, E=E0+ρg2t2/2, relative10−125.6⋅10−163.3⋅10−16
box2d, box2d-mhdmass and E+ρΦ in the closed box, relative10−121.3⋅10−14, 7.5⋅10−151.7⋅10−14, 8.8⋅10−15
box2d-limthe run completes (limiter acting); drift reported—4.4⋅10−74.4⋅10−7
wave2d, 3 resolutionsL1 order of ρ and p on the finest pair≥1.82.12, 2.002.12, 2.00

Related cases: the constant-g path of the same cases is verified in the force, the order of the energy source and the stratified atmospheres; the Poisson solver that feeds this path is SV-2.

Findings ​

  • In the closed box the potential path's energy budget closes on E+ρΦ alone. The constant path closes on W, which adds the O(Δx2) wall term of its fourth-order source: without that term its E+ρΦ drifts by 2⋅10−6.
  • With the limiter acting, the drift of the potential path (4.4⋅10−7) is of the size of the constant path's (1.2⋅10−6).
  • The potential path is second order (2.12 in ρ, 2.00 in p), as its face form without a fourth-order correction must be; the constant path gives 5.0 and 4.6 (GV-9).
  • The constant-g path is unchanged bitwise: the regression suite (35/35 on CPU and FNL at the time of P1) holds it.