Skip to content

The polytrope on AMR: static boxes, runtime regrids, Jeans refinement ​

IDGroupMilestoneTypeBackendsFigureRegression
SV-14 to SV-17, rg7Self-gravity#87 (follow-up) · P3, P4; #88 (follow-up); M9 (#91)P+CCPU, FNLyesselfgravity-star-amr

Case and scope ​

The n = 1 polytrope of SV-7 and SV-8 on AMR grids, under isolated self-gravity by the multigrid's symmetric James step (SV-13). The star is smaller than on the uniform grid (radius 0.3 instead of 0.5), so that the 2:1 seams lie in the atmosphere and not on the stellar surface.

What the case catches:

  • SV-14, the star on a static AMR box (#87 P3): the equilibrium with the star refined must have less spurious motion than on the uniform base; the collapse must keep the exact exchange of E and W (the per-stage reflux carries the seam gravity work); a regrid that refines a boundary block must stop the run;
  • SV-15, the collapse under runtime AMR (#88): a prolongation that builds cold, fast cells mid-collapse drives the run non-finite; conservative-state must run it to the end;
  • SV-16, Jeans refinement (#91): a Jeans marker must refine the star before the collapse, so that no regrid happens mid-collapse;
  • SV-17, dual energy (#91): euler-de must keep the cold infall from draining with the default prolongation;
  • rg7, the Jeans-marker contract: a Jeans marker without self-gravity, or with an inverted hysteresis band, must be refused at initialization.

Models and numerics ​

ItemChoiceCode
Equations, scheme, boundariesas SV-7, SV-8: Euler, γ=2, isolated self-gravity with G=1, WENO5 flux splitting, SSP-RK3, wall-inviscid on every facemodels
Poisson solverthe multigrid's James step for isolated boundaries, its coarsest level on the FFT solveradam_poisson_mg_object.F90, adam_poisson_fft_object.F90
Refluxreflux_cadence = stage: the seam fluxes, and the seam gravity work, reconciled every Runge–Kutta stagenumerics
Boundary refinementa regrid that refines a block on the domain boundary is fatal (the James step needs every leaf on the boundary at the coarsest level)adam_poisson_mg_object.F90
[amr] regrid_prolongationconservative (default) or conservative-state (below)refine_conservative, refine_conservative_state, adam_field_object.F90
Jeans marker[amr_marker_N] mode = 5: refine where the cell spacing exceeds λJ / jeans_cells; jeans_cells_derefine > jeans_cells sets the hysteresis band; needs self-gravitynumerics; input
Dual energyphysical_model = euler-de, switch 0.05DE; models

The conservative-state prolongation ​

The opt-in conservative-state (#88) sets the 2d children of a parent cell c to

qk=qc+θ(δk−⟨δ⟩),δk=∑a≠0wa(qc+a⊙σk−qc),wa=∏refined axes(34,14)ai,

with σk the side of child k per axis (±1), a∈{0,1}d and ⟨δ⟩ the mean of the δk over the children. qc+δk is the linear prolongation, a mixture of whole coarse states with the same weights for every variable; removing the mean makes the children average to the parent. θ∈[0,1], one factor for every variable of the cell, is the largest that keeps every child in the range of the parent and its 3d neighbours. Linear data have ⟨δ⟩=0 and keep θ=1.

The default conservative prolongation limits each variable by its own slope (regrid round trip), so its children are not mixtures of whole states; in a collapse that is what builds the cold, fast cells of SV-15. A bound on the children's specific internal energy or entropy, minmod slopes, and one θ per variable each failed a case of the sweep over the star's radius and regrid cadence that the single θ runs to the end.

The single θ is also its price: an extremum of any one variable in the neighbourhood (a vortex core) flattens the children of every variable. The tracked vortex of AV (av2) then gives an L1 error 1.68 times the uniform fine run's, above the bound 1.5 (1.23 with conservative). Hence an option for collapsing flows, not the default. The round-trip identities of conservative-state (exact integral, range) are asserted by rg0 in the regrid round trip.

Initial and boundary conditions ​

ItemValue
Starthe SV-7 polytrope with radius a=0.3: the 2:1 seam of the box [−1/2,1/2]3 lies in the atmosphere, 0.2 off the surface
Box, base[−1,1]3, octree, base 323 (blocks of 83, 4 ghosts), wall-inviscid on every face; 2 ranks
SV-14, gridthe box [−1/2,1/2]3 refined once over the 323 base (--box: 120 blocks, the star at the 643 spacing, 9.6 cells per radius)
SV-14, equilibriumas SV-7 (atmosphere 10−4ρc, limiter cell, to t=2), on the AMR grid and on the uniform 323 grid
SV-14, collapseas SV-8 (atmosphere 10−2ρc, no limiter, to t=1.5, CFL 0.4, 0.2, 0.1) on the AMR grid with reflux_cadence = stage
SV-14, refusalstarc --regrid 2 --boundary-box: a runtime marker on [1/2,1]3; the first regrid refines a boundary block
SV-15, runtime-AMR collapsestarc --radius 0.3 --reflux-cadence stage --regrid 5: the uniform 323 base (4.8 cells per radius), atmosphere 10−2ρc, no limiter, to t=1.5; a regrid every 5 steps by a Löhner marker on the density (one level more, the atmosphere's density as its floor), the first one refining the 8 inner blocks; regrid_prolongation = conservative-state, and the default conservative reported
SV-16, Jeans refinementstarc --radius 0.22 --reflux-cadence stage --regrid 5 --jeans 8: 3.5 cells per radius on the base; its Jeans length is 2a, 5 base cells, since λJ2=πγp/(Gρ2)=πK/G=2a2 for the γ=2 polytrope, uniform inside it and unchanged by an adiabatic collapse; the SV-15 Löhner marker and a Jeans marker of 8 cells per Jeans length, the initial AMR on (amr_iterations = 1), the default prolongation; the same star without the Jeans marker reported
SV-17, dual energythe SV-15 case with the default prolongation, no Jeans marker, and --physical-model euler-de
rg7the regression sod-x input (Sod) to t=0.002, 2 ranks, with one Jeans marker (mode = 5, jeans_cells = 8): as is (no [gravity]), and with jeans_cells_derefine = 4
Regression selfgravity-star-amrstarc --radius 0.3 --box --reflux-cadence stage: SV-14's collapse, 120 blocks of 83, 20 steps

Input files ​

FileRole
src/tests/flume/verification/selfgravity/make_polytrope.pywrites star and starc; on AMR --radius, --box, --regrid, --prolongation, --boundary-box, --reflux-cadence, --jeans, --physical-model
src/tests/flume/verification/selfgravity/star.shruns the legs sv14, sv15, sv16, sv17 (--np N, --legs LIST, --keep; FLUME_EXE selects the backend)
src/tests/flume/verification/selfgravity/star_oracle.py, jeans_oracle.pythe drift reductions (equilibrium) and E+W against Δt (collapse)
src/tests/flume/verification/regrid/check.sh --legs rg7rg7, the Jeans-marker refusals
src/tests/flume/regression/selfgravity-star-amr/input.inithe frozen SV-14 collapse on AMR, 20 steps (#87 P4)
src/tests/flume/verification/make_doc_runs.sh, group isolatedsv14-{uniform,box}, sv14-collapse-{0.4,0.2,0.1}
src/tests/flume/verification/make_doc_runs.sh, group collapse-regridsv15-{conservative-state,conservative}, sv16-{jeans,control} and sv17-de, a checkpoint every 2 steps (the conservative and control runs stop by design)
src/tests/flume/verification/make_doc_figures.py, fig_selfgravity_star_amr, fig_selfgravity_star_regriddraws the figures (--only selfgravity-star-amr selfgravity-star-regrid)
bash
cd src/tests/flume/verification/selfgravity && ./star.sh --legs sv14,sv15,sv16,sv17       # CPU (exe/adam_flume_cpu_fft)
FLUME_EXE=$PWD/../../../../../exe/adam_flume_fnl_fft ./star.sh --legs sv14,sv15,sv16,sv17   # FNL
cd ../regrid && ./check.sh --legs rg7                                                    # the Jeans-marker contract

Results ​

SV-14, the star on a static AMR box:

SV-14: the smaller star on AMR, its core and spurious motion against the uniform grid; the collapse's energy drift; the star on its composite grid

Top: the star of radius 0.3 on the uniform 323 grid (4.8 cells per radius) and with the box refined (9.6): on the AMR grid the core swings half as far and the interior Mach number stays at half. Bottom left: the collapse on the AMR grid, E+W at the Runge–Kutta order while E and W exchange 81 % of |E+W| (their curves coincide). Bottom right: the equilibrium star at t=2 on its composite grid, the radius dashed; the 2:1 seam lies in the atmosphere.

LegAssertedBoundCPUFNL
SV-14the largest central-density drift to t=2: 1.65⋅10−1 (uniform 323), 8.24⋅10−2 (AMR); reduction≥1.52.002.00
SV-14the largest Mach number inside 0.8a: 0.414, 0.189; reduction≥1.52.192.19
SV-14the largest Mach number in the whole star: 15.2 (uniform: the surface spans 5 cells), 0.36; reductionreported4242
SV-14collapse on AMR, drift of E+W at CFL 0.4, 0.2, 0.1: 4.76⋅10−7, 6.07⋅10−8, 7.72⋅10−9; order in Δt≥2.52.97, 2.972.97, 2.97 (the same drifts)
SV-14the largest |∫ρu|; mass drift10−14; 10−142.2⋅10−19; 2.4⋅10−164.3⋅10−19; 2.4⋅10−16
SV-14a regrid that refines a boundary blockrefused, exit 1refusedrefused

SV-15 to SV-17, the runtime-AMR collapse:

SV-15 and SV-16: the coldest cell of the runtime-AMR collapse with the two conservative prolongations and with the Jeans marker; the drift of the mass and of E + W

Top row, SV-15: the SV-14 star collapsing on the uniform 323 base, a regrid every 5 steps. Left: the regrid at step 5 refines the 8 inner blocks and lowers the smallest e/ρ from 7.0⋅10−3 to 5.0⋅10−3 with either prolongation. With the default conservative the coldest cells then keep cooling while an infall reaches Mach 10: 3.5⋅10−4 by step 62, non-finite at step 64 (t=0.70). With conservative-state the smallest e/ρ never falls below 5.07⋅10−3, the Mach number stays below 1.8 and the run reaches t=1.5. Right: the mass at round-off in both; E+W jumps at the regrid (the potential is solved on the new grid), by 1.5⋅10−3 with conservative and 3.5⋅10−5 with conservative-state, and drifts at the time integration's error between regrids. Bottom row, SV-16: the smaller star refined only by the Löhner marker at step 5 cools to non-finite at step 27; with the Jeans marker the initial AMR refines it before the collapse (120 blocks, 64 on the base), no regrid changes the grid, the coldest cell recovers and the run reaches t=1.5 with the default prolongation, E+W drifting by 7.6⋅10−7 with no regrid jump. Bottom row, SV-17: the SV-15 star with euler (the red curve of the top row) and with euler-de: the floor lifts the coldest cells to their adiabat in 6 steps, adding 4.1⋅10−7 to the total energy, and the run reaches t=1.5 with the default prolongation.

LegAssertedBoundCPUFNL
SV-15conservative-state: reaches t=1.5, with a regrid that changes the gridcompletest=1.5, 1 regrid changes the gridt=1.5, 1 regrid changes the grid
SV-15conservative-state: mass and momentum drifts10−13mass 1.2⋅10−16, momentum 3.8⋅10−18mass 1.2⋅10−16, momentum 7.6⋅10−18
SV-15conservative, the defaultreportednon-finite at step 64non-finite at step 65
SV-16Jeans marker: the initial grid refined (blocks at step 0 above the 64 of the base); reaches t=1.5completes120 blocks at step 0; t=1.5120 blocks at step 0; t=1.5
SV-16Jeans marker: mass and momentum drifts10−13mass 2.1⋅10−16, momentum 1.7⋅10−18mass 2.1⋅10−16, momentum 3.3⋅10−18
SV-16without the Jeans markerreportednon-finite at step 27non-finite at step 33
SV-17euler-de: reaches t=1.5completest=1.5t=1.5
SV-17euler-de: mass and momentum drifts10−13mass 1.2⋅10−16, momentum 4.8⋅10−19mass 1.2⋅10−16, momentum 9.6⋅10−19
SV-17the energy the entropy floor addedreported4.1⋅10−7 in 6 steps4.1⋅10−7 in 6 steps

rg7, the Jeans-marker contract:

InputExpectedCPUFNL
Jeans marker, no self-gravityfatal: "needs [gravity].(self_gravity) = .true."passpass
jeans_cells_derefine = 4fatal: "needs 0 < jeans_cells < jeans_cells_derefine"passpass

Related cases: the uniform-grid star is SV-7, SV-8; the solver on AMR is SV-13; self-gravity through regrids is SV-11; the dual-energy model is DE; the library regrid is the regrid round trip.

Findings ​

  • Isolated self-gravity on AMR holds the star and keeps the exchange exact (SV-14). Refining the star halves its spurious motion against the uniform base, as a uniform grid of the fine spacing would; the collapse drifts at third order in Δt with the momentum at round-off, as on the uniform grid (SV-8): the James step is symmetric and the per-stage reflux carries the seam gravity work.
  • Keep refinement boundaries off the stellar surface. With the SV-7 star (a=1/2) the box's faces lie on the surface; in the light atmosphere the end-of-step reflux run goes non-finite at t=1.41, the per-stage one reaches t=2 (#88). Production codes keep coarse–fine boundaries out of dense gas for the same reason (Castro refines everything far below the stellar density, Katz et al. 2016; Berger and Colella 1989 on the spurious waves of a resolution jump at a steep gradient).
  • A runtime-AMR star changes its grid once, and needs conservative-state (SV-15). One level above the 323 base can only refine the 8 inner blocks (0.5 wide); two levels would carry the 2:1 balance to the boundary blocks, which is refused; 4-cell blocks are below 2ngc. The first regrid refines the 8 inner blocks and later regrids keep that grid. With the default prolongation the collapse then drains a cell's internal energy to negative; conservative-state, one range limit for the whole state, runs it to the end. On the CPU it also runs the star of radius 0.25 regridded every 5 steps and of radius 0.3 every 8, on which the default goes non-finite (steps 53 and 48); it fails on the radius-0.22 star regridded every 5 steps and the radius-0.25 star every 8 (3.5 and 4.0 cells per radius on the base), which the non-conservative linear prolongation runs to the end.
  • Refine before the collapse: the Jeans criterion (SV-16). A star prolonged mid-collapse is the fragile case; a Jeans marker refines it at the start instead, and the collapse never regrids. With 8 cells per Jeans length the radius-0.22 star regridded every 5 steps, which no conservative prolongation survives, reaches t=1.5 with the default one, and so do the radius-0.25 star regridded every 8 and the SV-15 star (CPU). For this polytrope the Jeans length does not shrink in the collapse (λJ=2a at γ=2), so one refinement at the start holds; in an adiabatic collapse λJ∝ρ(γ−2)/2, so for any γ<2 it shortens as the density rises, and the runtime regrids then follow it.
  • Or carry the entropy: dual energy (SV-17). The coldest cells of the SV-15 collapse sit at e/E≈10−2 two steps before the default run goes non-finite; euler-de lifts them to their adiabat when they drop below it, and the run ends with the default prolongation. On the CPU it also runs the radius-0.25 star regridded every 5 and every 8 steps; the radius-0.22 star (3.5 cells per radius) still needs the Jeans marker.
  • Three remedies, one per cause: conservative-state keeps a mid-collapse regrid from building cold fast cells, the Jeans marker avoids the mid-collapse regrid, dual energy keeps the cold infall from draining.