From d359909aa820cde96cdb4b3afd72980dd00dd2bb Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Mon, 10 Apr 2017 17:27:28 -0400 Subject: [PATCH 1/5] Revised order of operations for consistent scattering matrix calculation to work with multiple nuclides --- openmc/mgxs/mgxs.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 3131e0e6e..ffe5bb6dd 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -3956,10 +3956,6 @@ class ScatterMatrixXS(MatrixMGXS): self._xs_tally = MGXS.xs_tally.fget(self) else: - # Compute groupwise scattering cross section - self._xs_tally = self.tallies['scatter'] / \ - self.tallies['flux (tracklength)'] - # Compute scattering probability matrix energyout_bins = [self.energy_groups.get_group_bounds(i) for i in range(self.num_groups, 0, -1)] @@ -3969,7 +3965,6 @@ class ScatterMatrixXS(MatrixMGXS): norm = self.tallies[tally_key].get_slice(scores=['scatter-0']) norm = norm.summation( filter_type=openmc.EnergyoutFilter, filter_bins=energyout_bins) - # Remove the AggregateFilter summed across energyout bins norm._filters = norm._filters[:2] @@ -3990,8 +3985,10 @@ class ScatterMatrixXS(MatrixMGXS): # Remove the AggregateFilter summed across mu bins norm._filters = norm._filters[:2] - # Multiply by the group-to-group probability matrix - self._xs_tally *= (self.tallies[tally_key] / norm) + # Compute groupwise scattering cross section + self._xs_tally = \ + self.tallies['scatter'] * self.tallies[tally_key] / norm + self._xs_tally /= self.tallies['flux (tracklength)'] # Multiply by the multiplicity matrix if self.nu: From 49aac978047480daee965cf0de46f0749c15f765 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Tue, 11 Apr 2017 08:37:00 -0400 Subject: [PATCH 2/5] Fix bugs when using nuclides for consistent scattering matrix MGXS with multiplicity or transport correction --- openmc/mgxs/mgxs.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index ffe5bb6dd..65dbba5f5 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -3917,6 +3917,8 @@ class ScatterMatrixXS(MatrixMGXS): scatter_p0 = self.tallies['{}-0'.format(self.rxn_type)] scatter_p1 = self.tallies['{}-1'.format(self.rxn_type)] energy_filter = scatter_p0.find_filter(openmc.EnergyFilter) + # Transform scatter-p1 tally into an energyin/out matrix + # to match scattering matrix shape for tally arithmetic energy_filter = copy.deepcopy(energy_filter) scatter_p1 = scatter_p1.diagonalize_filter(energy_filter) self._rxn_rate_tally = scatter_p0 - scatter_p1 @@ -3990,6 +3992,9 @@ class ScatterMatrixXS(MatrixMGXS): self.tallies['scatter'] * self.tallies[tally_key] / norm self._xs_tally /= self.tallies['flux (tracklength)'] + # Override the nuclides for tally arithmetic + self._xs_tally.nuclides = self.tallies['scatter'].nuclides + # Multiply by the multiplicity matrix if self.nu: numer = self.tallies['nu-scatter-0'] @@ -3998,14 +4003,27 @@ class ScatterMatrixXS(MatrixMGXS): # If using P0 correction subtract scatter-1 from the diagonal if self.correction == 'P0' and self.legendre_order == 0: - flux = self.tallies['flux (analog)'] - scatter_p1 = self.tallies['{}-1'.format(self.rxn_type)] + # Extract tallies needed to compute the transport correction + scatter_p1 = self.tallies['{}-1'.format(self.rxn_type)] + if self.formulation == 'simple': + flux = self.tallies['flux'] + else: + flux = self.tallies['flux (analog)'] + + # Transform scatter-p1 tally into an energyin/out matrix + # to match scattering matrix shape for tally arithmetic energy_filter = flux.find_filter(openmc.EnergyFilter) energy_filter = copy.deepcopy(energy_filter) scatter_p1 = scatter_p1.diagonalize_filter(energy_filter) - self._xs_tally -= (scatter_p1 / flux) + # Compute the trasnport correction term + correction = scatter_p1 / flux + + # Override the nuclides for tally arithmetic + correction.nuclides = scatter_p1.nuclides + self._xs_tally -= correction + self._compute_xs() return self._xs_tally From ba19fc71caaadb842a34986cee370c84a9829fe0 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Tue, 11 Apr 2017 08:51:36 -0400 Subject: [PATCH 3/5] Updated test results for MGXS library with nuclides test --- tests/test_mgxs_library_nuclides/results_true.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_mgxs_library_nuclides/results_true.dat b/tests/test_mgxs_library_nuclides/results_true.dat index c521a1a55..1b47f7126 100644 --- a/tests/test_mgxs_library_nuclides/results_true.dat +++ b/tests/test_mgxs_library_nuclides/results_true.dat @@ -1 +1 @@ -107576b21fa8ed72f71ac65866e4ad1100cc62df527f6f4e6bb8a6318f3694614b6ba1c72634b2e97474a75ea1b3112dcb9b4b36e58f0417e5b04aee5d3c7570 \ No newline at end of file +ea1c7567cb5399ab26297b5df0c1c21b52863303746d04f1698760d88b1aafb625d5743969ad30b194c353d106ed4287a8bc755ea6404c2f5dafb2ea930444a7 \ No newline at end of file From 5bc55d4a814a392fd3683dc48b2e4ef45e17553b Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Tue, 11 Apr 2017 13:11:53 -0400 Subject: [PATCH 4/5] Simplified code for xs_tally property for consistent scattering matrices --- openmc/mgxs/mgxs.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 65dbba5f5..093a20735 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -3967,6 +3967,7 @@ class ScatterMatrixXS(MatrixMGXS): norm = self.tallies[tally_key].get_slice(scores=['scatter-0']) norm = norm.summation( filter_type=openmc.EnergyoutFilter, filter_bins=energyout_bins) + # Remove the AggregateFilter summed across energyout bins norm._filters = norm._filters[:2] @@ -3988,9 +3989,9 @@ class ScatterMatrixXS(MatrixMGXS): norm._filters = norm._filters[:2] # Compute groupwise scattering cross section - self._xs_tally = \ - self.tallies['scatter'] * self.tallies[tally_key] / norm - self._xs_tally /= self.tallies['flux (tracklength)'] + self._xs_tally = self.tallies['scatter'] * \ + self.tallies[tally_key] / norm / \ + self.tallies['flux (tracklength)'] # Override the nuclides for tally arithmetic self._xs_tally.nuclides = self.tallies['scatter'].nuclides @@ -4003,13 +4004,8 @@ class ScatterMatrixXS(MatrixMGXS): # If using P0 correction subtract scatter-1 from the diagonal if self.correction == 'P0' and self.legendre_order == 0: - - # Extract tallies needed to compute the transport correction scatter_p1 = self.tallies['{}-1'.format(self.rxn_type)] - if self.formulation == 'simple': - flux = self.tallies['flux'] - else: - flux = self.tallies['flux (analog)'] + flux = self.tallies['flux (analog)'] # Transform scatter-p1 tally into an energyin/out matrix # to match scattering matrix shape for tally arithmetic From d8164952d0f258c773d3e73e6586cbb96144f544 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Tue, 11 Apr 2017 13:12:55 -0400 Subject: [PATCH 5/5] Cleaned up rxn_rate_tally property for consistent scattering matrices --- openmc/mgxs/mgxs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index 093a20735..fb58efbab 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -3917,6 +3917,7 @@ class ScatterMatrixXS(MatrixMGXS): scatter_p0 = self.tallies['{}-0'.format(self.rxn_type)] scatter_p1 = self.tallies['{}-1'.format(self.rxn_type)] energy_filter = scatter_p0.find_filter(openmc.EnergyFilter) + # Transform scatter-p1 tally into an energyin/out matrix # to match scattering matrix shape for tally arithmetic energy_filter = copy.deepcopy(energy_filter)