From 5556b0cedc0210ebc4913c6f6866cbf57ca4b4f4 Mon Sep 17 00:00:00 2001 From: josh Date: Wed, 22 Feb 2023 18:24:50 +0000 Subject: [PATCH] order nuclides by increasing mass number --- openmc/data/data.py | 2 +- openmc/element.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openmc/data/data.py b/openmc/data/data.py index 55bfb4f096..7d82a3c1f6 100644 --- a/openmc/data/data.py +++ b/openmc/data/data.py @@ -489,7 +489,7 @@ def isotopes(element): # Get the nuclides present in nature result = [] - for kv in sorted(NATURAL_ABUNDANCE.items()): + for kv in NATURAL_ABUNDANCE.items(): if re.match(r'{}\d+'.format(element), kv[0]): result.append(kv) diff --git a/openmc/element.py b/openmc/element.py index 729266cc27..f1a5d31d3e 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -4,7 +4,7 @@ from xml.etree import ElementTree as ET import openmc.checkvalue as cv import openmc -from openmc.data import NATURAL_ABUNDANCE, atomic_mass, \ +from openmc.data import NATURAL_ABUNDANCE, atomic_mass, zam, \ isotopes as natural_isotopes @@ -147,8 +147,8 @@ class Element(str): # and sort to avoid different ordering between Python 2 and 3. mutual_nuclides = natural_nuclides.intersection(library_nuclides) absent_nuclides = natural_nuclides.difference(mutual_nuclides) - mutual_nuclides = sorted(list(mutual_nuclides)) - absent_nuclides = sorted(list(absent_nuclides)) + mutual_nuclides = sorted(mutual_nuclides, key=zam) + absent_nuclides = sorted(absent_nuclides, key=zam) # If all naturally occurring isotopes are present in the library, # add them based on their abundance @@ -195,7 +195,7 @@ class Element(str): # If a cross_section library is not present, expand the element into # its natural nuclides else: - for nuclide in sorted(list(natural_nuclides)): + for nuclide in sorted(natural_nuclides, key=zam): abundances[nuclide] = NATURAL_ABUNDANCE[nuclide] # Modify mole fractions if enrichment provided