From d9b2c4dcccd222cddc3ac7d556a9f35ee6cbfd81 Mon Sep 17 00:00:00 2001 From: Paul Cosgrove Date: Thu, 27 Feb 2020 12:44:58 +0000 Subject: [PATCH 1/2] Requested changes for PR Modified data.py to align with OpenMC Python convention, added more elegant check for element names --- openmc/data/data.py | 1 + openmc/material.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openmc/data/data.py b/openmc/data/data.py index e34ab8d462..b2ab9462a9 100644 --- a/openmc/data/data.py +++ b/openmc/data/data.py @@ -4,6 +4,7 @@ import os import re from warnings import warn + # Isotopic abundances from Meija J, Coplen T B, et al, "Isotopic compositions # of the elements 2013 (IUPAC Technical Report)", Pure. Appl. Chem. 88 (3), # pp. 293-306 (2013). The "representative isotopic abundance" values from diff --git a/openmc/material.py b/openmc/material.py index 542ed90282..2bb461b02a 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -530,8 +530,9 @@ class Material(IDManagerMixin): # Allow for element identifier to be given as a symbol or name if len(element)>2: el = element.lower() - element = openmc.data.ELEMENT_SYMBOL.get(el,"empty") - if element == "empty": + if el in openmc.data.ELEMENT_SYMBOL: + element = openmc.data.ELEMENT_SYMBOL[el] + else: msg = 'Element name "{}" not recognised'.format(el) raise ValueError(msg) From 70b2f968f830d72ac727c982d43a4d0109907cd1 Mon Sep 17 00:00:00 2001 From: Paul Cosgrove Date: Thu, 27 Feb 2020 12:50:44 +0000 Subject: [PATCH 2/2] Even more elegant error check on element names --- openmc/material.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openmc/material.py b/openmc/material.py index 2bb461b02a..d6147b3419 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -530,9 +530,8 @@ class Material(IDManagerMixin): # Allow for element identifier to be given as a symbol or name if len(element)>2: el = element.lower() - if el in openmc.data.ELEMENT_SYMBOL: - element = openmc.data.ELEMENT_SYMBOL[el] - else: + element = openmc.data.ELEMENT_SYMBOL.get(el) + if element is None: msg = 'Element name "{}" not recognised'.format(el) raise ValueError(msg)