From 92433b255c397db3cd8da41222fd9f022f896b22 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 19 Aug 2019 09:56:21 -0500 Subject: [PATCH] Update filter_mesh test --- .../filter_mesh/inputs_true.dat | 334 ++---------------- .../filter_mesh/results_true.dat | 2 +- tests/regression_tests/filter_mesh/test.py | 151 ++++---- 3 files changed, 117 insertions(+), 370 deletions(-) diff --git a/tests/regression_tests/filter_mesh/inputs_true.dat b/tests/regression_tests/filter_mesh/inputs_true.dat index 6755a64c8..919347d69 100644 --- a/tests/regression_tests/filter_mesh/inputs_true.dat +++ b/tests/regression_tests/filter_mesh/inputs_true.dat @@ -1,332 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 -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 8 8 8 8 8 8 8 8 8 8 8 8 8 7 7 -7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 7 7 -7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 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 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 - 10 - 5 - - - -160 -160 -183 160 160 183 - - + 1000 + 5 + 0 17 - -182.07 - 182.07 + -10.0 + 10.0 17 17 - -182.07 -182.07 - 182.07 182.07 + -10.0 -10.0 + 10.0 10.0 17 17 17 - -182.07 -182.07 -183.0 - 182.07 182.07 183.0 + -10.0 -10.0 -183.0 + 10.0 10.0 183.0 - -182.07 -160.65 -139.23 -117.81 -96.39 -74.97 -53.55000000000001 -32.129999999999995 -10.710000000000008 10.70999999999998 32.129999999999995 53.54999999999998 74.96999999999997 96.38999999999999 117.81 139.22999999999996 160.64999999999998 182.07 - -182.07 -160.65 -139.23 -117.81 -96.39 -74.97 -53.55000000000001 -32.129999999999995 -10.710000000000008 10.70999999999998 32.129999999999995 53.54999999999998 74.96999999999997 96.38999999999999 117.81 139.22999999999996 160.64999999999998 182.07 + -10.0 -8.823529411764707 -7.647058823529411 -6.470588235294118 -5.294117647058823 -4.117647058823529 -2.9411764705882355 -1.7647058823529402 -0.5882352941176467 0.5882352941176467 1.764705882352942 2.9411764705882355 4.117647058823529 5.294117647058824 6.4705882352941195 7.647058823529413 8.823529411764707 10.0 + -10.0 -8.823529411764707 -7.647058823529411 -6.470588235294118 -5.294117647058823 -4.117647058823529 -2.9411764705882355 -1.7647058823529402 -0.5882352941176467 0.5882352941176467 1.764705882352942 2.9411764705882355 4.117647058823529 5.294117647058824 6.4705882352941195 7.647058823529413 8.823529411764707 10.0 1.0 1.683624003879018 2.8345897864376153 4.772383405596668 8.034899257376447 13.52774925846868 22.77564337001445 38.34561988154435 64.55960607618856 108.69410247084474 182.99999999999991 diff --git a/tests/regression_tests/filter_mesh/results_true.dat b/tests/regression_tests/filter_mesh/results_true.dat index 05efffe2f..55653d1a5 100644 --- a/tests/regression_tests/filter_mesh/results_true.dat +++ b/tests/regression_tests/filter_mesh/results_true.dat @@ -1 +1 @@ -35f04a6f062ef64116ef4eb0e9b803cd44cff7e185e2b53c9174afad8a26ca1a436ca9b800d6a228e006a9129f4536d7dce289d7a11cd56c6949d71d6a201b31 \ No newline at end of file +2bc8fce4a61bc431e90c44400ac626e7043144b575eeb5ca66b8c4fefb9bed076b20663d096801dca63085f090a96e662f12b6281c85c3ba8ce73efbc55356ba \ No newline at end of file diff --git a/tests/regression_tests/filter_mesh/test.py b/tests/regression_tests/filter_mesh/test.py index ed2e9b35b..e68c5f0e1 100644 --- a/tests/regression_tests/filter_mesh/test.py +++ b/tests/regression_tests/filter_mesh/test.py @@ -1,87 +1,110 @@ import numpy as np import openmc +import pytest from tests.testing_harness import HashedPyAPITestHarness -class FilterMeshTestHarness(HashedPyAPITestHarness): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) +@pytest.fixture +def model(): + model = openmc.model.Model() - # Initialize Meshes - mesh_1d = openmc.RegularMesh(mesh_id=1) - mesh_1d.dimension = [17] - mesh_1d.lower_left = [-182.07] - mesh_1d.upper_right = [182.07] + fuel = openmc.Material() + fuel.set_density('g/cm3', 10.0) + fuel.add_nuclide('U235', 1.0) + zr = openmc.Material() + zr.set_density('g/cm3', 1.0) + zr.add_nuclide('Zr90', 1.0) + model.materials.extend([fuel, zr]) - mesh_2d = openmc.RegularMesh(mesh_id=2) - mesh_2d.dimension = [17, 17] - mesh_2d.lower_left = [-182.07, -182.07] - mesh_2d.upper_right = [182.07, 182.07] + box1 = openmc.model.rectangular_prism(10.0, 10.0) + box2 = openmc.model.rectangular_prism(20.0, 20.0, boundary_type='reflective') + top = openmc.ZPlane(z0=10.0, boundary_type='vacuum') + bottom = openmc.ZPlane(z0=-10.0, boundary_type='vacuum') + cell1 = openmc.Cell(fill=fuel, region=box1 & +bottom & -top) + cell2 = openmc.Cell(fill=zr, region=~box1 & box2 & +bottom & -top) + model.geometry = openmc.Geometry([cell1, cell2]) - mesh_3d = openmc.RegularMesh(mesh_id=3) - mesh_3d.dimension = [17, 17, 17] - mesh_3d.lower_left = [-182.07, -182.07, -183.00] - mesh_3d.upper_right = [182.07, 182.07, 183.00] + model.settings.batches = 5 + model.settings.inactive = 0 + model.settings.particles = 1000 - recti_mesh = openmc.RectilinearMesh(mesh_id=4) - recti_mesh.x_grid = np.linspace(-182.07, 182.07, 18) - recti_mesh.y_grid = np.linspace(-182.07, 182.07, 18) - recti_mesh.z_grid = np.logspace(0, np.log10(183), 11) + # Initialize Meshes + mesh_1d = openmc.RegularMesh() + mesh_1d.dimension = [17] + mesh_1d.lower_left = [-10.0] + mesh_1d.upper_right = [10.0] - # Initialize the filters - mesh_1d_filter = openmc.MeshFilter(mesh_1d) - mesh_2d_filter = openmc.MeshFilter(mesh_2d) - mesh_3d_filter = openmc.MeshFilter(mesh_3d) - recti_mesh_filter = openmc.MeshFilter(recti_mesh) - meshsurf_1d_filter = openmc.MeshSurfaceFilter(mesh_1d) - meshsurf_2d_filter = openmc.MeshSurfaceFilter(mesh_2d) - meshsurf_3d_filter = openmc.MeshSurfaceFilter(mesh_3d) - recti_meshsurf_filter = openmc.MeshSurfaceFilter(recti_mesh) + mesh_2d = openmc.RegularMesh() + mesh_2d.dimension = [17, 17] + mesh_2d.lower_left = [-10.0, -10.0] + mesh_2d.upper_right = [10.0, 10.0] - # Initialized the tallies - tally = openmc.Tally(name='tally 1') - tally.filters = [mesh_1d_filter] - tally.scores = ['total'] - self._model.tallies.append(tally) + mesh_3d = openmc.RegularMesh() + mesh_3d.dimension = [17, 17, 17] + mesh_3d.lower_left = [-10.0, -10.0, -183.00] + mesh_3d.upper_right = [10.0, 10.0, 183.00] - tally = openmc.Tally(name='tally 2') - tally.filters = [meshsurf_1d_filter] - tally.scores = ['current'] - self._model.tallies.append(tally) + recti_mesh = openmc.RectilinearMesh() + recti_mesh.x_grid = np.linspace(-10.0, 10.0, 18) + recti_mesh.y_grid = np.linspace(-10.0, 10.0, 18) + recti_mesh.z_grid = np.logspace(0, np.log10(183), 11) - tally = openmc.Tally(name='tally 3') - tally.filters = [mesh_2d_filter] - tally.scores = ['total'] - self._model.tallies.append(tally) + # Initialize the filters + mesh_1d_filter = openmc.MeshFilter(mesh_1d) + mesh_2d_filter = openmc.MeshFilter(mesh_2d) + mesh_3d_filter = openmc.MeshFilter(mesh_3d) + recti_mesh_filter = openmc.MeshFilter(recti_mesh) + meshsurf_1d_filter = openmc.MeshSurfaceFilter(mesh_1d) + meshsurf_2d_filter = openmc.MeshSurfaceFilter(mesh_2d) + meshsurf_3d_filter = openmc.MeshSurfaceFilter(mesh_3d) + recti_meshsurf_filter = openmc.MeshSurfaceFilter(recti_mesh) - tally = openmc.Tally(name='tally 4') - tally.filters = [meshsurf_2d_filter] - tally.scores = ['current'] - self._model.tallies.append(tally) + # Initialized the tallies + tally = openmc.Tally(name='tally 1') + tally.filters = [mesh_1d_filter] + tally.scores = ['total'] + model.tallies.append(tally) - tally = openmc.Tally(name='tally 5') - tally.filters = [mesh_3d_filter] - tally.scores = ['total'] - self._model.tallies.append(tally) + tally = openmc.Tally(name='tally 2') + tally.filters = [meshsurf_1d_filter] + tally.scores = ['current'] + model.tallies.append(tally) - tally = openmc.Tally(name='tally 6') - tally.filters = [meshsurf_3d_filter] - tally.scores = ['current'] - self._model.tallies.append(tally) + tally = openmc.Tally(name='tally 3') + tally.filters = [mesh_2d_filter] + tally.scores = ['total'] + model.tallies.append(tally) - tally = openmc.Tally(name='tally 7') - tally.filters = [recti_mesh_filter] - tally.scores = ['total'] - self._model.tallies.append(tally) + tally = openmc.Tally(name='tally 4') + tally.filters = [meshsurf_2d_filter] + tally.scores = ['current'] + model.tallies.append(tally) - tally = openmc.Tally(name='tally 8') - tally.filters = [recti_meshsurf_filter] - tally.scores = ['current'] - self._model.tallies.append(tally) + tally = openmc.Tally(name='tally 5') + tally.filters = [mesh_3d_filter] + tally.scores = ['total'] + model.tallies.append(tally) + + tally = openmc.Tally(name='tally 6') + tally.filters = [meshsurf_3d_filter] + tally.scores = ['current'] + model.tallies.append(tally) + + tally = openmc.Tally(name='tally 7') + tally.filters = [recti_mesh_filter] + tally.scores = ['total'] + model.tallies.append(tally) + + tally = openmc.Tally(name='tally 8') + tally.filters = [recti_meshsurf_filter] + tally.scores = ['current'] + model.tallies.append(tally) + + return model -def test_filter_mesh(): - harness = FilterMeshTestHarness('statepoint.10.h5') +def test_filter_mesh(model): + harness = HashedPyAPITestHarness('statepoint.5.h5', model) harness.main()