Merge remote-tracking branch 'upstream/develop' into plot_mat

This commit is contained in:
Adam Nelson 2016-11-11 05:22:01 -05:00
commit 3884123a59
3 changed files with 40 additions and 1 deletions

View file

@ -51,7 +51,7 @@ o = openmc.Element('O')
# Instantiate some Materials and register the appropriate Nuclides
uo2 = openmc.Material(material_id=1, name='UO2 fuel at 2.4% wt enrichment')
uo2.set_density('g/cm3', 10.29769)
uo2.add_element(u, 1., enrichment=0.024)
uo2.add_element(u, 1., enrichment=2.4)
uo2.add_element(o, 2.)
helium = openmc.Material(material_id=2, name='Helium for gap')

View file

@ -1,5 +1,6 @@
import itertools
import os
import re
# Isotopic abundances from M. Berglund and M. E. Wieser, "Isotopic compositions
@ -149,6 +150,7 @@ def atomic_mass(isotope):
"""
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:
@ -159,6 +161,18 @@ def atomic_mass(isotope):
line[100:106] + '.' + line[107:112])
_ATOMIC_MASS[name.lower()] = mass
# For isotopes found in some libraries that represent all natural
# isotopes of their element (e.g. C0), calculate the atomic mass as
# the sum of the atomic mass times the natural abudance of the isotopes
# that make up the element.
for element in ['C', 'Zn', 'Pt', 'Os', 'Tl']:
isotope_zero = element.lower() + '0'
_ATOMIC_MASS[isotope_zero] = 0.
for iso, abundance in NATURAL_ABUNDANCE.items():
if re.match(r'{}\d+'.format(element), iso):
_ATOMIC_MASS[isotope_zero] += abundance * \
_ATOMIC_MASS[iso.lower()]
# Get rid of metastable information
if '_' in isotope:
isotope = isotope[:isotope.find('_')]

View file

@ -66,6 +66,10 @@ class Material(object):
List in which each item is a 3-tuple consisting of an
:class:`openmc.Nuclide` instance, the percent density, and the percent
type ('ao' or 'wo').
average_molar_mass : float
The average molar mass of nuclides in the material in units of grams per
mol. For example, UO2 with 3 nuclides will have an average molar mass
of 270 / 3 = 90 g / mol.
"""
@ -196,6 +200,27 @@ class Material(object):
def distrib_otf_file(self):
return self._distrib_otf_file
@property
def average_molar_mass(self):
# Get a list of all the nuclides, with elements expanded
nuclide_densities = self.get_nuclide_densities()
# Using the sum of specified atomic or weight amounts as a basis, sum
# the mass and moles of the material
mass = 0.
moles = 0.
for nuc, vals in nuclide_densities.items():
if vals[2] == 'ao':
mass += vals[1] * openmc.data.atomic_mass(nuc)
moles += vals[1]
else:
moles += vals[1] / openmc.data.atomic_mass(nuc)
mass += vals[1]
# Compute and return the molar mass
return mass / moles
@id.setter
def id(self, material_id):