From b68e6e96e614546d2cad91e8b023f994bdbd5d74 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 8 Sep 2022 22:38:22 -0500 Subject: [PATCH] Updating tests to include checks for quadratic/cubic interpolation --- .../filter_energyfun/inputs_true.dat | 30 +++++++++++++++++++ .../filter_energyfun/results_true.dat | 2 ++ .../regression_tests/filter_energyfun/test.py | 29 +++++++++++++++--- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/tests/regression_tests/filter_energyfun/inputs_true.dat b/tests/regression_tests/filter_energyfun/inputs_true.dat index 8c3db35186..133b3167f2 100644 --- a/tests/regression_tests/filter_energyfun/inputs_true.dat +++ b/tests/regression_tests/filter_energyfun/inputs_true.dat @@ -39,6 +39,21 @@ 0.1 0.1 0.1333 0.158 0.18467 0.25618 0.4297 0.48 0.48 log-linear + + 0.0 5000000.0 10000000.0 15000000.0 + 0.2 0.7 0.7 0.2 + linear-linear + + + 0.0 5000000.0 10000000.0 15000000.0 + 0.2 0.7 0.7 0.2 + quadratic + + + 0.0 5000000.0 10000000.0 15000000.0 + 0.2 0.7 0.7 0.2 + cubic + Am241 (n,gamma) @@ -63,4 +78,19 @@ Am241 (n,gamma) + + 6 + Am241 + (n,gamma) + + + 7 + Am241 + (n,gamma) + + + 8 + Am241 + (n,gamma) + diff --git a/tests/regression_tests/filter_energyfun/results_true.dat b/tests/regression_tests/filter_energyfun/results_true.dat index c0b59680e8..0aadac82e9 100644 --- a/tests/regression_tests/filter_energyfun/results_true.dat +++ b/tests/regression_tests/filter_energyfun/results_true.dat @@ -6,3 +6,5 @@ 0 b4e2ac84068d2d Am241 (n,gamma) 8.19e-02 2.25e-03 energyfunction nuclide score mean std. dev. 0 dacf88242512ea Am241 (n,gamma) 7.95e-02 2.19e-03 + energyfunction nuclide score mean std. dev. +0 fe168c70d9e078 Am241 (n,gamma) 1.06e-01 2.96e-03 diff --git a/tests/regression_tests/filter_energyfun/test.py b/tests/regression_tests/filter_energyfun/test.py index 9c2be7be39..12144c1fda 100644 --- a/tests/regression_tests/filter_energyfun/test.py +++ b/tests/regression_tests/filter_energyfun/test.py @@ -48,9 +48,21 @@ def model(): filt5 = openmc.EnergyFunctionFilter(x, y) filt5.interpolation = 'log-linear' - filters = [filt1, filt3, filt4, filt5] + # define a trapezoidal function for comparison + x = [0.0, 5e6, 1e7, 1.5e7] + y = [0.2, 0.7, 0.7, 0.2] + + filt6 = openmc.EnergyFunctionFilter(x, y) + + filt7 = openmc.EnergyFunctionFilter(x, y) + filt7.interpolation = 'quadratic' + + filt8 = openmc.EnergyFunctionFilter(x, y) + filt8.interpolation = 'cubic' + + filters = [filt1, filt3, filt4, filt5, filt6, filt7, filt8] # Make tallies - tallies = [openmc.Tally() for i in range(5)] + tallies = [openmc.Tally() for _ in range(len(filters) + 1)] for t in tallies: t.scores = ['(n,gamma)'] t.nuclides = ['Am241'] @@ -73,7 +85,7 @@ class FilterEnergyFunHarness(PyAPITestHarness): br_tally = sp.tallies[2] / sp.tallies[1] dataframes_string += br_tally.get_pandas_dataframe().to_string() + '\n' - for t_id in (3, 4, 5): + for t_id in (3, 4, 5, 6): ef_tally = sp.tallies[t_id] dataframes_string += ef_tally.get_pandas_dataframe().to_string() + '\n' @@ -122,7 +134,16 @@ class FilterEnergyFunHarness(PyAPITestHarness): sp_log_lin_filt = sp_log_lin_tally.find_filter(openmc.EnergyFunctionFilter) assert sp_log_lin_filt.interpolation == 'log-linear' + # check that the cubic interpolation provides a higher value + # than linear-linear + contrived_lin_lin_tally = sp.get_tally(id=6) + contrived_quadratic_tally = sp.get_tally(id=7) + contrived_cubic_tally = sp.get_tally(id=8) + + assert all(contrived_lin_lin_tally.mean < contrived_quadratic_tally.mean) + assert all(contrived_lin_lin_tally.mean < contrived_cubic_tally.mean) + def test_filter_energyfun(model): harness = FilterEnergyFunHarness('statepoint.5.h5', model) - harness.main() + harness.main() \ No newline at end of file