From abc9e9c7adc87b88af55e777a9396544b39f85e2 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 5 Oct 2020 15:39:20 -0500 Subject: [PATCH 1/3] Add decay_energy property on Decay class and associated bug in chain.py --- openmc/data/decay.py | 14 ++++++++++++-- openmc/deplete/chain.py | 3 +-- tests/unit_tests/test_data_decay.py | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/openmc/data/decay.py b/openmc/data/decay.py index 505d72cf06..94cae769e5 100644 --- a/openmc/data/decay.py +++ b/openmc/data/decay.py @@ -298,6 +298,8 @@ class Decay(EqualityMixin): applications. decay_constant : uncertainties.UFloat Decay constant in inverse seconds. + decay_energy : float + Average energy in [eV] per decay for a decay heat half_life : uncertainties.UFloat Half-life of the decay in seconds. modes : list @@ -347,7 +349,7 @@ class Decay(EqualityMixin): items, values = get_list_record(file_obj) self.half_life = ufloat(items[0], items[1]) NC = items[4]//2 - pairs = [x for x in zip(values[::2], values[1::2])] + pairs = list(zip(values[::2], values[1::2])) ex = self.average_energies ex['light'] = ufloat(*pairs[0]) ex['electromagnetic'] = ufloat(*pairs[1]) @@ -359,7 +361,7 @@ class Decay(EqualityMixin): ex['conversion'] = ufloat(*pairs[6]) ex['gamma'] = ufloat(*pairs[7]) ex['xray'] = ufloat(*pairs[8]) - ex['Bremsstrahlung'] = ufloat(*pairs[9]) + ex['bremsstrahlung'] = ufloat(*pairs[9]) ex['annihilation'] = ufloat(*pairs[10]) ex['alpha'] = ufloat(*pairs[11]) ex['recoil'] = ufloat(*pairs[12]) @@ -464,6 +466,14 @@ class Decay(EqualityMixin): mu, sigma = self.half_life return ufloat(log(2.)/mu, log(2.)/mu**2*sigma) + @property + def decay_energy(self): + energy = self.average_energies + if energy: + return energy['light'] + energy['electromagnetic'] + energy['heavy'] + else: + return 0.0 + @classmethod def from_endf(cls, ev_or_filename): """Generate radioactive decay data from an ENDF evaluation diff --git a/openmc/deplete/chain.py b/openmc/deplete/chain.py index e7cec9d71a..06d7ced585 100644 --- a/openmc/deplete/chain.py +++ b/openmc/deplete/chain.py @@ -395,8 +395,7 @@ class Chain: if not data.nuclide['stable'] and data.half_life.nominal_value != 0.0: nuclide.half_life = data.half_life.nominal_value - nuclide.decay_energy = sum(E.nominal_value for E in - data.average_energies.values()) + nuclide.decay_energy = data.decay_energy.nominal_value sum_br = 0.0 for i, mode in enumerate(data.modes): type_ = ','.join(mode.modes) diff --git a/tests/unit_tests/test_data_decay.py b/tests/unit_tests/test_data_decay.py index 0cc7939904..cb4560d515 100644 --- a/tests/unit_tests/test_data_decay.py +++ b/tests/unit_tests/test_data_decay.py @@ -34,7 +34,7 @@ def u235_yields(): def test_nb90_halflife(nb90): ufloat_close(nb90.half_life, ufloat(52560.0, 180.0)) ufloat_close(nb90.decay_constant, log(2.)/nb90.half_life) - + ufloat_close(nb90.decay_energy, ufloat(2265527.5, 25159.400474401213)) def test_nb90_nuclide(nb90): assert nb90.nuclide['atomic_number'] == 41 From a9f1d9c5bc5a79b0315cf4dd1ca35fef924fff4c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 5 Oct 2020 20:55:18 -0500 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Andrew Johnson --- openmc/data/decay.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/data/decay.py b/openmc/data/decay.py index 94cae769e5..a477f06cfa 100644 --- a/openmc/data/decay.py +++ b/openmc/data/decay.py @@ -298,7 +298,7 @@ class Decay(EqualityMixin): applications. decay_constant : uncertainties.UFloat Decay constant in inverse seconds. - decay_energy : float + decay_energy : uncertainties.UFloat Average energy in [eV] per decay for a decay heat half_life : uncertainties.UFloat Half-life of the decay in seconds. @@ -472,7 +472,7 @@ class Decay(EqualityMixin): if energy: return energy['light'] + energy['electromagnetic'] + energy['heavy'] else: - return 0.0 + return ufloat(0, 0) @classmethod def from_endf(cls, ev_or_filename): From 591639b9e0774ccff0206c740ad1700cedece735 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 5 Oct 2020 20:55:55 -0500 Subject: [PATCH 3/3] Fix typo in docstring --- openmc/data/decay.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/data/decay.py b/openmc/data/decay.py index a477f06cfa..3e7d9599c6 100644 --- a/openmc/data/decay.py +++ b/openmc/data/decay.py @@ -299,7 +299,7 @@ class Decay(EqualityMixin): decay_constant : uncertainties.UFloat Decay constant in inverse seconds. decay_energy : uncertainties.UFloat - Average energy in [eV] per decay for a decay heat + Average energy in [eV] per decay for decay heat applications half_life : uncertainties.UFloat Half-life of the decay in seconds. modes : list