From 4cce6ee6c05c3070bb5f256324f064570b2869bc Mon Sep 17 00:00:00 2001 From: John Tramm Date: Tue, 29 Jul 2025 05:15:40 -0500 Subject: [PATCH] Fix for Weight Window Scaling Bug (#3511) Co-authored-by: Paul Romano --- include/openmc/weight_windows.h | 1 + tests/regression_tests/weightwindows/generators/test.py | 4 ++-- tests/regression_tests/weightwindows/results_true.dat | 2 +- tests/regression_tests/weightwindows/test.py | 6 +++--- tests/testing_harness.py | 2 +- tests/unit_tests/weightwindows/test_ww_gen.py | 2 +- tests/unit_tests/weightwindows/test_wwinp_reader.py | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/openmc/weight_windows.h b/include/openmc/weight_windows.h index 6f2ef07079..7638155228 100644 --- a/include/openmc/weight_windows.h +++ b/include/openmc/weight_windows.h @@ -71,6 +71,7 @@ struct WeightWindow { { lower_weight *= factor; upper_weight *= factor; + survival_weight *= factor; } }; diff --git a/tests/regression_tests/weightwindows/generators/test.py b/tests/regression_tests/weightwindows/generators/test.py index d6a40b44f0..4dc0ab80d3 100644 --- a/tests/regression_tests/weightwindows/generators/test.py +++ b/tests/regression_tests/weightwindows/generators/test.py @@ -46,14 +46,14 @@ def test_ww_generator(run_in_tmpdir): # just test that the generation happens successfully here assert os.path.exists('weight_windows.h5') - wws_mean = openmc.hdf5_to_wws() + wws_mean = openmc.WeightWindowsList.from_hdf5() assert len(wws_mean) == 1 # check that generation using the relative error works too wwg.update_parameters['value'] = 'rel_err' model.run() - wws_rel_err = openmc.hdf5_to_wws() + wws_rel_err = openmc.WeightWindowsList.from_hdf5() assert len(wws_rel_err) == 1 # we should not get the same set of weight windows when switching to use of diff --git a/tests/regression_tests/weightwindows/results_true.dat b/tests/regression_tests/weightwindows/results_true.dat index 671be1d7b0..122c5d8909 100644 --- a/tests/regression_tests/weightwindows/results_true.dat +++ b/tests/regression_tests/weightwindows/results_true.dat @@ -1 +1 @@ -a5880ad9262e8aba90801783891ee74618144101401f06fb46e954e851a3c517ab28d5f0d6e1b2b364844f08d363cba35ab23b63fc81012ea8a6a328755d56c4 \ No newline at end of file +5df0c08573ccee3fd3495c877c7dc0c4b69c245faf8473b848c89fb837dea7fd437936ffebeb6455c793e66046c46eb0ad6941cc5ef1699fc5fc8a7fcb9b5a0c \ No newline at end of file diff --git a/tests/regression_tests/weightwindows/test.py b/tests/regression_tests/weightwindows/test.py index 864f4f062d..cfb651338c 100644 --- a/tests/regression_tests/weightwindows/test.py +++ b/tests/regression_tests/weightwindows/test.py @@ -1,4 +1,3 @@ -from copy import deepcopy import pytest import numpy as np @@ -8,6 +7,7 @@ from openmc.stats import Discrete, Point from tests.testing_harness import HashedPyAPITestHarness + @pytest.fixture def model(): model = openmc.Model() @@ -114,7 +114,7 @@ def test_weightwindows(model): def test_wwinp_cylindrical(): - ww = openmc.wwinp_to_wws('ww_n_cyl.txt')[0] + ww = openmc.WeightWindowsList.from_wwinp('ww_n_cyl.txt')[0] mesh = ww.mesh @@ -144,7 +144,7 @@ def test_wwinp_cylindrical(): def test_wwinp_spherical(): - ww = openmc.wwinp_to_wws('ww_n_sph.txt')[0] + ww = openmc.WeightWindowsList.from_wwinp('ww_n_sph.txt')[0] mesh = ww.mesh diff --git a/tests/testing_harness.py b/tests/testing_harness.py index 6de475e6e0..11ced5b38a 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -443,7 +443,7 @@ class TolerantPyAPITestHarness(PyAPITestHarness): class WeightWindowPyAPITestHarness(PyAPITestHarness): def _get_results(self): """Digest info in the weight window file and return as a string.""" - ww = openmc.hdf5_to_wws()[0] + ww = openmc.WeightWindowsList.from_hdf5()[0] # Access the weight window bounds lower_bound = ww.lower_ww_bounds diff --git a/tests/unit_tests/weightwindows/test_ww_gen.py b/tests/unit_tests/weightwindows/test_ww_gen.py index 555421461b..7ee03f55c2 100644 --- a/tests/unit_tests/weightwindows/test_ww_gen.py +++ b/tests/unit_tests/weightwindows/test_ww_gen.py @@ -303,7 +303,7 @@ def test_python_hdf5_roundtrip(run_in_tmpdir, model): openmc.lib.finalize() - wws_hdf5 = openmc.hdf5_to_wws()[0] + wws_hdf5 = openmc.WeightWindowsList.from_hdf5()[0] # ensure assert all(wws.energy_bounds == wws_hdf5.energy_bounds) diff --git a/tests/unit_tests/weightwindows/test_wwinp_reader.py b/tests/unit_tests/weightwindows/test_wwinp_reader.py index 434a36753a..28548a4486 100644 --- a/tests/unit_tests/weightwindows/test_wwinp_reader.py +++ b/tests/unit_tests/weightwindows/test_wwinp_reader.py @@ -96,7 +96,7 @@ def id_fn(params): def test_wwinp_reader(wwinp_data, request): wwinp_file, mesh, particle_types, energy_bounds = wwinp_data - wws = openmc.wwinp_to_wws(request.node.path.parent / wwinp_file) + wws = openmc.WeightWindowsList.from_wwinp(request.node.path.parent / wwinp_file) for i, ww in enumerate(wws): e_bounds = energy_bounds[i]