Rely on weight_windows_file implying weight windows are enabled

With the auto-enable behavior cherry-picked from develop (#4007),
convert_to_multigroup and the bootstrap test no longer need to set
weight_windows_on explicitly alongside the file.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
John Tramm 2026-07-17 21:11:47 +00:00
parent fae740292c
commit d9f2b53200
4 changed files with 19 additions and 23 deletions

View file

@ -2701,8 +2701,8 @@ class Model:
(fission treated as capture). If the resolved settings include a
``weight_windows_file`` (e.g., ``"weight_windows.h5"``), the
``"material_wise"`` method loads and applies those weight
windows during the continuous energy generation simulation
(``weight_windows_on`` is enabled automatically). Applying
windows during the continuous energy generation simulation.
Applying
weight windows allows the simulation to obtain tallies -- and
thus nonzero cross sections -- for materials located far from
the source, for example behind a thick shield, which an analog
@ -2792,24 +2792,23 @@ class Model:
settings.run_mode = 'fixed source'
# A weight windows file on the generation settings is loaded and
# applied during the "material_wise" method's continuous energy
# simulation of the original geometry, allowing materials far from
# the source -- which an analog simulation may struggle to reach --
# to still be tallied, and thus obtain nonzero cross sections. The
# applied (specifying a file turns weight windows on) during the
# "material_wise" method's continuous energy simulation of the
# original geometry, allowing materials far from the source --
# which an analog simulation may struggle to reach -- to still be
# tallied, and thus obtain nonzero cross sections. The
# "stochastic_slab" and "infinite_medium" methods use simplified
# surrogate geometries for which weight windows defined over the
# original geometry are neither applicable nor needed.
if settings.weight_windows_file is not None:
if method == "material_wise":
settings.weight_windows_on = True
else:
warnings.warn(
'The weight windows file set on the generation settings '
'is only applicable to the "material_wise" MGXS '
f'generation method and will be ignored for the '
f'"{method}" method.'
)
settings.weight_windows_file = None
if settings.weight_windows_file is not None and \
method != "material_wise":
warnings.warn(
'The weight windows file set on the generation settings '
'is only applicable to the "material_wise" MGXS '
f'generation method and will be ignored for the '
f'"{method}" method.'
)
settings.weight_windows_file = None
# Do all work (including MGXS generation) in a temporary directory
# to avoid polluting the working directory with residual XML files

View file

@ -61,7 +61,6 @@
<domain_ids>1</domain_ids>
</constraints>
</source>
<weight_windows_on>true</weight_windows_on>
<weight_windows_file>weight_windows.h5</weight_windows_file>
<weight_window_checkpoints>
<collision>true</collision>

View file

@ -91,7 +91,6 @@ def test_random_ray_auto_convert_bootstrap():
# Run the continuous energy model with the improved weight windows,
# tallying the flux in every region
model.settings.weight_windows_file = 'weight_windows.h5'
model.settings.weight_windows_on = True
model.settings.particles = 20
model.settings.batches = 10
tally = openmc.Tally(name='flux')

View file

@ -1169,13 +1169,12 @@ def test_convert_to_multigroup_settings_weight_windows(run_in_tmpdir, monkeypatc
gen = _capture_generation_settings(
monkeypatch, model, method='material_wise', settings=user)
# A weight windows file on the generation settings is applied to the
# "material_wise" generation run with weight windows turned on
# A weight windows file on the generation settings is passed through to
# the "material_wise" generation run (specifying a file turns weight
# windows on at run time)
assert gen.weight_windows_file == ww_path
assert gen.weight_windows_on is True
# The caller's object is never mutated
assert user.weight_windows_file == ww_path
assert user.weight_windows_on is None
# The surrogate-geometry methods ignore the file with a warning
with pytest.warns(UserWarning, match='material_wise'):