From f08550f5ed830fbe39786b490c94a2b3b8618705 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 21 Sep 2016 14:32:08 -0500 Subject: [PATCH] Handle reconstruction for multiple resolved ranges (Pu239 in ENDF/B-VII.1) --- openmc/data/function.py | 25 ++++++++++++++----------- openmc/data/neutron.py | 2 +- openmc/data/resonance.py | 4 ++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/openmc/data/function.py b/openmc/data/function.py index 13df12b47e..4121918e21 100644 --- a/openmc/data/function.py +++ b/openmc/data/function.py @@ -459,18 +459,21 @@ class ResonancesWithBackground(EqualityMixin): # Get background cross section xs = self.background(x) - rrr = self.resonances.resolved - if isinstance(x, Iterable): - # Determine which energies are within resolved resonance range - within_rrr = (rrr.energy_min <= x) & (x <= rrr.energy_max) + for r in self.resonances: + if not isinstance(r, openmc.data.resonance._RESOLVED): + continue - # Get resonance cross sections and add to background - resonant_xs = rrr.reconstruct(x[within_rrr]) - xs[within_rrr] += resonant_xs[self.mt] - else: - if rrr.energy_min <= x <= rrr.energy_max: - resonant_xs = rrr.reconstruct(x) - xs += resonant_xs[self.mt] + if isinstance(x, Iterable): + # Determine which energies are within resolved resonance range + within = (r.energy_min <= x) & (x <= r.energy_max) + + # Get resonance cross sections and add to background + resonant_xs = r.reconstruct(x[within]) + xs[within] += resonant_xs[self.mt] + else: + if r.energy_min <= x <= r.energy_max: + resonant_xs = r.reconstruct(x) + xs += resonant_xs[self.mt] return xs diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index 0c74aeaa1f..f903ea6f54 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -659,7 +659,7 @@ class IncidentNeutron(EqualityMixin): # Replace cross sections for elastic, capture, fission try: - if isinstance(data.resonances.resolved, _RESOLVED): + if any(isinstance(r, _RESOLVED) for r in data.resonances): for mt in (2, 102, 18): if mt in data.reactions: rx = data.reactions[mt] diff --git a/openmc/data/resonance.py b/openmc/data/resonance.py index 206a56df45..77d522a044 100644 --- a/openmc/data/resonance.py +++ b/openmc/data/resonance.py @@ -36,6 +36,10 @@ class Resonances(object): def __init__(self, ranges): self.ranges = ranges + def __iter__(self): + for r in self.ranges: + yield r + @property def ranges(self): return self._ranges