From 8c7ca7afea9f4fd02dec48330a45fccae660c34f Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 22 Mar 2017 09:37:18 -0500 Subject: [PATCH] Use resonance energies when performing reconstruction for 0 K elastic --- openmc/data/neutron.py | 21 +++++++++++++++++-- .../results_true.dat | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/openmc/data/neutron.py b/openmc/data/neutron.py index e24058ca8..84969f6e2 100644 --- a/openmc/data/neutron.py +++ b/openmc/data/neutron.py @@ -345,15 +345,29 @@ class IncidentNeutron(EqualityMixin): if strT in data.urr: self.urr[strT] = data.urr[strT] - def add_elastic_0K_from_endf(self, filename): + def add_elastic_0K_from_endf(self, filename, overwrite=False): """Append 0K elastic scattering cross section from an ENDF file. Parameters ---------- filename : str Path to ENDF file + overwrite : bool + If existing 0 K data is present, this flag can be used to indicate + that it should be overwritten. Otherwise, an exception will be + thrown. + + Raises + ------ + ValueError + If 0 K data is already present and the `overwrite` parameter is + False. """ + # Check for existing data + if '0K' in self.energy and not overwrite: + raise ValueError('0 K data already exists for this nuclide.') + data = type(self).from_endf(filename) if data.resonances is not None: x = [] @@ -366,7 +380,10 @@ class IncidentNeutron(EqualityMixin): # Create 1000 equal log-spaced energies over RRR e_min, e_max = rr.energy_min, rr.energy_max - energies = np.logspace(log10(e_min), log10(e_max), 1000) + e_log = np.logspace(log10(e_min), log10(e_max), 1000) + e_res = rr.parameters['energy'].values + in_range = (e_res > e_min) & (e_res < e_max) + energies = np.union1d(e_log, e_res[in_range]) # Linearize and thin cross section xi, yi = linearize(energies, data[2].xs['0K']) diff --git a/tests/test_resonance_scattering/results_true.dat b/tests/test_resonance_scattering/results_true.dat index 28bd3e9cb..f548f2f16 100644 --- a/tests/test_resonance_scattering/results_true.dat +++ b/tests/test_resonance_scattering/results_true.dat @@ -1,2 +1,2 @@ k-combined: -1.423955E+00 1.459996E-02 +1.399343E+00 1.149372E-01