mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Merge pull request #641 from paulromano/mgxs-element
Add ability to expand natural elements in Python API
This commit is contained in:
commit
69ec73705b
5 changed files with 165 additions and 5 deletions
1
openmc/data/__init__.py
Normal file
1
openmc/data/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from .data import *
|
||||
101
openmc/data/data.py
Normal file
101
openmc/data/data.py
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
# Isotopic abundances from M. Berglund and M. E. Wieser, "Isotopic compositions
|
||||
# of the elements 2009 (IUPAC Technical Report)", Pure. Appl. Chem. 83 (2),
|
||||
# pp. 397--410 (2011).
|
||||
natural_abundance = {
|
||||
'H-1': 0.999885, 'H-2': 0.000115, 'He-3': 1.34e-06,
|
||||
'He-4': 0.99999866, 'Li-6': 0.0759, 'Li-7': 0.9241,
|
||||
'Be-9': 1.0, 'B-10': 0.199, 'B-11': 0.801,
|
||||
'C-12': 0.9893, 'C-13': 0.0107, 'N-14': 0.99636,
|
||||
'N-15': 0.00364, 'O-16': 0.99757, 'O-17': 0.00038,
|
||||
'O-18': 0.00205, 'F-19': 1.0, 'Ne-20': 0.9048,
|
||||
'Ne-21': 0.0027, 'Ne-22': 0.0925, 'Na-23': 1.0,
|
||||
'Mg-24': 0.7899, 'Mg-25': 0.1, 'Mg-26': 0.1101,
|
||||
'Al-27': 1.0, 'Si-28': 0.92223, 'Si-29': 0.04685,
|
||||
'Si-30': 0.03092, 'P-31': 1.0, 'S-32': 0.9499,
|
||||
'S-33': 0.0075, 'S-34': 0.0425, 'S-36': 0.0001,
|
||||
'Cl-35': 0.7576, 'Cl-37': 0.2424, 'Ar-36': 0.003336,
|
||||
'Ar-38': 0.000629, 'Ar-40': 0.996035, 'K-39': 0.932581,
|
||||
'K-40': 0.000117, 'K-41': 0.067302, 'Ca-40': 0.96941,
|
||||
'Ca-42': 0.00647, 'Ca-43': 0.00135, 'Ca-44': 0.02086,
|
||||
'Ca-46': 4e-05, 'Ca-48': 0.00187, 'Sc-45': 1.0,
|
||||
'Ti-46': 0.0825, 'Ti-47': 0.0744, 'Ti-48': 0.7372,
|
||||
'Ti-49': 0.0541, 'Ti-50': 0.0518, 'V-50': 0.0025,
|
||||
'V-51': 0.9975, 'Cr-50': 0.04345, 'Cr-52': 0.83789,
|
||||
'Cr-53': 0.09501, 'Cr-54': 0.02365, 'Mn-55': 1.0,
|
||||
'Fe-54': 0.05845, 'Fe-56': 0.91754, 'Fe-57': 0.02119,
|
||||
'Fe-58': 0.00282, 'Co-59': 1.0, 'Ni-58': 0.68077,
|
||||
'Ni-60': 0.26223, 'Ni-61': 0.011399, 'Ni-62': 0.036346,
|
||||
'Ni-64': 0.009255, 'Cu-63': 0.6915, 'Cu-65': 0.3085,
|
||||
'Zn-64': 0.4917, 'Zn-66': 0.2773, 'Zn-67': 0.0404,
|
||||
'Zn-68': 0.1845, 'Zn-70': 0.0061, 'Ga-69': 0.60108,
|
||||
'Ga-71': 0.39892, 'Ge-70': 0.2057, 'Ge-72': 0.2745,
|
||||
'Ge-73': 0.0775, 'Ge-74': 0.365, 'Ge-76': 0.0773,
|
||||
'As-75': 1.0, 'Se-74': 0.0089, 'Se-76': 0.0937,
|
||||
'Se-77': 0.0763, 'Se-78': 0.2377, 'Se-80': 0.4961,
|
||||
'Se-82': 0.0873, 'Br-79': 0.5069, 'Br-81': 0.4931,
|
||||
'Kr-78': 0.00355, 'Kr-80': 0.02286, 'Kr-82': 0.11593,
|
||||
'Kr-83': 0.115, 'Kr-84': 0.56987, 'Kr-86': 0.17279,
|
||||
'Rb-85': 0.7217, 'Rb-87': 0.2783, 'Sr-84': 0.0056,
|
||||
'Sr-86': 0.0986, 'Sr-87': 0.07, 'Sr-88': 0.8258,
|
||||
'Y-89': 1.0, 'Zr-90': 0.5145, 'Zr-91': 0.1122,
|
||||
'Zr-92': 0.1715, 'Zr-94': 0.1738, 'Zr-96': 0.028,
|
||||
'Nb-93': 1.0, 'Mo-92': 0.1453, 'Mo-94': 0.0915,
|
||||
'Mo-95': 0.1584, 'Mo-96': 0.1667, 'Mo-97': 0.096,
|
||||
'Mo-98': 0.2439, 'Mo-100': 0.0982, 'Ru-96': 0.0554,
|
||||
'Ru-98': 0.0187, 'Ru-99': 0.1276, 'Ru-100': 0.126,
|
||||
'Ru-101': 0.1706, 'Ru-102': 0.3155, 'Ru-104': 0.1862,
|
||||
'Rh-103': 1.0, 'Pd-102': 0.0102, 'Pd-104': 0.1114,
|
||||
'Pd-105': 0.2233, 'Pd-106': 0.2733, 'Pd-108': 0.2646,
|
||||
'Pd-110': 0.1172, 'Ag-107': 0.51839, 'Ag-109': 0.48161,
|
||||
'Cd-106': 0.0125, 'Cd-108': 0.0089, 'Cd-110': 0.1249,
|
||||
'Cd-111': 0.128, 'Cd-112': 0.2413, 'Cd-113': 0.1222,
|
||||
'Cd-114': 0.2873, 'Cd-116': 0.0749, 'In-113': 0.0429,
|
||||
'In-115': 0.9571, 'Sn-112': 0.0097, 'Sn-114': 0.0066,
|
||||
'Sn-115': 0.0034, 'Sn-116': 0.1454, 'Sn-117': 0.0768,
|
||||
'Sn-118': 0.2422, 'Sn-119': 0.0859, 'Sn-120': 0.3258,
|
||||
'Sn-122': 0.0463, 'Sn-124': 0.0579, 'Sb-121': 0.5721,
|
||||
'Sb-123': 0.4279, 'Te-120': 0.0009, 'Te-122': 0.0255,
|
||||
'Te-123': 0.0089, 'Te-124': 0.0474, 'Te-125': 0.0707,
|
||||
'Te-126': 0.1884, 'Te-128': 0.3174, 'Te-130': 0.3408,
|
||||
'I-127': 1.0, 'Xe-124': 0.000952, 'Xe-126': 0.00089,
|
||||
'Xe-128': 0.019102, 'Xe-129': 0.264006, 'Xe-130': 0.04071,
|
||||
'Xe-131': 0.212324, 'Xe-132': 0.269086, 'Xe-134': 0.104357,
|
||||
'Xe-136': 0.088573, 'Cs-133': 1.0, 'Ba-130': 0.00106,
|
||||
'Ba-132': 0.00101, 'Ba-134': 0.02417, 'Ba-135': 0.06592,
|
||||
'Ba-136': 0.07854, 'Ba-137': 0.11232, 'Ba-138': 0.71698,
|
||||
'La-138': 0.0008881, 'La-139': 0.9991119, 'Ce-136': 0.00185,
|
||||
'Ce-138': 0.00251, 'Ce-140': 0.8845, 'Ce-142': 0.11114,
|
||||
'Pr-141': 1.0, 'Nd-142': 0.27152, 'Nd-143': 0.12174,
|
||||
'Nd-144': 0.23798, 'Nd-145': 0.08293, 'Nd-146': 0.17189,
|
||||
'Nd-148': 0.05756, 'Nd-150': 0.05638, 'Sm-144': 0.0307,
|
||||
'Sm-147': 0.1499, 'Sm-148': 0.1124, 'Sm-149': 0.1382,
|
||||
'Sm-150': 0.0738, 'Sm-152': 0.2675, 'Sm-154': 0.2275,
|
||||
'Eu-151': 0.4781, 'Eu-153': 0.5219, 'Gd-152': 0.002,
|
||||
'Gd-154': 0.0218, 'Gd-155': 0.148, 'Gd-156': 0.2047,
|
||||
'Gd-157': 0.1565, 'Gd-158': 0.2484, 'Gd-160': 0.2186,
|
||||
'Tb-159': 1.0, 'Dy-156': 0.00056, 'Dy-158': 0.00095,
|
||||
'Dy-160': 0.02329, 'Dy-161': 0.18889, 'Dy-162': 0.25475,
|
||||
'Dy-163': 0.24896, 'Dy-164': 0.2826, 'Ho-165': 1.0,
|
||||
'Er-162': 0.00139, 'Er-164': 0.01601, 'Er-166': 0.33503,
|
||||
'Er-167': 0.22869, 'Er-168': 0.26978, 'Er-170': 0.1491,
|
||||
'Tm-169': 1.0, 'Yb-168': 0.00123, 'Yb-170': 0.02982,
|
||||
'Yb-171': 0.1409, 'Yb-172': 0.2168, 'Yb-173': 0.16103,
|
||||
'Yb-174': 0.32026, 'Yb-176': 0.12996, 'Lu-175': 0.97401,
|
||||
'Lu-176': 0.02599, 'Hf-174': 0.0016, 'Hf-176': 0.0526,
|
||||
'Hf-177': 0.186, 'Hf-178': 0.2728, 'Hf-179': 0.1362,
|
||||
'Hf-180': 0.3508, 'Ta-180': 0.0001201, 'Ta-181': 0.9998799,
|
||||
'W-180': 0.0012, 'W-182': 0.265, 'W-183': 0.1431,
|
||||
'W-184': 0.3064, 'W-186': 0.2843, 'Re-185': 0.374,
|
||||
'Re-187': 0.626, 'Os-184': 0.0002, 'Os-186': 0.0159,
|
||||
'Os-187': 0.0196, 'Os-188': 0.1324, 'Os-189': 0.1615,
|
||||
'Os-190': 0.2626, 'Os-192': 0.4078, 'Ir-191': 0.373,
|
||||
'Ir-193': 0.627, 'Pt-190': 0.00012, 'Pt-192': 0.00782,
|
||||
'Pt-194': 0.3286, 'Pt-195': 0.3378, 'Pt-196': 0.2521,
|
||||
'Pt-198': 0.07356, 'Au-197': 1.0, 'Hg-196': 0.0015,
|
||||
'Hg-198': 0.0997, 'Hg-199': 0.1687, 'Hg-200': 0.231,
|
||||
'Hg-201': 0.1318, 'Hg-202': 0.2986, 'Hg-204': 0.0687,
|
||||
'Tl-203': 0.2952, 'Tl-205': 0.7048, 'Pb-204': 0.014,
|
||||
'Pb-206': 0.241, 'Pb-207': 0.221, 'Pb-208': 0.524,
|
||||
'Bi-209': 1.0, 'Th-232': 1.0, 'Pa-231': 1.0,
|
||||
'U-234': 5.4e-05, 'U-235': 0.007204, 'U-238': 0.992742
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
import sys
|
||||
|
||||
import openmc
|
||||
from openmc.checkvalue import check_type
|
||||
from openmc.data import natural_abundance
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
basestring = str
|
||||
|
|
@ -109,3 +111,22 @@ class Element(object):
|
|||
raise ValueError(msg)
|
||||
|
||||
self._scattering = scattering
|
||||
|
||||
def expand(self):
|
||||
"""Expand natural element into its naturally-occurring isotopes.
|
||||
|
||||
Returns
|
||||
-------
|
||||
isotopes : list
|
||||
Naturally-occurring isotopes of the element. Each item of the list
|
||||
is a tuple consisting of an openmc.Nuclide instance and the natural
|
||||
abundance of the isotope.
|
||||
|
||||
"""
|
||||
|
||||
isotopes = []
|
||||
for isotope, abundance in natural_abundance.items():
|
||||
if isotope.startswith(self.name):
|
||||
nuc = openmc.Nuclide(isotope, self.xs)
|
||||
isotopes.append((nuc, abundance))
|
||||
return isotopes
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ if sys.version_info[0] >= 3:
|
|||
import openmc
|
||||
import openmc.checkvalue as cv
|
||||
from openmc.clean_xml import *
|
||||
from openmc.data import natural_abundance
|
||||
|
||||
|
||||
# A static variable for auto-generated Material IDs
|
||||
|
|
@ -49,6 +50,14 @@ class Material(object):
|
|||
Units used for `density`. Can be one of 'g/cm3', 'g/cc', 'kg/cm3',
|
||||
'atom/b-cm', 'atom/cm3', 'sum', or 'macro'. The 'macro' unit only
|
||||
applies in the case of a multi-group calculation.
|
||||
elements : collections.OrderedDict
|
||||
Dictionary whose keys are element names and values are 3-tuples
|
||||
consisting of an :class:`openmc.Element` instance, the percent density,
|
||||
and the percent type (atom or weight fraction).
|
||||
nuclides : collections.OrderedDict
|
||||
Dictionary whose keys are nuclide names and values are 3-tuples
|
||||
consisting of an :class:`openmc.Nuclide` instance, the percent density,
|
||||
and the percent type (atom or weight fraction).
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -186,6 +195,14 @@ class Material(object):
|
|||
def density_units(self):
|
||||
return self._density_units
|
||||
|
||||
@property
|
||||
def elements(self):
|
||||
return self._elements
|
||||
|
||||
@property
|
||||
def nuclides(self):
|
||||
return self._nuclides
|
||||
|
||||
@property
|
||||
def convert_to_distrib_comps(self):
|
||||
return self._convert_to_distrib_comps
|
||||
|
|
@ -382,7 +399,7 @@ class Material(object):
|
|||
if macroscopic._name == self._macroscopic.name:
|
||||
self._macroscopic = None
|
||||
|
||||
def add_element(self, element, percent, percent_type='ao'):
|
||||
def add_element(self, element, percent, percent_type='ao', expand=False):
|
||||
"""Add a natural element to the material
|
||||
|
||||
Parameters
|
||||
|
|
@ -391,8 +408,12 @@ class Material(object):
|
|||
Element to add
|
||||
percent : float
|
||||
Atom or weight percent
|
||||
percent_type : {'ao', 'wo'}
|
||||
'ao' for atom percent and 'wo' for weight percent
|
||||
percent_type : {'ao', 'wo'}, optional
|
||||
'ao' for atom percent and 'wo' for weight percent. Defaults to atom
|
||||
percent.
|
||||
expand : bool, optional
|
||||
Whether to expand the natural element into its naturally-occurring
|
||||
isotopes. Defaults to False.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -422,7 +443,15 @@ class Material(object):
|
|||
else:
|
||||
element = openmc.Element(element)
|
||||
|
||||
self._elements[element._name] = (element, percent, percent_type)
|
||||
if expand:
|
||||
if percent_type == 'wo':
|
||||
raise NotImplementedError('Expanding natural element based on '
|
||||
'weight percent is not yet supported.')
|
||||
for isotope, abundance in element.expand():
|
||||
self._nuclides[isotope.name] = (
|
||||
isotope, percent*abundance, percent_type)
|
||||
else:
|
||||
self._elements[element.name] = (element, percent, percent_type)
|
||||
|
||||
def remove_element(self, element):
|
||||
"""Remove a natural element from the material
|
||||
|
|
@ -491,6 +520,14 @@ class Material(object):
|
|||
density = nuclide_tuple[1]
|
||||
nuclides[nuclide._name] = (nuclide, density)
|
||||
|
||||
for element_name, element_tuple in self._elements.items():
|
||||
element = element_tuple[0]
|
||||
density = element_tuple[1]
|
||||
|
||||
# Expand natural element into isotopes
|
||||
for isotope, abundance in element.expand():
|
||||
nuclides[isotope.name] = (isotope, density*abundance)
|
||||
|
||||
return nuclides
|
||||
|
||||
def _get_nuclide_xml(self, nuclide, distrib=False):
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -11,7 +11,7 @@ except ImportError:
|
|||
|
||||
kwargs = {'name': 'openmc',
|
||||
'version': '0.7.1',
|
||||
'packages': ['openmc', 'openmc.mgxs', 'openmc.stats'],
|
||||
'packages': ['openmc', 'openmc.data', 'openmc.mgxs', 'openmc.stats'],
|
||||
'scripts': glob.glob('scripts/openmc-*'),
|
||||
|
||||
# Metadata
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue