1+ import openmc
2+ import numpy
3+ import pytest
4+
5+ from tests .testing_harness import PyAPITestHarness
6+
7+
8+ @pytest .fixture
9+ def xcyl_model ():
10+ model = openmc .Model ()
11+ # Define materials
12+ fuel = openmc .Material ()
13+ fuel .add_nuclide ('U235' , 0.2 )
14+ fuel .add_nuclide ('U238' , 0.8 )
15+ fuel .set_density ('g/cc' , 19.1 )
16+ model .materials = openmc .Materials ([fuel ])
17+
18+ # Define geometry
19+ # finite cylinder
20+ x_min = openmc .XPlane (x0 = 0.0 , boundary_type = 'reflective' )
21+ x_max = openmc .XPlane (x0 = 20.0 , boundary_type = 'reflective' )
22+ x_cyl = openmc .XCylinder (r = 20.0 ,boundary_type = 'vacuum' )
23+ # slice cylinder for periodic BC
24+ periodic_bounding_yplane = openmc .YPlane (y0 = 0 , boundary_type = 'periodic' )
25+ periodic_bounding_plane = openmc .Plane (
26+ a = 0.0 , b = - np .sqrt (3 ) / 3 , c = 1 , boundary_type = 'periodic' ,
27+ )
28+ sixth_cyl_cell = openmc .Cell (1 , fill = fuel , region =
29+ + x_min & - x_max & - x_cyl & + periodic_bounding_yplane & + periodic_bounding_plane )
30+ periodic_bounding_yplane .periodic_surface = periodic_bounding_plane
31+ periodic_bounding_plane .periodic_surface = periodic_bounding_yplane
32+
33+ model .geometry = openmc .Geometry ([sixth_cyl_cell ])
34+
35+
36+ # Define settings
37+ model .settings .particles = 1000
38+ model .settings .batches = 4
39+ model .settings .inactive = 0
40+ model .settings .source = openmc .IndependentSource (space = openmc .stats .Box (
41+ (0 , 0 , 0 ), (20 , 20 , 20 ))
42+ )
43+
44+ @pytest .fixture
45+ def ycyl_model ():
46+ model = openmc .Model ()
47+ # Define materials
48+ fuel = openmc .Material ()
49+ fuel .add_nuclide ('U235' , 0.2 )
50+ fuel .add_nuclide ('U238' , 0.8 )
51+ fuel .set_density ('g/cc' , 19.1 )
52+ model .materials = openmc .Materials ([fuel ])
53+
54+ # Define geometry
55+ # finite cylinder
56+ y_min = openmc .YPlane (y0 = 0.0 , boundary_type = 'reflective' )
57+ y_max = openmc .YPlane (y0 = 20.0 , boundary_type = 'reflective' )
58+ y_cyl = openmc .YCylinder (r = 20.0 ,boundary_type = 'vacuum' )
59+ # slice cylinder for periodic BC
60+ periodic_bounding_xplane = openmc .XPlane (x0 = 0 , boundary_type = 'periodic' )
61+ periodic_bounding_plane = openmc .Plane (
62+ a = - np .sqrt (3 ) / 3 , b = 0.0 , c = 1 , boundary_type = 'periodic' ,
63+ )
64+ sixth_cyl_cell = openmc .Cell (1 , fill = fuel , region =
65+ + y_min & - y_max & - y_cyl & + periodic_bounding_xplane & + periodic_bounding_plane )
66+ periodic_bounding_xplane .periodic_surface = periodic_bounding_plane
67+ periodic_bounding_plane .periodic_surface = periodic_bounding_xplane
68+ model .geometry = openmc .Geometry ([sixth_cyl_cell ])
69+
70+
71+ # Define settings
72+ model .settings .particles = 1000
73+ model .settings .batches = 4
74+ model .settings .inactive = 0
75+ model .settings .source = openmc .IndependentSource (space = openmc .stats .Box (
76+ (0 , 0 , 0 ), (20 , 20 , 20 ))
77+ )
78+
79+
80+ @pytest .mark .parametrize ('cyl_model' , ['xcyl_model' ,'ycyl_model' ])
81+ def test_periodic (cyl_model ):
82+ with change_directory (cyl_model ):
83+ harness = PyAPITestHarness ('statepoint.4.h5' , cyl_model )
84+ harness .main ()
85+ assert
0 commit comments