diff --git a/openmc/element.py b/openmc/element.py index d18c5213f2..c882791095 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -36,7 +36,7 @@ class Element(str): return self def expand(self, percent, percent_type, enrichment=None, - enrichment_target=None, enrichment_type='ao', + enrichment_target=None, enrichment_type=None, cross_sections=None): """Expand natural element into its naturally-occurring isotopes. @@ -87,13 +87,11 @@ class Element(str): ValueError Enrichment is requested of the element that is not composed of two isotopes. - ValueError - If `enrichment_type` is not 'ao' or 'wo' - ValueError - If `enrichment` is outside <0;100> range ValueError If enrichment procedure for Uranium is used when element is not Uranium. + ValueError + Uranium enrichment is requested with enrichment_type=='ao' Notes ----- @@ -112,7 +110,8 @@ class Element(str): """ # Check input - cv.check_value('enrichment_type', enrichment_type, {'ao', 'wo'}) + if enrichment_type is not None: + cv.check_value('enrichment_type', enrichment_type, {'ao', 'wo'}) if enrichment is not None: cv.check_less_than('enrichment', enrichment, 100.0, equality=True) @@ -215,6 +214,12 @@ class Element(str): 'but the isotope is {0} not U'.format(self) raise ValueError(msg) + # Check that enrichment_type is not 'ao' + if enrichment_type == 'ao': + msg = 'Enrichment procedure for Uranium requires that '\ + 'enrichment value is provided as wo%.' + raise ValueError(msg) + # Calculate the mass fractions of isotopes abundances['U234'] = 0.0089 * enrichment abundances['U235'] = enrichment @@ -232,7 +237,6 @@ class Element(str): # Modify mole fractions if enrichment provided # New treatment for arbitrary element - # Interpret required enrichment as weight elif enrichment is not None and enrichment_target is not None: # Provide more informative error message for U235 diff --git a/openmc/material.py b/openmc/material.py index b1c5a7ccaa..aea6a10376 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -500,7 +500,7 @@ class Material(IDManagerMixin): self._macroscopic = None def add_element(self, element, percent, percent_type='ao', enrichment=None, - enrichment_target=None, enrichment_type='ao'): + enrichment_target=None, enrichment_type=None): """Add a natural element to the material Parameters diff --git a/tests/unit_tests/test_element.py b/tests/unit_tests/test_element.py index 727fc69501..5a17f1f221 100644 --- a/tests/unit_tests/test_element.py +++ b/tests/unit_tests/test_element.py @@ -77,3 +77,8 @@ def test_expand_exceptions(): with pt.raises(ValueError): element = openmc.element.Element('U') fail = element.expand(70.0, 'ao', 4.0, 'U235', 'wo') + + # Trying to enrich Uranium with wrong enrichment_target + with pt.raises(ValueError): + element = openmc.element.Element('U') + fail = element.expand(70.0, 'ao', 4.0, enrichment_type='ao')