Skip to content

Commit

Permalink
Rename max_splits to max_history_splits, set default value to 1.0e7 (#…
Browse files Browse the repository at this point in the history
…2954)

Co-authored-by: Patrick Shriwise <[email protected]>
Co-authored-by: Paul Romano <[email protected]>
  • Loading branch information
3 people authored Jun 18, 2024
1 parent ce4176d commit 97537d5
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 30 deletions.
4 changes: 2 additions & 2 deletions docs/source/io_formats/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ then, OpenMC will only use up to the :math:`P_1` data.
:ref:`energy_mode`.

------------------------
``<max_splits>`` Element
``<max_history_splits>`` Element
------------------------

The ``<max_splits>`` element indicates the number of times a particle can split during a history.
The ``<max_history_splits>`` element indicates the number of times a particle can split during a history.

*Default*: 1000

Expand Down
3 changes: 2 additions & 1 deletion include/openmc/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ extern std::unordered_set<int>
statepoint_batch; //!< Batches when state should be written
extern std::unordered_set<int>
source_write_surf_id; //!< Surface ids where sources will be written
extern int max_splits; //!< maximum number of particle splits for weight windows
extern int
max_history_splits; //!< maximum number of particle splits for weight windows
extern int64_t max_surface_particles; //!< maximum number of particles to be
//!< banked on surfaces per process
extern TemperatureMethod
Expand Down
36 changes: 20 additions & 16 deletions openmc/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Settings:
.. versionadded:: 0.14.1
max_order : None or int
Maximum scattering order to apply globally when in multi-group mode.
max_splits : int
max_history_splits : int
Maximum number of times a particle can split during a history
.. versionadded:: 0.13
Expand Down Expand Up @@ -358,7 +358,7 @@ def __init__(self, **kwargs):
self._weight_windows_on = None
self._weight_windows_file = None
self._weight_window_checkpoints = {}
self._max_splits = None
self._max_history_splits = None
self._max_tracks = None

self._random_ray = {}
Expand Down Expand Up @@ -1007,14 +1007,18 @@ def weight_window_checkpoints(self, weight_window_checkpoints: dict):
self._weight_window_checkpoints = weight_window_checkpoints

@property
def max_splits(self) -> int:
return self._max_splits
def max_splits(self):
raise AttributeError('max_splits has been deprecated. Please use max_history_splits instead')

@max_splits.setter
def max_splits(self, value: int):
@property
def max_history_splits(self) -> int:
return self._max_history_splits

@max_history_splits.setter
def max_history_splits(self, value: int):
cv.check_type('maximum particle splits', value, Integral)
cv.check_greater_than('max particle splits', value, 0)
self._max_splits = value
self._max_history_splits = value

@property
def max_tracks(self) -> int:
Expand Down Expand Up @@ -1472,10 +1476,10 @@ def _create_weight_window_checkpoints_subelement(self, root):
subelement = ET.SubElement(element, "surface")
subelement.text = str(self._weight_window_checkpoints['surface']).lower()

def _create_max_splits_subelement(self, root):
if self._max_splits is not None:
elem = ET.SubElement(root, "max_splits")
elem.text = str(self._max_splits)
def _create_max_history_splits_subelement(self, root):
if self._max_history_splits is not None:
elem = ET.SubElement(root, "max_history_splits")
elem.text = str(self._max_history_splits)

def _create_max_tracks_subelement(self, root):
if self._max_tracks is not None:
Expand Down Expand Up @@ -1834,10 +1838,10 @@ def _weight_window_checkpoints_from_xml_element(self, root):
value = value in ('true', '1')
self.weight_window_checkpoints[key] = value

def _max_splits_from_xml_element(self, root):
text = get_text(root, 'max_splits')
def _max_history_splits_from_xml_element(self, root):
text = get_text(root, 'max_history_splits')
if text is not None:
self.max_splits = int(text)
self.max_history_splits = int(text)

def _max_tracks_from_xml_element(self, root):
text = get_text(root, 'max_tracks')
Expand Down Expand Up @@ -1915,7 +1919,7 @@ def to_xml_element(self, mesh_memo=None):
self._create_weight_window_generators_subelement(element, mesh_memo)
self._create_weight_windows_file_element(element)
self._create_weight_window_checkpoints_subelement(element)
self._create_max_splits_subelement(element)
self._create_max_history_splits_subelement(element)
self._create_max_tracks_subelement(element)
self._create_random_ray_subelement(element)

Expand Down Expand Up @@ -2019,7 +2023,7 @@ def from_xml_element(cls, elem, meshes=None):
settings._weight_windows_from_xml_element(elem, meshes)
settings._weight_window_generators_from_xml_element(elem, meshes)
settings._weight_window_checkpoints_from_xml_element(elem)
settings._max_splits_from_xml_element(elem)
settings._max_history_splits_from_xml_element(elem)
settings._max_tracks_from_xml_element(elem)
settings._random_ray_from_xml_element(elem)

Expand Down
4 changes: 2 additions & 2 deletions src/finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ int openmc_finalize()
settings::max_lost_particles = 10;
settings::max_order = 0;
settings::max_particles_in_flight = 100000;
settings::max_particle_events = 1000000;
settings::max_splits = 1000;
settings::max_particle_events = 1'000'000;
settings::max_history_splits = 10'000'000;
settings::max_tracks = 1000;
settings::max_write_lost_particles = -1;
settings::n_log_bins = 8000;
Expand Down
7 changes: 4 additions & 3 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int max_order {0};
int n_log_bins {8000};
int n_batches;
int n_max_batches;
int max_splits {1000};
int max_history_splits {10'000'000};
int max_tracks {1000};
ResScatMethod res_scat_method {ResScatMethod::rvs};
double res_scat_energy_min {0.01};
Expand Down Expand Up @@ -981,8 +981,9 @@ void read_settings_xml(pugi::xml_node root)
weight_windows_on = get_node_value_bool(root, "weight_windows_on");
}

if (check_for_node(root, "max_splits")) {
settings::max_splits = std::stoi(get_node_value(root, "max_splits"));
if (check_for_node(root, "max_history_splits")) {
settings::max_history_splits =
std::stoi(get_node_value(root, "max_history_splits"));
}

if (check_for_node(root, "max_tracks")) {
Expand Down
2 changes: 1 addition & 1 deletion src/weight_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void apply_weight_windows(Particle& p)
// the window
if (weight > weight_window.upper_weight) {
// do not further split the particle if above the limit
if (p.n_split() >= settings::max_splits)
if (p.n_split() >= settings::max_history_splits)
return;

double n_split = std::ceil(weight / weight_window.upper_weight);
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/weightwindows/generators/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_ww_generator(run_in_tmpdir):
model.settings.particles = 500
model.settings.batches = 5
model.settings.run_mode = 'fixed source'
model.settings.max_splits = 100
model.settings.max_history_splits = 100

mesh = openmc.RegularMesh.from_domain(model.geometry.root_universe)
energy_bounds = np.linspace(0.0, 1e6, 70)
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/weightwindows/inputs_true.dat
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<max_split>10</max_split>
<weight_cutoff>1e-38</weight_cutoff>
</weight_windows>
<max_splits>200</max_splits>
<max_history_splits>200</max_history_splits>
</settings>
<tallies>
<mesh id="1">
Expand Down
2 changes: 1 addition & 1 deletion tests/regression_tests/weightwindows/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def model():
settings.run_mode = 'fixed source'
settings.particles = 200
settings.batches = 2
settings.max_splits = 200
settings.max_history_splits = 200
settings.photon_transport = True
space = Point((0.001, 0.001, 0.001))
energy = Discrete([14E6], [1.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/weightwindows/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def model():
settings.run_mode = 'fixed source'
settings.particles = 500
settings.batches = 2
settings.max_splits = 100
settings.max_history_splits = 100
settings.photon_transport = True
space = Point((0.001, 0.001, 0.001))
energy = Discrete([14E6], [1.0])
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/weightwindows/test_ww_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def model():
run_mode='fixed source',
particles=100,
batches=10,
max_splits=10,
max_history_splits=10,
survival_biasing=False
)

Expand Down

0 comments on commit 97537d5

Please sign in to comment.