Skip to content

Commit

Permalink
Add CI to check runtime parameters (#2577)
Browse files Browse the repository at this point in the history
This will check all of the inputs files to make sure the runtime parameters in the namespaces
defined in _cpp_parameters are all valid. Note: at the moment, we skip radiation parameters
and we also don't test on Microphysics.

This also updates problems found in existing inputs files.
  • Loading branch information
zingale authored Sep 23, 2023
1 parent 7067216 commit 27f71bc
Show file tree
Hide file tree
Showing 25 changed files with 134 additions and 54 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/check-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: check runtime params

on:
push:
branches:
- development
- main
pull_request:
branches:
- development

jobs:
check-runtime-params:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get submodules
run: |
git submodule update --init
cd external/Microphysics
git fetch; git checkout development
cd ../amrex
git fetch; git checkout development
cd ../..
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Cache pip
uses: actions/cache@v3
with:
# this path is specific to Ubuntu
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Run check-params
run: |
PYTHONPATH=external/Microphysics/util/build_scripts python .github/workflows/check_params.py .
76 changes: 76 additions & 0 deletions .github/workflows/check_params.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import argparse
import importlib
import os
import re
from pathlib import Path
import sys

# some parameters that are not defined in _cpp_parameters

whitelist = ["castro.lo_bc",
"castro.hi_bc",
"gravity.abs_tol",
"gravity.rel_tol"]

# we don't have all of the radiation parametrs in the _cpp_parameters
# yet, so we won't check these namespaces

namespace_ignore = ["radiation", "radsolve"]

def doit(castro_dir):

castro = Path(os.path.abspath(castro_dir))

# import the module that defines the Castro runtime params
sys.path.append(str(castro / "Source" / "driver/"))
import parse_castro_params

# read in the parameters defined in _cpp_parameters
param_file = castro / "Source" / "driver" / "_cpp_parameters"
params = parse_castro_params.read_param_file(str(param_file))

namespaces = set(p.namespace for p in params)
runtime_parameters = [f"{p.namespace}.{p.name}" for p in params]

pattern = re.compile(r"[A-Za-z0-9_]+\.[A-Za-z0-9_]+", re.IGNORECASE)

# loop over all the inputs files
exec_path = castro / "Exec"
for f in exec_path.glob("**/inputs*"):

if os.path.isdir(f):
continue

# find all the params in each namespace
with open(f) as infile:
print(f"working on {f}")
for line in infile:
# remove comments
idx = line.find("#")
if idx > 0:
line = line[idx:]

found_param = pattern.match(line)
if not found_param:
continue

p = found_param.group(0)
nm = p.split(".")[0]
if nm in namespaces and nm not in namespace_ignore:
if not (p in runtime_parameters or p in whitelist):
sys.exit(f"Error: {p} not valid")


if __name__ == "__main__":

# we need the top-level Castro directory

p = argparse.ArgumentParser()
p.add_argument("castro_dir", type=str, nargs=1,
help="top level Castro directory")

args = p.parse_args()

doit(args.castro_dir[0])


3 changes: 0 additions & 3 deletions Docs/source/Particles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ the same time and each line corresponds to each particle info. while
in the other output file for the other 6 particles, 6 lines are stored
at the same time.

If ``particles.write_in_plotfile`` = 1, the particle data are stored
in a binary file along with the main CASTRO output plotfile in
directories ``pltXXXXX/Tracer/``.

Run-time Screen Output
----------------------
Expand Down
1 change: 0 additions & 1 deletion Exec/hydro_tests/Sedov/inputs.3d.mhd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ castro.hi_bc = 2 2 2
castro.do_hydro = 1
castro.do_react = 0
castro.ppm_type = 1
castro.allow_negative_energy = 0

#MHD
castro.use_flattening = 1
Expand Down
2 changes: 1 addition & 1 deletion Exec/hydro_tests/riemann_2d/inputs_c12
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ castro.do_react = 0

castro.cfl = 0.6
castro.init_shrink = 0.1
castro.changemax = 1.1
castro.change_max = 1.1
#castro.fixed_dt =


Expand Down
2 changes: 1 addition & 1 deletion Exec/hydro_tests/riemann_2d/inputs_c15
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ castro.do_react = 0

castro.cfl = 0.6
castro.init_shrink = 1.0
castro.changemax = 1.1
castro.change_max = 1.1
#castro.fixed_dt =


Expand Down
2 changes: 1 addition & 1 deletion Exec/hydro_tests/riemann_2d/inputs_c17
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ castro.do_react = 0

castro.cfl = 0.6
castro.init_shrink = 1.0
castro.changemax = 1.1
castro.change_max = 1.1
#castro.fixed_dt =


Expand Down
2 changes: 1 addition & 1 deletion Exec/hydro_tests/riemann_2d/inputs_c3
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ castro.do_react = 0

castro.cfl = 0.6
castro.init_shrink = 1.0
castro.changemax = 1.1
castro.change_max = 1.1
#castro.fixed_dt =


Expand Down
2 changes: 1 addition & 1 deletion Exec/hydro_tests/riemann_2d/inputs_c4
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ castro.do_react = 0

castro.cfl = 0.6
castro.init_shrink = 1.0
castro.changemax = 1.1
castro.change_max = 1.1
#castro.fixed_dt =


Expand Down
2 changes: 1 addition & 1 deletion Exec/hydro_tests/riemann_2d/inputs_c6
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ castro.do_react = 0

castro.cfl = 0.6
castro.init_shrink = 1.0
castro.changemax = 1.1
castro.change_max = 1.1
#castro.fixed_dt =


Expand Down
2 changes: 1 addition & 1 deletion Exec/radiation_tests/RadThermalWave/inputs.1d
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ castro.change_max = 1.05

castro.sum_interval = 1 # timesteps between computing mass
castro.do_reflux = 1 # 1 => do refluxing
castro.gravity = 0
castro.do_grav = 0

castro.do_hydro = 1
castro.do_react = 0
Expand Down
2 changes: 1 addition & 1 deletion Exec/radiation_tests/RadThermalWave/inputs.1d.test
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ castro.change_max = 1.05

castro.sum_interval = 1 # timesteps between computing mass
castro.do_reflux = 1 # 1 => do refluxing
castro.gravity = 0
castro.do_grav = 0

castro.do_hydro = 1
castro.do_react = 0
Expand Down
2 changes: 1 addition & 1 deletion Exec/radiation_tests/RadThermalWave/inputs.2d
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ castro.change_max = 1.05

castro.sum_interval = 1 # timesteps between computing mass
castro.do_reflux = 1 # 1 => do refluxing
castro.gravity = 0
castro.do_grav = 0

castro.do_hydro = 1 # set to zero for comparison w/ analytic solution
castro.do_react = 0
Expand Down
2 changes: 1 addition & 1 deletion Exec/radiation_tests/RadThermalWave/inputs.2d.test
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ castro.change_max = 1.05

castro.sum_interval = 1 # timesteps between computing mass
castro.do_reflux = 1 # 1 => do refluxing
castro.gravity = 0
castro.do_grav = 0

castro.do_hydro = 1 # set to zero for comparison w/ analytic solution
castro.do_react = 0
Expand Down
2 changes: 1 addition & 1 deletion Exec/radiation_tests/RadThermalWave/inputs.3d
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ castro.change_max = 1.05

castro.sum_interval = 1 # timesteps between computing mass
castro.do_reflux = 1 # 1 => do refluxing
castro.gravity = 0
castro.do_grav = 0

castro.do_hydro = 0
castro.do_react = 0
Expand Down
2 changes: 1 addition & 1 deletion Exec/radiation_tests/RadThermalWave/inputs.3d.test
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ castro.change_max = 1.05

castro.sum_interval = 1 # timesteps between computing mass
castro.do_reflux = 1 # 1 => do refluxing
castro.gravity = 0
castro.do_grav = 0

castro.do_hydro = 0
castro.do_react = 0
Expand Down
9 changes: 0 additions & 9 deletions Exec/reacting_tests/reacting_bubble/inputs_2d_noentropy
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------

castro.MAESTRO_plotfile = "MAESTRO_plt00010"
castro.MAESTRO_modelfile = "./MAESTRO_plt00010/model_cc_00010"
castro.MAESTRO_first_species = "X(C12)"
castro.MAESTRO_npts_model = 576

castro.MAESTRO_cutoff_density = 3.e6
castro.MAESTRO_init_type = 2
castro.MAESTRO_spherical = 0

max_step = 10000
stop_time = 2.5

Expand Down
9 changes: 0 additions & 9 deletions Exec/reacting_tests/reacting_bubble/inputs_2d_zoom
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------

castro.MAESTRO_plotfile = "MAESTRO_plt00000"
castro.MAESTRO_modelfile = "./MAESTRO_plt00000/model_cc_00000"
castro.MAESTRO_first_species = "X(C12)"
castro.MAESTRO_npts_model = 128

castro.MAESTRO_cutoff_density = 3.e6
castro.MAESTRO_init_type = 2
castro.MAESTRO_spherical = 0

max_step = 100000
stop_time = 0.8

Expand Down
1 change: 0 additions & 1 deletion Exec/science/flame/inputs.1d.sdc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ castro.time_integration_method = 2
castro.sdc_order = 4

castro.sdc_solver = 1
castro.sdc_solver_relax_factor = 1

castro.use_reconstructed_gamma1 = 1

Expand Down
2 changes: 0 additions & 2 deletions Exec/science/planet/inputs_1d
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ castro.hse_interp_temp = 1
castro.hse_reflect_vels = 1
castro.hse_zero_vels=0

castro.xr_ext_base_type = "interp"

fab.format=NATIVE_32

# WHICH PHYSICS
Expand Down
5 changes: 0 additions & 5 deletions Exec/science/planet/inputs_2d
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,9 @@ particles.timestamp_dir = particle_dir # directory for output
particles.timestamp_density = 1
particles.timestamp_temperature = 1
particles.v = 1 # verbosity
particles.write_in_plotfile = 1




castro.ppm_type = 1
castro.ppm_reference = 1
castro.ppm_reference_edge_limit = 1
#castro.riemann_solver = 1

gravity.gravity_type = ConstantGrav
Expand Down
3 changes: 0 additions & 3 deletions Exec/science/planet/inputs_3d
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ castro.do_reflux = 1
#particles.timestamp_density = 1
#particles.timestamp_temperature = 1
#particles.v = 1 # verbosity
#particles.write_in_plotfile = 1




#castro.ppm_type = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ castro.riemann_solver = 0
# the iterations don't converge, but instead to do additional bisection iteration.
castro.cg_blend = 2

# Limit the maximum speed in the Riemann solver
castro.riemann_speed_limit = 2.99792458e9

# Use a lagged predictor estimate of the source terms in the hydro
castro.source_term_predictor = 1

Expand Down
3 changes: 0 additions & 3 deletions Exec/science/wdmerger/tests/wdmerger_collision_1D/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ castro.dtnuc_e = 1.e200
# Limit timestep based on nuclear burning considerations (changes in species)
castro.dtnuc_X = 1.e200

# Which method to use for estimating de/dt and dX/dt
castro.dtnuc_mode = 1

# Minimum temperature for allowing nuclear burning
castro.react_T_min = 1.0e7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ castro.dtnuc_e = 1.e200
# Limit timestep based on nuclear burning considerations (changes in species)
castro.dtnuc_X = 1.e200

# Which method to use for estimating de/dt and dX/dt
castro.dtnuc_mode = 1

# Minimum temperature for allowing nuclear burning
castro.react_T_min = 1.0e8

Expand Down

0 comments on commit 27f71bc

Please sign in to comment.