diff --git a/examples/python/pincell/build-xml.py b/examples/python/pincell/build-xml.py index 979614d635..2a550b9d73 100644 --- a/examples/python/pincell/build-xml.py +++ b/examples/python/pincell/build-xml.py @@ -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') diff --git a/openmc/data/data.py b/openmc/data/data.py index 1f759d3d4d..5dee5aca73 100644 --- a/openmc/data/data.py +++ b/openmc/data/data.py @@ -1,5 +1,6 @@ import itertools import os +import re # Isotopic abundances from M. Berglund and M. E. Wieser, "Isotopic compositions @@ -149,6 +150,28 @@ def atomic_mass(isotope): """ if not _ATOMIC_MASS: + + # If the isotope represents all natural isotopes of the element + # (e.g. C0), set atomic mass manually using the values from Atomic + # weights of the elements 2013 (IUPAC Technical Report) + # (doi:10.1515/pac-2015-0305). In cases where an atomic mass range is + # given (e.g. C), the average value is used. + if int(re.split(r"(\d+)", isotope)[1]) == 0: + if re.split(r"(\d+)", isotope)[0] == 'C': + _ATOMIC_MASS[isotope.lower()] = 12.0106 + elif re.split(r"(\d+)", isotope)[0] == 'Zn': + _ATOMIC_MASS[isotope.lower()] = 65.38 + elif re.split(r"(\d+)", isotope)[0] == 'Pt': + _ATOMIC_MASS[isotope.lower()] = 195.084 + elif re.split(r"(\d+)", isotope)[0] == 'Os': + _ATOMIC_MASS[isotope.lower()] = 190.23 + elif re.split(r"(\d+)", isotope)[0] == 'Tl': + _ATOMIC_MASS[isotope.lower()] = 204.3835 + else: + msg = 'Could not get the atomic mass for zero isotope'\ + ' {0}.'.format(isotope) + raise ValueError(msg) + # Load data from AME2012 file mass_file = os.path.join(os.path.dirname(__file__), 'mass.mas12') with open(mass_file, 'r') as ame: diff --git a/openmc/element.py b/openmc/element.py index d56c3b3507..ce0b5e4386 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -233,7 +233,7 @@ class Element(object): # Compute the ratio of the nuclide atomic masses to the element # atomic mass - if percent_type == 'wo': + if percent_type == 'wo' and len(abundances) > 1: # Compute the element atomic mass element_am = 0. diff --git a/openmc/material.py b/openmc/material.py index c265c90694..abd5467b81 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -4,6 +4,7 @@ from numbers import Real, Integral import warnings from xml.etree import ElementTree as ET import sys +import re from six import string_types @@ -581,6 +582,33 @@ class Material(object): return nuclides + def get_molar_mass(self): + """Returns the molar mass of the material + + Returns + ------- + molar_mass : float + The molar mass of the material + + """ + + # 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] + + return (mass / moles) + def _get_nuclide_xml(self, nuclide, distrib=False): xml_element = ET.Element("nuclide") xml_element.set("name", nuclide[0].name)