From 339ba91565fb40819e25c297dac49ed8b88ffb34 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 2 Dec 2019 14:56:45 -0600 Subject: [PATCH] Add filter_cellinstance test --- .../filter_cellinstance/__init__.py | 0 .../filter_cellinstance/inputs_true.dat | 64 +++++++++++++++++ .../filter_cellinstance/results_true.dat | 68 ++++++++++++++++++ .../filter_cellinstance/test.py | 69 +++++++++++++++++++ 4 files changed, 201 insertions(+) create mode 100644 tests/regression_tests/filter_cellinstance/__init__.py create mode 100644 tests/regression_tests/filter_cellinstance/inputs_true.dat create mode 100644 tests/regression_tests/filter_cellinstance/results_true.dat create mode 100644 tests/regression_tests/filter_cellinstance/test.py diff --git a/tests/regression_tests/filter_cellinstance/__init__.py b/tests/regression_tests/filter_cellinstance/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regression_tests/filter_cellinstance/inputs_true.dat b/tests/regression_tests/filter_cellinstance/inputs_true.dat new file mode 100644 index 0000000000..5abf734333 --- /dev/null +++ b/tests/regression_tests/filter_cellinstance/inputs_true.dat @@ -0,0 +1,64 @@ + + + + + + + + + 2 2 + 4 4 + -4 -4 + +1 2 2 2 +2 1 2 2 +2 2 1 2 +2 2 2 1 + + + + + + + + + + + + + + + + + + + + + + eigenvalue + 1000 + 5 + 0 + + + 0.0 0.0 0.0 + + + + + + + 3 0 3 1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3 9 3 10 3 11 2 0 2 1 2 2 2 3 + + + 2 3 2 2 2 1 2 0 3 11 3 10 3 9 3 8 3 7 3 6 3 5 3 4 3 3 3 2 3 1 3 0 + + + 1 + total + + + 2 + total + + diff --git a/tests/regression_tests/filter_cellinstance/results_true.dat b/tests/regression_tests/filter_cellinstance/results_true.dat new file mode 100644 index 0000000000..c1b48be8ab --- /dev/null +++ b/tests/regression_tests/filter_cellinstance/results_true.dat @@ -0,0 +1,68 @@ +k-combined: +1.060380E+00 4.511966E-03 +tally 1: +8.636855E-02 +1.795640E-03 +1.478489E-01 +5.007770E-03 +1.687036E-01 +6.223488E-03 +1.035433E-01 +2.767195E-03 +2.789537E-01 +1.720816E-02 +1.420504E-01 +4.539772E-03 +1.325589E-01 +3.998010E-03 +2.934613E-01 +2.064779E-02 +1.231465E-01 +3.847169E-03 +1.282909E-01 +3.680695E-03 +1.545480E-01 +5.588411E-03 +5.110026E-02 +5.947113E-04 +1.119824E+01 +3.030467E+01 +2.847726E+01 +1.920547E+02 +2.819853E+01 +1.906807E+02 +8.816481E+00 +2.016785E+01 +tally 2: +8.816481E+00 +2.016785E+01 +2.819853E+01 +1.906807E+02 +2.847726E+01 +1.920547E+02 +1.119824E+01 +3.030467E+01 +5.110026E-02 +5.947113E-04 +1.545480E-01 +5.588411E-03 +1.282909E-01 +3.680695E-03 +1.231465E-01 +3.847169E-03 +2.934613E-01 +2.064779E-02 +1.325589E-01 +3.998010E-03 +1.420504E-01 +4.539772E-03 +2.789537E-01 +1.720816E-02 +1.035433E-01 +2.767195E-03 +1.687036E-01 +6.223488E-03 +1.478489E-01 +5.007770E-03 +8.636855E-02 +1.795640E-03 diff --git a/tests/regression_tests/filter_cellinstance/test.py b/tests/regression_tests/filter_cellinstance/test.py new file mode 100644 index 0000000000..dc00394fc2 --- /dev/null +++ b/tests/regression_tests/filter_cellinstance/test.py @@ -0,0 +1,69 @@ +import openmc +import openmc.model +import pytest + +from tests.testing_harness import PyAPITestHarness + + +@pytest.fixture +def model(): + model = openmc.model.Model() + + # Materials + m1 = openmc.Material() + m1.set_density('g/cc', 4.5) + m1.add_nuclide('U235', 1.0) + m2 = openmc.Material() + m2.set_density('g/cc', 1.0) + m2.add_nuclide('H1', 1.0) + model.materials += [m1, m2] + + # Geometry + cyl1 = openmc.ZCylinder(r=0.7) + c1 = openmc.Cell(fill=m1, region=-cyl1) + c2 = openmc.Cell(fill=m2, region=+cyl1) + u1 = openmc.Universe(cells=[c1, c2]) + + cyl2 = openmc.ZCylinder(r=0.5) + c3 = openmc.Cell(fill=m1, region=-cyl2) + c4 = openmc.Cell(fill=m2, region=+cyl2) + u2 = openmc.Universe(cells=[c3, c4]) + + lat = openmc.RectLattice() + lat.lower_left = (-4, -4) + lat.pitch = (2, 2) + lat.universes = [ + [u1, u2, u2, u2], + [u2, u1, u2, u2], + [u2, u2, u1, u2], + [u2, u2, u2, u1] + ] + box = openmc.model.rectangular_prism(8.0, 8.0, boundary_type='reflective') + main_cell = openmc.Cell(fill=lat, region=box) + model.geometry.root_universe = openmc.Universe(cells=[main_cell]) + model.geometry.determine_paths() + + # Settings + model.settings.batches = 5 + model.settings.inactive = 0 + model.settings.particles = 1000 + model.settings.source = openmc.Source(space=openmc.stats.Point()) + + instances = ([(c3, i) for i in range(c3.num_instances)] + + [(c2, i) for i in range(c2.num_instances)]) + f1 = openmc.CellInstanceFilter(instances) + f2 = openmc.CellInstanceFilter(instances[::-1]) + t1 = openmc.Tally() + t1.filters = [f1] + t1.scores = ['total'] + t2 = openmc.Tally() + t2.filters = [f2] + t2.scores = ['total'] + model.tallies += [t1, t2] + + return model + + +def test_cell_instance(model): + harness = PyAPITestHarness('statepoint.5.h5', model) + harness.main()