From b7080ea370ddc0a3b7d344563439835533822289 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 8 Mar 2021 16:07:50 +0000 Subject: [PATCH 01/22] added new method of performing ordered boolean operations --- paramak/shape.py | 49 +++++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/paramak/shape.py b/paramak/shape.py index 8458be1b5..5a9ce9069 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -60,15 +60,9 @@ class Shape: description output. Defaults to None. physical_groups (dict, optional): contains information on physical groups (volumes and surfaces). Defaults to None. - cut (paramak.shape or list, optional): If set, the current solid will - be cut with the provided solid or iterable in cut. Defaults to - None. - intersect (paramak.shape or list, optional): If set, the current solid - will be interested with the provided solid or iterable of solids. - Defaults to None. - union (paramak.shape or list, optional): If set, the current solid - will be united with the provided solid or iterable of solids. - Defaults to None. + boolean_operations (dict, optional): dictionary of boolean operations + (cut, union, intersect) and the associated shapes with which the + operations will be performed with. Defaults to None. """ def __init__( @@ -87,9 +81,7 @@ def __init__( surface_reflectivity: Optional[bool] = False, physical_groups=None, # TODO defining Shape types as paramak.Shape results in circular import - cut=None, - intersect=None, - union=None, + boolean_operations: Optional[dict] = None ): self.connection_type = connection_type @@ -99,9 +91,7 @@ def __init__( self.color = color self.name = name - self.cut = cut - self.intersect = intersect - self.union = union + self.boolean_operations = boolean_operations self.azimuth_placement_angle = azimuth_placement_angle self.workplane = workplane @@ -1129,28 +1119,23 @@ def neutronics_description(self) -> dict: return neutronics_description def perform_boolean_operations(self, solid: cq.Workplane, **kwargs): - """Performs boolean cut, intersect and union operations if shapes are - provided""" - # If a cut solid is provided then perform a boolean cut - if self.cut is not None: - solid = cut_solid(solid, self.cut) + if self.boolean_operations is not None: + for operation, shapes in self.boolean_operations.items(): + if shapes is not None: + if operation == 'cut': + solid = cut_solid(solid, shapes) + + if operation == 'union': + solid = union_solid(solid, shapes) + + if operation == 'intersect': + solid = intersect_solid(solid, shapes) - # If a wedge cut is provided then perform a boolean cut - # Performed independantly to avoid use of self.cut - # Prevents repetition of 'outdated' wedge cuts if 'wedge_cut' in kwargs: if kwargs['wedge_cut'] is not None: solid = cut_solid(solid, kwargs['wedge_cut']) - - # If an intersect is provided then perform a boolean intersect - if self.intersect is not None: - solid = intersect_solid(solid, self.intersect) - - # If an intersect is provided then perform a boolean intersect - if self.union is not None: - solid = union_solid(solid, self.union) - + return solid def make_graveyard( From c28fae5cac1c8649bf4863241e461ae0a4d06849 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 8 Mar 2021 16:28:56 +0000 Subject: [PATCH 02/22] Automated autopep8 fixes --- paramak/shape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paramak/shape.py b/paramak/shape.py index 5a9ce9069..e2a3ed597 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -1135,7 +1135,7 @@ def perform_boolean_operations(self, solid: cq.Workplane, **kwargs): if 'wedge_cut' in kwargs: if kwargs['wedge_cut'] is not None: solid = cut_solid(solid, kwargs['wedge_cut']) - + return solid def make_graveyard( From 9234dd4a6d5a3ed3104d20c209b7a2ec0e3bee7a Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 8 Mar 2021 17:08:46 +0000 Subject: [PATCH 03/22] updated tests to use new boolean operation method --- tests/test_parametric_shapes/test_ExtrudeCircleShape.py | 4 ++-- tests/test_parametric_shapes/test_ExtrudeMixedShape.py | 2 +- tests/test_parametric_shapes/test_ExtrudeSplineShape.py | 3 ++- tests/test_parametric_shapes/test_ExtrudeStraightShape.py | 6 +++--- tests/test_parametric_shapes/test_RotateCircleShape.py | 2 +- tests/test_parametric_shapes/test_RotateMixedShape.py | 4 ++-- tests/test_parametric_shapes/test_RotateSplineShape.py | 2 +- tests/test_parametric_shapes/test_RotateStraightShape.py | 6 +++--- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/test_parametric_shapes/test_ExtrudeCircleShape.py b/tests/test_parametric_shapes/test_ExtrudeCircleShape.py index 0860b3d83..70e232fba 100644 --- a/tests/test_parametric_shapes/test_ExtrudeCircleShape.py +++ b/tests/test_parametric_shapes/test_ExtrudeCircleShape.py @@ -55,7 +55,7 @@ def test_cut_volume(self): shape_with_cut = ExtrudeCircleShape( points=[(30, 0)], radius=20, distance=40, - cut=self.test_shape + boolean_operations={"cut": self.test_shape} ) assert shape_with_cut.volume == pytest.approx( @@ -71,7 +71,7 @@ def test_intersect_volume(self): intersected_shape = ExtrudeCircleShape( points=[(30, 0)], radius=10, distance=50, - intersect=[self.test_shape, intersect_shape] + boolean_operations={"intersect": [self.test_shape, intersect_shape]} ) assert intersected_shape.volume == pytest.approx(math.pi * 5**2 * 30) diff --git a/tests/test_parametric_shapes/test_ExtrudeMixedShape.py b/tests/test_parametric_shapes/test_ExtrudeMixedShape.py index 5e0ce04cd..94071d744 100644 --- a/tests/test_parametric_shapes/test_ExtrudeMixedShape.py +++ b/tests/test_parametric_shapes/test_ExtrudeMixedShape.py @@ -103,7 +103,7 @@ def test_cut_volume(self): (12, 12, "spline"), (12, 3, "spline"), ], - cut=inner_shape, + boolean_operations={"cut": inner_shape}, distance=30, ) diff --git a/tests/test_parametric_shapes/test_ExtrudeSplineShape.py b/tests/test_parametric_shapes/test_ExtrudeSplineShape.py index c04685620..c8e34c311 100644 --- a/tests/test_parametric_shapes/test_ExtrudeSplineShape.py +++ b/tests/test_parametric_shapes/test_ExtrudeSplineShape.py @@ -59,7 +59,8 @@ def test_cut_volume(self): ) outer_shape_with_cut = ExtrudeSplineShape( - points=[(3, 3), (3, 12), (12, 12), (12, 3)], cut=inner_shape, + points=[(3, 3), (3, 12), (12, 12), (12, 3)], + boolean_operations={"cut": inner_shape}, distance=30, ) diff --git a/tests/test_parametric_shapes/test_ExtrudeStraightShape.py b/tests/test_parametric_shapes/test_ExtrudeStraightShape.py index 921ae3632..691d85d57 100644 --- a/tests/test_parametric_shapes/test_ExtrudeStraightShape.py +++ b/tests/test_parametric_shapes/test_ExtrudeStraightShape.py @@ -53,7 +53,7 @@ def test_cut_volume(self): shape_with_cut = ExtrudeStraightShape( points=[(0, 0), (0, 40), (40, 40), (40, 0)], distance=40, - cut=self.test_shape + boolean_operations={"cut": self.test_shape} ) assert shape_with_cut.volume == pytest.approx( @@ -66,7 +66,7 @@ def test_union_volume(self): unioned_shape = ExtrudeStraightShape( points=[(0, 10), (0, 30), (20, 30), (20, 10)], distance=30, - union=self.test_shape + boolean_operations={"union": self.test_shape} ) assert unioned_shape.volume == pytest.approx(30 * 20 * 30) @@ -76,7 +76,7 @@ def test_intersect_volume(self): intersected_shape = ExtrudeStraightShape( points=[(0, 10), (0, 30), (20, 30), (20, 10)], distance=30, - intersect=self.test_shape + boolean_operations={"intersect": self.test_shape} ) assert intersected_shape.volume == pytest.approx(10 * 20 * 30) diff --git a/tests/test_parametric_shapes/test_RotateCircleShape.py b/tests/test_parametric_shapes/test_RotateCircleShape.py index 2136fa470..98f44387f 100644 --- a/tests/test_parametric_shapes/test_RotateCircleShape.py +++ b/tests/test_parametric_shapes/test_RotateCircleShape.py @@ -78,7 +78,7 @@ def test_cut_volume(self): points=[(60, 0)], radius=15 ) outer_shape_volume = outer_shape.volume - outer_shape.cut = self.test_shape + outer_shape.boolean_operations = {"cut": self.test_shape} assert outer_shape.volume == pytest.approx( outer_shape_volume - self.test_shape.volume ) diff --git a/tests/test_parametric_shapes/test_RotateMixedShape.py b/tests/test_parametric_shapes/test_RotateMixedShape.py index 9a6d5718b..6b4ed4b8b 100644 --- a/tests/test_parametric_shapes/test_RotateMixedShape.py +++ b/tests/test_parametric_shapes/test_RotateMixedShape.py @@ -121,7 +121,7 @@ def test_union_volume_addition(self): (500, 200, "straight"), (500, 100, "straight"), ], - union=inner_box, + boolean_operations={"union": inner_box} ) assert inner_box.volume + outer_box.volume == pytest.approx( @@ -173,7 +173,7 @@ def test_cut_volume(self): ] ) outer_shape_volume = outer_shape.volume - outer_shape.cut = self.test_shape + outer_shape.boolean_operations = {"cut": self.test_shape} assert outer_shape.volume == pytest.approx( outer_shape_volume - self.test_shape.volume ) diff --git a/tests/test_parametric_shapes/test_RotateSplineShape.py b/tests/test_parametric_shapes/test_RotateSplineShape.py index fe69b1aff..5cd5e6024 100644 --- a/tests/test_parametric_shapes/test_RotateSplineShape.py +++ b/tests/test_parametric_shapes/test_RotateSplineShape.py @@ -50,7 +50,7 @@ def test_cut_volume(self): outer_shape_with_cut = RotateSplineShape( points=[(3, 3), (3, 12), (12, 12), (12, 3)], - cut=inner_shape, + boolean_operations={"cut": inner_shape}, rotation_angle=180, ) diff --git a/tests/test_parametric_shapes/test_RotateStraightShape.py b/tests/test_parametric_shapes/test_RotateStraightShape.py index 5dc97c818..6944cdad7 100644 --- a/tests/test_parametric_shapes/test_RotateStraightShape.py +++ b/tests/test_parametric_shapes/test_RotateStraightShape.py @@ -63,7 +63,7 @@ def test_union_volume_addition(self): outer_box_and_inner_box = RotateStraightShape( points=[(200, 100), (200, 200), (500, 200), (500, 100)], - union=inner_box, + boolean_operations={"union": inner_box} ) assert inner_box.volume + outer_box.volume == pytest.approx( @@ -215,7 +215,7 @@ def test_cut_volume(self): shape_with_cut = RotateStraightShape( points=[(0, -5), (0, 25), (25, 25), (25, -5)], - cut=self.test_shape + boolean_operations={"cut": self.test_shape} ) assert shape_with_cut.volume == pytest.approx( @@ -240,7 +240,7 @@ def test_multiple_cut_volume(self): main_shape_with_cuts = RotateStraightShape( points=[(0, 0), (0, 200), (200, 200), (200, 0)], - cut=[shape_to_cut_1, shape_to_cut_2] + boolean_operations={"cut": [shape_to_cut_1, shape_to_cut_2]} ) assert main_shape_with_cuts.volume == pytest.approx( From 03cf4ec5b049e2b0b90b1325d86565c82dfc17a3 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 8 Mar 2021 17:10:03 +0000 Subject: [PATCH 04/22] Automated autopep8 fixes --- tests/test_parametric_shapes/test_ExtrudeCircleShape.py | 7 ++++--- tests/test_parametric_shapes/test_ExtrudeSplineShape.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_parametric_shapes/test_ExtrudeCircleShape.py b/tests/test_parametric_shapes/test_ExtrudeCircleShape.py index 70e232fba..dffc1c089 100644 --- a/tests/test_parametric_shapes/test_ExtrudeCircleShape.py +++ b/tests/test_parametric_shapes/test_ExtrudeCircleShape.py @@ -70,9 +70,10 @@ def test_intersect_volume(self): points=[(30, 0)], radius=5, distance=50) intersected_shape = ExtrudeCircleShape( - points=[(30, 0)], radius=10, distance=50, - boolean_operations={"intersect": [self.test_shape, intersect_shape]} - ) + points=[ + (30, 0)], radius=10, distance=50, boolean_operations={ + "intersect": [ + self.test_shape, intersect_shape]}) assert intersected_shape.volume == pytest.approx(math.pi * 5**2 * 30) diff --git a/tests/test_parametric_shapes/test_ExtrudeSplineShape.py b/tests/test_parametric_shapes/test_ExtrudeSplineShape.py index c8e34c311..9ef04daf0 100644 --- a/tests/test_parametric_shapes/test_ExtrudeSplineShape.py +++ b/tests/test_parametric_shapes/test_ExtrudeSplineShape.py @@ -59,7 +59,7 @@ def test_cut_volume(self): ) outer_shape_with_cut = ExtrudeSplineShape( - points=[(3, 3), (3, 12), (12, 12), (12, 3)], + points=[(3, 3), (3, 12), (12, 12), (12, 3)], boolean_operations={"cut": inner_shape}, distance=30, ) From ecb7e9b537f6f79335372687bb610b16ba035401 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 8 Mar 2021 17:48:44 +0000 Subject: [PATCH 05/22] updated boolean operations --- paramak/parametric_reactors/ball_reactor.py | 8 ++--- .../center_column_study_reactor.py | 10 +++---- .../eu_demo_2015_reactor.py | 6 ++-- .../segmented_blanket_ball_reactor.py | 6 ++-- .../parametric_reactors/sparc_paper_2020.py | 2 +- .../parametric_reactors/submersion_reactor.py | 29 ++++++++++--------- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/paramak/parametric_reactors/ball_reactor.py b/paramak/parametric_reactors/ball_reactor.py index 6cae0fb92..651feb5cf 100644 --- a/paramak/parametric_reactors/ball_reactor.py +++ b/paramak/parametric_reactors/ball_reactor.py @@ -392,7 +392,7 @@ def _make_blankets_layers(self): material_tag="firstwall_mat", stp_filename="firstwall.stp", stl_filename="firstwall.stl", - cut=[self._center_column_cutter] + boolean_operations={"cut": [self._center_column_cutter]} ) self._blanket = paramak.BlanketFP( @@ -406,7 +406,7 @@ def _make_blankets_layers(self): material_tag="blanket_mat", stp_filename="blanket.stp", stl_filename="blanket.stl", - cut=[self._center_column_cutter]) + boolean_operations={"cut": [self_center_column_cutter]} self._blanket_rear_wall = paramak.BlanketFP( plasma=self._plasma, @@ -420,7 +420,7 @@ def _make_blankets_layers(self): material_tag="blanket_rear_wall_mat", stp_filename="blanket_rear_wall.stp", stl_filename="blanket_rear_wall.stl", - cut=[self._center_column_cutter], + boolean_operations={"cut": [self_center_column_cutter]} ) return [self._firstwall, self._blanket, self._blanket_rear_wall] @@ -466,7 +466,7 @@ def _make_divertor(self): self._firstwall, self._blanket, self._blanket_rear_wall]: - component.cut.append(self._divertor) + component.boolean_operations["cut"].append(self._divertor) return self._divertor diff --git a/paramak/parametric_reactors/center_column_study_reactor.py b/paramak/parametric_reactors/center_column_study_reactor.py index 44da9f067..5c11d5032 100644 --- a/paramak/parametric_reactors/center_column_study_reactor.py +++ b/paramak/parametric_reactors/center_column_study_reactor.py @@ -268,12 +268,12 @@ def _make_outboard_blanket(self): start_angle=-180, stop_angle=180, rotation_angle=self.rotation_angle, - cut=[self._center_column_cutter] + boolean_operations={"cut": [self._center_column_cutter]} ) return self._blanket def _make_divertor(self): - self._blanket_enveloppe = paramak.BlanketFP( + self._blanket_envelope = paramak.BlanketFP( plasma=self._plasma, thickness=100., offset_from_plasma=[ @@ -285,7 +285,7 @@ def _make_divertor(self): start_angle=-180, stop_angle=180, rotation_angle=self.rotation_angle, - cut=[self._center_column_cutter] + boolean_operations={"cut": [self._center_column_cutter]} ) self._divertor = paramak.CenterColumnShieldCylinder( @@ -298,7 +298,7 @@ def _make_divertor(self): stl_filename="divertor.stl", name="divertor", material_tag="divertor_mat", - intersect=self._blanket_enveloppe, + boolean_operations={"intersect": self._blanket_envelope} ) - self._blanket.cut.append(self._divertor) + self._blanket.boolean_operations["cut"].append(self._divertor) return self._divertor diff --git a/paramak/parametric_reactors/eu_demo_2015_reactor.py b/paramak/parametric_reactors/eu_demo_2015_reactor.py index 39ffad2e3..a3dea13fa 100644 --- a/paramak/parametric_reactors/eu_demo_2015_reactor.py +++ b/paramak/parametric_reactors/eu_demo_2015_reactor.py @@ -83,7 +83,7 @@ def create_tf_coils(self, vac_vessel_inner, vac_vessel) -> list: (375.4508992805756, 755, "straight"), ], distance=200, - cut=[vac_vessel_inner, vac_vessel], + boolean_operations={"cut": [vac_vessel_inner, vac_vessel]}, # azimuth placement angle can't start at # zero nor end at 360 until #757 is solved azimuth_placement_angle=np.linspace( @@ -220,7 +220,7 @@ def create_vessel_components(self) -> list: ], rotation_angle=self.rotation_angle, # avoid overlap between VV and blanket divertor - union=[blanket, divertor] + boolean_operations={"union": [blanket, divertor]} ) vac_vessel = paramak.RotateSplineShape( points=[ @@ -276,7 +276,7 @@ def create_vessel_components(self) -> list: (516.7486775621876, -175.64585325476332), (516.7486775621876, -107.40944903301386), ], - cut=vac_vessel_inner, # hollow shape + boolean_operations={"cut": vac_vessel_inner}, rotation_angle=self.rotation_angle, stp_filename='vacvessel.stp', stl_filename='vacvessel.stl', diff --git a/paramak/parametric_reactors/segmented_blanket_ball_reactor.py b/paramak/parametric_reactors/segmented_blanket_ball_reactor.py index ea79b5ba9..8f0189460 100644 --- a/paramak/parametric_reactors/segmented_blanket_ball_reactor.py +++ b/paramak/parametric_reactors/segmented_blanket_ball_reactor.py @@ -76,7 +76,7 @@ def _make_blankets_layers(self): 2 * self.firstwall_radial_thickness, azimuth_placement_angle=azimuth_placement_angles) - self._blanket.cut = [self._center_column_cutter, thick_cutter] + self._blanket.boolean_operations = {"cut": [self._center_column_cutter, thick_cutter]} if self.blanket_fillet_radius != 0: # tried firstwall start radius here already @@ -90,10 +90,10 @@ def _make_blankets_layers(self): paramak.EdgeLengthSelector(front_edge_length_b)).fillet( self.blanket_fillet_radius) self._firstwall.thickness += self.blanket_radial_thickness - self._firstwall.cut = [ + self._firstwall.boolean_operations = {"cut": [ self._center_column_cutter, thin_cutter, - self._blanket] + self._blanket]} # TODO this segfaults at the moment but works as an opperation on the # reactor after construction in jupyter diff --git a/paramak/parametric_reactors/sparc_paper_2020.py b/paramak/parametric_reactors/sparc_paper_2020.py index 6823e08dd..16982cadf 100644 --- a/paramak/parametric_reactors/sparc_paper_2020.py +++ b/paramak/parametric_reactors/sparc_paper_2020.py @@ -294,7 +294,7 @@ def create_vessel_components(self, vs_coils): ], rotation_angle=self.rotation_angle, stp_filename='inner_vessel.stp', - cut=[vac_vessel, vs_coils, antenna] + boolean_operations={"cut": [vac_vessel, vs_coils, antenna]} ) return [antenna, vac_vessel, inner_vessel] diff --git a/paramak/parametric_reactors/submersion_reactor.py b/paramak/parametric_reactors/submersion_reactor.py index 4496f05fb..053f8f8c6 100644 --- a/paramak/parametric_reactors/submersion_reactor.py +++ b/paramak/parametric_reactors/submersion_reactor.py @@ -444,7 +444,7 @@ def _make_firstwall(self): stl_filename="outboard_firstwall.stl", name="outboard_firstwall", material_tag="firstwall_mat", - union=self._inboard_firstwall, + boolean_operations={"union": self._inboard_firstwall} ) return self._firstwall @@ -469,7 +469,7 @@ def _make_divertor(self): stl_filename="outboard_firstwall.stl", name="outboard_firstwall", material_tag="firstwall_mat", - union=fw_enveloppe_inboard, + boolean_operations={"union": fw_enveloppe_inboard} ) divertor_height = self._blanket_rear_wall_end_height @@ -488,7 +488,7 @@ def _make_divertor(self): (self._divertor_end_radius, divertor_height_top), (self._divertor_start_radius, divertor_height_top) ], - intersect=fw_enveloppe, + boolean_operations={"intersect": fw_enveloppe}, rotation_angle=self.rotation_angle, stp_filename="divertor.stp", stl_filename="divertor.stl", @@ -496,8 +496,9 @@ def _make_divertor(self): material_tag="divertor_mat" ) - self._firstwall.cut = self._divertor - self._inboard_firstwall.cut = self._divertor + self._firstwall.boolean_operations = {"union": self._inboard_firstwall, + "cut": self._divertor} + self._inboard_firstwall.boolean_operations = {"cut": self._divertor} return self._divertor def _make_blanket(self): @@ -506,7 +507,7 @@ def _make_blanket(self): inner_radius=self._inboard_blanket_start_radius, outer_radius=max(self._inboard_firstwall.points)[0], rotation_angle=self.rotation_angle, - cut=self._inboard_firstwall, + boolean_operations={"cut": self._inboard_firstwall} ) # this takes a single solid from a compound of solids by finding the @@ -529,7 +530,7 @@ def _make_blanket(self): stl_filename="blanket.stl", name="blanket", material_tag="blanket_mat", - union=self._inboard_blanket, + boolean_operations={"union": self._inboard_blanket} ) return self._blanket @@ -542,7 +543,7 @@ def _make_supports(self): + self.firstwall_radial_thickness, thickness=self.outboard_blanket_radial_thickness, rotation_angle=self.rotation_angle, - union=self._inboard_blanket, + boolean_operations={"union": self._inboard_blanket} ) support_height = self._blanket_rear_wall_end_height support_height_top = support_height @@ -565,9 +566,10 @@ def _make_supports(self): stl_filename="supports.stl", name="supports", material_tag="supports_mat", - intersect=blanket_enveloppe, + boolean_operations={"intersect": blanket_enveloppe} ) - self._blanket.cut = self._supports + self._blanket.boolean_operations={"union": self._inboard_blanket, + "cut": self._supports} return self._supports @@ -629,9 +631,10 @@ def _make_rear_blanket_wall(self): stl_filename="outboard_rear_blanket_wall.stl", name="outboard_rear_blanket_wall", material_tag="blanket_rear_wall_mat", - union=[ - self._outboard_rear_blanket_wall_upper, - self._outboard_rear_blanket_wall_lower], + boolean_operations={"union": [ + self._outboard_rear_blanket_wall_upper, + self._outboard_rear_blanket_wall_lower + ]}, ) return self._outboard_rear_blanket_wall From 9aa350b5a90dac954d7b2f30f5c3c13ccd008255 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 8 Mar 2021 17:49:57 +0000 Subject: [PATCH 06/22] Automated autopep8 fixes --- paramak/parametric_reactors/ball_reactor.py | 30 +++++++++---------- .../segmented_blanket_ball_reactor.py | 3 +- .../parametric_reactors/submersion_reactor.py | 6 ++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/paramak/parametric_reactors/ball_reactor.py b/paramak/parametric_reactors/ball_reactor.py index 651feb5cf..dc8fa3261 100644 --- a/paramak/parametric_reactors/ball_reactor.py +++ b/paramak/parametric_reactors/ball_reactor.py @@ -408,7 +408,7 @@ def _make_blankets_layers(self): stl_filename="blanket.stl", boolean_operations={"cut": [self_center_column_cutter]} - self._blanket_rear_wall = paramak.BlanketFP( + self._blanket_rear_wall=paramak.BlanketFP( plasma=self._plasma, thickness=self.blanket_rear_wall_radial_thickness, offset_from_plasma=[e + self.firstwall_radial_thickness @@ -427,7 +427,7 @@ def _make_blankets_layers(self): def _make_divertor(self): # # used as an intersect when making the divertor - self._blanket_fw_rear_wall_envelope = paramak.BlanketFP( + self._blanket_fw_rear_wall_envelope=paramak.BlanketFP( plasma=self._plasma, thickness=self.firstwall_radial_thickness + self.blanket_radial_thickness + @@ -438,16 +438,16 @@ def _make_divertor(self): rotation_angle=self.rotation_angle, ) - divertor_height = self._blanket_rear_wall_end_height * 2 + divertor_height=self._blanket_rear_wall_end_height * 2 - divertor_height_top = divertor_height - divertor_height_bottom = -divertor_height + divertor_height_top=divertor_height + divertor_height_bottom=-divertor_height if self.divertor_position == "lower": - divertor_height_top = 0 + divertor_height_top=0 elif self.divertor_position == "upper": - divertor_height_bottom = 0 - self._divertor = paramak.RotateStraightShape( + divertor_height_bottom=0 + self._divertor=paramak.RotateStraightShape( points=[ (self._divertor_start_radius, divertor_height_bottom), (self._divertor_end_radius, divertor_height_bottom), @@ -471,12 +471,12 @@ def _make_divertor(self): return self._divertor def _make_pf_coils(self): - list_of_components = [] + list_of_components=[] if (self.pf_coil_vertical_thicknesses, self.pf_coil_radial_thicknesses, self.pf_coil_to_rear_blanket_radial_gap) != (None, None, None): - self._pf_coil = paramak.PoloidalFieldCoilSet( + self._pf_coil=paramak.PoloidalFieldCoilSet( heights=self.pf_coil_vertical_thicknesses, widths=self.pf_coil_radial_thicknesses, center_points=self._pf_coils_xy_values, @@ -487,7 +487,7 @@ def _make_pf_coils(self): material_tag="pf_coil_mat", ) - self._pf_coils_casing = paramak.PoloidalFieldCoilCaseSetFC( + self._pf_coils_casing=paramak.PoloidalFieldCoilCaseSetFC( pf_coils=self._pf_coil, casing_thicknesses=self.pf_coil_case_thickness, rotation_angle=self.rotation_angle, @@ -497,15 +497,15 @@ def _make_pf_coils(self): material_tag="pf_coil_case_mat", ) - list_of_components = [self._pf_coils_casing, self._pf_coil] + list_of_components=[self._pf_coils_casing, self._pf_coil] return list_of_components def _make_tf_coils(self): - comp = [] + comp=[] if (self.pf_coil_to_tf_coil_radial_gap, self.outboard_tf_coil_radial_thickness) != (None, None): - self._tf_coil = paramak.ToroidalFieldCoilRectangle( + self._tf_coil=paramak.ToroidalFieldCoilRectangle( with_inner_leg=False, horizontal_start_point=( self._inboard_tf_coils_start_radius, @@ -521,5 +521,5 @@ def _make_tf_coils(self): stl_filename="tf_coil.stl", rotation_angle=self.rotation_angle ) - comp = [self._tf_coil] + comp=[self._tf_coil] return comp diff --git a/paramak/parametric_reactors/segmented_blanket_ball_reactor.py b/paramak/parametric_reactors/segmented_blanket_ball_reactor.py index 8f0189460..10fdbfb65 100644 --- a/paramak/parametric_reactors/segmented_blanket_ball_reactor.py +++ b/paramak/parametric_reactors/segmented_blanket_ball_reactor.py @@ -76,7 +76,8 @@ def _make_blankets_layers(self): 2 * self.firstwall_radial_thickness, azimuth_placement_angle=azimuth_placement_angles) - self._blanket.boolean_operations = {"cut": [self._center_column_cutter, thick_cutter]} + self._blanket.boolean_operations = { + "cut": [self._center_column_cutter, thick_cutter]} if self.blanket_fillet_radius != 0: # tried firstwall start radius here already diff --git a/paramak/parametric_reactors/submersion_reactor.py b/paramak/parametric_reactors/submersion_reactor.py index 053f8f8c6..908e1adb5 100644 --- a/paramak/parametric_reactors/submersion_reactor.py +++ b/paramak/parametric_reactors/submersion_reactor.py @@ -568,8 +568,8 @@ def _make_supports(self): material_tag="supports_mat", boolean_operations={"intersect": blanket_enveloppe} ) - self._blanket.boolean_operations={"union": self._inboard_blanket, - "cut": self._supports} + self._blanket.boolean_operations = {"union": self._inboard_blanket, + "cut": self._supports} return self._supports @@ -632,7 +632,7 @@ def _make_rear_blanket_wall(self): name="outboard_rear_blanket_wall", material_tag="blanket_rear_wall_mat", boolean_operations={"union": [ - self._outboard_rear_blanket_wall_upper, + self._outboard_rear_blanket_wall_upper, self._outboard_rear_blanket_wall_lower ]}, ) From 95c2be34839b2be6b3090d1216caa35ecb408130 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 8 Mar 2021 18:18:29 +0000 Subject: [PATCH 07/22] fix syntax error --- paramak/parametric_reactors/ball_reactor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/paramak/parametric_reactors/ball_reactor.py b/paramak/parametric_reactors/ball_reactor.py index 651feb5cf..671cd1aca 100644 --- a/paramak/parametric_reactors/ball_reactor.py +++ b/paramak/parametric_reactors/ball_reactor.py @@ -407,6 +407,7 @@ def _make_blankets_layers(self): stp_filename="blanket.stp", stl_filename="blanket.stl", boolean_operations={"cut": [self_center_column_cutter]} + ) self._blanket_rear_wall = paramak.BlanketFP( plasma=self._plasma, From 3cdcbffdf071c5a7e1227dc0230ac3448502d7c8 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 8 Mar 2021 18:19:39 +0000 Subject: [PATCH 08/22] Automated autopep8 fixes --- paramak/parametric_reactors/ball_reactor.py | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/paramak/parametric_reactors/ball_reactor.py b/paramak/parametric_reactors/ball_reactor.py index a5db47abc..671cd1aca 100644 --- a/paramak/parametric_reactors/ball_reactor.py +++ b/paramak/parametric_reactors/ball_reactor.py @@ -409,7 +409,7 @@ def _make_blankets_layers(self): boolean_operations={"cut": [self_center_column_cutter]} ) - self._blanket_rear_wall=paramak.BlanketFP( + self._blanket_rear_wall = paramak.BlanketFP( plasma=self._plasma, thickness=self.blanket_rear_wall_radial_thickness, offset_from_plasma=[e + self.firstwall_radial_thickness @@ -428,7 +428,7 @@ def _make_blankets_layers(self): def _make_divertor(self): # # used as an intersect when making the divertor - self._blanket_fw_rear_wall_envelope=paramak.BlanketFP( + self._blanket_fw_rear_wall_envelope = paramak.BlanketFP( plasma=self._plasma, thickness=self.firstwall_radial_thickness + self.blanket_radial_thickness + @@ -439,16 +439,16 @@ def _make_divertor(self): rotation_angle=self.rotation_angle, ) - divertor_height=self._blanket_rear_wall_end_height * 2 + divertor_height = self._blanket_rear_wall_end_height * 2 - divertor_height_top=divertor_height - divertor_height_bottom=-divertor_height + divertor_height_top = divertor_height + divertor_height_bottom = -divertor_height if self.divertor_position == "lower": - divertor_height_top=0 + divertor_height_top = 0 elif self.divertor_position == "upper": - divertor_height_bottom=0 - self._divertor=paramak.RotateStraightShape( + divertor_height_bottom = 0 + self._divertor = paramak.RotateStraightShape( points=[ (self._divertor_start_radius, divertor_height_bottom), (self._divertor_end_radius, divertor_height_bottom), @@ -472,12 +472,12 @@ def _make_divertor(self): return self._divertor def _make_pf_coils(self): - list_of_components=[] + list_of_components = [] if (self.pf_coil_vertical_thicknesses, self.pf_coil_radial_thicknesses, self.pf_coil_to_rear_blanket_radial_gap) != (None, None, None): - self._pf_coil=paramak.PoloidalFieldCoilSet( + self._pf_coil = paramak.PoloidalFieldCoilSet( heights=self.pf_coil_vertical_thicknesses, widths=self.pf_coil_radial_thicknesses, center_points=self._pf_coils_xy_values, @@ -488,7 +488,7 @@ def _make_pf_coils(self): material_tag="pf_coil_mat", ) - self._pf_coils_casing=paramak.PoloidalFieldCoilCaseSetFC( + self._pf_coils_casing = paramak.PoloidalFieldCoilCaseSetFC( pf_coils=self._pf_coil, casing_thicknesses=self.pf_coil_case_thickness, rotation_angle=self.rotation_angle, @@ -498,15 +498,15 @@ def _make_pf_coils(self): material_tag="pf_coil_case_mat", ) - list_of_components=[self._pf_coils_casing, self._pf_coil] + list_of_components = [self._pf_coils_casing, self._pf_coil] return list_of_components def _make_tf_coils(self): - comp=[] + comp = [] if (self.pf_coil_to_tf_coil_radial_gap, self.outboard_tf_coil_radial_thickness) != (None, None): - self._tf_coil=paramak.ToroidalFieldCoilRectangle( + self._tf_coil = paramak.ToroidalFieldCoilRectangle( with_inner_leg=False, horizontal_start_point=( self._inboard_tf_coils_start_radius, @@ -522,5 +522,5 @@ def _make_tf_coils(self): stl_filename="tf_coil.stl", rotation_angle=self.rotation_angle ) - comp=[self._tf_coil] + comp = [self._tf_coil] return comp From fb61e623b8eb8a33c192ef3b137a74f058417eac Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 8 Mar 2021 18:52:17 +0000 Subject: [PATCH 09/22] updated tests to use new boolean operations method --- paramak/parametric_components/blanket_poloidal_segment.py | 4 ++-- tests/test_parametric_components/test_InboardFirstwallFCCS.py | 4 ++-- .../test_parametric_components/test_PortCutterRectangular.py | 2 +- tests/test_parametric_components/test_PortCutterRotated.py | 4 ++-- tests/test_parametric_components/test_VacuumVessel.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/paramak/parametric_components/blanket_poloidal_segment.py b/paramak/parametric_components/blanket_poloidal_segment.py index 37a9fe4fd..4718def0d 100644 --- a/paramak/parametric_components/blanket_poloidal_segment.py +++ b/paramak/parametric_components/blanket_poloidal_segment.py @@ -129,7 +129,7 @@ def create_segment_cutters(self): cutting_shape = RotateStraightShape( rotation_angle=self.rotation_angle, azimuth_placement_angle=self.azimuth_placement_angle, - union=[]) + boolean_operations={"union"=[]}) # add points to the shape to avoid void solid cutting_shape.points = [ (self.major_radius, @@ -188,7 +188,7 @@ def create_segment_cutters(self): angle=np.pi / 2)] cutter.points = points_cutter # add cutter to global cutting shape - cutting_shape.union.append(cutter) + cutting_shape.boolean_operations["cut"].append(cutter) self.segments_cutters = cutting_shape diff --git a/tests/test_parametric_components/test_InboardFirstwallFCCS.py b/tests/test_parametric_components/test_InboardFirstwallFCCS.py index 1e6dd2c18..582b40bf6 100644 --- a/tests/test_parametric_components/test_InboardFirstwallFCCS.py +++ b/tests/test_parametric_components/test_InboardFirstwallFCCS.py @@ -146,7 +146,7 @@ def test_boolean_union(self): thickness=20, rotation_angle=180, azimuth_placement_angle=180, - union=b) + boolean_operations={"union": b}) assert np.isclose(c.volume, 2 * b.volume) def test_azimuth_placement_angle(self): @@ -171,7 +171,7 @@ def test_azimuth_placement_angle(self): thickness=20, rotation_angle=180, azimuth_placement_angle=90, - cut=b) + boolean_operations={"cut": b}) assert np.isclose(c.volume, 0.5 * b.volume) def test_cut_attribute(self): diff --git a/tests/test_parametric_components/test_PortCutterRectangular.py b/tests/test_parametric_components/test_PortCutterRectangular.py index 7d5c4d374..bf03bbb37 100644 --- a/tests/test_parametric_components/test_PortCutterRectangular.py +++ b/tests/test_parametric_components/test_PortCutterRectangular.py @@ -64,7 +64,7 @@ def test_workplane(self): points=[(0, 0), (0, 50), (500, 50), (500, 0)], workplane="YZ", ) - self.test_shape.cut = cutting_shape + self.test_shape.boolean_operations = {"cut": cutting_shape} assert self.test_shape.volume == pytest.approx(20 * 40 * 300 * 0.5) diff --git a/tests/test_parametric_components/test_PortCutterRotated.py b/tests/test_parametric_components/test_PortCutterRotated.py index 1040289d9..b7c52a0c5 100644 --- a/tests/test_parametric_components/test_PortCutterRotated.py +++ b/tests/test_parametric_components/test_PortCutterRotated.py @@ -37,14 +37,14 @@ def test_shape_construction_and_volume(self): height=500, inner_radius=200, outer_radius=300, - cut=small_ports + boolean_operations={"cut": small_ports} ) vessel_with_large_ports = paramak.CenterColumnShieldCylinder( height=500, inner_radius=200, outer_radius=300, - cut=large_ports + boolean_operations={"cut": large_ports} ) assert large_ports.volume > small_ports.volume diff --git a/tests/test_parametric_components/test_VacuumVessel.py b/tests/test_parametric_components/test_VacuumVessel.py index 3499c4d47..b14bf0a60 100644 --- a/tests/test_parametric_components/test_VacuumVessel.py +++ b/tests/test_parametric_components/test_VacuumVessel.py @@ -44,6 +44,6 @@ def test_ports(self): pre_cut_volume = self.test_shape.volume - self.test_shape.cut = [cutter1, cutter2, cutter3, cutter4, cutter5] + self.test_shape.boolean_operations = {"cut": [cutter1, cutter2, cutter3, cutter4, cutter5]} assert self.test_shape.solid is not None assert self.test_shape.volume < pre_cut_volume From 066fd181cdf89a5d0c350b8dbd25fcade7ed0ea0 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Mon, 8 Mar 2021 18:53:33 +0000 Subject: [PATCH 10/22] Automated autopep8 fixes --- tests/test_parametric_components/test_VacuumVessel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_parametric_components/test_VacuumVessel.py b/tests/test_parametric_components/test_VacuumVessel.py index b14bf0a60..12df1e70a 100644 --- a/tests/test_parametric_components/test_VacuumVessel.py +++ b/tests/test_parametric_components/test_VacuumVessel.py @@ -44,6 +44,7 @@ def test_ports(self): pre_cut_volume = self.test_shape.volume - self.test_shape.boolean_operations = {"cut": [cutter1, cutter2, cutter3, cutter4, cutter5]} + self.test_shape.boolean_operations = { + "cut": [cutter1, cutter2, cutter3, cutter4, cutter5]} assert self.test_shape.solid is not None assert self.test_shape.volume < pre_cut_volume From 58db06ac2940b9cc8949ccef0512ec395b50e7b2 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Mon, 8 Mar 2021 19:01:37 +0000 Subject: [PATCH 11/22] fixed syntax error --- paramak/parametric_components/blanket_poloidal_segment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paramak/parametric_components/blanket_poloidal_segment.py b/paramak/parametric_components/blanket_poloidal_segment.py index 4718def0d..52f769f29 100644 --- a/paramak/parametric_components/blanket_poloidal_segment.py +++ b/paramak/parametric_components/blanket_poloidal_segment.py @@ -129,7 +129,7 @@ def create_segment_cutters(self): cutting_shape = RotateStraightShape( rotation_angle=self.rotation_angle, azimuth_placement_angle=self.azimuth_placement_angle, - boolean_operations={"union"=[]}) + boolean_operations={"union": []}) # add points to the shape to avoid void solid cutting_shape.points = [ (self.major_radius, From 03abc55bbc0d36a5447833c59589cf4f5e31a39b Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 10:27:35 +0000 Subject: [PATCH 12/22] fixed typos --- paramak/parametric_reactors/ball_reactor.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paramak/parametric_reactors/ball_reactor.py b/paramak/parametric_reactors/ball_reactor.py index 671cd1aca..e418bcea2 100644 --- a/paramak/parametric_reactors/ball_reactor.py +++ b/paramak/parametric_reactors/ball_reactor.py @@ -406,7 +406,7 @@ def _make_blankets_layers(self): material_tag="blanket_mat", stp_filename="blanket.stp", stl_filename="blanket.stl", - boolean_operations={"cut": [self_center_column_cutter]} + boolean_operations={"cut": [self._center_column_cutter]} ) self._blanket_rear_wall = paramak.BlanketFP( @@ -421,7 +421,7 @@ def _make_blankets_layers(self): material_tag="blanket_rear_wall_mat", stp_filename="blanket_rear_wall.stp", stl_filename="blanket_rear_wall.stl", - boolean_operations={"cut": [self_center_column_cutter]} + boolean_operations={"cut": [self._center_column_cutter]} ) return [self._firstwall, self._blanket, self._blanket_rear_wall] @@ -455,7 +455,7 @@ def _make_divertor(self): (self._divertor_end_radius, divertor_height_top), (self._divertor_start_radius, divertor_height_top) ], - intersect=self._blanket_fw_rear_wall_envelope, + boolean_operations={"intersect": self._blanket_fw_rear_wall_envelope}, stp_filename="divertor.stp", stl_filename="divertor.stl", name="divertor", From f192e2039ea0a99e024178acffd30f749abf76bf Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 10:59:15 +0000 Subject: [PATCH 13/22] updated boolean operations --- paramak/parametric_reactors/submersion_reactor.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/paramak/parametric_reactors/submersion_reactor.py b/paramak/parametric_reactors/submersion_reactor.py index 908e1adb5..f961637a7 100644 --- a/paramak/parametric_reactors/submersion_reactor.py +++ b/paramak/parametric_reactors/submersion_reactor.py @@ -496,8 +496,7 @@ def _make_divertor(self): material_tag="divertor_mat" ) - self._firstwall.boolean_operations = {"union": self._inboard_firstwall, - "cut": self._divertor} + self._firstwall.boolean_operations["cut"] = self._divertor self._inboard_firstwall.boolean_operations = {"cut": self._divertor} return self._divertor @@ -568,8 +567,7 @@ def _make_supports(self): material_tag="supports_mat", boolean_operations={"intersect": blanket_enveloppe} ) - self._blanket.boolean_operations = {"union": self._inboard_blanket, - "cut": self._supports} + self._blanket.boolean_operations["cut"] = self._supports return self._supports From c5d89d704f04dd6edfbc38ecc1d80e1c28aa9b6a Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 10:59:29 +0000 Subject: [PATCH 14/22] updated appending to cut --- .../inboard_firstwall_fccs.py | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/paramak/parametric_components/inboard_firstwall_fccs.py b/paramak/parametric_components/inboard_firstwall_fccs.py index ffb65760f..8e7bb20f6 100644 --- a/paramak/parametric_components/inboard_firstwall_fccs.py +++ b/paramak/parametric_components/inboard_firstwall_fccs.py @@ -152,10 +152,22 @@ def find_points(self): points = firstwall.points[:-1] # remove last point self.points = points - # add to cut attribute - if self.cut is None: - self.cut = self.central_column_shield - elif isinstance(self.cut, Iterable): - self.cut = [*self.cut, self.central_column_shield] + if self.boolean_operations is None: + self.boolean_operations = {"cut": self.central_column_shield} else: - self.cut = [*[self.cut], self.central_column_shield] + if "cut" not in self.boolean_operations: + self.boolean_operations["cut"] = self.central_column_shield + else: + if isinstance(self.boolean_operations["cut"], Iterable): + self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] + else: + self.boolean_operations["cut"] [*[self.boolean_operations["cut"]], self.central_column_shield] + + + # add to cut attribute + # if self.cut is None: + # self.cut = self.central_column_shield + # elif isinstance(self.cut, Iterable): + # self.cut = [*self.cut, self.central_column_shield] + # else: + # self.cut = [*[self.cut], self.central_column_shield] From 042e30ff249b57b4f4d1b5c66d599088075bb0fe Mon Sep 17 00:00:00 2001 From: autopep8 Date: Tue, 9 Mar 2021 11:00:27 +0000 Subject: [PATCH 15/22] Automated autopep8 fixes --- paramak/parametric_components/inboard_firstwall_fccs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paramak/parametric_components/inboard_firstwall_fccs.py b/paramak/parametric_components/inboard_firstwall_fccs.py index 8e7bb20f6..8fa4abc5e 100644 --- a/paramak/parametric_components/inboard_firstwall_fccs.py +++ b/paramak/parametric_components/inboard_firstwall_fccs.py @@ -159,10 +159,10 @@ def find_points(self): self.boolean_operations["cut"] = self.central_column_shield else: if isinstance(self.boolean_operations["cut"], Iterable): - self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] + self.boolean_operations["cut"] = [ + *self.boolean_operations["cut"], self.central_column_shield] else: - self.boolean_operations["cut"] [*[self.boolean_operations["cut"]], self.central_column_shield] - + self.boolean_operations["cut"][*[self.boolean_operations["cut"]], self.central_column_shield] # add to cut attribute # if self.cut is None: From 041523006a13e7c0e7065fb1325adf531f6cceaf Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 11:03:10 +0000 Subject: [PATCH 16/22] fixed typo and tidied up if else --- .../parametric_components/inboard_firstwall_fccs.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/paramak/parametric_components/inboard_firstwall_fccs.py b/paramak/parametric_components/inboard_firstwall_fccs.py index 8e7bb20f6..40404755e 100644 --- a/paramak/parametric_components/inboard_firstwall_fccs.py +++ b/paramak/parametric_components/inboard_firstwall_fccs.py @@ -154,14 +154,13 @@ def find_points(self): if self.boolean_operations is None: self.boolean_operations = {"cut": self.central_column_shield} + elif "cut" not in self.boolean_operations: + self.boolean_operations["cut"] = self.central_column_shield else: - if "cut" not in self.boolean_operations: - self.boolean_operations["cut"] = self.central_column_shield + if isinstance(self.boolean_operations["cut"], Iterable): + self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] else: - if isinstance(self.boolean_operations["cut"], Iterable): - self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] - else: - self.boolean_operations["cut"] [*[self.boolean_operations["cut"]], self.central_column_shield] + self.boolean_operations["cut"] = [*[self.boolean_operations["cut"]], self.central_column_shield] # add to cut attribute From 59da389bd6709e6b33f0232f40a7900e0f33b6c2 Mon Sep 17 00:00:00 2001 From: autopep8 Date: Tue, 9 Mar 2021 11:05:25 +0000 Subject: [PATCH 17/22] Automated autopep8 fixes --- paramak/parametric_components/inboard_firstwall_fccs.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/paramak/parametric_components/inboard_firstwall_fccs.py b/paramak/parametric_components/inboard_firstwall_fccs.py index f3814aa98..e359f4ce5 100644 --- a/paramak/parametric_components/inboard_firstwall_fccs.py +++ b/paramak/parametric_components/inboard_firstwall_fccs.py @@ -158,10 +158,11 @@ def find_points(self): self.boolean_operations["cut"] = self.central_column_shield else: if isinstance(self.boolean_operations["cut"], Iterable): - self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] + self.boolean_operations["cut"] = [ + *self.boolean_operations["cut"], self.central_column_shield] else: - self.boolean_operations["cut"] = [*[self.boolean_operations["cut"]], self.central_column_shield] - + self.boolean_operations["cut"] = [ + *[self.boolean_operations["cut"]], self.central_column_shield] # add to cut attribute # if self.cut is None: From 5930dc5de040e4bf809b8c2f6e14655a3a786bb9 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 11:06:11 +0000 Subject: [PATCH 18/22] updated if else --- paramak/parametric_components/inboard_firstwall_fccs.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/paramak/parametric_components/inboard_firstwall_fccs.py b/paramak/parametric_components/inboard_firstwall_fccs.py index f3814aa98..bb159bb7f 100644 --- a/paramak/parametric_components/inboard_firstwall_fccs.py +++ b/paramak/parametric_components/inboard_firstwall_fccs.py @@ -156,11 +156,10 @@ def find_points(self): self.boolean_operations = {"cut": self.central_column_shield} elif "cut" not in self.boolean_operations: self.boolean_operations["cut"] = self.central_column_shield + elif isinstance(self.boolean_operations["cut"], Iterable): + self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] else: - if isinstance(self.boolean_operations["cut"], Iterable): - self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] - else: - self.boolean_operations["cut"] = [*[self.boolean_operations["cut"]], self.central_column_shield] + self.boolean_operations["cut"] = [*[self.boolean_operations["cut"]], self.central_column_shield] # add to cut attribute From e8f6e01884e791fa759f3fb64efd665e68d8299c Mon Sep 17 00:00:00 2001 From: autopep8 Date: Tue, 9 Mar 2021 11:07:47 +0000 Subject: [PATCH 19/22] Automated autopep8 fixes --- paramak/parametric_components/inboard_firstwall_fccs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/paramak/parametric_components/inboard_firstwall_fccs.py b/paramak/parametric_components/inboard_firstwall_fccs.py index 74560d172..1c1eb231a 100644 --- a/paramak/parametric_components/inboard_firstwall_fccs.py +++ b/paramak/parametric_components/inboard_firstwall_fccs.py @@ -157,9 +157,12 @@ def find_points(self): elif "cut" not in self.boolean_operations: self.boolean_operations["cut"] = self.central_column_shield elif isinstance(self.boolean_operations["cut"], Iterable): - self.boolean_operations["cut"] = [*self.boolean_operations["cut"], self.central_column_shield] + self.boolean_operations["cut"] = [ + *self.boolean_operations["cut"], + self.central_column_shield] else: - self.boolean_operations["cut"] = [*[self.boolean_operations["cut"]], self.central_column_shield] + self.boolean_operations["cut"] = [ + *[self.boolean_operations["cut"]], self.central_column_shield] # add to cut attribute # if self.cut is None: From 45c4303b487b42e73609c5f4e6bb3f06cf333966 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 11:19:11 +0000 Subject: [PATCH 20/22] fixed typo --- paramak/parametric_components/blanket_poloidal_segment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paramak/parametric_components/blanket_poloidal_segment.py b/paramak/parametric_components/blanket_poloidal_segment.py index 52f769f29..149dff82b 100644 --- a/paramak/parametric_components/blanket_poloidal_segment.py +++ b/paramak/parametric_components/blanket_poloidal_segment.py @@ -129,7 +129,7 @@ def create_segment_cutters(self): cutting_shape = RotateStraightShape( rotation_angle=self.rotation_angle, azimuth_placement_angle=self.azimuth_placement_angle, - boolean_operations={"union": []}) + boolean_operations={"cut": []}) # add points to the shape to avoid void solid cutting_shape.points = [ (self.major_radius, @@ -188,7 +188,7 @@ def create_segment_cutters(self): angle=np.pi / 2)] cutter.points = points_cutter # add cutter to global cutting shape - cutting_shape.boolean_operations["cut"].append(cutter) + cutting_shape.boolean_operations["union"].append(cutter) self.segments_cutters = cutting_shape From 8c1d7348b807d1c8a032cedd05b944045d2a97ae Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 11:21:15 +0000 Subject: [PATCH 21/22] using new boolean opeartions syntax --- .../test_PoloidallySegmentedBlanketFP.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_parametric_components/test_PoloidallySegmentedBlanketFP.py b/tests/test_parametric_components/test_PoloidallySegmentedBlanketFP.py index db18b4321..28fd98a1d 100644 --- a/tests/test_parametric_components/test_PoloidallySegmentedBlanketFP.py +++ b/tests/test_parametric_components/test_PoloidallySegmentedBlanketFP.py @@ -61,7 +61,7 @@ def test_modifying_nb_segments_limits(self): blanket2 = paramak.BlanketFPPoloidalSegments( thickness=20, start_angle=0, stop_angle=180, rotation_angle=180, - cut=blanket1) + boolean_operations={"cut": blanket1}) blanket1.nb_segments_limits = (4, 8) blanket2.nb_segments_limits = (3, 8) @@ -76,7 +76,7 @@ def test_segments_angles_is_modified_num_segments(self): blanket2 = paramak.BlanketFPPoloidalSegments( thickness=20, start_angle=0, stop_angle=180, rotation_angle=180, - cut=blanket1) + boolean_operations={"cut": blanket1}) blanket1.num_segments = 8 blanket2.num_segments = 5 @@ -97,7 +97,7 @@ def test_segment_angles_affects_solid(self): blanket2 = paramak.BlanketFPPoloidalSegments( thickness=20, start_angle=0, stop_angle=180, rotation_angle=180, - cut=blanket1) + boolean_operations={"cut": blanket1}) blanket2.segments_angles = [0, 25, 50, 90, 130, 150, 180] assert blanket2.volume != 0 From 5ba68698359606e4a2dbbc343d777105b997ffc3 Mon Sep 17 00:00:00 2001 From: billingsley-john Date: Tue, 9 Mar 2021 13:16:15 +0000 Subject: [PATCH 22/22] fixed typo --- paramak/parametric_components/blanket_poloidal_segment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paramak/parametric_components/blanket_poloidal_segment.py b/paramak/parametric_components/blanket_poloidal_segment.py index 149dff82b..45f305cf6 100644 --- a/paramak/parametric_components/blanket_poloidal_segment.py +++ b/paramak/parametric_components/blanket_poloidal_segment.py @@ -129,7 +129,7 @@ def create_segment_cutters(self): cutting_shape = RotateStraightShape( rotation_angle=self.rotation_angle, azimuth_placement_angle=self.azimuth_placement_angle, - boolean_operations={"cut": []}) + boolean_operations={"union": []}) # add points to the shape to avoid void solid cutting_shape.points = [ (self.major_radius,