From 53b5cce209a9777368da90a53e29b7658b40295c Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 22 Jun 2022 08:01:07 +0100 Subject: [PATCH] Applying missed suggestions Co-authored-by: Paul Romano --- openmc/data/data.py | 13 ++++++------- openmc/material.py | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/openmc/data/data.py b/openmc/data/data.py index 914c6c6227..d50afecc20 100644 --- a/openmc/data/data.py +++ b/openmc/data/data.py @@ -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 `_. 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 diff --git a/openmc/material.py b/openmc/material.py index 70cfa7adeb..95fd7aaf7c 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -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