Skip to content

Commit afdd4d9

Browse files
committed
pep8
1 parent c73458e commit afdd4d9

File tree

6 files changed

+79
-131
lines changed

6 files changed

+79
-131
lines changed

openmc_dagmc_wrapper/Geometry.py

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from typing import Tuple
32

43
import dagmc_h5m_file_inspector as di
@@ -30,7 +29,7 @@ def __init__(
3029
self,
3130
h5m_filename: str = None,
3231
reflective_angles: Tuple[float, float] = None,
33-
graveyard_box=None
32+
graveyard_box=None,
3433
):
3534
self.h5m_filename = h5m_filename
3635
self.reflective_angles = reflective_angles
@@ -45,7 +44,7 @@ def make_root(self):
4544
if self.reflective_angles is None:
4645
# if a graveyard is not found in the dagmc geometry a CSG one is
4746
# made
48-
if 'graveyard' not in di.get_materials_from_h5m(self.h5m_filename):
47+
if "graveyard" not in di.get_materials_from_h5m(self.h5m_filename):
4948
# vac_surfs = self.create_cube_of_vacuum_surfaces()
5049
# # creates a cube of surfaces for the boundary conditions
5150
# region = +vac_surfs[0] & \
@@ -58,9 +57,7 @@ def make_root(self):
5857
region = -vac_surf
5958

6059
containing_cell = openmc.Cell(
61-
cell_id=9999,
62-
region=region,
63-
fill=dag_univ
60+
cell_id=9999, region=region, fill=dag_univ
6461
)
6562
root = [containing_cell]
6663
else:
@@ -72,7 +69,7 @@ def make_root(self):
7269
c=0.0,
7370
d=0.0,
7471
surface_id=9991,
75-
boundary_type='reflective'
72+
boundary_type="reflective",
7673
)
7774

7875
reflective_2 = openmc.Plane(
@@ -81,22 +78,18 @@ def make_root(self):
8178
c=0.0,
8279
d=0.0,
8380
surface_id=9990,
84-
boundary_type='reflective'
81+
boundary_type="reflective",
8582
)
8683

8784
# if a graveyard is not found in the dagmc geometry a CSG one is
8885
# made
89-
if 'graveyard' in di.get_materials_from_h5m(self.h5m_filename):
86+
if "graveyard" in di.get_materials_from_h5m(self.h5m_filename):
9087
region = -reflective_1 & +reflective_2
9188
else:
9289
vac_surf = self.create_sphere_of_vacuum_surface()
9390
region = -vac_surf & -reflective_1 & +reflective_2
9491

95-
containing_cell = openmc.Cell(
96-
cell_id=9999,
97-
region=region,
98-
fill=dag_univ
99-
)
92+
containing_cell = openmc.Cell(cell_id=9999, region=region, fill=dag_univ)
10093

10194
root = [containing_cell]
10295
return root
@@ -112,9 +105,8 @@ def create_sphere_of_vacuum_surface(self):
112105
largest_radius = max(max(bbox[0]), max(bbox[1]))
113106

114107
sphere_surface = openmc.Sphere(
115-
r=largest_radius,
116-
surface_id=9999,
117-
boundary_type='vacuum')
108+
r=largest_radius, surface_id=9999, boundary_type="vacuum"
109+
)
118110

119111
return sphere_surface
120112

@@ -130,31 +122,13 @@ def create_cube_of_vacuum_surfaces(self):
130122
bbox[0][0] = 0.0
131123
bbox[0][1] = 0.0
132124

133-
lower_x = openmc.XPlane(
134-
bbox[0][0],
135-
surface_id=9999,
136-
boundary_type='vacuum')
137-
upper_x = openmc.XPlane(
138-
bbox[1][0],
139-
surface_id=9998,
140-
boundary_type='vacuum')
141-
142-
lower_y = openmc.YPlane(
143-
bbox[0][1],
144-
surface_id=9997,
145-
boundary_type='vacuum')
146-
upper_y = openmc.YPlane(
147-
bbox[1][1],
148-
surface_id=9996,
149-
boundary_type='vacuum')
150-
151-
lower_z = openmc.ZPlane(
152-
bbox[0][2],
153-
surface_id=9995,
154-
boundary_type='vacuum')
155-
upper_z = openmc.ZPlane(
156-
bbox[1][2],
157-
surface_id=9994,
158-
boundary_type='vacuum')
125+
lower_x = openmc.XPlane(bbox[0][0], surface_id=9999, boundary_type="vacuum")
126+
upper_x = openmc.XPlane(bbox[1][0], surface_id=9998, boundary_type="vacuum")
127+
128+
lower_y = openmc.YPlane(bbox[0][1], surface_id=9997, boundary_type="vacuum")
129+
upper_y = openmc.YPlane(bbox[1][1], surface_id=9996, boundary_type="vacuum")
130+
131+
lower_z = openmc.ZPlane(bbox[0][2], surface_id=9995, boundary_type="vacuum")
132+
upper_z = openmc.ZPlane(bbox[1][2], surface_id=9994, boundary_type="vacuum")
159133

160134
return [lower_x, upper_x, lower_y, upper_y, lower_z, upper_z]

openmc_dagmc_wrapper/Materials.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import dagmc_h5m_file_inspector as di
32
import neutronics_material_maker as nmm
43
import openmc
@@ -34,16 +33,13 @@ def correspondence_dict(self):
3433
@correspondence_dict.setter
3534
def correspondence_dict(self, value):
3635
if not isinstance(value, dict):
37-
raise TypeError(
38-
".correspondence_dict should be a dictionary"
39-
)
36+
raise TypeError(".correspondence_dict should be a dictionary")
4037
self._correspondence_dict = value
4138

4239
def set_openmc_materials(self):
4340
openmc_materials = {}
4441
for material_tag, material_entry in self.correspondence_dict.items():
45-
openmc_material = create_material(
46-
material_tag, material_entry)
42+
openmc_material = create_material(material_tag, material_entry)
4743
openmc_materials[material_tag] = openmc_material
4844

4945
self.openmc_materials = openmc_materials
@@ -70,7 +66,8 @@ def checks(self):
7066
f"the number of materials provided in the correspondence_dict "
7167
f"{len(self.correspondence_dict.keys())} "
7268
f"is not equal to the number of materials specified in the "
73-
f"DAGMC h5m file {required_nb_of_materials}")
69+
f"DAGMC h5m file {required_nb_of_materials}"
70+
)
7471
raise ValueError(msg)
7572

7673
silently_remove_file("materials.xml")

openmc_dagmc_wrapper/Settings.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import openmc
32

43

@@ -13,5 +12,5 @@ def __init__(self):
1312
super().__init__()
1413

1514
# performed after the super init as these are setting attributes
16-
self.run_mode = 'fixed source'
15+
self.run_mode = "fixed source"
1716
self.inactive = 0

openmc_dagmc_wrapper/Tally.py

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ class Tally(openmc.Tally):
1717
specified materials or volumes.
1818
"""
1919

20-
def __init__(
21-
self,
22-
tally_type,
23-
**kwargs
24-
):
20+
def __init__(self, tally_type, **kwargs):
2521

2622
self.tally_type = tally_type
2723
super().__init__(**kwargs)
@@ -61,9 +57,12 @@ def tally_type(self, value):
6157

6258
def set_score(self):
6359
flux_scores = [
64-
"neutron_fast_flux", "photon_fast_flux",
65-
"neutron_spectra", "photon_spectra",
66-
"neutron_effective_dose", "photon_effective_dose"
60+
"neutron_fast_flux",
61+
"photon_fast_flux",
62+
"neutron_spectra",
63+
"photon_spectra",
64+
"neutron_effective_dose",
65+
"photon_effective_dose",
6766
]
6867

6968
if self.tally_type == "TBR":
@@ -155,29 +154,25 @@ class CellTallies:
155154
h5m_filename
156155
"""
157156

158-
def __init__(
159-
self,
160-
tally_types,
161-
targets=[None],
162-
materials=None,
163-
h5m_filename=None):
157+
def __init__(self, tally_types, targets=[None], materials=None, h5m_filename=None):
164158
self.tallies = []
165159
self.tally_types = tally_types
166160
self.targets = targets
167161
self.materials = materials
168162
self.h5m_filename = h5m_filename
169163

170-
if self.targets == 'all_volumes':
164+
if self.targets == "all_volumes":
171165
all_targets = di.get_volumes_from_h5m(self.h5m_filename)
172-
elif self.targets == 'all_materials':
166+
elif self.targets == "all_materials":
173167
all_targets = di.get_materials_from_h5m(self.h5m_filename)
174168
else:
175169
all_targets = self.targets
176170

177171
for score in self.tally_types:
178172
for target in all_targets:
179-
self.tallies.append(CellTally(
180-
tally_type=score, target=target, materials=materials))
173+
self.tallies.append(
174+
CellTally(tally_type=score, target=target, materials=materials)
175+
)
181176

182177

183178
class TetMeshTally(Tally):
@@ -208,11 +203,9 @@ def create_unstructured_mesh(self):
208203
# format
209204
library = "moab"
210205
else:
211-
msg = ("only h5m or exo files are accepted as valid "
212-
"filename values")
206+
msg = "only h5m or exo files are accepted as valid " "filename values"
213207
raise ValueError(msg)
214-
self.umesh = openmc.UnstructuredMesh(
215-
self.filename, library=library)
208+
self.umesh = openmc.UnstructuredMesh(self.filename, library=library)
216209

217210

218211
class TetMeshTallies:
@@ -231,17 +224,12 @@ def __init__(self, tally_types, filenames):
231224
self.tally_types = tally_types
232225
for score in self.tally_types:
233226
for filename in filenames:
234-
self.tallies.append(
235-
TetMeshTally(tally_type=score, filename=filename))
227+
self.tallies.append(TetMeshTally(tally_type=score, filename=filename))
236228

237229

238230
class MeshTally3D(Tally):
239231
def __init__(
240-
self,
241-
tally_type,
242-
mesh_resolution=(100, 100, 100),
243-
bounding_box=None,
244-
**kwargs
232+
self, tally_type, mesh_resolution=(100, 100, 100), bounding_box=None, **kwargs
245233
):
246234
self.tally_type = tally_type
247235
self.mesh_resolution = mesh_resolution
@@ -253,8 +241,7 @@ def __init__(
253241
def add_mesh_filter(self, bounding_box):
254242

255243
if isinstance(bounding_box, str):
256-
self.bounding_box = find_bounding_box(
257-
h5m_filename=bounding_box)
244+
self.bounding_box = find_bounding_box(h5m_filename=bounding_box)
258245
else:
259246
self.bounding_box = bounding_box
260247

@@ -277,10 +264,7 @@ class MeshTallies3D:
277264
"""
278265

279266
def __init__(
280-
self,
281-
tally_types,
282-
meshes_resolution=(100, 100, 100),
283-
bounding_box=None
267+
self, tally_types, meshes_resolution=(100, 100, 100), bounding_box=None
284268
):
285269
self.tallies = []
286270
self.tally_types = tally_types
@@ -289,7 +273,8 @@ def __init__(
289273
MeshTally3D(
290274
tally_type=tally_type,
291275
mesh_resolution=meshes_resolution,
292-
bounding_box=bounding_box)
276+
bounding_box=bounding_box,
277+
)
293278
)
294279

295280

@@ -305,11 +290,7 @@ class MeshTally2D(Tally):
305290
"""
306291

307292
def __init__(
308-
self,
309-
tally_type,
310-
plane,
311-
mesh_resolution=(400, 400),
312-
bounding_box=None
293+
self, tally_type, plane, mesh_resolution=(400, 400), bounding_box=None
313294
):
314295
self.tally_type = tally_type
315296
self.plane = plane
@@ -403,8 +384,7 @@ def set_bounding_box(self, bounding_box):
403384

404385
if isinstance(bounding_box, str):
405386
self.bbox_from_h5 = True
406-
self.bounding_box = find_bounding_box(
407-
h5m_filename=bounding_box)
387+
self.bounding_box = find_bounding_box(h5m_filename=bounding_box)
408388
else:
409389
self.bbox_from_h5 = False
410390
self.bounding_box = bounding_box
@@ -434,9 +414,11 @@ def __init__(
434414
for plane in planes:
435415
self.tallies.append(
436416
MeshTally2D(
437-
tally_type=tally_type, plane=plane,
417+
tally_type=tally_type,
418+
plane=plane,
438419
mesh_resolution=meshes_resolution,
439-
bounding_box=bounding_box)
420+
bounding_box=bounding_box,
421+
)
440422
)
441423

442424

@@ -471,12 +453,12 @@ def compute_filters(tally_type):
471453
additional_filters = [photon_particle_filter, energy_filter]
472454
elif tally_type == "neutron_effective_dose":
473455
energy_function_filter_n = openmc.EnergyFunctionFilter(
474-
energy_bins_n, dose_coeffs_n)
475-
additional_filters = [
476-
neutron_particle_filter, energy_function_filter_n]
456+
energy_bins_n, dose_coeffs_n
457+
)
458+
additional_filters = [neutron_particle_filter, energy_function_filter_n]
477459
elif tally_type == "photon_effective_dose":
478460
energy_function_filter_p = openmc.EnergyFunctionFilter(
479-
energy_bins_p, dose_coeffs_p)
480-
additional_filters = [
481-
photon_particle_filter, energy_function_filter_p]
461+
energy_bins_p, dose_coeffs_p
462+
)
463+
additional_filters = [photon_particle_filter, energy_function_filter_p]
482464
return additional_filters

openmc_dagmc_wrapper/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
from .Geometry import Geometry
44
from .Materials import Materials
5-
from .Tally import CellTally, CellTallies, MeshTally2D, MeshTallies2D, \
6-
MeshTally3D, MeshTallies3D
5+
from .Tally import (
6+
CellTally,
7+
CellTallies,
8+
MeshTally2D,
9+
MeshTallies2D,
10+
MeshTally3D,
11+
MeshTallies3D,
12+
)
713
from .Settings import FusionSettings

0 commit comments

Comments
 (0)