From 80dad0f2403176c8fe5a501ec7a29ef0963ddf03 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 31 Dec 2022 11:32:39 +0700 Subject: [PATCH 1/2] Small fix in plot_xs when S(a,b) tables are present --- openmc/plotter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/plotter.py b/openmc/plotter.py index 16760868e..e2d18d085 100644 --- a/openmc/plotter.py +++ b/openmc/plotter.py @@ -563,7 +563,7 @@ def _calculate_cexs_elem_mat(this, types, temperature=294., for nuclide in nuclides.items(): sabs[nuclide[0]] = None if isinstance(this, openmc.Material): - for sab_name in this._sab: + for sab_name, _ in this._sab: sab = openmc.data.ThermalScattering.from_hdf5( library.get_by_material(sab_name, data_type='thermal')['path']) for nuc in sab.nuclides: From 82429cbb19d4ba10aa771a5493a092cd35711b4f Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 5 Jan 2023 11:16:16 +0000 Subject: [PATCH 2/2] added test for sab xs appears in xs calc --- tests/unit_tests/test_plotter.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/unit_tests/test_plotter.py diff --git a/tests/unit_tests/test_plotter.py b/tests/unit_tests/test_plotter.py new file mode 100644 index 000000000..a3f1ff666 --- /dev/null +++ b/tests/unit_tests/test_plotter.py @@ -0,0 +1,27 @@ +import openmc +import numpy as np + + +def test_calculate_cexs_elem_mat_sab(): + """Checks that sab cross sections are included in the + _calculate_cexs_elem_mat method and have the correct shape""" + + mat_1 = openmc.Material() + mat_1.add_element("H", 4.0, "ao") + mat_1.add_element("O", 4.0, "ao") + mat_1.add_element("C", 4.0, "ao") + + mat_1.add_s_alpha_beta("c_C6H6") + mat_1.set_density("g/cm3", 0.865) + + energy_grid, data = openmc.plotter._calculate_cexs_elem_mat( + mat_1, + ["inelastic"], + sab_name="c_C6H6", + ) + + assert isinstance(energy_grid, np.ndarray) + assert isinstance(data, np.ndarray) + assert len(energy_grid) > 1 + assert len(data) == 1 + assert len(data[0]) == len(energy_grid)