Allow groups to be passed as sequence of floats in convert_to_multigroup (#3873)

Co-authored-by: Jonathan Shimwell <drshimwell@gmail.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Christopher Ashe 2026-03-12 19:47:47 +00:00 committed by GitHub
parent 27522fe851
commit c44d2f0b43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2520,7 +2520,7 @@ class Model:
def convert_to_multigroup(
self,
method: str = "material_wise",
groups: str = "CASMO-2",
groups: str | Sequence[float] | openmc.mgxs.EnergyGroups = "CASMO-2",
nparticles: int = 2000,
overwrite_mgxs_library: bool = False,
mgxs_path: PathLike = "mgxs.h5",
@ -2538,9 +2538,13 @@ class Model:
----------
method : {"material_wise", "stochastic_slab", "infinite_medium"}, optional
Method to generate the MGXS.
groups : openmc.mgxs.EnergyGroups or str, optional
Energy group structure for the MGXS or the name of the group
structure (based on keys from openmc.mgxs.GROUP_STRUCTURES).
groups : openmc.mgxs.EnergyGroups, str, or sequence of float, optional
Energy group structure for the MGXS. Can be an
:class:`openmc.mgxs.EnergyGroups` object, a string name of a
predefined group structure from :data:`openmc.mgxs.GROUP_STRUCTURES`
(e.g., ``"CASMO-2"``), or a sequence of floats specifying energy
bin boundaries in eV (e.g., ``[0.0, 1e6]`` for a single group).
Defaults to ``"CASMO-2"``.
nparticles : int, optional
Number of particles to simulate per batch when generating MGXS.
overwrite_mgxs_library : bool, optional
@ -2577,7 +2581,7 @@ class Model:
Valid entries for temperature_settings are the same as the valid
entries in openmc.Settings.temperature_settings.
"""
if isinstance(groups, str):
if not isinstance(groups, openmc.mgxs.EnergyGroups):
groups = openmc.mgxs.EnergyGroups(groups)
# Do all work (including MGXS generation) in a temporary directory