Applying missed suggestions

Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
Jonathan Shimwell 2022-06-22 08:01:07 +01:00 committed by GitHub
parent 87dafd1e31
commit 53b5cce209
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -278,9 +278,9 @@ def atomic_weight(element):
def half_life(isotope):
"""Return half-life of isotope in seconds. Returns None if isotope is stable
"""Return half-life of isotope in seconds or None if isotope is stable
Half-life values are from `ENDF/B VIII.0 Decay Reaction Sublibrary
Half-life values are from the `ENDF/B-VIII.0 decay sublibrary
<https://www.nndc.bnl.gov/endf-b8.0/download.html>`_.
Parameters
@ -291,15 +291,14 @@ def half_life(isotope):
Returns
-------
float
Half-life of isotope in [seconds]
Half-life of isotope in [s]
"""
global _HALF_LIFE
if not _HALF_LIFE:
# Load data from AME2016 file
half_life_filename = os.path.join(os.path.dirname(__file__), 'half_life.json')
with open(half_life_filename, 'r') as f:
_HALF_LIFE = json.load(f)
# Load ENDF/B-VIII.0 data from JSON file
half_life_path = Path(__file__).with_name('half_life.json')
_HALF_LIFE = json.load(half_life_path.read_text())
if isotope.title() not in _HALF_LIFE.keys():
return None

View file

@ -147,9 +147,9 @@ class Material(IDManagerMixin):
def activity(self):
"""Returns the total activity of the material in Becquerels."""
atoms_per_barn_cm2 = self.get_nuclide_atom_densities()
atoms_per_barn_cm = self.get_nuclide_atom_densities()
total_activity = 0
for key, value in atoms_per_barn_cm2.items():
for key, value in atoms_per_barn_cm.items():
half_life = openmc.data.half_life(key)
if half_life:
atoms = value[1] * self.volume