diff --git a/tests/regression_tests/tally_aggregation/inputs_true.dat b/tests/regression_tests/tally_aggregation/inputs_true.dat index 86806572a..80356f711 100644 --- a/tests/regression_tests/tally_aggregation/inputs_true.dat +++ b/tests/regression_tests/tally_aggregation/inputs_true.dat @@ -1,311 +1,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.26 1.26 - 17 17 - -10.71 -10.71 + + + + + 1.2 1.2 + 1 + 2 2 + -1.2 -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 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 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 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7 7 -7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 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 + 1000 10 5 - - - -160 -160 -183 160 160 183 - - @@ -313,7 +47,7 @@ 0.0 0.253 1000.0 1000000.0 20000000.0 - 60 + 1 1 2 diff --git a/tests/regression_tests/tally_aggregation/results_true.dat b/tests/regression_tests/tally_aggregation/results_true.dat index f1738ddfd..e48f93370 100644 --- a/tests/regression_tests/tally_aggregation/results_true.dat +++ b/tests/regression_tests/tally_aggregation/results_true.dat @@ -1 +1,97 @@ -eac8fb56a8146b9e186ac9fb003753f4a0a18d4159d10e6fa51da4856baef66a10a0f5fb10c5727b51c6e44d81c147a8a7348ad9c9f7119a6ec33e0361082376 \ No newline at end of file +[[1.63731762e-05 5.08325999e-04] + [3.27547470e-01 1.77506218e-01] + [1.89164083e-02 7.22719366e-01]], [[1.64200315e-05 5.45231503e-04] + [3.24031537e-01 1.75537230e-01] + [1.87708717e-02 7.26768216e-01]], [[1.67487818e-05 5.03394672e-04] + [3.07780931e-01 1.67166322e-01] + [1.97449893e-02 7.06598738e-01]], [[1.63603106e-05 6.10423337e-04] + [3.32313666e-01 1.79982864e-01] + [1.90686364e-02 7.22662206e-01]][[4.65536263e-07 4.34762669e-05] + [9.14451087e-03 4.56766386e-03] + [7.87091351e-04 1.04610084e-02]], [[1.70217471e-07 3.74604055e-05] + [9.18903111e-03 4.56228307e-03] + [1.74179620e-04 9.17281345e-03]], [[2.49291594e-07 1.81470751e-05] + [8.34746285e-03 4.15219947e-03] + [3.57935129e-04 1.00438242e-02]], [[4.12850822e-07 3.98122204e-05] + [1.38191650e-02 6.82224745e-03] + [6.79096490e-04 9.85922061e-03]][[1.03849782e-06 8.14983256e-04] + [1.13114721e+00 5.60394847e-01] + [1.40550899e-06 5.11848857e-01]], [[1.99773314e-06 1.03955500e-03] + [1.42269343e-01 9.92372469e-02] + [3.30482612e-05 8.08235307e-01]], [[1.45630159e-05 2.22446467e-04] + [1.30357824e-02 2.93669452e-02] + [3.05346682e-04 1.10154874e+00]], [[4.83030533e-05 9.03907895e-05] + [5.22127114e-03 1.11935954e-02] + [7.61611053e-02 4.57115627e-01]][[1.87165262e-08 1.43906416e-05] + [2.05916324e-02 1.01675733e-02] + [2.50902573e-08 8.54377830e-03]], [[1.12098060e-07 7.06870145e-05] + [2.16279434e-03 1.42142705e-03] + [1.22851164e-05 1.41445724e-02]], [[2.08629342e-07 1.63602148e-06] + [1.08988258e-04 2.01647731e-04] + [7.14052741e-06 9.13467415e-03]], [[6.49497971e-07 1.17295883e-06] + [7.03193479e-05 1.45388818e-04] + [1.11307638e-03 5.92861613e-03]][[0.28708077 0.27231775]], [[0.283269 0.26846215]], [[0.26933717 0.25561967]], [[0.29146272 0.27665912]], [[0.03591854 0.2267151 ]], [[0.03618374 0.23663228]], [[0.03393119 0.22268261]], [[0.03627092 0.22248212]], [[0.00333501 0.28502144]], [[0.00339378 0.2823686 ]], [[0.0032646 0.27622413]], [[0.0033623 0.28752397]], [[0.02014593 0.11667962]], [[0.01997231 0.11538764]], [[0.02100971 0.11974205]], [[0.02030272 0.11659029]][[0.00908247 0.00614665]], [[0.00911888 0.00556208]], [[0.00831969 0.00596124]], [[0.01375328 0.00849244]], [[0.00106067 0.00719168]], [[0.00113262 0.00790992]], [[0.00067545 0.00732313]], [[0.00134675 0.00584628]], [[5.86657354e-05 4.85962742e-03]], [[3.78231391e-05 3.26052035e-03]], [[7.89746053e-05 5.03120906e-03]], [[2.86395600e-05 4.89110417e-03]], [[0.00078861 0.00414495]], [[0.00017413 0.00090648]], [[0.00035855 0.00190835]], [[0.00068051 0.0036777 ]][[2.07154706e-04] + [4.29264961e-01] + [1.29926403e-01]], [[2.04124023e-04] + [4.23635331e-01] + [1.27891698e-01]], [[1.94482255e-04] + [4.02735295e-01] + [1.22027057e-01]], [[2.10260769e-04] + [4.35906468e-01] + [1.32005105e-01]], [[0.00022426] + [0.06105851] + [0.20135086]], [[0.00026389] + [0.0612101 ] + [0.21134203]], [[0.00023084] + [0.05761498] + [0.19876799]], [[0.00032256] + [0.061623 ] + [0.19680747]], [[5.87610156e-05] + [1.06427230e-02] + [2.77654967e-01]], [[5.94899925e-05] + [1.06822132e-02] + [2.75020675e-01]], [[5.93176564e-05] + [1.03968293e-02] + [2.69032575e-01]], [[5.94408186e-05] + [1.06809621e-02] + [2.80145865e-01]], [[3.45195544e-05] + [4.08749343e-03] + [1.32703540e-01]], [[3.41476180e-05] + [4.04112643e-03] + [1.31284684e-01]], [[3.55075881e-05] + [4.20014745e-03] + [1.36516110e-01]], [[3.45190823e-05] + [4.08609920e-03] + [1.32772398e-01]][[6.53616088e-06] + [1.01396032e-02] + [4.17862796e-03]], [[6.14101518e-06] + [1.01647874e-02] + [3.28144648e-03]], [[6.21879601e-06] + [9.29002877e-03] + [4.29521996e-03]], [[9.37998012e-06] + [1.53282674e-02] + [5.13014723e-03]], [[4.29725320e-05] + [1.28419933e-03] + [7.15501363e-03]], [[3.69392134e-05] + [1.38678579e-03] + [7.86925329e-03]], [[1.70223774e-05] + [7.65771551e-04] + [7.31421975e-03]], [[3.86750728e-05] + [1.59354492e-03] + [5.78376198e-03]], [[4.00936601e-07] + [1.10265266e-04] + [4.85873047e-03]], [[1.02736776e-06] + [7.78918832e-05] + [3.25980910e-03]], [[8.71027724e-07] + [1.64820060e-04] + [5.02912867e-03]], [[8.63231446e-07] + [8.45518855e-05] + [4.89045708e-03]], [[9.39068799e-07] + [1.12928697e-04] + [4.21779516e-03]], [[1.94712273e-07] + [2.39886479e-05] + [9.22741200e-04]], [[4.30155635e-07] + [5.18679547e-05] + [1.94104652e-03]], [[8.32395987e-07] + [1.00319931e-04] + [3.73878581e-03]] \ No newline at end of file diff --git a/tests/regression_tests/tally_aggregation/test.py b/tests/regression_tests/tally_aggregation/test.py index f7df543de..8914ac2a8 100644 --- a/tests/regression_tests/tally_aggregation/test.py +++ b/tests/regression_tests/tally_aggregation/test.py @@ -1,26 +1,63 @@ import hashlib import openmc +import pytest from tests.testing_harness import PyAPITestHarness +@pytest.fixture +def model(): + model = openmc.model.Model() + + fuel = openmc.Material(name='UO2') + fuel.set_density('g/cm3', 10.29769) + fuel.add_nuclide("U234", 4.4843e-6) + fuel.add_nuclide("U235", 5.5815e-4) + fuel.add_nuclide("U238", 2.2408e-2) + fuel.add_nuclide("O16", 4.5829e-2) + water = openmc.Material(name='light water') + water.add_nuclide('H1', 2.0) + water.add_nuclide('O16', 1.0) + water.set_density('g/cm3', 1.0) + water.add_s_alpha_beta('c_H_in_H2O') + model.materials.extend([fuel, water]) + + cyl = openmc.ZCylinder(r=0.4) + c1 = openmc.Cell(fill=fuel, region=-cyl) + c2 = openmc.Cell(fill=water, region=+cyl) + pin = openmc.Universe(cells=[c1, c2]) + d = 1.2 + lattice = openmc.RectLattice() + lattice.lower_left = (-d, -d) + lattice.pitch = (d, d) + lattice.outer = pin + lattice.universes = [ + [pin, pin], + [pin, pin], + ] + box = openmc.model.rectangular_prism(2*d, 2*d, boundary_type='reflective') + main_cell = openmc.Cell(fill=lattice, region=box) + model.geometry = openmc.Geometry([main_cell]) + + model.settings.batches = 10 + model.settings.inactive = 5 + model.settings.particles = 1000 + + energy_filter = openmc.EnergyFilter([0.0, 0.253, 1.0e3, 1.0e6, 20.0e6]) + distrib_filter = openmc.DistribcellFilter(c1) + tally = openmc.Tally(name='distribcell tally') + tally.filters = [energy_filter, distrib_filter] + tally.scores = ['nu-fission', 'total'] + tally.nuclides = ['U234', 'U235', 'U238'] + model.tallies.append(tally) + + return model + + + class TallyAggregationTestHarness(PyAPITestHarness): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - - # Initialize the filters - energy_filter = openmc.EnergyFilter([0.0, 0.253, 1.0e3, 1.0e6, 20.0e6]) - distrib_filter = openmc.DistribcellFilter(60) - - # Initialized the tallies - tally = openmc.Tally(name='distribcell tally') - tally.filters = [energy_filter, distrib_filter] - tally.scores = ['nu-fission', 'total'] - tally.nuclides = ['U234', 'U235', 'U238'] - self._model.tallies.append(tally) - - def _get_results(self, hash_output=True): + def _get_results(self, hash_output=False): """Digest info in the statepoint and return as a string.""" # Read the statepoint file. @@ -52,15 +89,9 @@ class TallyAggregationTestHarness(PyAPITestHarness): outstr += ', '.join(map(str, tally_sum.mean)) outstr += ', '.join(map(str, tally_sum.std_dev)) - # Hash the results if necessary - if hash_output: - sha512 = hashlib.sha512() - sha512.update(outstr.encode('utf-8')) - outstr = sha512.hexdigest() - return outstr -def test_tally_aggregation(): - harness = TallyAggregationTestHarness('statepoint.10.h5') +def test_tally_aggregation(model): + harness = TallyAggregationTestHarness('statepoint.10.h5', model) harness.main()