diff --git a/docs/source/io_formats/settings.rst b/docs/source/io_formats/settings.rst index ead440ae9..7f58ee3ab 100644 --- a/docs/source/io_formats/settings.rst +++ b/docs/source/io_formats/settings.rst @@ -1050,6 +1050,12 @@ sub-elements/attributes: *Default*: 3.0 + :max_lower_bound_ratio: + Maximum allowed ratio of a particle's weight to the weight window's lower + bound. A factor will be applied to raise the weight window to be lower than + the particle's weight by a factor of max_lower_bound_ratio during transport + if exceeded. + :max_split: Maximum allowable number of particles when splitting diff --git a/include/openmc/particle_data.h b/include/openmc/particle_data.h index 727be0ec0..b3a31ff42 100644 --- a/include/openmc/particle_data.h +++ b/include/openmc/particle_data.h @@ -310,8 +310,7 @@ private: // Weight window information int n_split_ {0}; // Number of times this particle has been split - // Particle-specific factor for on-the-fly weight window adjustment - double ww_factor_ {0.0}; + double ww_factor_ {0.0}; // Particle-specific factor for on-the-fly weight window adjustment // DagMC state variables #ifdef DAGMC diff --git a/openmc/weight_windows.py b/openmc/weight_windows.py index f19dfcadc..118f58fca 100644 --- a/openmc/weight_windows.py +++ b/openmc/weight_windows.py @@ -48,11 +48,11 @@ class WeightWindows(IDManagerMixin): survival_ratio : float Ratio of the survival weight to the lower weight window bound for rouletting - max_lower_bound_ratio: float + max_lower_bound_ratio : float Maximum allowed ratio of a particle's weight to the weight window's lower bound. A factor will be applied to raise the weight window to be lower than the particle's weight by a factor of max_lower_bound_ratio - during transport if exceeded. Only applied if > 1.0. (Default: 1.0). + during transport if exceeded. max_split : int Maximum allowable number of particles when splitting weight_cutoff : float @@ -99,7 +99,8 @@ class WeightWindows(IDManagerMixin): def __init__(self, mesh, lower_ww_bounds, upper_ww_bounds=None, upper_bound_ratio=None, energy_bins=None, particle_type='neutron', - survival_ratio=3, max_lb_ratio=1.0, max_split=10, weight_cutoff=1.e-38, id=None): + survival_ratio=3, max_lower_bound_ratio=None, max_split=10, + weight_cutoff=1.e-38, id=None): self.mesh = mesh self.id = id self.particle_type = particle_type @@ -129,7 +130,8 @@ class WeightWindows(IDManagerMixin): 'do not match') self.survival_ratio = survival_ratio - self.max_lower_bound_ratio = max_lb_ratio + if self.max_lower_bound_ratio is not None: + self.max_lower_bound_ratio = max_lower_bound_ratio self.max_split = max_split self.weight_cutoff = weight_cutoff @@ -260,8 +262,9 @@ class WeightWindows(IDManagerMixin): subelement = ET.SubElement(element, 'survival_ratio') subelement.text = str(self.survival_ratio) - subelement = ET.SubElement(element, 'max_lower_bound_ratio') - subelement.text = str(self.max_lower_bound_ratio) + if self.max_lower_bound_ratio is not None: + subelement = ET.SubElement(element, 'max_lower_bound_ratio') + subelement.text = str(self.max_lower_bound_ratio) subelement = ET.SubElement(element, 'max_split') subelement.text = str(self.max_split) @@ -300,7 +303,11 @@ class WeightWindows(IDManagerMixin): ebins = [float(b) for b in get_text(elem, 'energy_bins').split()] particle_type = get_text(elem, 'particle_type') survival_ratio = float(get_text(elem, 'survival_ratio')) - max_lb_ratio = float(get_text(elem, 'max_lower_bound_ratio')) + + max_lower_bound_ratio = None + if get_text(elem, 'max_lower_bound_ratio'): + max_lower_bound_ratio = float(get_text(elem, 'max_lower_bound_ratio')) + max_split = int(get_text(elem, 'max_split')) weight_cutoff = float(get_text(elem, 'weight_cutoff')) id = int(get_text(elem, 'id')) @@ -312,7 +319,7 @@ class WeightWindows(IDManagerMixin): energy_bins=ebins, particle_type=particle_type, survival_ratio=survival_ratio, - max_lb_ratio=max_lb_ratio, + max_lower_bound_ratio=max_lower_bound_ratio, max_split=max_split, weight_cutoff=weight_cutoff, id=id @@ -342,7 +349,11 @@ class WeightWindows(IDManagerMixin): lower_ww_bounds = group['lower_ww_bounds'][()] upper_ww_bounds = group['upper_ww_bounds'][()] survival_ratio = group['survival_ratio'][()] - max_lb_ratio = group['max_lower_bound_ratio'][()] + + max_lower_bound_ratio = None + if group.get('max_lower_bound_ratio') is not None: + max_lower_bound_ratio = group['max_lower_bound_ratio'][()] + max_split = group['max_split'][()] weight_cutoff = group['weight_cutoff'][()] @@ -353,7 +364,7 @@ class WeightWindows(IDManagerMixin): energy_bins=ebins, particle_type=ptype, survival_ratio=survival_ratio, - max_lb_ratio=max_lb_ratio, + max_lower_bound_ratio=max_lower_bound_ratio, max_split=max_split, weight_cutoff=weight_cutoff, id=id