diff --git a/openmc/material.py b/openmc/material.py index de1b2187be..188ec2d471 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -407,6 +407,23 @@ class Material(IDManagerMixin): if nuclide == nuc.name: self.nuclides.remove(nuc) + def remove_element(self, element): + """Remove an element from the material + + Parameters + ---------- + element : str + Element to remove + + """ + cv.check_type('element', element, str) + + # If the Material contains the element, delete it + for nuc in reversed(self.nuclides): + element_name = re.split(r'(\d+)', nuc) + if nuc == element_name: + self.nuclides.remove(nuc) + def add_macroscopic(self, macroscopic): """Add a macroscopic to the material. This will also set the density of the material to 1.0, unless it has been otherwise set, diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 3a976da996..dda75c88be 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -43,7 +43,7 @@ def test_remove_elements(): m = openmc.Material() for elem, percent in [('Li', 1.0), ('Be', 1.0)]: m.add_element(elem, percent) - m.remove_nuclide('Li') + m.remove_element('Li') assert len(m.nuclides) == 1 assert m.nuclides == ['Be9'] assert m.nuclides[0].percent == 1.0