diff --git a/tests/regression_tests/filter_energyfun/inputs_true.dat b/tests/regression_tests/filter_energyfun/inputs_true.dat index 418354fc2..0f506f3f5 100644 --- a/tests/regression_tests/filter_energyfun/inputs_true.dat +++ b/tests/regression_tests/filter_energyfun/inputs_true.dat @@ -1,312 +1,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.26 1.26 - 17 17 - -10.71 -10.71 - -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 -1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 2 1 1 2 1 1 2 1 1 2 1 1 2 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 -1 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 - - - 1.26 1.26 - 17 17 - -10.71 -10.71 - -3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -3 3 3 3 3 4 3 3 4 3 3 4 3 3 3 3 3 -3 3 3 4 3 3 3 3 3 3 3 3 3 4 3 3 3 -3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -3 3 4 3 3 4 3 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8 7 7 7 -7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 7 7 7 7 -7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 7 7 7 7 7 -7 7 7 7 7 7 7 8 8 8 8 8 8 8 7 7 7 7 7 7 7 -7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 -7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + eigenvalue - 100 - 10 - 5 - - - -160 -160 -183 160 160 183 - - + 1000 + 5 + 0 diff --git a/tests/regression_tests/filter_energyfun/results_true.dat b/tests/regression_tests/filter_energyfun/results_true.dat index 8e5577c43..a88cff496 100644 --- a/tests/regression_tests/filter_energyfun/results_true.dat +++ b/tests/regression_tests/filter_energyfun/results_true.dat @@ -1,2 +1,2 @@ energyfunction nuclide score mean std. dev. -0 d2effa26cb3cf2 Am241 ((n,gamma) / (n,gamma)) 1.00e-01 9.97e-03 +0 d2effa26cb3cf2 Am241 ((n,gamma) / (n,gamma)) 1.74e-01 3.55e-03 diff --git a/tests/regression_tests/filter_energyfun/test.py b/tests/regression_tests/filter_energyfun/test.py index 7c5645b65..f61f05d78 100644 --- a/tests/regression_tests/filter_energyfun/test.py +++ b/tests/regression_tests/filter_energyfun/test.py @@ -1,36 +1,51 @@ import openmc +import pytest from tests.testing_harness import PyAPITestHarness +@pytest.fixture +def model(): + model = openmc.model.Model() + + m = openmc.Material() + m.set_density('g/cm3', 10.0) + m.add_nuclide('Am241', 1.0) + model.materials.append(m) + + s = openmc.Sphere(r=100.0, boundary_type='vacuum') + c = openmc.Cell(fill=m, region=-s) + model.geometry = openmc.Geometry([c]) + + model.settings.batches = 5 + model.settings.inactive = 0 + model.settings.particles = 1000 + + # Define Am242m / Am242 branching ratio from ENDF/B-VII.1 data. + x = [1e-5, 3.69e-1, 1e3, 1e5, 6e5, 1e6, 2e6, 4e6, 3e7] + y = [0.1, 0.1, 0.1333, 0.158, 0.18467, 0.25618, 0.4297, 0.48, 0.48] + + # Make an EnergyFunctionFilter directly from the x and y lists. + filt1 = openmc.EnergyFunctionFilter(x, y) + + # Also make a filter with the .from_tabulated1d constructor. Make sure + # the filters are identical. + tab1d = openmc.data.Tabulated1D(x, y) + filt2 = openmc.EnergyFunctionFilter.from_tabulated1d(tab1d) + assert filt1 == filt2, 'Error with the .from_tabulated1d constructor' + + # Make tallies + tallies = [openmc.Tally(), openmc.Tally()] + for t in tallies: + t.scores = ['(n,gamma)'] + t.nuclides = ['Am241'] + tallies[1].filters = [filt1] + model.tallies.extend(tallies) + + return model + + class FilterEnergyFunHarness(PyAPITestHarness): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - # Add Am241 to the fuel. - self._model.materials[1].add_nuclide('Am241', 1e-7) - - # Define Am242m / Am242 branching ratio from ENDF/B-VII.1 data. - x = [1e-5, 3.69e-1, 1e3, 1e5, 6e5, 1e6, 2e6, 4e6, 3e7] - y = [0.1, 0.1, 0.1333, 0.158, 0.18467, 0.25618, 0.4297, 0.48, 0.48] - - # Make an EnergyFunctionFilter directly from the x and y lists. - filt1 = openmc.EnergyFunctionFilter(x, y) - - # Also make a filter with the .from_tabulated1d constructor. Make sure - # the filters are identical. - tab1d = openmc.data.Tabulated1D(x, y) - filt2 = openmc.EnergyFunctionFilter.from_tabulated1d(tab1d) - assert filt1 == filt2, 'Error with the .from_tabulated1d constructor' - - # Make tallies. - tallies = [openmc.Tally(1), openmc.Tally(2)] - for t in tallies: - t.scores = ['(n,gamma)'] - t.nuclides = ['Am241'] - tallies[1].filters = [filt1] - self._model.tallies = tallies - def _get_results(self): # Read the statepoint file. sp = openmc.StatePoint(self._sp_name) @@ -42,6 +57,6 @@ class FilterEnergyFunHarness(PyAPITestHarness): return br_tally.get_pandas_dataframe().to_string() + '\n' -def test_filter_energyfun(): - harness = FilterEnergyFunHarness('statepoint.10.h5') +def test_filter_energyfun(model): + harness = FilterEnergyFunHarness('statepoint.5.h5', model) harness.main()