1
- import openmc
1
+ from functools import wraps
2
+
2
3
import pytest
3
4
5
+ import openmc
6
+
4
7
from openmc_cad_adapter import to_cubit_journal
5
8
6
9
from .test_utilities import diff_gold_file
7
10
from test import run_in_tmpdir
8
11
9
12
13
+ def reset_openmc_ids (func ):
14
+ """
15
+ Decorator to reset the auto-generated IDs in OpenMC before running a test
16
+ """
17
+ @wraps (func )
18
+ def wrapper (* args , ** kwargs ):
19
+ openmc .reset_auto_ids ()
20
+ func (* args , ** kwargs )
21
+ return wrapper
22
+
23
+
24
+ @reset_openmc_ids
10
25
def test_planes (request , run_in_tmpdir ):
11
26
plane1 = openmc .Plane (A = 1.0 , B = 1.0 , C = 0.0 , D = - 5.0 )
12
27
plane2 = openmc .Plane (A = 1.0 , B = 1.0 , C = 0.0 , D = 5.0 )
@@ -18,80 +33,92 @@ def test_planes(request, run_in_tmpdir):
18
33
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'plane.jou' )
19
34
diff_gold_file ('plane.jou' )
20
35
36
+
21
37
# Test the XCylinder and YCylinder classes, the ZCylinder surface is tested
22
38
# extensively in the OpenMC example tests
39
+ @reset_openmc_ids
23
40
def test_xcylinder (request , run_in_tmpdir ):
24
41
x_cyl = openmc .XCylinder (r = 1.0 , y0 = 10.0 , z0 = 5.0 )
25
42
g = openmc .Geometry ([openmc .Cell (region = - x_cyl )])
26
43
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'xcylinder.jou' )
27
44
diff_gold_file ('xcylinder.jou' )
28
45
29
46
47
+ @reset_openmc_ids
30
48
def test_ycylinder (request , run_in_tmpdir ):
31
49
y_cyl = openmc .YCylinder (r = 1.0 , x0 = 10.0 , z0 = 5.0 )
32
50
g = openmc .Geometry ([openmc .Cell (region = - y_cyl )])
33
51
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'ycylinder.jou' )
34
52
diff_gold_file ('ycylinder.jou' )
35
53
36
54
55
+ @reset_openmc_ids
37
56
def test_cylinder (request , run_in_tmpdir ):
38
57
cyl = openmc .Cylinder (x0 = 0.0 , y0 = 0.0 , z0 = 0.0 , r = 6.0 , dx = 0.7071 , dy = 0.7071 , dz = 0.0 )
39
58
g = openmc .Geometry ([openmc .Cell (region = - cyl )])
40
59
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'cylinder.jou' )
41
60
diff_gold_file ('cylinder.jou' )
42
61
43
62
63
+ @reset_openmc_ids
44
64
def test_x_cone (request , run_in_tmpdir ):
45
65
x_cone = openmc .XCone (x0 = 30.0 , y0 = 3.0 , z0 = 5.0 , r2 = 5.0 )
46
66
g = openmc .Geometry ([openmc .Cell (region = - x_cone )])
47
67
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'x_cone.jou' )
48
68
diff_gold_file ('x_cone.jou' )
49
69
50
70
71
+ @reset_openmc_ids
51
72
def test_y_cone (request , run_in_tmpdir ):
52
73
y_cone = openmc .YCone (x0 = 40.0 , y0 = 20.0 , z0 = 7.0 , r2 = 2.0 )
53
74
g = openmc .Geometry ([openmc .Cell (region = - y_cone )])
54
75
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'y_cone.jou' )
55
76
diff_gold_file ('y_cone.jou' )
56
77
57
78
79
+ @reset_openmc_ids
58
80
def test_z_cone (request , run_in_tmpdir ):
59
81
z_cone = openmc .ZCone (x0 = 50.0 , y0 = 10.0 , z0 = 2.0 , r2 = 1.0 )
60
82
g = openmc .Geometry ([openmc .Cell (region = - z_cone )])
61
83
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'z_cone.jou' )
62
84
diff_gold_file ('z_cone.jou' )
63
85
64
86
87
+ @reset_openmc_ids
65
88
def test_x_torus (request , run_in_tmpdir ):
66
89
x_torus = openmc .XTorus (x0 = 10.0 , y0 = 10.0 , z0 = 10.0 , a = 5.0 , b = 2.0 , c = 2.0 )
67
90
g = openmc .Geometry ([openmc .Cell (region = - x_torus )])
68
91
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'x_torus.jou' )
69
92
diff_gold_file ('x_torus.jou' )
70
93
71
94
95
+ @reset_openmc_ids
72
96
def test_y_torus (request , run_in_tmpdir ):
73
97
y_torus = openmc .YTorus (x0 = - 10.0 , y0 = - 10.0 , z0 = - 10.0 , a = 5.0 , b = 2.0 , c = 2.0 )
74
98
g = openmc .Geometry ([openmc .Cell (region = - y_torus )])
75
99
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'y_torus.jou' )
76
100
diff_gold_file ('y_torus.jou' )
77
101
78
102
103
+ @reset_openmc_ids
79
104
def test_z_torus (request , run_in_tmpdir ):
80
105
z_torus = openmc .ZTorus (x0 = 50.0 , y0 = 50.0 , z0 = 50.0 , a = 5.0 , b = 2.0 , c = 2.0 )
81
106
g = openmc .Geometry ([openmc .Cell (region = - z_torus )])
82
107
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'z_torus.jou' )
83
108
diff_gold_file ('z_torus.jou' )
84
109
85
110
111
+ @reset_openmc_ids
86
112
def test_torus_diff_radii (request , run_in_tmpdir ):
87
113
with pytest .raises (ValueError ):
88
114
z_torus = openmc .ZTorus (x0 = 50.0 , y0 = 50.0 , z0 = 50.0 , a = 5.0 , b = 2.0 , c = 3.0 )
89
115
g = openmc .Geometry ([openmc .Cell (region = - z_torus )])
90
116
to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'a_torus.jou' )
91
117
92
118
119
+ @reset_openmc_ids
93
120
def test_general_cone (request , run_in_tmpdir ):
94
121
with pytest .raises (NotImplementedError ):
95
122
cone = openmc .Cone (x0 = 0.0 , y0 = 0.0 , z0 = 0.0 , r2 = 6.0 , dx = 1 , dy = 1 , dz = 1 )
96
123
g = openmc .Geometry ([openmc .Cell (region = - cone )])
97
- to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'cone.jou' )
124
+ to_cubit_journal (g , world = (500 , 500 , 500 ), filename = 'cone.jou' )
0 commit comments