Fix for Weight Window Scaling Bug (#3511)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
John Tramm 2025-07-29 05:15:40 -05:00 committed by GitHub
parent 836bc487cf
commit 4cce6ee6c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 10 additions and 9 deletions

View file

@ -71,6 +71,7 @@ struct WeightWindow {
{
lower_weight *= factor;
upper_weight *= factor;
survival_weight *= factor;
}
};

View file

@ -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

View file

@ -1 +1 @@
a5880ad9262e8aba90801783891ee74618144101401f06fb46e954e851a3c517ab28d5f0d6e1b2b364844f08d363cba35ab23b63fc81012ea8a6a328755d56c4
5df0c08573ccee3fd3495c877c7dc0c4b69c245faf8473b848c89fb837dea7fd437936ffebeb6455c793e66046c46eb0ad6941cc5ef1699fc5fc8a7fcb9b5a0c

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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]