Fix bugs in Material.remove_nuclide and Material.remove_element

This commit is contained in:
Paul Romano 2017-03-10 09:07:17 -06:00
parent 97d99f1625
commit 247c2461c5

View file

@ -464,16 +464,16 @@ class Material(object):
Nuclide to remove
"""
cv.check_type('nuclide', nuclide, string_types + (openmc.Nuclide,))
if not isinstance(nuclide, openmc.Nuclide):
msg = 'Unable to remove a Nuclide "{}" in Material ID="{}" ' \
'since it is not a Nuclide'.format(self._id, nuclide)
raise ValueError(msg)
if isinstance(nuclide, string_types):
nuclide = openmc.Nuclide(nuclide)
# If the Material contains the Nuclide, delete it
for nuc in self._nuclides:
if nuclide == nuc:
if nuclide == nuc[0]:
self._nuclides.remove(nuc)
break
def add_macroscopic(self, macroscopic):
"""Add a macroscopic to the material. This will also set the
@ -625,15 +625,14 @@ class Material(object):
Element to remove
"""
cv.check_type('element', element, string_types + (openmc.Element,))
if not isinstance(element, openmc.Element):
msg = 'Unable to remove "{}" in Material ID="{}" ' \
'since it is not an Element'.format(self.id, element)
raise ValueError(msg)
if isinstance(element, string_types):
element = openmc.Element(element)
# If the Material contains the Element, delete it
for elm in self._elements:
if element == elm:
if element == elm[0]:
self._elements.remove(elm)
def add_s_alpha_beta(self, name):