From 27f71bcd5f2f45b2f10c6ca4cac6af9d1bf0c665 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Sat, 23 Sep 2023 19:26:16 -0400 Subject: [PATCH] Add CI to check runtime parameters (#2577) 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. --- .github/workflows/check-params.yml | 46 +++++++++++ .github/workflows/check_params.py | 76 +++++++++++++++++++ Docs/source/Particles.rst | 3 - Exec/hydro_tests/Sedov/inputs.3d.mhd | 1 - Exec/hydro_tests/riemann_2d/inputs_c12 | 2 +- Exec/hydro_tests/riemann_2d/inputs_c15 | 2 +- Exec/hydro_tests/riemann_2d/inputs_c17 | 2 +- Exec/hydro_tests/riemann_2d/inputs_c3 | 2 +- Exec/hydro_tests/riemann_2d/inputs_c4 | 2 +- Exec/hydro_tests/riemann_2d/inputs_c6 | 2 +- Exec/radiation_tests/RadThermalWave/inputs.1d | 2 +- .../RadThermalWave/inputs.1d.test | 2 +- Exec/radiation_tests/RadThermalWave/inputs.2d | 2 +- .../RadThermalWave/inputs.2d.test | 2 +- Exec/radiation_tests/RadThermalWave/inputs.3d | 2 +- .../RadThermalWave/inputs.3d.test | 2 +- .../reacting_bubble/inputs_2d_noentropy | 9 --- .../reacting_bubble/inputs_2d_zoom | 9 --- Exec/science/flame/inputs.1d.sdc | 1 - Exec/science/planet/inputs_1d | 2 - Exec/science/planet/inputs_2d | 5 -- Exec/science/planet/inputs_3d | 3 - .../wdmerger_collision/inputs_2d_collision | 3 - .../tests/wdmerger_collision_1D/inputs | 3 - .../wdmerger_retry/inputs_test_wdmerger_retry | 3 - 25 files changed, 134 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/check-params.yml create mode 100644 .github/workflows/check_params.py diff --git a/.github/workflows/check-params.yml b/.github/workflows/check-params.yml new file mode 100644 index 0000000000..324a0eb05f --- /dev/null +++ b/.github/workflows/check-params.yml @@ -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 . diff --git a/.github/workflows/check_params.py b/.github/workflows/check_params.py new file mode 100644 index 0000000000..c2807710d7 --- /dev/null +++ b/.github/workflows/check_params.py @@ -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]) + + diff --git a/Docs/source/Particles.rst b/Docs/source/Particles.rst index dcd235b9a9..10cbca4cd2 100644 --- a/Docs/source/Particles.rst +++ b/Docs/source/Particles.rst @@ -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 ---------------------- diff --git a/Exec/hydro_tests/Sedov/inputs.3d.mhd b/Exec/hydro_tests/Sedov/inputs.3d.mhd index 0ed77860db..3df326a54c 100644 --- a/Exec/hydro_tests/Sedov/inputs.3d.mhd +++ b/Exec/hydro_tests/Sedov/inputs.3d.mhd @@ -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 diff --git a/Exec/hydro_tests/riemann_2d/inputs_c12 b/Exec/hydro_tests/riemann_2d/inputs_c12 index 73e59d129a..abd99b16de 100644 --- a/Exec/hydro_tests/riemann_2d/inputs_c12 +++ b/Exec/hydro_tests/riemann_2d/inputs_c12 @@ -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 = diff --git a/Exec/hydro_tests/riemann_2d/inputs_c15 b/Exec/hydro_tests/riemann_2d/inputs_c15 index ebb580b19b..13238e8424 100644 --- a/Exec/hydro_tests/riemann_2d/inputs_c15 +++ b/Exec/hydro_tests/riemann_2d/inputs_c15 @@ -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 = diff --git a/Exec/hydro_tests/riemann_2d/inputs_c17 b/Exec/hydro_tests/riemann_2d/inputs_c17 index 2e0ef441d5..500dd1d794 100644 --- a/Exec/hydro_tests/riemann_2d/inputs_c17 +++ b/Exec/hydro_tests/riemann_2d/inputs_c17 @@ -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 = diff --git a/Exec/hydro_tests/riemann_2d/inputs_c3 b/Exec/hydro_tests/riemann_2d/inputs_c3 index a6641147ac..2a1d57d167 100644 --- a/Exec/hydro_tests/riemann_2d/inputs_c3 +++ b/Exec/hydro_tests/riemann_2d/inputs_c3 @@ -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 = diff --git a/Exec/hydro_tests/riemann_2d/inputs_c4 b/Exec/hydro_tests/riemann_2d/inputs_c4 index f50aa8b910..4921ea2816 100644 --- a/Exec/hydro_tests/riemann_2d/inputs_c4 +++ b/Exec/hydro_tests/riemann_2d/inputs_c4 @@ -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 = diff --git a/Exec/hydro_tests/riemann_2d/inputs_c6 b/Exec/hydro_tests/riemann_2d/inputs_c6 index 3261a675f5..503e2bd4eb 100644 --- a/Exec/hydro_tests/riemann_2d/inputs_c6 +++ b/Exec/hydro_tests/riemann_2d/inputs_c6 @@ -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 = diff --git a/Exec/radiation_tests/RadThermalWave/inputs.1d b/Exec/radiation_tests/RadThermalWave/inputs.1d index 3615115f33..c8a0da6922 100644 --- a/Exec/radiation_tests/RadThermalWave/inputs.1d +++ b/Exec/radiation_tests/RadThermalWave/inputs.1d @@ -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 diff --git a/Exec/radiation_tests/RadThermalWave/inputs.1d.test b/Exec/radiation_tests/RadThermalWave/inputs.1d.test index bff29c9b72..0b12b2318c 100644 --- a/Exec/radiation_tests/RadThermalWave/inputs.1d.test +++ b/Exec/radiation_tests/RadThermalWave/inputs.1d.test @@ -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 diff --git a/Exec/radiation_tests/RadThermalWave/inputs.2d b/Exec/radiation_tests/RadThermalWave/inputs.2d index d306f95712..74620a1e18 100644 --- a/Exec/radiation_tests/RadThermalWave/inputs.2d +++ b/Exec/radiation_tests/RadThermalWave/inputs.2d @@ -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 diff --git a/Exec/radiation_tests/RadThermalWave/inputs.2d.test b/Exec/radiation_tests/RadThermalWave/inputs.2d.test index 7e179c22c3..12b55511b2 100644 --- a/Exec/radiation_tests/RadThermalWave/inputs.2d.test +++ b/Exec/radiation_tests/RadThermalWave/inputs.2d.test @@ -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 diff --git a/Exec/radiation_tests/RadThermalWave/inputs.3d b/Exec/radiation_tests/RadThermalWave/inputs.3d index a31147b4ce..baec10f865 100644 --- a/Exec/radiation_tests/RadThermalWave/inputs.3d +++ b/Exec/radiation_tests/RadThermalWave/inputs.3d @@ -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 diff --git a/Exec/radiation_tests/RadThermalWave/inputs.3d.test b/Exec/radiation_tests/RadThermalWave/inputs.3d.test index 061c4e6532..a08fe4b3a1 100644 --- a/Exec/radiation_tests/RadThermalWave/inputs.3d.test +++ b/Exec/radiation_tests/RadThermalWave/inputs.3d.test @@ -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 diff --git a/Exec/reacting_tests/reacting_bubble/inputs_2d_noentropy b/Exec/reacting_tests/reacting_bubble/inputs_2d_noentropy index 4bef0d7244..7cd485f11c 100644 --- a/Exec/reacting_tests/reacting_bubble/inputs_2d_noentropy +++ b/Exec/reacting_tests/reacting_bubble/inputs_2d_noentropy @@ -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 diff --git a/Exec/reacting_tests/reacting_bubble/inputs_2d_zoom b/Exec/reacting_tests/reacting_bubble/inputs_2d_zoom index 13f617ebe9..fed1a26c5d 100644 --- a/Exec/reacting_tests/reacting_bubble/inputs_2d_zoom +++ b/Exec/reacting_tests/reacting_bubble/inputs_2d_zoom @@ -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 diff --git a/Exec/science/flame/inputs.1d.sdc b/Exec/science/flame/inputs.1d.sdc index 8c4a6af130..bce690fa62 100644 --- a/Exec/science/flame/inputs.1d.sdc +++ b/Exec/science/flame/inputs.1d.sdc @@ -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 diff --git a/Exec/science/planet/inputs_1d b/Exec/science/planet/inputs_1d index b79ffdfc25..635a03dd64 100644 --- a/Exec/science/planet/inputs_1d +++ b/Exec/science/planet/inputs_1d @@ -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 diff --git a/Exec/science/planet/inputs_2d b/Exec/science/planet/inputs_2d index 9701367d42..3fc97cde04 100644 --- a/Exec/science/planet/inputs_2d +++ b/Exec/science/planet/inputs_2d @@ -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 diff --git a/Exec/science/planet/inputs_3d b/Exec/science/planet/inputs_3d index 81e6b75501..f566015483 100644 --- a/Exec/science/planet/inputs_3d +++ b/Exec/science/planet/inputs_3d @@ -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 diff --git a/Exec/science/wdmerger/tests/wdmerger_collision/inputs_2d_collision b/Exec/science/wdmerger/tests/wdmerger_collision/inputs_2d_collision index 1fd08b126a..a718a7124f 100644 --- a/Exec/science/wdmerger/tests/wdmerger_collision/inputs_2d_collision +++ b/Exec/science/wdmerger/tests/wdmerger_collision/inputs_2d_collision @@ -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 diff --git a/Exec/science/wdmerger/tests/wdmerger_collision_1D/inputs b/Exec/science/wdmerger/tests/wdmerger_collision_1D/inputs index ed8d99059d..6dcabf249c 100644 --- a/Exec/science/wdmerger/tests/wdmerger_collision_1D/inputs +++ b/Exec/science/wdmerger/tests/wdmerger_collision_1D/inputs @@ -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 diff --git a/Exec/science/wdmerger/tests/wdmerger_retry/inputs_test_wdmerger_retry b/Exec/science/wdmerger/tests/wdmerger_retry/inputs_test_wdmerger_retry index 4858cc085e..0d63ab606c 100644 --- a/Exec/science/wdmerger/tests/wdmerger_retry/inputs_test_wdmerger_retry +++ b/Exec/science/wdmerger/tests/wdmerger_retry/inputs_test_wdmerger_retry @@ -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