Repository: openmc-dev/openmc

Issue:
Reading Beta-decay energies from ENDF format files
I'm currently working on my depletion code validation with residual heat tests and using data generated by `chain = openmc.deplete.Chain.from_endf(decay_files, nfy_files, neutron_files)`. I initially started with endfb-vii.1 library and results was fine except the first 10 seconds of heat measurement then i switched to jeff 3.3 lib and results have changed extrmely. As I supposed the main reason is the value of decay energy calculated as follows: `nuclide.decay_energy = sum(E.nominal_value for E in data.average_energies.values())` (openmc/depletion/chain.py:398) with average_energies were read from *.endf file `ex = self.average_energies

            ex['light'] = ufloat(*pairs[0])
            ex['electromagnetic'] = ufloat(*pairs[1])
            ex['heavy'] = ufloat(*pairs[2])
            if NC == 17:
                ex['beta-'] = ufloat(*pairs[3])
                ex['beta+'] = ufloat(*pairs[4])
                ex['auger'] = ufloat(*pairs[5])
                ex['conversion'] = ufloat(*pairs[6])
                ex['gamma'] = ufloat(*pairs[7])
                ex['xray'] = ufloat(*pairs[8])
                ex['Bremsstrahlung'] = ufloat(*pairs[9])
                ex['annihilation'] = ufloat(*pairs[10])
                ex['alpha'] = ufloat(*pairs[11])
                ex['recoil'] = ufloat(*pairs[12])
                ex['SF'] = ufloat(*pairs[13])
                ex['neutron'] = ufloat(*pairs[14])
                ex['proton'] = ufloat(*pairs[15])
                ex['neutrino'] = ufloat(*pairs[16])`
(openmc/data/decay.py:351)
Where the  endfb lib contains only the first three records('light', 'electromagnetic', 'heavy') but the jeff along with these contains the rest 14 records. 
It seems to me to duplicating take places by simple sum over these 17 values in the case with jeff3.3 lib.
I can fix it but i don't know how to do it properly.
@paulromano 
@drewejohnson 



Discussion:
Thanks for reporting this @dryuri92. Your assessment is exactly right. I'll submit a pull request to fix this issue.

Resolving patch:
diff --git a/openmc/data/decay.py b/openmc/data/decay.py
--- 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 : uncertainties.UFloat
+        Average energy in [eV] per decay for decay heat applications
     half_life : uncertainties.UFloat
         Half-life of the decay in seconds.
     modes : list
@@ -347,7 +349,7 @@ def __init__(self, ev_or_filename):
             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 @@ def __init__(self, ev_or_filename):
                 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 @@ def decay_constant(self):
             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 ufloat(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
--- a/openmc/deplete/chain.py
+++ b/openmc/deplete/chain.py
@@ -395,8 +395,7 @@ def from_endf(cls, decay_files, fpy_files, neutron_files,
 
             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)


Test patch:
diff --git a/tests/unit_tests/test_data_decay.py b/tests/unit_tests/test_data_decay.py
--- 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