Add openmc.data.atomic_mass function, finally

This commit is contained in:
Paul Romano 2016-08-05 11:25:55 -05:00
parent ab432ac151
commit 6bb147fe8f
4 changed files with 3449 additions and 2 deletions

View file

@ -324,6 +324,16 @@ Functions
:mod:`openmc.data` -- Nuclear Data Interface
--------------------------------------------
Physical Data
-------------
.. autosummary::
:toctree: generated
:nosignatures:
:template: myfunction.rst
openmc.data.atomic_mass
Core Classes
------------

View file

@ -1,3 +1,7 @@
import itertools
import os
# 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).
@ -119,9 +123,12 @@ ATOMIC_SYMBOL = {1: 'H', 2: 'He', 3: 'Li', 4: 'Be', 5: 'B', 6: 'C', 7: 'N',
98: 'Cf', 99: 'Es', 100: 'Fm', 101: 'Md', 102: 'No',
103: 'Lr', 104: 'Rf', 105: 'Db', 106: 'Sg', 107: 'Bh',
108: 'Hs', 109: 'Mt', 110: 'Ds', 111: 'Rg', 112: 'Cn',
114: 'Fl', 116: 'Lv'}
113: 'Nh', 114: 'Fl', 115: 'Mc', 116: 'Lv', 117: 'Ts',
118: 'Og'}
ATOMIC_NUMBER = {value: key for key, value in ATOMIC_SYMBOL.items()}
_ATOMIC_MASS = {}
REACTION_NAME = {1: '(n,total)', 2: '(n,elastic)', 4: '(n,level)',
5: '(n,misc)', 11: '(n,2nd)', 16: '(n,2n)', 17: '(n,3n)',
18: '(n,fission)', 19: '(n,f)', 20: '(n,nf)', 21: '(n,2nf)',
@ -175,3 +182,35 @@ SUM_RULES = {1: [2, 3],
105: list(range(700, 750)),
106: list(range(750, 800)),
107: list(range(800, 850))}
def atomic_mass(isotope):
"""Return atomic mass of isotope in atomic mass units.
Atomic mass data comes from the Atomic Mass Evaluation 2012, published in
Chinese Physics C 36 (2012), 1287--1602.
Parameters
----------
isotope : str
Name of isotope, e.g. 'Pu239'
Returns
-------
float or None
Atomic mass of isotope in atomic mass units. If the isotope listed does
not have a known atomic mass, None is returned.
"""
if not _ATOMIC_MASS:
# Load data from AME2012 file
mass_file = os.path.join(os.path.dirname(__file__), 'mass.mas12')
with open(mass_file, 'r') as ame:
# Read lines in file starting at line 40
for line in itertools.islice(ame, 40, None):
name = '{}{}'.format(line[20:22].strip(), int(line[16:19]))
mass = float(line[96:99]) + 1e-6*float(
line[100:106] + '.' + line[107:112])
_ATOMIC_MASS[name.lower()] = mass
return _ATOMIC_MASS.get(isotope.lower())

3392
openmc/data/mass.mas12 Normal file

File diff suppressed because it is too large Load diff

View file

@ -40,6 +40,12 @@ if have_setuptools:
'sparse' : ['scipy'],
'vtk': ['vtk', 'silomesh'],
'validate': ['lxml']
}})
},
# Data files
'package_data': {
'openmc.data': ['mass.mas12']
},
})
setup(**kwargs)