Skip to content

Commit 01fa805

Browse files
authored
Introduce WeightWindowsList class that enables export to HDF5 (#3456)
1 parent a6db05a commit 01fa805

6 files changed

Lines changed: 337 additions & 210 deletions

File tree

docs/source/pythonapi/base.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Simulation Settings
3737

3838
openmc.read_source_file
3939
openmc.write_source_file
40-
openmc.wwinp_to_wws
4140

4241
Material Specification
4342
----------------------
@@ -259,8 +258,16 @@ Variance Reduction
259258
:template: myclass
260259

261260
openmc.WeightWindows
261+
openmc.WeightWindowsList
262262
openmc.WeightWindowGenerator
263+
264+
.. autosummary::
265+
:toctree: generated
266+
:nosignatures:
267+
:template: myfunction.rst
268+
263269
openmc.hdf5_to_wws
270+
openmc.wwinp_to_wws
264271

265272

266273
Coarse Mesh Finite Difference Acceleration

docs/source/usersguide/variance_reduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ solver, the Python input just needs to load the h5 file::
162162

163163
settings.weight_window_checkpoints = {'collision': True, 'surface': True}
164164
settings.survival_biasing = False
165-
settings.weight_windows = openmc.hdf5_to_wws('weight_windows.h5')
165+
settings.weight_windows = openmc.WeightWindowsList.from_hdf5('weight_windows.h5')
166166
settings.weight_windows_on = True
167167

168168
The :class:`~openmc.WeightWindowGenerator` instance is not needed to load an

openmc/settings.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from .source import SourceBase, MeshSource, IndependentSource
1717
from .utility_funcs import input_path
1818
from .volume import VolumeCalculation
19-
from .weight_windows import WeightWindows, WeightWindowGenerator
19+
from .weight_windows import WeightWindows, WeightWindowGenerator, WeightWindowsList
2020

2121

2222
class RunMode(Enum):
@@ -313,7 +313,7 @@ class Settings:
313313
described in :ref:`verbosity`.
314314
volume_calculations : VolumeCalculation or iterable of VolumeCalculation
315315
Stochastic volume calculation specifications
316-
weight_windows : WeightWindows or iterable of WeightWindows
316+
weight_windows : WeightWindowsList
317317
Weight windows to use for variance reduction
318318
319319
.. versionadded:: 0.13
@@ -424,7 +424,7 @@ def __init__(self, **kwargs):
424424
self._max_particles_in_flight = None
425425
self._max_particle_events = None
426426
self._write_initial_source = None
427-
self._weight_windows = cv.CheckedList(WeightWindows, 'weight windows')
427+
self._weight_windows = WeightWindowsList()
428428
self._weight_window_generators = cv.CheckedList(WeightWindowGenerator, 'weight window generators')
429429
self._weight_windows_on = None
430430
self._weight_windows_file = None
@@ -1095,14 +1095,14 @@ def write_initial_source(self, value: bool):
10951095
self._write_initial_source = value
10961096

10971097
@property
1098-
def weight_windows(self) -> list[WeightWindows]:
1098+
def weight_windows(self) -> WeightWindowsList:
10991099
return self._weight_windows
11001100

11011101
@weight_windows.setter
1102-
def weight_windows(self, value: WeightWindows | Iterable[WeightWindows]):
1103-
if not isinstance(value, MutableSequence):
1102+
def weight_windows(self, value: WeightWindows | Sequence[WeightWindows]):
1103+
if not isinstance(value, Sequence):
11041104
value = [value]
1105-
self._weight_windows = cv.CheckedList(WeightWindows, 'weight windows', value)
1105+
self._weight_windows = WeightWindowsList(value)
11061106

11071107
@property
11081108
def weight_windows_on(self) -> bool:

0 commit comments

Comments
 (0)