diff --git a/docs/source/usersguide/materials.rst b/docs/source/usersguide/materials.rst index 90b624192..69647342a 100644 --- a/docs/source/usersguide/materials.rst +++ b/docs/source/usersguide/materials.rst @@ -40,7 +40,7 @@ of an element, you specify the element itself. For example, mat.add_element('C', 1.0) -This method can also accept element names, insensitive to case, such as +This method can also accept case-insensitive element names such as :: diff --git a/openmc/data/data.py b/openmc/data/data.py index b2ab9462a..5440dec7c 100644 --- a/openmc/data/data.py +++ b/openmc/data/data.py @@ -112,30 +112,30 @@ NATURAL_ABUNDANCE = { # Dictionary to give element symbols from IUPAC names # (and some common mispellings) -ELEMENT_SYMBOL = {'neutron': 'n', 'hydrogen': 'H', 'helium': 'He', - 'lithium': 'Li', 'beryllium': 'Be', 'boron': 'B', +ELEMENT_SYMBOL = {'neutron': 'n', 'hydrogen': 'H', 'helium': 'He', + 'lithium': 'Li', 'beryllium': 'Be', 'boron': 'B', 'carbon': 'C', 'nitrogen': 'N', 'oxygen': 'O', 'fluorine': 'F', 'neon': 'Ne', 'sodium': 'Na', 'magnesium': 'Mg', - 'aluminium': 'Al', 'aluminum':'Al', 'silicon': 'Si', - 'phosphorus': 'P', 'sulfur': 'S', 'sulphur': 'S', - 'chlorine': 'Cl', 'argon': 'Ar', 'potassium': 'K', + 'aluminium': 'Al', 'aluminum': 'Al', 'silicon': 'Si', + 'phosphorus': 'P', 'sulfur': 'S', 'sulphur': 'S', + 'chlorine': 'Cl', 'argon': 'Ar', 'potassium': 'K', 'calcium': 'Ca', 'scandium': 'Sc', 'titanium': 'Ti', 'vanadium': 'V', 'chromium': 'Cr', 'manganese': 'Mn', 'iron': 'Fe', 'cobalt': 'Co', 'nickel': 'Ni', 'copper': 'Cu', 'zinc': 'Zn', 'gallium': 'Ga', 'germanium': 'Ge', - 'arsenic': 'As', 'selenium': 'Se', 'bromine': 'Br', - 'krypton': 'Kr', 'rubidium': 'Rb', 'strontium': 'Sr', - 'yttrium': 'Y', 'zirconium': 'Zr', 'niobium': 'Nb', - 'molybdenum': 'Mo', 'technetium': 'Tc', 'ruthenium': 'Ru', - 'rhodium': 'Rh', 'palladium': 'Pd', 'silver': 'Ag', + 'arsenic': 'As', 'selenium': 'Se', 'bromine': 'Br', + 'krypton': 'Kr', 'rubidium': 'Rb', 'strontium': 'Sr', + 'yttrium': 'Y', 'zirconium': 'Zr', 'niobium': 'Nb', + 'molybdenum': 'Mo', 'technetium': 'Tc', 'ruthenium': 'Ru', + 'rhodium': 'Rh', 'palladium': 'Pd', 'silver': 'Ag', 'cadmium': 'Cd', 'indium': 'In', 'tin': 'Sn', 'antimony': 'Sb', 'tellurium': 'Te', 'iodine': 'I', 'xenon': 'Xe', 'caesium': 'Cs', 'cesium': 'Cs', 'barium': 'Ba', 'lanthanum': 'La', 'cerium': 'Ce', 'praseodymium': 'Pr', - 'neodymium': 'Nd', 'promethium': 'Pm', 'samarium': 'Sm', - 'europium': 'Eu', 'gadolinium': 'Gd', 'terbium': 'Tb', - 'dysprosium': 'Dy', 'holmium': 'Ho', 'erbium': 'Er', - 'thulium': 'Tm', 'ytterbium': 'Yb', 'lutetium': 'Lu', + 'neodymium': 'Nd', 'promethium': 'Pm', 'samarium': 'Sm', + 'europium': 'Eu', 'gadolinium': 'Gd', 'terbium': 'Tb', + 'dysprosium': 'Dy', 'holmium': 'Ho', 'erbium': 'Er', + 'thulium': 'Tm', 'ytterbium': 'Yb', 'lutetium': 'Lu', 'hafnium': 'Hf', 'tantalum': 'Ta', 'tungsten': 'W', 'wolfram': 'W', 'rhenium': 'Re', 'osmium': 'Os', 'iridium': 'Ir', 'platinum': 'Pt', 'gold': 'Au', diff --git a/openmc/material.py b/openmc/material.py index d6147b341..122d7d8ca 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -528,7 +528,7 @@ class Material(IDManagerMixin): "element's symbol or name, e.g., 'Zr', 'zirconium'") # Allow for element identifier to be given as a symbol or name - if len(element)>2: + if len(element) > 2: el = element.lower() element = openmc.data.ELEMENT_SYMBOL.get(el) if element is None: diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 35b10b8b3..095df8df9 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -37,17 +37,17 @@ def test_elements(): def test_elements_by_name(): """Test adding elements by name""" m = openmc.Material() - m.add_element('woLfrAm',1.0) + m.add_element('woLfrAm', 1.0) with pytest.raises(ValueError): - m.add_element('uranum',1.0) - m.add_element('uRaNiUm',1.0) - m.add_element('Aluminium',1.0) + m.add_element('uranum', 1.0) + m.add_element('uRaNiUm', 1.0) + m.add_element('Aluminium', 1.0) a = openmc.Material() b = openmc.Material() c = openmc.Material() - a.add_element('sulfur',1.0) - b.add_element('SulPhUR',1.0) - c.add_element('S',1.0) + a.add_element('sulfur', 1.0) + b.add_element('SulPhUR', 1.0) + c.add_element('S', 1.0) assert a._nuclides == b._nuclides assert b._nuclides == c._nuclides