From df5727cf3e0e3e63603193df147342bf9ea922e9 Mon Sep 17 00:00:00 2001 From: guillaume Date: Sat, 14 Dec 2019 21:02:48 -0500 Subject: [PATCH 1/5] Fix setting multiplicity matrix for histogram MGMC XS --- openmc/mgxs_library.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/mgxs_library.py b/openmc/mgxs_library.py index b98902030a..34c36ec170 100644 --- a/openmc/mgxs_library.py +++ b/openmc/mgxs_library.py @@ -1638,9 +1638,9 @@ class XSdata(object): xs_type=xs_type, moment=0, subdomains=subdomain) if scatter.scatter_format == 'histogram': - scatt = np.sum(scatt, axis=0) + scatt = np.sum(scatt, axis=2) if nuscatter.scatter_format == 'histogram': - nuscatt = np.sum(nuscatt, axis=0) + nuscatt = np.sum(nuscatt, axis=2) self._multiplicity_matrix[i] = np.divide(nuscatt, scatt) self._multiplicity_matrix[i] = \ From e97a69069ebbf76cec325620843a49929dbaaa6d Mon Sep 17 00:00:00 2001 From: guillaume Date: Sat, 14 Dec 2019 21:17:00 -0500 Subject: [PATCH 2/5] Handle case where user forgot to tally multiplicities or nu-scatter more gracefully --- openmc/mgxs/library.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 83d3178ff7..352c5b1736 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -1167,6 +1167,16 @@ class Library(object): np.subtract(xsdata._total[i], np.sum(np.sum( xsdata._scatter_matrix[i][:, :, :, :, :], axis=4), axis=3)) + # if only scatter matrices have been tallied, multiplicity cannot + # be accounted for + else: + msg = 'Scatter multiplicity (such as (n,xn) reactions) ' \ + 'are ignored since multiplicity or nu-scatter matrices '\ + 'were not tallied for '+xsdata_name + warn(msg, RuntimeWarning) + xsdata.set_scatter_matrix_mgxs(scatt_mgxs, xs_type=xs_type, + nuclide=[nuclide], + subdomain=subdomain) return xsdata From 80dc9967179e5152e4b9a1b5758baf51d147e5ec Mon Sep 17 00:00:00 2001 From: guillaume Date: Sat, 14 Dec 2019 21:27:41 -0500 Subject: [PATCH 3/5] Check for multiplicity matrix tallies in routine meant to check libraries for MGMC library creation --- openmc/mgxs/library.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 352c5b1736..0f10826eb6 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -1420,6 +1420,8 @@ class Library(object): fixed source problem could be the target. - Fission and kappa-fission are not required as they are only needed to support tallies the user may wish to request. + - Scattering multiplicity should have been tallied, either using a + multiplicity or scatter and nu-scatter matrix tally. See also -------- @@ -1470,6 +1472,16 @@ class Library(object): '"scatter matrix", or "consistent scatter matrix" MGXS ' 'type is required.') + # Make sure there is some kind of a scattering multiplicity matrix data + if 'multiplicity matrix' not in self.mgxs_types and \ + ('scatter matrix' not in self.mgxs_types or + 'nu-scatter matrix' not in self.mgxs_types) and\ + ('consistent scatter matrix' not in self.mgxs_types or + 'consistent nu-scatter matrix' not in self.mgxs_types): + error_flag = True + warn('A "multiplicity matrix" or both a "scatter" and "nu-scatter" ' + 'matrix MGXS type(s) is/are required.') + # Ensure absorption is present if 'absorption' not in self.mgxs_types: error_flag = True From d9195b93f8f2bf5876370886d3c3678a59015c90 Mon Sep 17 00:00:00 2001 From: guillaume Date: Mon, 16 Dec 2019 17:35:19 -0500 Subject: [PATCH 4/5] Address @nelsonag 's review --- openmc/mgxs/library.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 0f10826eb6..9b62634c72 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -1172,7 +1172,7 @@ class Library(object): else: msg = 'Scatter multiplicity (such as (n,xn) reactions) ' \ 'are ignored since multiplicity or nu-scatter matrices '\ - 'were not tallied for '+xsdata_name + 'were not tallied for ' + xsdata_name warn(msg, RuntimeWarning) xsdata.set_scatter_matrix_mgxs(scatt_mgxs, xs_type=xs_type, nuclide=[nuclide], @@ -1420,8 +1420,9 @@ class Library(object): fixed source problem could be the target. - Fission and kappa-fission are not required as they are only needed to support tallies the user may wish to request. - - Scattering multiplicity should have been tallied, either using a - multiplicity or scatter and nu-scatter matrix tally. + - Scattering multiplicity should have been tallied for increased model + accuracy, either using a multiplicity or scatter and nu-scatter matrix + tally. See also -------- @@ -1478,9 +1479,8 @@ class Library(object): 'nu-scatter matrix' not in self.mgxs_types) and\ ('consistent scatter matrix' not in self.mgxs_types or 'consistent nu-scatter matrix' not in self.mgxs_types): - error_flag = True warn('A "multiplicity matrix" or both a "scatter" and "nu-scatter" ' - 'matrix MGXS type(s) is/are required.') + 'matrix MGXS type(s) should be provided.') # Ensure absorption is present if 'absorption' not in self.mgxs_types: From a50a342f273b0f4b4818c37ec8a5f83af8534209 Mon Sep 17 00:00:00 2001 From: guillaume Date: Mon, 16 Dec 2019 17:38:29 -0500 Subject: [PATCH 5/5] Add MGMC loading of regular transport cross sections --- openmc/mgxs/library.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 9b62634c72..701f7d8eb7 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -999,6 +999,11 @@ class Library(object): xsdata.set_total_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], subdomain=subdomain) + elif 'transport' in self.mgxs_types and self.correction == 'P0': + mymgxs = self.get_mgxs(domain, 'transport') + xsdata.set_total_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], + subdomain=subdomain) + elif 'total' in self.mgxs_types: mymgxs = self.get_mgxs(domain, 'total') xsdata.set_total_mgxs(mymgxs, xs_type=xs_type, nuclide=[nuclide], @@ -1170,7 +1175,7 @@ class Library(object): # if only scatter matrices have been tallied, multiplicity cannot # be accounted for else: - msg = 'Scatter multiplicity (such as (n,xn) reactions) ' \ + msg = 'Scatter multiplicity (such as (n,xn) reactions) '\ 'are ignored since multiplicity or nu-scatter matrices '\ 'were not tallied for ' + xsdata_name warn(msg, RuntimeWarning)