Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions paramak/parametric_neutronics/neutronics_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

try:
import openmc
except BaseException:
except ImportError:
warnings.warn('OpenMC not found, NeutronicsModelFromReactor.simulate \
method not available', UserWarning)

try:
import neutronics_material_maker as nmm
except BaseException:
except ImportError:
warnings.warn("neutronics_material_maker not found, \
NeutronicsModelFromReactor.materials can't accept strings or \
neutronics_material_maker objects", UserWarning)
Expand Down Expand Up @@ -305,7 +305,8 @@ def create_neutronics_geometry(self, method=None):
self.geometry.export_neutronics_description()

if not Path("make_faceteted_neutronics_model.py").is_file():
raise ValueError("The make_faceteted_neutronics_model.py was \
raise FileNotFoundError(
"The make_faceteted_neutronics_model.py was \
not found in the directory")
os.system("trelis -batch -nographics make_faceteted_neutronics_model.py \"faceting_tolerance='" +
str(self.faceting_tolerance) + "'\" \"merge_tolerance='" + str(self.merge_tolerance) + "'\"")
Expand Down Expand Up @@ -541,7 +542,7 @@ def get_results(self):
results = defaultdict(dict)

# access the tallies
for key, tally in sp.tallies.items():
for tally in sp.tallies.values():

if tally.name == 'TBR':

Expand Down
4 changes: 1 addition & 3 deletions paramak/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,9 +593,7 @@ def create_solid(self):
if list(entry.keys())[0] == "straight":
solid = solid.polyline(list(entry.values())[0])
if list(entry.keys())[0] == "circle":
p0 = list(entry.values())[0][0]
p1 = list(entry.values())[0][1]
p2 = list(entry.values())[0][2]
p0, p1, p2 = list(entry.values())[0][:3]
solid = solid.moveTo(
p0[0], p0[1]).threePointArc(
p1, p2)
Expand Down
48 changes: 23 additions & 25 deletions tests/test_Reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,6 @@ def test_stp_filename_duplication():

self.assertRaises(ValueError, test_stp_filename_duplication)

def test_adding_shape_with_duplicate_stl_filename_to_reactor(self):
"""Adds shapes to a Reactor object to checks errors are raised
correctly"""

def test_stl_filename_duplication():
"""Checks ValueError is raised when shapes with the same stl
filenames are added to a reactor object"""

test_shape_1 = paramak.RotateStraightShape(
points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl"
)
test_shape_2 = paramak.RotateStraightShape(
points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl"
)
test_shape_1.rotation_angle = 90
my_reactor = paramak.Reactor([test_shape_1, test_shape_2])
my_reactor.export_stl()

sefl.assertRaises(ValueError, test_stl_filename_duplication)

def test_adding_shape_with_None_stp_filename_to_reactor(self):
"""adds shapes to a Reactor object to check errors are raised correctly"""

Expand All @@ -131,19 +111,37 @@ def test_stp_filename_None():
self.assertRaises(ValueError, test_stp_filename_None)

def test_adding_shape_with_duplicate_stl_filename_to_reactor(self):
"""Adds shapes to a Reactor object to checks errors are raised
correctly"""

def test_stl_filename_duplication():
"""Checks ValueError is raised when shapes with the same stl
filenames are added to a reactor object"""

test_shape_1 = paramak.RotateStraightShape(
points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl"
)
test_shape_2 = paramak.RotateSplineShape(
points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl"
)
test_shape_1.rotation_angle = 90
my_reactor = paramak.Reactor([test_shape_1, test_shape_2])
my_reactor.export_stl()

self.assertRaises(ValueError, test_stl_filename_duplication)

def test_adding_shape_with_the_same_default_stl_filename_to_reactor(self):
"""Adds shapes to a Reactor object to check errors are raised
correctly."""

def test_stl_filename_duplication_rotate_straight():
"""checks ValueError is raised when RotateStraightShapes with
duplicate stl filenames are added"""
duplicate stl filenames (defaults) are added"""

test_shape = paramak.RotateStraightShape(
points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl"
)
points=[(0, 0), (0, 20), (20, 20)])
test_shape2 = paramak.RotateStraightShape(
points=[(0, 0), (0, 20), (20, 20)], stl_filename="filename.stl"
)
points=[(0, 0), (0, 20), (20, 20)])
test_shape.rotation_angle = 360
test_shape.create_solid()
my_reactor = paramak.Reactor([test_shape, test_shape2])
Expand Down
6 changes: 3 additions & 3 deletions tests/test_parametric_neutronics/test_NeutronicModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def incorrect_faceting_tolerance():
)

self.assertRaises(
ValueError,
TypeError,
incorrect_faceting_tolerance
)

Expand Down Expand Up @@ -117,7 +117,7 @@ def incorrect_merge_tolerance():
)

self.assertRaises(
ValueError,
TypeError,
incorrect_merge_tolerance
)

Expand Down Expand Up @@ -172,7 +172,7 @@ def incorrect_materials():
)

self.assertRaises(
ValueError,
TypeError,
incorrect_materials
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_parametric_shapes/test_SweepStraightShape.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_relative_shape_volume(self):
self.test_shape.points = [(-20, 20), (20, 20), (20, -20), (-20, -20)]
assert self.test_shape.volume == pytest.approx(test_volume * 4)

def test_relative_shape_volume(self):
def test_relative_shape_volume_again(self):
"""Creates two SweepStraightShapes and checks that their relative volumes
are correct."""

Expand Down