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

Rename max_splits to max_history_splits, set default value to 1.0e7 #2954

Merged
merged 8 commits into from
Jun 18, 2024
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 @@ -120,7 +120,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 @@ -115,7 +115,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 @@ -345,7 +345,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

for key, value in kwargs.items():
Expand Down Expand Up @@ -992,14 +992,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 replaced by max_history_splits')

@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 @@ -1432,10 +1436,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 @@ -1783,10 +1787,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 @@ -1853,7 +1857,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)

# Clean the indentation in the file to be user-readable
Expand Down Expand Up @@ -1956,7 +1960,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)

# TODO: Get volume calculations
Expand Down
2 changes: 1 addition & 1 deletion src/finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int openmc_finalize()
settings::max_order = 0;
settings::max_particles_in_flight = 100000;
settings::max_particle_events = 1000000;
settings::max_splits = 1000;
settings::max_history_splits = 1.0e7;
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 @@ -106,7 +106,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 {1.0e7};
int max_tracks {1000};
ResScatMethod res_scat_method {ResScatMethod::rvs};
double res_scat_energy_min {0.01};
Expand Down Expand Up @@ -937,8 +937,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
4 changes: 3 additions & 1 deletion tests/regression_tests/plot/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


def test_plot():
harness = PlotTestHarness(('plot_1.png', 'plot_2.png', 'plot_3.png',
harness = PlotTestHarness(('./not-a-dir/plot_1.png', 'plot_2.png', 'plot_3.png',
'plot_4.h5'))
harness.main()


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/results_true.dat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ebc761815175b25fc95a226174928c226a3ab5dbf3b2a2abf09e079a0b87dee1dee74aa9b9eaec35acd58b8c481d264be7e9b3f052905bcc14ccd76f36b01549
62db808face24026fa14b5c8be96ee2d8409ba3c1e073daf843abe2035c04078885b860aea81cf564ef8820e848eaa08f9009e4db8d4c44904870c7a7bfd6d41
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
Loading