Handle reconstruction for multiple resolved ranges (Pu239 in ENDF/B-VII.1)

This commit is contained in:
Paul Romano 2016-09-21 14:32:08 -05:00
parent eed74c9d26
commit f08550f5ed
3 changed files with 19 additions and 12 deletions

View file

@ -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

View file

@ -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]

View file

@ -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