From 20ce145e366a50240fbec7e552f6fb60ed46c3d7 Mon Sep 17 00:00:00 2001 From: Adam Nelson Date: Mon, 21 Nov 2016 20:30:54 -0500 Subject: [PATCH] Read in total_nu as a derived product for MT=18 if it only exists as summed, and more correctly treated yields --- openmc/data/neutron.py | 3 +++ openmc/plotter.py | 50 +++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index f478aafc7..581adc417 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -511,6 +511,9 @@ class IncidentNeutron(EqualityMixin): rxs = [data[mt] for mt in SUM_RULES[mt_sum] if mt in data] if len(rxs) > 0: data.summed_reactions[mt_sum] = rx = Reaction(mt_sum) + if rx.mt == 18 and 'total_nu' in group: + tgroup = group['total_nu'] + rx.derived_products.append(Product.from_hdf5(tgroup)) for T in data.temperatures: rx.xs[T] = Sum([rx_i.xs[T] for rx_i in rxs]) diff --git a/openmc/plotter.py b/openmc/plotter.py index d6c9527bd..f576dd8a6 100644 --- a/openmc/plotter.py +++ b/openmc/plotter.py @@ -1,5 +1,6 @@ from numbers import Integral, Real from six import string_types +from itertools import chain import numpy as np @@ -371,38 +372,41 @@ def _calculate_xs_nuclide(this, types, temperature=294., sab_name=None, funcs.append(pw_funcs) else: funcs.append(nuc[mt].xs[nucT]) - elif mt == 5 and mt in nuc: - # Only consider the (n,misc) products if neutrons are - # included in the outgoing channel since (n,misc) is only - # explicitly needed for scatter cross sections. - for prod in nuc[mt].products: - if prod.particle == 'neutron' and \ - prod.emission_mode in ('total', 'prompt'): - if yields[i]: - func = openmc.data.Combination( - [nuc[mt].xs[nucT], prod.yield_], - [np.multiply]) - else: - func = nuc[mt].xs[nucT] - - funcs.append(func) - break - else: - funcs.append(lambda x: 0.) - elif mt in nuc: if yields[i]: - for prod in nuc[mt].products: + for prod in chain(nuc[mt].products, + nuc[mt].derived_products): if prod.particle == 'neutron' and \ - prod.emission_mode in ('total', 'prompt'): + prod.emission_mode == 'total': func = openmc.data.Combination( [nuc[mt].xs[nucT], prod.yield_], [np.multiply]) funcs.append(func) break else: - # Assume the yield is 1 - funcs.append(nuc[mt].xs[nucT]) + # Total doesn't exist so we have to create from + # prompt and delayed + func = None + for prod in chain(nuc[mt].products, + nuc[mt].derived_products): + if prod.particle == 'neutron' and \ + prod.emission_mode != 'total': + if func: + func = openmc.data.Combination( + [nuc[mt].xs[nucT], prod.yield_, + func], [np.multiply, np.add]) + else: + func = openmc.data.Combination( + [nuc[mt].xs[nucT], prod.yield_], + [np.multiply]) + if func: + funcs.append(func) + else: + # If func is still None, then there were no + # products. In that case, assume the yield is + # one as its not provided for some summed + # reactions like MT=4 + funcs.append(nuc[mt].xs[nucT]) else: funcs.append(nuc[mt].xs[nucT]) elif mt == UNITY_MT: