Fix Resetting of Auto IDs When Generating MGXS (#3437)

This commit is contained in:
John Tramm 2025-06-12 19:54:35 -05:00 committed by GitHub
parent f81962c960
commit aeb1052c19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1552,7 +1552,6 @@ class Model:
"if a material has a k-infinity > 1.0.")
mgxs_sets = []
for material in self.materials:
openmc.reset_auto_ids()
model = openmc.Model()
# Set materials on the model
@ -1749,7 +1748,6 @@ class Model:
directory : str
Directory to run the simulation in, so as to contain XML files.
"""
openmc.reset_auto_ids()
model = openmc.Model()
model.materials = self.materials
@ -1861,7 +1859,6 @@ class Model:
directory : PathLike
Directory to run the simulation in, so as to contain XML files.
"""
openmc.reset_auto_ids()
model = copy.deepcopy(self)
model.tallies = openmc.Tallies()
@ -1973,7 +1970,7 @@ class Model:
# Make sure all materials have a name, and that the name is a valid HDF5
# dataset name
for material in self.materials:
if material.name is None:
if not material.name or not material.name.strip():
material.name = f"material {material.id}"
material.name = re.sub(r'[^a-zA-Z0-9]', '_', material.name)