From 0e029771e70cdf8ebdbf3fcd5b220c65f836ad26 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sun, 27 Nov 2016 16:04:40 -0600 Subject: [PATCH] Fix decay_constant attribute, add Decay.from_endf classmethod --- openmc/data/decay.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/openmc/data/decay.py b/openmc/data/decay.py index 33d4479739..4327b2fc35 100644 --- a/openmc/data/decay.py +++ b/openmc/data/decay.py @@ -157,7 +157,7 @@ class FissionProductYields(EqualityMixin): assert np.all(energies == self.energies) @classmethod - def from_endf(cls, filename): + def from_endf(cls, ev_or_filename): """Generate fission product yield data from an ENDF evaluation Parameters @@ -172,7 +172,7 @@ class FissionProductYields(EqualityMixin): Fission product yield data """ - return cls(filename) + return cls(ev_or_filename) class DecayMode(EqualityMixin): @@ -460,4 +460,26 @@ class Decay(EqualityMixin): @property def decay_constant(self): - return log(2.)/self.half_life + if hasattr(self.half_life, 'n'): + return log(2.)/self.half_life + else: + mu, sigma = self.half_life + return ufloat(log(2.)/mu, log(2.)/mu**2*sigma) + + @classmethod + def from_endf(cls, ev_or_filename): + """Generate radioactive decay data from an ENDF evaluation + + Parameters + ---------- + ev_or_filename : str or openmc.data.endf.Evaluation + ENDF radioactive decay data evaluation to read from. If given as a + string, it is assumed to be the filename for the ENDF file. + + Returns + ------- + openmc.data.Decay + Radioactive decay data + + """ + return cls(ev_or_filename)