From ebc36e7fccc1bede9a9ba5ba52968f0cc2f6c803 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 16 Mar 2022 12:33:48 +0000 Subject: [PATCH 1/4] [skip ci] added another animation style --- .../render_of_random_reactor_gif.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/example_parametric_reactors/render_of_random_reactor_gif.py b/examples/example_parametric_reactors/render_of_random_reactor_gif.py index 399f75c89..4b59313db 100644 --- a/examples/example_parametric_reactors/render_of_random_reactor_gif.py +++ b/examples/example_parametric_reactors/render_of_random_reactor_gif.py @@ -1,6 +1,7 @@ # This examples creates Gif animation of 50 reactors by creating individual # images of reactors and stiching them together using Imagemagick into a Gif -# animation. +# animation. Two animations are made, of of a 3D render and one of a wireframe +# line drawing. import math import os @@ -40,7 +41,15 @@ def create_reactor_renders( lower_vv_thickness=10, ) - # saves the reactor geometry as separate stl files + # exports line drawing of individual reactor + my_reactor.export_svg( + f"render_{str(render_number).zfill(3)}.svg", + projectionDir=[1, -1, -0.1], + strokeWidth=2, + ) + + # saves the reactor geometry as separate stl files that are later read in + # for the rendering my_reactor.export_stl() # assigns colours to each stl file @@ -103,5 +112,8 @@ def create_reactor_renders( blanket_vv_gap=np.random.uniform(low=10, high=90), ) -# saves the plot as a gif, the convert comand requires imagemagick -os.system("convert -delay 20 -loop 0 render_*.png reactors.gif") +# The convert comand requires imagemagick +# saves the rendered png files as a gif +os.system("convert -delay 40 -loop 0 render_*.png reactors.gif") +# saves the line drawing svg files as a gif +os.system("convert -delay 40 -loop 0 render_*.svg reactors.gif") From b27c818d80088dd318d38137f8a0bb9286cf93d2 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Wed, 16 Mar 2022 13:35:30 +0000 Subject: [PATCH 2/4] updated and reorganised animation scripts --- ...y => render_of_random_reactor_collarge.py} | 0 ...=> render_of_random_reactor_render_gif.py} | 9 -- ...ender_of_random_reactor_types_collarge.py} | 0 ..._random_reactor_wireframe_with_text_gif.py | 103 ++++++++++++++++++ 4 files changed, 103 insertions(+), 9 deletions(-) rename examples/example_parametric_reactors/{render_of_random_reactor.py => render_of_random_reactor_collarge.py} (100%) rename examples/example_parametric_reactors/{render_of_random_reactor_gif.py => render_of_random_reactor_render_gif.py} (92%) rename examples/example_parametric_reactors/{render_of_random_reactors.py => render_of_random_reactor_types_collarge.py} (100%) create mode 100644 examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py diff --git a/examples/example_parametric_reactors/render_of_random_reactor.py b/examples/example_parametric_reactors/render_of_random_reactor_collarge.py similarity index 100% rename from examples/example_parametric_reactors/render_of_random_reactor.py rename to examples/example_parametric_reactors/render_of_random_reactor_collarge.py diff --git a/examples/example_parametric_reactors/render_of_random_reactor_gif.py b/examples/example_parametric_reactors/render_of_random_reactor_render_gif.py similarity index 92% rename from examples/example_parametric_reactors/render_of_random_reactor_gif.py rename to examples/example_parametric_reactors/render_of_random_reactor_render_gif.py index 4b59313db..a30dfb06d 100644 --- a/examples/example_parametric_reactors/render_of_random_reactor_gif.py +++ b/examples/example_parametric_reactors/render_of_random_reactor_render_gif.py @@ -41,13 +41,6 @@ def create_reactor_renders( lower_vv_thickness=10, ) - # exports line drawing of individual reactor - my_reactor.export_svg( - f"render_{str(render_number).zfill(3)}.svg", - projectionDir=[1, -1, -0.1], - strokeWidth=2, - ) - # saves the reactor geometry as separate stl files that are later read in # for the rendering my_reactor.export_stl() @@ -115,5 +108,3 @@ def create_reactor_renders( # The convert comand requires imagemagick # saves the rendered png files as a gif os.system("convert -delay 40 -loop 0 render_*.png reactors.gif") -# saves the line drawing svg files as a gif -os.system("convert -delay 40 -loop 0 render_*.svg reactors.gif") diff --git a/examples/example_parametric_reactors/render_of_random_reactors.py b/examples/example_parametric_reactors/render_of_random_reactor_types_collarge.py similarity index 100% rename from examples/example_parametric_reactors/render_of_random_reactors.py rename to examples/example_parametric_reactors/render_of_random_reactor_types_collarge.py diff --git a/examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py b/examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py new file mode 100644 index 000000000..6819c82d8 --- /dev/null +++ b/examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py @@ -0,0 +1,103 @@ +# This examples creates Gif animation of 50 reactors by creating individual +# images of reactors and stiching them together using Imagemagick into a Gif +# animation. Two animations are made, of of a 3D render and one of a wireframe +# line drawing. + +import math +import os + +# to run this example you will need all of the following packages installed +import matplotlib.pyplot as plt +import numpy as np +import paramak + +import svgwrite # required to write text to svg file +import svgutils.transform as sg # required to merge text svg files with wireframe svg file + + +def create_reactor_renders( + render_number, + inner_blanket_radius, + blanket_thickness, + blanket_height, + lower_blanket_thickness, + upper_blanket_thickness, + blanket_vv_gap, + upper_vv_thickness=10, + vv_thickness=10, + lower_vv_thickness=10, +): + + # creates a reactor from the input arguments + my_reactor = paramak.FlfSystemCodeReactor( + rotation_angle=180, + inner_blanket_radius=inner_blanket_radius, + blanket_thickness=blanket_thickness, + blanket_height=blanket_height, + lower_blanket_thickness=lower_blanket_thickness, + upper_blanket_thickness=upper_blanket_thickness, + blanket_vv_gap=blanket_vv_gap, + upper_vv_thickness=upper_vv_thickness, + vv_thickness=vv_thickness, + lower_vv_thickness=lower_vv_thickness, + ) + + # exports line drawing of individual reactor + my_reactor.export_svg( + f"wireframe_{str(render_number).zfill(3)}.svg", + projectionDir=[1, -1, -0.1], + strokeWidth=2, + width=1000, + height=800, + ) + + svg_file_object = svgwrite.Drawing( + filename=f"text_{str(render_number).zfill(3)}.svg", + size=("1000px", "800px"), + ) + + lines_of_text_to_write = [ + "Parametric reactor inputs", + f"Inner blanket radius {inner_blanket_radius/100:.1f}m", + f"Blanket thickness {blanket_thickness/100:.1f}m", + f"Blanket thickness {blanket_thickness/100:.1f}m", + f"Blanket height {blanket_height/100:.1f}m", + f"Lower blanket thickness {lower_blanket_thickness/100:.1f}m", + f"Upper blanket thickness {upper_blanket_thickness/100:.1f}m", + f"Blanket vv gap {blanket_vv_gap/100:.1f}m", + f"Upper vv thickness {upper_vv_thickness/100:.1f}m", + f"Vv thickness {vv_thickness/100:.1f}m", + f"Lower vv thickness {lower_vv_thickness/100:.1f}m", + ] + y_value = 50 + for line in lines_of_text_to_write: + y_value = y_value + 40 + svg_file_object.add( + svg_file_object.text(line, insert=(555, y_value), font_size=27) + ) + svg_file_object.save() + + background = sg.fromfile(f"wireframe_{str(render_number).zfill(3)}.svg") + forground = sg.fromfile(f"text_{str(render_number).zfill(3)}.svg") + + root = forground.getroot() + background.append([root]) + + background.save(f"combined_{str(render_number).zfill(3)}.svg") + + +# loops through adding a random reactor render to the figure with each iteration +for i in range(50): + create_reactor_renders( + render_number=i, + inner_blanket_radius=np.random.uniform(low=50, high=90), + blanket_thickness=np.random.uniform(low=50, high=140), + blanket_height=np.random.uniform(low=400, high=550), + lower_blanket_thickness=np.random.uniform(low=20, high=70), + upper_blanket_thickness=np.random.uniform(low=20, high=70), + blanket_vv_gap=np.random.uniform(low=10, high=90), + ) + +# The convert comand requires imagemagick +# saves the line drawing svg files as a gif +os.system("convert -delay 40 -loop 0 combined_*.svg reactors_with_parameters.gif") From 4d63b3fdc436206ab7d075ef578544bf8ea2022e Mon Sep 17 00:00:00 2001 From: shimwell Date: Wed, 16 Mar 2022 13:36:31 +0000 Subject: [PATCH 3/4] [skip ci] Apply formatting changes --- .../render_of_random_reactor_collarge.py | 8 +- .../render_of_random_reactor_render_gif.py | 8 +- ...render_of_random_reactor_types_collarge.py | 16 +-- ..._random_reactor_wireframe_with_text_gif.py | 4 +- .../blanket_cutter_parallels.py | 7 +- .../blanket_cutters_star.py | 6 +- paramak/parametric_components/blanket_fp.py | 22 +-- .../blanket_poloidal_segment.py | 22 +-- .../capsule_vacuum_vessel.py | 18 +-- .../center_column_cylinder.py | 10 +- .../center_column_flat_top_hyperbola.py | 5 +- .../center_column_plasma_dependant.py | 5 +- .../parametric_components/cutting_wedge.py | 8 +- .../parametric_components/cutting_wedge_fs.py | 18 +-- .../parametric_components/divertor_ITER.py | 12 +- .../divertor_ITER_no_dome.py | 9 +- .../extrude_rectangle.py | 7 +- .../inner_tf_coils_circular.py | 16 +-- .../inner_tf_coils_flat.py | 51 ++----- .../poloidal_field_coil.py | 7 +- .../poloidal_field_coil_case_set.py | 20 +-- .../poloidal_field_coil_case_set_fc.py | 12 +- .../poloidal_field_coil_fp.py | 4 +- .../poloidal_field_coil_set.py | 16 +-- .../poloidal_segmenter.py | 12 +- .../port_cutters_rectangular.py | 4 +- .../port_cutters_rotated.py | 4 +- .../rotated_isosceles_triangle.py | 10 +- .../rotated_trapezoid.py | 11 +- .../parametric_components/tf_coil_casing.py | 22 +-- .../parametric_components/tokamak_plasma.py | 15 +- .../tokamak_plasma_from_points.py | 4 +- .../tokamak_plasma_plasmaboundaries.py | 4 +- .../toroidal_field_coil_coat_hanger.py | 13 +- .../toroidal_field_coil_rectangle.py | 5 +- .../toroidal_field_coil_round_corners.py | 41 ++---- .../toroidal_field_coil_triple_arc.py | 24 +--- .../parametric_components/vacuum_vessel.py | 4 +- .../vacuum_vessel_inner_leg.py | 14 +- paramak/parametric_reactors/ball_reactor.py | 91 +++--------- .../center_column_study_reactor.py | 59 +++----- .../eu_demo_2015_reactor.py | 8 +- .../flf_system_code_reactor.py | 34 ++--- .../parametric_reactors/iter_paper_2020.py | 4 +- .../negative_triangularity_reactor.py | 131 +++++------------- .../segmented_blanket_ball_reactor.py | 14 +- .../single_null_submersion_reactor.py | 13 +- .../parametric_reactors/sparc_paper_2020.py | 16 +-- .../parametric_reactors/submersion_reactor.py | 123 +++++----------- .../extruded_spline_shape.py | 8 +- .../extruded_straight_shape.py | 8 +- .../parametric_shapes/rotate_circle_shape.py | 6 +- .../parametric_shapes/rotate_spline_shape.py | 8 +- .../rotate_straight_shape.py | 8 +- .../parametric_shapes/sweep_circle_shape.py | 10 +- .../parametric_shapes/sweep_mixed_shape.py | 4 +- paramak/reactor.py | 31 +---- paramak/shape.py | 88 +++--------- paramak/utils.py | 56 ++------ tests/local_test_examples.py | 4 +- .../test_blanket_cutter_parallels.py | 5 +- .../test_blanket_fp.py | 4 +- .../test_capsule_vacuum_vessel.py | 29 +--- .../test_center_column_shield_cylinder.py | 27 +--- .../test_coolant_channel_ring_straight.py | 4 +- .../test_cutting_wedge_fs.py | 8 +- .../test_extrude_hollow_rectangle.py | 4 +- .../test_extrude_rectangle.py | 4 +- .../test_hexagon_pin.py | 9 +- .../test_inboard_firstwall_fccs.py | 48 ++----- .../test_parametric_components/test_plasma.py | 40 ++---- .../test_poloidal_field_coil.py | 4 +- .../test_poloidal_field_coil_case.py | 4 +- .../test_poloidal_field_coil_case_fc.py | 12 +- .../test_poloidal_field_coil_case_set.py | 12 +- .../test_poloidal_field_coil_case_set_fc.py | 36 ++--- .../test_poloidal_field_coil_set.py | 16 +-- .../test_poloidal_segments.py | 20 +-- .../test_poloidally_segmented_blanket_fp.py | 32 ++--- .../test_port_cutter_rectangular.py | 4 +- .../test_port_cutter_rotated.py | 4 +- .../test_shell_fs.py | 4 +- .../test_test_tf_coil_casing.py | 10 +- .../test_toroidal_field_coil_coat_hanger.py | 47 ++----- .../test_toroidal_field_coil_princetond.py | 8 +- .../test_toroidal_field_coil_rectangle.py | 36 ++--- ...oidal_field_coil_rectangle_round_corner.py | 8 +- .../test_toroidal_field_coil_triple_arc.py | 8 +- .../test_vacuum_vessel.py | 8 +- .../test_ball_reactor.py | 5 +- .../test_center_column_study_reactor.py | 13 +- .../test_eu_demo_2015_reactor.py | 4 +- .../test_flf_system_code_reactor.py | 9 +- .../test_iter_reactor.py | 4 +- .../test_single_null_submersion_tokamak.py | 8 +- .../test_submersion_tokamak.py | 5 +- .../test_extrude_circle_shape.py | 22 +-- .../test_extrude_mixed_shape.py | 14 +- .../test_extrude_spline_shape.py | 18 +-- .../test_extrude_straight_shape.py | 14 +- .../test_rotate_circle_shape.py | 28 +--- .../test_rotate_mixed_shape.py | 22 +-- .../test_rotate_spline_shape.py | 18 +-- .../test_rotate_straight_shape.py | 49 ++----- .../test_sweep_circle_shape.py | 33 +---- .../test_sweep_mixed_shape.py | 14 +- .../test_sweep_spline_shape.py | 14 +- .../test_sweep_straight_shape.py | 10 +- tests/test_reactor.py | 24 +--- tests/test_shape.py | 60 ++------ tests/test_utils.py | 8 +- tests_h5m/test_reactor_export_h5m.py | 17 +-- .../test_rotate_straight_shape_export_h5m.py | 19 +-- tests_show/test_reactor.py | 4 +- tests_show/test_shape.py | 4 +- 115 files changed, 495 insertions(+), 1622 deletions(-) diff --git a/examples/example_parametric_reactors/render_of_random_reactor_collarge.py b/examples/example_parametric_reactors/render_of_random_reactor_collarge.py index 84db26462..41500e370 100644 --- a/examples/example_parametric_reactors/render_of_random_reactor_collarge.py +++ b/examples/example_parametric_reactors/render_of_random_reactor_collarge.py @@ -61,15 +61,11 @@ def create_reactor_renders( render_mesh = pyrender.Mesh.from_trimesh(trimesh_obj, smooth=False) scene.add(render_mesh) - camera = pyrender.camera.PerspectiveCamera( - yfov=math.radians(90.0) # aspectRatio=2.0 could be added here - ) + camera = pyrender.camera.PerspectiveCamera(yfov=math.radians(90.0)) # aspectRatio=2.0 could be added here # sets the position of the camera using a matrix cam = 2**-0.5 - camera_pose = np.array( - [[1, 0, 0, 0], [0, cam, -cam, -350], [0, cam, cam, 350], [0, 0, 0, 1]] - ) + camera_pose = np.array([[1, 0, 0, 0], [0, cam, -cam, -350], [0, cam, cam, 350], [0, 0, 0, 1]]) # adds a camera and a point light source at the same location scene.add(camera, pose=camera_pose) diff --git a/examples/example_parametric_reactors/render_of_random_reactor_render_gif.py b/examples/example_parametric_reactors/render_of_random_reactor_render_gif.py index a30dfb06d..ffdb1ce27 100644 --- a/examples/example_parametric_reactors/render_of_random_reactor_render_gif.py +++ b/examples/example_parametric_reactors/render_of_random_reactor_render_gif.py @@ -66,15 +66,11 @@ def create_reactor_renders( render_mesh = pyrender.Mesh.from_trimesh(trimesh_obj, smooth=False) scene.add(render_mesh) - camera = pyrender.camera.PerspectiveCamera( - yfov=math.radians(90.0) # aspectRatio=2.0 could be added here - ) + camera = pyrender.camera.PerspectiveCamera(yfov=math.radians(90.0)) # aspectRatio=2.0 could be added here # sets the position of the camera using a matrix cam = 2**-0.5 - camera_pose = np.array( - [[1, 0, 0, 0], [0, cam, -cam, -350], [0, cam, cam, 350], [0, 0, 0, 1]] - ) + camera_pose = np.array([[1, 0, 0, 0], [0, cam, -cam, -350], [0, cam, cam, 350], [0, 0, 0, 1]]) # adds a camera and a point light source at the same location scene.add(camera, pose=camera_pose) diff --git a/examples/example_parametric_reactors/render_of_random_reactor_types_collarge.py b/examples/example_parametric_reactors/render_of_random_reactor_types_collarge.py index 5cc32bb87..710458a99 100644 --- a/examples/example_parametric_reactors/render_of_random_reactor_types_collarge.py +++ b/examples/example_parametric_reactors/render_of_random_reactor_types_collarge.py @@ -52,16 +52,12 @@ def generate_random_reactor(): if input_arg in my_reactor.__dict__: if isinstance(my_reactor.__dict__[input_arg], float): rand_scale = random.uniform(0.8, 1.2) - setattr( - my_reactor, input_arg, my_reactor.__dict__[input_arg] * rand_scale - ) + setattr(my_reactor, input_arg, my_reactor.__dict__[input_arg] * rand_scale) return my_reactor -def create_reactor_renders( - render_number, number_of_images_in_x, number_of_images_in_y, reactor -): +def create_reactor_renders(render_number, number_of_images_in_x, number_of_images_in_y, reactor): # saves the reactor geometry as separate stl files reactor.export_stl() @@ -78,15 +74,11 @@ def create_reactor_renders( render_mesh = pyrender.Mesh.from_trimesh(trimesh_obj, smooth=False) scene.add(render_mesh) - camera = pyrender.camera.PerspectiveCamera( - yfov=math.radians(90.0) # aspectRatio=2.0 could be added here - ) + camera = pyrender.camera.PerspectiveCamera(yfov=math.radians(90.0)) # aspectRatio=2.0 could be added here # sets the position of the camera using a matrix cam = 2**-0.5 - camera_pose = np.array( - [[1, 0, 0, 0], [0, cam, -cam, -650], [0, cam, cam, 650], [0, 0, 0, 1]] - ) + camera_pose = np.array([[1, 0, 0, 0], [0, cam, -cam, -650], [0, cam, cam, 650], [0, 0, 0, 1]]) # adds a camera and a point light source at the same location scene.add(camera, pose=camera_pose) diff --git a/examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py b/examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py index 6819c82d8..4640e028c 100644 --- a/examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py +++ b/examples/example_parametric_reactors/render_of_random_reactor_wireframe_with_text_gif.py @@ -72,9 +72,7 @@ def create_reactor_renders( y_value = 50 for line in lines_of_text_to_write: y_value = y_value + 40 - svg_file_object.add( - svg_file_object.text(line, insert=(555, y_value), font_size=27) - ) + svg_file_object.add(svg_file_object.text(line, insert=(555, y_value), font_size=27)) svg_file_object.save() background = sg.fromfile(f"wireframe_{str(render_number).zfill(3)}.svg") diff --git a/paramak/parametric_components/blanket_cutter_parallels.py b/paramak/parametric_components/blanket_cutter_parallels.py index 9fd950371..cc678125e 100644 --- a/paramak/parametric_components/blanket_cutter_parallels.py +++ b/paramak/parametric_components/blanket_cutter_parallels.py @@ -50,12 +50,7 @@ def __init__( ) self.gap_size = gap_size self.thickness = thickness - super().__init__( - distance=self.distance, - azimuth_placement_angle=azimuth_placement_angle, - name=name, - **kwargs - ) + super().__init__(distance=self.distance, azimuth_placement_angle=azimuth_placement_angle, name=name, **kwargs) self.height = height self.width = width diff --git a/paramak/parametric_components/blanket_cutters_star.py b/paramak/parametric_components/blanket_cutters_star.py index 9ffad18cc..8c6c9a5af 100644 --- a/paramak/parametric_components/blanket_cutters_star.py +++ b/paramak/parametric_components/blanket_cutters_star.py @@ -42,11 +42,7 @@ def __init__( ) -> None: super().__init__( - extrude_both=True, - name=name, - azimuth_placement_angle=azimuth_placement_angle, - distance=distance, - **kwargs + extrude_both=True, name=name, azimuth_placement_angle=azimuth_placement_angle, distance=distance, **kwargs ) self.azimuth_placement_angle = azimuth_placement_angle diff --git a/paramak/parametric_components/blanket_fp.py b/paramak/parametric_components/blanket_fp.py index 5a8210e5d..3017a853c 100644 --- a/paramak/parametric_components/blanket_fp.py +++ b/paramak/parametric_components/blanket_fp.py @@ -46,9 +46,7 @@ def __init__( thickness, start_angle: float, stop_angle: float, - plasma: Optional[ - Union[paramak.Plasma, paramak.PlasmaBoundaries, paramak.PlasmaFromPoints] - ] = None, + plasma: Optional[Union[paramak.Plasma, paramak.PlasmaBoundaries, paramak.PlasmaFromPoints]] = None, minor_radius: Optional[float] = 150.0, major_radius: Optional[float] = 450.0, triangularity: Optional[float] = 0.55, @@ -155,9 +153,7 @@ def make_callable(self, attribute): else: # no list of angles is given offset_values = attribute - list_of_angles = np.linspace( - self.start_angle, self.stop_angle, len(offset_values), endpoint=True - ) + list_of_angles = np.linspace(self.start_angle, self.stop_angle, len(offset_values), endpoint=True) interpolated_values = interp1d(list_of_angles, offset_values) def fun(theta): @@ -202,10 +198,7 @@ def outer_offset(theta): # assemble points = inner_points + outer_points if self._overlapping_shape and self.allow_overlapping_shape is False: - msg = ( - "BlanketFP: Some points with negative R coordinate have " - "been ignored." - ) + msg = "BlanketFP: Some points with negative R coordinate have " "been ignored." warnings.warn(msg) self.points = points @@ -273,11 +266,6 @@ def distribution(self, theta, pkg=np): theta = np.radians(theta) else: theta = mpmath.radians(theta) - R = self.major_radius + self.minor_radius * pkg.cos( - theta + self.triangularity * pkg.sin(theta) - ) - Z = ( - self.elongation * self.minor_radius * pkg.sin(theta) - + self.vertical_displacement - ) + R = self.major_radius + self.minor_radius * pkg.cos(theta + self.triangularity * pkg.sin(theta)) + Z = self.elongation * self.minor_radius * pkg.sin(theta) + self.vertical_displacement return R, Z diff --git a/paramak/parametric_components/blanket_poloidal_segment.py b/paramak/parametric_components/blanket_poloidal_segment.py index f8cee6cba..e1691d8ee 100644 --- a/paramak/parametric_components/blanket_poloidal_segment.py +++ b/paramak/parametric_components/blanket_poloidal_segment.py @@ -53,16 +53,10 @@ def segments_angles(self): def segments_angles(self, value): if value is not None: if self.start_angle is not None or self.stop_angle is not None: - msg = ( - "start_angle and stop_angle attributes will be " - + "ignored if segments_angles is not None" - ) + msg = "start_angle and stop_angle attributes will be " + "ignored if segments_angles is not None" warnings.warn(msg) elif self.num_segments is not None: - msg = ( - "num_segment attribute will be ignored if " - + "segments_angles is not None" - ) + msg = "num_segment attribute will be ignored if " + "segments_angles is not None" warnings.warn(msg) self._segments_angles = value @@ -100,9 +94,7 @@ def get_angles(self): stop_on_success=True, ) elif self.segments_angles is None: - angles = np.linspace( - self.start_angle, self.stop_angle, num=self.num_segments + 1 - ) + angles = np.linspace(self.start_angle, self.stop_angle, num=self.num_segments + 1) else: angles = self.segments_angles return angles @@ -152,9 +144,7 @@ def create_segment_cutters(self): ] # Create cutters for each gap - for inner_point, outer_point in zip( - self.inner_points[:-1], self.outer_points[-1::-1] - ): + for inner_point, outer_point in zip(self.inner_points[:-1], self.outer_points[-1::-1]): # initialise cutter for gap cutter = RotateStraightShape( rotation_angle=self.rotation_angle, @@ -205,9 +195,7 @@ def compute_lengths_from_angles(angles: List[float], distribution: Callable): return lengths -def segments_optimiser( - length_limits, nb_segments_limits, distribution, angles, stop_on_success=True -): +def segments_optimiser(length_limits, nb_segments_limits, distribution, angles, stop_on_success=True): """Optimiser segmenting a given R(theta), Z(theta) distribution of points with constraints regarding the number of segments and the length of the segments. diff --git a/paramak/parametric_components/capsule_vacuum_vessel.py b/paramak/parametric_components/capsule_vacuum_vessel.py index cbafff49d..bc77bfa2a 100644 --- a/paramak/parametric_components/capsule_vacuum_vessel.py +++ b/paramak/parametric_components/capsule_vacuum_vessel.py @@ -38,9 +38,7 @@ def radius(self, value): if not isinstance(value, (float, int)): raise ValueError("VacuumVessel.radius must be a number. Not", value) if value <= 0: - msg = ( - "VacuumVessel.radius must be a positive number above 0. " f"Not {value}" - ) + msg = "VacuumVessel.radius must be a positive number above 0. " f"Not {value}" raise ValueError(msg) self._radius = value @@ -54,9 +52,7 @@ def thickness(self, value): msg = f"VacuumVessel.thickness must be a number. Not {value}" raise ValueError(msg) if value <= 0: - msg = ( - f"VacuumVessel.thickness must be a positive number above 0. Not {value}" - ) + msg = f"VacuumVessel.thickness must be a positive number above 0. Not {value}" raise ValueError(msg) self._thickness = value @@ -72,15 +68,7 @@ def find_points(self): top_outer_y = bottom_outer_y + (4 * radius) top_outer_x = bottom_outer_x inner_r = radius - thickness - ( - bottom_outer_x, - bottom_outer_y, - thickness, - radius, - top_outer_x, - top_outer_y, - inner_r, - ) = ( + (bottom_outer_x, bottom_outer_y, thickness, radius, top_outer_x, top_outer_y, inner_r,) = ( float(bottom_outer_x), float(bottom_outer_y), float(thickness), diff --git a/paramak/parametric_components/center_column_cylinder.py b/paramak/parametric_components/center_column_cylinder.py index 710ee17db..3db8eddf6 100644 --- a/paramak/parametric_components/center_column_cylinder.py +++ b/paramak/parametric_components/center_column_cylinder.py @@ -65,10 +65,7 @@ def inner_radius(self): def inner_radius(self, value): if hasattr(self, "outer_radius"): if value >= self.outer_radius: - msg = ( - f"inner_radius ({value}) is larger than outer_radius " - "({self.outer_radius})" - ) + msg = f"inner_radius ({value}) is larger than outer_radius " "({self.outer_radius})" raise ValueError(msg) self._inner_radius = value @@ -80,10 +77,7 @@ def outer_radius(self): def outer_radius(self, value): if hasattr(self, "inner_radius"): if value <= self.inner_radius: - msg = ( - f"inner_radius ({self.inner_radius}) is larger than " - "outer_radius ({value})" - ) + msg = f"inner_radius ({self.inner_radius}) is larger than " "outer_radius ({value})" raise ValueError(msg) self._outer_radius = value diff --git a/paramak/parametric_components/center_column_flat_top_hyperbola.py b/paramak/parametric_components/center_column_flat_top_hyperbola.py index 5057f1643..66c07357d 100644 --- a/paramak/parametric_components/center_column_flat_top_hyperbola.py +++ b/paramak/parametric_components/center_column_flat_top_hyperbola.py @@ -94,10 +94,7 @@ def find_points(self): ) if self.arc_height >= self.height: - msg = ( - "arc_height ({self.arc_height}) is larger than height " - "({self.height})" - ) + msg = "arc_height ({self.arc_height}) is larger than height " "({self.height})" raise ValueError(msg) points = [ diff --git a/paramak/parametric_components/center_column_plasma_dependant.py b/paramak/parametric_components/center_column_plasma_dependant.py index e1d2be60c..03027a68e 100644 --- a/paramak/parametric_components/center_column_plasma_dependant.py +++ b/paramak/parametric_components/center_column_plasma_dependant.py @@ -125,10 +125,7 @@ def find_points(self): plasma_height = abs(plasma.high_point[1]) + abs(plasma.low_point[1]) if self.height <= plasma_height: - msg = ( - f"Center column height ({self.height}) is smaller than " - "plasma height ({plasma_height}" - ) + msg = f"Center column height ({self.height}) is smaller than " "plasma height ({plasma_height}" raise ValueError(msg) if self.inner_radius >= plasma.inner_equatorial_point[0] - self.mid_offset: diff --git a/paramak/parametric_components/cutting_wedge.py b/paramak/parametric_components/cutting_wedge.py index 3ac93e4c3..865a62bbc 100644 --- a/paramak/parametric_components/cutting_wedge.py +++ b/paramak/parametric_components/cutting_wedge.py @@ -13,13 +13,7 @@ class CuttingWedge(RotateStraightShape): rotation_angle: Defaults to 180.0. """ - def __init__( - self, - height: float, - radius: float, - rotation_angle: Optional[float] = 180.0, - **kwargs - ) -> None: + def __init__(self, height: float, radius: float, rotation_angle: Optional[float] = 180.0, **kwargs) -> None: super().__init__(rotation_angle=rotation_angle, **kwargs) diff --git a/paramak/parametric_components/cutting_wedge_fs.py b/paramak/parametric_components/cutting_wedge_fs.py index 71e9e62eb..f732e8850 100644 --- a/paramak/parametric_components/cutting_wedge_fs.py +++ b/paramak/parametric_components/cutting_wedge_fs.py @@ -26,10 +26,7 @@ def shape(self): @shape.setter def shape(self, value): if value.rotation_angle == 360: - msg = ( - "cutting_wedge cannot be created, rotation_angle must be " - "less than 360 degrees" - ) + msg = "cutting_wedge cannot be created, rotation_angle must be " "less than 360 degrees" raise ValueError(msg) self._shape = value @@ -87,9 +84,7 @@ def azimuth_placement_angle(self): if isinstance(self.shape.azimuth_placement_angle, Iterable): self.azimuth_placement_angle = self.shape.rotation_angle else: - self.azimuth_placement_angle = ( - self.shape.azimuth_placement_angle + self.shape.rotation_angle - ) + self.azimuth_placement_angle = self.shape.azimuth_placement_angle + self.shape.rotation_angle return self._azimuth_placement_angle @azimuth_placement_angle.setter @@ -99,10 +94,7 @@ def azimuth_placement_angle(self, value): def find_radius_height(self): shape = self.shape if shape.rotation_angle == 360: - msg = ( - "cutting_wedge cannot be created, rotation_angle must be " - "less than 360 degrees" - ) + msg = "cutting_wedge cannot be created, rotation_angle must be " "less than 360 degrees" raise ValueError(msg) shape_points = shape.points if hasattr(shape, "radius") and len(shape_points) == 1: @@ -111,9 +103,7 @@ def find_radius_height(self): elif len(shape_points) > 1: max_x = max(shape_points, key=itemgetter(0))[0] - if shape.get_rotation_axis()[1] not in shape.workplane and hasattr( - shape, "distance" - ): + if shape.get_rotation_axis()[1] not in shape.workplane and hasattr(shape, "distance"): max_y = shape.distance else: max_y = max(shape_points, key=itemgetter(1))[1] diff --git a/paramak/parametric_components/divertor_ITER.py b/paramak/parametric_components/divertor_ITER.py index ab1dc54ab..d9a19845f 100644 --- a/paramak/parametric_components/divertor_ITER.py +++ b/paramak/parametric_components/divertor_ITER.py @@ -98,9 +98,7 @@ def _create_vertical_target_points(self, anchor, coverage, tilt, radius, length) points.append([c_coord[0], c_coord[1]]) return points - def _create_dome_points( - self, c_coord, F, dome_length, dome_height, dome_thickness, dome_pos - ): + def _create_dome_points(self, c_coord, F, dome_length, dome_height, dome_thickness, dome_pos): """Creates a list of points for the dome alongside with their connectivity @@ -118,12 +116,8 @@ def _create_dome_points( """ points = [] - dome_base = extend( - c_coord, F, dome_pos * distance_between_two_points(F, c_coord) - ) - dome_lower_point = extend( - dome_base, rotate(dome_base, c_coord, -math.pi / 2), dome_height - ) + dome_base = extend(c_coord, F, dome_pos * distance_between_two_points(F, c_coord)) + dome_lower_point = extend(dome_base, rotate(dome_base, c_coord, -math.pi / 2), dome_height) d_prime = extend(dome_base, dome_lower_point, dome_height + dome_thickness) D = extend( diff --git a/paramak/parametric_components/divertor_ITER_no_dome.py b/paramak/parametric_components/divertor_ITER_no_dome.py index 6311db253..1994c6dbb 100644 --- a/paramak/parametric_components/divertor_ITER_no_dome.py +++ b/paramak/parametric_components/divertor_ITER_no_dome.py @@ -6,11 +6,4 @@ class ITERtypeDivertorNoDome(ITERtypeDivertor): def __init__(self, **kwargs): - super().__init__( - dome=False, - dome_height=None, - dome_length=None, - dome_thickness=None, - dome_pos=None, - **kwargs - ) + super().__init__(dome=False, dome_height=None, dome_length=None, dome_thickness=None, dome_pos=None, **kwargs) diff --git a/paramak/parametric_components/extrude_rectangle.py b/paramak/parametric_components/extrude_rectangle.py index 07b146746..e01da021a 100644 --- a/paramak/parametric_components/extrude_rectangle.py +++ b/paramak/parametric_components/extrude_rectangle.py @@ -14,12 +14,7 @@ class ExtrudeRectangle(ExtrudeStraightShape): """ def __init__( - self, - height: float, - width: float, - center_point: Tuple[float, float], - name: str = "extrude_rectangle", - **kwargs + self, height: float, width: float, center_point: Tuple[float, float], name: str = "extrude_rectangle", **kwargs ) -> None: super().__init__(name=name, **kwargs) diff --git a/paramak/parametric_components/inner_tf_coils_circular.py b/paramak/parametric_components/inner_tf_coils_circular.py index af0d69ecd..12e65cd6d 100644 --- a/paramak/parametric_components/inner_tf_coils_circular.py +++ b/paramak/parametric_components/inner_tf_coils_circular.py @@ -34,9 +34,7 @@ def __init__( **kwargs ) -> None: - super().__init__( - distance=height, workplane=workplane, rotation_axis=rotation_axis, **kwargs - ) + super().__init__(distance=height, workplane=workplane, rotation_axis=rotation_axis, **kwargs) self.azimuth_start_angle = azimuth_start_angle self.height = height @@ -117,14 +115,14 @@ def find_points(self): if self.gap_size * self.number_of_coils > 2 * math.pi * self.inner_radius: raise ValueError("gap_size is too large") - theta_inner = ( - (2 * math.pi * self.inner_radius) - (self.gap_size * self.number_of_coils) - ) / (self.inner_radius * self.number_of_coils) + theta_inner = ((2 * math.pi * self.inner_radius) - (self.gap_size * self.number_of_coils)) / ( + self.inner_radius * self.number_of_coils + ) omega_inner = math.asin(self.gap_size / (2 * self.inner_radius)) - theta_outer = ( - (2 * math.pi * self.outer_radius) - (self.gap_size * self.number_of_coils) - ) / (self.outer_radius * self.number_of_coils) + theta_outer = ((2 * math.pi * self.outer_radius) - (self.gap_size * self.number_of_coils)) / ( + self.outer_radius * self.number_of_coils + ) omega_outer = math.asin(self.gap_size / (2 * self.outer_radius)) # inner points diff --git a/paramak/parametric_components/inner_tf_coils_flat.py b/paramak/parametric_components/inner_tf_coils_flat.py index d15f359ae..b38624bec 100644 --- a/paramak/parametric_components/inner_tf_coils_flat.py +++ b/paramak/parametric_components/inner_tf_coils_flat.py @@ -42,9 +42,7 @@ def __init__( **kwargs, ) -> None: - super().__init__( - distance=height, workplane=workplane, rotation_axis=rotation_axis, **kwargs - ) + super().__init__(distance=height, workplane=workplane, rotation_axis=rotation_axis, **kwargs) self.azimuth_start_angle = azimuth_start_angle self.height = height @@ -159,10 +157,7 @@ def find_points(self): distance_to_inner_corner = self.inner_radius / math.cos(math.radians(angle)) distance_to_rear_corner = self.outer_radius / math.cos(math.radians(angle)) - if ( - self.gap_size * self.number_of_coils - > 2 * math.pi * distance_to_inner_corner - ): + if self.gap_size * self.number_of_coils > 2 * math.pi * distance_to_inner_corner: msg = ( "Gap_size is too large. The gap_size * number of coils must " "be less than the circumference of the circle made by " @@ -171,10 +166,9 @@ def find_points(self): raise ValueError(msg) if distance_to_inner_corner != 0.0: - theta_inner = ( - (2 * math.pi * distance_to_inner_corner) - - (self.gap_size * self.number_of_coils) - ) / (distance_to_inner_corner * self.number_of_coils) + theta_inner = ((2 * math.pi * distance_to_inner_corner) - (self.gap_size * self.number_of_coils)) / ( + distance_to_inner_corner * self.number_of_coils + ) omega_inner = math.asin(self.gap_size / (2 * distance_to_inner_corner)) # inner points @@ -184,20 +178,12 @@ def find_points(self): ) point_2 = ( ( - distance_to_inner_corner - * math.cos(theta_inner) - * math.cos(-omega_inner) - + distance_to_inner_corner - * math.sin(theta_inner) - * math.sin(-omega_inner) + distance_to_inner_corner * math.cos(theta_inner) * math.cos(-omega_inner) + + distance_to_inner_corner * math.sin(theta_inner) * math.sin(-omega_inner) ), ( - -distance_to_inner_corner - * math.cos(theta_inner) - * math.sin(-omega_inner) - + distance_to_inner_corner - * math.sin(theta_inner) - * math.cos(-omega_inner) + -distance_to_inner_corner * math.cos(theta_inner) * math.sin(-omega_inner) + + distance_to_inner_corner * math.sin(theta_inner) * math.cos(-omega_inner) ), ) points = [(point_1[0], point_1[1]), (point_2[0], point_2[1])] @@ -209,10 +195,9 @@ def find_points(self): # print(point_1) # print(point_2) - theta_outer = ( - (2 * math.pi * distance_to_rear_corner) - - (self.gap_size * self.number_of_coils) - ) / (distance_to_rear_corner * self.number_of_coils) + theta_outer = ((2 * math.pi * distance_to_rear_corner) - (self.gap_size * self.number_of_coils)) / ( + distance_to_rear_corner * self.number_of_coils + ) omega_outer = math.asin(self.gap_size / (2 * distance_to_rear_corner)) # outer points @@ -223,17 +208,11 @@ def find_points(self): point_6 = ( ( distance_to_rear_corner * math.cos(theta_outer) * math.cos(-omega_outer) - + distance_to_rear_corner - * math.sin(theta_outer) - * math.sin(-omega_outer) + + distance_to_rear_corner * math.sin(theta_outer) * math.sin(-omega_outer) ), ( - -distance_to_rear_corner - * math.cos(theta_outer) - * math.sin(-omega_outer) - + distance_to_rear_corner - * math.sin(theta_outer) - * math.cos(-omega_outer) + -distance_to_rear_corner * math.cos(theta_outer) * math.sin(-omega_outer) + + distance_to_rear_corner * math.sin(theta_outer) * math.cos(-omega_outer) ), ) points.append((point_6[0], point_6[1])) diff --git a/paramak/parametric_components/poloidal_field_coil.py b/paramak/parametric_components/poloidal_field_coil.py index 361d7de04..545450545 100644 --- a/paramak/parametric_components/poloidal_field_coil.py +++ b/paramak/parametric_components/poloidal_field_coil.py @@ -14,12 +14,7 @@ class PoloidalFieldCoil(RotateStraightShape): """ def __init__( - self, - height: float, - width: float, - center_point: Tuple[float, float], - name: str = "pf_coil", - **kwargs + self, height: float, width: float, center_point: Tuple[float, float], name: str = "pf_coil", **kwargs ) -> None: super().__init__(name=name, **kwargs) diff --git a/paramak/parametric_components/poloidal_field_coil_case_set.py b/paramak/parametric_components/poloidal_field_coil_case_set.py index e1bf9e2ec..b078afba8 100644 --- a/paramak/parametric_components/poloidal_field_coil_case_set.py +++ b/paramak/parametric_components/poloidal_field_coil_case_set.py @@ -72,14 +72,10 @@ def casing_thicknesses(self): def casing_thicknesses(self, value): if isinstance(value, list): if not all(isinstance(x, (int, float)) for x in value): - raise ValueError( - "Every entry in Casing_thicknesses must be a float or int" - ) + raise ValueError("Every entry in Casing_thicknesses must be a float or int") else: if not isinstance(value, (float, int)): - raise ValueError( - "Casing_thicknesses must be a list of numbers or a number" - ) + raise ValueError("Casing_thicknesses must be a list of numbers or a number") self._casing_thicknesses = value def find_points(self): @@ -93,16 +89,8 @@ def find_points(self): else: casing_thicknesses_list = [self.casing_thicknesses] * len(self.widths) - if ( - not len(self.heights) - == len(self.widths) - == len(self.center_points) - == len(casing_thicknesses_list) - ): - raise ValueError( - "The number of heights, widths, center_points and " - "casing_thicknesses must be equal" - ) + if not len(self.heights) == len(self.widths) == len(self.center_points) == len(casing_thicknesses_list): + raise ValueError("The number of heights, widths, center_points and " "casing_thicknesses must be equal") for height, width, center_point, casing_thickness in zip( self.heights, self.widths, self.center_points, casing_thicknesses_list diff --git a/paramak/parametric_components/poloidal_field_coil_case_set_fc.py b/paramak/parametric_components/poloidal_field_coil_case_set_fc.py index f4350ab93..038d55c8c 100644 --- a/paramak/parametric_components/poloidal_field_coil_case_set_fc.py +++ b/paramak/parametric_components/poloidal_field_coil_case_set_fc.py @@ -45,14 +45,10 @@ def casing_thicknesses(self): def casing_thicknesses(self, value): if isinstance(value, list): if not all(isinstance(x, (int, float)) for x in value): - raise ValueError( - "Every entry in Casing_thicknesses must be a float or int" - ) + raise ValueError("Every entry in Casing_thicknesses must be a float or int") else: if not isinstance(value, (float, int)): - raise ValueError( - "Casing_thicknesses must be a list of numbers or a number" - ) + raise ValueError("Casing_thicknesses must be a list of numbers or a number") self._casing_thicknesses = value @property @@ -90,9 +86,7 @@ def find_points(self): if isinstance(self.casing_thicknesses, list): if len(self.casing_thicknesses) != num_of_coils: raise ValueError( - "The number pf_coils is not equal to the " - "number of thichnesses provided. " - "casing_thicknesses=", + "The number pf_coils is not equal to the " "number of thichnesses provided. " "casing_thicknesses=", self.casing_thicknesses, "num_of_coils=", num_of_coils, diff --git a/paramak/parametric_components/poloidal_field_coil_fp.py b/paramak/parametric_components/poloidal_field_coil_fp.py index 8ebb6685b..fe1a2cfd4 100644 --- a/paramak/parametric_components/poloidal_field_coil_fp.py +++ b/paramak/parametric_components/poloidal_field_coil_fp.py @@ -18,9 +18,7 @@ def __init__(self, corner_points, **kwargs): center_height = (corner_points[0][1] + corner_points[1][1]) / 2.0 center_point = (center_width, center_height) - super().__init__( - height=height, width=width, center_point=center_point, **kwargs - ) + super().__init__(height=height, width=width, center_point=center_point, **kwargs) self.corner_points = corner_points diff --git a/paramak/parametric_components/poloidal_field_coil_set.py b/paramak/parametric_components/poloidal_field_coil_set.py index aafe64701..1586eedfd 100644 --- a/paramak/parametric_components/poloidal_field_coil_set.py +++ b/paramak/parametric_components/poloidal_field_coil_set.py @@ -24,9 +24,7 @@ def __init__(self, heights, widths, center_points, name="pf_coil", **kwargs): self.heights = heights self.widths = widths - if len(self.widths) != len(self.heights) or len(self.heights) != len( - self.center_points - ): + if len(self.widths) != len(self.heights) or len(self.heights) != len(self.center_points): raise ValueError( "The length of widthts, height and center_points \ must be the same when making a PoloidalFieldCoilSet" @@ -68,9 +66,7 @@ def find_points(self): all_points = [] - for height, width, center_point in zip( - self.heights, self.widths, self.center_points - ): + for height, width, center_point in zip(self.heights, self.widths, self.center_points): all_points = all_points + [ ( @@ -106,13 +102,9 @@ def create_solid(self): iter_points = iter(self.points) pf_coils_set = [] wires = [] - for point_1, point_2, point_3, point_4 in zip( - iter_points, iter_points, iter_points, iter_points - ): + for point_1, point_2, point_3, point_4 in zip(iter_points, iter_points, iter_points, iter_points): - solid = cq.Workplane(self.workplane).polyline( - [point_1[:2], point_2[:2], point_3[:2], point_4[:2]] - ) + solid = cq.Workplane(self.workplane).polyline([point_1[:2], point_2[:2], point_3[:2], point_4[:2]]) wire = solid.close() diff --git a/paramak/parametric_components/poloidal_segmenter.py b/paramak/parametric_components/poloidal_segmenter.py index ec5607fee..02af748f8 100644 --- a/paramak/parametric_components/poloidal_segmenter.py +++ b/paramak/parametric_components/poloidal_segmenter.py @@ -50,9 +50,7 @@ def number_of_segments(self, value): if isinstance(value, int) is False: raise TypeError("PoloidalSegmenter.number_of_segments must be an int.") if value < 1: - raise ValueError( - "PoloidalSegmenter.number_of_segments must be a minimum of 1." - ) + raise ValueError("PoloidalSegmenter.number_of_segments must be a minimum of 1.") self._number_of_segments = value @property @@ -97,9 +95,7 @@ def find_points(self): points.append(self.center_point) - outer_point_1 = rotate( - self.center_point, outer_point, math.radians(current_angle) - ) + outer_point_1 = rotate(self.center_point, outer_point, math.radians(current_angle)) outer_point_2 = rotate( self.center_point, @@ -110,9 +106,7 @@ def find_points(self): # if the point goes beyond the zero line then set to zero for new_point in [outer_point_1, outer_point_2]: if new_point[0] < 0: - m, c = coefficients_of_line_from_points( - new_point, self.center_point - ) + m, c = coefficients_of_line_from_points(new_point, self.center_point) points.append((0, c)) else: points.append(new_point) diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 9c277dd9a..31d0fa284 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -66,9 +66,7 @@ def find_points(self): (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 - ] + points = [(e[0] + self.center_point[0], e[1] + self.center_point[1]) for e in points] self.points = points diff --git a/paramak/parametric_components/port_cutters_rotated.py b/paramak/parametric_components/port_cutters_rotated.py index 28a201983..d157dc89a 100644 --- a/paramak/parametric_components/port_cutters_rotated.py +++ b/paramak/parametric_components/port_cutters_rotated.py @@ -85,9 +85,7 @@ def find_points(self): self.center_point[1], ) - outer_point_rotated = rotate( - self.center_point, outer_point, math.radians(self.polar_placement_angle) - ) + outer_point_rotated = rotate(self.center_point, outer_point, math.radians(self.polar_placement_angle)) outer_point_1 = rotate( self.center_point, diff --git a/paramak/parametric_components/rotated_isosceles_triangle.py b/paramak/parametric_components/rotated_isosceles_triangle.py index 2c0e7e296..44a32cc66 100644 --- a/paramak/parametric_components/rotated_isosceles_triangle.py +++ b/paramak/parametric_components/rotated_isosceles_triangle.py @@ -17,15 +17,7 @@ class RotatedIsoscelesTriangle(RotateStraightShape): name (str, optional): defaults to "rotated_triangle". """ - def __init__( - self, - base_length, - height, - pivot_point, - pivot_angle=0.0, - name="rotated_triangle", - **kwargs - ): + def __init__(self, base_length, height, pivot_point, pivot_angle=0.0, name="rotated_triangle", **kwargs): super().__init__(name=name, **kwargs) diff --git a/paramak/parametric_components/rotated_trapezoid.py b/paramak/parametric_components/rotated_trapezoid.py index 5a48e33b9..25b6524f9 100644 --- a/paramak/parametric_components/rotated_trapezoid.py +++ b/paramak/parametric_components/rotated_trapezoid.py @@ -22,16 +22,7 @@ class RotatedTrapezoid(RotateStraightShape): name (str, optional): defaults to "rotated_trapezoid". """ - def __init__( - self, - length_1, - length_2, - length_3, - pivot_point, - pivot_angle=0.0, - name="rotated_trapezoid", - **kwargs - ): + def __init__(self, length_1, length_2, length_3, pivot_point, pivot_angle=0.0, name="rotated_trapezoid", **kwargs): super().__init__(name=name, **kwargs) diff --git a/paramak/parametric_components/tf_coil_casing.py b/paramak/parametric_components/tf_coil_casing.py index 265f49a3c..4dd4ac40f 100644 --- a/paramak/parametric_components/tf_coil_casing.py +++ b/paramak/parametric_components/tf_coil_casing.py @@ -19,12 +19,7 @@ class TFCoilCasing(ExtrudeMixedShape): """ def __init__( - self, - magnet, - inner_offset: float, - outer_offset: float, - vertical_section_offset: float, - **kwargs + self, magnet, inner_offset: float, outer_offset: float, vertical_section_offset: float, **kwargs ) -> None: self.magnet = magnet @@ -51,10 +46,7 @@ def azimuth_placement_angle(self): def azimuth_placement_angle(self, value): correct_angles = self.magnet.azimuth_placement_angle if value != correct_angles: - msg = ( - "Casing azimuth_placement_angle should be the" - "same value as TFCoilCasing.magnet." - ) + msg = "Casing azimuth_placement_angle should be the" "same value as TFCoilCasing.magnet." warnings.warn(msg, UserWarning) self._azimuth_placement_angle = correct_angles @@ -71,9 +63,7 @@ def find_points(self): outer_points = add_thickness(*outer_points_magnet, thickness=-self.outer_offset) curve_points = [] for distrib_points in [inner_points, outer_points]: - curve_points.append( - [[R, Z, "spline"] for R, Z in zip(distrib_points[0], distrib_points[1])] - ) + curve_points.append([[R, Z, "spline"] for R, Z in zip(distrib_points[0], distrib_points[1])]) curve_points[0][-1][2] = "straight" curve_points[1][-1][2] = "straight" @@ -81,11 +71,7 @@ def find_points(self): points = curve_points[0] + curve_points[1] self.points = points - ya = outer_points[1][ - outer_points[0].index( - min(outer_points[0], key=lambda x: abs(x - min(inner_points[0]))) - ) - ] + ya = outer_points[1][outer_points[0].index(min(outer_points[0], key=lambda x: abs(x - min(inner_points[0]))))] self.leg_points = [ ( min(outer_points[0]) - self.vertical_section_offset + self.outer_offset, diff --git a/paramak/parametric_components/tokamak_plasma.py b/paramak/parametric_components/tokamak_plasma.py index 2818c62b3..55b849e44 100644 --- a/paramak/parametric_components/tokamak_plasma.py +++ b/paramak/parametric_components/tokamak_plasma.py @@ -182,16 +182,14 @@ def compute_x_points(self): # no X points for non-null config lower_x_point = ( 1 - (1 + shift) * triangularity * self.minor_radius, - -(1 + shift) * elongation * self.minor_radius - + self.vertical_displacement, + -(1 + shift) * elongation * self.minor_radius + self.vertical_displacement, ) if self.configuration == "double-null": # upper_x_point is up-down symmetrical upper_x_point = ( lower_x_point[0], - (1 + shift) * elongation * self.minor_radius - + self.vertical_displacement, + (1 + shift) * elongation * self.minor_radius + self.vertical_displacement, ) self.lower_x_point = lower_x_point self.upper_x_point = upper_x_point @@ -204,14 +202,9 @@ def find_points(self): # parametric equations for plasma def R(theta): - return self.major_radius + self.minor_radius * np.cos( - theta + self.triangularity * np.sin(theta) - ) + return self.major_radius + self.minor_radius * np.cos(theta + self.triangularity * np.sin(theta)) def Z(theta): - return ( - self.elongation * self.minor_radius * np.sin(theta) - + self.vertical_displacement - ) + return self.elongation * self.minor_radius * np.sin(theta) + self.vertical_displacement self.points = np.stack((R(theta), Z(theta)), axis=1).tolist() diff --git a/paramak/parametric_components/tokamak_plasma_from_points.py b/paramak/parametric_components/tokamak_plasma_from_points.py index f1ceea853..5d1e09d7a 100644 --- a/paramak/parametric_components/tokamak_plasma_from_points.py +++ b/paramak/parametric_components/tokamak_plasma_from_points.py @@ -14,9 +14,7 @@ class PlasmaFromPoints(Plasma): of the plasma (cm). """ - def __init__( - self, outer_equatorial_x_point, inner_equatorial_x_point, high_point, **kwargs - ): + def __init__(self, outer_equatorial_x_point, inner_equatorial_x_point, high_point, **kwargs): minor_radius = (outer_equatorial_x_point - inner_equatorial_x_point) / 2.0 major_radius = inner_equatorial_x_point + minor_radius diff --git a/paramak/parametric_components/tokamak_plasma_plasmaboundaries.py b/paramak/parametric_components/tokamak_plasma_plasmaboundaries.py index 83faba31c..a73f96040 100644 --- a/paramak/parametric_components/tokamak_plasma_plasmaboundaries.py +++ b/paramak/parametric_components/tokamak_plasma_plasmaboundaries.py @@ -81,7 +81,5 @@ def find_points(self): if self.configuration == "double-null": upper_point_y = self.upper_x_point[1] - points = points[ - (points[:, 1] >= lower_point_y) & (points[:, 1] <= upper_point_y) - ] + points = points[(points[:, 1] >= lower_point_y) & (points[:, 1] <= upper_point_y)] self.points = points.tolist()[:-1] diff --git a/paramak/parametric_components/toroidal_field_coil_coat_hanger.py b/paramak/parametric_components/toroidal_field_coil_coat_hanger.py index 354fc8908..aed5109ba 100644 --- a/paramak/parametric_components/toroidal_field_coil_coat_hanger.py +++ b/paramak/parametric_components/toroidal_field_coil_coat_hanger.py @@ -91,12 +91,8 @@ def find_points(self): # - - # 7---8 - adjacent_length = self.vertical_mid_point[0] - ( - self.horizontal_start_point[0] + self.horizontal_length - ) - oppersite_length = self.horizontal_start_point[1] - ( - self.vertical_mid_point[1] + 0.5 * self.vertical_length - ) + adjacent_length = self.vertical_mid_point[0] - (self.horizontal_start_point[0] + self.horizontal_length) + oppersite_length = self.horizontal_start_point[1] - (self.vertical_mid_point[1] + 0.5 * self.vertical_length) point_rotation = math.atan(oppersite_length / adjacent_length) point_rotation_mid = math.radians(90) - point_rotation @@ -201,9 +197,6 @@ def find_points(self): ] # adds any vertical displacement and the connection type to the points - points = [ - (point[0], point[1] + self.vertical_displacement, "straight") - for point in points - ] + points = [(point[0], point[1] + self.vertical_displacement, "straight") for point in points] self.points = points diff --git a/paramak/parametric_components/toroidal_field_coil_rectangle.py b/paramak/parametric_components/toroidal_field_coil_rectangle.py index 68bec0b9d..18e6e8d0b 100644 --- a/paramak/parametric_components/toroidal_field_coil_rectangle.py +++ b/paramak/parametric_components/toroidal_field_coil_rectangle.py @@ -107,10 +107,7 @@ def find_points(self): ] # adds any vertical displacement and the connection type to the points - points = [ - (point[0], point[1] + self.vertical_displacement, "straight") - for point in points - ] + points = [(point[0], point[1] + self.vertical_displacement, "straight") for point in points] self.inner_leg_connection_points = [ (points[0][0], points[0][1]), diff --git a/paramak/parametric_components/toroidal_field_coil_round_corners.py b/paramak/parametric_components/toroidal_field_coil_round_corners.py index c66d00dae..cf8bc15f4 100644 --- a/paramak/parametric_components/toroidal_field_coil_round_corners.py +++ b/paramak/parametric_components/toroidal_field_coil_round_corners.py @@ -72,10 +72,7 @@ def __init__( # TODO move to setters if len(lower_inner_coordinates) != 2 or len(mid_point_coordinates) != 2: - msg = ( - "The input tuples are too long or too short, they must be " - "2 element long" - ) + msg = "The input tuples are too long or too short, they must be " "2 element long" raise ValueError(msg) if self._lower_inner_coordinates[0] > self._mid_point_coordinates[0]: @@ -87,15 +84,11 @@ def __init__( def _find_base_and_height(self): # Adding hidden attributes for analyse list population # inner base length of the coil - self._base_length = ( - self._mid_point_coordinates[0] - self._lower_inner_coordinates[0] - ) + self._base_length = self._mid_point_coordinates[0] - self._lower_inner_coordinates[0] self._analyse_attributes[0] = self._base_length # height of the coil - self._height = ( - abs(self.mid_point_coordinates[1] - self.lower_inner_coordinates[1]) * 2 - ) + self._height = abs(self.mid_point_coordinates[1] - self.lower_inner_coordinates[1]) * 2 self._analyse_attributes[1] = self._height def _find_radii(self): @@ -111,9 +104,7 @@ def _find_radii(self): self._inner_curve_radius = self._thickness * 0.1 self._outter_curve_radius = self._thickness * 1.1 else: - self._outter_curve_radius = ( - 1 + (self._thickness / self._base_length) - ) * self._thickness + self._outter_curve_radius = (1 + (self._thickness / self._base_length)) * self._thickness self._inner_curve_radius = (self._thickness**2) / self._base_length self._analyse_attributes[2] = self._inner_curve_radius @@ -143,9 +134,7 @@ def lower_inner_coordinates(self, val): if not isinstance(val[1], (float, int)): raise TypeError("Input Z Coordinates must be a number!") if val[0] > self._mid_point_coordinates[0]: - raise ValueError( - "Mid Point's x-coordinate, must be larger than lower point's!" - ) + raise ValueError("Mid Point's x-coordinate, must be larger than lower point's!") self._lower_inner_coordinates = val @property @@ -163,9 +152,7 @@ def mid_point_coordinates(self, val): if not isinstance(val[1], (float, int)): raise TypeError("Input Z Coordinates must be a number!") if val[0] < self._lower_inner_coordinates[0]: - raise ValueError( - "Mid Point's x-coordinate, must be larger than lower point's!" - ) + raise ValueError("Mid Point's x-coordinate, must be larger than lower point's!") self._mid_point_coordinates = val @property @@ -373,13 +360,9 @@ def create_solid(self): .lineTo(points[7][0], points[7][1]) .lineTo(points[8][0], points[8][1]) .lineTo(points[9][0], points[9][1]) - .threePointArc( - (points[10][0], points[10][1]), (points[11][0], points[11][1]) - ) + .threePointArc((points[10][0], points[10][1]), (points[11][0], points[11][1])) .lineTo(points[12][0], points[12][1]) - .threePointArc( - (points[13][0], points[13][1]), (points[14][0], points[14][1]) - ) + .threePointArc((points[13][0], points[13][1]), (points[14][0], points[14][1])) .lineTo(points[15][0], points[15][1]) .lineTo(points[16][0], points[16][1]) .close() @@ -403,13 +386,9 @@ def create_solid(self): ) inner_leg_solid = self.rotate_solid(inner_leg_solid) - inner_leg_solid = self.perform_boolean_operations( - inner_leg_solid, wedge_cut=cutting_wedge - ) + inner_leg_solid = self.perform_boolean_operations(inner_leg_solid, wedge_cut=cutting_wedge) - solid = cq.Compound.makeCompound( - [a.val() for a in [inner_leg_solid, solid]] - ) + solid = cq.Compound.makeCompound([a.val() for a in [inner_leg_solid, solid]]) self.solid = solid diff --git a/paramak/parametric_components/toroidal_field_coil_triple_arc.py b/paramak/parametric_components/toroidal_field_coil_triple_arc.py index 9b6599dbd..5a8ddb8fe 100644 --- a/paramak/parametric_components/toroidal_field_coil_triple_arc.py +++ b/paramak/parametric_components/toroidal_field_coil_triple_arc.py @@ -69,32 +69,20 @@ def _compute_curve(self, R1, h, radii, coverages): asum = small_coverage + mid_coverage # small arc - theta = np.linspace( - 0, small_coverage, round(0.5 * npoints * small_coverage / np.pi) - ) + theta = np.linspace(0, small_coverage, round(0.5 * npoints * small_coverage / np.pi)) small_arc_R = R1 + small_radius * (1 - np.cos(theta)) small_arc_Z = h + small_radius * np.sin(theta) # mid arc - theta = np.linspace( - theta[-1], asum, round(0.5 * npoints * mid_coverage / np.pi) - ) - mid_arc_R = small_arc_R[-1] + mid_radius * ( - np.cos(small_coverage) - np.cos(theta) - ) - mid_arc_Z = small_arc_Z[-1] + mid_radius * ( - np.sin(theta) - np.sin(small_coverage) - ) + theta = np.linspace(theta[-1], asum, round(0.5 * npoints * mid_coverage / np.pi)) + mid_arc_R = small_arc_R[-1] + mid_radius * (np.cos(small_coverage) - np.cos(theta)) + mid_arc_Z = small_arc_Z[-1] + mid_radius * (np.sin(theta) - np.sin(small_coverage)) # large arc large_radius = (mid_arc_Z[-1]) / np.sin(np.pi - asum) theta = np.linspace(theta[-1], np.pi, 60) - large_arc_R = mid_arc_R[-1] + large_radius * ( - np.cos(np.pi - theta) - np.cos(np.pi - asum) - ) - large_arc_Z = mid_arc_Z[-1] - large_radius * ( - np.sin(asum) - np.sin(np.pi - theta) - ) + large_arc_R = mid_arc_R[-1] + large_radius * (np.cos(np.pi - theta) - np.cos(np.pi - asum)) + large_arc_Z = mid_arc_Z[-1] - large_radius * (np.sin(asum) - np.sin(np.pi - theta)) R = np.concatenate((small_arc_R, mid_arc_R[1:], large_arc_R[1:])) R = np.append(R, np.flip(R)[1:]) diff --git a/paramak/parametric_components/vacuum_vessel.py b/paramak/parametric_components/vacuum_vessel.py index f78a748c0..1b66bb1af 100644 --- a/paramak/parametric_components/vacuum_vessel.py +++ b/paramak/parametric_components/vacuum_vessel.py @@ -25,9 +25,7 @@ def height(self, value): if not isinstance(value, (float, int)): raise ValueError("VacuumVessel.height must be a number. Not " f"{value}") if value <= 0: - msg = ( - "VacuumVessel.height must be a positive number above 0. " f"Not {value}" - ) + msg = "VacuumVessel.height must be a positive number above 0. " f"Not {value}" raise ValueError(msg) self._height = value diff --git a/paramak/parametric_components/vacuum_vessel_inner_leg.py b/paramak/parametric_components/vacuum_vessel_inner_leg.py index 2a9f053a7..817f8be16 100644 --- a/paramak/parametric_components/vacuum_vessel_inner_leg.py +++ b/paramak/parametric_components/vacuum_vessel_inner_leg.py @@ -34,9 +34,7 @@ def inner_height(self): @inner_height.setter def inner_height(self, value): if not isinstance(value, (float, int)): - raise ValueError( - "VacuumVesselInnerLeg.inner_height must be a number. Not", value - ) + raise ValueError("VacuumVesselInnerLeg.inner_height must be a number. Not", value) if value <= 0: msg = f"VacuumVesselInnerLeg.inner_height must be a positive number above 0. Not {value}" raise ValueError(msg) @@ -112,16 +110,10 @@ def create_solid(self): big_wire = (cq.Workplane(self.workplane).polyline(local_points[:4])).close() - small_wire = ( - cq.Workplane(self.workplane).polyline( - local_points[4:8] - ) # list of points has 10 entries - ).close() + small_wire = (cq.Workplane(self.workplane).polyline(local_points[4:8])).close() # list of points has 10 entries inner_wire = ( - cq.Workplane(self.workplane).polyline( - [local_points[1], local_points[2], local_points[9], local_points[8]] - ) + cq.Workplane(self.workplane).polyline([local_points[1], local_points[2], local_points[9], local_points[8]]) ).close() inner_solid = inner_wire.revolve(self.rotation_angle) diff --git a/paramak/parametric_reactors/ball_reactor.py b/paramak/parametric_reactors/ball_reactor.py index 813a733ba..eab95c45b 100644 --- a/paramak/parametric_reactors/ball_reactor.py +++ b/paramak/parametric_reactors/ball_reactor.py @@ -93,9 +93,7 @@ def __init__( self.inner_bore_radial_thickness = inner_bore_radial_thickness self.inboard_tf_leg_radial_thickness = inboard_tf_leg_radial_thickness - self.center_column_shield_radial_thickness = ( - center_column_shield_radial_thickness - ) + self.center_column_shield_radial_thickness = center_column_shield_radial_thickness self.divertor_radial_thickness = divertor_radial_thickness self.inner_plasma_gap_radial_thickness = inner_plasma_gap_radial_thickness self.plasma_radial_thickness = plasma_radial_thickness @@ -117,9 +115,7 @@ def __init__( self.rotation_angle = rotation_angle self.plasma_gap_vertical_thickness = plasma_gap_vertical_thickness - self.divertor_to_tf_gap_vertical_thickness = ( - divertor_to_tf_gap_vertical_thickness - ) + self.divertor_to_tf_gap_vertical_thickness = divertor_to_tf_gap_vertical_thickness self.elongation = elongation self.triangularity = triangularity @@ -173,10 +169,7 @@ def rotation_angle(self): @rotation_angle.setter def rotation_angle(self, value): if value == 360: - msg = ( - "360 degree rotation may result in a " - "Standard_ConstructionError or AttributeError" - ) + msg = "360 degree rotation may result in a " "Standard_ConstructionError or AttributeError" warnings.warn(msg, UserWarning) elif value > 360: raise ValueError("rotation_angle can not be larger than 360") @@ -295,25 +288,18 @@ def _make_radial_build(self): # another starts self._inner_bore_start_radius = 0 - self._inner_bore_end_radius = ( - self._inner_bore_start_radius + self.inner_bore_radial_thickness - ) + self._inner_bore_end_radius = self._inner_bore_start_radius + self.inner_bore_radial_thickness self._inboard_tf_coils_start_radius = self._inner_bore_end_radius - self._inboard_tf_coils_end_radius = ( - self._inboard_tf_coils_start_radius + self.inboard_tf_leg_radial_thickness - ) + self._inboard_tf_coils_end_radius = self._inboard_tf_coils_start_radius + self.inboard_tf_leg_radial_thickness self._center_column_shield_start_radius = self._inboard_tf_coils_end_radius self._center_column_shield_end_radius = ( - self._center_column_shield_start_radius - + self.center_column_shield_radial_thickness + self._center_column_shield_start_radius + self.center_column_shield_radial_thickness ) self._divertor_start_radius = self._center_column_shield_end_radius - self._divertor_end_radius = ( - self._center_column_shield_end_radius + self.divertor_radial_thickness - ) + self._divertor_end_radius = self._center_column_shield_end_radius + self.divertor_radial_thickness self._firstwall_start_radius = ( self._center_column_shield_end_radius @@ -321,19 +307,14 @@ def _make_radial_build(self): + self.plasma_radial_thickness + self.outer_plasma_gap_radial_thickness ) - self._firstwall_end_radius = ( - self._firstwall_start_radius + self.firstwall_radial_thickness - ) + self._firstwall_end_radius = self._firstwall_start_radius + self.firstwall_radial_thickness self._blanket_start_radius = self._firstwall_end_radius - self._blanket_end_radius = ( - self._blanket_start_radius + self.blanket_radial_thickness - ) + self._blanket_end_radius = self._blanket_start_radius + self.blanket_radial_thickness self._blanket_rear_wall_start_radius = self._blanket_end_radius self._blanket_rear_wall_end_radius = ( - self._blanket_rear_wall_start_radius - + self.blanket_rear_wall_radial_thickness + self._blanket_rear_wall_start_radius + self.blanket_rear_wall_radial_thickness ) def _make_vertical_build(self): @@ -341,38 +322,24 @@ def _make_vertical_build(self): # this is the vertical build sequence, components build on each other # in a similar manner to the radial build - self._firstwall_start_height = ( - self._plasma.high_point[1] + self.plasma_gap_vertical_thickness - ) - self._firstwall_end_height = ( - self._firstwall_start_height + self.firstwall_radial_thickness - ) + self._firstwall_start_height = self._plasma.high_point[1] + self.plasma_gap_vertical_thickness + self._firstwall_end_height = self._firstwall_start_height + self.firstwall_radial_thickness self._blanket_start_height = self._firstwall_end_height - self._blanket_end_height = ( - self._blanket_start_height + self.blanket_radial_thickness - ) + self._blanket_end_height = self._blanket_start_height + self.blanket_radial_thickness self._blanket_rear_wall_start_height = self._blanket_end_height self._blanket_rear_wall_end_height = ( - self._blanket_rear_wall_start_height - + self.blanket_rear_wall_radial_thickness + self._blanket_rear_wall_start_height + self.blanket_rear_wall_radial_thickness ) - self._tf_coil_start_height = ( - self._blanket_rear_wall_end_height - + self.divertor_to_tf_gap_vertical_thickness - ) + self._tf_coil_start_height = self._blanket_rear_wall_end_height + self.divertor_to_tf_gap_vertical_thickness self._center_column_shield_height = self._blanket_rear_wall_end_height * 2 if self.rear_blanket_to_tf_gap is not None: - self._tf_coil_start_radius = ( - self._blanket_rear_wall_end_radius + self.rear_blanket_to_tf_gap - ) - self._tf_coil_end_radius = ( - self._tf_coil_start_radius + self.outboard_tf_coil_radial_thickness - ) + self._tf_coil_start_radius = self._blanket_rear_wall_end_radius + self.rear_blanket_to_tf_gap + self._tf_coil_end_radius = self._tf_coil_start_radius + self.outboard_tf_coil_radial_thickness def _make_inboard_tf_coils(self): @@ -433,9 +400,7 @@ def _make_blankets_layers(self): self._blanket = paramak.BlanketFP( plasma=self._plasma, thickness=self.blanket_radial_thickness, - offset_from_plasma=[ - e + self.firstwall_radial_thickness for e in offset_from_plasma - ], + offset_from_plasma=[e + self.firstwall_radial_thickness for e in offset_from_plasma], start_angle=-180, stop_angle=180, rotation_angle=self.rotation_angle, @@ -449,8 +414,7 @@ def _make_blankets_layers(self): plasma=self._plasma, thickness=self.blanket_rear_wall_radial_thickness, offset_from_plasma=[ - e + self.firstwall_radial_thickness + self.blanket_radial_thickness - for e in offset_from_plasma + e + self.firstwall_radial_thickness + self.blanket_radial_thickness for e in offset_from_plasma ], start_angle=-180, stop_angle=180, @@ -541,26 +505,15 @@ def _make_pf_coils(self): ] # checks if lists are all the same length - if all( - len(input_list) == len(pf_input_lists[0]) for input_list in pf_input_lists - ): + if all(len(input_list) == len(pf_input_lists[0]) for input_list in pf_input_lists): number_of_pf_coils = len(pf_input_lists[0]) if number_of_pf_coils == 0: return None - center_points = [ - (x, y) - for x, y in zip( - self.pf_coil_radial_position, self.pf_coil_vertical_position - ) - ] + center_points = [(x, y) for x, y in zip(self.pf_coil_radial_position, self.pf_coil_vertical_position)] self._pf_coils = [] - for counter, ( - center_point, - pf_coil_vertical_thickness, - pf_coil_radial_thickness, - ) in enumerate( + for counter, (center_point, pf_coil_vertical_thickness, pf_coil_radial_thickness,) in enumerate( zip( center_points, self.pf_coil_vertical_thicknesses, diff --git a/paramak/parametric_reactors/center_column_study_reactor.py b/paramak/parametric_reactors/center_column_study_reactor.py index b4a44cabf..386bd800e 100644 --- a/paramak/parametric_reactors/center_column_study_reactor.py +++ b/paramak/parametric_reactors/center_column_study_reactor.py @@ -65,12 +65,8 @@ def __init__( self.inner_bore_radial_thickness = inner_bore_radial_thickness self.inboard_tf_leg_radial_thickness = inboard_tf_leg_radial_thickness - self.center_column_shield_radial_thickness_mid = ( - center_column_shield_radial_thickness_mid - ) - self.center_column_shield_radial_thickness_upper = ( - center_column_shield_radial_thickness_upper - ) + self.center_column_shield_radial_thickness_mid = center_column_shield_radial_thickness_mid + self.center_column_shield_radial_thickness_upper = center_column_shield_radial_thickness_upper self.inboard_firstwall_radial_thickness = inboard_firstwall_radial_thickness self.divertor_radial_thickness = divertor_radial_thickness self.inner_plasma_gap_radial_thickness = inner_plasma_gap_radial_thickness @@ -128,10 +124,7 @@ def create_solids(self): def _rotation_angle_check(self): if self.rotation_angle == 360: - msg = ( - "360 degree rotation may result " - + "in a Standard_ConstructionError or AttributeError" - ) + msg = "360 degree rotation may result " + "in a Standard_ConstructionError or AttributeError" warnings.warn(msg, UserWarning) def _make_plasma(self): @@ -167,56 +160,38 @@ def _make_radial_build(self): # another starts self._inner_bore_start_radius = 0 - self._inner_bore_end_radius = ( - self._inner_bore_start_radius + self.inner_bore_radial_thickness - ) + self._inner_bore_end_radius = self._inner_bore_start_radius + self.inner_bore_radial_thickness self._inboard_tf_coils_start_radius = self._inner_bore_end_radius - self._inboard_tf_coils_end_radius = ( - self._inboard_tf_coils_start_radius + self.inboard_tf_leg_radial_thickness - ) + self._inboard_tf_coils_end_radius = self._inboard_tf_coils_start_radius + self.inboard_tf_leg_radial_thickness self._center_column_shield_start_radius = self._inboard_tf_coils_end_radius self._center_column_shield_end_radius_upper = ( - self._center_column_shield_start_radius - + self.center_column_shield_radial_thickness_upper + self._center_column_shield_start_radius + self.center_column_shield_radial_thickness_upper ) self._center_column_shield_end_radius_mid = ( - self._center_column_shield_start_radius - + self.center_column_shield_radial_thickness_mid + self._center_column_shield_start_radius + self.center_column_shield_radial_thickness_mid ) - self._inboard_firstwall_start_radius = ( - self._center_column_shield_end_radius_upper - ) + self._inboard_firstwall_start_radius = self._center_column_shield_end_radius_upper self._inboard_firstwall_end_radius = ( - self._inboard_firstwall_start_radius - + self.inboard_firstwall_radial_thickness + self._inboard_firstwall_start_radius + self.inboard_firstwall_radial_thickness ) self._divertor_start_radius = self._inboard_firstwall_end_radius - self._divertor_end_radius = ( - self._divertor_start_radius + self.divertor_radial_thickness - ) + self._divertor_end_radius = self._divertor_start_radius + self.divertor_radial_thickness self._inner_plasma_gap_start_radius = ( - self._center_column_shield_end_radius_mid - + self.inboard_firstwall_radial_thickness + self._center_column_shield_end_radius_mid + self.inboard_firstwall_radial_thickness ) - self._inner_plasma_gap_end_radius = ( - self._inner_plasma_gap_start_radius + self.inner_plasma_gap_radial_thickness - ) + self._inner_plasma_gap_end_radius = self._inner_plasma_gap_start_radius + self.inner_plasma_gap_radial_thickness self._plasma_start_radius = self._inner_plasma_gap_end_radius - self._plasma_end_radius = ( - self._plasma_start_radius + self.plasma_radial_thickness - ) + self._plasma_end_radius = self._plasma_start_radius + self.plasma_radial_thickness self._outer_plasma_gap_start_radius = self._plasma_end_radius - self._outer_plasma_gap_end_radius = ( - self._outer_plasma_gap_start_radius + self.outer_plasma_gap_radial_thickness - ) + self._outer_plasma_gap_end_radius = self._outer_plasma_gap_start_radius + self.outer_plasma_gap_radial_thickness self._outboard_blanket_start_radius = self._outer_plasma_gap_end_radius self._outboard_blanket_end_radius = self._outboard_blanket_start_radius + 100.0 @@ -228,8 +203,7 @@ def _make_vertical_build(self): self._plasma_to_blanket_gap_start_height = self._plasma.high_point[1] self._plasma_to_blanket_gap_end_height = ( - self._plasma_to_blanket_gap_start_height - + self.plasma_gap_vertical_thickness + self._plasma_to_blanket_gap_start_height + self.plasma_gap_vertical_thickness ) self._blanket_start_height = self._plasma_to_blanket_gap_end_height @@ -320,8 +294,7 @@ def _make_divertor(self): ) self._divertor = paramak.CenterColumnShieldCylinder( - height=self._center_column_shield_end_height - * 2.5, # extra 0.5 to ensure overlap + height=self._center_column_shield_end_height * 2.5, # extra 0.5 to ensure overlap inner_radius=self._divertor_start_radius, outer_radius=self._divertor_end_radius, rotation_angle=self.rotation_angle, diff --git a/paramak/parametric_reactors/eu_demo_2015_reactor.py b/paramak/parametric_reactors/eu_demo_2015_reactor.py index 4f6548e70..dac236102 100644 --- a/paramak/parametric_reactors/eu_demo_2015_reactor.py +++ b/paramak/parametric_reactors/eu_demo_2015_reactor.py @@ -90,9 +90,7 @@ def create_tf_coils(self, vac_vessel_inner, vac_vessel) -> list: 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( - 0 + 20, 360 + 20, self.number_of_tf_coils - ), + azimuth_placement_angle=np.linspace(0 + 20, 360 + 20, self.number_of_tf_coils), rotation_angle=self.rotation_angle, color=(1.0, 1.0, 0.498), name="tf_coil_casing", @@ -339,9 +337,7 @@ def create_pf_coils(self) -> list: 684 - 563, ] outboard_pf_coils = [] - for counter, (center_point, width, height) in enumerate( - zip(center_points, widths, heights), 1 - ): + for counter, (center_point, width, height) in enumerate(zip(center_points, widths, heights), 1): pf_coil = paramak.PoloidalFieldCoil( height=height, width=width, diff --git a/paramak/parametric_reactors/flf_system_code_reactor.py b/paramak/parametric_reactors/flf_system_code_reactor.py index 8ac30d8bb..54e146910 100644 --- a/paramak/parametric_reactors/flf_system_code_reactor.py +++ b/paramak/parametric_reactors/flf_system_code_reactor.py @@ -74,9 +74,7 @@ def create_solids(self): """Creates a list of paramak.Shape for components and saves it in self.shapes_and_components """ - inner_wall = ( - self.inner_blanket_radius + self.blanket_thickness + self.blanket_vv_gap - ) + inner_wall = self.inner_blanket_radius + self.blanket_thickness + self.blanket_vv_gap lower_vv = paramak.RotateStraightShape( points=[ ( @@ -85,13 +83,11 @@ def create_solids(self): ), ( inner_wall, - (-self.blanket_height / 2.0) - - (self.lower_blanket_thickness + self.lower_vv_thickness), + (-self.blanket_height / 2.0) - (self.lower_blanket_thickness + self.lower_vv_thickness), ), ( 0, - (-self.blanket_height / 2.0) - - (self.lower_blanket_thickness + self.lower_vv_thickness), + (-self.blanket_height / 2.0) - (self.lower_blanket_thickness + self.lower_vv_thickness), ), (0, (-self.blanket_height / 2.0) - self.lower_blanket_thickness), ], @@ -130,15 +126,11 @@ def create_solids(self): (inner_wall, (self.blanket_height / 2.0) + self.upper_vv_thickness), ( inner_wall, - (self.blanket_height / 2.0) - + self.upper_vv_thickness - + self.upper_blanket_thickness, + (self.blanket_height / 2.0) + self.upper_vv_thickness + self.upper_blanket_thickness, ), ( 0, - (self.blanket_height / 2.0) - + self.upper_vv_thickness - + self.upper_blanket_thickness, + (self.blanket_height / 2.0) + self.upper_vv_thickness + self.upper_blanket_thickness, ), (0, (self.blanket_height / 2.0) + self.upper_vv_thickness), ], @@ -163,27 +155,19 @@ def create_solids(self): points=[ ( inner_wall + self.vv_thickness, - (self.blanket_height / 2.0) - + self.upper_vv_thickness - + self.upper_blanket_thickness, + (self.blanket_height / 2.0) + self.upper_vv_thickness + self.upper_blanket_thickness, ), ( inner_wall, - (self.blanket_height / 2.0) - + self.upper_vv_thickness - + self.upper_blanket_thickness, + (self.blanket_height / 2.0) + self.upper_vv_thickness + self.upper_blanket_thickness, ), ( inner_wall, - -(self.blanket_height / 2.0) - - self.lower_blanket_thickness - - self.lower_vv_thickness, + -(self.blanket_height / 2.0) - self.lower_blanket_thickness - self.lower_vv_thickness, ), ( inner_wall + self.vv_thickness, - -(self.blanket_height / 2.0) - - self.lower_blanket_thickness - - self.lower_vv_thickness, + -(self.blanket_height / 2.0) - self.lower_blanket_thickness - self.lower_vv_thickness, ), ], rotation_angle=self.rotation_angle, diff --git a/paramak/parametric_reactors/iter_paper_2020.py b/paramak/parametric_reactors/iter_paper_2020.py index 734c2b26f..98efa5345 100644 --- a/paramak/parametric_reactors/iter_paper_2020.py +++ b/paramak/parametric_reactors/iter_paper_2020.py @@ -236,9 +236,7 @@ def create_pf_coils(self) -> list: ) outboard_pf_coils = [] - for counter, (top_right, lower_left) in enumerate( - zip(top_rights, lower_lefts), 1 - ): + for counter, (top_right, lower_left) in enumerate(zip(top_rights, lower_lefts), 1): pf_coil = paramak.PoloidalFieldCoilFP( corner_points=(top_right, lower_left), rotation_angle=self.rotation_angle, diff --git a/paramak/parametric_reactors/negative_triangularity_reactor.py b/paramak/parametric_reactors/negative_triangularity_reactor.py index ab744da9c..3e1357887 100644 --- a/paramak/parametric_reactors/negative_triangularity_reactor.py +++ b/paramak/parametric_reactors/negative_triangularity_reactor.py @@ -236,11 +236,7 @@ def _plasma_geometry(self): + self._vacuum_vessel_thickness + self._central_shield_thickness ) - blanket_width = ( - self._inner_wall_thickness - + self._blanket_thickness - + self._rear_wall_thickness - ) + blanket_width = self._inner_wall_thickness + self._blanket_thickness + self._rear_wall_thickness wdth_diff = blanket_width - core_width if wdth_diff > 0: @@ -260,18 +256,12 @@ def _equatorial_points(self): ) if not self._low_aspect: self._inner_equatorial_point += ( - self._inner_wall_thickness - + self._blanket_thickness - + self._rear_wall_thickness + self._inner_wall_thickness + self._blanket_thickness + self._rear_wall_thickness ) - self._outer_equatorial_point = ( - self._inner_equatorial_point + self._plasma_radial_thickness - ) + self._outer_equatorial_point = self._inner_equatorial_point + self._plasma_radial_thickness - self._major_radius = ( - self._outer_equatorial_point + self._inner_equatorial_point - ) / 2 + self._major_radius = (self._outer_equatorial_point + self._inner_equatorial_point) / 2 self._minor_radius = self._major_radius - self._inner_equatorial_point # Getters @@ -410,9 +400,7 @@ def vacuum_vessel_thickness(self, val): @central_shield_thickness.setter def central_shield_thickness(self, val): if not isinstance(val, (float, int)): - raise TypeError( - "Inbore heat shield thickness must be float or integer value!" - ) + raise TypeError("Inbore heat shield thickness must be float or integer value!") self._central_shield_thickness = val @wall_to_plasma_gap.setter @@ -479,54 +467,42 @@ def tf_width(self, val): @port_side_lengths.setter def port_side_lengths(self, val): - if not isinstance(val, list) or False in [ - isinstance(x, (float, int)) for x in val - ]: + if not isinstance(val, list) or False in [isinstance(x, (float, int)) for x in val]: raise TypeError("Port side lengths must be a list of numbers!") self._port_checks() self._port_side_lengths = val @port_heights.setter def port_heights(self, val): - if not isinstance(val, list) or False in [ - isinstance(x, (float, int)) for x in val - ]: + if not isinstance(val, list) or False in [isinstance(x, (float, int)) for x in val]: raise TypeError("Port heights must be a list of numbers!") self._port_checks() self._port_thickness = val @port_angles.setter def port_angles(self, val): - if not isinstance(val, list) or False in [ - isinstance(x, (float, int)) for x in val - ]: + if not isinstance(val, list) or False in [isinstance(x, (float, int)) for x in val]: raise TypeError("Port angles must be a list of numbers!") self._port_checks() self._ports_angles = val @port_z_pos.setter def port_z_pos(self, val): - if not isinstance(val, list) or False in [ - isinstance(x, (float, int)) for x in val - ]: + if not isinstance(val, list) or False in [isinstance(x, (float, int)) for x in val]: raise TypeError("Port Z positions must be a list of numbers!") self._port_checks() self._port_z_pos = val @pf_coil_heights.setter def pf_coil_heights(self, val): - if not isinstance(val, list) or False in [ - isinstance(x, (float, int)) for x in val - ]: + if not isinstance(val, list) or False in [isinstance(x, (float, int)) for x in val]: raise TypeError("Pf coil heights must be a list of numbers!") self._pf_checks(False) self._pf_coil_heights = val @pf_coil_widths.setter def pf_coil_widths(self, val): - if not isinstance(val, list) or False in [ - isinstance(x, (float, int)) for x in val - ]: + if not isinstance(val, list) or False in [isinstance(x, (float, int)) for x in val]: raise TypeError("Pf coil width must be a list of numbers!") self._pf_checks(False) self._pf_coil_widths = val @@ -540,9 +516,7 @@ def pf_coil_center_points(self, val): @pf_coil_casing_thickness.setter def pf_coil_casing_thickness(self, val): - if not isinstance(val, list) or False in [ - isinstance(x, (float, int)) for x in val - ]: + if not isinstance(val, list) or False in [isinstance(x, (float, int)) for x in val]: raise TypeError("Pf coil heights must be a list of numbers!") self._pf_checks(False) self._pf_casing_thickness = val @@ -594,27 +568,17 @@ def _make_plasma(self): def _make_vertical_build(self): # Above the plasma # Inner wall - self._inner_wall_start_height = ( - self._plasma.high_point[1] + self._wall_to_plasma_gap - ) - self._inner_wall_end_height = ( - self._inner_wall_start_height + self._inner_wall_thickness - ) + self._inner_wall_start_height = self._plasma.high_point[1] + self._wall_to_plasma_gap + self._inner_wall_end_height = self._inner_wall_start_height + self._inner_wall_thickness # Blanket self._blanket_start_height_top = self._inner_wall_end_height - self._blanket_end_height_top = ( - self._blanket_start_height_top + self._blanket_thickness - ) + self._blanket_end_height_top = self._blanket_start_height_top + self._blanket_thickness # Rear wall self._rear_wall_start_height_top = self._blanket_end_height_top - self._rear_wall_end_height_top = ( - self._rear_wall_start_height_top + self._rear_wall_thickness - ) + self._rear_wall_end_height_top = self._rear_wall_start_height_top + self._rear_wall_thickness # Divertor self._divertor_start_height = self._plasma.high_point[1] - self._divertor_end_height_top = ( - self._divertor_start_height + self._divertor_height_full - ) + self._divertor_end_height_top = self._divertor_start_height + self._divertor_height_full # Diverter height check min_div_h = self._rear_wall_end_height_top - self._divertor_start_height @@ -626,17 +590,13 @@ def _make_vertical_build(self): self._divertor_end_height_top = self._divertor_start_height + min_div_h # Vacuum Vessel Inner Wall self._vacuum_vessel_start_height = self._divertor_end_height_top - self._vacuum_vessel_end_height = ( - self._vacuum_vessel_start_height + self._vacuum_vessel_thickness - ) + self._vacuum_vessel_end_height = self._vacuum_vessel_start_height + self._vacuum_vessel_thickness # Central Heights self._inner_tf_leg_height = self._vacuum_vessel_end_height * 2 self._vacuum_vessel_height = self._vacuum_vessel_start_height * 2 self._inner_shield_height = self._vacuum_vessel_start_height * 2 # Outer Blanket Height - self._outer_blanket_height = self._inner_shield_height - ( - 2 * self._divertor_height_full - ) + self._outer_blanket_height = self._inner_shield_height - (2 * self._divertor_height_full) if self._outer_blanket_height < 0: raise ValueError("The divertors are overlapping at the center plane.") @@ -646,29 +606,17 @@ def _make_radial_build(self): self._inner_bore_stop_rad = self._inner_bore_radius # Inner TF Coil self._tf_inner_leg_start_rad = self._inner_bore_stop_rad - self._tf_inner_leg_end_rad = ( - self._tf_inner_leg_start_rad + self._inner_tf_coil_thickness - ) + self._tf_inner_leg_end_rad = self._tf_inner_leg_start_rad + self._inner_tf_coil_thickness # Vacuum Vessel Inner wall - self._vacuum_vessel_inwall_start_rad = ( - self._tf_inner_leg_end_rad + self._inner_leg_to_vacuum_inner_wall_gap - ) - self._vacuum_vessel_inwall_end_rad = ( - self._vacuum_vessel_inwall_start_rad + self._vacuum_vessel_thickness - ) + self._vacuum_vessel_inwall_start_rad = self._tf_inner_leg_end_rad + self._inner_leg_to_vacuum_inner_wall_gap + self._vacuum_vessel_inwall_end_rad = self._vacuum_vessel_inwall_start_rad + self._vacuum_vessel_thickness # Central Column Shield self._inner_shield_start_rad = self._vacuum_vessel_inwall_end_rad - self._inner_shield_end_rad = ( - self._inner_shield_start_rad + self._central_shield_thickness - ) + self._inner_shield_end_rad = self._inner_shield_start_rad + self._central_shield_thickness # Blanket Offset self._blanket_offset = self._wall_to_plasma_gap + self._inner_wall_thickness # Rear Wall offset - self._rear_wall_plasma_offset = ( - self._wall_to_plasma_gap - + self._blanket_thickness - + self._inner_wall_thickness - ) + self._rear_wall_plasma_offset = self._wall_to_plasma_gap + self._blanket_thickness + self._inner_wall_thickness # Run check for diverter parameters full_outer_blanket_rad = ( @@ -692,14 +640,10 @@ def _make_radial_build(self): # Divertor parts self._divertor_start_rad = self._plasma.high_point[0] - self._divertor_end_rad = ( - self._divertor_start_rad + self._divertor_radial_thickness - ) + self._divertor_end_rad = self._divertor_start_rad + self._divertor_radial_thickness # Vacuum Vessel Body self._vacuum_vessel_body_start_rad = self._divertor_end_rad - self._vacuum_vessel_body_end_rad = ( - self._vacuum_vessel_body_start_rad + self._vacuum_vessel_thickness - ) + self._vacuum_vessel_body_end_rad = self._vacuum_vessel_body_start_rad + self._vacuum_vessel_thickness # TF Coils # Getting small radius for inner corner self._tf_coils_init = paramak.ToroidalFieldCoilRectangleRoundCorners( @@ -718,9 +662,7 @@ def _make_radial_build(self): self._small_rad_displacement = self._tf_coils_init.analyse_attributes[2] - self._tf_start_rad = ( - self._vacuum_vessel_body_end_rad + self._small_rad_displacement - ) + self._tf_start_rad = self._vacuum_vessel_body_end_rad + self._small_rad_displacement self._tf_end_rad = self._tf_start_rad + self._inner_tf_coil_thickness def _make_pf_coils(self): @@ -854,9 +796,7 @@ def _make_blankets(self): stop_angle=360, plasma=self._make_plasma(), rotation_angle=self._rotation_angle, - offset_from_plasma=self._inner_wall_thickness - + self._blanket_thickness - + self._wall_to_plasma_gap, + offset_from_plasma=self._inner_wall_thickness + self._blanket_thickness + self._wall_to_plasma_gap, name="blanket_rear_wall", cut=[ central_cutter, @@ -991,12 +931,7 @@ def _port_checks(self): or len(self._port_z_pos) != len(self._ports_angles) ): raise ValueError("Number of elements in Port Parameters don't match!") - _port_coord_list = ( - self._port_side_lengths - + self._ports_angles - + self._port_heights - + self._ports_angles - ) + _port_coord_list = self._port_side_lengths + self._ports_angles + self._port_heights + self._ports_angles for cord in _port_coord_list: if not isinstance(cord, (float, int)): raise TypeError("Port parameters must be float or integer values!") @@ -1011,15 +946,11 @@ def _pf_checks(self, tuple_bool): ): raise ValueError("Number of elements in PF Parameters don't match!") if not tuple_bool: - _pf_lists = ( - self._pf_coil_heights + self._pf_coil_widths + self._pf_casing_thickness - ) + _pf_lists = self._pf_coil_heights + self._pf_coil_widths + self._pf_casing_thickness for cord in _pf_lists: if not isinstance(cord, (float, int)): - raise TypeError( - "PF parameters must be float or integer values! yay" - ) + raise TypeError("PF parameters must be float or integer values! yay") else: _pf_lists = ( self._pf_coil_heights diff --git a/paramak/parametric_reactors/segmented_blanket_ball_reactor.py b/paramak/parametric_reactors/segmented_blanket_ball_reactor.py index 54be01cd6..887d58209 100644 --- a/paramak/parametric_reactors/segmented_blanket_ball_reactor.py +++ b/paramak/parametric_reactors/segmented_blanket_ball_reactor.py @@ -71,9 +71,7 @@ def number_of_blanket_segments(self, value): def _make_blankets_layers(self): super()._make_blankets_layers() - azimuth_placement_angles = np.linspace( - 0, 360, self.number_of_blanket_segments, endpoint=False - ) + azimuth_placement_angles = np.linspace(0, 360, self.number_of_blanket_segments, endpoint=False) thin_cutter = paramak.BlanketCutterStar( distance=self.gap_between_blankets, azimuth_placement_angle=azimuth_placement_angles, @@ -89,14 +87,12 @@ def _make_blankets_layers(self): if self.blanket_fillet_radius != 0: # tried firstwall start radius here already x = self.major_radius + 1 - front_face_b = self._blanket.solid.faces( - cq.NearestToPointSelector((0, x, 0)) - ) + front_face_b = self._blanket.solid.faces(cq.NearestToPointSelector((0, x, 0))) front_edge_b = front_face_b.edges(cq.NearestToPointSelector((0, x, 0))) front_edge_length_b = front_edge_b.val().Length() - self._blanket.solid = self._blanket.solid.edges( - paramak.EdgeLengthSelector(front_edge_length_b) - ).fillet(self.blanket_fillet_radius) + self._blanket.solid = self._blanket.solid.edges(paramak.EdgeLengthSelector(front_edge_length_b)).fillet( + self.blanket_fillet_radius + ) self._firstwall.thickness += self.blanket_radial_thickness self._firstwall.cut = [self._center_column_cutter, thin_cutter, self._blanket] diff --git a/paramak/parametric_reactors/single_null_submersion_reactor.py b/paramak/parametric_reactors/single_null_submersion_reactor.py index 70b03a24d..7a3928270 100644 --- a/paramak/parametric_reactors/single_null_submersion_reactor.py +++ b/paramak/parametric_reactors/single_null_submersion_reactor.py @@ -12,15 +12,6 @@ class SingleNullSubmersionTokamak(paramak.SubmersionTokamak): support_position (str): Defaults to "upper". """ - def __init__( - self, - divertor_position: str = "upper", - support_position: str = "upper", - **kwargs - ): + def __init__(self, divertor_position: str = "upper", support_position: str = "upper", **kwargs): - super().__init__( - divertor_position=divertor_position, - support_position=support_position, - **kwargs - ) + super().__init__(divertor_position=divertor_position, support_position=support_position, **kwargs) diff --git a/paramak/parametric_reactors/sparc_paper_2020.py b/paramak/parametric_reactors/sparc_paper_2020.py index 6b10d6ecb..6e9e7db51 100644 --- a/paramak/parametric_reactors/sparc_paper_2020.py +++ b/paramak/parametric_reactors/sparc_paper_2020.py @@ -56,9 +56,7 @@ def create_pf_coils(self): widths = [27.7, 27.7, 27.7, 27.7, 27.7, 27.7] inboard_pf_coils = [] - for counter, (center_point, width, height) in enumerate( - zip(center_points, widths, heights), 1 - ): + for counter, (center_point, width, height) in enumerate(zip(center_points, widths, heights), 1): pf_coil = paramak.PoloidalFieldCoil( height=height, width=width, @@ -99,9 +97,7 @@ def create_pf_coils(self): 37, ] outboard_pf_coils = [] - for counter, (center_point, width, height) in enumerate( - zip(center_points, widths, heights), 1 - ): + for counter, (center_point, width, height) in enumerate(zip(center_points, widths, heights), 1): pf_coil = paramak.PoloidalFieldCoil( height=height, width=width, @@ -121,9 +117,7 @@ def create_pf_coils(self): heights = [15, 15, 15, 15] div_coils = [] - for counter, (center_point, width, height) in enumerate( - zip(center_points, widths, heights), 1 - ): + for counter, (center_point, width, height) in enumerate(zip(center_points, widths, heights), 1): pf_coil = paramak.PoloidalFieldCoil( height=height, width=width, @@ -208,9 +202,7 @@ def create_pf_coils(self): heights = [10, 10] vs_coils = [] - for counter, (center_point, width, height) in enumerate( - zip(center_points, widths, heights), 1 - ): + for counter, (center_point, width, height) in enumerate(zip(center_points, widths, heights), 1): pf_coil = paramak.PoloidalFieldCoil( height=height, width=width, diff --git a/paramak/parametric_reactors/submersion_reactor.py b/paramak/parametric_reactors/submersion_reactor.py index a810e7f9d..5c6144396 100644 --- a/paramak/parametric_reactors/submersion_reactor.py +++ b/paramak/parametric_reactors/submersion_reactor.py @@ -88,9 +88,7 @@ def __init__( self.inner_bore_radial_thickness = inner_bore_radial_thickness self.inboard_tf_leg_radial_thickness = inboard_tf_leg_radial_thickness - self.center_column_shield_radial_thickness = ( - center_column_shield_radial_thickness - ) + self.center_column_shield_radial_thickness = center_column_shield_radial_thickness self.inboard_blanket_radial_thickness = inboard_blanket_radial_thickness self.firstwall_radial_thickness = firstwall_radial_thickness self.inner_plasma_gap_radial_thickness = inner_plasma_gap_radial_thickness @@ -245,10 +243,7 @@ def create_solids(self): def _rotation_angle_check(self): if self.rotation_angle == 360: - msg = ( - "360 degree rotation may result" - + " in a Standard_ConstructionError or AttributeError" - ) + msg = "360 degree rotation may result" + " in a Standard_ConstructionError or AttributeError" warnings.warn(msg, UserWarning) def _make_radial_build(self): @@ -257,60 +252,40 @@ def _make_radial_build(self): # another starts self._inner_bore_start_radius = 0 - self._inner_bore_end_radius = ( - self._inner_bore_start_radius + self.inner_bore_radial_thickness - ) + self._inner_bore_end_radius = self._inner_bore_start_radius + self.inner_bore_radial_thickness self._inboard_tf_coils_start_radius = self._inner_bore_end_radius - self._inboard_tf_coils_end_radius = ( - self._inboard_tf_coils_start_radius + self.inboard_tf_leg_radial_thickness - ) + self._inboard_tf_coils_end_radius = self._inboard_tf_coils_start_radius + self.inboard_tf_leg_radial_thickness self._center_column_shield_start_radius = self._inboard_tf_coils_end_radius self._center_column_shield_end_radius = ( - self._center_column_shield_start_radius - + self.center_column_shield_radial_thickness + self._center_column_shield_start_radius + self.center_column_shield_radial_thickness ) self._inboard_blanket_start_radius = self._center_column_shield_end_radius - self._inboard_blanket_end_radius = ( - self._inboard_blanket_start_radius + self.inboard_blanket_radial_thickness - ) + self._inboard_blanket_end_radius = self._inboard_blanket_start_radius + self.inboard_blanket_radial_thickness self._inboard_firstwall_start_radius = self._inboard_blanket_end_radius - self._inboard_firstwall_end_radius = ( - self._inboard_firstwall_start_radius + self.firstwall_radial_thickness - ) + self._inboard_firstwall_end_radius = self._inboard_firstwall_start_radius + self.firstwall_radial_thickness self._inner_plasma_gap_start_radius = self._inboard_firstwall_end_radius - self._inner_plasma_gap_end_radius = ( - self._inner_plasma_gap_start_radius + self.inner_plasma_gap_radial_thickness - ) + self._inner_plasma_gap_end_radius = self._inner_plasma_gap_start_radius + self.inner_plasma_gap_radial_thickness self._plasma_start_radius = self._inner_plasma_gap_end_radius - self._plasma_end_radius = ( - self._plasma_start_radius + self.plasma_radial_thickness - ) + self._plasma_end_radius = self._plasma_start_radius + self.plasma_radial_thickness self._outer_plasma_gap_start_radius = self._plasma_end_radius - self._outer_plasma_gap_end_radius = ( - self._outer_plasma_gap_start_radius + self.outer_plasma_gap_radial_thickness - ) + self._outer_plasma_gap_end_radius = self._outer_plasma_gap_start_radius + self.outer_plasma_gap_radial_thickness self._outboard_firstwall_start_radius = self._outer_plasma_gap_end_radius - self._outboard_firstwall_end_radius = ( - self._outboard_firstwall_start_radius + self.firstwall_radial_thickness - ) + self._outboard_firstwall_end_radius = self._outboard_firstwall_start_radius + self.firstwall_radial_thickness self._outboard_blanket_start_radius = self._outboard_firstwall_end_radius - self._outboard_blanket_end_radius = ( - self._outboard_blanket_start_radius + self.outboard_blanket_radial_thickness - ) + self._outboard_blanket_end_radius = self._outboard_blanket_start_radius + self.outboard_blanket_radial_thickness self._blanket_rear_wall_start_radius = self._outboard_blanket_end_radius self._blanket_rear_wall_end_radius = ( - self._blanket_rear_wall_start_radius - + self.blanket_rear_wall_radial_thickness + self._blanket_rear_wall_start_radius + self.blanket_rear_wall_radial_thickness ) self._tf_info_provided = False @@ -320,27 +295,16 @@ def _make_radial_build(self): and self.outboard_tf_coil_poloidal_thickness is not None ): self._tf_info_provided = True - self._outboard_tf_coil_start_radius = ( - self._blanket_rear_wall_end_radius + self.rear_blanket_to_tf_gap - ) + self._outboard_tf_coil_start_radius = self._blanket_rear_wall_end_radius + self.rear_blanket_to_tf_gap self._outboard_tf_coil_end_radius = ( - self._outboard_tf_coil_start_radius - + self.outboard_tf_coil_radial_thickness + self._outboard_tf_coil_start_radius + self.outboard_tf_coil_radial_thickness ) - self._divertor_start_radius = ( - self._plasma.high_point[0] - 0.5 * self.divertor_radial_thickness - ) - self._divertor_end_radius = ( - self._plasma.high_point[0] + 0.5 * self.divertor_radial_thickness - ) + self._divertor_start_radius = self._plasma.high_point[0] - 0.5 * self.divertor_radial_thickness + self._divertor_end_radius = self._plasma.high_point[0] + 0.5 * self.divertor_radial_thickness - self._support_start_radius = ( - self._plasma.high_point[0] - 0.5 * self.support_radial_thickness - ) - self._support_end_radius = ( - self._plasma.high_point[0] + 0.5 * self.support_radial_thickness - ) + self._support_start_radius = self._plasma.high_point[0] - 0.5 * self.support_radial_thickness + self._support_end_radius = self._plasma.high_point[0] + 0.5 * self.support_radial_thickness def _make_vertical_build(self): @@ -352,34 +316,24 @@ def _make_vertical_build(self): self._plasma_to_divertor_gap_start_height = self._plasma_end_height self._plasma_to_divertor_gap_end_height = ( - self._plasma_to_divertor_gap_start_height - + self.outer_plasma_gap_radial_thickness + self._plasma_to_divertor_gap_start_height + self.outer_plasma_gap_radial_thickness ) # the firstwall is cut by the divertor but uses the same control points self._firstwall_start_height = self._plasma_to_divertor_gap_end_height - self._firstwall_end_height = ( - self._firstwall_start_height + self.firstwall_radial_thickness - ) + self._firstwall_end_height = self._firstwall_start_height + self.firstwall_radial_thickness self._blanket_start_height = self._firstwall_end_height - self._blanket_end_height = ( - self._blanket_start_height + self.outboard_blanket_radial_thickness - ) + self._blanket_end_height = self._blanket_start_height + self.outboard_blanket_radial_thickness self._blanket_rear_wall_start_height = self._blanket_end_height self._blanket_rear_wall_end_height = ( - self._blanket_rear_wall_start_height - + self.blanket_rear_wall_radial_thickness + self._blanket_rear_wall_start_height + self.blanket_rear_wall_radial_thickness ) if self._tf_info_provided: - self._outboard_tf_coils_vertical_height = ( - self._blanket_rear_wall_end_height * 1.5 - ) - self._outboard_tf_coils_horizontal_length = ( - self._blanket_rear_wall_end_radius * 0.75 - ) + self._outboard_tf_coils_vertical_height = self._blanket_rear_wall_end_height * 1.5 + self._outboard_tf_coils_horizontal_length = self._blanket_rear_wall_end_radius * 0.75 def _make_center_column_shield(self): @@ -527,9 +481,7 @@ def _make_blanket(self): # this takes a single solid from a compound of solids by finding the # solid nearest to a point # TODO: find alternative - self._inboard_blanket.solid = self._inboard_blanket.solid.solids( - cq.selectors.NearestToPointSelector((0, 0, 0)) - ) + self._inboard_blanket.solid = self._inboard_blanket.solid.solids(cq.selectors.NearestToPointSelector((0, 0, 0))) # this is the outboard fused /unioned with the inboard blanket @@ -537,8 +489,7 @@ def _make_blanket(self): plasma=self._plasma, start_angle=90, stop_angle=-90, - offset_from_plasma=self.outer_plasma_gap_radial_thickness - + self.firstwall_radial_thickness, + offset_from_plasma=self.outer_plasma_gap_radial_thickness + self.firstwall_radial_thickness, thickness=self.outboard_blanket_radial_thickness, rotation_angle=self.rotation_angle, name="blanket", @@ -552,8 +503,7 @@ def _make_supports(self): plasma=self._plasma, start_angle=90, stop_angle=-90, - offset_from_plasma=self.outer_plasma_gap_radial_thickness - + self.firstwall_radial_thickness, + offset_from_plasma=self.outer_plasma_gap_radial_thickness + self.firstwall_radial_thickness, thickness=self.outboard_blanket_radial_thickness, rotation_angle=self.rotation_angle, union=self._inboard_blanket, @@ -658,26 +608,15 @@ def _make_pf_coils(self): ] # checks if lists are all the same length - if all( - len(input_list) == len(pf_input_lists[0]) for input_list in pf_input_lists - ): + if all(len(input_list) == len(pf_input_lists[0]) for input_list in pf_input_lists): number_of_pf_coils = len(pf_input_lists[0]) if number_of_pf_coils == 0: return None - center_points = [ - (x, y) - for x, y in zip( - self.pf_coil_radial_position, self.pf_coil_vertical_position - ) - ] + center_points = [(x, y) for x, y in zip(self.pf_coil_radial_position, self.pf_coil_vertical_position)] self._pf_coils = [] - for counter, ( - center_point, - pf_coil_vertical_thickness, - pf_coil_radial_thickness, - ) in enumerate( + for counter, (center_point, pf_coil_vertical_thickness, pf_coil_radial_thickness,) in enumerate( zip( center_points, self.pf_coil_vertical_thicknesses, diff --git a/paramak/parametric_shapes/extruded_spline_shape.py b/paramak/parametric_shapes/extruded_spline_shape.py index 2871558c5..ae6996e8e 100644 --- a/paramak/parametric_shapes/extruded_spline_shape.py +++ b/paramak/parametric_shapes/extruded_spline_shape.py @@ -24,10 +24,4 @@ def __init__( **kwargs ): - super().__init__( - distance=distance, - connection_type="spline", - color=color, - name=name, - **kwargs - ) + super().__init__(distance=distance, connection_type="spline", color=color, name=name, **kwargs) diff --git a/paramak/parametric_shapes/extruded_straight_shape.py b/paramak/parametric_shapes/extruded_straight_shape.py index 4d372d85e..9ab8c2e8b 100644 --- a/paramak/parametric_shapes/extruded_straight_shape.py +++ b/paramak/parametric_shapes/extruded_straight_shape.py @@ -23,10 +23,4 @@ def __init__( **kwargs ): - super().__init__( - distance=distance, - connection_type="straight", - color=color, - name=name, - **kwargs - ) + super().__init__(distance=distance, connection_type="straight", color=color, name=name, **kwargs) diff --git a/paramak/parametric_shapes/rotate_circle_shape.py b/paramak/parametric_shapes/rotate_circle_shape.py index f867f3c00..2d91f9871 100644 --- a/paramak/parametric_shapes/rotate_circle_shape.py +++ b/paramak/parametric_shapes/rotate_circle_shape.py @@ -52,11 +52,7 @@ def create_solid(self): A CadQuery solid: A 3D solid volume """ - wire = ( - Workplane(self.workplane) - .moveTo(self.points[0][0], self.points[0][1]) - .circle(self.radius) - ) + wire = Workplane(self.workplane).moveTo(self.points[0][0], self.points[0][1]).circle(self.radius) self.wire = wire diff --git a/paramak/parametric_shapes/rotate_spline_shape.py b/paramak/parametric_shapes/rotate_spline_shape.py index 242f7d6d3..116f571b3 100644 --- a/paramak/parametric_shapes/rotate_spline_shape.py +++ b/paramak/parametric_shapes/rotate_spline_shape.py @@ -23,10 +23,4 @@ def __init__( **kwargs ): - super().__init__( - rotation_angle=rotation_angle, - color=color, - connection_type="spline", - name=name, - **kwargs - ) + super().__init__(rotation_angle=rotation_angle, color=color, connection_type="spline", name=name, **kwargs) diff --git a/paramak/parametric_shapes/rotate_straight_shape.py b/paramak/parametric_shapes/rotate_straight_shape.py index 712758601..c41a78cbd 100644 --- a/paramak/parametric_shapes/rotate_straight_shape.py +++ b/paramak/parametric_shapes/rotate_straight_shape.py @@ -24,10 +24,4 @@ def __init__( **kwargs ): - super().__init__( - rotation_angle=rotation_angle, - color=color, - connection_type="straight", - name=name, - **kwargs - ) + super().__init__(rotation_angle=rotation_angle, color=color, connection_type="straight", name=name, **kwargs) diff --git a/paramak/parametric_shapes/sweep_circle_shape.py b/paramak/parametric_shapes/sweep_circle_shape.py index be95b3f71..c153176d0 100644 --- a/paramak/parametric_shapes/sweep_circle_shape.py +++ b/paramak/parametric_shapes/sweep_circle_shape.py @@ -73,9 +73,7 @@ def path_workplane(self): @path_workplane.setter def path_workplane(self, value): if value[0] != self.workplane[0]: - raise ValueError( - "workplane and path_workplane must start with the same letter" - ) + raise ValueError("workplane and path_workplane must start with the same letter") elif value == self.workplane: raise ValueError("workplane and path_workplane must be different") else: @@ -98,11 +96,7 @@ def create_solid(self): if self.force_cross_section: wire = Workplane(self.workplane).center(0, 0) for point in self.path_points[:-1]: - wire = ( - wire.workplane(offset=point[1] * factor) - .center(point[0], 0) - .circle(self.radius) - ) + wire = wire.workplane(offset=point[1] * factor).center(point[0], 0).circle(self.radius) wires.append(wire) diff --git a/paramak/parametric_shapes/sweep_mixed_shape.py b/paramak/parametric_shapes/sweep_mixed_shape.py index 6a7e7c335..f80fcdbe4 100644 --- a/paramak/parametric_shapes/sweep_mixed_shape.py +++ b/paramak/parametric_shapes/sweep_mixed_shape.py @@ -62,9 +62,7 @@ def path_workplane(self): @path_workplane.setter def path_workplane(self, value): if value[0] != self.workplane[0]: - raise ValueError( - "workplane and path_workplane must start with the same letter" - ) + raise ValueError("workplane and path_workplane must start with the same letter") elif value == self.workplane: raise ValueError("workplane and path_workplane must be different") else: diff --git a/paramak/reactor.py b/paramak/reactor.py index 9c34c22db..50e90876b 100644 --- a/paramak/reactor.py +++ b/paramak/reactor.py @@ -122,9 +122,7 @@ def largest_shapes(self): @largest_shapes.setter def largest_shapes(self, value): if not isinstance(value, (list, tuple, type(None))): - raise ValueError( - "paramak.Reactor.largest_shapes should be a " "list of paramak.Shapes" - ) + raise ValueError("paramak.Reactor.largest_shapes should be a " "list of paramak.Shapes") self._largest_shapes = value @property @@ -328,11 +326,7 @@ def export_dagmc_h5m( # allows components like the plasma to be removed if isinstance(exclude, Iterable): for name_to_remove in exclude: - key_and_part_id = { - key: val - for key, val in key_and_part_id.items() - if val != name_to_remove - } + key_and_part_id = {key: val for key, val in key_and_part_id.items() if val != name_to_remove} brep_to_h5m( brep_filename=tmp_brep_filename, @@ -386,9 +380,7 @@ def export_stp( assembly.save(filename, exportType="STEP") if units == "cm": - _replace( - filename, "SI_UNIT(.MILLI.,.METRE.)", "SI_UNIT(.CENTI.,.METRE.)" - ) + _replace(filename, "SI_UNIT(.MILLI.,.METRE.)", "SI_UNIT(.CENTI.,.METRE.)") return [filename] @@ -421,9 +413,7 @@ def export_stp( ) if units == "cm": - _replace( - stp_filename, "SI_UNIT(.MILLI.,.METRE.)", "SI_UNIT(.CENTI.,.METRE.)" - ) + _replace(stp_filename, "SI_UNIT(.MILLI.,.METRE.)", "SI_UNIT(.CENTI.,.METRE.)") return filename @@ -572,10 +562,7 @@ def make_sector_wedge( if hasattr(self, "rotation_angle"): rotation_angle = self.rotation_angle if rotation_angle is None: - Warning( - "No sector_wedge can be made as rotation_angle" - " or Reactor.rotation_angle have not been set" - ) + Warning("No sector_wedge can be made as rotation_angle" " or Reactor.rotation_angle have not been set") return None if rotation_angle > 360: @@ -755,9 +742,7 @@ def make_graveyard( elif self.graveyard_offset is not None: self.solid - graveyard_size_to_use = ( - self.largest_dimension * 2 + self.graveyard_offset * 2 - ) + graveyard_size_to_use = self.largest_dimension * 2 + self.graveyard_offset * 2 else: raise ValueError( @@ -818,9 +803,7 @@ def export_2d_image( return str(path_filename) - def export_html_3d( - self, filename: Optional[str] = "reactor_3d.html", **kwargs - ) -> Optional[str]: + def export_html_3d(self, filename: Optional[str] = "reactor_3d.html", **kwargs) -> Optional[str]: """Saves an interactive 3d html view of the Reactor to a html file. Args: diff --git a/paramak/shape.py b/paramak/shape.py index d0353902b..ec9647b82 100644 --- a/paramak/shape.py +++ b/paramak/shape.py @@ -260,13 +260,9 @@ def workplane(self, value): if value in acceptable_values: self._workplane = value else: - raise ValueError( - "Shape.workplane must be one of ", acceptable_values, " not ", value - ) + raise ValueError("Shape.workplane must be one of ", acceptable_values, " not ", value) else: - raise TypeError( - "Shape.workplane must be a string or a ", "cadquery.Plane object" - ) + raise TypeError("Shape.workplane must be a string or a ", "cadquery.Plane object") @property def rotation_axis(self): @@ -277,12 +273,7 @@ def rotation_axis(self, value): if isinstance(value, str): acceptable_values = ["X", "Y", "Z", "-X", "-Y", "-Z", "+X", "+Y", "+Z"] if value not in acceptable_values: - msg = ( - "Shape.rotation_axis must be one of " - + " ".join(acceptable_values) - + " not " - + value - ) + msg = "Shape.rotation_axis must be one of " + " ".join(acceptable_values) + " not " + value raise ValueError(msg) elif isinstance(value, Iterable): msg = "Shape.rotation_axis must be a tuple of three floats (X, Y, Z)" @@ -353,15 +344,9 @@ def color(self, value): if len(value) in [3, 4]: for i in value: if not isinstance(i, (int, float)): - raise ValueError( - "Individual entries in the Shape.color must a " - "number (float or int)" - ) + raise ValueError("Individual entries in the Shape.color must a " "number (float or int)") if i > 1 or i < 0: - raise ValueError( - "Individual entries in the Shape.color must be " - "between 0 and 1" - ) + raise ValueError("Individual entries in the Shape.color must be " "between 0 and 1") else: raise ValueError("Shape.color must be a list or tuple of 3 or 4 floats") else: @@ -420,9 +405,7 @@ def points(self): incorrect type: only list of lists or tuples are accepted """ ignored_keys = ["_points", "_points_hash_value"] - if self.find_points() and self.points_hash_value != get_hash( - self, ignored_keys - ): + if self.find_points() and self.points_hash_value != get_hash(self, ignored_keys): self.find_points() self.points_hash_value = get_hash(self, ignored_keys) @@ -440,18 +423,13 @@ def points(self, values_in): for value in values: if not isinstance(value, (list, tuple)): - msg = ( - f"individual points must be a tuple.{value} in of " - f"type {type(value)}" - ) + msg = f"individual points must be a tuple.{value} in of " f"type {type(value)}" raise ValueError(msg) for counter, value in enumerate(values): if self.connection_type == "mixed": if len(value) != 3: - if ( - counter != len(values) - 1 - ): # last point doesn't need connections + if counter != len(values) - 1: # last point doesn't need connections msg = ( "individual points should contain 3 " "entries when the Shape.connection_type is " @@ -492,17 +470,12 @@ def points(self, values_in): # part of points if len(value) == 3: if value[2] not in ["straight", "spline", "circle"]: - msg = ( - "individual connections must be either " - '"straight", "circle" or "spline"' - ) + msg = "individual connections must be either " '"straight", "circle" or "spline"' raise ValueError(msg) if len(values) > 1: if values[0][:2] == values[-1][:2]: - msg = ( - "The coordinates of the last and first points are " "the same." - ) + msg = "The coordinates of the last and first points are " "the same." raise ValueError(msg) self._points = values @@ -569,9 +542,7 @@ def show(self, **kwargs): scaled_color = [int(i * 255) for i in self.color[0:3]] if isinstance(self.solid, (shapes.Shape, shapes.Compound)): for i, solid in enumerate(self.solid.Solids()): - parts.append( - Part(solid, name=f"{name}{i}", color=scaled_color, show_edges=True) - ) + parts.append(Part(solid, name=f"{name}{i}", color=scaled_color, show_edges=True)) else: parts.append( Part( @@ -621,26 +592,18 @@ def create_solid(self) -> Workplane: if self.force_cross_section: for point in self.path_points[:-1]: - solid = ( - solid.workplane(offset=point[1] * factor) - .center(point[0], 0) - .workplane() - ) + solid = solid.workplane(offset=point[1] * factor).center(point[0], 0).workplane() for entry in instructions: connection_type = list(entry.keys())[0] if connection_type == "spline": - solid = solid.spline( - listOfXYTuple=list(entry.values())[0] - ) + solid = solid.spline(listOfXYTuple=list(entry.values())[0]) elif connection_type == "straight": solid = solid.polyline(list(entry.values())[0]) elif connection_type == "circle": p0, p1, p2 = list(entry.values())[0][:3] solid = solid.moveTo(p0[0], p0[1]).threePointArc(p1, p2) solid = solid.close() - solid = solid.center(-point[0], 0).workplane( - offset=-point[1] * factor - ) + solid = solid.center(-point[0], 0).workplane(offset=-point[1] * factor) elif self.force_cross_section is False: solid = ( @@ -1098,24 +1061,15 @@ def export_html( facet_splines=facet_splines, facet_circles=facet_circles, tolerance=tolerance, - title=( - f"coordinates of {self.__class__.__name__} shape, viewed " - "from the {view_plane} plane" - ), + title=(f"coordinates of {self.__class__.__name__} shape, viewed " "from the {view_plane} plane"), ) if self.points is not None: - fig.add_trace( - plotly_trace(points=self.points, mode="markers", name="Shape.points") - ) + fig.add_trace(plotly_trace(points=self.points, mode="markers", name="Shape.points")) # sweep shapes have .path_points but not .points attribute if self.path_points: - fig.add_trace( - plotly_trace( - points=self.path_points, mode="markers", name="Shape.path_points" - ) - ) + fig.add_trace(plotly_trace(points=self.path_points, mode="markers", name="Shape.path_points")) if filename is not None: @@ -1278,9 +1232,7 @@ def make_graveyard( elif self.graveyard_offset is not None: self.solid - graveyard_size_to_use = ( - self.largest_dimension * 2 + self.graveyard_offset * 2 - ) + graveyard_size_to_use = self.largest_dimension * 2 + self.graveyard_offset * 2 else: raise ValueError( @@ -1350,9 +1302,7 @@ def convert_all_circle_connections_to_splines( p_1 = self.processed_points[counter + 1][:2] p_2 = self.processed_points[counter + 2][:2] - points = paramak.utils.convert_circle_to_spline( - p_0, p_1, p_2, tolerance=tolerance - ) + points = paramak.utils.convert_circle_to_spline(p_0, p_1, p_2, tolerance=tolerance) # the last point needs to have the connection type of p2 for point in points[:-1]: diff --git a/paramak/utils.py b/paramak/utils.py index bc94042bf..a79d52de8 100644 --- a/paramak/utils.py +++ b/paramak/utils.py @@ -89,9 +89,7 @@ def facet_wire( return edges -def coefficients_of_line_from_points( - point_a: Tuple[float, float], point_b: Tuple[float, float] -) -> Tuple[float, float]: +def coefficients_of_line_from_points(point_a: Tuple[float, float], point_b: Tuple[float, float]) -> Tuple[float, float]: """Computes the m and c coefficients of the equation (y=mx+c) for a straight line from two points. @@ -148,9 +146,7 @@ def diff_between_angles(angle_a: float, angle_b: float) -> float: return delta_mod -def distance_between_two_points( - point_a: Tuple[float, float], point_b: Tuple[float, float] -) -> float: +def distance_between_two_points(point_a: Tuple[float, float], point_b: Tuple[float, float]) -> float: """Computes the distance between two points. Args: @@ -167,9 +163,7 @@ def distance_between_two_points( return np.linalg.norm(u_vec) -def extend( - point_a: Tuple[float, float], point_b: Tuple[float, float], L: float -) -> Tuple[float, float]: +def extend(point_a: Tuple[float, float], point_b: Tuple[float, float], L: float) -> Tuple[float, float]: """Creates a point C in (ab) direction so that \\|aC\\| = L Args: @@ -209,9 +203,7 @@ def find_center_point_of_circle( temp = point_b[0] * point_b[0] + point_b[1] * point_b[1] bc = (point_a[0] * point_a[0] + point_a[1] * point_a[1] - temp) / 2 cd = (temp - point_3[0] * point_3[0] - point_3[1] * point_3[1]) / 2 - det = (point_a[0] - point_b[0]) * (point_b[1] - point_3[1]) - ( - point_b[0] - point_3[0] - ) * (point_a[1] - point_b[1]) + det = (point_a[0] - point_b[0]) * (point_b[1] - point_3[1]) - (point_b[0] - point_3[0]) * (point_a[1] - point_b[1]) if abs(det) < 1.0e-6: return None @@ -239,9 +231,7 @@ def find_radius_of_circle( if center_point == edge_point: return np.inf - radius = np.sqrt( - (center_point[0] - edge_point[0]) ** 2 + (center_point[1] - edge_point[1]) ** 2 - ) + radius = np.sqrt((center_point[0] - edge_point[0]) ** 2 + (center_point[1] - edge_point[1]) ** 2) return radius @@ -318,9 +308,7 @@ def calculate_wedge_cut(self): return cutting_wedge -def add_thickness( - x: List[float], y: List[float], thickness: float, dy_dx: List[float] = None -) -> Tuple[list, list]: +def add_thickness(x: List[float], y: List[float], thickness: float, dy_dx: List[float] = None) -> Tuple[list, list]: """Computes outer curve points based on thickness Args: @@ -535,9 +523,7 @@ def extract_points_from_edges( elif view_plane == "XYZ": points.append((vertex.X, vertex.Y, vertex.Z)) else: - raise ValueError( - "view_plane value of ", view_plane, " is not supported" - ) + raise ValueError("view_plane value of ", view_plane, " is not supported") return points @@ -636,13 +622,9 @@ def export_wire_to_html( tolerance=tolerance, ) - points = paramak.utils.extract_points_from_edges( - edges=edges, view_plane=view_plane - ) + points = paramak.utils.extract_points_from_edges(edges=edges, view_plane=view_plane) - fig.add_trace( - plotly_trace(points=points, mode=mode, name="edge " + str(counter)) - ) + fig.add_trace(plotly_trace(points=points, mode=mode, name="edge " + str(counter))) for counter, wire in enumerate(list_of_wires): @@ -656,15 +638,9 @@ def export_wire_to_html( # this is for cadquery generated solids edges = wire.val().Edges() - points = paramak.utils.extract_points_from_edges( - edges=edges, view_plane=view_plane - ) + points = paramak.utils.extract_points_from_edges(edges=edges, view_plane=view_plane) - fig.add_trace( - plotly_trace( - points=points, mode="markers", name="points on wire " + str(counter) - ) - ) + fig.add_trace(plotly_trace(points=points, mode="markers", name="points on wire " + str(counter))) if filename is not None: @@ -748,10 +724,7 @@ def filter(self, object_list): face_area = obj.Area() # Only return faces that meet the requirements - if ( - face_area > self.area - self.tolerance - and face_area < self.area + self.tolerance - ): + if face_area > self.area - self.tolerance and face_area < self.area + self.tolerance: new_obj_list.append(obj) return new_obj_list @@ -793,10 +766,7 @@ def filter(self, object_list): edge_len = obj.Length() # Only return edges that meet our requirements - if ( - edge_len > self.length - self.tolerance - and edge_len < self.length + self.tolerance - ): + if edge_len > self.length - self.tolerance and edge_len < self.length + self.tolerance: new_obj_list.append(obj) print("length(new_obj_list)", len(new_obj_list)) diff --git a/tests/local_test_examples.py b/tests/local_test_examples.py index df19cd5cc..540dba135 100644 --- a/tests/local_test_examples.py +++ b/tests/local_test_examples.py @@ -63,9 +63,7 @@ def test_make_paramak_animation(self): def test_export_3d_image(self): """checks that export_3d_image() exports png files with the correct suffix""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)] - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)]) test_shape.rotation_angle = 360 os.system("rm filename.png") test_shape.export_3d_image("filename") diff --git a/tests/test_parametric_components/test_blanket_cutter_parallels.py b/tests/test_parametric_components/test_blanket_cutter_parallels.py index bbe4f3486..346098730 100644 --- a/tests/test_parametric_components/test_blanket_cutter_parallels.py +++ b/tests/test_parametric_components/test_blanket_cutter_parallels.py @@ -70,7 +70,4 @@ def test_main_cutting_shape_is_modified(self): test_shape.gap_size = gap_size test_shape.azimuth_placement_angle = angles assert test_shape.main_cutting_shape.distance == test_shape.gap_size / 2.0 - assert ( - test_shape.main_cutting_shape.azimuth_placement_angle - == test_shape.azimuth_placement_angle - ) + assert test_shape.main_cutting_shape.azimuth_placement_angle == test_shape.azimuth_placement_angle diff --git a/tests/test_parametric_components/test_blanket_fp.py b/tests/test_parametric_components/test_blanket_fp.py index e5a21613c..7a5f01ded 100644 --- a/tests/test_parametric_components/test_blanket_fp.py +++ b/tests/test_parametric_components/test_blanket_fp.py @@ -8,9 +8,7 @@ class TestBlanketFP(unittest.TestCase): def setUp(self): - self.plasma = paramak.Plasma( - major_radius=450, minor_radius=150, triangularity=0.55, elongation=2 - ) + self.plasma = paramak.Plasma(major_radius=450, minor_radius=150, triangularity=0.55, elongation=2) self.test_shape = paramak.BlanketFP( thickness=150, diff --git a/tests/test_parametric_components/test_capsule_vacuum_vessel.py b/tests/test_parametric_components/test_capsule_vacuum_vessel.py index 6dde0c998..462cc12e4 100644 --- a/tests/test_parametric_components/test_capsule_vacuum_vessel.py +++ b/tests/test_parametric_components/test_capsule_vacuum_vessel.py @@ -9,9 +9,7 @@ def perimeter(outer_start_point, radius, thickness): - test_shape = paramak.CapsuleVacuumVessel( - outer_start_point=outer_start_point, radius=radius, thickness=thickness - ) + test_shape = paramak.CapsuleVacuumVessel(outer_start_point=outer_start_point, radius=radius, thickness=thickness) point1 = test_shape.points[0] # point2 = test_shape.points[1] point3 = test_shape.points[2] @@ -26,10 +24,7 @@ def perimeter(outer_start_point, radius, thickness): point12 = test_shape.points[11] straightedges = float( - (point12[1] - point1[1]) - + (point6[1] - point7[1]) - + (point4[1] - point3[1]) - + (point9[1] - point10[1]) + (point12[1] - point1[1]) + (point6[1] - point7[1]) + (point4[1] - point3[1]) + (point9[1] - point10[1]) ) curvededges = float((math.pi * radius) + (math.pi * (radius - thickness))) total = float(straightedges + curvededges) @@ -56,27 +51,21 @@ def test_perimeter3(): def test_pointnum1(): """this tests if the number of points returned are correct""" - shape = paramak.CapsuleVacuumVessel( - outer_start_point=(0, 0), radius=300, thickness=10 - ) + shape = paramak.CapsuleVacuumVessel(outer_start_point=(0, 0), radius=300, thickness=10) assert len(shape.points) == 12 assert len(shape.processed_points) == 13 def test_pointnum2(): """this tests if the number of points returned are correct""" - shape = paramak.CapsuleVacuumVessel( - outer_start_point=(100, -100), radius=400, thickness=25 - ) + shape = paramak.CapsuleVacuumVessel(outer_start_point=(100, -100), radius=400, thickness=25) assert len(shape.points) == 12 assert len(shape.processed_points) == 13 def test_pointnum3(): """this tests if the number of points returned are correct""" - shape = paramak.CapsuleVacuumVessel( - outer_start_point=(1000, -500), radius=5000, thickness=50 - ) + shape = paramak.CapsuleVacuumVessel(outer_start_point=(1000, -500), radius=5000, thickness=50) assert len(shape.points) == 12 assert len(shape.processed_points) == 13 @@ -100,9 +89,7 @@ def volume(outer_start_point, radius, thickness, angle): point10 = test_shape.points[9] outer_volume_cylinder = float(math.pi * (radius**2) * (point4[1] - point3[1])) - inner_volume_cylinder = float( - math.pi * ((radius - thickness) ** 2) * (point9[1] - point10[1]) - ) + inner_volume_cylinder = float(math.pi * ((radius - thickness) ** 2) * (point9[1] - point10[1])) outer_volume_sphere = float((4 / 3) * math.pi * (radius**3)) inner_volume_sphere = float((4 / 3) * math.pi * ((radius - thickness) ** 3)) outer_volume = outer_volume_sphere + outer_volume_cylinder @@ -123,7 +110,5 @@ def testvolume2(): def testvolume3(): - testvol = volume( - outer_start_point=(1000, -500), radius=5000, thickness=50, angle=90 - ) + testvol = volume(outer_start_point=(1000, -500), radius=5000, thickness=50, angle=90) assert testvol == pytest.approx(7795207671.41) diff --git a/tests/test_parametric_components/test_center_column_shield_cylinder.py b/tests/test_parametric_components/test_center_column_shield_cylinder.py index 48807a8b8..9230e0c28 100644 --- a/tests/test_parametric_components/test_center_column_shield_cylinder.py +++ b/tests/test_parametric_components/test_center_column_shield_cylinder.py @@ -10,9 +10,7 @@ class TestCenterColumnShieldCylinder(unittest.TestCase): def setUp(self): - self.test_shape = paramak.CenterColumnShieldCylinder( - height=600, inner_radius=100, outer_radius=200 - ) + self.test_shape = paramak.CenterColumnShieldCylinder(height=600, inner_radius=100, outer_radius=200) def test_default_parameters(self): """Checks that the default parameters of a CenterColumnShieldCylinder are correct.""" @@ -63,9 +61,7 @@ def test_absolute_volume(self): """Creates a CenterColumnShieldCylinder shape and checks that its relative volume is correct""" - assert self.test_shape.volume() == pytest.approx( - ((math.pi * (200**2)) - (math.pi * (100**2))) * 600 - ) + assert self.test_shape.volume() == pytest.approx(((math.pi * (200**2)) - (math.pi * (100**2))) * 600) def test_absolute_area(self): """Creates a CenterColumnShieldCylinder shape and checks that the @@ -77,18 +73,9 @@ def test_absolute_area(self): + (math.pi * (2 * 200) * 600) + (math.pi * (2 * 100) * 600) ) - assert ( - self.test_shape.areas.count( - pytest.approx((math.pi * (200**2)) - (math.pi * (100**2))) - ) - == 2 - ) - assert ( - self.test_shape.areas.count(pytest.approx(math.pi * (2 * 200) * 600)) == 1 - ) - assert ( - self.test_shape.areas.count(pytest.approx(math.pi * (2 * 100) * 600)) == 1 - ) + assert self.test_shape.areas.count(pytest.approx((math.pi * (200**2)) - (math.pi * (100**2)))) == 2 + assert self.test_shape.areas.count(pytest.approx(math.pi * (2 * 200) * 600)) == 1 + assert self.test_shape.areas.count(pytest.approx(math.pi * (2 * 100) * 600)) == 1 def test_export_stp_CenterColumnShieldCylinder(self): """Creates a CenterColumnShieldCylinder shape and checks that a stp @@ -152,9 +139,7 @@ def test_center_height_usage(self): """Makes a offset cyclinder using center_height that overlaps half of the default center_height=0 shape. Cuts shapes and checks volumes. """ - test_shape1 = paramak.CenterColumnShieldCylinder( - inner_radius=3, outer_radius=3.3, height=5, color=(1, 0, 0) - ) + test_shape1 = paramak.CenterColumnShieldCylinder(inner_radius=3, outer_radius=3.3, height=5, color=(1, 0, 0)) test_shape2 = paramak.CenterColumnShieldCylinder( inner_radius=3, diff --git a/tests/test_parametric_components/test_coolant_channel_ring_straight.py b/tests/test_parametric_components/test_coolant_channel_ring_straight.py index 7ab9ce202..90b4b83a0 100644 --- a/tests/test_parametric_components/test_coolant_channel_ring_straight.py +++ b/tests/test_parametric_components/test_coolant_channel_ring_straight.py @@ -32,9 +32,7 @@ def test_faces(self): self.test_shape.workplane = "XY" self.test_shape.rotation_axis = "Z" - assert self.test_shape.area == pytest.approx( - (((math.pi * (10**2)) * 2) + (math.pi * (10 * 2) * 100)) * 8 - ) + assert self.test_shape.area == pytest.approx((((math.pi * (10**2)) * 2) + (math.pi * (10 * 2) * 100)) * 8) assert len(self.test_shape.areas) == 24 assert self.test_shape.areas.count(pytest.approx(math.pi * (10**2))) == 16 assert self.test_shape.areas.count(pytest.approx(math.pi * (10 * 2) * 100)) == 8 diff --git a/tests/test_parametric_components/test_cutting_wedge_fs.py b/tests/test_parametric_components/test_cutting_wedge_fs.py index 0a03b403f..ce4d07b24 100644 --- a/tests/test_parametric_components/test_cutting_wedge_fs.py +++ b/tests/test_parametric_components/test_cutting_wedge_fs.py @@ -11,9 +11,7 @@ def test_shape_construction_and_volume(self): volume of the cutter shape is larger than the shape it encompasses.""" - hoop_shape = paramak.PoloidalFieldCoil( - height=20, width=20, center_point=(50, 200), rotation_angle=180 - ) + hoop_shape = paramak.PoloidalFieldCoil(height=20, width=20, center_point=(50, 200), rotation_angle=180) cutter = paramak.CuttingWedgeFS( shape=hoop_shape, @@ -26,9 +24,7 @@ def test_invalid_parameters_errors(self): """Checks that the correct errors are raised when invalid arguments are input as shape parameters.""" - shape = paramak.ExtrudeStraightShape( - distance=1, points=[(0, 0), (0, 1), (1, 1)], rotation_angle=180 - ) + shape = paramak.ExtrudeStraightShape(distance=1, points=[(0, 0), (0, 1), (1, 1)], rotation_angle=180) cutter = paramak.CuttingWedgeFS( shape=shape, diff --git a/tests/test_parametric_components/test_extrude_hollow_rectangle.py b/tests/test_parametric_components/test_extrude_hollow_rectangle.py index 465ac2de0..92274cf0b 100644 --- a/tests/test_parametric_components/test_extrude_hollow_rectangle.py +++ b/tests/test_parametric_components/test_extrude_hollow_rectangle.py @@ -7,9 +7,7 @@ class TestExtrudeHollowRectangle(unittest.TestCase): def setUp(self): - self.test_shape = paramak.ExtrudeHollowRectangle( - height=10, width=15, casing_thickness=1, distance=2 - ) + self.test_shape = paramak.ExtrudeHollowRectangle(height=10, width=15, casing_thickness=1, distance=2) def test_default_parameters(self): """Checks that the default parameters of a ExtrudeHollowRectangle are diff --git a/tests/test_parametric_components/test_extrude_rectangle.py b/tests/test_parametric_components/test_extrude_rectangle.py index 7c2a9f102..e4c014236 100644 --- a/tests/test_parametric_components/test_extrude_rectangle.py +++ b/tests/test_parametric_components/test_extrude_rectangle.py @@ -7,9 +7,7 @@ class TestExtrudeRectangle(unittest.TestCase): def setUp(self): - self.test_shape = paramak.ExtrudeRectangle( - height=50, width=60, center_point=(1000, 500), distance=333 - ) + self.test_shape = paramak.ExtrudeRectangle(height=50, width=60, center_point=(1000, 500), distance=333) def test_default_parameters(self): """Checks that the default parameters of a ExtrudeRectangle are diff --git a/tests/test_parametric_components/test_hexagon_pin.py b/tests/test_parametric_components/test_hexagon_pin.py index 49f564b28..aff4f24a9 100644 --- a/tests/test_parametric_components/test_hexagon_pin.py +++ b/tests/test_parametric_components/test_hexagon_pin.py @@ -8,9 +8,7 @@ class TestHexagonPin(unittest.TestCase): def setUp(self): - self.test_shape = paramak.HexagonPin( - length_of_side=5, distance=42.0, center_point=(0, 0) - ) + self.test_shape = paramak.HexagonPin(length_of_side=5, distance=42.0, center_point=(0, 0)) def test_setting_parameters(self): """Checks that the default parameters and user parameters are set""" @@ -28,10 +26,7 @@ def test_volume(self): hexagon_face_area = (3 * math.sqrt(3) / 2) * math.pow(length, 2) # this needs a pytest.approx() as the volumes are not exact - assert ( - pytest.approx(self.test_shape.volume(), rel=0.1) - == hexagon_face_area * distance - ) + assert pytest.approx(self.test_shape.volume(), rel=0.1) == hexagon_face_area * distance def test_distance_impacts_volume(self): """Checks that changing the distance argument results in the diff --git a/tests/test_parametric_components/test_inboard_firstwall_fccs.py b/tests/test_parametric_components/test_inboard_firstwall_fccs.py index 25cb47ee6..56b789ceb 100644 --- a/tests/test_parametric_components/test_inboard_firstwall_fccs.py +++ b/tests/test_parametric_components/test_inboard_firstwall_fccs.py @@ -10,9 +10,7 @@ def test_construction_with_CenterColumnShieldCylinder(self): """Makes a firstwall from a CenterColumnShieldCylinder and checks the volume is smaller than the shield.""" - test_shape_1 = paramak.CenterColumnShieldCylinder( - height=100, inner_radius=20, outer_radius=80 - ) + test_shape_1 = paramak.CenterColumnShieldCylinder(height=100, inner_radius=20, outer_radius=80) test_shape_2 = paramak.InboardFirstwallFCCS( central_column_shield=test_shape_1, thickness=20, rotation_angle=180 ) @@ -24,12 +22,8 @@ def test_construction_with_CenterColumnShieldHyperbola(self): """Makes a firstwall from a CenterColumnShieldHyperbola and checks the volume is smaller than the shield.""" - a = paramak.CenterColumnShieldHyperbola( - height=200, inner_radius=20, mid_radius=80, outer_radius=120 - ) - b = paramak.InboardFirstwallFCCS( - central_column_shield=a, thickness=20, rotation_angle=180 - ) + a = paramak.CenterColumnShieldHyperbola(height=200, inner_radius=20, mid_radius=80, outer_radius=120) + b = paramak.InboardFirstwallFCCS(central_column_shield=a, thickness=20, rotation_angle=180) assert a.solid is not None assert b.solid is not None assert a.volume() > b.volume() @@ -41,9 +35,7 @@ def test_construction_with_CenterColumnShieldFlatTopHyperbola(self): a = paramak.CenterColumnShieldFlatTopHyperbola( height=200, arc_height=100, inner_radius=50, mid_radius=80, outer_radius=100 ) - b = paramak.InboardFirstwallFCCS( - central_column_shield=a, thickness=20, rotation_angle=180 - ) + b = paramak.InboardFirstwallFCCS(central_column_shield=a, thickness=20, rotation_angle=180) assert a.solid is not None assert b.solid is not None assert a.volume() > b.volume() @@ -52,12 +44,8 @@ def test_construction_with_CenterColumnShieldPlasmaHyperbola(self): """Makes a firstwall from a CenterColumnShieldPlasmaHyperbola and checks the volume is smaller than the shield.""" - a = paramak.CenterColumnShieldPlasmaHyperbola( - height=601, inner_radius=20, mid_offset=50, edge_offset=0 - ) - b = paramak.InboardFirstwallFCCS( - central_column_shield=a, thickness=20, rotation_angle=180 - ) + a = paramak.CenterColumnShieldPlasmaHyperbola(height=601, inner_radius=20, mid_offset=50, edge_offset=0) + b = paramak.InboardFirstwallFCCS(central_column_shield=a, thickness=20, rotation_angle=180) assert a.solid is not None assert b.solid is not None assert a.volume() > b.volume() @@ -66,12 +54,8 @@ def test_construction_with_CenterColumnShieldCircular(self): """Makes a firstwall from a CenterColumnShieldCircular and checks the volume is smaller than the shield.""" - a = paramak.CenterColumnShieldCircular( - height=300, inner_radius=20, mid_radius=50, outer_radius=100 - ) - b = paramak.InboardFirstwallFCCS( - central_column_shield=a, thickness=20, rotation_angle=180 - ) + a = paramak.CenterColumnShieldCircular(height=300, inner_radius=20, mid_radius=50, outer_radius=100) + b = paramak.InboardFirstwallFCCS(central_column_shield=a, thickness=20, rotation_angle=180) assert a.solid is not None assert b.solid is not None assert a.volume() > b.volume() @@ -83,9 +67,7 @@ def test_construction_with_CenterColumnShieldFlatTopCircular(self): a = paramak.CenterColumnShieldFlatTopCircular( height=500, arc_height=300, inner_radius=30, mid_radius=70, outer_radius=120 ) - b = paramak.InboardFirstwallFCCS( - central_column_shield=a, thickness=20, rotation_angle=180 - ) + b = paramak.InboardFirstwallFCCS(central_column_shield=a, thickness=20, rotation_angle=180) assert a.solid is not None assert b.solid is not None assert a.volume() > b.volume() @@ -95,9 +77,7 @@ def test_construction_with_string(): """Only CenterColumnShields are acceptable inputs for inputs, this should fail as it trys to use a string.""" - b = paramak.InboardFirstwallFCCS( - central_column_shield="incorrect type", thickness=20, rotation_angle=180 - ) + b = paramak.InboardFirstwallFCCS(central_column_shield="incorrect type", thickness=20, rotation_angle=180) b.solid self.assertRaises(ValueError, test_construction_with_string) @@ -153,12 +133,8 @@ def test_cut_attribute(self): """Creates a firstwall then resets its cut attribute and checks that the shape is not affected.""" - a = paramak.CenterColumnShieldCylinder( - height=100, inner_radius=20, outer_radius=80 - ) - b = paramak.InboardFirstwallFCCS( - central_column_shield=a, thickness=20, rotation_angle=180 - ) + a = paramak.CenterColumnShieldCylinder(height=100, inner_radius=20, outer_radius=80) + b = paramak.InboardFirstwallFCCS(central_column_shield=a, thickness=20, rotation_angle=180) volume_1 = b.volume() b.cut = None diff --git a/tests/test_parametric_components/test_plasma.py b/tests/test_parametric_components/test_plasma.py index 347e1b667..f7fb804a5 100644 --- a/tests/test_parametric_components/test_plasma.py +++ b/tests/test_parametric_components/test_plasma.py @@ -49,16 +49,12 @@ def major_radius_out_of_range(): def test_plasma_points_of_interest(self): test_plasma = paramak.Plasma(vertical_displacement=2) assert test_plasma.high_point == ( - test_plasma.major_radius - - test_plasma.triangularity * test_plasma.minor_radius, - test_plasma.elongation * test_plasma.minor_radius - + test_plasma.vertical_displacement, + test_plasma.major_radius - test_plasma.triangularity * test_plasma.minor_radius, + test_plasma.elongation * test_plasma.minor_radius + test_plasma.vertical_displacement, ) assert test_plasma.low_point == ( - test_plasma.major_radius - - test_plasma.triangularity * test_plasma.minor_radius, - -test_plasma.elongation * test_plasma.minor_radius - + test_plasma.vertical_displacement, + test_plasma.major_radius - test_plasma.triangularity * test_plasma.minor_radius, + -test_plasma.elongation * test_plasma.minor_radius + test_plasma.vertical_displacement, ) assert test_plasma.outer_equatorial_point == ( test_plasma.major_radius + test_plasma.minor_radius, @@ -74,13 +70,7 @@ def test_plasma_x_points(self): Plasma parametric component and checks the location of the x point for each.""" - for ( - triangularity, - elongation, - minor_radius, - major_radius, - vertical_displacement, - ) in zip( + for (triangularity, elongation, minor_radius, major_radius, vertical_displacement,) in zip( [-0.7, 0, 0.5], # triangularity [1, 1.5, 2], # elongation [100, 200, 300], # minor radius @@ -104,19 +94,14 @@ def test_plasma_x_points(self): expected_lower_x_point, expected_upper_x_point = None, None if config == "single-null" or config == "double-null": expected_lower_x_point = ( - 1 - - (1 + test_plasma.x_point_shift) - * triangularity - * minor_radius, - -(1 + test_plasma.x_point_shift) * elongation * minor_radius - + vertical_displacement, + 1 - (1 + test_plasma.x_point_shift) * triangularity * minor_radius, + -(1 + test_plasma.x_point_shift) * elongation * minor_radius + vertical_displacement, ) if config == "double-null": expected_upper_x_point = ( expected_lower_x_point[0], - (1 + test_plasma.x_point_shift) * elongation * minor_radius - + vertical_displacement, + (1 + test_plasma.x_point_shift) * elongation * minor_radius + vertical_displacement, ) # Check @@ -155,10 +140,7 @@ def test_plasma_x_points_plasmaboundaries(self): expected_lower_x_point, expected_upper_x_point = None, None if config == "single-null" or config == "double-null": expected_lower_x_point = ( - 1 - - (1 + test_plasma.x_point_shift) - * triangularity - * minor_radius, + 1 - (1 + test_plasma.x_point_shift) * triangularity * minor_radius, -(1 + test_plasma.x_point_shift) * elongation * minor_radius, ) @@ -213,9 +195,7 @@ def test_export_plasma_from_points_export(self): test_plasma.export_stp("plasma.stp") assert test_plasma.high_point[0] > test_plasma.inner_equatorial_x_point assert test_plasma.high_point[0] < test_plasma.outer_equatorial_x_point - assert ( - test_plasma.outer_equatorial_x_point > test_plasma.inner_equatorial_x_point - ) + assert test_plasma.outer_equatorial_x_point > test_plasma.inner_equatorial_x_point assert Path("plasma.stp").exists() os.system("rm plasma.stp") diff --git a/tests/test_parametric_components/test_poloidal_field_coil.py b/tests/test_parametric_components/test_poloidal_field_coil.py index 366baa03f..1065f5d2c 100644 --- a/tests/test_parametric_components/test_poloidal_field_coil.py +++ b/tests/test_parametric_components/test_poloidal_field_coil.py @@ -8,9 +8,7 @@ class TestPoloidalFieldCoil(unittest.TestCase): def setUp(self): - self.test_shape = paramak.PoloidalFieldCoil( - height=50, width=60, center_point=(1000, 500) - ) + self.test_shape = paramak.PoloidalFieldCoil(height=50, width=60, center_point=(1000, 500)) def test_default_parameters(self): """Checks that the default parameters of a PoloidalFieldCoil are correct.""" diff --git a/tests/test_parametric_components/test_poloidal_field_coil_case.py b/tests/test_parametric_components/test_poloidal_field_coil_case.py index 0e30377e9..cdcbae0a9 100644 --- a/tests/test_parametric_components/test_poloidal_field_coil_case.py +++ b/tests/test_parametric_components/test_poloidal_field_coil_case.py @@ -64,9 +64,7 @@ def test_absolute_volume(self): """Creates a pf coil case using the PoloidalFieldCoilCase parametric component and checks that its volume is correct.""" - assert self.test_shape.volume() == pytest.approx( - (math.pi * 2 * 1000) * ((60 * 5 * 2) + (50 * 5 * 2)) - ) + assert self.test_shape.volume() == pytest.approx((math.pi * 2 * 1000) * ((60 * 5 * 2) + (50 * 5 * 2))) def test_absolute_areas(self): """Creates a pf coil case using the PoloidalFieldCoilCase parametric diff --git a/tests/test_parametric_components/test_poloidal_field_coil_case_fc.py b/tests/test_parametric_components/test_poloidal_field_coil_case_fc.py index 68a5ce4dc..f6000c001 100644 --- a/tests/test_parametric_components/test_poloidal_field_coil_case_fc.py +++ b/tests/test_parametric_components/test_poloidal_field_coil_case_fc.py @@ -8,13 +8,9 @@ class TestPoloidalFieldCoilCaseFC(unittest.TestCase): def setUp(self): - self.pf_coil = paramak.PoloidalFieldCoil( - height=50, width=60, center_point=(1000, 500) - ) + self.pf_coil = paramak.PoloidalFieldCoil(height=50, width=60, center_point=(1000, 500)) - self.test_shape = paramak.PoloidalFieldCoilCaseFC( - pf_coil=self.pf_coil, casing_thickness=5 - ) + self.test_shape = paramak.PoloidalFieldCoilCaseFC(pf_coil=self.pf_coil, casing_thickness=5) def test_default_parameters(self): """Checks that the default parameters of a PoloidalFieldCoilCaseFC are correct.""" @@ -32,9 +28,7 @@ def test_absolute_volume(self): """Creates a pf coil case using the PoloidalFieldCoilCaseFC parametric component and checks that its volume is correct.""" - assert self.test_shape.volume() == pytest.approx( - (math.pi * 2 * 1000) * ((50 * 5 * 2) + (70 * 5 * 2)) - ) + assert self.test_shape.volume() == pytest.approx((math.pi * 2 * 1000) * ((50 * 5 * 2) + (70 * 5 * 2))) def test_absolute_areas(self): """Creates a pf coil case using the PoloidalFieldCoilCaseFC parametric diff --git a/tests/test_parametric_components/test_poloidal_field_coil_case_set.py b/tests/test_parametric_components/test_poloidal_field_coil_case_set.py index 015e6cb49..c7959cfff 100644 --- a/tests/test_parametric_components/test_poloidal_field_coil_case_set.py +++ b/tests/test_parametric_components/test_poloidal_field_coil_case_set.py @@ -199,9 +199,7 @@ def make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_1(): self.test_shape.casing_thicknesses = [5, 5, 10] self.test_shape.solid - self.assertRaises( - ValueError, make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_1 - ) + self.assertRaises(ValueError, make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_1) def test_PoloidalFieldCoil_incorrect_thicknesses_2(self): """Checks that an error is raised when a PoloidalFieldCoilCaseSet is made @@ -210,9 +208,7 @@ def test_PoloidalFieldCoil_incorrect_thicknesses_2(self): def make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_2(): self.test_shape.casing_thicknesses = [5, 5, 5, "ten"] - self.assertRaises( - ValueError, make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_2 - ) + self.assertRaises(ValueError, make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_2) def test_PoloidalFieldCoil_incorrect_thicknesses_3(self): """Checks that an error is raised when a PoloidalFieldCoilCaseSet is made @@ -221,6 +217,4 @@ def test_PoloidalFieldCoil_incorrect_thicknesses_3(self): def make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_3(): self.test_shape.casing_thicknesses = "ten" - self.assertRaises( - ValueError, make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_3 - ) + self.assertRaises(ValueError, make_PoloidalFieldCoilCaseSet_incorrect_thicknesses_3) diff --git a/tests/test_parametric_components/test_poloidal_field_coil_case_set_fc.py b/tests/test_parametric_components/test_poloidal_field_coil_case_set_fc.py index fde257fef..8586a62e9 100644 --- a/tests/test_parametric_components/test_poloidal_field_coil_case_set_fc.py +++ b/tests/test_parametric_components/test_poloidal_field_coil_case_set_fc.py @@ -179,9 +179,7 @@ def make_PoloidalFieldCoilCaseSetFC_incorrect_lengths_FC(): self.test_shape.casing_thicknesses = [5, 5, 10] self.test_shape.solid - self.assertRaises( - ValueError, make_PoloidalFieldCoilCaseSetFC_incorrect_lengths_FC - ) + self.assertRaises(ValueError, make_PoloidalFieldCoilCaseSetFC_incorrect_lengths_FC) def test_PoloidalFieldCoilCaseSetFC_incorrect_lengths(self): """Checks that an error is raised when a PoloidalFieldCoilCaseSetFC is made @@ -211,21 +209,13 @@ def test_from_list(self): """Creates a set of PF coil cases from a list of PF coils with a list of thicknesses.""" - pf_coils_1 = paramak.PoloidalFieldCoil( - height=10, width=10, center_point=(100, 100) - ) + pf_coils_1 = paramak.PoloidalFieldCoil(height=10, width=10, center_point=(100, 100)) - pf_coils_2 = paramak.PoloidalFieldCoil( - height=10, width=10, center_point=(100, 150) - ) + pf_coils_2 = paramak.PoloidalFieldCoil(height=10, width=10, center_point=(100, 150)) - pf_coils_3 = paramak.PoloidalFieldCoil( - height=20, width=20, center_point=(50, 200) - ) + pf_coils_3 = paramak.PoloidalFieldCoil(height=20, width=20, center_point=(50, 200)) - pf_coils_4 = paramak.PoloidalFieldCoil( - height=20, width=40, center_point=(50, 50) - ) + pf_coils_4 = paramak.PoloidalFieldCoil(height=20, width=40, center_point=(50, 50)) test_shape = paramak.PoloidalFieldCoilCaseSetFC( pf_coils=[pf_coils_1, pf_coils_2, pf_coils_3, pf_coils_4], @@ -239,21 +229,13 @@ def test_PoloidalFieldCoilCaseSetFC_with_number_thickness(self): """Creates a set of PF coil cases from a list of PF coils with a single numerical thicknesses.""" - pf_coils_1 = paramak.PoloidalFieldCoil( - height=10, width=10, center_point=(100, 100) - ) + pf_coils_1 = paramak.PoloidalFieldCoil(height=10, width=10, center_point=(100, 100)) - pf_coils_2 = paramak.PoloidalFieldCoil( - height=10, width=10, center_point=(100, 150) - ) + pf_coils_2 = paramak.PoloidalFieldCoil(height=10, width=10, center_point=(100, 150)) - pf_coils_3 = paramak.PoloidalFieldCoil( - height=20, width=20, center_point=(50, 200) - ) + pf_coils_3 = paramak.PoloidalFieldCoil(height=20, width=20, center_point=(50, 200)) - pf_coils_4 = paramak.PoloidalFieldCoil( - height=20, width=40, center_point=(50, 50) - ) + pf_coils_4 = paramak.PoloidalFieldCoil(height=20, width=40, center_point=(50, 50)) test_shape = paramak.PoloidalFieldCoilCaseSetFC( pf_coils=[pf_coils_1, pf_coils_2, pf_coils_3, pf_coils_4], diff --git a/tests/test_parametric_components/test_poloidal_field_coil_set.py b/tests/test_parametric_components/test_poloidal_field_coil_set.py index 3277eb31d..07241ba52 100644 --- a/tests/test_parametric_components/test_poloidal_field_coil_set.py +++ b/tests/test_parametric_components/test_poloidal_field_coil_set.py @@ -72,9 +72,7 @@ def test_absolute_volume(self): assert self.test_shape.volume() == ( pytest.approx( - (10 * 20 * math.pi * (2 * 100)) - + (15 * 25 * math.pi * (2 * 200)) - + (5 * 30 * math.pi * (2 * 300)) + (10 * 20 * math.pi * (2 * 100)) + (15 * 25 * math.pi * (2 * 200)) + (5 * 30 * math.pi * (2 * 300)) ) ) @@ -89,12 +87,8 @@ def test_absolute_areas(self): assert self.test_shape.areas.count(pytest.approx(30 * math.pi * (2 * 300))) == 2 assert self.test_shape.areas.count(pytest.approx(10 * math.pi * (2 * 90))) == 1 assert self.test_shape.areas.count(pytest.approx(10 * math.pi * (2 * 110))) == 1 - assert ( - self.test_shape.areas.count(pytest.approx(15 * math.pi * (2 * 187.5))) == 1 - ) - assert ( - self.test_shape.areas.count(pytest.approx(15 * math.pi * (2 * 212.5))) == 1 - ) + assert self.test_shape.areas.count(pytest.approx(15 * math.pi * (2 * 187.5))) == 1 + assert self.test_shape.areas.count(pytest.approx(15 * math.pi * (2 * 212.5))) == 1 assert self.test_shape.areas.count(pytest.approx(5 * math.pi * (2 * 285))) == 1 assert self.test_shape.areas.count(pytest.approx(5 * math.pi * (2 * 315))) == 1 @@ -129,9 +123,7 @@ def test_PoloidalFieldCoilSet_incorrect_center_points(self): with center_points passed as the wrong type.""" def make_PoloidalFieldCoilSet_incorrect_center_points(): - paramak.PoloidalFieldCoilSet( - heights=[10, 10, 10], widths=[20, 20, 20], center_points=100 - ) + paramak.PoloidalFieldCoilSet(heights=[10, 10, 10], widths=[20, 20, 20], center_points=100) self.assertRaises(ValueError, make_PoloidalFieldCoilSet_incorrect_center_points) diff --git a/tests/test_parametric_components/test_poloidal_segments.py b/tests/test_parametric_components/test_poloidal_segments.py index f91ec55dd..e40adb505 100644 --- a/tests/test_parametric_components/test_poloidal_segments.py +++ b/tests/test_parametric_components/test_poloidal_segments.py @@ -8,9 +8,7 @@ def test_solid_count_with_incorrect_input(self): """Checks the segmenter does not take a float as an input.""" def create_shape(): - test_shape_to_segment = paramak.PoloidalFieldCoil( - height=100, width=100, center_point=(500, 500) - ) + test_shape_to_segment = paramak.PoloidalFieldCoil(height=100, width=100, center_point=(500, 500)) paramak.PoloidalSegments( shape_to_segment=test_shape_to_segment, @@ -24,9 +22,7 @@ def test_solid_count_with_incorrect_inputs2(self): """Checks the segmenter does not take a negative int as an input.""" def create_shape(): - test_shape_to_segment = paramak.PoloidalFieldCoil( - height=100, width=100, center_point=(500, 500) - ) + test_shape_to_segment = paramak.PoloidalFieldCoil(height=100, width=100, center_point=(500, 500)) paramak.PoloidalSegments( shape_to_segment=test_shape_to_segment, @@ -40,13 +36,9 @@ def test_solid_count(self): """Creates a rotated hollow ring and segments it into poloidal sections.""" - pf_coil = paramak.PoloidalFieldCoil( - height=100, width=100, center_point=(500, 500) - ) + pf_coil = paramak.PoloidalFieldCoil(height=100, width=100, center_point=(500, 500)) - test_shape_to_segment = paramak.PoloidalFieldCoilCaseFC( - pf_coil=pf_coil, casing_thickness=100 - ) + test_shape_to_segment = paramak.PoloidalFieldCoilCaseFC(pf_coil=pf_coil, casing_thickness=100) test_shape = paramak.PoloidalSegments( shape_to_segment=test_shape_to_segment, @@ -60,9 +52,7 @@ def test_solid_count(self): def test_solid_count2(self): """Creates a rotated ring and segments it into poloidal sections.""" - test_shape_to_segment = paramak.PoloidalFieldCoil( - height=100, width=100, center_point=(500, 500) - ) + test_shape_to_segment = paramak.PoloidalFieldCoil(height=100, width=100, center_point=(500, 500)) test_shape = paramak.PoloidalSegments( shape_to_segment=test_shape_to_segment, diff --git a/tests/test_parametric_components/test_poloidally_segmented_blanket_fp.py b/tests/test_parametric_components/test_poloidally_segmented_blanket_fp.py index 1a278f380..b53c1b102 100644 --- a/tests/test_parametric_components/test_poloidally_segmented_blanket_fp.py +++ b/tests/test_parametric_components/test_poloidally_segmented_blanket_fp.py @@ -5,16 +5,12 @@ class TestBlanketFP(unittest.TestCase): def test_creation(self): - blanket = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=0, stop_angle=180, rotation_angle=180 - ) + blanket = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=0, stop_angle=180, rotation_angle=180) assert blanket.solid is not None def test_creation_with_optimiser(self): # Default - blanket = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=0, stop_angle=180, rotation_angle=180 - ) + blanket = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=0, stop_angle=180, rotation_angle=180) assert blanket.solid is not None # With limits @@ -34,9 +30,7 @@ def test_creation_with_optimiser(self): assert blanket.solid is not None def test_optimiser(self): - blanket = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=0, stop_angle=180, rotation_angle=180 - ) + blanket = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=0, stop_angle=180, rotation_angle=180) blanket.length_limits = (100, 300) blanket.nb_segments_limits = (2, 8) @@ -53,9 +47,7 @@ def test_modifying_nb_segments_limits(self): """creates a shape and checks that modifying the nb_segments_limits also modifies segmets_angles accordingly """ - blanket1 = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=0, stop_angle=180, rotation_angle=180 - ) + blanket1 = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=0, stop_angle=180, rotation_angle=180) blanket2 = paramak.BlanketFPPoloidalSegments( thickness=20, @@ -71,9 +63,7 @@ def test_modifying_nb_segments_limits(self): assert blanket2.volume() != 0 def test_segments_angles_is_modified_num_segments(self): - blanket1 = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=0, stop_angle=180, rotation_angle=180 - ) + blanket1 = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=0, stop_angle=180, rotation_angle=180) blanket2 = paramak.BlanketFPPoloidalSegments( thickness=20, @@ -88,17 +78,13 @@ def test_segments_angles_is_modified_num_segments(self): assert blanket2.volume() != 0 def test_num_point_is_affected(self): - blanket = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=0, stop_angle=180, rotation_angle=180 - ) + blanket = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=0, stop_angle=180, rotation_angle=180) assert blanket.num_points == blanket.num_segments + 1 blanket.num_segments = 60 assert blanket.num_points == blanket.num_segments + 1 def test_segment_angles_affects_solid(self): - blanket1 = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=0, stop_angle=180, rotation_angle=180 - ) + blanket1 = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=0, stop_angle=180, rotation_angle=180) blanket2 = paramak.BlanketFPPoloidalSegments( thickness=20, start_angle=0, @@ -110,9 +96,7 @@ def test_segment_angles_affects_solid(self): assert blanket2.volume() != 0 def test_warning_segment_angles(self): - blanket = paramak.BlanketFPPoloidalSegments( - thickness=20, start_angle=1, stop_angle=50, rotation_angle=180 - ) + blanket = paramak.BlanketFPPoloidalSegments(thickness=20, start_angle=1, stop_angle=50, rotation_angle=180) def warning1(): blanket.start_angle = 1 diff --git a/tests/test_parametric_components/test_port_cutter_rectangular.py b/tests/test_parametric_components/test_port_cutter_rectangular.py index 5ce707204..9fafffb88 100644 --- a/tests/test_parametric_components/test_port_cutter_rectangular.py +++ b/tests/test_parametric_components/test_port_cutter_rectangular.py @@ -7,9 +7,7 @@ class TestPortCutterRectangular(unittest.TestCase): def setUp(self): - self.test_shape = paramak.PortCutterRectangular( - width=20, height=40, distance=300 - ) + self.test_shape = paramak.PortCutterRectangular(width=20, height=40, distance=300) def test_default_parameters(self): """Checks that the default parameters of a PortCutterRectangular are correct.""" diff --git a/tests/test_parametric_components/test_port_cutter_rotated.py b/tests/test_parametric_components/test_port_cutter_rotated.py index 95c19a846..f5c08e7d1 100644 --- a/tests/test_parametric_components/test_port_cutter_rotated.py +++ b/tests/test_parametric_components/test_port_cutter_rotated.py @@ -27,9 +27,7 @@ def test_shape_construction_and_volume(self): rotation_angle=10, ) - vessel_with_out_ports = paramak.CenterColumnShieldCylinder( - height=500, inner_radius=200, outer_radius=300 - ) + vessel_with_out_ports = paramak.CenterColumnShieldCylinder(height=500, inner_radius=200, outer_radius=300) vessel_with_small_ports = paramak.CenterColumnShieldCylinder( height=500, inner_radius=200, outer_radius=300, cut=small_ports diff --git a/tests/test_parametric_components/test_shell_fs.py b/tests/test_parametric_components/test_shell_fs.py index 97ffb36fd..5dbbf48dd 100644 --- a/tests/test_parametric_components/test_shell_fs.py +++ b/tests/test_parametric_components/test_shell_fs.py @@ -6,9 +6,7 @@ class TestShellFS(unittest.TestCase): def setUp(self): # this is the shape that gets shelled - self.test_shape = paramak.PoloidalFieldCoil( - height=50, width=50, rotation_angle=90, center_point=(100, 100) - ) + self.test_shape = paramak.PoloidalFieldCoil(height=50, width=50, rotation_angle=90, center_point=(100, 100)) def test_creation_with_different_kinds(self): diff --git a/tests/test_parametric_components/test_test_tf_coil_casing.py b/tests/test_parametric_components/test_test_tf_coil_casing.py index 59fb7f299..1f42ac709 100644 --- a/tests/test_parametric_components/test_test_tf_coil_casing.py +++ b/tests/test_parametric_components/test_test_tf_coil_casing.py @@ -49,13 +49,7 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_components/test_toroidal_field_coil_coat_hanger.py b/tests/test_parametric_components/test_toroidal_field_coil_coat_hanger.py index f78314577..2e27b737d 100644 --- a/tests/test_parametric_components/test_toroidal_field_coil_coat_hanger.py +++ b/tests/test_parametric_components/test_toroidal_field_coil_coat_hanger.py @@ -82,9 +82,7 @@ def test_creation_with_inner_leg(self): assert self.test_shape.volume() > 1000 assert self.test_shape.inner_leg_connection_points is not None - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=30 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=30) assert test_inner_leg.solid is not None def test_creation_with_inner_leg_with_overlap(self): @@ -109,9 +107,7 @@ def test_creation_with_inner_leg_with_overlap(self): ) inner_leg_volume = test_inner_leg.volume() - assert with_inner_leg_volume == pytest.approx( - without_inner_leg_volume + inner_leg_volume - ) + assert with_inner_leg_volume == pytest.approx(without_inner_leg_volume + inner_leg_volume) def test_creation_no_inner_leg(self): """Creates a tf coil with no inner leg using the ToroidalFieldCoilRectangle @@ -119,9 +115,7 @@ def test_creation_no_inner_leg(self): test_volume = self.test_shape.volume() - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=30 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=30) inner_leg_volume = test_inner_leg.volume() self.test_shape.with_inner_leg = False @@ -137,10 +131,7 @@ def test_absolute_volume(self): (400 * 50 * 30 * 2) + ((50 * 50 * 30 / 2) * 2) + (50 * 500 * 30) - + ( - ((150 * 250 * 30) - (((100 * 250) / 2) * 30) - (((100 * 250) / 2) * 30)) - * 2 - ) + + (((150 * 250 * 30) - (((100 * 250) / 2) * 30) - (((100 * 250) / 2) * 30)) * 2) + (50 * 1000 * 30), rel=0.1, ) @@ -150,10 +141,7 @@ def test_absolute_volume(self): (400 * 50 * 30 * 2) + ((50 * 50 * 30 / 2) * 2) + (50 * 500 * 30) - + ( - ((150 * 250 * 30) - (((100 * 250) / 2) * 30) - (((100 * 250) / 2) * 30)) - * 2 - ), + + (((150 * 250 * 30) - (((100 * 250) / 2) * 30) - (((100 * 250) / 2) * 30)) * 2), rel=0.1, ) @@ -164,14 +152,7 @@ def test_absolute_volume(self): (400 * 50 * 30 * 2) + ((50 * 50 * 30 / 2) * 2) + (50 * 500 * 30) - + ( - ( - (150 * 250 * 30) - - (((100 * 250) / 2) * 30) - - (((100 * 250) / 2) * 30) - ) - * 2 - ) + + (((150 * 250 * 30) - (((100 * 250) / 2) * 30) - (((100 * 250) / 2) * 30)) * 2) + (50 * 1000 * 30) ) * 8, @@ -184,14 +165,7 @@ def test_absolute_volume(self): (400 * 50 * 30 * 2) + ((50 * 50 * 30 / 2) * 2) + (50 * 500 * 30) - + ( - ( - (150 * 250 * 30) - - (((100 * 250) / 2) * 30) - - (((100 * 250) / 2) * 30) - ) - * 2 - ) + + (((150 * 250 * 30) - (((100 * 250) / 2) * 30) - (((100 * 250) / 2) * 30)) * 2) ) * 8, rel=0.1, @@ -226,12 +200,7 @@ def test_absolute_area(self): # assert self.test_shape.areas.count(pytest.approx(50 * 30)) == 4 # assert self.test_shape.areas.count(pytest.approx(400 * 30)) == 4 assert self.test_shape.areas.count(pytest.approx(500 * 30)) == 2 - assert ( - self.test_shape.areas.count( - pytest.approx(((100**2 + 250**2) ** 0.5) * 30) - ) - == 4 - ) + assert self.test_shape.areas.count(pytest.approx(((100**2 + 250**2) ** 0.5) * 30)) == 4 # assert self.test_shape.areas.count(pytest.approx(50 * 1000)) == 2 # assert self.test_shape.areas.count(pytest.approx(1000 * 30)) == 2 diff --git a/tests/test_parametric_components/test_toroidal_field_coil_princetond.py b/tests/test_parametric_components/test_toroidal_field_coil_princetond.py index 4bc97275b..59108d7cb 100644 --- a/tests/test_parametric_components/test_toroidal_field_coil_princetond.py +++ b/tests/test_parametric_components/test_toroidal_field_coil_princetond.py @@ -31,9 +31,7 @@ def test_creation_with_inner_leg(self): assert self.test_shape.volume() > 1000 assert self.test_shape.inner_leg_connection_points is not None - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=30 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=30) assert test_inner_leg.solid is not None def test_creation_no_inner_leg(self): @@ -42,9 +40,7 @@ def test_creation_no_inner_leg(self): test_volume = self.test_shape.volume() - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=30 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=30) test_inner_leg.volume() self.test_shape.with_inner_leg = False diff --git a/tests/test_parametric_components/test_toroidal_field_coil_rectangle.py b/tests/test_parametric_components/test_toroidal_field_coil_rectangle.py index b08eb4e6e..147722820 100644 --- a/tests/test_parametric_components/test_toroidal_field_coil_rectangle.py +++ b/tests/test_parametric_components/test_toroidal_field_coil_rectangle.py @@ -65,9 +65,7 @@ def test_creation_with_inner_leg(self): assert self.test_shape.volume() > 1000 assert self.test_shape.inner_leg_connection_points is not None - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=30 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=30) assert test_inner_leg.solid is not None def test_creation_with_inner_leg_with_overlap(self): @@ -92,9 +90,7 @@ def test_creation_with_inner_leg_with_overlap(self): ) inner_leg_volume = test_inner_leg.volume() - assert with_inner_leg_volume == pytest.approx( - without_inner_leg_volume + inner_leg_volume - ) + assert with_inner_leg_volume == pytest.approx(without_inner_leg_volume + inner_leg_volume) def test_creation_no_inner_leg(self): """Creates a tf coil with no inner leg using the ToroidalFieldCoilRectangle @@ -102,9 +98,7 @@ def test_creation_no_inner_leg(self): test_volume = self.test_shape.volume() - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=30 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=30) inner_leg_volume = test_inner_leg.volume() self.test_shape.with_inner_leg = False @@ -118,25 +112,17 @@ def test_absolute_volume(self): self.test_shape.thickness = 150 self.test_shape.distance = 50 - assert self.test_shape.volume() == pytest.approx( - (850 * 150 * 50 * 2) + (1400 * 150 * 50 * 2) - ) + assert self.test_shape.volume() == pytest.approx((850 * 150 * 50 * 2) + (1400 * 150 * 50 * 2)) self.test_shape.with_inner_leg = False - assert self.test_shape.volume() == pytest.approx( - (850 * 150 * 50 * 2) + (1400 * 150 * 50) - ) + assert self.test_shape.volume() == pytest.approx((850 * 150 * 50 * 2) + (1400 * 150 * 50)) self.test_shape.with_inner_leg = True self.test_shape.number_of_coils = 8 - assert self.test_shape.volume() == pytest.approx( - ((850 * 150 * 50 * 2) + (1400 * 150 * 50 * 2)) * 8 - ) + assert self.test_shape.volume() == pytest.approx(((850 * 150 * 50 * 2) + (1400 * 150 * 50 * 2)) * 8) self.test_shape.with_inner_leg = False - assert self.test_shape.volume() == pytest.approx( - ((850 * 150 * 50 * 2) + (1400 * 150 * 50)) * 8 - ) + assert self.test_shape.volume() == pytest.approx(((850 * 150 * 50 * 2) + (1400 * 150 * 50)) * 8) def test_absolute_areas(self): """Creates tf coils using the ToroidalFieldCoilRectangle parametric @@ -212,9 +198,7 @@ def make_ToroidalFieldCoilRectangle_incorrect_horizontal_start_point(): self.test_shape.horizontal_start_point = (801, 700) self.test_shape.solid - self.assertRaises( - ValueError, make_ToroidalFieldCoilRectangle_incorrect_horizontal_start_point - ) + self.assertRaises(ValueError, make_ToroidalFieldCoilRectangle_incorrect_horizontal_start_point) def test_ToroidalFieldCoilRectangle_incorrect_vertical_mid_point(self): """Checks that an error is raised when a ToroidalFieldCoilRectangle is made @@ -225,6 +209,4 @@ def make_ToroidalFieldCoilRectangle_incorrect_vertical_mid_point(): self.test_shape.vertical_mid_point = (800, 701) self.test_shape.solid - self.assertRaises( - ValueError, make_ToroidalFieldCoilRectangle_incorrect_vertical_mid_point - ) + self.assertRaises(ValueError, make_ToroidalFieldCoilRectangle_incorrect_vertical_mid_point) diff --git a/tests/test_parametric_components/test_toroidal_field_coil_rectangle_round_corner.py b/tests/test_parametric_components/test_toroidal_field_coil_rectangle_round_corner.py index ab382330e..96c8c4f93 100644 --- a/tests/test_parametric_components/test_toroidal_field_coil_rectangle_round_corner.py +++ b/tests/test_parametric_components/test_toroidal_field_coil_rectangle_round_corner.py @@ -60,9 +60,7 @@ def surface_area( # XZ plane face area total_face_area = base_segment_area * 2 + vertical_segment_area + corner_area * 2 # The surface area of the planes in YZ plane - contour_length = ( - inner_rad * (pi - 8) + pi * outter_rad + 2 * (2 * base + thickness + height) - ) + contour_length = inner_rad * (pi - 8) + pi * outter_rad + 2 * (2 * base + thickness + height) extrusion_area = contour_length * extrusion_length # Total Area total_bounding_surface = total_face_area * 2 + extrusion_area @@ -72,9 +70,7 @@ def surface_area( total_face_area += thickness * height print(total_face_area) total_leg_surface_area = ( - 2 * height * thickness - + 2 * extrusion_length * height - + 2 * extrusion_length * thickness + 2 * height * thickness + 2 * extrusion_length * height + 2 * extrusion_length * thickness ) # Total bounding surface diff --git a/tests/test_parametric_components/test_toroidal_field_coil_triple_arc.py b/tests/test_parametric_components/test_toroidal_field_coil_triple_arc.py index 811f651fc..cf4500b64 100644 --- a/tests/test_parametric_components/test_toroidal_field_coil_triple_arc.py +++ b/tests/test_parametric_components/test_toroidal_field_coil_triple_arc.py @@ -32,9 +32,7 @@ def test_creation_with_inner_leg(self): assert self.test_shape.volume() > 1000 assert self.test_shape.inner_leg_connection_points is not None - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=50 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=50) assert test_inner_leg.solid is not None def test_creation_no_inner_leg(self): @@ -43,9 +41,7 @@ def test_creation_no_inner_leg(self): test_volume = self.test_shape.volume() - test_inner_leg = paramak.ExtrudeStraightShape( - points=self.test_shape.inner_leg_connection_points, distance=50 - ) + test_inner_leg = paramak.ExtrudeStraightShape(points=self.test_shape.inner_leg_connection_points, distance=50) inner_leg_volume = test_inner_leg.volume() self.test_shape.with_inner_leg = False diff --git a/tests/test_parametric_components/test_vacuum_vessel.py b/tests/test_parametric_components/test_vacuum_vessel.py index 295e1d794..eebad1850 100644 --- a/tests/test_parametric_components/test_vacuum_vessel.py +++ b/tests/test_parametric_components/test_vacuum_vessel.py @@ -23,18 +23,14 @@ def test_ports(self): cutter2 = paramak.PortCutterRectangular( 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 - ) + cutter3 = paramak.PortCutterRectangular(distance=3, center_point=(-0.5, 0), height=0.2, width=0.4) cutter4 = paramak.PortCutterCircular( distance=3, center_point=(0.25, 0), radius=0.1, azimuth_placement_angle=45, ) - cutter5 = paramak.PortCutterRotated( - (0, 0), azimuth_placement_angle=-90, rotation_angle=10, fillet_radius=0.01 - ) + cutter5 = paramak.PortCutterRotated((0, 0), azimuth_placement_angle=-90, rotation_angle=10, fillet_radius=0.01) pre_cut_volume = self.test_shape.volume() diff --git a/tests/test_parametric_reactors/test_ball_reactor.py b/tests/test_parametric_reactors/test_ball_reactor.py index 1f3c9b906..f5e3e9ded 100644 --- a/tests/test_parametric_reactors/test_ball_reactor.py +++ b/tests/test_parametric_reactors/test_ball_reactor.py @@ -125,9 +125,8 @@ def warning_trigger(): warning_trigger() assert len(w) == 1 assert issubclass(w[-1].category, UserWarning) - assert ( - "360 degree rotation may result in a Standard_ConstructionError or AttributeError" - in str(w[-1].message) + assert "360 degree rotation may result in a Standard_ConstructionError or AttributeError" in str( + w[-1].message ) def test_ball_reactor_hash_value(self): diff --git a/tests/test_parametric_reactors/test_center_column_study_reactor.py b/tests/test_parametric_reactors/test_center_column_study_reactor.py index c2c2d843f..65ee8e844 100644 --- a/tests/test_parametric_reactors/test_center_column_study_reactor.py +++ b/tests/test_parametric_reactors/test_center_column_study_reactor.py @@ -63,13 +63,9 @@ def test_rotation_angle_impacts_volume(self): volumes of all the components is double in the 180 reactor.""" self.test_reactor.rotation_angle = 90 - r90_comp_vols = [ - comp.volume() for comp in self.test_reactor.shapes_and_components - ] + r90_comp_vols = [comp.volume() for comp in self.test_reactor.shapes_and_components] self.test_reactor.rotation_angle = 180 - r180_comp_vols = [ - comp.volume() for comp in self.test_reactor.shapes_and_components - ] + r180_comp_vols = [comp.volume() for comp in self.test_reactor.shapes_and_components] for r90_vol, r180_vol in zip(r90_comp_vols, r180_comp_vols): assert r90_vol == pytest.approx(r180_vol * 0.5, rel=0.1) @@ -89,9 +85,8 @@ def warning_trigger(): warning_trigger() assert len(w) == 1 assert issubclass(w[-1].category, UserWarning) - assert ( - "360 degree rotation may result in a Standard_ConstructionError or AttributeError" - in str(w[-1].message) + assert "360 degree rotation may result in a Standard_ConstructionError or AttributeError" in str( + w[-1].message ) def test_export_brep(self): diff --git a/tests/test_parametric_reactors/test_eu_demo_2015_reactor.py b/tests/test_parametric_reactors/test_eu_demo_2015_reactor.py index 7be575304..af6f01714 100644 --- a/tests/test_parametric_reactors/test_eu_demo_2015_reactor.py +++ b/tests/test_parametric_reactors/test_eu_demo_2015_reactor.py @@ -95,9 +95,7 @@ def test_make_parametric_demo_2015_rector(self): ] os.system("rm *.stp") - my_reactor = paramak.EuDemoFrom2015PaperDiagram( - number_of_tf_coils=1, rotation_angle=90 - ) + my_reactor = paramak.EuDemoFrom2015PaperDiagram(number_of_tf_coils=1, rotation_angle=90) my_reactor.export_stp(filename=output_filenames) for output_filename in output_filenames: assert Path(output_filename).exists() is True diff --git a/tests/test_parametric_reactors/test_flf_system_code_reactor.py b/tests/test_parametric_reactors/test_flf_system_code_reactor.py index f7fb44c13..b1986c7d4 100644 --- a/tests/test_parametric_reactors/test_flf_system_code_reactor.py +++ b/tests/test_parametric_reactors/test_flf_system_code_reactor.py @@ -70,17 +70,12 @@ def test_blanket_volume_against_analytical_volume(self): outer_volume = ( math.pi * math.pow( - self.test_reactor.inner_blanket_radius - + self.test_reactor.blanket_thickness, + self.test_reactor.inner_blanket_radius + self.test_reactor.blanket_thickness, 2, ) * self.test_reactor.blanket_height ) - inner_volume = ( - math.pi - * math.pow(self.test_reactor.inner_blanket_radius, 2) - * self.test_reactor.blanket_height - ) + inner_volume = math.pi * math.pow(self.test_reactor.inner_blanket_radius, 2) * self.test_reactor.blanket_height sector_fraction = 360.0 / self.test_reactor.rotation_angle blanket_volume = (outer_volume - inner_volume) / sector_fraction diff --git a/tests/test_parametric_reactors/test_iter_reactor.py b/tests/test_parametric_reactors/test_iter_reactor.py index 190c4eb82..9fb0abd02 100644 --- a/tests/test_parametric_reactors/test_iter_reactor.py +++ b/tests/test_parametric_reactors/test_iter_reactor.py @@ -97,9 +97,7 @@ def test_make_parametric_iter_rector(self): "tf_coils.stp", ] os.system("rm *.stp") - my_reactor = paramak.IterFrom2020PaperDiagram( - number_of_tf_coils=1, rotation_angle=90 - ) + my_reactor = paramak.IterFrom2020PaperDiagram(number_of_tf_coils=1, rotation_angle=90) my_reactor.export_stp(filename=output_filenames) for output_filename in output_filenames: assert Path(output_filename).exists() is True diff --git a/tests/test_parametric_reactors/test_single_null_submersion_tokamak.py b/tests/test_parametric_reactors/test_single_null_submersion_tokamak.py index b1dd4b5cb..adb622717 100644 --- a/tests/test_parametric_reactors/test_single_null_submersion_tokamak.py +++ b/tests/test_parametric_reactors/test_single_null_submersion_tokamak.py @@ -62,13 +62,9 @@ def test_single_null_submersion_tokamak_rotation_angle_impacts_volume(self): checks that the relative volumes of the components are correct.""" self.test_reactor.rotation_angle = 90 - comps_90_vol = [ - comp.volume() for comp in self.test_reactor.shapes_and_components - ] + comps_90_vol = [comp.volume() for comp in self.test_reactor.shapes_and_components] self.test_reactor.rotation_angle = 180 - comps_180_vol = [ - comp.volume() for comp in self.test_reactor.shapes_and_components - ] + comps_180_vol = [comp.volume() for comp in self.test_reactor.shapes_and_components] for vol_90, vol_180 in zip(comps_90_vol, comps_180_vol): assert vol_90 == pytest.approx(vol_180 * 0.5, rel=0.1) diff --git a/tests/test_parametric_reactors/test_submersion_tokamak.py b/tests/test_parametric_reactors/test_submersion_tokamak.py index 9063382b0..e86787a30 100644 --- a/tests/test_parametric_reactors/test_submersion_tokamak.py +++ b/tests/test_parametric_reactors/test_submersion_tokamak.py @@ -210,10 +210,7 @@ def warning_trigger(): except BaseException: pass - msg = ( - "360 degree rotation may result in a " - + "Standard_ConstructionError or AttributeError" - ) + msg = "360 degree rotation may result in a " + "Standard_ConstructionError or AttributeError" with pytest.warns(UserWarning, match=msg): warning_trigger() diff --git a/tests/test_parametric_shapes/test_extrude_circle_shape.py b/tests/test_parametric_shapes/test_extrude_circle_shape.py index 9446356ce..57c93abb5 100644 --- a/tests/test_parametric_shapes/test_extrude_circle_shape.py +++ b/tests/test_parametric_shapes/test_extrude_circle_shape.py @@ -36,9 +36,7 @@ def test_absolute_shape_areas(self): """Creates ExtrudeCircleShapes and checks that the areas of each face are correct.""" - assert self.test_shape.area == pytest.approx( - (math.pi * (10**2) * 2) + (math.pi * (2 * 10) * 30) - ) + assert self.test_shape.area == pytest.approx((math.pi * (10**2) * 2) + (math.pi * (2 * 10) * 30)) assert len(self.test_shape.areas) == 3 assert self.test_shape.areas.count(pytest.approx(math.pi * (10**2))) == 2 assert self.test_shape.areas.count(pytest.approx(math.pi * (2 * 10) * 30)) == 1 @@ -47,13 +45,9 @@ def test_cut_volume(self): """Creates an ExtrudeCircleShape with another ExtrudeCircleShape cut out and checks that the volume is correct.""" - shape_with_cut = ExtrudeCircleShape( - points=[(30, 0)], radius=20, distance=40, cut=self.test_shape - ) + shape_with_cut = ExtrudeCircleShape(points=[(30, 0)], radius=20, distance=40, cut=self.test_shape) - assert shape_with_cut.volume() == pytest.approx( - (math.pi * (20**2) * 40) - (math.pi * (10**2) * 30) - ) + assert shape_with_cut.volume() == pytest.approx((math.pi * (20**2) * 40) - (math.pi * (10**2) * 30)) def test_intersect_volume(self): """Creates ExtrudeCircleShapes with other ExtrudeCircleShapes @@ -101,14 +95,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_extrude_mixed_shape.py b/tests/test_parametric_shapes/test_extrude_mixed_shape.py index 7ac61d34c..613d35dd9 100644 --- a/tests/test_parametric_shapes/test_extrude_mixed_shape.py +++ b/tests/test_parametric_shapes/test_extrude_mixed_shape.py @@ -167,14 +167,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - pytest.approx(Path("test_solid.stp").stat().st_size, rel=1) - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert pytest.approx(Path("test_solid.stp").stat().st_size, rel=1) == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") @@ -196,9 +190,7 @@ def test_convert_all_circle_points_change_to_splines(self): assert self.test_shape_2.processed_points[-4] == (150, 100, "straight") assert self.test_shape_2.processed_points[-5] == (200, 100, "straight") - for point in self.test_shape_2.processed_points[ - 1 : len(self.test_shape_2.points) - 5 - ]: + for point in self.test_shape_2.processed_points[1 : len(self.test_shape_2.points) - 5]: assert point[2] == "spline" def test_convert_circles_to_splines_volume(self): diff --git a/tests/test_parametric_shapes/test_extrude_spline_shape.py b/tests/test_parametric_shapes/test_extrude_spline_shape.py index 9cfa6afae..f60637438 100644 --- a/tests/test_parametric_shapes/test_extrude_spline_shape.py +++ b/tests/test_parametric_shapes/test_extrude_spline_shape.py @@ -58,13 +58,9 @@ def test_cut_volume(self): """Creates an ExtrudeSplineShape with another ExtrudeSplineShape cut out and checks that the volume is correct.""" - inner_shape = ExtrudeSplineShape( - points=[(5, 5), (5, 10), (10, 10), (10, 5)], distance=30 - ) + inner_shape = ExtrudeSplineShape(points=[(5, 5), (5, 10), (10, 10), (10, 5)], distance=30) - outer_shape = ExtrudeSplineShape( - points=[(3, 3), (3, 12), (12, 12), (12, 3)], distance=30 - ) + outer_shape = ExtrudeSplineShape(points=[(3, 3), (3, 12), (12, 12), (12, 3)], distance=30) outer_shape_with_cut = ExtrudeSplineShape( points=[(3, 3), (3, 12), (12, 12), (12, 3)], @@ -107,14 +103,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_extrude_straight_shape.py b/tests/test_parametric_shapes/test_extrude_straight_shape.py index 1e6d2a00f..3894d1363 100644 --- a/tests/test_parametric_shapes/test_extrude_straight_shape.py +++ b/tests/test_parametric_shapes/test_extrude_straight_shape.py @@ -10,9 +10,7 @@ class TestExtrudeStraightShape(unittest.TestCase): def setUp(self): - self.test_shape = ExtrudeStraightShape( - points=[(10, 10), (10, 30), (30, 30), (30, 10)], distance=30 - ) + self.test_shape = ExtrudeStraightShape(points=[(10, 10), (10, 30), (30, 30), (30, 10)], distance=30) def test_workplane_of_type_cadquery_plane(self): """Tests that a Cadquery.Plane is accepted as a workplane entry and @@ -130,14 +128,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_rotate_circle_shape.py b/tests/test_parametric_shapes/test_rotate_circle_shape.py index 79432040a..f2a2945f3 100644 --- a/tests/test_parametric_shapes/test_rotate_circle_shape.py +++ b/tests/test_parametric_shapes/test_rotate_circle_shape.py @@ -26,9 +26,7 @@ def test_absolute_shape_volume(self): # 2 * math.pi * 60 * math.pi * (10**2) # ) self.test_shape.rotation_angle = 270 - assert self.test_shape.volume() == pytest.approx( - 2 * math.pi * 60 * math.pi * (10**2) * 0.75 - ) + assert self.test_shape.volume() == pytest.approx(2 * math.pi * 60 * math.pi * (10**2) * 0.75) def test_absolute_shape_areas(self): """Creates RotateCircleShapes and checks that the areas of each face are @@ -48,12 +46,7 @@ def test_absolute_shape_areas(self): ) assert len(self.test_shape.areas) == 3 assert self.test_shape.areas.count(pytest.approx(math.pi * (10**2))) == 2 - assert ( - self.test_shape.areas.count( - pytest.approx(math.pi * (10 * 2) * math.pi * (60 * 2) / 2, rel=0.01) - ) - == 1 - ) + assert self.test_shape.areas.count(pytest.approx(math.pi * (10 * 2) * math.pi * (60 * 2) / 2, rel=0.01)) == 1 def test_relative_shape_volume_azimuth_placement_angle(self): """Creates two RotateCircleShapes with different @@ -61,14 +54,10 @@ def test_relative_shape_volume_azimuth_placement_angle(self): correct.""" self.test_shape.rotation_angle = 10 - assert self.test_shape.volume() == pytest.approx( - (math.pi * 10**2) * ((2 * math.pi * 60) / 36) - ) + assert self.test_shape.volume() == pytest.approx((math.pi * 10**2) * ((2 * math.pi * 60) / 36)) self.test_shape.azimuth_placement_angle = [0, 90, 180, 270] - assert self.test_shape.volume() == pytest.approx( - (math.pi * 10**2) * ((2 * math.pi * 60) / 36) * 4 - ) + assert self.test_shape.volume() == pytest.approx((math.pi * 10**2) * ((2 * math.pi * 60) / 36) * 4) def test_cut_volume(self): """Creates a RotateCircleShape with another RotateCircleShape cut out @@ -77,9 +66,7 @@ def test_cut_volume(self): outer_shape = RotateCircleShape(points=[(60, 0)], radius=15) outer_shape_volume = outer_shape.volume() outer_shape.cut = self.test_shape - assert outer_shape.volume() == pytest.approx( - outer_shape_volume - self.test_shape.volume() - ) + assert outer_shape.volume() == pytest.approx(outer_shape_volume - self.test_shape.volume()) def test_export_stp(self): """Exports and stp file with mode = solid and wire and checks @@ -95,10 +82,7 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size # the circle wire file is actually larger than the circle solid file # assert Path("test_wire.stp").stat().st_size < \ # Path("test_solid2.stp").stat().st_size diff --git a/tests/test_parametric_shapes/test_rotate_mixed_shape.py b/tests/test_parametric_shapes/test_rotate_mixed_shape.py index e4767af1d..19036f65f 100644 --- a/tests/test_parametric_shapes/test_rotate_mixed_shape.py +++ b/tests/test_parametric_shapes/test_rotate_mixed_shape.py @@ -127,9 +127,7 @@ def test_union_volume_addition(self): union=inner_box, ) - assert inner_box.volume() + outer_box.volume() == pytest.approx( - outer_box_and_inner_box.volume() - ) + assert inner_box.volume() + outer_box.volume() == pytest.approx(outer_box_and_inner_box.volume()) def test_incorrect_connections(self): """Checks that errors are raised when invalid connection arguments are @@ -154,9 +152,7 @@ def incorrect_number_of_connections_function(): """Checks ValueError is raised when an incorrect number of connections is specified.""" - RotateMixedShape( - points=[(0, 200, "straight"), (200, 100), (0, 0, "spline")] - ) + RotateMixedShape(points=[(0, 200, "straight"), (200, 100), (0, 0, "spline")]) self.assertRaises(ValueError, incorrect_number_of_connections_function) @@ -177,9 +173,7 @@ def test_cut_volume(self): ) outer_shape_volume = outer_shape.volume() outer_shape.cut = self.test_shape - assert outer_shape.volume() == pytest.approx( - outer_shape_volume - self.test_shape.volume() - ) + assert outer_shape.volume() == pytest.approx(outer_shape_volume - self.test_shape.volume()) def test_mixed_shape_with_straight_and_circle(self): """Creates a RotateMixedShape with straight and circular connections and @@ -231,14 +225,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_rotate_spline_shape.py b/tests/test_parametric_shapes/test_rotate_spline_shape.py index e1a3e0210..8d22f8ecc 100644 --- a/tests/test_parametric_shapes/test_rotate_spline_shape.py +++ b/tests/test_parametric_shapes/test_rotate_spline_shape.py @@ -47,13 +47,9 @@ def test_cut_volume(self): """Creates a RotateSplineShape with another RotateSplineShape cut out and checks that the volume is correct.""" - inner_shape = RotateSplineShape( - points=[(5, 5), (5, 10), (10, 10), (10, 5)], rotation_angle=180 - ) + inner_shape = RotateSplineShape(points=[(5, 5), (5, 10), (10, 10), (10, 5)], rotation_angle=180) - outer_shape = RotateSplineShape( - points=[(3, 3), (3, 12), (12, 12), (12, 3)], rotation_angle=180 - ) + outer_shape = RotateSplineShape(points=[(3, 3), (3, 12), (12, 12), (12, 3)], rotation_angle=180) outer_shape_with_cut = RotateSplineShape( points=[(3, 3), (3, 12), (12, 12), (12, 3)], @@ -90,14 +86,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_rotate_straight_shape.py b/tests/test_parametric_shapes/test_rotate_straight_shape.py index 3e3fc7262..0f4c290ca 100644 --- a/tests/test_parametric_shapes/test_rotate_straight_shape.py +++ b/tests/test_parametric_shapes/test_rotate_straight_shape.py @@ -9,9 +9,7 @@ class TestRotateStraightShape(unittest.TestCase): def setUp(self): - self.test_shape = RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)] - ) + self.test_shape = RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)]) def test_largest_dimension(self): """Checks that the largest_dimension is correct.""" @@ -62,17 +60,13 @@ def test_union_volume_addition(self): union=inner_box, ) - assert inner_box.volume() + outer_box.volume() == pytest.approx( - outer_box_and_inner_box.volume(), rel=0.01 - ) + assert inner_box.volume() + outer_box.volume() == pytest.approx(outer_box_and_inner_box.volume(), rel=0.01) def test_absolute_shape_areas(self): """Creates RotateStraightShapes and checks that the areas of each face are correct.""" - assert self.test_shape.area == pytest.approx( - (math.pi * (20**2) * 2) + (math.pi * (20 * 2) * 20) - ) + assert self.test_shape.area == pytest.approx((math.pi * (20**2) * 2) + (math.pi * (20 * 2) * 20)) assert len(self.test_shape.areas) == 3 assert self.test_shape.areas.count(pytest.approx(math.pi * (20**2))) == 2 assert self.test_shape.areas.count(pytest.approx(math.pi * (20 * 2) * 20)) == 1 @@ -84,10 +78,7 @@ def test_absolute_shape_areas(self): assert len(self.test_shape.areas) == 4 assert self.test_shape.areas.count(pytest.approx(math.pi * (20**2) / 2)) == 2 assert self.test_shape.areas.count(pytest.approx(20 * 40)) == 1 - assert ( - self.test_shape.areas.count(pytest.approx((math.pi * (20 * 2) * 20) / 2)) - == 1 - ) + assert self.test_shape.areas.count(pytest.approx((math.pi * (20 * 2) * 20) / 2)) == 1 test_shape = RotateStraightShape( points=[(50, 0), (50, 50), (70, 50), (70, 0)], @@ -99,12 +90,7 @@ def test_absolute_shape_areas(self): + (math.pi * (70 * 2) * 50) ) assert len(test_shape.areas) == 4 - assert ( - test_shape.areas.count( - pytest.approx((math.pi * (70**2)) - (math.pi * (50**2))) - ) - == 2 - ) + assert test_shape.areas.count(pytest.approx((math.pi * (70**2)) - (math.pi * (50**2)))) == 2 assert test_shape.areas.count(pytest.approx(math.pi * (50 * 2) * 50)) == 1 assert test_shape.areas.count(pytest.approx(math.pi * (70 * 2) * 50)) == 1 @@ -117,12 +103,7 @@ def test_absolute_shape_areas(self): ) assert len(test_shape.areas) == 6 assert test_shape.areas.count(pytest.approx(20 * 50)) == 2 - assert ( - test_shape.areas.count( - pytest.approx(((math.pi * (70**2)) / 2) - ((math.pi * (50**2)) / 2)) - ) - == 2 - ) + assert test_shape.areas.count(pytest.approx(((math.pi * (70**2)) / 2) - ((math.pi * (50**2)) / 2))) == 2 assert test_shape.areas.count(pytest.approx(math.pi * (50 * 2) * 50 / 2)) == 1 assert test_shape.areas.count(pytest.approx(math.pi * (70 * 2) * 50 / 2)) == 1 @@ -208,13 +189,9 @@ def test_cut_volume(self): """Creates a RotateStraightShape with another RotateStraightShape cut out and checks that the volume is correct.""" - shape_with_cut = RotateStraightShape( - points=[(0, -5), (0, 25), (25, 25), (25, -5)], cut=self.test_shape - ) + shape_with_cut = RotateStraightShape(points=[(0, -5), (0, 25), (25, 25), (25, -5)], cut=self.test_shape) - assert shape_with_cut.volume() == pytest.approx( - (math.pi * (25**2) * 30) - (math.pi * (20**2) * 20) - ) + assert shape_with_cut.volume() == pytest.approx((math.pi * (25**2) * 30) - (math.pi * (20**2) * 20)) def test_multiple_cut_volume(self): """Creates a RotateStraightShape with multiple RotateStraightShapes @@ -273,14 +250,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_sweep_circle_shape.py b/tests/test_parametric_shapes/test_sweep_circle_shape.py index 2e9bb83e5..6a12f49a4 100644 --- a/tests/test_parametric_shapes/test_sweep_circle_shape.py +++ b/tests/test_parametric_shapes/test_sweep_circle_shape.py @@ -10,9 +10,7 @@ class TestSweepCircleShape(unittest.TestCase): def setUp(self): - self.test_shape = SweepCircleShape( - radius=10, path_points=[(50, 0), (30, 50), (70, 100), (50, 150)] - ) + self.test_shape = SweepCircleShape(radius=10, path_points=[(50, 0), (30, 50), (70, 100), (50, 150)]) def test_default_parameters(self): """Checks that the default parameters of a SweepCircleShape are correct.""" @@ -90,30 +88,19 @@ def test_force_cross_section(self): self.test_shape.force_cross_section = True - assert ( - self.test_shape.areas.count(pytest.approx(math.pi * (10**2), rel=0.01)) - == 2 - ) + assert self.test_shape.areas.count(pytest.approx(math.pi * (10**2), rel=0.01)) == 2 cutting_shape = RotateStraightShape( points=[(0, 50), (0, 200), (100, 200), (100, 50)], ) self.test_shape.cut = cutting_shape - assert ( - self.test_shape.areas.count(pytest.approx(math.pi * (10**2), rel=0.01)) - == 2 - ) + assert self.test_shape.areas.count(pytest.approx(math.pi * (10**2), rel=0.01)) == 2 - cutting_shape = RotateStraightShape( - points=[(0, 100), (0, 200), (100, 200), (100, 100)] - ) + cutting_shape = RotateStraightShape(points=[(0, 100), (0, 200), (100, 200), (100, 100)]) self.test_shape.cut = cutting_shape - assert ( - self.test_shape.areas.count(pytest.approx(math.pi * (10**2), rel=0.01)) - == 2 - ) + assert self.test_shape.areas.count(pytest.approx(math.pi * (10**2), rel=0.01)) == 2 def test_force_cross_section_volume(self): """Checks that a SweepCircleShape with a larger volume is created when @@ -144,14 +131,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_sweep_mixed_shape.py b/tests/test_parametric_shapes/test_sweep_mixed_shape.py index f6b52edc5..908862cf4 100644 --- a/tests/test_parametric_shapes/test_sweep_mixed_shape.py +++ b/tests/test_parametric_shapes/test_sweep_mixed_shape.py @@ -106,9 +106,7 @@ def test_force_cross_section(self): assert self.test_shape.areas.count(pytest.approx(test_area, rel=0.01)) == 2 - cutting_shape = RotateStraightShape( - points=[(0, 50), (0, 200), (100, 200), (100, 50)] - ) + cutting_shape = RotateStraightShape(points=[(0, 50), (0, 200), (100, 200), (100, 50)]) self.test_shape.cut = cutting_shape assert self.test_shape.areas.count(pytest.approx(test_area, rel=0.01)) == 2 @@ -147,14 +145,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_sweep_spline_shape.py b/tests/test_parametric_shapes/test_sweep_spline_shape.py index 010e34ec4..69572c891 100644 --- a/tests/test_parametric_shapes/test_sweep_spline_shape.py +++ b/tests/test_parametric_shapes/test_sweep_spline_shape.py @@ -61,9 +61,7 @@ def test_force_cross_section(self): assert self.test_shape.areas.count(pytest.approx(test_area, rel=0.01)) == 2 - cutting_shape = RotateStraightShape( - points=[(0, 50), (0, 200), (100, 200), (100, 50)] - ) + cutting_shape = RotateStraightShape(points=[(0, 50), (0, 200), (100, 200), (100, 50)]) self.test_shape.cut = cutting_shape assert self.test_shape.areas.count(pytest.approx(test_area, rel=0.01)) == 2 @@ -102,14 +100,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_parametric_shapes/test_sweep_straight_shape.py b/tests/test_parametric_shapes/test_sweep_straight_shape.py index 85ad05937..644483f83 100644 --- a/tests/test_parametric_shapes/test_sweep_straight_shape.py +++ b/tests/test_parametric_shapes/test_sweep_straight_shape.py @@ -97,14 +97,8 @@ def test_export_stp(self): assert Path("test_solid2.stp").exists() is True assert Path("test_wire.stp").exists() is True - assert ( - Path("test_solid.stp").stat().st_size - == Path("test_solid2.stp").stat().st_size - ) - assert ( - Path("test_wire.stp").stat().st_size - < Path("test_solid2.stp").stat().st_size - ) + assert Path("test_solid.stp").stat().st_size == Path("test_solid2.stp").stat().st_size + assert Path("test_wire.stp").stat().st_size < Path("test_solid2.stp").stat().st_size os.system("rm test_solid.stp test_solid2.stp test_wire.stp") diff --git a/tests/test_reactor.py b/tests/test_reactor.py index f44e6c781..0d0393aa2 100644 --- a/tests/test_reactor.py +++ b/tests/test_reactor.py @@ -10,9 +10,7 @@ class TestReactor(unittest.TestCase): def setUp(self): - self.test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], name="test_shape" - ) + self.test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)], name="test_shape") self.test_shape2 = paramak.ExtrudeStraightShape( points=[(100, 100), (50, 100), (50, 50)], distance=20, name="test_shape2" @@ -44,9 +42,7 @@ def incorrect_name(): def test_reactor_export_stp(self): """Exports the reactor as separate files and as a single file""" os.system("rm *.stp") - self.test_reactor_2.export_stp( - filename=["RotateStraightShape.stp", "ExtrudeStraightShape.stp"] - ) + self.test_reactor_2.export_stp(filename=["RotateStraightShape.stp", "ExtrudeStraightShape.stp"]) assert Path("RotateStraightShape.stp").is_file() assert Path("ExtrudeStraightShape.stp").is_file() self.test_reactor_2.export_stp(filename="single_file.stp", units="cm") @@ -85,16 +81,12 @@ def test_largest_dimension_setting_and_getting_using_largest_shapes(self): def test_make_sector_wedge(self): """Checks that the wedge is not made when rotation angle is 360""" - sector_wedge = self.test_reactor.make_sector_wedge( - height=100, radius=100, rotation_angle=360 - ) + sector_wedge = self.test_reactor.make_sector_wedge(height=100, radius=100, rotation_angle=360) assert sector_wedge is None def test_wrong_number_of_filenames(self): def test_stl_filename_list_length(): - test_shape = paramak.ExtrudeCircleShape( - points=[(20, 20)], radius=10, distance=10 - ) + test_shape = paramak.ExtrudeCircleShape(points=[(20, 20)], radius=10, distance=10) my_reactor = paramak.Reactor([test_shape]) my_reactor.export_stl(["wrong.stl", "number_of.stl", "files.stl"]) @@ -191,9 +183,7 @@ def test_make_graveyard_offset(self): test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)]) os.system("rm graveyard.stp") - test_reactor = paramak.Reactor( - [test_shape], graveyard_size=None, graveyard_offset=100 - ) + test_reactor = paramak.Reactor([test_shape], graveyard_size=None, graveyard_offset=100) test_reactor.make_graveyard() graveyard_volume_1 = test_reactor.graveyard.volume() @@ -432,9 +422,7 @@ def test_compound_in_shapes(self): shape1 = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)]) shape2 = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)]) shape3 = paramak.Shape() - shape3.solid = cq.Compound.makeCompound( - [a.val() for a in [shape1.solid, shape2.solid]] - ) + shape3.solid = cq.Compound.makeCompound([a.val() for a in [shape1.solid, shape2.solid]]) test_reactor = paramak.Reactor([shape3]) assert test_reactor.solid is not None diff --git a/tests/test_shape.py b/tests/test_shape.py index 1ce1dae55..4c6aefd1d 100644 --- a/tests/test_shape.py +++ b/tests/test_shape.py @@ -79,9 +79,7 @@ def test_make_graveyard_offset(self): """checks that the graveyard can be exported with the correct default parameters and that these parameters can be changed""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], graveyard_size=None - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)], graveyard_size=None) os.system("rm graveyard.stp") test_shape.make_graveyard(graveyard_offset=50) @@ -265,9 +263,7 @@ def test_initial_solid_construction(self): """Creates a shape and checks that a cadquery solid with a unique hash value is created when .solid is called.""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360 - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360) assert test_shape.hash_value is None assert test_shape.solid is not None @@ -279,9 +275,7 @@ def test_solid_return(self): is returned when shape.solid is called again after no changes have been made to the Shape.""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360 - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360) assert test_shape.solid is not None initial_hash_value = test_shape.hash_value @@ -293,9 +287,7 @@ def test_conditional_solid_reconstruction(self): constructed when shape.solid is called after changes to the Shape have been made.""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], rotation_angle=360 - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)], rotation_angle=360) assert test_shape.solid is not None assert test_shape.hash_value is not None @@ -311,9 +303,7 @@ def test_hash_value_update(self): """Checks that the hash value of a Shape is not updated until a new cadquery solid has been created.""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], rotation_angle=360 - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)], rotation_angle=360) test_shape.solid assert test_shape.hash_value is not None initial_hash_value = test_shape.hash_value @@ -327,9 +317,7 @@ def test_export_html(self): """Checks a plotly figure of the Shape is exported by the export_html method with the correct filename with RGB and RGBA colors.""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360 - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360) os.system("rm filename.html") test_shape.export_html("filename") @@ -344,9 +332,7 @@ def test_export_html_view_planes(self): """Checks a plotly figure of the Shape is exported by the export_html method with a range of different view_plane options.""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=180 - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=180) for view_plane in ["XZ", "XY", "YZ", "YX", "ZY", "ZX", "RZ", "XYZ"]: os.system("rm *.html") @@ -428,9 +414,7 @@ def invalid_color_type(): def invalid_color_length(): - paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], color=(255, 255, 255, 1, 1) - ) + paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)], color=(255, 255, 255, 1, 1)) self.assertRaises(ValueError, invalid_color_length) @@ -438,42 +422,32 @@ def test_volumes_add_up_to_total_volume_Compound(self): """Checks the volume and volumes attributes are correct types and that the volumes sum to equalt the volume for a Compound.""" - test_shape = paramak.PoloidalFieldCoilSet( - heights=[10, 10], widths=[20, 20], center_points=[(15, 15), (50, 50)] - ) + test_shape = paramak.PoloidalFieldCoilSet(heights=[10, 10], widths=[20, 20], center_points=[(15, 15), (50, 50)]) assert isinstance(test_shape.volume(), float) assert isinstance(test_shape.volume(split_compounds=True), list) assert isinstance(test_shape.volume(split_compounds=True)[0], float) assert isinstance(test_shape.volume(split_compounds=True)[1], float) assert len(test_shape.volume(split_compounds=True)) == 2 - assert sum(test_shape.volume(split_compounds=True)) == pytest.approx( - test_shape.volume() - ) + assert sum(test_shape.volume(split_compounds=True)) == pytest.approx(test_shape.volume()) def test_volumes_add_up_to_total_volume(self): """Checks the volume and volumes attributes are correct types and that the volumes sum to equalt the volume.""" - test_shape = paramak.PoloidalFieldCoil( - center_point=(100, 100), height=50, width=50 - ) + test_shape = paramak.PoloidalFieldCoil(center_point=(100, 100), height=50, width=50) assert isinstance(test_shape.volume(), float) assert isinstance(test_shape.volume(split_compounds=True), list) assert isinstance(test_shape.volume(split_compounds=True)[0], float) assert len(test_shape.volume(split_compounds=True)) == 1 - assert sum(test_shape.volume(split_compounds=True)) == pytest.approx( - test_shape.volume() - ) + assert sum(test_shape.volume(split_compounds=True)) == pytest.approx(test_shape.volume()) def test_areas_add_up_to_total_area_Compound(self): """Checks the area and areas attributes are correct types and that the areas sum to equalt the area for a Compound.""" - test_shape = paramak.PoloidalFieldCoilSet( - heights=[10, 10], widths=[20, 20], center_points=[(15, 15), (50, 50)] - ) + test_shape = paramak.PoloidalFieldCoilSet(heights=[10, 10], widths=[20, 20], center_points=[(15, 15), (50, 50)]) assert isinstance(test_shape.area, float) assert isinstance(test_shape.areas, list) @@ -492,9 +466,7 @@ def test_areas_add_up_to_total_area(self): """Checks the area and areas attributes are correct types and that the areas sum to equalt the area.""" - test_shape = paramak.PoloidalFieldCoil( - center_point=(100, 100), height=50, width=50 - ) + test_shape = paramak.PoloidalFieldCoil(center_point=(100, 100), height=50, width=50) assert isinstance(test_shape.area, float) assert isinstance(test_shape.areas, list) @@ -518,9 +490,7 @@ def patch(): def test_create_patch_alpha(self): """Checks _create_patch returns a patch when alpha is given.""" - test_shape = paramak.PoloidalFieldCoil( - center_point=(100, 100), height=50, width=50, color=(0.5, 0.5, 0.5, 0.1) - ) + test_shape = paramak.PoloidalFieldCoil(center_point=(100, 100), height=50, width=50, color=(0.5, 0.5, 0.5, 0.1)) assert test_shape._create_patch() is not None def test_azimuth_placement_angle_error(self): diff --git a/tests/test_utils.py b/tests/test_utils.py index 45571743f..753edac95 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -41,9 +41,7 @@ def test_extract_points_from_edges(self): correct len and contains the correct types""" test_points = [(1, 1), (3, 1), (4, 2)] - test_shape = paramak.ExtrudeStraightShape( - points=test_points, distance=6, workplane="YZ" - ) + test_shape = paramak.ExtrudeStraightShape(points=test_points, distance=6, workplane="YZ") edges = facet_wire(wire=test_shape.wire) @@ -127,9 +125,7 @@ def test_EdgeLengthSelector_with_fillet_areas(self): def test_FaceAreaSelector_with_fillet_areas(self): """tests the filleting of a ExtrudeStraightShape""" - test_shape = paramak.ExtrudeStraightShape( - distance=5, points=[(1, 1), (2, 1), (2, 2)] - ) + test_shape = paramak.ExtrudeStraightShape(distance=5, points=[(1, 1), (2, 1), (2, 2)]) assert len(test_shape.areas) == 5 diff --git a/tests_h5m/test_reactor_export_h5m.py b/tests_h5m/test_reactor_export_h5m.py index 1021492f1..97b61de03 100644 --- a/tests_h5m/test_reactor_export_h5m.py +++ b/tests_h5m/test_reactor_export_h5m.py @@ -9,9 +9,7 @@ class TestReactor(unittest.TestCase): """testing the export_dagmc_h5m method of the TestReactor class""" def setUp(self): - self.test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], name="test_shape" - ) + self.test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)], name="test_shape") self.test_shape2 = paramak.ExtrudeStraightShape( points=[(100, 100), (50, 100), (50, 50)], distance=20, name="test_shape2" @@ -53,17 +51,10 @@ def test_dagmc_h5m_export_mesh_size(self): """Exports h5m file with higher resolution mesh and checks that the file sizes increases""" - self.test_reactor_3.export_dagmc_h5m( - "dagmc_default.h5m", min_mesh_size=10, max_mesh_size=20 - ) - self.test_reactor_3.export_dagmc_h5m( - "dagmc_bigger.h5m", min_mesh_size=2, max_mesh_size=9 - ) + self.test_reactor_3.export_dagmc_h5m("dagmc_default.h5m", min_mesh_size=10, max_mesh_size=20) + self.test_reactor_3.export_dagmc_h5m("dagmc_bigger.h5m", min_mesh_size=2, max_mesh_size=9) - assert ( - Path("dagmc_bigger.h5m").stat().st_size - > Path("dagmc_default.h5m").stat().st_size - ) + assert Path("dagmc_bigger.h5m").stat().st_size > Path("dagmc_default.h5m").stat().st_size if __name__ == "__main__": diff --git a/tests_h5m/test_rotate_straight_shape_export_h5m.py b/tests_h5m/test_rotate_straight_shape_export_h5m.py index ed0583005..880b9a28f 100644 --- a/tests_h5m/test_rotate_straight_shape_export_h5m.py +++ b/tests_h5m/test_rotate_straight_shape_export_h5m.py @@ -9,9 +9,7 @@ class TestRotateStraightShape(unittest.TestCase): """testing the export_dagmc_h5m method of the RotateStraightShape class""" def setUp(self): - self.test_shape = RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)] - ) + self.test_shape = RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)]) def test_dagmc_h5m_export_multi_volume(self): """Exports a shape with multiple volumes and checks that they all @@ -57,17 +55,10 @@ def test_dagmc_h5m_export_mesh_size(self): """Exports h5m file with higher resolution mesh and checks that the file sizes increases""" - self.test_shape.export_dagmc_h5m( - "dagmc_default.h5m", min_mesh_size=10, max_mesh_size=20 - ) - self.test_shape.export_dagmc_h5m( - "dagmc_bigger.h5m", min_mesh_size=2, max_mesh_size=9 - ) - - assert ( - Path("dagmc_bigger.h5m").stat().st_size - > Path("dagmc_default.h5m").stat().st_size - ) + self.test_shape.export_dagmc_h5m("dagmc_default.h5m", min_mesh_size=10, max_mesh_size=20) + self.test_shape.export_dagmc_h5m("dagmc_bigger.h5m", min_mesh_size=2, max_mesh_size=9) + + assert Path("dagmc_bigger.h5m").stat().st_size > Path("dagmc_default.h5m").stat().st_size if __name__ == "__main__": diff --git a/tests_show/test_reactor.py b/tests_show/test_reactor.py index 63ad2c616..c999d088f 100644 --- a/tests_show/test_reactor.py +++ b/tests_show/test_reactor.py @@ -10,9 +10,7 @@ class TestReactor(unittest.TestCase): jupyter_cadquery""" def setUp(self): - self.test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20)], name="test_shape" - ) + self.test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20)], name="test_shape") self.test_shape2 = paramak.ExtrudeStraightShape( points=[(100, 100), (50, 100), (50, 50)], distance=20, name="test_shape2" diff --git a/tests_show/test_shape.py b/tests_show/test_shape.py index dc7763427..bfc46fc43 100644 --- a/tests_show/test_shape.py +++ b/tests_show/test_shape.py @@ -53,9 +53,7 @@ def test_export_3d_html(self): """Checks the 3d html file is exported by the export_html_3d method with the correct filename""" - test_shape = paramak.RotateStraightShape( - points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360 - ) + test_shape = paramak.RotateStraightShape(points=[(0, 0), (0, 20), (20, 20), (20, 0)], rotation_angle=360) os.system("rm filename.html") filename = test_shape.export_html_3d("filename.html") From 4a8396c34ffc7ae1745793ae93bcc7d8c1ebb232 Mon Sep 17 00:00:00 2001 From: Jonathan Shimwell Date: Thu, 17 Mar 2022 12:22:56 +0000 Subject: [PATCH 4/4] [skip ci] removed line length of 120 --- .github/workflows/auto_format_pep8.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto_format_pep8.yml b/.github/workflows/auto_format_pep8.yml index 0ef6eb158..a329f2ee5 100644 --- a/.github/workflows/auto_format_pep8.yml +++ b/.github/workflows/auto_format_pep8.yml @@ -26,7 +26,7 @@ jobs: pip install black==22.1.0 - name: Run black run: | - black . --line-length=120 + black . - uses: stefanzweifel/git-auto-commit-action@v4 with: commit_message: "[skip ci] Apply formatting changes"