Skip to content

Commit 383af9f

Browse files
committed
Merge branch 'development' into mengxuan/duststoppingtime
2 parents 407240e + 1852bc6 commit 383af9f

23 files changed

Lines changed: 1027 additions & 128 deletions

.github/workflows/rocm-diskgalaxy-container.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ env:
2323
IS_INTERNAL_PR: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
2424

2525
jobs:
26+
check_changes:
27+
uses: ./.github/workflows/check_changes.yml
28+
with:
29+
workflow_file: '.github/workflows/rocm-diskgalaxy-container.yml'
30+
2631
build-and-push:
2732
runs-on: ubuntu-latest
33+
needs: check_changes
34+
if: needs.check_changes.outputs.has_non_docs_changes == 'true'
2835

2936
steps:
3037
- name: Checkout

docs/markdown/parameters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ These parameters are read in the `AMRSimulation<problem_t>::readParameters()` fu
2626
| derived_vars | String | A list of the names of derived variables that should be included in the plotfile and Ascent outputs. |
2727
| regrid_interval | Integer | The number of timesteps between AMR regridding. |
2828
| density_floor | Float | The minimum density value allowed in the simulation. Enforced through EnforceLimits. |
29+
| density_floor_expr | String | Optional AMReX parser expression for a spatially varying density floor. Variables: x, y, z, base_density_floor. When set, this overrides the constant floor. |
30+
| debug_density_floor_plot | Boolean (0/1) | If set to 1, adds a derived field `density_floor_dbg` to plotfiles to visualize the spatially varying density floor. Default: 0 (disabled). |
2931
| temperature_floor | Float | The minimum temperature value allowed in the simulation. Enforced through EnforceLimits. |
3032
| max_walltime | String | The maximum walltime for the simulation in the format DD:HH:SS (days/hours/seconds). After 90% of this walltime elapses, the simulation will automatically stop and exit. |
3133
| dt_cutoff | Float | Timestep drop detector threshold. If the timestep drops below dt_cutoff \* current_time, the simulation aborts with an error message. This helps detect numerical instabilities early. Default: 0.0 (disabled). |

extern/openPMD-api

Submodule openPMD-api updated 217 files

inputs/HydrostaticAtmosphere.in

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Hydrostatic exponential atmosphere density floor unit test inputs
2+
3+
# *****************************************************************
4+
# Problem size and geometry
5+
# *****************************************************************
6+
geometry.prob_lo = 0.0 0.0 0.0
7+
geometry.prob_hi = 1.0 1.0 1.0
8+
quokka.bc = ext_dir periodic periodic
9+
10+
# *****************************************************************
11+
# VERBOSITY
12+
# *****************************************************************
13+
amr.v = 0 # verbosity in Amr
14+
15+
# *****************************************************************
16+
# Resolution and refinement
17+
# *****************************************************************
18+
amr.n_cell = 8 8 8
19+
amr.max_level = 0 # number of levels = max_level + 1
20+
amr.blocking_factor = 1 # grid size must be divisible by this
21+
22+
do_reflux = 0
23+
do_subcycle = 0
24+
25+
density_floor = 1.0
26+
atmosphere_scale_height = 0.25
27+
density_floor_expr = "1.0e-2*base_density_floor*exp(-x/0.25)"

inputs/MHDBalsaraVortex.in

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# *****************************************************************
2+
# Problem size and geometry
3+
# *****************************************************************
4+
geometry.prob_lo = -5.0 -5.0 -5.0
5+
geometry.prob_hi = 5.0 5.0 5.0
6+
geometry.is_periodic = 1 1 1
7+
8+
# *****************************************************************
9+
# VERBOSITY
10+
# *****************************************************************
11+
amr.v = 1
12+
13+
# *****************************************************************
14+
# Resolution and refinement
15+
# *****************************************************************
16+
amr.n_cell = 32 32 8
17+
amr.max_level = 0
18+
amr.max_grid_size = 32
19+
amr.blocking_factor_x = 32
20+
amr.blocking_factor_y = 32
21+
amr.blocking_factor_z = 8
22+
23+
do_reflux = 0
24+
do_subcycle = 0
25+
26+
plotfile_interval = 10
27+
plotfile_prefix = balsara_vortex_plt
28+
checkpoint_interval = -1
29+
cfl = 0.3
30+
max_timesteps = 10000
31+
32+
hydro.rk_integrator_order = 2
33+
hydro.reconstruction_order = 5
34+
hydro.use_dual_energy = 0
35+
36+
setup.vortex_Mach = 0.1
37+
setup.vortex_b_magn = 0.1
38+
setup.advection = 1
39+
setup.num_orbits = 3

scripts/python/hydro_wave_convergence_analysis.py

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ class FitResult:
3232
sse: float
3333

3434

35+
@dataclass
36+
class ConvergenceRun:
37+
label: str
38+
data: Sequence[ConvergenceDatum]
39+
fit: FitResult
40+
41+
3542
def read_convergence_csv(path: Path) -> List[ConvergenceDatum]:
3643
if not path.exists():
3744
raise FileNotFoundError(f"Could not find convergence file: {path}")
@@ -161,39 +168,32 @@ def geometric_space(x_min: float, x_max: float, num: int) -> List[float]:
161168
return [math.exp(log_min + (log_max - log_min) * i / (num - 1)) for i in range(num)]
162169

163170

164-
def make_plot(
165-
data: Sequence[ConvergenceDatum],
166-
fit: FitResult,
167-
output_path: Path,
168-
) -> None:
171+
def make_plot(runs: Sequence[ConvergenceRun], output_path: Path) -> None:
169172
import matplotlib
170173

171174
matplotlib.use("Agg")
172175

173176
import matplotlib.pyplot as plt
174177

175-
nx_values = [item.nx for item in data]
176-
error_values = [item.error for item in data]
177-
178-
nx_min = min(nx_values)
179-
nx_max = max(nx_values)
180-
nx_plot = geometric_space(nx_min, nx_max, 200)
181-
182-
model_values = []
183-
asymptotic_values = []
184-
for nx in nx_plot:
185-
asymptotic = fit.amplitude * (nx ** (-fit.order))
186-
model_values.append(math.sqrt(asymptotic * asymptotic + fit.floor * fit.floor))
187-
asymptotic_values.append(asymptotic)
188-
189178
fig, ax = plt.subplots(figsize=(6.0, 4.0))
190-
ax.loglog(nx_values, error_values, "o", label="Simulation data")
191-
ax.loglog(nx_plot, model_values, "-", label="Power law + floor fit")
192-
ax.loglog(nx_plot, asymptotic_values, "--", label="Asymptotic power law")
193-
194-
x_lo, x_hi = ax.get_xlim()
195-
ax.axhline(fit.floor, color="gray", linestyle="--", label="Roundoff floor")
196-
ax.set_xlim(x_lo, x_hi)
179+
color_cycle = plt.rcParams["axes.prop_cycle"].by_key()["color"]
180+
for run_index, run in enumerate(runs):
181+
color = color_cycle[run_index % len(color_cycle)]
182+
nx_values = [item.nx for item in run.data]
183+
error_values = [item.error for item in run.data]
184+
185+
nx_plot = geometric_space(min(nx_values), max(nx_values), 200)
186+
model_values = []
187+
asymptotic_values = []
188+
for nx in nx_plot:
189+
asymptotic = run.fit.amplitude * (nx ** (-run.fit.order))
190+
model_values.append(math.sqrt(asymptotic * asymptotic + run.fit.floor * run.fit.floor))
191+
asymptotic_values.append(asymptotic)
192+
193+
ax.loglog(nx_values, error_values, "o", color=color, label="_nolegend_")
194+
ax.loglog(nx_plot, model_values, "-", color=color, label=f"{run.label} fit")
195+
ax.loglog(nx_plot, asymptotic_values, "--", color=color, label="_nolegend_")
196+
ax.axhline(run.fit.floor, color=color, linestyle=":", alpha=0.5, label="_nolegend_")
197197

198198
ax.set_xlabel("Cells per wavelength (N_x)")
199199
ax.set_ylabel("L1 error norm")
@@ -211,8 +211,15 @@ def main() -> None:
211211
parser.add_argument(
212212
"--csv",
213213
type=Path,
214-
default=Path("tests") / "hydro_wave_convergence.csv",
215-
help="Path to the hydro wave convergence CSV file (default: tests/hydro_wave_convergence.csv).",
214+
action="append",
215+
default=[],
216+
help="Path to a hydro wave convergence CSV file (repeatable).",
217+
)
218+
parser.add_argument(
219+
"--label",
220+
action="append",
221+
default=[],
222+
help="Optional label for a CSV file (repeatable, matches --csv order).",
216223
)
217224
parser.add_argument(
218225
"--output",
@@ -227,29 +234,38 @@ def main() -> None:
227234
)
228235
args = parser.parse_args()
229236

230-
data = read_convergence_csv(args.csv)
231-
fit = fit_power_law_with_floor(data)
232-
orders = compute_observed_orders(data)
237+
csv_paths = args.csv or [Path("tests") / "hydro_wave_convergence.csv"]
238+
if args.label and len(args.label) != len(csv_paths):
239+
raise ValueError("Provide the same number of --label entries as --csv entries.")
240+
241+
labels = args.label or [path.stem for path in csv_paths]
242+
runs: List[ConvergenceRun] = []
243+
244+
for label, csv_path in zip(labels, csv_paths):
245+
data = read_convergence_csv(csv_path)
246+
fit = fit_power_law_with_floor(data)
247+
orders = compute_observed_orders(data)
248+
runs.append(ConvergenceRun(label=label, data=data, fit=fit))
233249

234-
print("Hydro wave convergence statistics:\n")
235-
print(f"{'nx':>8} {'dx':>14} {'error':>16}")
236-
for row in data:
237-
print(f"{row.nx:8d} {row.dx:14.6e} {row.error:16.6e}")
250+
print(f"Hydro wave convergence statistics for {label} ({csv_path}):\n")
251+
print(f"{'nx':>8} {'dx':>14} {'error':>16}")
252+
for row in data:
253+
print(f"{row.nx:8d} {row.dx:14.6e} {row.error:16.6e}")
238254

239-
print("\nObserved refinement ratios and orders (successive levels):")
240-
print(f"{'nx':>8} {'ratio':>10} {'order':>10}")
241-
for nx, ratio, order in orders:
242-
print(f"{nx:8d} {ratio:10.3f} {order:10.3f}")
255+
print("\nObserved refinement ratios and orders (successive levels):")
256+
print(f"{'nx':>8} {'ratio':>10} {'order':>10}")
257+
for nx, ratio, order in orders:
258+
print(f"{nx:8d} {ratio:10.3f} {order:10.3f}")
243259

244-
print("\nPower-law + floor fit parameters:")
245-
print(f" amplitude (A): {fit.amplitude:.6e}")
246-
print(f" order (p): {fit.order:.3f}")
247-
print(f" floor (f): {fit.floor:.6e}")
260+
print("\nPower-law + floor fit parameters:")
261+
print(f" amplitude (A): {fit.amplitude:.6e}")
262+
print(f" order (p): {fit.order:.3f}")
263+
print(f" floor (f): {fit.floor:.6e}\n")
248264

249265
if args.no_plot:
250266
print("\nSkipping plot generation (per --no-plot).")
251267
else:
252-
make_plot(data, fit, args.output)
268+
make_plot(runs, args.output)
253269
print(f"\nSaved log-log plot to {args.output}")
254270

255271

0 commit comments

Comments
 (0)