Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeprieto committed Oct 17, 2024
1 parent 32e129b commit be3151a
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 0 deletions.
Empty file.
59 changes: 59 additions & 0 deletions tests/regression_tests/filter_rotations/inputs_true.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version='1.0' encoding='utf-8'?>
<model>
<materials>
<material depletable="true" id="1">
<density units="g/cm3" value="10.0"/>
<nuclide ao="1.0" name="U235"/>
</material>
<material id="2">
<density units="g/cm3" value="1.0"/>
<nuclide ao="1.0" name="Zr90"/>
</material>
</materials>
<geometry>
<cell id="1" material="1" region="1 -2 3 -4 10 -9" universe="1"/>
<cell id="2" material="2" region="(-1 | 2 | -3 | 4) (5 -6 7 -8) 10 -9" universe="1"/>
<surface coeffs="-5.0" id="1" name="minimum x" type="x-plane"/>
<surface coeffs="5.0" id="2" name="maximum x" type="x-plane"/>
<surface coeffs="-5.0" id="3" name="minimum y" type="y-plane"/>
<surface coeffs="5.0" id="4" name="maximum y" type="y-plane"/>
<surface boundary="reflective" coeffs="-10.0" id="5" name="minimum x" type="x-plane"/>
<surface boundary="reflective" coeffs="10.0" id="6" name="maximum x" type="x-plane"/>
<surface boundary="reflective" coeffs="-10.0" id="7" name="minimum y" type="y-plane"/>
<surface boundary="reflective" coeffs="10.0" id="8" name="maximum y" type="y-plane"/>
<surface boundary="vacuum" coeffs="10.0" id="9" type="z-plane"/>
<surface boundary="vacuum" coeffs="-10.0" id="10" type="z-plane"/>
</geometry>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>1000</particles>
<batches>5</batches>
<inactive>0</inactive>
</settings>
<tallies>
<mesh id="1">
<dimension>3 4 5</dimension>
<lower_left>-9 -9 -9</lower_left>
<upper_right>9 9 9</upper_right>
</mesh>
<mesh id="2">
<dimension>3 4 5</dimension>
<lower_left>-9 -9 -9</lower_left>
<upper_right>9 9 9</upper_right>
</mesh>
<filter id="1" type="mesh">
<bins>1</bins>
</filter>
<filter id="2" rotation="180 0 0" type="mesh">
<bins>2</bins>
</filter>
<tally id="1">
<filters>1</filters>
<scores>total</scores>
</tally>
<tally id="2">
<filters>2</filters>
<scores>total</scores>
</tally>
</tallies>
</model>
244 changes: 244 additions & 0 deletions tests/regression_tests/filter_rotations/results_true.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
k-combined:
7.636353E-01 4.057290E-02
tally 1:
4.822286E-02
4.702103E-04
7.795747E-02
1.264976E-03
5.246247E-02
6.010487E-04
1.381521E-01
3.882829E-03
4.006098E-01
3.276817E-02
1.461245E-01
4.284629E-03
1.472761E-01
4.580042E-03
4.231003E-01
3.688977E-02
1.570474E-01
4.994200E-03
5.343196E-02
5.920614E-04
7.887573E-02
1.268548E-03
6.104743E-02
7.603156E-04
5.802196E-02
6.982348E-04
9.537977E-02
1.844108E-03
6.396802E-02
8.270095E-04
1.585161E-01
5.084396E-03
6.167748E-01
7.697960E-02
2.006027E-01
8.324003E-03
2.017743E-01
8.189489E-03
5.819773E-01
6.794391E-02
1.982030E-01
7.902246E-03
6.154927E-02
7.698096E-04
1.015902E-01
2.071734E-03
6.962916E-02
9.993543E-04
6.776056E-02
9.385013E-04
1.143174E-01
2.691537E-03
7.666265E-02
1.193926E-03
2.007931E-01
8.319175E-03
9.777197E-01
2.519793E-01
2.285251E-01
1.055548E-02
2.089040E-01
8.785184E-03
9.910042E-01
2.510425E-01
2.275036E-01
1.048027E-02
7.152323E-02
1.026565E-03
1.193786E-01
2.869848E-03
7.347415E-02
1.119793E-03
5.947772E-02
7.124689E-04
9.579824E-02
1.844045E-03
6.679543E-02
8.965346E-04
1.935643E-01
7.693339E-03
5.637670E-01
6.397346E-02
1.816786E-01
6.678457E-03
1.911934E-01
7.522517E-03
6.011794E-01
7.269645E-02
1.966028E-01
7.881554E-03
5.786691E-02
6.751742E-04
9.672829E-02
1.898387E-03
6.519787E-02
8.768115E-04
5.472934E-02
6.263917E-04
7.754484E-02
1.233552E-03
4.910631E-02
4.844593E-04
1.211479E-01
3.056876E-03
3.526875E-01
2.579511E-02
1.228810E-01
3.139485E-03
1.446069E-01
4.513740E-03
3.597180E-01
2.676605E-02
1.341348E-01
3.663077E-03
4.904601E-02
4.951114E-04
7.578263E-02
1.154340E-03
5.126777E-02
5.406317E-04
tally 2:
4.904601E-02
4.951114E-04
7.578263E-02
1.154340E-03
5.126777E-02
5.406317E-04
1.446069E-01
4.513740E-03
3.597180E-01
2.676605E-02
1.341348E-01
3.663077E-03
1.211479E-01
3.056876E-03
3.526875E-01
2.579511E-02
1.228810E-01
3.139485E-03
5.472934E-02
6.263917E-04
7.754484E-02
1.233552E-03
4.910631E-02
4.844593E-04
5.786691E-02
6.751742E-04
9.672829E-02
1.898387E-03
6.519787E-02
8.768115E-04
1.911934E-01
7.522517E-03
6.011794E-01
7.269645E-02
1.966028E-01
7.881554E-03
1.935643E-01
7.693339E-03
5.637670E-01
6.397346E-02
1.816786E-01
6.678457E-03
5.947772E-02
7.124689E-04
9.579824E-02
1.844045E-03
6.679543E-02
8.965346E-04
7.152323E-02
1.026565E-03
1.193786E-01
2.869848E-03
7.347415E-02
1.119793E-03
2.089040E-01
8.785184E-03
9.910042E-01
2.510425E-01
2.275036E-01
1.048027E-02
2.007931E-01
8.319175E-03
9.777197E-01
2.519793E-01
2.285251E-01
1.055548E-02
6.776056E-02
9.385013E-04
1.143174E-01
2.691537E-03
7.666265E-02
1.193926E-03
6.154927E-02
7.698096E-04
1.015902E-01
2.071734E-03
6.962916E-02
9.993543E-04
2.017743E-01
8.189489E-03
5.819773E-01
6.794391E-02
1.982030E-01
7.902246E-03
1.585161E-01
5.084396E-03
6.167748E-01
7.697960E-02
2.006027E-01
8.324003E-03
5.802196E-02
6.982348E-04
9.537977E-02
1.844108E-03
6.396802E-02
8.270095E-04
5.343196E-02
5.920614E-04
7.887573E-02
1.268548E-03
6.104743E-02
7.603156E-04
1.472761E-01
4.580042E-03
4.231003E-01
3.688977E-02
1.570474E-01
4.994200E-03
1.381521E-01
3.882829E-03
4.006098E-01
3.276817E-02
1.461245E-01
4.284629E-03
4.822286E-02
4.702103E-04
7.795747E-02
1.264976E-03
5.246247E-02
6.010487E-04
73 changes: 73 additions & 0 deletions tests/regression_tests/filter_rotations/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import numpy as np

import openmc
import pytest

from tests.testing_harness import PyAPITestHarness


@pytest.fixture
def model():

model = openmc.model.Model()

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])

box1 = openmc.model.RectangularPrism(10.0, 10.0)
box2 = openmc.model.RectangularPrism(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])

model.settings.batches = 5
model.settings.inactive = 0
model.settings.particles = 1000

rotation = np.array((180, 0, 0))

llc = np.array([-9, -9, -9])
urc = np.array([9, 9, 9])

mesh_dims = (3, 4, 5)

filters = []

# un-rotated meshes
reg_mesh = openmc.RegularMesh()
reg_mesh.dimension = mesh_dims
reg_mesh.lower_left = llc
reg_mesh.upper_right = urc

filters.append(openmc.MeshFilter(reg_mesh))


# rotated meshes
rotated_reg_mesh = openmc.RegularMesh()
rotated_reg_mesh.dimension = mesh_dims
rotated_reg_mesh.lower_left = llc
rotated_reg_mesh.upper_right = urc

filters.append(openmc.MeshFilter(rotated_reg_mesh))
filters[-1].rotation = rotation

# Create tallies
for f in filters:
tally = openmc.Tally()
tally.filters = [f]
tally.scores = ['total']
model.tallies.append(tally)

return model


def test_filter_mesh_rotations(model):
harness = PyAPITestHarness('statepoint.5.h5', model)
harness.main()
7 changes: 7 additions & 0 deletions tests/unit_tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,13 @@ def test_regular_mesh(lib_init):
msf.translation = translation
assert msf.translation == translation

rotation = (180.0, 0.0, 0.0)

mf = openmc.lib.MeshFilter(mesh)
assert mf.mesh == mesh
mf.rotation = rotation
assert mf.rotation == rotation

# Test material volumes
mesh = openmc.lib.RegularMesh()
mesh.dimension = (2, 2, 1)
Expand Down

0 comments on commit be3151a

Please sign in to comment.