mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Merge pull request #756 from samuelshaner/molar-mass
Molar mass calculation
This commit is contained in:
commit
288521a217
3 changed files with 40 additions and 1 deletions
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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('_')]
|
||||
|
|
|
|||
|
|
@ -64,6 +64,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.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -194,6 +198,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):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue