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

Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
vanessalulla 2024-06-17 23:31:34 -04:00 committed by GitHub
parent ce4176deb5
commit 97537d5e9a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 36 additions and 30 deletions

View file

@ -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

View file

@ -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

View file

@ -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
@ -358,7 +358,7 @@ class Settings:
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 = {}
@ -1007,14 +1007,18 @@ class Settings:
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:
@ -1472,10 +1476,10 @@ class Settings:
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:
@ -1834,10 +1838,10 @@ class Settings:
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')
@ -1915,7 +1919,7 @@ class Settings:
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)
@ -2019,7 +2023,7 @@ class Settings:
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)

View file

@ -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;

View file

@ -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};
@ -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")) {

View file

@ -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);

View file

@ -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)

View file

@ -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">

View file

@ -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])

View file

@ -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])

View file

@ -55,7 +55,7 @@ def model():
run_mode='fixed source',
particles=100,
batches=10,
max_splits=10,
max_history_splits=10,
survival_biasing=False
)