fixing expansion of elemental Ta bug (#3443)

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
GuySten 2025-06-18 18:10:03 +03:00 committed by GitHub
parent f31130d367
commit 1c5aa6559b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 5 deletions

View file

@ -94,7 +94,7 @@ NATURAL_ABUNDANCE = {
'Yb174': 0.32025, 'Yb176': 0.12995, 'Lu175': 0.97401,
'Lu176': 0.02599, 'Hf174': 0.0016, 'Hf176': 0.0526,
'Hf177': 0.186, 'Hf178': 0.2728, 'Hf179': 0.1362,
'Hf180': 0.3508, 'Ta180': 0.0001201, 'Ta181': 0.9998799,
'Hf180': 0.3508, 'Ta180_m1': 0.0001201, 'Ta181': 0.9998799,
'W180': 0.0012, 'W182': 0.265, 'W183': 0.1431,
'W184': 0.3064, 'W186': 0.2843, 'Re185': 0.374,
'Re187': 0.626, 'Os184': 0.0002, 'Os186': 0.0159,

View file

@ -144,8 +144,7 @@ class Element(str):
root = tree.getroot()
for child in root.findall('library'):
nuclide = child.attrib['materials']
if re.match(r'{}\d+'.format(self), nuclide) and \
'_m' not in nuclide:
if re.match(r'{}\d+'.format(self), nuclide):
library_nuclides.add(nuclide)
# Get a set of the mutual and absent nuclides. Convert to lists
@ -185,8 +184,10 @@ class Element(str):
for nuclide in absent_nuclides:
if nuclide in ['O17', 'O18'] and 'O16' in mutual_nuclides:
abundances['O16'] += NATURAL_ABUNDANCE[nuclide]
elif nuclide == 'Ta180' and 'Ta181' in mutual_nuclides:
abundances['Ta181'] += NATURAL_ABUNDANCE[nuclide]
elif nuclide == 'Ta180_m1' and 'Ta180' in library_nuclides:
abundances['Ta180'] = NATURAL_ABUNDANCE[nuclide]
elif nuclide == 'Ta180_m1' and 'Ta181' in mutual_nuclides:
abundances['Ta181'] += NATURAL_ABUNDANCE[nuclide]
elif nuclide == 'W180' and 'W182' in mutual_nuclides:
abundances['W182'] += NATURAL_ABUNDANCE[nuclide]
else:

View file

@ -44,6 +44,13 @@ def test_expand_no_isotopes():
element.expand(100.0, 'ao')
def test_expand_ta():
ref = {'Ta180': 0.01201, 'Ta181': 99.98799}
element = openmc.Element('Ta')
for isotope in element.expand(100.0, 'ao'):
assert isotope[1] == approx(ref[isotope[0]])
def test_expand_exceptions():
""" Test that correct exceptions are raised for invalid input """