From bb7b9e570bd1e06b2ece8835e4bf83cdcf42ca1a Mon Sep 17 00:00:00 2001 From: Jingang Liang Date: Sun, 20 Oct 2019 14:11:21 +0800 Subject: [PATCH] create redundant xs upon requested --- openmc/data/neutron.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index ea14be784..7420387da 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -118,7 +118,12 @@ class IncidentNeutron(EqualityMixin): if mt in self.reactions: return self.reactions[mt] else: - raise KeyError('No reaction with MT={}.'.format(mt)) + # Try to create a redundant cross section + mts = self.get_reaction_components(mt) + if len(mts) > 0: + return self._get_redundant_reaction(mt, mts) + else: + raise KeyError('No reaction with MT={}.'.format(mt)) def __repr__(self): return "".format(self.name) @@ -911,16 +916,17 @@ class IncidentNeutron(EqualityMixin): Redundant reaction """ - # Get energy grid - strT = self.temperatures[0] - energy = self.energy[strT] rx = Reaction(mt) - xss = [self.reactions[mt_i].xs[strT] for mt_i in mts] - idx = min([xs._threshold_idx if hasattr(xs, '_threshold_idx') - else 0 for xs in xss]) - rx.xs[strT] = Tabulated1D(energy[idx:], Sum(xss)(energy[idx:])) - rx.xs[strT]._threshold_idx = idx + # Get energy grid + for strT in self.temperatures: + energy = self.energy[strT] + xss = [self.reactions[mt_i].xs[strT] for mt_i in mts] + idx = min([xs._threshold_idx if hasattr(xs, '_threshold_idx') + else 0 for xs in xss]) + rx.xs[strT] = Tabulated1D(energy[idx:], Sum(xss)(energy[idx:])) + rx.xs[strT]._threshold_idx = idx + rx.redundant = True return rx