From bf27a11276ea4bee0132ec8d9528b3253c654421 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 12:13:58 +0000 Subject: [PATCH 01/26] now using center point instead of z_pos and added edge filleting --- .../port_cutters_circular.py | 23 +++++++++--------- .../port_cutters_rectangular.py | 24 ++++++++++++------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/paramak/parametric_components/port_cutters_circular.py b/paramak/parametric_components/port_cutters_circular.py index b6aa508d0..3591250fb 100644 --- a/paramak/parametric_components/port_cutters_circular.py +++ b/paramak/parametric_components/port_cutters_circular.py @@ -7,23 +7,22 @@ class PortCutterCircular(ExtrudeCircleShape): other components (eg. blanket, vessel,..) in order to create ports. Args: - z_pos (float): Z position (cm) of the port - height (float): height (cm) of the port - width (float): width (cm) of the port - distance (float): extruded distance (cm) of the cutter - stp_filename (str, optional): defaults to "PortCutterCircular.stp". - stl_filename (str, optional): defaults to "PortCutterCircular.stl". - name (str, optional): defaults to "circular_port_cutter". - material_tag (str, optional): defaults to "circular_port_cutter_mat". - extrusion_start_offset (float, optional): the distance between 0 and + center_point: center point of the port cutter. Defaults to (0, 0). + radius: radius (cm) of port cutter. + distance: extruded distance (cm) of the port cutter. + stp_filename: defaults to "PortCutterCircular.stp". + stl_filename: defaults to "PortCutterCircular.stl". + name: defaults to "circular_port_cutter". + material_tag: defaults to "circular_port_cutter_mat". + extrusion_start_offset: the distance between 0 and the start of the extrusion. Defaults to 1.. """ def __init__( self, - z_pos, radius, distance, + center_point=(0, 0), workplane="ZY", rotation_axis="Z", extrusion_start_offset=1., @@ -47,8 +46,8 @@ def __init__( **kwargs ) - self.z_pos = z_pos + self.center_point = center_point self.radius = radius def find_points(self): - self.points = [(0, self.z_pos)] + self.points = [self.center_point] diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 4ac5fc9b4..5b3d867bb 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -7,10 +7,10 @@ class PortCutterRectangular(ExtrudeStraightShape): other components (eg. blanket, vessel,..) in order to create ports. Args: - z_pos (float): Z position (cm) of the port - height (float): height (cm) of the port - width (float): width (cm) of the port - distance (float): extruded distance (cm) of the cutter + center_point: Center point of the port cutter. Defaults to (0, 0). + height: height (cm) of the port cutter. + width: width (cm) of the port cutter. + distance: extruded distance (cm) of the port cutter. fillet_radius (float, optional): If not None, radius (cm) of fillets added to edges orthogonal to the Z direction. Defaults to None. stp_filename (str, optional): defaults to "PortCutterRectangular.stp". @@ -24,10 +24,10 @@ class PortCutterRectangular(ExtrudeStraightShape): def __init__( self, - z_pos, height, width, distance, + center_point=(0, 0), workplane="ZY", rotation_axis="Z", extrusion_start_offset=1., @@ -52,7 +52,7 @@ def __init__( **kwargs ) - self.z_pos = z_pos + self.center_point = center_point self.height = height self.width = width self.fillet_radius = fillet_radius @@ -65,9 +65,17 @@ def find_points(self): (self.width / 2, self.height / 2), (-self.width / 2, self.height / 2), ] - points = [(e[0], e[1] + self.z_pos) for e in points] + points = [(e[0] + self.center_point[0], e[1] + + self.center_point[1]) for e in points] self.points = points def add_fillet(self): + if "X" not in self.workplane: + filleting_edge = "|X" + if "Y" not in self.workplane: + filleting_edge = "|Y" + if "Z" not in self.workplane: + filleting_edge = "|Z" + if self.fillet_radius is not None and self.fillet_radius != 0: - self.solid = self.solid.edges('#Z').fillet(self.fillet_radius) + self.solid = self.solid.edges(filleting_edge).fillet(self.fillet_radius) From 5ec94e584e58a9c6be936eb3179a2d56b9dbbd37 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 12:19:25 +0000 Subject: [PATCH 02/26] added type hinting --- .../port_cutters_circular.py | 22 +++++++++------- .../port_cutters_rectangular.py | 26 ++++++++++--------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/paramak/parametric_components/port_cutters_circular.py b/paramak/parametric_components/port_cutters_circular.py index 3591250fb..bf3290590 100644 --- a/paramak/parametric_components/port_cutters_circular.py +++ b/paramak/parametric_components/port_cutters_circular.py @@ -1,6 +1,8 @@ from paramak import ExtrudeCircleShape +from typing import Optional + class PortCutterCircular(ExtrudeCircleShape): """Creates an extruded shape with a circular section that is used to cut @@ -20,16 +22,16 @@ class PortCutterCircular(ExtrudeCircleShape): def __init__( self, - radius, - distance, - center_point=(0, 0), - workplane="ZY", - rotation_axis="Z", - extrusion_start_offset=1., - stp_filename="PortCutterCircular.stp", - stl_filename="PortCutterCircular.stl", - name="circular_port_cutter", - material_tag="circular_port_cutter_mat", + radius: float, + distance: float, + center_point: Optional[tuple] = (0, 0), + workplane: Optional[str] = "ZY", + rotation_axis: Optional[str] = "Z", + extrusion_start_offset: Optional[float] = 1., + stp_filename: Optional[str] = "PortCutterCircular.stp", + stl_filename: Optional[str] = "PortCutterCircular.stl", + name: Optional[str] = "circular_port_cutter", + material_tag: Optional[str] = "circular_port_cutter_mat", **kwargs ): super().__init__( diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 5b3d867bb..6cfe28307 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -1,6 +1,8 @@ from paramak import ExtrudeStraightShape +from typing import Optional + class PortCutterRectangular(ExtrudeStraightShape): """Creates an extruded shape with a rectangular section that is used to cut @@ -24,18 +26,18 @@ class PortCutterRectangular(ExtrudeStraightShape): def __init__( self, - height, - width, - distance, - center_point=(0, 0), - workplane="ZY", - rotation_axis="Z", - extrusion_start_offset=1., - fillet_radius=None, - stp_filename="PortCutterRectangular.stp", - stl_filename="PortCutterRectangular.stl", - name="rectangular_port_cutter", - material_tag="rectangular_port_cutter_mat", + height: float, + width: float, + distance: float, + center_point: Optional[tuple] = (0, 0), + workplane: Optional[str] = "ZY", + rotation_axis: Optional[str] = "Z", + extrusion_start_offset: Optional[float] = 1., + fillet_radius: Optional[float] = None, + stp_filename: Optional[str] = "PortCutterRectangular.stp", + stl_filename: Optional[str] = "PortCutterRectangular.stl", + name: Optional[str] = "rectangular_port_cutter", + material_tag: Optional[str] = "rectangular_port_cutter_mat", **kwargs ): From 854fb54a2e858a40d0a77ad31620cb65c88fb8ee Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 12:22:33 +0000 Subject: [PATCH 03/26] added port cutter tests --- .../test_PortCutterCircular.py | 61 +++++++++++++++---- .../test_PortCutterRectangular.py | 58 ++++++++++++++---- 2 files changed, 96 insertions(+), 23 deletions(-) diff --git a/tests/test_parametric_components/test_PortCutterCircular.py b/tests/test_parametric_components/test_PortCutterCircular.py index a6d5e7197..09b8eac04 100644 --- a/tests/test_parametric_components/test_PortCutterCircular.py +++ b/tests/test_parametric_components/test_PortCutterCircular.py @@ -1,19 +1,56 @@ - +import math import unittest import paramak +import pytest + + +class test_component(unittest.TestCase): + + def setUp(self): + self.test_shape = paramak.PortCutterCircular( + distance=300, radius=20 + ) + + def test_default_parameters(self): + """Checks that the default parameters of a PortCutterCircular are correct.""" + + assert self.test_shape.center_point == (0, 0) + assert self.test_shape.workplane == "ZY" + assert self.test_shape.rotation_axis == "Z" + assert self.test_shape.extrusion_start_offset == 1 + assert self.test_shape.stp_filename == "PortCutterCircular.stp" + assert self.test_shape.stl_filename == "PortCutterCircular.stl" + assert self.test_shape.name == "circular_port_cutter" + assert self.test_shape.material_tag == "circular_port_cutter_mat" + + def test_creation(self): + """Creates a circular port cutter using the PortCutterCircular parametric + component and checks that a cadquery solid is created.""" + + assert self.test_shape.solid is not None + assert self.test_shape.volume > 1000 + + def test_relative_volume(self): + """Creates PortCutterCircular shapes and checks that their relative volumes + are correct.""" + + test_volume = self.test_shape.volume + + self.test_shape.extrusion_start_offset = 20 + self.test_shape.azimuth_placement_angle = [0, 90, 180, 270] + + assert self.test_shape.volume == pytest.approx(test_volume * 4) + + def test_absolute_volume(self): + """Creates a PortCutterCircular shape and checks that its volume is correct.""" -# class test_component(unittest.TestCase): -# TODO: fix issue 548 -# def test_creation(self): -# """Checks a PortCutterCircular creation.""" + assert self.test_shape.volume == pytest.approx(math.pi * (20**2) * 300) -# test_component = paramak.PortCutterCircular( -# distance=3, -# z_pos=0.25, -# radius=0.1, -# azimuth_placement_angle=[0, 45, 90, 180] -# ) + self.test_shape.extrusion_start_offset = 20 + self.test_shape.azimuth_placement_angle = [0, 90, 180, 270] + self.test_shape.radius = 10 -# assert test_component.solid is not None + assert self.test_shape.volume == pytest.approx( + math.pi * (10**2) * 300 * 4) \ No newline at end of file diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index 0f927ccc3..f1274d21e 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -3,19 +3,55 @@ import paramak +import pytest + class TestPortCutterRectangular(unittest.TestCase): - def test_creation(self): - """Checks a PortCutterRectangular creation.""" - - test_component = paramak.PortCutterRectangular( - distance=3, - z_pos=0, - height=0.2, - width=0.4, - fillet_radius=0.02, - azimuth_placement_angle=[0, 45, 90, 180] + def setUp(self): + self.test_shape = paramak.PortCutterRectangular( + width=40, height=40, distance=300 ) - assert test_component.solid is not None + def test_default_parameters(self): + """Checks that the default parameters of a PortCutterRectangular are correct.""" + + assert self.test_shape.center_point == (0, 0) + assert self.test_shape.workplane == "ZY" + assert self.test_shape.rotation_axis == "Z" + assert self.test_shape.extrusion_start_offset == 1 + assert self.test_shape.fillet_radius is None + assert self.test_shape.stp_filename == "PortCutterRectangular.stp" + assert self.test_shape.stl_filename == "PortCutterRectangular.stl" + assert self.test_shape.name == "rectangular_port_cutter" + assert self.test_shape.material_tag == "rectangular_port_cutter_mat" + + def test_creation(self): + """Creates a rectangular port cutter using the PortCutterRectangular parametric + component and checks that a cadquery solid is created.""" + + assert self.test_shape.solid is not None + assert self.test_shape.volume > 1000 + + def test_relative_volume(self): + """Creates PortCutterRectangular shapes and checks that their relative volumes + are correct.""" + + test_volume = self.test_shape.volume + + self.test_shape.extrusion_start_offset = 20 + self.test_shape.azimuth_placement_angle = [0, 90, 180, 270] + + assert self.test_shape.volume == pytest.approx(test_volume * 4) + + def test_absolute_volume(self): + """Creates a PortCutterRectangular shape and checks that its volume is correct.""" + + assert self.test_shape.volume == pytest.approx(40 * 40 * 300) + + self.test_shape.extrusion_start_offset = 20 + self.test_shape.azimuth_placement_angle = [0, 90, 180, 270] + self.test_shape.width = 20 + self.test_shape.height = 20 + + assert self.test_shape.volume == pytest.approx(20 * 20 * 300 * 4) \ No newline at end of file From 31b726c241231ee91a945281c95e074535f0cb01 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 12:24:21 +0000 Subject: [PATCH 04/26] moved point at which filleting is performed --- paramak/parametric_components/port_cutters_rectangular.py | 2 +- paramak/parametric_shapes/extruded_mixed_shape.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 6cfe28307..08c7cfcf6 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -58,7 +58,7 @@ def __init__( self.height = height self.width = width self.fillet_radius = fillet_radius - self.add_fillet() + # self.add_fillet() def find_points(self): points = [ diff --git a/paramak/parametric_shapes/extruded_mixed_shape.py b/paramak/parametric_shapes/extruded_mixed_shape.py index 0e19acc2c..22ae06f15 100644 --- a/paramak/parametric_shapes/extruded_mixed_shape.py +++ b/paramak/parametric_shapes/extruded_mixed_shape.py @@ -88,6 +88,11 @@ def create_solid(self): solid = wire.extrude( distance=extrusion_distance, both=self.extrude_both) + + # filleting rectangular port cutter edges + # must be done before azimuthal placement + if hasattr(self, "add_fillet"): + solid = self.add_fillet(solid) solid = self.rotate_solid(solid) cutting_wedge = calculate_wedge_cut(self) From 68802292fda437e36ed6f5bcfe02b3986ec53ca2 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Thu, 4 Feb 2021 12:27:52 +0000 Subject: [PATCH 05/26] Automated autopep8 fixes --- paramak/parametric_components/port_cutters_rectangular.py | 3 ++- paramak/parametric_shapes/extruded_mixed_shape.py | 2 +- tests/test_parametric_components/test_PortCutterCircular.py | 2 +- tests/test_parametric_components/test_PortCutterRectangular.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 08c7cfcf6..2003862d3 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -80,4 +80,5 @@ def add_fillet(self): filleting_edge = "|Z" if self.fillet_radius is not None and self.fillet_radius != 0: - self.solid = self.solid.edges(filleting_edge).fillet(self.fillet_radius) + self.solid = self.solid.edges( + filleting_edge).fillet(self.fillet_radius) diff --git a/paramak/parametric_shapes/extruded_mixed_shape.py b/paramak/parametric_shapes/extruded_mixed_shape.py index 22ae06f15..027d5d362 100644 --- a/paramak/parametric_shapes/extruded_mixed_shape.py +++ b/paramak/parametric_shapes/extruded_mixed_shape.py @@ -88,7 +88,7 @@ def create_solid(self): solid = wire.extrude( distance=extrusion_distance, both=self.extrude_both) - + # filleting rectangular port cutter edges # must be done before azimuthal placement if hasattr(self, "add_fillet"): diff --git a/tests/test_parametric_components/test_PortCutterCircular.py b/tests/test_parametric_components/test_PortCutterCircular.py index 09b8eac04..a4d25af4a 100644 --- a/tests/test_parametric_components/test_PortCutterCircular.py +++ b/tests/test_parametric_components/test_PortCutterCircular.py @@ -53,4 +53,4 @@ def test_absolute_volume(self): self.test_shape.radius = 10 assert self.test_shape.volume == pytest.approx( - math.pi * (10**2) * 300 * 4) \ No newline at end of file + math.pi * (10**2) * 300 * 4) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index f1274d21e..9b21016af 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -54,4 +54,4 @@ def test_absolute_volume(self): self.test_shape.width = 20 self.test_shape.height = 20 - assert self.test_shape.volume == pytest.approx(20 * 20 * 300 * 4) \ No newline at end of file + assert self.test_shape.volume == pytest.approx(20 * 20 * 300 * 4) From 7e3f4ee56dab31f0f8b8603179ab9c5159a4bb0a Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 12:38:47 +0000 Subject: [PATCH 06/26] using solid instead of self.solid --- paramak/parametric_components/port_cutters_rectangular.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 08c7cfcf6..1f6794aa7 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -71,7 +71,7 @@ def find_points(self): self.center_point[1]) for e in points] self.points = points - def add_fillet(self): + def add_fillet(self, solid): if "X" not in self.workplane: filleting_edge = "|X" if "Y" not in self.workplane: @@ -80,4 +80,5 @@ def add_fillet(self): filleting_edge = "|Z" if self.fillet_radius is not None and self.fillet_radius != 0: - self.solid = self.solid.edges(filleting_edge).fillet(self.fillet_radius) + solid = solid.edges(filleting_edge).fillet(self.fillet_radius) + return solid From 52f6d32011892c02fd6c0f16a66ec301f900fe5c Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 12:40:26 +0000 Subject: [PATCH 07/26] using solid instead of self.solid --- paramak/parametric_components/port_cutters_rectangular.py | 2 ++ paramak/parametric_shapes/extruded_mixed_shape.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 1f6794aa7..303130803 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -81,4 +81,6 @@ def add_fillet(self, solid): if self.fillet_radius is not None and self.fillet_radius != 0: solid = solid.edges(filleting_edge).fillet(self.fillet_radius) + return solid + diff --git a/paramak/parametric_shapes/extruded_mixed_shape.py b/paramak/parametric_shapes/extruded_mixed_shape.py index 22ae06f15..027d5d362 100644 --- a/paramak/parametric_shapes/extruded_mixed_shape.py +++ b/paramak/parametric_shapes/extruded_mixed_shape.py @@ -88,7 +88,7 @@ def create_solid(self): solid = wire.extrude( distance=extrusion_distance, both=self.extrude_both) - + # filleting rectangular port cutter edges # must be done before azimuthal placement if hasattr(self, "add_fillet"): From efcb4119f184b102eb8d06e4ea02003ccd033101 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Thu, 4 Feb 2021 12:42:43 +0000 Subject: [PATCH 08/26] Automated autopep8 fixes --- paramak/parametric_components/port_cutters_rectangular.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 303130803..55ce4a741 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -81,6 +81,5 @@ def add_fillet(self, solid): if self.fillet_radius is not None and self.fillet_radius != 0: solid = solid.edges(filleting_edge).fillet(self.fillet_radius) - - return solid + return solid From dd4f6e7c7bca30eb9c5784d32ede19e28b857bbf Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 14:24:40 +0000 Subject: [PATCH 09/26] updated port arguments --- .../make_vacuum_vessel_with_ports.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/example_parametric_components/make_vacuum_vessel_with_ports.py b/examples/example_parametric_components/make_vacuum_vessel_with_ports.py index 9085eb41a..70ffdbca4 100644 --- a/examples/example_parametric_components/make_vacuum_vessel_with_ports.py +++ b/examples/example_parametric_components/make_vacuum_vessel_with_ports.py @@ -25,7 +25,7 @@ def main(): # makes the middle row of ports circular_ports = paramak.PortCutterCircular( distance=5, - z_pos=0, + center_point=(0, 0), radius=0.2, azimuth_placement_angle=angles_for_ports ) @@ -33,7 +33,7 @@ def main(): # makes the lower row of ports rectangular_ports = paramak.PortCutterRectangular( distance=5, - z_pos=-1, + center_point=(0, 0), height=0.3, width=0.4, fillet_radius=0.08, From db55b43c224dd116b2032b6706a9d5e88274023b Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Thu, 4 Feb 2021 14:43:00 +0000 Subject: [PATCH 10/26] updated port center points --- .../make_all_parametric_components.py | 4 ++-- .../make_vacuum_vessel_with_ports.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/example_parametric_components/make_all_parametric_components.py b/examples/example_parametric_components/make_all_parametric_components.py index bcee900e0..4160bc5eb 100644 --- a/examples/example_parametric_components/make_all_parametric_components.py +++ b/examples/example_parametric_components/make_all_parametric_components.py @@ -334,7 +334,7 @@ def main(): component = paramak.PortCutterRectangular( distance=3, - z_pos=0, + center_point=(0, 0), height=0.2, width=0.4, fillet_radius=0.02, @@ -344,7 +344,7 @@ def main(): component = paramak.PortCutterCircular( distance=3, - z_pos=0.25, + center_point=(0.25, 0), radius=0.1, # azimuth_placement_angle=[0, 45, 90, 180], # TODO: fix issue #548 azimuth_placement_angle=[0, 45, 90], diff --git a/examples/example_parametric_components/make_vacuum_vessel_with_ports.py b/examples/example_parametric_components/make_vacuum_vessel_with_ports.py index 70ffdbca4..16b3d2b61 100644 --- a/examples/example_parametric_components/make_vacuum_vessel_with_ports.py +++ b/examples/example_parametric_components/make_vacuum_vessel_with_ports.py @@ -33,7 +33,7 @@ def main(): # makes the lower row of ports rectangular_ports = paramak.PortCutterRectangular( distance=5, - center_point=(0, 0), + center_point=(-1, 0), height=0.3, width=0.4, fillet_radius=0.08, From 4a79d93b92bc428b58b1e12a6f191d992762c870 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Fri, 5 Feb 2021 09:00:16 +0000 Subject: [PATCH 11/26] changed to pascal style --- tests/test_parametric_components/test_PortCutterCircular.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_parametric_components/test_PortCutterCircular.py b/tests/test_parametric_components/test_PortCutterCircular.py index a4d25af4a..c626c5432 100644 --- a/tests/test_parametric_components/test_PortCutterCircular.py +++ b/tests/test_parametric_components/test_PortCutterCircular.py @@ -6,7 +6,7 @@ import pytest -class test_component(unittest.TestCase): +class TestComponent(unittest.TestCase): def setUp(self): self.test_shape = paramak.PortCutterCircular( From edd5df263f434565107eb38c65fa587aade23279 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Fri, 5 Feb 2021 09:00:55 +0000 Subject: [PATCH 12/26] updated import and docstring orders --- .../parametric_components/port_cutters_circular.py | 12 ++++++------ .../port_cutters_rectangular.py | 13 ++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/paramak/parametric_components/port_cutters_circular.py b/paramak/parametric_components/port_cutters_circular.py index bf3290590..57b25a408 100644 --- a/paramak/parametric_components/port_cutters_circular.py +++ b/paramak/parametric_components/port_cutters_circular.py @@ -1,23 +1,23 @@ -from paramak import ExtrudeCircleShape - from typing import Optional +from paramak import ExtrudeCircleShape + class PortCutterCircular(ExtrudeCircleShape): """Creates an extruded shape with a circular section that is used to cut other components (eg. blanket, vessel,..) in order to create ports. Args: - center_point: center point of the port cutter. Defaults to (0, 0). radius: radius (cm) of port cutter. distance: extruded distance (cm) of the port cutter. + center_point: center point of the port cutter. Defaults to (0, 0). + extrusion_start_offset: the distance between 0 and + the start of the extrusion. Defaults to 1.. stp_filename: defaults to "PortCutterCircular.stp". stl_filename: defaults to "PortCutterCircular.stl". name: defaults to "circular_port_cutter". material_tag: defaults to "circular_port_cutter_mat". - extrusion_start_offset: the distance between 0 and - the start of the extrusion. Defaults to 1.. """ def __init__( @@ -48,8 +48,8 @@ def __init__( **kwargs ) - self.center_point = center_point self.radius = radius + self.center_point = center_point def find_points(self): self.points = [self.center_point] diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 55ce4a741..880e7f12d 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -1,18 +1,20 @@ -from paramak import ExtrudeStraightShape - from typing import Optional +from paramak import ExtrudeStraightShape + class PortCutterRectangular(ExtrudeStraightShape): """Creates an extruded shape with a rectangular section that is used to cut other components (eg. blanket, vessel,..) in order to create ports. Args: - center_point: Center point of the port cutter. Defaults to (0, 0). height: height (cm) of the port cutter. width: width (cm) of the port cutter. distance: extruded distance (cm) of the port cutter. + center_point: Center point of the port cutter. Defaults to (0, 0). + extrusion_start_offset (float, optional): the distance between 0 and + the start of the extrusion. Defaults to 1.. fillet_radius (float, optional): If not None, radius (cm) of fillets added to edges orthogonal to the Z direction. Defaults to None. stp_filename (str, optional): defaults to "PortCutterRectangular.stp". @@ -20,8 +22,6 @@ class PortCutterRectangular(ExtrudeStraightShape): name (str, optional): defaults to "rectangular_port_cutter". material_tag (str, optional): defaults to "rectangular_port_cutter_mat". - extrusion_start_offset (float, optional): the distance between 0 and - the start of the extrusion. Defaults to 1.. """ def __init__( @@ -54,11 +54,10 @@ def __init__( **kwargs ) - self.center_point = center_point self.height = height self.width = width + self.center_point = center_point self.fillet_radius = fillet_radius - # self.add_fillet() def find_points(self): points = [ From c0e804f208c78b0d536f426c92fab767eca95a44 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Fri, 5 Feb 2021 09:44:08 +0000 Subject: [PATCH 13/26] added missing docstrings --- paramak/parametric_components/port_cutters_circular.py | 8 ++++++-- paramak/parametric_components/port_cutters_rectangular.py | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/paramak/parametric_components/port_cutters_circular.py b/paramak/parametric_components/port_cutters_circular.py index 57b25a408..9924e1584 100644 --- a/paramak/parametric_components/port_cutters_circular.py +++ b/paramak/parametric_components/port_cutters_circular.py @@ -12,8 +12,12 @@ class PortCutterCircular(ExtrudeCircleShape): radius: radius (cm) of port cutter. distance: extruded distance (cm) of the port cutter. center_point: center point of the port cutter. Defaults to (0, 0). - extrusion_start_offset: the distance between 0 and - the start of the extrusion. Defaults to 1.. + workplane: workplane in which the port cutters are created. Defaults + to "ZY". + rotation_axis: axis around which the port cutters are rotated and + placed. Defaults to "Z". + extrusion_start_offset: the distance between 0 and the start of the + extrusion. Defaults to 1.. stp_filename: defaults to "PortCutterCircular.stp". stl_filename: defaults to "PortCutterCircular.stl". name: defaults to "circular_port_cutter". diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 880e7f12d..d36cf047f 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -13,6 +13,10 @@ class PortCutterRectangular(ExtrudeStraightShape): width: width (cm) of the port cutter. distance: extruded distance (cm) of the port cutter. center_point: Center point of the port cutter. Defaults to (0, 0). + workplane: workplane in which the port cutters are created. Defaults + to "ZY". + rotation_axis: axis around which the port cutters are rotated and + placed. Defaults to "Z". extrusion_start_offset (float, optional): the distance between 0 and the start of the extrusion. Defaults to 1.. fillet_radius (float, optional): If not None, radius (cm) of fillets @@ -20,7 +24,7 @@ class PortCutterRectangular(ExtrudeStraightShape): stp_filename (str, optional): defaults to "PortCutterRectangular.stp". stl_filename (str, optional): defaults to "PortCutterRectangular.stl". name (str, optional): defaults to "rectangular_port_cutter". - material_tag (str, optional): defaults to + material_tag (str, optional): defaults to "rectangular_port_cutter_mat". """ From 057a4176f6cdc14b15e6096cf34fbfa5803b017d Mon Sep 17 00:00:00 2001 From: autopep8 Date: Fri, 5 Feb 2021 09:45:13 +0000 Subject: [PATCH 14/26] Automated autopep8 fixes --- paramak/parametric_components/port_cutters_circular.py | 2 +- paramak/parametric_components/port_cutters_rectangular.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paramak/parametric_components/port_cutters_circular.py b/paramak/parametric_components/port_cutters_circular.py index 9924e1584..38a672127 100644 --- a/paramak/parametric_components/port_cutters_circular.py +++ b/paramak/parametric_components/port_cutters_circular.py @@ -16,7 +16,7 @@ class PortCutterCircular(ExtrudeCircleShape): to "ZY". rotation_axis: axis around which the port cutters are rotated and placed. Defaults to "Z". - extrusion_start_offset: the distance between 0 and the start of the + extrusion_start_offset: the distance between 0 and the start of the extrusion. Defaults to 1.. stp_filename: defaults to "PortCutterCircular.stp". stl_filename: defaults to "PortCutterCircular.stl". diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index d36cf047f..137896219 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -24,7 +24,7 @@ class PortCutterRectangular(ExtrudeStraightShape): stp_filename (str, optional): defaults to "PortCutterRectangular.stp". stl_filename (str, optional): defaults to "PortCutterRectangular.stl". name (str, optional): defaults to "rectangular_port_cutter". - material_tag (str, optional): defaults to + material_tag (str, optional): defaults to "rectangular_port_cutter_mat". """ From faf577c6aae23420e111bf4b4ea3c18a5fc98d2e Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Fri, 5 Feb 2021 10:11:37 +0000 Subject: [PATCH 15/26] now accounting for workplane correctly --- .../port_cutters_rectangular.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index d36cf047f..1368aa4f1 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -64,14 +64,22 @@ def __init__( self.fillet_radius = fillet_radius def find_points(self): + if self.workplane[0] < self.workplane[1]: + parameter_1 = self.width + parameter_2 = self.height + else: + parameter_1 = self.height + parameter_2 = self.width + points = [ - (-self.width / 2, -self.height / 2), - (self.width / 2, -self.height / 2), - (self.width / 2, self.height / 2), - (-self.width / 2, self.height / 2), + (-parameter_1 / 2, parameter_2 / 2), + (parameter_1 / 2, parameter_2 / 2), + (parameter_1 / 2, -parameter_2 / 2), + (-parameter_1 / 2, -parameter_2 / 2), ] points = [(e[0] + self.center_point[0], e[1] + - self.center_point[1]) for e in points] + self.center_point[1]) for e in points] + self.points = points def add_fillet(self, solid): From 3efe6e7db4ce9df7c6678c86e01a6de2a7b8b557 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Fri, 5 Feb 2021 10:12:54 +0000 Subject: [PATCH 16/26] Automated autopep8 fixes --- paramak/parametric_components/port_cutters_rectangular.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 744eca3e2..73b366417 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -78,8 +78,8 @@ def find_points(self): (-parameter_1 / 2, -parameter_2 / 2), ] points = [(e[0] + self.center_point[0], e[1] + - self.center_point[1]) for e in points] - + self.center_point[1]) for e in points] + self.points = points def add_fillet(self, solid): From 79df4eee9fac38d6e80af0fc4ff4fffcc747442e Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Fri, 5 Feb 2021 10:15:20 +0000 Subject: [PATCH 17/26] updated test class name --- tests/test_parametric_components/test_PortCutterCircular.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_parametric_components/test_PortCutterCircular.py b/tests/test_parametric_components/test_PortCutterCircular.py index c626c5432..49870c4e9 100644 --- a/tests/test_parametric_components/test_PortCutterCircular.py +++ b/tests/test_parametric_components/test_PortCutterCircular.py @@ -6,7 +6,7 @@ import pytest -class TestComponent(unittest.TestCase): +class TestPortCutterCircular(unittest.TestCase): def setUp(self): self.test_shape = paramak.PortCutterCircular( From 071f9dd981936e0ebe9dcea062b70406e98ba036 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Fri, 5 Feb 2021 10:37:04 +0000 Subject: [PATCH 18/26] now using center_point instead of z_pos --- tests/test_parametric_components/test_VacuumVessel.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_parametric_components/test_VacuumVessel.py b/tests/test_parametric_components/test_VacuumVessel.py index 7026be32d..048390221 100644 --- a/tests/test_parametric_components/test_VacuumVessel.py +++ b/tests/test_parametric_components/test_VacuumVessel.py @@ -22,14 +22,14 @@ def test_ports(self): caquery solid is created.""" cutter1 = paramak.PortCutterRectangular( - distance=3, z_pos=0, height=0.2, width=0.4, fillet_radius=0.01) + distance=3, center_point=(0, 0), height=0.2, width=0.4, fillet_radius=0.01) cutter2 = paramak.PortCutterRectangular( - distance=3, z_pos=0.5, height=0.2, width=0.4, fillet_radius=0.00) + distance=3, center_point=(0.5, 0), height=0.2, width=0.4, fillet_radius=0.00) cutter3 = paramak.PortCutterRectangular( - distance=3, z_pos=-0.5, height=0.2, width=0.4, + distance=3, center_point=(-0.5, 0), height=0.2, width=0.4, physical_groups=None) cutter4 = paramak.PortCutterCircular( - distance=3, z_pos=0.25, radius=0.1, azimuth_placement_angle=45, + distance=3, center_point=(0.25, 0), radius=0.1, azimuth_placement_angle=45, physical_groups=None) cutter5 = paramak.PortCutterRotated( (0, 0), azimuth_placement_angle=-90, rotation_angle=10, From aed1daf048e9b8b32f89d598c163d906919c2816 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Fri, 5 Feb 2021 10:38:06 +0000 Subject: [PATCH 19/26] Automated autopep8 fixes --- .../test_parametric_components/test_VacuumVessel.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_parametric_components/test_VacuumVessel.py b/tests/test_parametric_components/test_VacuumVessel.py index 048390221..3499c4d47 100644 --- a/tests/test_parametric_components/test_VacuumVessel.py +++ b/tests/test_parametric_components/test_VacuumVessel.py @@ -22,14 +22,21 @@ def test_ports(self): caquery solid is created.""" cutter1 = paramak.PortCutterRectangular( - distance=3, center_point=(0, 0), height=0.2, width=0.4, fillet_radius=0.01) + distance=3, center_point=( + 0, 0), height=0.2, width=0.4, fillet_radius=0.01) cutter2 = paramak.PortCutterRectangular( - distance=3, center_point=(0.5, 0), height=0.2, width=0.4, fillet_radius=0.00) + distance=3, center_point=( + 0.5, 0), height=0.2, width=0.4, fillet_radius=0.00) cutter3 = paramak.PortCutterRectangular( distance=3, center_point=(-0.5, 0), height=0.2, width=0.4, physical_groups=None) cutter4 = paramak.PortCutterCircular( - distance=3, center_point=(0.25, 0), radius=0.1, azimuth_placement_angle=45, + distance=3, + center_point=( + 0.25, + 0), + radius=0.1, + azimuth_placement_angle=45, physical_groups=None) cutter5 = paramak.PortCutterRotated( (0, 0), azimuth_placement_angle=-90, rotation_angle=10, From 862803464159938c9447a2a19478ec31e11da5fc Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 15 Feb 2021 12:20:06 +0000 Subject: [PATCH 20/26] added workplane geometry test --- .../test_PortCutterRectangular.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index 9b21016af..d42b8b2c4 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -10,7 +10,7 @@ class TestPortCutterRectangular(unittest.TestCase): def setUp(self): self.test_shape = paramak.PortCutterRectangular( - width=40, height=40, distance=300 + width=20, height=40, distance=300 ) def test_default_parameters(self): @@ -47,7 +47,7 @@ def test_relative_volume(self): def test_absolute_volume(self): """Creates a PortCutterRectangular shape and checks that its volume is correct.""" - assert self.test_shape.volume == pytest.approx(40 * 40 * 300) + assert self.test_shape.volume == pytest.approx(20 * 40 * 300) self.test_shape.extrusion_start_offset = 20 self.test_shape.azimuth_placement_angle = [0, 90, 180, 270] @@ -55,3 +55,20 @@ def test_absolute_volume(self): self.test_shape.height = 20 assert self.test_shape.volume == pytest.approx(20 * 20 * 300 * 4) + + def test_workplane(self): + """Creates PortCutterRectangular shapes in different workplanes and checks that + the geometries are correct.""" + + cutting_shape = paramak.RotateStraightShape( + points = [(0, 0), (0, 50), (500, 50), (500, 0)], + workplane = "YZ", + ) + self.test_shape.cut = cutting_shape + + assert self.test_shape.volume == pytest.approx(20 * 40 * 300 * 0.5) + + self.test_shape.workplane = "XZ" + cutting_shape.workplane = "YZ" + + assert self.test_shape.volume == pytest.approx(20 * 40 * 300) From 6c80984056ed08c94a1cceee4071490761cf0d68 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 15 Feb 2021 12:21:07 +0000 Subject: [PATCH 21/26] Automated autopep8 fixes --- .../test_parametric_components/test_PortCutterRectangular.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index d42b8b2c4..9dfb4ca84 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -61,8 +61,8 @@ def test_workplane(self): the geometries are correct.""" cutting_shape = paramak.RotateStraightShape( - points = [(0, 0), (0, 50), (500, 50), (500, 0)], - workplane = "YZ", + points=[(0, 0), (0, 50), (500, 50), (500, 0)], + workplane="YZ", ) self.test_shape.cut = cutting_shape From bd95376184016b8a3aac9d08ea24e5f931184450 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 15 Feb 2021 12:27:06 +0000 Subject: [PATCH 22/26] fixed assertion --- tests/test_parametric_components/test_PortCutterRectangular.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index d42b8b2c4..4c3766ec1 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -71,4 +71,4 @@ def test_workplane(self): self.test_shape.workplane = "XZ" cutting_shape.workplane = "YZ" - assert self.test_shape.volume == pytest.approx(20 * 40 * 300) + assert self.test_shape.volume == pytest.approx(20 * 40 * 300 * 0.5) From 0d2497e8975fdc7695d2a8018a7cf0de70ac2f61 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 15 Feb 2021 12:29:54 +0000 Subject: [PATCH 23/26] added filleting test --- .../test_PortCutterRectangular.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index ef15618d6..516781f13 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -72,3 +72,12 @@ def test_workplane(self): cutting_shape.workplane = "YZ" assert self.test_shape.volume == pytest.approx(20 * 40 * 300 * 0.5) + + def test_filleting(self): + """Creates a PortCutterRectangular shape with filleted edges and checks + that its volume is correct.""" + + test_volume = self.test_shape.volume + + self.test_shape.fillet_radius = 5 + assert self.test_shape.volume < test_volume From e4c9819f02b45fc025887e4fd6acda7f54eb3051 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 15 Feb 2021 12:32:53 +0000 Subject: [PATCH 24/26] added more filleting tests --- .../test_parametric_components/test_PortCutterRectangular.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index 516781f13..86d5b0767 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -78,6 +78,9 @@ def test_filleting(self): that its volume is correct.""" test_volume = self.test_shape.volume - self.test_shape.fillet_radius = 5 + + assert self.test_shape.volume < test_volume + self.test_shape.workplane = "ZX" assert self.test_shape.volume < test_volume + self.test_shape.workplane = "YX" From ee51bb57aac978c743de32965f5a6c32b7aa14cf Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 15 Feb 2021 12:33:41 +0000 Subject: [PATCH 25/26] added assertion --- tests/test_parametric_components/test_PortCutterRectangular.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index 86d5b0767..dc7492992 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -84,3 +84,4 @@ def test_filleting(self): self.test_shape.workplane = "ZX" assert self.test_shape.volume < test_volume self.test_shape.workplane = "YX" + assert self.test_shape.volume < test_volume From ce3bdf793737dd17c2412eef6f5f26a5bd4d4c6a Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 15 Feb 2021 12:34:44 +0000 Subject: [PATCH 26/26] Automated autopep8 fixes --- tests/test_parametric_components/test_PortCutterRectangular.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index dc7492992..7d5c4d374 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -79,7 +79,7 @@ def test_filleting(self): test_volume = self.test_shape.volume self.test_shape.fillet_radius = 5 - + assert self.test_shape.volume < test_volume self.test_shape.workplane = "ZX" assert self.test_shape.volume < test_volume