diff --git a/conda/meta.yaml b/conda/meta.yaml index e8122201a..f187b2d43 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -24,6 +24,7 @@ requirements: - plotly - brep_part_finder >=0.4.1 # [not win] - brep_to_h5m >=0.3.1 # [not win] + - moab >=5.3.1 # - jupyter-cadquery not available on conda test: diff --git a/paramak/parametric_components/blanket_cutter_parallels.py b/paramak/parametric_components/blanket_cutter_parallels.py index cc678125e..185b15fbc 100644 --- a/paramak/parametric_components/blanket_cutter_parallels.py +++ b/paramak/parametric_components/blanket_cutter_parallels.py @@ -1,3 +1,5 @@ +from typing import Iterable, Union + from paramak import ExtrudeStraightShape from paramak.utils import cut_solid @@ -28,7 +30,7 @@ def __init__( gap_size: float, height: float = 2000.0, width: float = 2000.0, - azimuth_placement_angle=[ + azimuth_placement_angle: Union[float, Iterable[float]] = [ 0.0, 36.0, 72.0, diff --git a/paramak/parametric_components/blanket_cutters_star.py b/paramak/parametric_components/blanket_cutters_star.py index 8c6c9a5af..8065d096a 100644 --- a/paramak/parametric_components/blanket_cutters_star.py +++ b/paramak/parametric_components/blanket_cutters_star.py @@ -1,4 +1,4 @@ -from typing import List, Union +from typing import Iterable, Union from paramak import ExtrudeStraightShape @@ -25,7 +25,7 @@ def __init__( distance: float, height: float = 2000.0, width: float = 2000.0, - azimuth_placement_angle: Union[float, List[float]] = [ + azimuth_placement_angle: Union[float, Iterable[float]] = [ 0.0, 36.0, 72.0, diff --git a/paramak/parametric_components/blanket_fp.py b/paramak/parametric_components/blanket_fp.py index 3017a853c..a0e72f59e 100644 --- a/paramak/parametric_components/blanket_fp.py +++ b/paramak/parametric_components/blanket_fp.py @@ -1,5 +1,5 @@ import warnings -from typing import Optional, Union +from typing import Optional, Union, Iterable import mpmath import numpy as np @@ -47,13 +47,13 @@ def __init__( start_angle: float, stop_angle: float, 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, - elongation: Optional[float] = 2.0, - vertical_displacement: Optional[float] = 0.0, - offset_from_plasma: Union[float, list] = 0.0, - num_points: Optional[int] = 50, + minor_radius: float = 150.0, + major_radius: float = 450.0, + triangularity: float = 0.55, + elongation: float = 2.0, + vertical_displacement: float = 0.0, + offset_from_plasma: Union[float, Iterable[float]] = 0.0, + num_points: int = 50, allow_overlapping_shape=False, **kwargs ): diff --git a/paramak/parametric_components/blanket_poloidal_segment.py b/paramak/parametric_components/blanket_poloidal_segment.py index e1691d8ee..8e98eb9d4 100644 --- a/paramak/parametric_components/blanket_poloidal_segment.py +++ b/paramak/parametric_components/blanket_poloidal_segment.py @@ -1,5 +1,5 @@ import warnings -from typing import Callable, List, Optional, Tuple, Union +from typing import Callable, Iterable, Optional, Tuple, Union import numpy as np from scipy.optimize import minimize @@ -29,8 +29,8 @@ class BlanketFPPoloidalSegments(BlanketFP): def __init__( self, - segments_angles: Optional[List[float]] = None, - num_segments: Optional[int] = 7, + segments_angles: Optional[Iterable[float]] = None, + num_segments: int = 7, length_limits: Optional[Tuple[Union[float, None], Union[float, None]]] = None, nb_segments_limits: Optional[Tuple[float, float]] = None, segments_gap: Optional[float] = 0.0, @@ -173,14 +173,14 @@ def create_segment_cutters(self): self.segments_cutters = cutting_shape -def compute_lengths_from_angles(angles: List[float], distribution: Callable): +def compute_lengths_from_angles(angles: Iterable[float], distribution: Callable): """Computes the length of segments between a set of points on a (x,y) distribution. Args: - angles (list): Contains the angles of the points (degree) - distribution (callable): function taking an angle as argument and - returning (x,y) coordinates. + angles: Contains the angles of the points (degrees) + distribution: function taking an angle as argument and returning (x,y) + coordinates. Returns: list: contains the lengths of the segments. diff --git a/paramak/parametric_components/center_column_cylinder.py b/paramak/parametric_components/center_column_cylinder.py index 3db8eddf6..599ae5a25 100644 --- a/paramak/parametric_components/center_column_cylinder.py +++ b/paramak/parametric_components/center_column_cylinder.py @@ -1,4 +1,4 @@ -from typing import Optional, Tuple +from typing import Optional, Tuple, Union from paramak import RotateStraightShape @@ -40,7 +40,7 @@ def center_height(self): return self._center_height @center_height.setter - def center_height(self, value): + def center_height(self, value: Union[float, int]): if not isinstance(value, (int, float)): msg = f"CenterColumnShieldBlock.center_height should be a float or int. Not a {type(value)}" raise TypeError(msg) @@ -52,7 +52,7 @@ def height(self): return self._height @height.setter - def height(self, value): + def height(self, value: float): if value is None: raise ValueError("height of the CenterColumnShieldBlock cannot be None") self._height = value @@ -62,7 +62,7 @@ def inner_radius(self): return self._inner_radius @inner_radius.setter - def inner_radius(self, value): + def inner_radius(self, value: float): if hasattr(self, "outer_radius"): if value >= self.outer_radius: msg = f"inner_radius ({value}) is larger than outer_radius " "({self.outer_radius})" @@ -74,7 +74,7 @@ def outer_radius(self): return self._outer_radius @outer_radius.setter - def outer_radius(self, value): + def outer_radius(self, value: float): if hasattr(self, "inner_radius"): if value <= self.inner_radius: msg = f"inner_radius ({self.inner_radius}) is larger than " "outer_radius ({value})" diff --git a/paramak/parametric_components/center_column_flat_top_circular.py b/paramak/parametric_components/center_column_flat_top_circular.py index 421ad5a4e..d53c7869a 100644 --- a/paramak/parametric_components/center_column_flat_top_circular.py +++ b/paramak/parametric_components/center_column_flat_top_circular.py @@ -56,7 +56,7 @@ def arc_height(self): return self._arc_height @arc_height.setter - def arc_height(self, arc_height): + def arc_height(self, arc_height: float): self._arc_height = arc_height @property @@ -64,7 +64,7 @@ def inner_radius(self): return self._inner_radius @inner_radius.setter - def inner_radius(self, inner_radius): + def inner_radius(self, inner_radius: float): self._inner_radius = inner_radius @property @@ -72,7 +72,7 @@ def mid_radius(self): return self._mid_radius @mid_radius.setter - def mid_radius(self, mid_radius): + def mid_radius(self, mid_radius: float): self._mid_radius = mid_radius @property @@ -80,7 +80,7 @@ def outer_radius(self): return self._outer_radius @outer_radius.setter - def outer_radius(self, outer_radius): + def outer_radius(self, outer_radius: float): self._outer_radius = outer_radius def find_points(self): diff --git a/paramak/parametric_components/center_column_flat_top_hyperbola.py b/paramak/parametric_components/center_column_flat_top_hyperbola.py index 66c07357d..e44bf4291 100644 --- a/paramak/parametric_components/center_column_flat_top_hyperbola.py +++ b/paramak/parametric_components/center_column_flat_top_hyperbola.py @@ -48,7 +48,7 @@ def height(self): return self._height @height.setter - def height(self, height): + def height(self, height: float): self._height = height @property @@ -56,7 +56,7 @@ def arc_height(self): return self._arc_height @arc_height.setter - def arc_height(self, arc_height): + def arc_height(self, arc_height: float): self._arc_height = arc_height @property @@ -64,7 +64,7 @@ def inner_radius(self): return self._inner_radius @inner_radius.setter - def inner_radius(self, inner_radius): + def inner_radius(self, inner_radius: float): self._inner_radius = inner_radius @property @@ -72,7 +72,7 @@ def mid_radius(self): return self._mid_radius @mid_radius.setter - def mid_radius(self, mid_radius): + def mid_radius(self, mid_radius: float): self._mid_radius = mid_radius @property @@ -80,7 +80,7 @@ def outer_radius(self): return self._outer_radius @outer_radius.setter - def outer_radius(self, outer_radius): + def outer_radius(self, outer_radius: float): self._outer_radius = outer_radius def find_points(self): diff --git a/paramak/parametric_components/center_column_plasma_dependant.py b/paramak/parametric_components/center_column_plasma_dependant.py index 03027a68e..0ee33b1fb 100644 --- a/paramak/parametric_components/center_column_plasma_dependant.py +++ b/paramak/parametric_components/center_column_plasma_dependant.py @@ -1,5 +1,3 @@ -from typing import Optional - from paramak import Plasma, RotateMixedShape @@ -28,10 +26,10 @@ def __init__( inner_radius: float, mid_offset: float, edge_offset: float, - major_radius: Optional[float] = 450.0, - minor_radius: Optional[float] = 150.0, - triangularity: Optional[float] = 0.55, - elongation: Optional[float] = 2.0, + major_radius: float = 450.0, + minor_radius: float = 150.0, + triangularity: float = 0.55, + elongation: float = 2.0, **kwargs, ) -> None: diff --git a/paramak/parametric_components/circular_port.py b/paramak/parametric_components/circular_port.py index 86bf3a651..4e38af9b6 100644 --- a/paramak/parametric_components/circular_port.py +++ b/paramak/parametric_components/circular_port.py @@ -33,12 +33,12 @@ def __init__( flange_overhang: float = 10, flange_thickness: float = 5, flange_gap: float = 0, - blank_flange_thickness: Optional[float] = 5, - workplane: Optional[str] = "ZY", - rotation_axis: Optional[str] = "Z", - extrusion_start_offset: Optional[float] = 100, - center_point: Optional[tuple] = (0, 0), - name: Optional[str] = "circular_port_cutter", + blank_flange_thickness: float = 5, + workplane: str = "ZY", + rotation_axis: str = "Z", + extrusion_start_offset: float = 100, + center_point: tuple = (0, 0), + name: str = "circular_port_cutter", color: Tuple[float, float, float, Optional[float]] = ( 0.984, 0.603, @@ -72,12 +72,7 @@ def create_solid(self): A CadQuery solid: A 3D solid volume """ - # so a positive offset moves extrusion further from axis of azimuthal - # placement rotation - if self.extrusion_start_offset is None: - extrusion_offset = 0.0 - else: - extrusion_offset = -self.extrusion_start_offset + extrusion_offset = -self.extrusion_start_offset flange_gap = -self.flange_gap extrusion_distance = -self.distance flange_thickness = self.flange_thickness @@ -110,11 +105,7 @@ def create_solid(self): flange_solid = flange_solid.cut(inner_solid) solid = solid.union(flange_solid) - # changing value internally so that 0 can be used in additions - if self.blank_flange_thickness is None: - blank_flange_thickness = 0 - else: - blank_flange_thickness = self.blank_flange_thickness + blank_flange_thickness = self.blank_flange_thickness if blank_flange_thickness > 0: blank_flange_wire = ( diff --git a/paramak/parametric_components/constant_thickness_dome.py b/paramak/parametric_components/constant_thickness_dome.py index 965eca63f..96de3cce9 100644 --- a/paramak/parametric_components/constant_thickness_dome.py +++ b/paramak/parametric_components/constant_thickness_dome.py @@ -1,6 +1,7 @@ import math from paramak import RotateMixedShape, RotateStraightShape, Shape, CuttingWedge import cadquery as cq +import numbers class ConstantThicknessDome(RotateMixedShape): @@ -46,9 +47,9 @@ def chord_width(self): return self._chord_width @chord_width.setter - def chord_width(self, value): - if not isinstance(value, (float, int)): - raise ValueError("ConstantThicknessDome.chord_width must be a number. Not", value) + def chord_width(self, value: float): + if not isinstance(value, numbers.Number): + raise ValueError("ConstantThicknessDome.chord_width must be a float. Not", value) if value <= 0: msg = f"ConstantThicknessDome.chord_width must be a positive number above 0. Not {value}" raise ValueError(msg) @@ -59,9 +60,9 @@ def chord_height(self): return self._chord_height @chord_height.setter - def chord_height(self, value): - if not isinstance(value, (float, int)): - raise ValueError("ConstantThicknessDome.chord_height must be a number. Not", value) + def chord_height(self, value: float): + if not isinstance(value, numbers.Number): + raise ValueError("ConstantThicknessDome.chord_height must be a float. Not", value) if value <= 0: msg = f"ConstantThicknessDome.chord_height must be a positive number above 0. Not {value}" raise ValueError(msg) @@ -72,9 +73,9 @@ def thickness(self): return self._thickness @thickness.setter - def thickness(self, value): - if not isinstance(value, (float, int)): - msg = f"VacuumVessel.thickness must be a number. Not {value}" + def thickness(self, value: float): + if not isinstance(value, numbers.Number): + msg = f"VacuumVessel.thickness must be a float. Not {value}" raise ValueError(msg) if value <= 0: msg = f"VacuumVessel.thickness must be a positive number above 0. Not {value}" diff --git a/paramak/parametric_components/coolant_channel_ring_curved.py b/paramak/parametric_components/coolant_channel_ring_curved.py index 5c1057ba9..041ecae56 100644 --- a/paramak/parametric_components/coolant_channel_ring_curved.py +++ b/paramak/parametric_components/coolant_channel_ring_curved.py @@ -1,5 +1,3 @@ -from typing import Optional - import numpy as np from paramak import SweepCircleShape @@ -33,7 +31,7 @@ def __init__( number_of_coolant_channels: int, ring_radius: float, mid_offset: float, - start_angle: Optional[float] = 0.0, + start_angle: float = 0.0, **kwargs ) -> None: diff --git a/paramak/parametric_components/cutting_wedge.py b/paramak/parametric_components/cutting_wedge.py index 865a62bbc..7f9011444 100644 --- a/paramak/parametric_components/cutting_wedge.py +++ b/paramak/parametric_components/cutting_wedge.py @@ -1,5 +1,3 @@ -from typing import Optional - from paramak import RotateStraightShape @@ -13,7 +11,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: float = 180.0, **kwargs) -> None: super().__init__(rotation_angle=rotation_angle, **kwargs) @@ -25,7 +23,7 @@ def height(self): return self._height @height.setter - def height(self, value): + def height(self, value: float): self._height = value @property @@ -33,7 +31,7 @@ def radius(self): return self._radius @radius.setter - def radius(self, value): + def radius(self, value: float): self._radius = value def find_points(self): diff --git a/paramak/parametric_components/cutting_wedge_fs.py b/paramak/parametric_components/cutting_wedge_fs.py index 18f592e45..cb474bd12 100644 --- a/paramak/parametric_components/cutting_wedge_fs.py +++ b/paramak/parametric_components/cutting_wedge_fs.py @@ -45,7 +45,7 @@ def height(self): return self._height @height.setter - def height(self, value): + def height(self, value: float): self._height = value @property @@ -54,7 +54,7 @@ def rotation_angle(self): return self._rotation_angle @rotation_angle.setter - def rotation_angle(self, value): + def rotation_angle(self, value: float): self._rotation_angle = value @property @@ -67,7 +67,7 @@ def workplane(self): return self._workplane @workplane.setter - def workplane(self, value): + def workplane(self, value: str): self._workplane = value @property @@ -76,7 +76,7 @@ def rotation_axis(self): return self._rotation_axis @rotation_axis.setter - def rotation_axis(self, value): + def rotation_axis(self, value: str): self._rotation_axis = value @property diff --git a/paramak/parametric_components/dished_vacuum_vessel.py b/paramak/parametric_components/dished_vacuum_vessel.py index a2fe7f456..2555df8d2 100644 --- a/paramak/parametric_components/dished_vacuum_vessel.py +++ b/paramak/parametric_components/dished_vacuum_vessel.py @@ -40,7 +40,7 @@ def radius(self): return self._radius @radius.setter - def radius(self, value): + def radius(self, value: float): if not isinstance(value, (float, int)): raise ValueError("VacuumVessel.radius must be a number. Not", value) if value <= 0: @@ -53,7 +53,7 @@ def thickness(self): return self._thickness @thickness.setter - def thickness(self, value): + def thickness(self, value: float): if not isinstance(value, (float, int)): msg = f"VacuumVessel.thickness must be a number. Not {value}" raise ValueError(msg) diff --git a/paramak/parametric_components/divertor_ITER.py b/paramak/parametric_components/divertor_ITER.py index d9a19845f..cd6ecfa1b 100644 --- a/paramak/parametric_components/divertor_ITER.py +++ b/paramak/parametric_components/divertor_ITER.py @@ -1,7 +1,7 @@ import math +from typing import Tuple import numpy as np - from paramak import RotateMixedShape, distance_between_two_points, extend, rotate @@ -10,42 +10,34 @@ class ITERtypeDivertor(RotateMixedShape): dome Args: - anchors ((float, float), (float, float), optional): xz coordinates of - points at the top of vertical targets. - Defaults to ((450, -300), (561, -367)). - coverages ((float, float), optional): coverages (anticlockwise) in - degrees of the circular parts of vertical targets. - Defaults to (90, 180). - radii ((float, float), optional): radii (cm) of circular parts of the - vertical targets. Defaults to (50, 25). - lengths ((float, float), optional): leg length (cm) of the vertical - targets. Defaults to (78, 87). - dome (bool, optional): if set to False, the dome will not be created. - Defaults to True. - dome_height (float, optional): distance (cm) between the dome base and - lower points. Defaults to 43. - dome_length (float, optional): length of the dome. Defaults to 66. - dome_thickness (float, optional): thickness of the dome. - Defaults to 10. - dome_pos (float, optional): relative location of the dome between - vertical targets (0 inner, 1 outer). Ex: 0.5 will place the dome - in between the targets. Defaults to 0.5. + anchors: xz coordinates of points at the top of vertical targets. + coverages: coverages (anticlockwise) in degrees of the circular parts + of vertical targets. + radii: radii (cm) of circular parts of the vertical targets. + lengths: leg length (cm) of the vertical targets. + dome: if set to False, the dome will not be created. + dome_height: distance (cm) between the dome base and lower points. + dome_length: length of the dome. + dome_thickness: thickness of the dome. + dome_pos: relative location of the dome between vertical targets + (0 inner, 1 outer). Ex: 0.5 will place the dome in between the + targets. tilts ((float, float), optional): tilt angles (anticlockwise) in - degrees for the vertical targets. Defaults to (-27, 0). + degrees for the vertical targets. """ def __init__( self, - anchors=((450, -300), (561, -367)), - coverages=(90, 180), - radii=(50, 25), - lengths=(78, 87), - dome=True, - dome_height=43, - dome_length=66, - dome_thickness=10, - dome_pos=0.5, - tilts=(-27, 0), + anchors: Tuple[Tuple[float, float], Tuple[float, float]] = ((450, -300), (561, -367)), + coverages: Tuple[float, float] = (90, 180), + radii: Tuple[float, float] = (50, 25), + lengths: Tuple[float, float] = (78, 87), + dome: bool = True, + dome_height: float = 43, + dome_length: float = 66, + dome_thickness: float = 10, + dome_pos: float = 0.5, + tilts: Tuple[float, float] = (-27, 0), **kwargs ): @@ -62,19 +54,18 @@ def __init__( self.dome_pos = dome_pos self.dome_thickness = dome_thickness - def _create_vertical_target_points(self, anchor, coverage, tilt, radius, length): + def _create_vertical_target_points( + self, anchor: Tuple[float, float], coverage: float, tilt: float, radius: float, length: float + ): """Creates a list of points for a vertical target Args: - anchor (float, float): xz coordinates of point at - the top of the vertical target. - coverage (float): coverages (anticlockwise) in degrees of the - circular part of the vertical target. - tilt (float): tilt angle (anticlockwise) in - degrees for the vertical target. - radius (float): radius (cm) of circular part of the vertical - target. - length (float): leg length (cm) of the vertical target. + anchor: xz coordinates of point at the top of the vertical target. + coverage: coverages (anticlockwise) in degrees of the circular part + of the vertical target. + tilt: tilt angle (anticlockwise) in degrees for the vertical target. + radius: radius (cm) of circular part of the vertical target. + length: leg length (cm) of the vertical target. Returns: list: list of x y coordinates @@ -98,17 +89,25 @@ 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: Tuple[float, float], + F: Tuple[float, float], + dome_length: float, + dome_height: float, + dome_thickness: float, + dome_pos: float, + ): """Creates a list of points for the dome alongside with their connectivity Args: - c_coord (float, float): coordinate of inner end of the dome - F (float, float): coordinate of outer end of the dome - dome_length (float): dome length (cm) - dome_height (float): dome height (cm) - dome_thickness (float): dome thickness (cm) - dome_pos (float): position of the dome between the two ends. + c_coord: coordinate of inner end of the dome + F: coordinate of outer end of the dome + dome_length: dome length (cm) + dome_height: dome height (cm) + dome_thickness: dome thickness (cm) + dome_pos: position of the dome between the two ends. Returns: list: list of points with connectivity @@ -141,16 +140,21 @@ def _create_dome_points(self, c_coord, F, dome_length, dome_height, dome_thickne points.append([E[0], E[1], "straight"]) return points - def _create_casing_points(self, anchors, c_coord, F, targets_lengths): + def _create_casing_points( + self, + anchors: Tuple[float, float], + c_coord: Tuple[float, float], + F: Tuple[float, float], + targets_lengths: Tuple[float, float], + ): """Creates a list of points for the casing alongside with their connectivity Args: - anchors ((float, float), (float, float)): xz coordinates of points - at the top of vertical targets. - c_coord (float, float): coordinate of inner end of the dome - F (float, float): coordinate of outer end of the dome - targets_lengths (float, float): leg lengths of the vertical targets + anchors: xz coordinates of points at the top of vertical targets. + c_coord: coordinate of inner end of the dome + F: coordinate of outer end of the dome + targets_lengths: leg lengths of the vertical targets Returns: list: list of points with connectivity diff --git a/paramak/parametric_components/extrude_hollow_rectangle.py b/paramak/parametric_components/extrude_hollow_rectangle.py index 3f84b3f0b..8a1af4b3d 100644 --- a/paramak/parametric_components/extrude_hollow_rectangle.py +++ b/paramak/parametric_components/extrude_hollow_rectangle.py @@ -1,4 +1,4 @@ -from typing import List, Optional, Tuple, Union +from typing import Optional, Tuple, Union, Iterable from cadquery import Plane from paramak import ExtrudeStraightShape @@ -12,8 +12,8 @@ class ExtrudeHollowRectangle(ExtrudeStraightShape): width: the width of the internal hollow section. distance: the depth of the internal hollow section. casing_thickness: the thickness of the casing around the hollow section. - center_point: the center of the rectangle (x,z) values (cm). name: defaults to "extrude_rectangle". + center_point: the center of the rectangle (x,z) values (cm). """ def __init__( @@ -26,7 +26,7 @@ def __init__( center_point: Tuple[float, float] = (0, 0), extrude_both: bool = True, color: Tuple[float, float, float, Optional[float]] = (0.5, 0.5, 0.5), - azimuth_placement_angle: Union[float, List[float]] = 0.0, + azimuth_placement_angle: Union[float, Iterable[float]] = 0.0, workplane: Union[str, Plane] = "XZ", cut=None, intersect=None, diff --git a/paramak/parametric_components/hollow_cube.py b/paramak/parametric_components/hollow_cube.py index caa727127..736e3ff2c 100644 --- a/paramak/parametric_components/hollow_cube.py +++ b/paramak/parametric_components/hollow_cube.py @@ -20,7 +20,7 @@ def __init__( length: float, thickness: float = 10.0, center_coordinate: Tuple[float, float, float] = (0.0, 0.0, 0.0), - name="hollow_cube", + name: str = "hollow_cube", **kwargs ): super().__init__(name=name, **kwargs) diff --git a/paramak/parametric_components/poloidal_field_coil_case_fc.py b/paramak/parametric_components/poloidal_field_coil_case_fc.py index 79429bcf1..43ec0570e 100644 --- a/paramak/parametric_components/poloidal_field_coil_case_fc.py +++ b/paramak/parametric_components/poloidal_field_coil_case_fc.py @@ -1,6 +1,6 @@ from typing import Optional, Tuple -from paramak import RotateStraightShape +from paramak import RotateStraightShape, PoloidalFieldCoil class PoloidalFieldCoilCaseFC(RotateStraightShape): @@ -8,15 +8,14 @@ class PoloidalFieldCoilCaseFC(RotateStraightShape): around an existing coil (which is passed as an argument on construction). Args: - pf_coil (paramak.PoloidalFieldCoil): a pf coil object with a set width, - height and center point. - casing_thickness (float): the thickness of the coil casing (cm). + pf_coil: a pf coil object with a set width, height and center point. + casing_thickness: the thickness of the coil casing (cm). """ def __init__( self, - pf_coil, - casing_thickness, + pf_coil: PoloidalFieldCoil, + casing_thickness: float, color: Tuple[float, float, float, Optional[float]] = (1.0, 1.0, 0.498), **kwargs ): diff --git a/paramak/parametric_components/poloidal_field_coil_case_set.py b/paramak/parametric_components/poloidal_field_coil_case_set.py index b078afba8..e769c1404 100644 --- a/paramak/parametric_components/poloidal_field_coil_case_set.py +++ b/paramak/parametric_components/poloidal_field_coil_case_set.py @@ -1,8 +1,9 @@ -from typing import Optional, Tuple +from typing import Optional, Tuple, Union import cadquery as cq from paramak import RotateStraightShape +from typing import Iterable class PoloidalFieldCoilCaseSet(RotateStraightShape): @@ -24,11 +25,11 @@ class PoloidalFieldCoilCaseSet(RotateStraightShape): def __init__( self, - heights, - widths, - casing_thicknesses, - center_points, - name="pf_coil_case_set", + heights: Iterable[float], + widths: Iterable[float], + casing_thicknesses: Iterable[float], + center_points: Iterable[float], + name: str = "pf_coil_case_set", color: Tuple[float, float, float, Optional[float]] = (1.0, 1.0, 0.498), **kwargs ): @@ -69,7 +70,7 @@ def casing_thicknesses(self): return self._casing_thicknesses @casing_thicknesses.setter - def casing_thicknesses(self, value): + def casing_thicknesses(self, value: Union[Iterable[float], float]): 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") 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 038d55c8c..bfbd76201 100644 --- a/paramak/parametric_components/poloidal_field_coil_case_set_fc.py +++ b/paramak/parametric_components/poloidal_field_coil_case_set_fc.py @@ -1,8 +1,8 @@ from typing import Optional, Tuple import cadquery as cq - -from paramak import PoloidalFieldCoilSet, RotateStraightShape +from typing import Iterable +from paramak import PoloidalFieldCoilSet, RotateStraightShape, PoloidalFieldCoil class PoloidalFieldCoilCaseSetFC(RotateStraightShape): @@ -20,9 +20,9 @@ class PoloidalFieldCoilCaseSetFC(RotateStraightShape): def __init__( self, - pf_coils, - casing_thicknesses, - name="pf_coil_case_set_fc", + pf_coils: Iterable[PoloidalFieldCoil], + casing_thicknesses: float, + name: str = "pf_coil_case_set_fc", color: Tuple[float, float, float, Optional[float]] = (1.0, 1.0, 0.498), **kwargs ): @@ -42,7 +42,7 @@ def casing_thicknesses(self): return self._casing_thicknesses @casing_thicknesses.setter - def casing_thicknesses(self, value): + def casing_thicknesses(self, value: float): 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") @@ -56,7 +56,7 @@ def pf_coils(self): return self._pf_coils @pf_coils.setter - def pf_coils(self, value): + def pf_coils(self, value: float): if not isinstance(value, (list, PoloidalFieldCoilSet)): msg = ( "PoloidalFieldCoilCaseSetFC.pf_coils must be either a list " diff --git a/paramak/parametric_components/poloidal_field_coil_fp.py b/paramak/parametric_components/poloidal_field_coil_fp.py index fe1a2cfd4..e56e761ac 100644 --- a/paramak/parametric_components/poloidal_field_coil_fp.py +++ b/paramak/parametric_components/poloidal_field_coil_fp.py @@ -1,3 +1,4 @@ +from typing import Iterable, Tuple from paramak import PoloidalFieldCoil @@ -9,7 +10,7 @@ class PoloidalFieldCoilFP(PoloidalFieldCoil): corners of the rectangular shaped coil e.g [(x1, y1), (x2, y2)] """ - def __init__(self, corner_points, **kwargs): + def __init__(self, corner_points: Iterable[Tuple[float, float]], **kwargs): height = abs(corner_points[0][1] - corner_points[1][1]) width = abs(corner_points[0][0] - corner_points[1][0]) diff --git a/paramak/parametric_components/poloidal_field_coil_set.py b/paramak/parametric_components/poloidal_field_coil_set.py index 1586eedfd..838013d3c 100644 --- a/paramak/parametric_components/poloidal_field_coil_set.py +++ b/paramak/parametric_components/poloidal_field_coil_set.py @@ -1,5 +1,5 @@ import cadquery as cq - +from typing import Iterable, Tuple from paramak import RotateStraightShape @@ -7,16 +7,21 @@ class PoloidalFieldCoilSet(RotateStraightShape): """Creates a series of rectangular poloidal field coils. Args: - heights (list of floats): the vertical (z axis) heights of the coils - (cm). - widths (list of floats): the horizontal (x axis) widths of the coils - (cm). - center_points (list of tuple of floats): the center of the coil (x,z) - values e.g. [(100,100), (100,200)] (cm). - name (str, optional): defaults to "pf_coil". + heights: the vertical (z axis) heights of the coils (cm). + widths: the horizontal (x axis) widths of the coils (cm). + center_points: the center of the coil (x,z) values e.g. [(100,100), + (100,200)] (cm). + name: defaults to "pf_coil". """ - def __init__(self, heights, widths, center_points, name="pf_coil", **kwargs): + def __init__( + self, + heights: Iterable[float], + widths: Iterable[float], + center_points: Iterable[Tuple[float, float]], + name="pf_coil", + **kwargs + ): super().__init__(name=name, **kwargs) diff --git a/paramak/parametric_components/poloidal_segmenter.py b/paramak/parametric_components/poloidal_segmenter.py index 02af748f8..50f13fe35 100644 --- a/paramak/parametric_components/poloidal_segmenter.py +++ b/paramak/parametric_components/poloidal_segmenter.py @@ -1,8 +1,8 @@ import math import cadquery as cq - -from paramak import RotateStraightShape +from typing import Tuple, Optional +from paramak import Shape, RotateStraightShape from paramak.utils import coefficients_of_line_from_points, intersect_solid, rotate @@ -13,10 +13,9 @@ class PoloidalSegments(RotateStraightShape): firstwall geometry for using in neutron wall loading simulations. Args: - center_point (tuple of floats): the center of the segmentation wedges - (x,z) values (cm). - shape_to_segment (paramak.Shape, optional): the Shape to segment, if - None then the segmenting solids will be returned. Defaults to None. + center_point: the center of the segmentation wedges (x,z) values (cm). + shape_to_segment: the Shape to segment, if None then the segmenting + solids will be returned. Defaults to None. number_of_segments (int, optional): the number of equal angles segments in 360 degrees. Defaults to 10. max_distance_from_center (float): the maximum distance from the center @@ -26,11 +25,11 @@ class PoloidalSegments(RotateStraightShape): def __init__( self, - center_point, - shape_to_segment=None, - number_of_segments=10, - max_distance_from_center=1000.0, - name="poloidal_segmenter", + center_point: Tuple[float, float], + shape_to_segment: Optional[Shape] = None, + number_of_segments: int = 10, + max_distance_from_center: float = 1000.0, + name: str = "poloidal_segmenter", **kwargs ): @@ -46,7 +45,7 @@ def number_of_segments(self): return self._number_of_segments @number_of_segments.setter - def number_of_segments(self, value): + def number_of_segments(self, value: int): if isinstance(value, int) is False: raise TypeError("PoloidalSegmenter.number_of_segments must be an int.") if value < 1: diff --git a/paramak/parametric_components/port_cutters_circular.py b/paramak/parametric_components/port_cutters_circular.py index c34e385f1..71d0f11f6 100644 --- a/paramak/parametric_components/port_cutters_circular.py +++ b/paramak/parametric_components/port_cutters_circular.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Tuple from paramak import ExtrudeCircleShape @@ -24,11 +24,11 @@ def __init__( self, radius: float, distance: float, - center_point: Optional[tuple] = (0, 0), - workplane: Optional[str] = "ZY", - rotation_axis: Optional[str] = "Z", - extrusion_start_offset: Optional[float] = 1.0, - name: Optional[str] = "circular_port_cutter", + center_point: Tuple[float, float] = (0, 0), + workplane: str = "ZY", + rotation_axis: str = "Z", + extrusion_start_offset: float = 1.0, + name: str = "circular_port_cutter", **kwargs ): super().__init__( diff --git a/paramak/parametric_components/port_cutters_rectangular.py b/paramak/parametric_components/port_cutters_rectangular.py index 31d0fa284..7a8db6ebb 100644 --- a/paramak/parametric_components/port_cutters_rectangular.py +++ b/paramak/parametric_components/port_cutters_rectangular.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Tuple from paramak import ExtrudeStraightShape @@ -28,12 +28,12 @@ def __init__( height: float, width: float, distance: float, - center_point: Optional[tuple] = (0, 0), - workplane: Optional[str] = "ZY", - rotation_axis: Optional[str] = "Z", - extrusion_start_offset: Optional[float] = 1.0, - fillet_radius: Optional[float] = None, - name: Optional[str] = "rectangular_port_cutter", + center_point: Tuple[float, float] = (0, 0), + workplane: str = "ZY", + rotation_axis: str = "Z", + extrusion_start_offset: float = 1.0, + fillet_radius: float = None, + name: str = "rectangular_port_cutter", **kwargs ): diff --git a/paramak/parametric_components/rotated_isosceles_triangle.py b/paramak/parametric_components/rotated_isosceles_triangle.py index 44a32cc66..6fb3d5f36 100644 --- a/paramak/parametric_components/rotated_isosceles_triangle.py +++ b/paramak/parametric_components/rotated_isosceles_triangle.py @@ -1,5 +1,5 @@ import math - +from typing import Tuple from paramak import RotateStraightShape from paramak.utils import rotate @@ -8,16 +8,24 @@ class RotatedIsoscelesTriangle(RotateStraightShape): """Creates a rotated triangle (truncated triangle) shape. Args: - base_length (float): the length of the base of the triangle (cm). - height (float): the height of the triangle (cm). - pivot_point ((float, float)): the coordinates of the tip of the - triangle at the opposite side to the base of the triangle. - pivot_angle (float, optional): the angle (in degrees) to pivot (rotate) - the shape by around the pivot point. Defaults to 0. - name (str, optional): defaults to "rotated_triangle". + base_length: the length of the base of the triangle (cm). + height: the height of the triangle (cm). + pivot_point: the coordinates of the tip of the triangle at the opposite + side to the base of the triangle. + pivot_angle: the angle (in degrees) to pivot (rotate) the shape by + around the pivot point. Defaults to 0. + name: 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: float, + height: float, + pivot_point: Tuple[float, float], + pivot_angle: float = 0.0, + name: str = "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 25b6524f9..889b427cc 100644 --- a/paramak/parametric_components/rotated_trapezoid.py +++ b/paramak/parametric_components/rotated_trapezoid.py @@ -1,5 +1,5 @@ import math - +from typing import Tuple from paramak import RotateStraightShape from paramak.utils import rotate @@ -8,21 +8,26 @@ class RotatedTrapezoid(RotateStraightShape): """Creates a rotated trapezoid (truncated triangle) shape. Args: - length_1 (float): the length of the top parrallel edge of the trapezoid - (cm). - length_2 (float): the length of the base parrallel edge of the - trapezoid (cm). - length_3 (float): the height of the trapezoid, the distances from top - to base (cm). - pivot_point ((float, float)): the coordinates of the center of - rotation (x,z). The piviot point is located in the center of the - length_1 edge (cm). - pivot_angle (float, optional): the angle (in degrees) to pivot (rotate) - the shape by around the pivot point. Defaults to 0. - name (str, optional): defaults to "rotated_trapezoid". + length_1: the length of the top parallel edge of the trapezoid (cm). + length_2: the length of the base parallel edge of the trapezoid (cm). + length_3: the height of the trapezoid, the distances from top to base (cm). + pivot_point: the coordinates of the center of rotation (x,z). The + pivot point is located in the center of the length_1 edge (cm). + pivot_angle: the angle (in degrees) to pivot (rotate) the shape by + around the pivot point. Defaults to 0. + name: 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: float, + length_2: float, + length_3: float, + pivot_point: Tuple[float, float], + pivot_angle: float = 0.0, + name: str = "rotated_trapezoid", + **kwargs + ): super().__init__(name=name, **kwargs) diff --git a/paramak/parametric_components/shell_fs.py b/paramak/parametric_components/shell_fs.py index a46e7360c..14d22eaf1 100644 --- a/paramak/parametric_components/shell_fs.py +++ b/paramak/parametric_components/shell_fs.py @@ -11,16 +11,16 @@ class ShellFS(Shape): to the original rotation angle of the shape. Args: - shape (paramak.Shape): the shape to create a shell / 3D offset around - thickness (float): the thickness of the shell casing around the shape - (cm). Passed directly to CadQuery.shell(). Defaults to 10.0. - kind (str, optional) : the method used to connect gaps in the resulting - shelled shape. Options include 'arc' or 'intersection'. Use 'arc' - for rounded edges 'intersection' for sharp edges. Passed directly - to CadQuery.shell(). Defaults to intersection. + shape: the shape to create a shell / 3D offset around + thickness: the thickness of the shell casing around the shape (cm). + Passed directly to CadQuery.shell(). Defaults to 10.0. + kind: the method used to connect gaps in the resulting shelled shape. + Options include 'arc' or 'intersection'. Use 'arc' for rounded + edges 'intersection' for sharp edges. Passed directly to + CadQuery.shell(). Defaults to intersection. """ - def __init__(self, shape, thickness=10.0, kind="intersection", **kwargs): + def __init__(self, shape: Shape, thickness: float = 10.0, kind: str = "intersection", **kwargs): super().__init__(**kwargs) diff --git a/paramak/parametric_components/tokamak_plasma.py b/paramak/parametric_components/tokamak_plasma.py index 55b849e44..e7b74e3c5 100644 --- a/paramak/parametric_components/tokamak_plasma.py +++ b/paramak/parametric_components/tokamak_plasma.py @@ -8,37 +8,28 @@ class Plasma(RotateSplineShape): shaping parameters. Args: - elongation (float, optional): the elongation of the plasma. - Defaults to 2.0. - major_radius (float, optional): the major radius of the plasma (cm). - Defaults to 450.0. - minor_radius (int, optional): the minor radius of the plasma (cm). - Defaults to 150.0. - triangularity (float, optional): the triangularity of the plasma. - Defaults to 0.55. - vertical_displacement (float, optional): the vertical_displacement - of the plasma (cm). Defaults to 0.0. - num_points (int, optional): number of points to describe the - shape. Defaults to 50. - configuration (str, optional): plasma configuration - ("non-null", "single-null", "double-null"). - Defaults to "non-null". - x_point_shift (float, optional): shift parameters for locating the - X points in [0, 1]. Defaults to 0.1. - name (str, optional): Defaults to "plasma". + elongation: the elongation of the plasma. + major_radius: the major radius of the plasma (cm). + minor_radius: the minor radius of the plasma (cm). + triangularity: the triangularity of the plasma. + vertical_displacement: the vertical_displacement of the plasma (cm).. + num_points: number of points to describe the shape. + configuration: plasma configuration ("non-null", "single-null", "double-null"). + x_point_shift: shift parameters for locating the X points in [0, 1].. + name: """ def __init__( self, - elongation=2.0, - major_radius=450.0, - minor_radius=150.0, - triangularity=0.55, - vertical_displacement=0.0, - num_points=50, - configuration="non-null", - x_point_shift=0.1, - name="plasma", + elongation: float = 2.0, + major_radius: float = 450.0, + minor_radius: float = 150.0, + triangularity: float = 0.55, + vertical_displacement: float = 0.0, + num_points: float = 50, + configuration: str = "non-null", + x_point_shift: float = 0.1, + name: str = "plasma", **kwargs ): diff --git a/paramak/parametric_components/tokamak_plasma_from_points.py b/paramak/parametric_components/tokamak_plasma_from_points.py index 5d1e09d7a..ed9918c4b 100644 --- a/paramak/parametric_components/tokamak_plasma_from_points.py +++ b/paramak/parametric_components/tokamak_plasma_from_points.py @@ -1,3 +1,4 @@ +from typing import Tuple from paramak import Plasma @@ -6,15 +7,21 @@ class PlasmaFromPoints(Plasma): coordinates. Args: - outer_equatorial_x_point (float): the x value of the outer equatorial - of the plasma (cm). - inner_equatorial_x_point (float): the x value of the inner equatorial - of the plasma (cm). + outer_equatorial_x_point: the x value of the outer equatorial of the + plasma (cm). + inner_equatorial_x_point: the x value of the inner equatorial of the + plasma (cm). high_point (tuple of 2 floats): the (x,z) coordinate values of the top 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: Tuple[float, float], + inner_equatorial_x_point: Tuple[float, float], + high_point: Tuple[float, float], + **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 a73f96040..0ee60a681 100644 --- a/paramak/parametric_components/tokamak_plasma_plasmaboundaries.py +++ b/paramak/parametric_components/tokamak_plasma_plasmaboundaries.py @@ -10,35 +10,26 @@ class PlasmaBoundaries(Plasma): http://github.com/fusion-energy/plasmaboundaries Args: - A (float, optional): plasma parameter see plasmaboundaries doc. - Defaults to 0.05. - elongation (float, optional): the elongation of the plasma. - Defaults to 2.0. - major_radius (float, optional): the major radius of the plasma - (cm). Defaults to 450.0. - minor_radius (float, optional): the minor radius of the plasma - (cm). Defaults to 150.0. - triangularity (float, optional): the triangularity of the plasma. - Defaults to 0.55. - vertical_displacement (float, optional): the vertical_displacement - of the plasma (cm). Defaults to 0.0. - configuration (str, optional): plasma configuration - ("non-null", "single-null", "double-null"). - Defaults to "non-null". - x_point_shift (float, optional): Shift parameters for locating the - X points in [0, 1]. Defaults to 0.1. + A: plasma parameter see plasmaboundaries doc. + elongation: the elongation of the plasma. + major_radius: the major radius of the plasma (cm). + minor_radius: the minor radius of the plasma (cm). + triangularity: the triangularity of the plasma. + vertical_displacement: the vertical_displacement of the plasma (cm). + configuration (str, optional): plasma configuration ("non-null", "single-null", "double-null"). + x_point_shift: Shift parameters for locating the X points in [0, 1]. Defaults to 0.1. """ def __init__( self, - A=0.05, - elongation=2.0, - major_radius=450.0, - minor_radius=150.0, - triangularity=0.55, - vertical_displacement=0.0, - configuration="non-null", - x_point_shift=0.1, + A: float = 0.05, + elongation: float = 2.0, + major_radius: float = 450.0, + minor_radius: float = 150.0, + triangularity: float = 0.55, + vertical_displacement: float = 0.0, + configuration: str = "non-null", + x_point_shift: float = 0.1, **kwargs ): diff --git a/paramak/parametric_components/toroidal_field_coil_round_corners.py b/paramak/parametric_components/toroidal_field_coil_round_corners.py index cf8bc15f4..7e8674f67 100644 --- a/paramak/parametric_components/toroidal_field_coil_round_corners.py +++ b/paramak/parametric_components/toroidal_field_coil_round_corners.py @@ -17,19 +17,18 @@ class ToroidalFieldCoilRectangleRoundCorners(ExtrudeMixedShape): parameters, and takes three additional boolean arguments. Arguments: - lower_inner_coordinates (Tuple): the (X,Z) coordinate of the inner - corner of the lower end of the coil (cm) - mid_point_coordinates (Tuple): the (X,Z) coordinate of the mid - point of the vertical section (cm) - thickness: The thickness in the (X,Z) plane of the toroidal - field coils (cm) - extrusiondistance: The total extruded thickness of the coils - when in the y-direction (centered extrusion) + lower_inner_coordinates: the (X,Z) coordinate of the inner corner of + the lower end of the coil (cm) + mid_point_coordinates: the (X,Z) coordinate of the mid point of the + vertical section (cm) + thickness: The thickness in the (X,Z) plane of the toroidal field coils + (cm) + extrusiondistance: The total extruded thickness of the coils when in + the y-direction (centered extrusion) coil_count: The number of coils placed in the model (changing azimuth_placement_angle by dividing 360 by the amount given). Defaults to 1 with_inner_leg: Boolean to include the inside of the Coils - defaults to False azimuth_start_angle: The azimuth angle to for the first TF coil which offsets the placement of coils around the azimuthal angle """ diff --git a/paramak/parametric_components/vacuum_vessel.py b/paramak/parametric_components/vacuum_vessel.py index 1b66bb1af..6f6f8c3f5 100644 --- a/paramak/parametric_components/vacuum_vessel.py +++ b/paramak/parametric_components/vacuum_vessel.py @@ -5,12 +5,12 @@ class VacuumVessel(RotateStraightShape): """A cylindrical vessel volume with constant thickness. Arguments: - height (float): height of the vessel. - inner_radius (float): the inner radius of the vessel. - thickness (float): thickness of the vessel + height: height of the vessel. + inner_radius: the inner radius of the vessel. + thickness: thickness of the vessel """ - def __init__(self, height, inner_radius, thickness, **kwargs): + def __init__(self, height: float, inner_radius: float, thickness: float, **kwargs): self.height = height self.inner_radius = inner_radius self.thickness = thickness diff --git a/setup.cfg b/setup.cfg index efc12be33..f38f06833 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ project_urls = [options] packages = find: -python_requires= >=3.6 +python_requires= >=3.8 install_requires= plotly >= 5.1.0 scipy >= 1.7.0