diff --git a/openmc/material.py b/openmc/material.py index 37ebc8a77f..542078c7c1 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -12,17 +12,13 @@ from openmc.checkvalue import check_type, check_value, check_greater_than from openmc.clean_xml import * -# A list of all IDs for all Materials created -MATERIAL_IDS = [] - # A static variable for auto-generated Material IDs AUTO_MATERIAL_ID = 10000 def reset_auto_material_id(): - global AUTO_MATERIAL_ID, MATERIAL_IDS + global AUTO_MATERIAL_ID AUTO_MATERIAL_ID = 10000 - MATERIAL_IDS = [] # Units for density supported by OpenMC @@ -192,26 +188,15 @@ class Material(object): @id.setter def id(self, material_id): - global AUTO_MATERIAL_ID, MATERIAL_IDS - - # If the Material already has an ID, remove it from global list - if hasattr(self, '_id') and self._id is not None: - MATERIAL_IDS.remove(self._id) if material_id is None: + global AUTO_MATERIAL_ID self._id = AUTO_MATERIAL_ID - MATERIAL_IDS.append(AUTO_MATERIAL_ID) AUTO_MATERIAL_ID += 1 else: check_type('material ID', material_id, Integral) - if material_id in MATERIAL_IDS: - msg = 'Unable to set Material ID to "{0}" since a Material with ' \ - 'this ID was already initialized'.format(material_id) - raise ValueError(msg) check_greater_than('material ID', material_id, 0, equality=True) - self._id = material_id - MATERIAL_IDS.append(material_id) @name.setter def name(self, name): diff --git a/openmc/summary.py b/openmc/summary.py index 8e8d4bc7ee..45742b0c8a 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -575,7 +575,7 @@ class Summary(object): """ for index, material in self.materials.items(): - if material._id == material_id: + if material.id == material_id: return material return None @@ -596,7 +596,7 @@ class Summary(object): """ for index, surface in self.surfaces.items(): - if surface._id == surface_id: + if surface.id == surface_id: return surface return None @@ -617,7 +617,7 @@ class Summary(object): """ for index, cell in self.cells.items(): - if cell._id == cell_id: + if cell.id == cell_id: return cell return None @@ -638,7 +638,7 @@ class Summary(object): """ for index, universe in self.universes.items(): - if universe._id == universe_id: + if universe.id == universe_id: return universe return None @@ -659,7 +659,7 @@ class Summary(object): """ for index, lattice in self.lattices.items(): - if lattice._id == lattice_id: + if lattice.id == lattice_id: return lattice return None