Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing WeightWindowGenerator to be fully made via constructor #2686

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions openmc/weight_windows.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations
from collections.abc import Iterable
from numbers import Real, Integral
import pathlib
from typing import Iterable, List, Optional, Union, Dict
from typing import Iterable, List, Optional, Dict, Sequence
shimwell marked this conversation as resolved.
Show resolved Hide resolved
import warnings

import lxml.etree as ET
Expand Down Expand Up @@ -664,6 +663,16 @@ class WeightWindowGenerator:
maximum and minimum energy for the data available at runtime.
particle_type : {'neutron', 'photon'}
Particle type the weight windows apply to
method : {'magic'}
The weight window generation methodology applied during an update. Only
'magic' is currently supported.
max_realizations : int
The upper limit for number of tally realizations when generating weight
windows.
update_interval : int
The number of tally realizations between updates.
on_the_fly : bool
Whether or not to apply weight windows on the fly.

Attributes
----------
Expand All @@ -681,30 +690,36 @@ class WeightWindowGenerator:
The upper limit for number of tally realizations when generating weight
windows.
update_interval : int
The number of tally realizations between updates. (default: 1)
The number of tally realizations between updates.
update_parameters : dict
A set of parameters related to the update.
on_the_fly : bool
Whether or not to apply weight windows on the fly. (default: True)
Whether or not to apply weight windows on the fly.
"""

_MAGIC_PARAMS = {'value': str, 'threshold': float, 'ratio': float}

def __init__(self, mesh, energy_bounds=None, particle_type='neutron'):
def __init__(
self,
mesh: openmc.MeshBase,
energy_bounds: Optional[Sequence[float]] = None,
particle_type: str = 'neutron',
method: str = 'magic',
max_realizations: int = 1,
update_interval: int = 1,
on_the_fly: bool = True
):
self._update_parameters = None

self.mesh = mesh
self._energy_bounds = None
if energy_bounds is not None:
self.energy_bounds = energy_bounds
self.particle_type = particle_type
self.max_realizations = 1

self._update_parameters = None

self.method = 'magic'
self.particle_type = particle_type
self.update_interval = 1
self.on_the_fly = True

self.method = method
self.max_realizations = max_realizations
self.update_interval = update_interval
self.on_the_fly = on_the_fly

def __repr__(self):
string = type(self).__name__ + '\n'
Expand Down Expand Up @@ -927,4 +942,4 @@ def hdf5_to_wws(path='weight_windows.h5'):
for mesh_group in h5_file['meshes']:
mesh = MeshBase.from_hdf5(h5_file['meshes'][mesh_group])
meshes[mesh.id] = mesh
return [WeightWindows.from_hdf5(ww, meshes) for ww in h5_file['weight_windows'].values()]
return [WeightWindows.from_hdf5(ww, meshes) for ww in h5_file['weight_windows'].values()]