From fd516c1c4cca06889e6bcfae664017984a0d64ef Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 3 Nov 2022 18:55:06 +0100 Subject: [PATCH 1/3] Doctors the incoherent inelastic TSL data when in continuous format. --- openmc/data/thermal.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index 7e66b6319..44010a0b0 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -670,12 +670,41 @@ class ThermalScattering(EqualityMixin): mu_i = [] for j in range(n_energy_out[i]): mu = ace.xss[idx + 4:idx + 4 + n_mu] + # The equiprobable angles produced by NJOY are not always + # sorted. This is problematic when the smearing algorithm + # is applied when sampling the angles. We sort the angles + # here, because they are equiprobable, so the order + # doesn't mater. + mu.sort() p_mu = 1. / n_mu * np.ones(n_mu) mu_ij = Discrete(mu, p_mu) mu_ij.c = np.cumsum(p_mu) mu_i.append(mu_ij) idx += 3 + n_mu + # Check if the CDF for the outgoing energy distribution starts + # at 0. For NJOY and FRENDY evaluations, this is never the case, + # and can very rarely lead to negative energies when sampling + # the outgoing energy. From Eq. 7.6 of the ENDF manual, we can + # add the outgoing energy 0 eV, which has a PDF of 0 (and of + # course, a CDF of 0 as well). + if eout_i.c[0] > 0.: + eout_i.x = np.insert(eout_i.x, 0, 0.) + eout_i.p = np.insert(eout_i.p, 0, 0.) + eout_i.c = np.insert(eout_i.c, 0, 0.) + + # For this added outgoing energy (of 0 eV) we add a set of + # isotropic discrete angles. + dmu = 2. / n_mu + mu = np.linsace(-1. + 0.5*dmu, 1. - 0.5*dmu, n_mu) + p_mu = 1. / n_mu * np.ones(n_mu) + mu_0 = Discrete(mu, p_mu) + mu_0.c = np.cumsum(p_mu) + mu_i.insert(0, mu_0) + # We don't worry about renormalizing the outgoing energy PDF/CDF + # after this manipulation, because it never seems to be + # normalized to begin with (at least with NJOY). + energy_out.append(eout_i) mu_out.append(mu_i) From 6cb7a178e8018a2376a3488320239d2c5f2862e6 Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Thu, 3 Nov 2022 19:09:28 +0100 Subject: [PATCH 2/3] Fix spelling error. --- openmc/data/thermal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index 44010a0b0..12e666cdc 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -696,7 +696,7 @@ class ThermalScattering(EqualityMixin): # For this added outgoing energy (of 0 eV) we add a set of # isotropic discrete angles. dmu = 2. / n_mu - mu = np.linsace(-1. + 0.5*dmu, 1. - 0.5*dmu, n_mu) + mu = np.linspace(-1. + 0.5*dmu, 1. - 0.5*dmu, n_mu) p_mu = 1. / n_mu * np.ones(n_mu) mu_0 = Discrete(mu, p_mu) mu_0.c = np.cumsum(p_mu) From 6a0d5043030cffd791b0500e6eecdf11be3fb02b Mon Sep 17 00:00:00 2001 From: Hunter Belanger Date: Sat, 5 Nov 2022 13:05:47 +0100 Subject: [PATCH 3/3] Fix wording of comments --- openmc/data/thermal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/data/thermal.py b/openmc/data/thermal.py index 12e666cdc..e6213e5f0 100644 --- a/openmc/data/thermal.py +++ b/openmc/data/thermal.py @@ -674,7 +674,7 @@ class ThermalScattering(EqualityMixin): # sorted. This is problematic when the smearing algorithm # is applied when sampling the angles. We sort the angles # here, because they are equiprobable, so the order - # doesn't mater. + # doesn't matter. mu.sort() p_mu = 1. / n_mu * np.ones(n_mu) mu_ij = Discrete(mu, p_mu) @@ -686,7 +686,7 @@ class ThermalScattering(EqualityMixin): # at 0. For NJOY and FRENDY evaluations, this is never the case, # and can very rarely lead to negative energies when sampling # the outgoing energy. From Eq. 7.6 of the ENDF manual, we can - # add the outgoing energy 0 eV, which has a PDF of 0 (and of + # add an outgoing energy 0 eV that has a PDF of 0 (and of # course, a CDF of 0 as well). if eout_i.c[0] > 0.: eout_i.x = np.insert(eout_i.x, 0, 0.)