diff --git a/openmc/mgxs/library.py b/openmc/mgxs/library.py index 78ab3ca1989..faa83c0481f 100644 --- a/openmc/mgxs/library.py +++ b/openmc/mgxs/library.py @@ -1290,6 +1290,14 @@ def get_xsdata(self, domain, xsdata_name, nuclide='total', xs_type='macro', 'are ignored since multiplicity or nu-scatter matrices '\ 'were not tallied for ' + xsdata_name warn(msg, RuntimeWarning) + + if 'scatter matrix' in self.mgxs_types: + scatt_mgxs = self.get_mgxs(domain, 'scatter matrix') + elif 'consistent scatter matrix' in self.mgxs_types: + scatt_mgxs = self.get_mgxs(domain, 'consistent scatter matrix') + else: + raise ValueError(f'No scatter matrix found for {xsdata_name}.') + xsdata.set_scatter_matrix_mgxs(scatt_mgxs, temperature=temperature, xs_type=xs_type, nuclide=[nuclide], diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true.dat b/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_multiplicity_matrix.dat similarity index 100% rename from tests/regression_tests/mgxs_library_ce_to_mg/inputs_true.dat rename to tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_multiplicity_matrix.dat diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_scatter_matrix.dat b/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_scatter_matrix.dat new file mode 100644 index 00000000000..6e60f1b199e --- /dev/null +++ b/tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_scatter_matrix.dat @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + eigenvalue + 100 + 10 + 5 + + + -0.63 -0.63 -1 0.63 0.63 1 + + + true + + + + + + 7 + + + 0.0 0.625 20000000.0 + + + 0.0 0.625 20000000.0 + + + 3 + + + 8 + + + 9 + + + 43 44 + total + flux + tracklength + + + 43 44 + total + total + tracklength + + + 43 44 + total + flux + tracklength + + + 43 44 + total + absorption + tracklength + + + 43 44 + total + flux + analog + + + 43 44 49 + total + nu-fission + analog + + + 43 44 + total + flux + analog + + + 43 44 49 53 + total + scatter + analog + + + 54 44 + total + flux + tracklength + + + 54 44 + total + total + tracklength + + + 54 44 + total + flux + tracklength + + + 54 44 + total + absorption + tracklength + + + 54 44 + total + flux + analog + + + 54 44 49 + total + nu-fission + analog + + + 54 44 + total + flux + analog + + + 54 44 49 53 + total + scatter + analog + + + 65 44 + total + flux + tracklength + + + 65 44 + total + total + tracklength + + + 65 44 + total + flux + tracklength + + + 65 44 + total + absorption + tracklength + + + 65 44 + total + flux + analog + + + 65 44 49 + total + nu-fission + analog + + + 65 44 + total + flux + analog + + + 65 44 49 53 + total + scatter + analog + + + diff --git a/tests/regression_tests/mgxs_library_ce_to_mg/test.py b/tests/regression_tests/mgxs_library_ce_to_mg/test.py index 075167f5884..b68fbd6c339 100644 --- a/tests/regression_tests/mgxs_library_ce_to_mg/test.py +++ b/tests/regression_tests/mgxs_library_ce_to_mg/test.py @@ -9,7 +9,7 @@ class MGXSTestHarness(PyAPITestHarness): - def __init__(self, *args, **kwargs): + def __init__(self, *args, scatter_mgxs_type=None, **kwargs): # Generate inputs using parent class routine super().__init__(*args, **kwargs) @@ -19,8 +19,8 @@ def __init__(self, *args, **kwargs): # Initialize MGXS Library for a few cross section types self.mgxs_lib = openmc.mgxs.Library(self._model.geometry) self.mgxs_lib.by_nuclide = False - self.mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission matrix', - 'nu-scatter matrix', 'multiplicity matrix'] + self.mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission matrix'] + self.mgxs_lib.mgxs_types += scatter_mgxs_type self.mgxs_lib.energy_groups = energy_groups self.mgxs_lib.correction = None self.mgxs_lib.legendre_order = 3 @@ -69,9 +69,23 @@ def _cleanup(self): os.remove(f) -def test_mgxs_library_ce_to_mg(): +def test_mgxs_library_ce_to_mg_multiplicity_matrix(): # Set the input set to use the pincell model model = pwr_pin_cell() - harness = MGXSTestHarness('statepoint.10.h5', model) + harness = MGXSTestHarness( + 'statepoint.10.h5', model, + inputs_true='inputs_true_multiplicity_matrix.dat', + scatter_mgxs_type=['nu-scatter matrix', 'multiplicity matrix'] + ) + harness.main() + + +def test_mgxs_library_ce_to_mg_scatter_matrix(): + # Set the input set to use the pincell model + model = pwr_pin_cell() + + harness = MGXSTestHarness('statepoint.10.h5', model, + inputs_true='inputs_true_scatter_matrix.dat', + scatter_mgxs_type=['scatter matrix']) harness.main()