From 0214b220367a6c58fc950ec2d241e40797b27f8a Mon Sep 17 00:00:00 2001 From: yardasol Date: Thu, 1 Sep 2022 11:52:21 -0500 Subject: [PATCH 1/4] fix errorneous behavior when adding metastable nuclides via add_components --- openmc/material.py | 3 ++- tests/unit_tests/test_material.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/openmc/material.py b/openmc/material.py index d9d4f241d..4a988c597 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -438,7 +438,8 @@ class Material(IDManagerMixin): params['percent_type'] = percent_type ## check if nuclide - if str.isdigit(component[-1]): + if str.isdigit(component[-1]) or (component[-1] == 'm' + and str.isdigit(component[-2])): self.add_nuclide(component, **params) else: # is element kwargs = params diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index 8bb881795..dde755231 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -32,6 +32,7 @@ def test_add_components(): 'O16': 1.0, 'Zr': 1.0, 'O': 1.0, + 'Ag110m': 1.0, 'U': {'percent': 1.0, 'enrichment': 4.5}, 'Li': {'percent': 1.0, From 85c5c791d6db687bd0deb9813a15d98808b931bd Mon Sep 17 00:00:00 2001 From: Olek <45364492+yardasol@users.noreply.github.com> Date: Thu, 1 Sep 2022 14:33:24 -0500 Subject: [PATCH 2/4] Cleanup flow control for detecting nuclides Co-authored-by: Paul Romano --- tests/unit_tests/test_material.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit_tests/test_material.py b/tests/unit_tests/test_material.py index dde755231..8e04ca192 100644 --- a/tests/unit_tests/test_material.py +++ b/tests/unit_tests/test_material.py @@ -32,7 +32,7 @@ def test_add_components(): 'O16': 1.0, 'Zr': 1.0, 'O': 1.0, - 'Ag110m': 1.0, + 'Ag110_m1': 1.0, 'U': {'percent': 1.0, 'enrichment': 4.5}, 'Li': {'percent': 1.0, From 2d01241b533b961ac2c9c4951855b6c2dbeed26a Mon Sep 17 00:00:00 2001 From: Olek <45364492+yardasol@users.noreply.github.com> Date: Thu, 1 Sep 2022 14:33:44 -0500 Subject: [PATCH 3/4] Cleanup flow control for detecting nuclides Co-authored-by: Paul Romano --- openmc/material.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openmc/material.py b/openmc/material.py index 4a988c597..de4940a47 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -438,8 +438,7 @@ class Material(IDManagerMixin): params['percent_type'] = percent_type ## check if nuclide - if str.isdigit(component[-1]) or (component[-1] == 'm' - and str.isdigit(component[-2])): + if not str.isalpha(): self.add_nuclide(component, **params) else: # is element kwargs = params From e34f786c6f6c5cf3c236aa9d8cb15cf39876aaa8 Mon Sep 17 00:00:00 2001 From: Olek <45364492+yardasol@users.noreply.github.com> Date: Wed, 7 Sep 2022 11:52:06 -0500 Subject: [PATCH 4/4] str->component in flow control Co-authored-by: Paul Romano --- openmc/material.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/material.py b/openmc/material.py index de4940a47..67615d74c 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -438,7 +438,7 @@ class Material(IDManagerMixin): params['percent_type'] = percent_type ## check if nuclide - if not str.isalpha(): + if not component.isalpha(): self.add_nuclide(component, **params) else: # is element kwargs = params