From 3351918394cad106ce6ca35fa3fc4b53a2389e87 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Sat, 17 Sep 2022 11:32:24 -0500 Subject: [PATCH] Adding a histogram filter test. Testing conversion from Tabulated1D for many interpolation types --- .../filter_energyfun/inputs_true.dat | 10 ++++++++++ .../regression_tests/filter_energyfun/test.py | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/regression_tests/filter_energyfun/inputs_true.dat b/tests/regression_tests/filter_energyfun/inputs_true.dat index 133b3167f2..db7f91ed08 100644 --- a/tests/regression_tests/filter_energyfun/inputs_true.dat +++ b/tests/regression_tests/filter_energyfun/inputs_true.dat @@ -54,6 +54,11 @@ 0.2 0.7 0.7 0.2 cubic + + 0.0 5000000.0 10000000.0 15000000.0 + 0.2 0.7 0.7 0.2 + histogram + Am241 (n,gamma) @@ -93,4 +98,9 @@ Am241 (n,gamma) + + 9 + Am241 + (n,gamma) + diff --git a/tests/regression_tests/filter_energyfun/test.py b/tests/regression_tests/filter_energyfun/test.py index 4a42ce0cb4..489eec8c07 100644 --- a/tests/regression_tests/filter_energyfun/test.py +++ b/tests/regression_tests/filter_energyfun/test.py @@ -28,6 +28,7 @@ def model(): # Make an EnergyFunctionFilter directly from the x and y lists. filt1 = openmc.EnergyFunctionFilter(x, y) + # check interpolatoin property setter assert filt1.interpolation == 'linear-linear' with pytest.raises(ValueError): @@ -60,7 +61,10 @@ def model(): filt8 = openmc.EnergyFunctionFilter(x, y) filt8.interpolation = 'cubic' - filters = [filt1, filt3, filt4, filt5, filt6, filt7, filt8] + filt9 = openmc.EnergyFunctionFilter(x, y) + filt9.interpolation = 'histogram' + + filters = [filt1, filt3, filt4, filt5, filt6, filt7, filt8, filt9] # Make tallies tallies = [openmc.Tally() for _ in range(len(filters) + 1)] for t in tallies: @@ -72,6 +76,14 @@ def model(): model.tallies.extend(tallies) + interpolation_vals = \ + list(openmc.EnergyFunctionFilter.INTERPOLATION_SCHEMES.keys()) + for i_val in interpolation_vals: + # breakpoint here is fake and unused + t1d = openmc.data.Tabulated1D(x, y, breakpoints=[1], interpolation=[i_val]) + f = openmc.EnergyFunctionFilter.from_tabulated1d(t1d) + assert f.interpolation == openmc.EnergyFunctionFilter.INTERPOLATION_SCHEMES[i_val] + return model @@ -143,6 +155,10 @@ class FilterEnergyFunHarness(PyAPITestHarness): assert all(contrived_lin_lin_tally.mean < contrived_quadratic_tally.mean) assert all(contrived_lin_lin_tally.mean < contrived_cubic_tally.mean) + # check that the histogram tally is less than the quadratic/cubic interpolations + histogram_tally = sp.get_tally(id=9) + assert all(histogram_tally.mean < contrived_quadratic_tally.mean) + assert all(histogram_tally.mean < contrived_cubic_tally.mean) def test_filter_energyfun(model): harness = FilterEnergyFunHarness('statepoint.5.h5', model)