From ed314ae27a7367660a32d12936d9b7c6f42b1ba7 Mon Sep 17 00:00:00 2001 From: markriegler Date: Fri, 9 Aug 2024 15:42:48 +0200 Subject: [PATCH 01/23] Add test for microtile classes --- splinepy/microstructure/microstructure.py | 4 +- splinepy/microstructure/tiles/__init__.py | 2 + splinepy/microstructure/tiles/armadillo.py | 9 + splinepy/microstructure/tiles/chi.py | 14 +- splinepy/microstructure/tiles/cross_2d.py | 15 +- splinepy/microstructure/tiles/cross_3d.py | 6 + .../microstructure/tiles/cross_3d_linear.py | 2 + splinepy/microstructure/tiles/cube_void.py | 1 + .../microstructure/tiles/double_lattice.py | 3 +- splinepy/microstructure/tiles/ellips_v_oid.py | 1 + splinepy/microstructure/tiles/hollow_cube.py | 1 + .../microstructure/tiles/hollow_octagon.py | 2 + .../tiles/hollow_octagon_extrude.py | 4 +- .../microstructure/tiles/inverse_cross_3d.py | 556 +++++++++--------- splinepy/microstructure/tiles/snappy.py | 4 +- tests/test_microstructure.py | 75 +++ 16 files changed, 412 insertions(+), 287 deletions(-) create mode 100644 tests/test_microstructure.py diff --git a/splinepy/microstructure/microstructure.py b/splinepy/microstructure/microstructure.py index 366935651..bb34246c6 100644 --- a/splinepy/microstructure/microstructure.py +++ b/splinepy/microstructure/microstructure.py @@ -9,7 +9,7 @@ class Microstructure(_SplinepyBase): - """Helper class to facilitatae the construction of microstructures.""" + """Helper class to facilitate the construction of microstructures.""" def __init__( self, @@ -18,7 +18,7 @@ def __init__( microtile=None, parametrization_function=None, ): - """Helper class to facilitatae the construction of microstructures. + """Helper class to facilitate the construction of microstructures. Parameters ---------- diff --git a/splinepy/microstructure/tiles/__init__.py b/splinepy/microstructure/tiles/__init__.py index 3b35a1f5c..f1b703a04 100644 --- a/splinepy/microstructure/tiles/__init__.py +++ b/splinepy/microstructure/tiles/__init__.py @@ -8,6 +8,7 @@ armadillo, chi, cross_2d, + cross_3d, cross_3d_linear, cube_void, double_lattice, @@ -42,6 +43,7 @@ "chi", "cross_2d", "cube_void", + "cross_3d", "cross_3d_linear", "double_lattice", "ellips_v_oid", diff --git a/splinepy/microstructure/tiles/armadillo.py b/splinepy/microstructure/tiles/armadillo.py index e7f39aa66..9bbf602da 100644 --- a/splinepy/microstructure/tiles/armadillo.py +++ b/splinepy/microstructure/tiles/armadillo.py @@ -20,6 +20,15 @@ class Armadillo(_TileBase): _dim = 3 _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 1 + _sensitivities_implemented = False + _closure_directions = [ + "x_min", + "x_max", + "y_min", + "y_max", + "z_min", + "z_max", + ] def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/chi.py b/splinepy/microstructure/tiles/chi.py index b8430d0dc..e3cbf708b 100644 --- a/splinepy/microstructure/tiles/chi.py +++ b/splinepy/microstructure/tiles/chi.py @@ -18,6 +18,9 @@ class Chi(_TileBase): _para_dim = 1 _evaluation_points = _np.array([[0.5, 0.5]]) _n_info_per_eval_point = 1 + _sensitivities_implemented = True + + _parameter_bounds = {"parameters": [-_np.pi / 2, _np.pi / 2]} def create_tile( self, @@ -48,11 +51,16 @@ def create_tile( ) parameters = _np.array([[_np.pi / 8]]) else: + angle_bounds = self._parameter_bounds["parameters"] if not ( - _np.all(parameters >= -_np.pi * 0.5) - and _np.all(parameters < _np.pi * 0.5) + _np.all(parameters >= angle_bounds[0]) + and _np.all(parameters < angle_bounds[1]) ): - raise ValueError("The parameter must be in -Pi/2 and Pi/2") + error_message = ( + f"The parameter must be in {angle_bounds[0]}" + + f"and {angle_bounds[1]}" + ) + raise ValueError(error_message) pass self.check_params(parameters) diff --git a/splinepy/microstructure/tiles/cross_2d.py b/splinepy/microstructure/tiles/cross_2d.py index 083d0c65a..cf4a988d2 100644 --- a/splinepy/microstructure/tiles/cross_2d.py +++ b/splinepy/microstructure/tiles/cross_2d.py @@ -26,6 +26,9 @@ class Cross2D(_TileBase): ] ) _n_info_per_eval_point = 1 + _parameter_bounds = {"center_expansion": [0.5, 1.5]} + _sensitivities_implemented = True + _closure_directions = ["x_min", "x_max", "y_min", "y_max"] def _closing_tile( self, @@ -417,8 +420,16 @@ def create_tile( if not isinstance(center_expansion, float): raise ValueError("Invalid Type") - if not ((center_expansion > 0.5) and (center_expansion < 1.5)): - raise ValueError("Center Expansion must be in (.5,1.5)") + center_expansion_bounds = self._parameter_bounds["center_expansion"] + if not ( + (center_expansion > center_expansion_bounds[0]) + and (center_expansion < center_expansion_bounds[1]) + ): + error_message = ( + "Center Expansion must be in (" + + f"{center_expansion_bounds[0]}, {center_expansion_bounds[1]})" + ) + raise ValueError(error_message) max_radius = min(0.5, (0.5 / center_expansion)) diff --git a/splinepy/microstructure/tiles/cross_3d.py b/splinepy/microstructure/tiles/cross_3d.py index 8752c9881..01282c6f3 100644 --- a/splinepy/microstructure/tiles/cross_3d.py +++ b/splinepy/microstructure/tiles/cross_3d.py @@ -28,6 +28,8 @@ class Cross3D(_TileBase): ] ) _n_info_per_eval_point = 1 + _sensitivities_implemented = True + _closure_directions = ["z_min", "z_max"] def _closing_tile( self, @@ -557,6 +559,10 @@ def create_tile( derivatives = None if closure is not None: + if closure not in self._closure_directions: + raise NotImplementedError( + f"Closure '{closure}' not implemented" + ) return self._closing_tile( parameters=parameters, parameter_sensitivities=parameter_sensitivities, diff --git a/splinepy/microstructure/tiles/cross_3d_linear.py b/splinepy/microstructure/tiles/cross_3d_linear.py index 3e5901371..952738afe 100644 --- a/splinepy/microstructure/tiles/cross_3d_linear.py +++ b/splinepy/microstructure/tiles/cross_3d_linear.py @@ -28,6 +28,8 @@ class Cross3DLinear(_TileBase): ] ) _n_info_per_eval_point = 1 + _sensitivities_implemented = True + _closure_directions = ["z_min", "z_max"] def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/cube_void.py b/splinepy/microstructure/tiles/cube_void.py index be4f1ab3a..a8da85df6 100644 --- a/splinepy/microstructure/tiles/cube_void.py +++ b/splinepy/microstructure/tiles/cube_void.py @@ -25,6 +25,7 @@ class CubeVoid(_TileBase): _para_dim = 3 _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 4 + _sensitivities_implemented = True # Aux values _sphere_ctps = _np.array( diff --git a/splinepy/microstructure/tiles/double_lattice.py b/splinepy/microstructure/tiles/double_lattice.py index ad8f6e803..ffb2166b2 100644 --- a/splinepy/microstructure/tiles/double_lattice.py +++ b/splinepy/microstructure/tiles/double_lattice.py @@ -20,6 +20,7 @@ class DoubleLattice(_TileBase): _para_dim = 2 _evaluation_points = _np.array([[0.5, 0.5]]) _n_info_per_eval_point = 2 + _sensitivities_implemented = True def create_tile( self, @@ -44,7 +45,7 @@ def create_tile( correlates with thickness of branches and entouring wall contact_length : double required for conformity between tiles, sets the length of the center - block on the tiles boundary + block on the tile's boundary Returns ------- diff --git a/splinepy/microstructure/tiles/ellips_v_oid.py b/splinepy/microstructure/tiles/ellips_v_oid.py index 4b6e7bf23..ec7a5cfe9 100644 --- a/splinepy/microstructure/tiles/ellips_v_oid.py +++ b/splinepy/microstructure/tiles/ellips_v_oid.py @@ -27,6 +27,7 @@ class EllipsVoid(_TileBase): _para_dim = 3 _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 4 + _sensitivities_implemented = True # Aux values _c0 = 0.5 / 3**0.5 diff --git a/splinepy/microstructure/tiles/hollow_cube.py b/splinepy/microstructure/tiles/hollow_cube.py index cd8cc300a..028ca0ed4 100644 --- a/splinepy/microstructure/tiles/hollow_cube.py +++ b/splinepy/microstructure/tiles/hollow_cube.py @@ -28,6 +28,7 @@ class HollowCube(_TileBase): ] ) _n_info_per_eval_point = 1 + _sensitivities_implemented = True def create_tile( self, diff --git a/splinepy/microstructure/tiles/hollow_octagon.py b/splinepy/microstructure/tiles/hollow_octagon.py index 20a628e17..44b31a65a 100644 --- a/splinepy/microstructure/tiles/hollow_octagon.py +++ b/splinepy/microstructure/tiles/hollow_octagon.py @@ -18,6 +18,8 @@ class HollowOctagon(_TileBase): _para_dim = 2 _evaluation_points = _np.array([[0.5, 0.5]]) _n_info_per_eval_point = 1 + _sensitivities_implemented = False + _closure_directions = ["x_min", "x_max", "y_min", "y_max"] def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/hollow_octagon_extrude.py b/splinepy/microstructure/tiles/hollow_octagon_extrude.py index 82e738d23..dbf5f1901 100644 --- a/splinepy/microstructure/tiles/hollow_octagon_extrude.py +++ b/splinepy/microstructure/tiles/hollow_octagon_extrude.py @@ -18,6 +18,8 @@ class HollowOctagonExtrude(_TileBase): _para_dim = 3 _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 1 + _sensitivities_implemented = False + _closure_directions = ["x_min", "x_max", "y_min", "y_max"] def create_tile( self, @@ -215,7 +217,7 @@ def create_tile( return (spline_list, None) - def closing_tile( + def _closing_tile( self, parameters=None, parameter_sensitivities=None, # TODO diff --git a/splinepy/microstructure/tiles/inverse_cross_3d.py b/splinepy/microstructure/tiles/inverse_cross_3d.py index c24954702..a633632fc 100644 --- a/splinepy/microstructure/tiles/inverse_cross_3d.py +++ b/splinepy/microstructure/tiles/inverse_cross_3d.py @@ -32,6 +32,8 @@ class InverseCross3D(_TileBase): ] ) _n_info_per_eval_point = 1 + _sensitivities_implemented = False + _closure_directions = ["z_min", "z_max"] def _closing_tile( self, @@ -40,7 +42,7 @@ def _closing_tile( closure=None, boundary_width=0.1, filling_height=0.5, - seperator_distance=None, + separator_distance=None, **kwargs, # noqa ARG002 ): """Create a closing tile to match with closed surface. @@ -53,7 +55,7 @@ def _closing_tile( with of the boundary surrounding branch filling_height : float portion of the height that is filled in parametric domain - seperator_distance : float + separator_distance : float Describes the position of the separator layer in the control point domain closure : str @@ -70,8 +72,8 @@ def _closing_tile( raise ValueError("No closing direction given") # Set default values - if seperator_distance is None: - seperator_distance = 0.3 + if separator_distance is None: + separator_distance = 0.3 if parameters is None: self._logd("Tile request is not parametrized, setting default 0.2") @@ -108,7 +110,7 @@ def _closing_tile( center_width = 1.0 - 2 * boundary_width r_center = center_width * 0.5 half_r_center = (r_center + 0.5) * 0.5 - aux_column_width = 0.5 - 2 * (0.5 - seperator_distance) + aux_column_width = 0.5 - 2 * (0.5 - separator_distance) spline_list = [] if closure == "z_min": @@ -123,7 +125,7 @@ def _closing_tile( [-r_center, r_center, filling_height], [-0.5, -aux_column_width, ctps_mid_height_top], [ - -seperator_distance, + -separator_distance, -aux_column_width, ctps_mid_height_top, ], @@ -134,16 +136,16 @@ def _closing_tile( ], [-0.5, aux_column_width, ctps_mid_height_top], [ - -seperator_distance, + -separator_distance, aux_column_width, ctps_mid_height_top, ], [-branch_thickness, branch_thickness, ctps_mid_height_top], [-0.5, -aux_column_width, 1.0], - [-seperator_distance, -aux_column_width, 1.0], + [-separator_distance, -aux_column_width, 1.0], [-branch_thickness, -branch_thickness, 1.0], [-0.5, aux_column_width, 1.0], - [-seperator_distance, aux_column_width, 1.0], + [-separator_distance, aux_column_width, 1.0], [-branch_thickness, branch_thickness, 1.0], ] ) + _np.array([0.5, 0.5, 0.0]) @@ -165,23 +167,23 @@ def _closing_tile( [0.5, r_center, filling_height], [branch_thickness, -branch_thickness, ctps_mid_height_top], [ - seperator_distance, + separator_distance, -aux_column_width, ctps_mid_height_top, ], [0.5, -aux_column_width, ctps_mid_height_top], [branch_thickness, branch_thickness, ctps_mid_height_top], [ - seperator_distance, + separator_distance, aux_column_width, ctps_mid_height_top, ], [0.5, aux_column_width, ctps_mid_height_top], [branch_thickness, -branch_thickness, 1.0], - [seperator_distance, -aux_column_width, 1.0], + [separator_distance, -aux_column_width, 1.0], [0.5, -aux_column_width, 1.0], [branch_thickness, branch_thickness, 1.0], - [seperator_distance, aux_column_width, 1.0], + [separator_distance, aux_column_width, 1.0], [0.5, aux_column_width, 1.0], ] ) + _np.array([0.5, 0.5, 0.0]) @@ -205,12 +207,12 @@ def _closing_tile( [aux_column_width, -0.5, ctps_mid_height_top], [ -aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_top, ], [ aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_top, ], [ @@ -221,8 +223,8 @@ def _closing_tile( [branch_thickness, -branch_thickness, ctps_mid_height_top], [-aux_column_width, -0.5, 1.0], [aux_column_width, -0.5, 1.0], - [-aux_column_width, -seperator_distance, 1.0], - [aux_column_width, -seperator_distance, 1.0], + [-aux_column_width, -separator_distance, 1.0], + [aux_column_width, -separator_distance, 1.0], [-branch_thickness, -branch_thickness, 1.0], [branch_thickness, -branch_thickness, 1.0], ] @@ -247,20 +249,20 @@ def _closing_tile( [branch_thickness, branch_thickness, ctps_mid_height_top], [ -aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_top, ], [ aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_top, ], [-aux_column_width, 0.5, ctps_mid_height_top], [aux_column_width, 0.5, ctps_mid_height_top], [-branch_thickness, branch_thickness, 1.0], [branch_thickness, branch_thickness, 1.0], - [-aux_column_width, seperator_distance, 1.0], - [aux_column_width, seperator_distance, 1.0], + [-aux_column_width, separator_distance, 1.0], + [aux_column_width, separator_distance, 1.0], [-aux_column_width, 0.5, 1.0], [aux_column_width, 0.5, 1.0], ] @@ -285,22 +287,22 @@ def _closing_tile( [-half_r_center, -r_center, filling_height], [-r_center, -r_center, filling_height], [-0.5, -0.5, ctps_mid_height_top], - [-seperator_distance, -0.5, ctps_mid_height_top], + [-separator_distance, -0.5, ctps_mid_height_top], [-aux_column_width, -0.5, ctps_mid_height_top], - [-0.5, -seperator_distance, ctps_mid_height_top], + [-0.5, -separator_distance, ctps_mid_height_top], [ - -seperator_distance, - -seperator_distance, + -separator_distance, + -separator_distance, ctps_mid_height_top, ], [ -aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_top, ], [-0.5, -aux_column_width, ctps_mid_height_top], [ - -seperator_distance, + -separator_distance, -aux_column_width, ctps_mid_height_top, ], @@ -310,13 +312,13 @@ def _closing_tile( ctps_mid_height_top, ], [-0.5, -0.5, 1.0], - [-seperator_distance, -0.5, 1.0], + [-separator_distance, -0.5, 1.0], [-aux_column_width, -0.5, 1.0], - [-0.5, -seperator_distance, 1.0], - [-seperator_distance, -seperator_distance, 1.0], - [-aux_column_width, -seperator_distance, 1.0], + [-0.5, -separator_distance, 1.0], + [-separator_distance, -separator_distance, 1.0], + [-aux_column_width, -separator_distance, 1.0], [-0.5, -aux_column_width, 1.0], - [-seperator_distance, -aux_column_width, 1.0], + [-separator_distance, -aux_column_width, 1.0], [-branch_thickness, -branch_thickness, 1.0], ] ) + _np.array([0.5, 0.5, 0.0]) @@ -340,33 +342,33 @@ def _closing_tile( [-r_center, 0.5, filling_height], [-0.5, aux_column_width, ctps_mid_height_top], [ - -seperator_distance, + -separator_distance, aux_column_width, ctps_mid_height_top, ], [-branch_thickness, branch_thickness, ctps_mid_height_top], - [-0.5, seperator_distance, ctps_mid_height_top], + [-0.5, separator_distance, ctps_mid_height_top], [ - -seperator_distance, - seperator_distance, + -separator_distance, + separator_distance, ctps_mid_height_top, ], [ -aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_top, ], [-0.5, 0.5, ctps_mid_height_top], - [-seperator_distance, 0.5, ctps_mid_height_top], + [-separator_distance, 0.5, ctps_mid_height_top], [-aux_column_width, 0.5, ctps_mid_height_top], [-0.5, aux_column_width, 1.0], - [-seperator_distance, aux_column_width, 1.0], + [-separator_distance, aux_column_width, 1.0], [-branch_thickness, branch_thickness, 1.0], - [-0.5, seperator_distance, 1.0], - [-seperator_distance, seperator_distance, 1.0], - [-aux_column_width, seperator_distance, 1.0], + [-0.5, separator_distance, 1.0], + [-separator_distance, separator_distance, 1.0], + [-aux_column_width, separator_distance, 1.0], [-0.5, 0.5, 1.0], - [-seperator_distance, 0.5, 1.0], + [-separator_distance, 0.5, 1.0], [-aux_column_width, 0.5, 1.0], ] ) + _np.array([0.5, 0.5, 0.0]) @@ -389,34 +391,34 @@ def _closing_tile( [half_r_center, -r_center, filling_height], [0.5, -r_center, filling_height], [aux_column_width, -0.5, ctps_mid_height_top], - [seperator_distance, -0.5, ctps_mid_height_top], + [separator_distance, -0.5, ctps_mid_height_top], [0.5, -0.5, ctps_mid_height_top], [ aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_top, ], [ - seperator_distance, - -seperator_distance, + separator_distance, + -separator_distance, ctps_mid_height_top, ], - [0.5, -seperator_distance, ctps_mid_height_top], + [0.5, -separator_distance, ctps_mid_height_top], [branch_thickness, -branch_thickness, ctps_mid_height_top], [ - seperator_distance, + separator_distance, -aux_column_width, ctps_mid_height_top, ], [0.5, -aux_column_width, ctps_mid_height_top], [aux_column_width, -0.5, 1.0], - [seperator_distance, -0.5, 1.0], + [separator_distance, -0.5, 1.0], [0.5, -0.5, 1.0], - [aux_column_width, -seperator_distance, 1.0], - [seperator_distance, -seperator_distance, 1.0], - [0.5, -seperator_distance, 1.0], + [aux_column_width, -separator_distance, 1.0], + [separator_distance, -separator_distance, 1.0], + [0.5, -separator_distance, 1.0], [branch_thickness, -branch_thickness, 1.0], - [seperator_distance, -aux_column_width, 1.0], + [separator_distance, -aux_column_width, 1.0], [0.5, -aux_column_width, 1.0], ] ) + _np.array([0.5, 0.5, 0.0]) @@ -440,33 +442,33 @@ def _closing_tile( [0.5, 0.5, filling_height], [branch_thickness, branch_thickness, ctps_mid_height_top], [ - seperator_distance, + separator_distance, aux_column_width, ctps_mid_height_top, ], [0.5, aux_column_width, ctps_mid_height_top], [ aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_top, ], [ - seperator_distance, - seperator_distance, + separator_distance, + separator_distance, ctps_mid_height_top, ], - [0.5, seperator_distance, ctps_mid_height_top], + [0.5, separator_distance, ctps_mid_height_top], [aux_column_width, 0.5, ctps_mid_height_top], - [seperator_distance, 0.5, ctps_mid_height_top], + [separator_distance, 0.5, ctps_mid_height_top], [0.5, 0.5, ctps_mid_height_top], [branch_thickness, branch_thickness, 1.0], - [seperator_distance, aux_column_width, 1.0], + [separator_distance, aux_column_width, 1.0], [0.5, aux_column_width, 1.0], - [aux_column_width, seperator_distance, 1.0], - [seperator_distance, seperator_distance, 1.0], - [0.5, seperator_distance, 1.0], + [aux_column_width, separator_distance, 1.0], + [separator_distance, separator_distance, 1.0], + [0.5, separator_distance, 1.0], [aux_column_width, 0.5, 1.0], - [seperator_distance, 0.5, 1.0], + [separator_distance, 0.5, 1.0], [0.5, 0.5, 1.0], ] ) + _np.array([0.5, 0.5, 0.0]) @@ -484,14 +486,14 @@ def _closing_tile( branch_neighbor_x_min_ctps = _np.array( [ [-0.5, -aux_column_width, 0.0], - [-seperator_distance, -aux_column_width, 0.0], + [-separator_distance, -aux_column_width, 0.0], [-branch_thickness, -branch_thickness, 0.0], [-0.5, aux_column_width, 0.0], - [-seperator_distance, aux_column_width, 0.0], + [-separator_distance, aux_column_width, 0.0], [-branch_thickness, branch_thickness, 0.0], [-0.5, -aux_column_width, ctps_mid_height_bottom], [ - -seperator_distance, + -separator_distance, -aux_column_width, ctps_mid_height_bottom, ], @@ -502,7 +504,7 @@ def _closing_tile( ], [-0.5, aux_column_width, ctps_mid_height_bottom], [ - -seperator_distance, + -separator_distance, aux_column_width, ctps_mid_height_bottom, ], @@ -530,10 +532,10 @@ def _closing_tile( branch_neighbor_x_max_ctps = _np.array( [ [branch_thickness, -branch_thickness, 0.0], - [seperator_distance, -aux_column_width, 0.0], + [separator_distance, -aux_column_width, 0.0], [0.5, -aux_column_width, 0.0], [branch_thickness, branch_thickness, 0.0], - [seperator_distance, aux_column_width, 0.0], + [separator_distance, aux_column_width, 0.0], [0.5, aux_column_width, 0.0], [ branch_thickness, @@ -541,7 +543,7 @@ def _closing_tile( ctps_mid_height_bottom, ], [ - seperator_distance, + separator_distance, -aux_column_width, ctps_mid_height_bottom, ], @@ -552,7 +554,7 @@ def _closing_tile( ctps_mid_height_bottom, ], [ - seperator_distance, + separator_distance, aux_column_width, ctps_mid_height_bottom, ], @@ -577,20 +579,20 @@ def _closing_tile( [ [-aux_column_width, -0.5, 0.0], [aux_column_width, -0.5, 0.0], - [-aux_column_width, -seperator_distance, 0.0], - [aux_column_width, -seperator_distance, 0.0], + [-aux_column_width, -separator_distance, 0.0], + [aux_column_width, -separator_distance, 0.0], [-branch_thickness, -branch_thickness, 0.0], [branch_thickness, -branch_thickness, 0.0], [-aux_column_width, -0.5, ctps_mid_height_bottom], [aux_column_width, -0.5, ctps_mid_height_bottom], [ -aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_bottom, ], [ aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_bottom, ], [ @@ -623,8 +625,8 @@ def _closing_tile( [ [-branch_thickness, branch_thickness, 0.0], [branch_thickness, branch_thickness, 0.0], - [-aux_column_width, seperator_distance, 0.0], - [aux_column_width, seperator_distance, 0.0], + [-aux_column_width, separator_distance, 0.0], + [aux_column_width, separator_distance, 0.0], [-aux_column_width, 0.5, 0.0], [aux_column_width, 0.5, 0.0], [ @@ -639,12 +641,12 @@ def _closing_tile( ], [ -aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_bottom, ], [ aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_bottom, ], [-aux_column_width, 0.5, ctps_mid_height_bottom], @@ -668,31 +670,31 @@ def _closing_tile( branch_x_min_y_min_ctps = _np.array( [ [-0.5, -0.5, 0.0], - [-seperator_distance, -0.5, 0.0], + [-separator_distance, -0.5, 0.0], [-aux_column_width, -0.5, 0.0], - [-0.5, -seperator_distance, 0.0], - [-seperator_distance, -seperator_distance, 0.0], - [-aux_column_width, -seperator_distance, 0.0], + [-0.5, -separator_distance, 0.0], + [-separator_distance, -separator_distance, 0.0], + [-aux_column_width, -separator_distance, 0.0], [-0.5, -aux_column_width, 0.0], - [-seperator_distance, -aux_column_width, 0.0], + [-separator_distance, -aux_column_width, 0.0], [-branch_thickness, -branch_thickness, 0.0], [-0.5, -0.5, ctps_mid_height_bottom], - [-seperator_distance, -0.5, ctps_mid_height_bottom], + [-separator_distance, -0.5, ctps_mid_height_bottom], [-aux_column_width, -0.5, ctps_mid_height_bottom], - [-0.5, -seperator_distance, ctps_mid_height_bottom], + [-0.5, -separator_distance, ctps_mid_height_bottom], [ - -seperator_distance, - -seperator_distance, + -separator_distance, + -separator_distance, ctps_mid_height_bottom, ], [ -aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_bottom, ], [-0.5, -aux_column_width, ctps_mid_height_bottom], [ - -seperator_distance, + -separator_distance, -aux_column_width, ctps_mid_height_bottom, ], @@ -722,13 +724,13 @@ def _closing_tile( branch_x_max_y_max_ctps = _np.array( [ [branch_thickness, branch_thickness, 0.0], - [seperator_distance, aux_column_width, 0.0], + [separator_distance, aux_column_width, 0.0], [0.5, aux_column_width, 0.0], - [aux_column_width, seperator_distance, 0.0], - [seperator_distance, seperator_distance, 0.0], - [0.5, seperator_distance, 0.0], + [aux_column_width, separator_distance, 0.0], + [separator_distance, separator_distance, 0.0], + [0.5, separator_distance, 0.0], [aux_column_width, 0.5, 0.0], - [seperator_distance, 0.5, 0.0], + [separator_distance, 0.5, 0.0], [0.5, 0.5, 0.0], [ branch_thickness, @@ -736,24 +738,24 @@ def _closing_tile( ctps_mid_height_bottom, ], [ - seperator_distance, + separator_distance, aux_column_width, ctps_mid_height_bottom, ], [0.5, aux_column_width, ctps_mid_height_bottom], [ aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_bottom, ], [ - seperator_distance, - seperator_distance, + separator_distance, + separator_distance, ctps_mid_height_bottom, ], - [0.5, seperator_distance, ctps_mid_height_bottom], + [0.5, separator_distance, ctps_mid_height_bottom], [aux_column_width, 0.5, ctps_mid_height_bottom], - [seperator_distance, 0.5, ctps_mid_height_bottom], + [separator_distance, 0.5, ctps_mid_height_bottom], [0.5, 0.5, ctps_mid_height_bottom], [r_center, r_center, inv_filling_height], [half_r_center, r_center, inv_filling_height], @@ -776,35 +778,35 @@ def _closing_tile( branch_x_max_y_min_ctps = _np.array( [ [aux_column_width, -0.5, 0.0], - [seperator_distance, -0.5, 0.0], + [separator_distance, -0.5, 0.0], [0.5, -0.5, 0.0], - [aux_column_width, -seperator_distance, 0.0], - [seperator_distance, -seperator_distance, 0.0], - [0.5, -seperator_distance, 0.0], + [aux_column_width, -separator_distance, 0.0], + [separator_distance, -separator_distance, 0.0], + [0.5, -separator_distance, 0.0], [branch_thickness, -branch_thickness, 0.0], - [seperator_distance, -aux_column_width, 0.0], + [separator_distance, -aux_column_width, 0.0], [0.5, -aux_column_width, 0.0], [aux_column_width, -0.5, ctps_mid_height_bottom], - [seperator_distance, -0.5, ctps_mid_height_bottom], + [separator_distance, -0.5, ctps_mid_height_bottom], [0.5, -0.5, ctps_mid_height_bottom], [ aux_column_width, - -seperator_distance, + -separator_distance, ctps_mid_height_bottom, ], [ - seperator_distance, - -seperator_distance, + separator_distance, + -separator_distance, ctps_mid_height_bottom, ], - [0.5, -seperator_distance, ctps_mid_height_bottom], + [0.5, -separator_distance, ctps_mid_height_bottom], [ branch_thickness, -branch_thickness, ctps_mid_height_bottom, ], [ - seperator_distance, + separator_distance, -aux_column_width, ctps_mid_height_bottom, ], @@ -830,17 +832,17 @@ def _closing_tile( branch_x_min_y_max_ctps = _np.array( [ [-0.5, aux_column_width, 0.0], - [-seperator_distance, aux_column_width, 0.0], + [-separator_distance, aux_column_width, 0.0], [-branch_thickness, branch_thickness, 0.0], - [-0.5, seperator_distance, 0.0], - [-seperator_distance, seperator_distance, 0.0], - [-aux_column_width, seperator_distance, 0.0], + [-0.5, separator_distance, 0.0], + [-separator_distance, separator_distance, 0.0], + [-aux_column_width, separator_distance, 0.0], [-0.5, 0.5, 0.0], - [-seperator_distance, 0.5, 0.0], + [-separator_distance, 0.5, 0.0], [-aux_column_width, 0.5, 0.0], [-0.5, aux_column_width, ctps_mid_height_bottom], [ - -seperator_distance, + -separator_distance, aux_column_width, ctps_mid_height_bottom, ], @@ -849,19 +851,19 @@ def _closing_tile( branch_thickness, ctps_mid_height_bottom, ], - [-0.5, seperator_distance, ctps_mid_height_bottom], + [-0.5, separator_distance, ctps_mid_height_bottom], [ - -seperator_distance, - seperator_distance, + -separator_distance, + separator_distance, ctps_mid_height_bottom, ], [ -aux_column_width, - seperator_distance, + separator_distance, ctps_mid_height_bottom, ], [-0.5, 0.5, ctps_mid_height_bottom], - [-seperator_distance, 0.5, ctps_mid_height_bottom], + [-separator_distance, 0.5, ctps_mid_height_bottom], [-aux_column_width, 0.5, ctps_mid_height_bottom], [-0.5, r_center, inv_filling_height], [-half_r_center, r_center, inv_filling_height], @@ -889,7 +891,7 @@ def create_tile( self, parameters=None, parameter_sensitivities=None, - seperator_distance=None, + separator_distance=None, center_expansion=1.0, closure=None, **kwargs, # noqa ARG002 @@ -905,7 +907,7 @@ def create_tile( parameters : np.array only first entry is used, defines the internal radii of the branches - seperator_distance : float + separator_distance : float Control point distance to separation layer of biquadratic degrees, determines the minimum branch thickness (defaults to 0.4) center_expansion : float @@ -927,16 +929,16 @@ def create_tile( raise ValueError("Center Expansion must be in (.5, 1.5)") # Set default values - if seperator_distance is None: - seperator_distance = 0.3 + if separator_distance is None: + separator_distance = 0.3 if center_expansion is None: center_expansion = 1.0 # Check if all radii are in allowed range max_radius = min(0.5, (0.5 / center_expansion)) - max_radius = min(max_radius, seperator_distance) - min_radius = max(0.5 - seperator_distance, 0) + max_radius = min(max_radius, separator_distance) + min_radius = max(0.5 - separator_distance, 0) # set to default if nothing is given if parameters is None: @@ -967,7 +969,7 @@ def create_tile( return self._closing_tile( parameters=parameters, parameter_sensitivities=parameter_sensitivities, - seperator_distance=seperator_distance, + separator_distance=separator_distance, closure=closure, **kwargs, ) @@ -995,7 +997,7 @@ def create_tile( ] = _np.minimum(parameters.ravel(), center_r) # Branch midlength hd_center = 0.5 * (0.5 + center_r) - aux_column_width = 0.5 - 2 * (0.5 - seperator_distance) + aux_column_width = 0.5 - 2 * (0.5 - separator_distance) # Init return type spline_list = [] @@ -1004,18 +1006,18 @@ def create_tile( x_min_y_min = _np.array( [ [-0.5, -0.5, -aux_column_width], - [-seperator_distance, -0.5, -aux_column_width], + [-separator_distance, -0.5, -aux_column_width], [-y_min_r, -0.5, -y_min_r], - [-0.5, -seperator_distance, -aux_column_width], + [-0.5, -separator_distance, -aux_column_width], [-hd_center, -hd_center, -aux_column_width], [-aux_y_min, -hd_center, -aux_y_min], [-0.5, -x_min_r, -x_min_r], [-hd_center, -aux_x_min, -aux_x_min], [-center_r, -center_r, -center_r], [-0.5, -0.5, aux_column_width], - [-seperator_distance, -0.5, aux_column_width], + [-separator_distance, -0.5, aux_column_width], [-y_min_r, -0.5, y_min_r], - [-0.5, -seperator_distance, aux_column_width], + [-0.5, -separator_distance, aux_column_width], [-hd_center, -hd_center, aux_column_width], [-aux_y_min, -hd_center, aux_y_min], [-0.5, -x_min_r, x_min_r], @@ -1031,20 +1033,20 @@ def create_tile( x_max_y_min = _np.array( [ [y_min_r, -0.5, -y_min_r], - [seperator_distance, -0.5, -aux_column_width], + [separator_distance, -0.5, -aux_column_width], [0.5, -0.5, -aux_column_width], [aux_y_min, -hd_center, -aux_y_min], [hd_center, -hd_center, -aux_column_width], - [0.5, -seperator_distance, -aux_column_width], + [0.5, -separator_distance, -aux_column_width], [center_r, -center_r, -center_r], [hd_center, -aux_x_max, -aux_x_max], [0.5, -x_max_r, -x_max_r], [y_min_r, -0.5, y_min_r], - [seperator_distance, -0.5, aux_column_width], + [separator_distance, -0.5, aux_column_width], [0.5, -0.5, aux_column_width], [aux_y_min, -hd_center, aux_y_min], [hd_center, -hd_center, aux_column_width], - [0.5, -seperator_distance, aux_column_width], + [0.5, -separator_distance, aux_column_width], [center_r, -center_r, center_r], [hd_center, -aux_x_max, aux_x_max], [0.5, -x_max_r, x_max_r], @@ -1060,20 +1062,20 @@ def create_tile( [-0.5, x_min_r, -x_min_r], [-hd_center, aux_x_min, -aux_x_min], [-center_r, center_r, -center_r], - [-0.5, seperator_distance, -aux_column_width], + [-0.5, separator_distance, -aux_column_width], [-hd_center, hd_center, -aux_column_width], [-aux_y_max, hd_center, -aux_y_max], [-0.5, 0.5, -aux_column_width], - [-seperator_distance, 0.5, -aux_column_width], + [-separator_distance, 0.5, -aux_column_width], [-y_max_r, 0.5, -y_max_r], [-0.5, x_min_r, x_min_r], [-hd_center, aux_x_min, aux_x_min], [-center_r, center_r, center_r], - [-0.5, seperator_distance, aux_column_width], + [-0.5, separator_distance, aux_column_width], [-hd_center, hd_center, aux_column_width], [-aux_y_max, hd_center, aux_y_max], [-0.5, 0.5, aux_column_width], - [-seperator_distance, 0.5, aux_column_width], + [-separator_distance, 0.5, aux_column_width], [-y_max_r, 0.5, y_max_r], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1089,18 +1091,18 @@ def create_tile( [0.5, x_max_r, -x_max_r], [aux_y_max, hd_center, -aux_y_max], [hd_center, hd_center, -aux_column_width], - [0.5, seperator_distance, -aux_column_width], + [0.5, separator_distance, -aux_column_width], [y_max_r, 0.5, -y_max_r], - [seperator_distance, 0.5, -aux_column_width], + [separator_distance, 0.5, -aux_column_width], [0.5, 0.5, -aux_column_width], [center_r, center_r, center_r], [hd_center, aux_x_max, aux_x_max], [0.5, x_max_r, x_max_r], [aux_y_max, hd_center, aux_y_max], [hd_center, hd_center, aux_column_width], - [0.5, seperator_distance, aux_column_width], + [0.5, separator_distance, aux_column_width], [y_max_r, 0.5, y_max_r], - [seperator_distance, 0.5, aux_column_width], + [separator_distance, 0.5, aux_column_width], [0.5, 0.5, aux_column_width], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1112,15 +1114,15 @@ def create_tile( x_min_z_min = _np.array( [ [-0.5, -aux_column_width, -0.5], - [-seperator_distance, -aux_column_width, -0.5], + [-separator_distance, -aux_column_width, -0.5], [-z_min_r, -z_min_r, -0.5], [-0.5, aux_column_width, -0.5], - [-seperator_distance, aux_column_width, -0.5], + [-separator_distance, aux_column_width, -0.5], [-z_min_r, z_min_r, -0.5], - [-0.5, -aux_column_width, -seperator_distance], + [-0.5, -aux_column_width, -separator_distance], [-hd_center, -aux_column_width, -hd_center], [-aux_z_min, -aux_z_min, -hd_center], - [-0.5, aux_column_width, -seperator_distance], + [-0.5, aux_column_width, -separator_distance], [-hd_center, aux_column_width, -hd_center], [-aux_z_min, aux_z_min, -hd_center], [-0.5, -x_min_r, -x_min_r], @@ -1139,17 +1141,17 @@ def create_tile( x_max_z_min = _np.array( [ [z_min_r, -z_min_r, -0.5], - [seperator_distance, -aux_column_width, -0.5], + [separator_distance, -aux_column_width, -0.5], [0.5, -aux_column_width, -0.5], [z_min_r, z_min_r, -0.5], - [seperator_distance, aux_column_width, -0.5], + [separator_distance, aux_column_width, -0.5], [0.5, aux_column_width, -0.5], [aux_z_min, -aux_z_min, -hd_center], [hd_center, -aux_column_width, -hd_center], - [0.5, -aux_column_width, -seperator_distance], + [0.5, -aux_column_width, -separator_distance], [aux_z_min, aux_z_min, -hd_center], [hd_center, aux_column_width, -hd_center], - [0.5, aux_column_width, -seperator_distance], + [0.5, aux_column_width, -separator_distance], [center_r, -center_r, -center_r], [hd_center, -aux_x_max, -aux_x_max], [0.5, -x_max_r, -x_max_r], @@ -1171,17 +1173,17 @@ def create_tile( [-0.5, x_min_r, x_min_r], [-hd_center, aux_x_min, aux_x_min], [-center_r, center_r, center_r], - [-0.5, -aux_column_width, seperator_distance], + [-0.5, -aux_column_width, separator_distance], [-hd_center, -aux_column_width, hd_center], [-aux_z_max, -aux_z_max, hd_center], - [-0.5, aux_column_width, seperator_distance], + [-0.5, aux_column_width, separator_distance], [-hd_center, aux_column_width, hd_center], [-aux_z_max, aux_z_max, hd_center], [-0.5, -aux_column_width, 0.5], - [-seperator_distance, -aux_column_width, 0.5], + [-separator_distance, -aux_column_width, 0.5], [-z_max_r, -z_max_r, 0.5], [-0.5, aux_column_width, 0.5], - [-seperator_distance, aux_column_width, 0.5], + [-separator_distance, aux_column_width, 0.5], [-z_max_r, z_max_r, 0.5], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1200,15 +1202,15 @@ def create_tile( [0.5, x_max_r, x_max_r], [aux_z_max, -aux_z_max, hd_center], [hd_center, -aux_column_width, hd_center], - [0.5, -aux_column_width, seperator_distance], + [0.5, -aux_column_width, separator_distance], [aux_z_max, aux_z_max, hd_center], [hd_center, aux_column_width, hd_center], - [0.5, aux_column_width, seperator_distance], + [0.5, aux_column_width, separator_distance], [z_max_r, -z_max_r, 0.5], - [seperator_distance, -aux_column_width, 0.5], + [separator_distance, -aux_column_width, 0.5], [0.5, -aux_column_width, 0.5], [z_max_r, z_max_r, 0.5], - [seperator_distance, aux_column_width, 0.5], + [separator_distance, aux_column_width, 0.5], [0.5, aux_column_width, 0.5], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1221,12 +1223,12 @@ def create_tile( [ [-aux_column_width, -0.5, -0.5], [aux_column_width, -0.5, -0.5], - [-aux_column_width, -seperator_distance, -0.5], - [aux_column_width, -seperator_distance, -0.5], + [-aux_column_width, -separator_distance, -0.5], + [aux_column_width, -separator_distance, -0.5], [-z_min_r, -z_min_r, -0.5], [z_min_r, -z_min_r, -0.5], - [-aux_column_width, -0.5, -seperator_distance], - [aux_column_width, -0.5, -seperator_distance], + [-aux_column_width, -0.5, -separator_distance], + [aux_column_width, -0.5, -separator_distance], [-aux_column_width, -hd_center, -hd_center], [aux_column_width, -hd_center, -hd_center], [-aux_z_min, -aux_z_min, -hd_center], @@ -1248,16 +1250,16 @@ def create_tile( [ [-z_min_r, z_min_r, -0.5], [z_min_r, z_min_r, -0.5], - [-aux_column_width, seperator_distance, -0.5], - [aux_column_width, seperator_distance, -0.5], + [-aux_column_width, separator_distance, -0.5], + [aux_column_width, separator_distance, -0.5], [-aux_column_width, 0.5, -0.5], [aux_column_width, 0.5, -0.5], [-aux_z_min, aux_z_min, -hd_center], [aux_z_min, aux_z_min, -hd_center], [-aux_column_width, hd_center, -hd_center], [aux_column_width, hd_center, -hd_center], - [-aux_column_width, 0.5, -seperator_distance], - [aux_column_width, 0.5, -seperator_distance], + [-aux_column_width, 0.5, -separator_distance], + [aux_column_width, 0.5, -separator_distance], [-center_r, center_r, -center_r], [center_r, center_r, -center_r], [-aux_y_max, hd_center, -aux_y_max], @@ -1279,16 +1281,16 @@ def create_tile( [aux_y_min, -hd_center, aux_y_min], [-center_r, -center_r, center_r], [center_r, -center_r, center_r], - [-aux_column_width, -0.5, seperator_distance], - [aux_column_width, -0.5, seperator_distance], + [-aux_column_width, -0.5, separator_distance], + [aux_column_width, -0.5, separator_distance], [-aux_column_width, -hd_center, hd_center], [aux_column_width, -hd_center, hd_center], [-aux_z_max, -aux_z_max, hd_center], [aux_z_max, -aux_z_max, hd_center], [-aux_column_width, -0.5, 0.5], [aux_column_width, -0.5, 0.5], - [-aux_column_width, -seperator_distance, 0.5], - [aux_column_width, -seperator_distance, 0.5], + [-aux_column_width, -separator_distance, 0.5], + [aux_column_width, -separator_distance, 0.5], [-z_max_r, -z_max_r, 0.5], [z_max_r, -z_max_r, 0.5], ] @@ -1310,12 +1312,12 @@ def create_tile( [aux_z_max, aux_z_max, hd_center], [-aux_column_width, hd_center, hd_center], [aux_column_width, hd_center, hd_center], - [-aux_column_width, 0.5, seperator_distance], - [aux_column_width, 0.5, seperator_distance], + [-aux_column_width, 0.5, separator_distance], + [aux_column_width, 0.5, separator_distance], [-z_max_r, z_max_r, 0.5], [z_max_r, z_max_r, 0.5], - [-aux_column_width, seperator_distance, 0.5], - [aux_column_width, seperator_distance, 0.5], + [-aux_column_width, separator_distance, 0.5], + [aux_column_width, separator_distance, 0.5], [-aux_column_width, 0.5, 0.5], [aux_column_width, 0.5, 0.5], ] @@ -1328,27 +1330,27 @@ def create_tile( x_min_y_min_z_min = _np.array( [ [-0.5, -0.5, -0.5], - [-seperator_distance, -0.5, -0.5], + [-separator_distance, -0.5, -0.5], [-aux_column_width, -0.5, -0.5], - [-0.5, -seperator_distance, -0.5], - [-seperator_distance, -seperator_distance, -0.5], - [-aux_column_width, -seperator_distance, -0.5], + [-0.5, -separator_distance, -0.5], + [-separator_distance, -separator_distance, -0.5], + [-aux_column_width, -separator_distance, -0.5], [-0.5, -aux_column_width, -0.5], - [-seperator_distance, -aux_column_width, -0.5], + [-separator_distance, -aux_column_width, -0.5], [-z_min_r, -z_min_r, -0.5], - [-0.5, -0.5, -seperator_distance], - [-seperator_distance, -0.5, -seperator_distance], - [-aux_column_width, -0.5, -seperator_distance], - [-0.5, -seperator_distance, -seperator_distance], + [-0.5, -0.5, -separator_distance], + [-separator_distance, -0.5, -separator_distance], + [-aux_column_width, -0.5, -separator_distance], + [-0.5, -separator_distance, -separator_distance], [-hd_center, -hd_center, -hd_center], [-aux_column_width, -hd_center, -hd_center], - [-0.5, -aux_column_width, -seperator_distance], + [-0.5, -aux_column_width, -separator_distance], [-hd_center, -aux_column_width, -hd_center], [-aux_z_min, -aux_z_min, -hd_center], [-0.5, -0.5, -aux_column_width], - [-seperator_distance, -0.5, -aux_column_width], + [-separator_distance, -0.5, -aux_column_width], [-y_min_r, -0.5, -y_min_r], - [-0.5, -seperator_distance, -aux_column_width], + [-0.5, -separator_distance, -aux_column_width], [-hd_center, -hd_center, -aux_column_width], [-aux_y_min, -hd_center, -aux_y_min], [-0.5, -x_min_r, -x_min_r], @@ -1364,29 +1366,29 @@ def create_tile( x_max_y_min_z_min = _np.array( [ [aux_column_width, -0.5, -0.5], - [seperator_distance, -0.5, -0.5], + [separator_distance, -0.5, -0.5], [0.5, -0.5, -0.5], - [aux_column_width, -seperator_distance, -0.5], - [seperator_distance, -seperator_distance, -0.5], - [0.5, -seperator_distance, -0.5], + [aux_column_width, -separator_distance, -0.5], + [separator_distance, -separator_distance, -0.5], + [0.5, -separator_distance, -0.5], [z_min_r, -z_min_r, -0.5], - [seperator_distance, -aux_column_width, -0.5], + [separator_distance, -aux_column_width, -0.5], [0.5, -aux_column_width, -0.5], - [aux_column_width, -0.5, -seperator_distance], - [seperator_distance, -0.5, -seperator_distance], - [0.5, -0.5, -seperator_distance], + [aux_column_width, -0.5, -separator_distance], + [separator_distance, -0.5, -separator_distance], + [0.5, -0.5, -separator_distance], [aux_column_width, -hd_center, -hd_center], [hd_center, -hd_center, -hd_center], - [0.5, -seperator_distance, -seperator_distance], + [0.5, -separator_distance, -separator_distance], [aux_z_min, -aux_z_min, -hd_center], [hd_center, -aux_column_width, -hd_center], - [0.5, -aux_column_width, -seperator_distance], + [0.5, -aux_column_width, -separator_distance], [y_min_r, -0.5, -y_min_r], - [seperator_distance, -0.5, -aux_column_width], + [separator_distance, -0.5, -aux_column_width], [0.5, -0.5, -aux_column_width], [aux_y_min, -hd_center, -aux_y_min], [hd_center, -hd_center, -aux_column_width], - [0.5, -seperator_distance, -aux_column_width], + [0.5, -separator_distance, -aux_column_width], [center_r, -center_r, -center_r], [hd_center, -aux_x_max, -aux_x_max], [0.5, -x_max_r, -x_max_r], @@ -1400,31 +1402,31 @@ def create_tile( x_min_y_max_z_min = _np.array( [ [-0.5, aux_column_width, -0.5], - [-seperator_distance, aux_column_width, -0.5], + [-separator_distance, aux_column_width, -0.5], [-z_min_r, z_min_r, -0.5], - [-0.5, seperator_distance, -0.5], - [-seperator_distance, seperator_distance, -0.5], - [-aux_column_width, seperator_distance, -0.5], + [-0.5, separator_distance, -0.5], + [-separator_distance, separator_distance, -0.5], + [-aux_column_width, separator_distance, -0.5], [-0.5, 0.5, -0.5], - [-seperator_distance, 0.5, -0.5], + [-separator_distance, 0.5, -0.5], [-aux_column_width, 0.5, -0.5], - [-0.5, aux_column_width, -seperator_distance], + [-0.5, aux_column_width, -separator_distance], [-hd_center, aux_column_width, -hd_center], [-aux_z_min, aux_z_min, -hd_center], - [-0.5, seperator_distance, -seperator_distance], + [-0.5, separator_distance, -separator_distance], [-hd_center, hd_center, -hd_center], [-aux_column_width, hd_center, -hd_center], - [-0.5, 0.5, -seperator_distance], - [-seperator_distance, 0.5, -seperator_distance], - [-aux_column_width, 0.5, -seperator_distance], + [-0.5, 0.5, -separator_distance], + [-separator_distance, 0.5, -separator_distance], + [-aux_column_width, 0.5, -separator_distance], [-0.5, x_min_r, -x_min_r], [-hd_center, aux_x_min, -aux_x_min], [-center_r, center_r, -center_r], - [-0.5, seperator_distance, -aux_column_width], + [-0.5, separator_distance, -aux_column_width], [-hd_center, hd_center, -aux_column_width], [-aux_y_max, hd_center, -aux_y_max], [-0.5, 0.5, -aux_column_width], - [-seperator_distance, 0.5, -aux_column_width], + [-separator_distance, 0.5, -aux_column_width], [-y_max_r, 0.5, -y_max_r], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1436,31 +1438,31 @@ def create_tile( x_max_y_max_z_min = _np.array( [ [z_min_r, z_min_r, -0.5], - [seperator_distance, aux_column_width, -0.5], + [separator_distance, aux_column_width, -0.5], [0.5, aux_column_width, -0.5], - [aux_column_width, seperator_distance, -0.5], - [seperator_distance, seperator_distance, -0.5], - [0.5, seperator_distance, -0.5], + [aux_column_width, separator_distance, -0.5], + [separator_distance, separator_distance, -0.5], + [0.5, separator_distance, -0.5], [aux_column_width, 0.5, -0.5], - [seperator_distance, 0.5, -0.5], + [separator_distance, 0.5, -0.5], [0.5, 0.5, -0.5], [aux_z_min, aux_z_min, -hd_center], [hd_center, aux_column_width, -hd_center], - [0.5, aux_column_width, -seperator_distance], + [0.5, aux_column_width, -separator_distance], [aux_column_width, hd_center, -hd_center], [hd_center, hd_center, -hd_center], - [0.5, seperator_distance, -seperator_distance], - [aux_column_width, 0.5, -seperator_distance], - [seperator_distance, 0.5, -seperator_distance], - [0.5, 0.5, -seperator_distance], + [0.5, separator_distance, -separator_distance], + [aux_column_width, 0.5, -separator_distance], + [separator_distance, 0.5, -separator_distance], + [0.5, 0.5, -separator_distance], [center_r, center_r, -center_r], [hd_center, aux_x_max, -aux_x_max], [0.5, x_max_r, -x_max_r], [aux_y_max, hd_center, -aux_y_max], [hd_center, hd_center, -aux_column_width], - [0.5, seperator_distance, -aux_column_width], + [0.5, separator_distance, -aux_column_width], [y_max_r, 0.5, -y_max_r], - [seperator_distance, 0.5, -aux_column_width], + [separator_distance, 0.5, -aux_column_width], [0.5, 0.5, -aux_column_width], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1472,31 +1474,31 @@ def create_tile( x_min_y_min_z_max = _np.array( [ [-0.5, -0.5, aux_column_width], - [-seperator_distance, -0.5, aux_column_width], + [-separator_distance, -0.5, aux_column_width], [-y_min_r, -0.5, y_min_r], - [-0.5, -seperator_distance, aux_column_width], + [-0.5, -separator_distance, aux_column_width], [-hd_center, -hd_center, aux_column_width], [-aux_y_min, -hd_center, aux_y_min], [-0.5, -x_min_r, x_min_r], [-hd_center, -aux_x_min, aux_x_min], [-center_r, -center_r, center_r], - [-0.5, -0.5, seperator_distance], - [-seperator_distance, -0.5, seperator_distance], - [-aux_column_width, -0.5, seperator_distance], - [-0.5, -seperator_distance, seperator_distance], + [-0.5, -0.5, separator_distance], + [-separator_distance, -0.5, separator_distance], + [-aux_column_width, -0.5, separator_distance], + [-0.5, -separator_distance, separator_distance], [-hd_center, -hd_center, hd_center], [-aux_column_width, -hd_center, hd_center], - [-0.5, -aux_column_width, seperator_distance], + [-0.5, -aux_column_width, separator_distance], [-hd_center, -aux_column_width, hd_center], [-aux_z_max, -aux_z_max, hd_center], [-0.5, -0.5, 0.5], - [-seperator_distance, -0.5, 0.5], + [-separator_distance, -0.5, 0.5], [-aux_column_width, -0.5, 0.5], - [-0.5, -seperator_distance, 0.5], - [-seperator_distance, -seperator_distance, 0.5], - [-aux_column_width, -seperator_distance, 0.5], + [-0.5, -separator_distance, 0.5], + [-separator_distance, -separator_distance, 0.5], + [-aux_column_width, -separator_distance, 0.5], [-0.5, -aux_column_width, 0.5], - [-seperator_distance, -aux_column_width, 0.5], + [-separator_distance, -aux_column_width, 0.5], [-z_max_r, -z_max_r, 0.5], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1508,31 +1510,31 @@ def create_tile( x_max_y_min_z_max = _np.array( [ [y_min_r, -0.5, y_min_r], - [seperator_distance, -0.5, aux_column_width], + [separator_distance, -0.5, aux_column_width], [0.5, -0.5, aux_column_width], [aux_y_min, -hd_center, aux_y_min], [hd_center, -hd_center, aux_column_width], - [0.5, -seperator_distance, aux_column_width], + [0.5, -separator_distance, aux_column_width], [center_r, -center_r, center_r], [hd_center, -aux_x_max, aux_x_max], [0.5, -x_max_r, x_max_r], - [aux_column_width, -0.5, seperator_distance], - [seperator_distance, -0.5, seperator_distance], - [0.5, -0.5, seperator_distance], + [aux_column_width, -0.5, separator_distance], + [separator_distance, -0.5, separator_distance], + [0.5, -0.5, separator_distance], [aux_column_width, -hd_center, hd_center], [hd_center, -hd_center, hd_center], - [0.5, -seperator_distance, seperator_distance], + [0.5, -separator_distance, separator_distance], [aux_z_max, -aux_z_max, hd_center], [hd_center, -aux_column_width, hd_center], - [0.5, -aux_column_width, seperator_distance], + [0.5, -aux_column_width, separator_distance], [aux_column_width, -0.5, 0.5], - [seperator_distance, -0.5, 0.5], + [separator_distance, -0.5, 0.5], [0.5, -0.5, 0.5], - [aux_column_width, -seperator_distance, 0.5], - [seperator_distance, -seperator_distance, 0.5], - [0.5, -seperator_distance, 0.5], + [aux_column_width, -separator_distance, 0.5], + [separator_distance, -separator_distance, 0.5], + [0.5, -separator_distance, 0.5], [z_max_r, -z_max_r, 0.5], - [seperator_distance, -aux_column_width, 0.5], + [separator_distance, -aux_column_width, 0.5], [0.5, -aux_column_width, 0.5], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1546,29 +1548,29 @@ def create_tile( [-0.5, x_min_r, x_min_r], [-hd_center, aux_x_min, aux_x_min], [-center_r, center_r, center_r], - [-0.5, seperator_distance, aux_column_width], + [-0.5, separator_distance, aux_column_width], [-hd_center, hd_center, aux_column_width], [-aux_y_max, hd_center, aux_y_max], [-0.5, 0.5, aux_column_width], - [-seperator_distance, 0.5, aux_column_width], + [-separator_distance, 0.5, aux_column_width], [-y_max_r, 0.5, y_max_r], - [-0.5, aux_column_width, seperator_distance], + [-0.5, aux_column_width, separator_distance], [-hd_center, aux_column_width, hd_center], [-aux_z_max, aux_z_max, hd_center], - [-0.5, seperator_distance, seperator_distance], + [-0.5, separator_distance, separator_distance], [-hd_center, hd_center, hd_center], [-aux_column_width, hd_center, hd_center], - [-0.5, 0.5, seperator_distance], - [-seperator_distance, 0.5, seperator_distance], - [-aux_column_width, 0.5, seperator_distance], + [-0.5, 0.5, separator_distance], + [-separator_distance, 0.5, separator_distance], + [-aux_column_width, 0.5, separator_distance], [-0.5, aux_column_width, 0.5], - [-seperator_distance, aux_column_width, 0.5], + [-separator_distance, aux_column_width, 0.5], [-z_max_r, z_max_r, 0.5], - [-0.5, seperator_distance, 0.5], - [-seperator_distance, seperator_distance, 0.5], - [-aux_column_width, seperator_distance, 0.5], + [-0.5, separator_distance, 0.5], + [-separator_distance, separator_distance, 0.5], + [-aux_column_width, separator_distance, 0.5], [-0.5, 0.5, 0.5], - [-seperator_distance, 0.5, 0.5], + [-separator_distance, 0.5, 0.5], [-aux_column_width, 0.5, 0.5], ] ) + _np.array([0.5, 0.5, 0.5]) @@ -1584,27 +1586,27 @@ def create_tile( [0.5, x_max_r, x_max_r], [aux_y_max, hd_center, aux_y_max], [hd_center, hd_center, aux_column_width], - [0.5, seperator_distance, aux_column_width], + [0.5, separator_distance, aux_column_width], [y_max_r, 0.5, y_max_r], - [seperator_distance, 0.5, aux_column_width], + [separator_distance, 0.5, aux_column_width], [0.5, 0.5, aux_column_width], [aux_z_max, aux_z_max, hd_center], [hd_center, aux_column_width, hd_center], - [0.5, aux_column_width, seperator_distance], + [0.5, aux_column_width, separator_distance], [aux_column_width, hd_center, hd_center], [hd_center, hd_center, hd_center], - [0.5, seperator_distance, seperator_distance], - [aux_column_width, 0.5, seperator_distance], - [seperator_distance, 0.5, seperator_distance], - [0.5, 0.5, seperator_distance], + [0.5, separator_distance, separator_distance], + [aux_column_width, 0.5, separator_distance], + [separator_distance, 0.5, separator_distance], + [0.5, 0.5, separator_distance], [z_max_r, z_max_r, 0.5], - [seperator_distance, aux_column_width, 0.5], + [separator_distance, aux_column_width, 0.5], [0.5, aux_column_width, 0.5], - [aux_column_width, seperator_distance, 0.5], - [seperator_distance, seperator_distance, 0.5], - [0.5, seperator_distance, 0.5], + [aux_column_width, separator_distance, 0.5], + [separator_distance, separator_distance, 0.5], + [0.5, separator_distance, 0.5], [aux_column_width, 0.5, 0.5], - [seperator_distance, 0.5, 0.5], + [separator_distance, 0.5, 0.5], [0.5, 0.5, 0.5], ] ) + _np.array([0.5, 0.5, 0.5]) diff --git a/splinepy/microstructure/tiles/snappy.py b/splinepy/microstructure/tiles/snappy.py index dac00bd20..7df89d6e8 100644 --- a/splinepy/microstructure/tiles/snappy.py +++ b/splinepy/microstructure/tiles/snappy.py @@ -20,6 +20,8 @@ class Snappy(_TileBase): # dummy values - not used _evaluation_points = _np.array([[0.5, 0.5]]) _n_info_per_eval_point = 1 + _sensitivities_implemented = False + _closure_directions = ["y_min", "y_max"] def _closing_tile( self, @@ -362,7 +364,7 @@ def create_tile( if parameters is not None: raise NotImplementedError( - "Parametriazation is not implemented for this tile yet" + "Parametrization is not implemented for this tile yet" ) if parameter_sensitivities is not None: diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py new file mode 100644 index 000000000..cfb59555e --- /dev/null +++ b/tests/test_microstructure.py @@ -0,0 +1,75 @@ +from inspect import getfullargspec + +import numpy as np + +import splinepy.microstructure as ms + +EPS = 1e-8 + +all_tile_classes = list(ms.tiles.everything().values()) + + +def test_tile_class(): + """Checks if all tile classes have the appropriate members and functions.""" + required_class_variables = { + "_para_dim": int, + "_dim": int, + "_evaluation_points": np.ndarray, + "_n_info_per_eval_point": int, + # "_sensitivities_implemented": bool + } + + # Go through all available tiles + for tile_class in all_tile_classes: + # Get tile class' objects + members = [ + attr for attr in dir(tile_class) if not attr.startswith("__") + ] + + # Class must have function create_tile() + assert hasattr( + tile_class, "create_tile" + ), "Tile class must have create_tile()" + # Tile must be able to take parameters and sensitivities as input + create_parameters = getfullargspec(tile_class.create_tile).args + for required_param in ["parameters", "parameter_sensitivities"]: + assert ( + required_param in create_parameters + ), f"create_tile() must have '{required_param}' as an input parameter" + + # Ensure closure can be correctly handled + if "closure" in create_parameters: + assert "_closure_directions" in members, ( + "Tile class has closure ability. The available closure directions " + + "are missing" + ) + assert hasattr( + tile_class, "_closing_tile" + ), "Tile class has closure ability but no _closing_tile() function!" + + # Check if tile class has all required variables and they are the correct type + for required_variable, var_type in required_class_variables.items(): + assert ( + required_variable in members + ), f"Tile class needs to have member variable '{required_variable}'" + assert isinstance( + eval(f"tile_class.{required_variable}"), var_type + ), f"Variable {required_variable} needs to be of type {var_type}" + + +def test_tile_bounds(): + """Test if tile is still in unit cube at the bounds""" + # TODO + pass + + +def test_tile_derivatives(): + """Testing the correctness of the tile derivatives""" + # TODO + pass + + +def test_tile_closure(): + """Check if closing tiles also lie in unit cube. Maybe also check derivatives.""" + # TODO + pass From 0aa09c871699dd8d1afc475990faf279b2cbb571 Mon Sep 17 00:00:00 2001 From: markriegler Date: Fri, 9 Aug 2024 16:26:21 +0200 Subject: [PATCH 02/23] Remove hollow cube's rotation parameter check since there is no rotation --- splinepy/microstructure/tiles/hollow_cube.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/splinepy/microstructure/tiles/hollow_cube.py b/splinepy/microstructure/tiles/hollow_cube.py index 028ca0ed4..d94b5e8cc 100644 --- a/splinepy/microstructure/tiles/hollow_cube.py +++ b/splinepy/microstructure/tiles/hollow_cube.py @@ -66,18 +66,9 @@ def create_tile( self.check_params(parameters) - if not ( - _np.all(parameters[:, :2] > 0.0) - and _np.all(parameters[:, :2] < 0.5) - ): + if not _np.all((parameters > 0.0) & (parameters < 0.5)): raise ValueError("The wall thickness must be in (0.0 and 0.5)") - if not _np.all( - (parameters[:, 2:] > _np.deg2rad(-30)) - and (parameters[:, 2:] < _np.deg2rad(30)) - ): - raise ValueError("Rotation is only allowed between +-30 deg") - if self.check_param_derivatives(parameter_sensitivities): n_derivatives = parameter_sensitivities.shape[2] derivatives = [] From 2551b677b4342eaf29a4ea0fe401a6c2a4a9b8f8 Mon Sep 17 00:00:00 2001 From: markriegler Date: Fri, 9 Aug 2024 16:29:50 +0200 Subject: [PATCH 03/23] WIP add test if all microtiles lie in unit cube (only for default parameters) --- tests/test_microstructure.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index cfb59555e..6e3cd8330 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -16,7 +16,7 @@ def test_tile_class(): "_dim": int, "_evaluation_points": np.ndarray, "_n_info_per_eval_point": int, - # "_sensitivities_implemented": bool + "_sensitivities_implemented": bool, } # Go through all available tiles @@ -58,13 +58,28 @@ def test_tile_class(): def test_tile_bounds(): - """Test if tile is still in unit cube at the bounds""" - # TODO - pass + """Test if tile is still in unit cube at the bounds. Currently only checks + default parameter values.""" + # TODO: also check non-default parameters + + def check_control_points(tile_patches): + """Check if all of tile's control points all lie within unit square/cube""" + # Go through all patches + for tile_patch in tile_patches: + cps = tile_patch.control_points + assert np.all( + (cps >= 0.0) & (cps <= 1.0) + ), "Control points of tile must lie inside the unit square/cube" + + for tile_class in all_tile_classes: + tile_creator = tile_class() + # Create tile with default parameters + tile_patches, _ = tile_creator.create_tile() + check_control_points(tile_patches) def test_tile_derivatives(): - """Testing the correctness of the tile derivatives""" + """Testing the correctness of the tile derivatives using Finite Differences""" # TODO pass From a5373d85c898f81f09870fe906961c1b3d1d1e6e Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 12 Aug 2024 13:31:55 +0200 Subject: [PATCH 04/23] Add test for microstructure closures --- splinepy/microstructure/tiles/armadillo.py | 1 + splinepy/microstructure/tiles/chi.py | 2 +- splinepy/microstructure/tiles/cross_2d.py | 15 ++++------ splinepy/microstructure/tiles/cross_3d.py | 3 ++ .../microstructure/tiles/cross_3d_linear.py | 3 ++ splinepy/microstructure/tiles/snappy.py | 8 ++++-- tests/test_microstructure.py | 28 +++++++++++++++++-- 7 files changed, 43 insertions(+), 17 deletions(-) diff --git a/splinepy/microstructure/tiles/armadillo.py b/splinepy/microstructure/tiles/armadillo.py index 9bbf602da..acf8828be 100644 --- a/splinepy/microstructure/tiles/armadillo.py +++ b/splinepy/microstructure/tiles/armadillo.py @@ -29,6 +29,7 @@ class Armadillo(_TileBase): "z_min", "z_max", ] + _parameter_bounds = [[0.0, 0.5]] def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/chi.py b/splinepy/microstructure/tiles/chi.py index e3cbf708b..707484c38 100644 --- a/splinepy/microstructure/tiles/chi.py +++ b/splinepy/microstructure/tiles/chi.py @@ -20,7 +20,7 @@ class Chi(_TileBase): _n_info_per_eval_point = 1 _sensitivities_implemented = True - _parameter_bounds = {"parameters": [-_np.pi / 2, _np.pi / 2]} + _parameter_bounds = [[-_np.pi / 2, _np.pi / 2]] def create_tile( self, diff --git a/splinepy/microstructure/tiles/cross_2d.py b/splinepy/microstructure/tiles/cross_2d.py index cf4a988d2..147da3cee 100644 --- a/splinepy/microstructure/tiles/cross_2d.py +++ b/splinepy/microstructure/tiles/cross_2d.py @@ -26,9 +26,11 @@ class Cross2D(_TileBase): ] ) _n_info_per_eval_point = 1 - _parameter_bounds = {"center_expansion": [0.5, 1.5]} _sensitivities_implemented = True _closure_directions = ["x_min", "x_max", "y_min", "y_max"] + _parameter_bounds = [ + [0.0, 0.5] + ] * 4 # valid for default center_expansion=1.0 def _closing_tile( self, @@ -420,15 +422,8 @@ def create_tile( if not isinstance(center_expansion, float): raise ValueError("Invalid Type") - center_expansion_bounds = self._parameter_bounds["center_expansion"] - if not ( - (center_expansion > center_expansion_bounds[0]) - and (center_expansion < center_expansion_bounds[1]) - ): - error_message = ( - "Center Expansion must be in (" - + f"{center_expansion_bounds[0]}, {center_expansion_bounds[1]})" - ) + if not ((center_expansion > 0.5) and (center_expansion < 1.5)): + error_message = "Center Expansion must be in (0.5, 1.5)" raise ValueError(error_message) max_radius = min(0.5, (0.5 / center_expansion)) diff --git a/splinepy/microstructure/tiles/cross_3d.py b/splinepy/microstructure/tiles/cross_3d.py index 01282c6f3..435ac3811 100644 --- a/splinepy/microstructure/tiles/cross_3d.py +++ b/splinepy/microstructure/tiles/cross_3d.py @@ -30,6 +30,9 @@ class Cross3D(_TileBase): _n_info_per_eval_point = 1 _sensitivities_implemented = True _closure_directions = ["z_min", "z_max"] + _parameter_bounds = [ + [0.0, 0.5] + ] * 6 # valid for default center_expansion=1.0 def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/cross_3d_linear.py b/splinepy/microstructure/tiles/cross_3d_linear.py index 952738afe..535592aa4 100644 --- a/splinepy/microstructure/tiles/cross_3d_linear.py +++ b/splinepy/microstructure/tiles/cross_3d_linear.py @@ -30,6 +30,9 @@ class Cross3DLinear(_TileBase): _n_info_per_eval_point = 1 _sensitivities_implemented = True _closure_directions = ["z_min", "z_max"] + _parameter_bounds = [ + [0.0, 0.5] + ] * 6 # valid for default center_expansion=1.0 def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/snappy.py b/splinepy/microstructure/tiles/snappy.py index 7df89d6e8..60cab586f 100644 --- a/splinepy/microstructure/tiles/snappy.py +++ b/splinepy/microstructure/tiles/snappy.py @@ -63,7 +63,9 @@ def _closing_tile( if closure is None: raise ValueError("No closing direction given") - self.check_params(parameters) + # TODO: parameters are not implemented, therefore do not check params + if parameters is not None: + self.check_params(parameters) if parameter_sensitivities is not None: raise NotImplementedError( @@ -222,7 +224,6 @@ def _closing_tile( spline_list.append( _Bezier(degrees=[3, 1], control_points=spline_10) ) - return spline_list elif closure == "y_max": spline_1 = _np.array( [ @@ -288,12 +289,13 @@ def _closing_tile( spline_list.append( _Bezier(degrees=[3, 1], control_points=spline_5) ) - return (spline_list, None) else: raise ValueError( "Closing tile is only implemented for y-enclosure" ) + return (spline_list, None) + def create_tile( self, parameters=None, diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 6e3cd8330..b287b5b09 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -81,10 +81,32 @@ def check_control_points(tile_patches): def test_tile_derivatives(): """Testing the correctness of the tile derivatives using Finite Differences""" # TODO - pass + for tile_class in all_tile_classes: + tile_creator = tile_class() + # Skip test if tile class has no implemented sensitivities + if not tile_creator._sensitivities_implemented: + continue + pass def test_tile_closure(): """Check if closing tiles also lie in unit cube. Maybe also check derivatives.""" - # TODO - pass + # TODO: check closure also for extreme values of parameters + for tile_class in all_tile_classes: + # Skip tile if if does not support closure + if "_closure_directions" not in dir(tile_class): + continue + tile_creator = tile_class() + # Go through all implemented closure directions + for closure_direction in tile_creator._closure_directions: + tile_patches, sensitivities = tile_creator.create_tile( + closure=closure_direction + ) + assert ( + sensitivities is None + ), "Ensure sensitivities for closure are None if no sensitivities are asked" + for tile_patch in tile_patches: + cps = tile_patch.control_points + assert np.all( + (cps >= 0.0) & (cps <= 1.0) + ), "Control points of tile must lie inside the unit square/cube" From 7859a87ec9a2cd09db97ef44c3549a5a7eea4b1c Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 12 Aug 2024 15:54:45 +0200 Subject: [PATCH 05/23] Add test for non-default parameters of microtiles --- splinepy/microstructure/tiles/armadillo.py | 1 + splinepy/microstructure/tiles/chi.py | 4 +- splinepy/microstructure/tiles/cross_2d.py | 1 + splinepy/microstructure/tiles/cross_3d.py | 1 + .../microstructure/tiles/cross_3d_linear.py | 1 + splinepy/microstructure/tiles/cube_void.py | 13 +++- .../microstructure/tiles/double_lattice.py | 2 + splinepy/microstructure/tiles/ellips_v_oid.py | 10 +++ splinepy/microstructure/tiles/hollow_cube.py | 2 + .../microstructure/tiles/hollow_octagon.py | 2 + .../tiles/hollow_octagon_extrude.py | 6 +- .../microstructure/tiles/inverse_cross_3d.py | 4 +- splinepy/microstructure/tiles/snappy.py | 2 + tests/test_microstructure.py | 76 +++++++++++++++---- 14 files changed, 104 insertions(+), 21 deletions(-) diff --git a/splinepy/microstructure/tiles/armadillo.py b/splinepy/microstructure/tiles/armadillo.py index acf8828be..7137f6565 100644 --- a/splinepy/microstructure/tiles/armadillo.py +++ b/splinepy/microstructure/tiles/armadillo.py @@ -30,6 +30,7 @@ class Armadillo(_TileBase): "z_max", ] _parameter_bounds = [[0.0, 0.5]] + _parameters_shape = (1, 1) def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/chi.py b/splinepy/microstructure/tiles/chi.py index 707484c38..dcc2c971f 100644 --- a/splinepy/microstructure/tiles/chi.py +++ b/splinepy/microstructure/tiles/chi.py @@ -19,8 +19,8 @@ class Chi(_TileBase): _evaluation_points = _np.array([[0.5, 0.5]]) _n_info_per_eval_point = 1 _sensitivities_implemented = True - _parameter_bounds = [[-_np.pi / 2, _np.pi / 2]] + _parameters_shape = (1, 1) def create_tile( self, @@ -51,7 +51,7 @@ def create_tile( ) parameters = _np.array([[_np.pi / 8]]) else: - angle_bounds = self._parameter_bounds["parameters"] + angle_bounds = self._parameter_bounds[0] if not ( _np.all(parameters >= angle_bounds[0]) and _np.all(parameters < angle_bounds[1]) diff --git a/splinepy/microstructure/tiles/cross_2d.py b/splinepy/microstructure/tiles/cross_2d.py index 147da3cee..2fe51c2be 100644 --- a/splinepy/microstructure/tiles/cross_2d.py +++ b/splinepy/microstructure/tiles/cross_2d.py @@ -31,6 +31,7 @@ class Cross2D(_TileBase): _parameter_bounds = [ [0.0, 0.5] ] * 4 # valid for default center_expansion=1.0 + _parameters_shape = (4, 1) def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/cross_3d.py b/splinepy/microstructure/tiles/cross_3d.py index 435ac3811..fba595111 100644 --- a/splinepy/microstructure/tiles/cross_3d.py +++ b/splinepy/microstructure/tiles/cross_3d.py @@ -33,6 +33,7 @@ class Cross3D(_TileBase): _parameter_bounds = [ [0.0, 0.5] ] * 6 # valid for default center_expansion=1.0 + _parameters_shape = (6, 1) def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/cross_3d_linear.py b/splinepy/microstructure/tiles/cross_3d_linear.py index 535592aa4..22c0f7959 100644 --- a/splinepy/microstructure/tiles/cross_3d_linear.py +++ b/splinepy/microstructure/tiles/cross_3d_linear.py @@ -33,6 +33,7 @@ class Cross3DLinear(_TileBase): _parameter_bounds = [ [0.0, 0.5] ] * 6 # valid for default center_expansion=1.0 + _parameters_shape = (6, 1) def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/cube_void.py b/splinepy/microstructure/tiles/cube_void.py index a8da85df6..6fd8e04c6 100644 --- a/splinepy/microstructure/tiles/cube_void.py +++ b/splinepy/microstructure/tiles/cube_void.py @@ -26,6 +26,15 @@ class CubeVoid(_TileBase): _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 4 _sensitivities_implemented = True + # TODO: clever parameter bounds and checks if given parametrization would + # still lie in unit cube + _parameter_bounds = [ + [0.0, 1.0], + [0.0, 1.0], + [-_np.pi / 2, _np.pi / 2], + [-_np.pi / 2, _np.pi / 2], + ] + _parameters_shape = (1, 1, 4) # Aux values _sphere_ctps = _np.array( @@ -92,7 +101,9 @@ def create_tile( derivatives : list> / None """ # set to default if nothing is given if parameters is None: - parameters = _np.array([0.5, 0.5, 0, 0]).reshape(1, 1, 4) + parameters = _np.array([0.5, 0.5, 0, 0]).reshape( + self._parameters_shape + ) # Create center ellipsoid # RotY * RotX * DIAG(r_x, r_yz) * T_base diff --git a/splinepy/microstructure/tiles/double_lattice.py b/splinepy/microstructure/tiles/double_lattice.py index ffb2166b2..e040078f9 100644 --- a/splinepy/microstructure/tiles/double_lattice.py +++ b/splinepy/microstructure/tiles/double_lattice.py @@ -21,6 +21,8 @@ class DoubleLattice(_TileBase): _evaluation_points = _np.array([[0.5, 0.5]]) _n_info_per_eval_point = 2 _sensitivities_implemented = True + _parameter_bounds = [[0.0, 1 / (2 * (1 + _np.sqrt(2)))]] * 2 + _parameters_shape = (1, 2) def create_tile( self, diff --git a/splinepy/microstructure/tiles/ellips_v_oid.py b/splinepy/microstructure/tiles/ellips_v_oid.py index ec7a5cfe9..4f5c830c6 100644 --- a/splinepy/microstructure/tiles/ellips_v_oid.py +++ b/splinepy/microstructure/tiles/ellips_v_oid.py @@ -28,6 +28,16 @@ class EllipsVoid(_TileBase): _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 4 _sensitivities_implemented = True + # TODO: clever parameter bounds and checks if given parametrization would + # still lie in unit cube + # Due to ellipsoid, control points very easily lie outside unit cube + _parameter_bounds = [ + [0.0, 1.0], + [0.0, 1.0], + [-_np.pi / 2, _np.pi / 2], + [-_np.pi / 2, _np.pi / 2], + ] + _parameters_shape = (1, 1, 4) # Aux values _c0 = 0.5 / 3**0.5 diff --git a/splinepy/microstructure/tiles/hollow_cube.py b/splinepy/microstructure/tiles/hollow_cube.py index d94b5e8cc..a93e3b457 100644 --- a/splinepy/microstructure/tiles/hollow_cube.py +++ b/splinepy/microstructure/tiles/hollow_cube.py @@ -29,6 +29,8 @@ class HollowCube(_TileBase): ) _n_info_per_eval_point = 1 _sensitivities_implemented = True + _parameter_bounds = [[0.0, 0.5]] * 7 + _parameters_shape = (7, 1) def create_tile( self, diff --git a/splinepy/microstructure/tiles/hollow_octagon.py b/splinepy/microstructure/tiles/hollow_octagon.py index 44b31a65a..1b9489fcc 100644 --- a/splinepy/microstructure/tiles/hollow_octagon.py +++ b/splinepy/microstructure/tiles/hollow_octagon.py @@ -20,6 +20,8 @@ class HollowOctagon(_TileBase): _n_info_per_eval_point = 1 _sensitivities_implemented = False _closure_directions = ["x_min", "x_max", "y_min", "y_max"] + _parameter_bounds = [[0.0, 0.5]] + _parameters_shape = (1, 1) def _closing_tile( self, diff --git a/splinepy/microstructure/tiles/hollow_octagon_extrude.py b/splinepy/microstructure/tiles/hollow_octagon_extrude.py index dbf5f1901..1c935be0f 100644 --- a/splinepy/microstructure/tiles/hollow_octagon_extrude.py +++ b/splinepy/microstructure/tiles/hollow_octagon_extrude.py @@ -20,6 +20,8 @@ class HollowOctagonExtrude(_TileBase): _n_info_per_eval_point = 1 _sensitivities_implemented = False _closure_directions = ["x_min", "x_max", "y_min", "y_max"] + _parameter_bounds = [[0.0, 0.5]] + _parameters_shape = (1, 1) def create_tile( self, @@ -75,9 +77,9 @@ def create_tile( self.check_params(parameters) v_h_void = parameters[0, 0] - if not ((v_h_void > 0.01) and (v_h_void < 0.5)): + if not ((v_h_void > 0.0) and (v_h_void < 0.5)): raise ValueError( - "The thickness of the wall must be in (0.01 and 0.49)" + "The thickness of the wall must be in (0.0 and 0.5)" ) v_zero = 0.0 diff --git a/splinepy/microstructure/tiles/inverse_cross_3d.py b/splinepy/microstructure/tiles/inverse_cross_3d.py index a633632fc..6e4f0e010 100644 --- a/splinepy/microstructure/tiles/inverse_cross_3d.py +++ b/splinepy/microstructure/tiles/inverse_cross_3d.py @@ -34,6 +34,8 @@ class InverseCross3D(_TileBase): _n_info_per_eval_point = 1 _sensitivities_implemented = False _closure_directions = ["z_min", "z_max"] + _parameter_bounds = [[0.2, 0.3]] * 6 # For default values + _parameters_shape = (6, 1) def _closing_tile( self, @@ -909,7 +911,7 @@ def create_tile( branches separator_distance : float Control point distance to separation layer of biquadratic degrees, - determines the minimum branch thickness (defaults to 0.4) + determines the minimum branch thickness (defaults to 0.3) center_expansion : float thickness of center is expanded by a factor (default to 1.0), which determines the maximum branch thickness diff --git a/splinepy/microstructure/tiles/snappy.py b/splinepy/microstructure/tiles/snappy.py index 60cab586f..84eba670d 100644 --- a/splinepy/microstructure/tiles/snappy.py +++ b/splinepy/microstructure/tiles/snappy.py @@ -22,6 +22,8 @@ class Snappy(_TileBase): _n_info_per_eval_point = 1 _sensitivities_implemented = False _closure_directions = ["y_min", "y_max"] + _parameter_bounds = [] + _parameters_shape = () def _closing_tile( self, diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index b287b5b09..8d7846ded 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -3,12 +3,43 @@ import numpy as np import splinepy.microstructure as ms +from splinepy.utils.data import cartesian_product as _cartesian_product EPS = 1e-8 all_tile_classes = list(ms.tiles.everything().values()) +def check_control_points(tile_patches): + """Check if all of tile's control points all lie within unit square/cube""" + # Go through all patches + for tile_patch in tile_patches: + cps = tile_patch.control_points + assert np.all( + (cps >= 0.0 - EPS) & (cps <= 1.0 + EPS) + ), "Control points of tile must lie inside the unit square/cube" + + +def make_bounds_feasible(bounds): + """Bounds are given are understood as open set of min. and max. values. Therefore, + convert bounds to open set of these values. + + Parameters + ------------ + bounds: list> + Values of bounds + + Returns + ---------- + feasible_bounds: np.ndarray + Values of bounds + """ + feasible_bounds = [ + [min_value + EPS, max_value - EPS] for min_value, max_value in bounds + ] + return np.array(feasible_bounds) + + def test_tile_class(): """Checks if all tile classes have the appropriate members and functions.""" required_class_variables = { @@ -60,23 +91,41 @@ def test_tile_class(): def test_tile_bounds(): """Test if tile is still in unit cube at the bounds. Currently only checks default parameter values.""" - # TODO: also check non-default parameters - - def check_control_points(tile_patches): - """Check if all of tile's control points all lie within unit square/cube""" - # Go through all patches - for tile_patch in tile_patches: - cps = tile_patch.control_points - assert np.all( - (cps >= 0.0) & (cps <= 1.0) - ), "Control points of tile must lie inside the unit square/cube" + # Skip certain tile classes for testing + skip_tiles = [ + ms.tiles.EllipsVoid, # Control points easily lie outside unitcube + ms.tiles.Snappy, # Has no parameters + ] for tile_class in all_tile_classes: + # Skip certain classes for testing + skip_tile_class = False + for skip_tile in skip_tiles: + if tile_class is skip_tile: + skip_tile_class = True + break + if skip_tile_class: + continue + tile_creator = tile_class() # Create tile with default parameters tile_patches, _ = tile_creator.create_tile() check_control_points(tile_patches) + # Go through all extremes of parameters and ensure that also they create + # tiles within unit square/cube + feasible_parameter_bounds = make_bounds_feasible( + tile_creator._parameter_bounds + ) + all_parameter_bounds = _cartesian_product(feasible_parameter_bounds) + for parameter_extremes in all_parameter_bounds: + tile_patches, _ = tile_creator.create_tile( + parameters=parameter_extremes.reshape( + tile_creator._parameters_shape + ) + ) + check_control_points(tile_patches) + def test_tile_derivatives(): """Testing the correctness of the tile derivatives using Finite Differences""" @@ -105,8 +154,5 @@ def test_tile_closure(): assert ( sensitivities is None ), "Ensure sensitivities for closure are None if no sensitivities are asked" - for tile_patch in tile_patches: - cps = tile_patch.control_points - assert np.all( - (cps >= 0.0) & (cps <= 1.0) - ), "Control points of tile must lie inside the unit square/cube" + + check_control_points(tile_patches) From 6a6d40270ff5ffcd17f4ca7102229981a6b4f8a4 Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 12 Aug 2024 16:10:04 +0200 Subject: [PATCH 06/23] Add test for non-default parameters plus closure of microtiles --- .../microstructure/tiles/hollow_octagon.py | 4 +-- tests/test_microstructure.py | 34 ++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/splinepy/microstructure/tiles/hollow_octagon.py b/splinepy/microstructure/tiles/hollow_octagon.py index 1b9489fcc..f3dbfd5e8 100644 --- a/splinepy/microstructure/tiles/hollow_octagon.py +++ b/splinepy/microstructure/tiles/hollow_octagon.py @@ -77,9 +77,9 @@ def _closing_tile( ) v_h_void = parameters[0, 0] - if not ((v_h_void > 0.01) and (v_h_void < 0.5)): + if not ((v_h_void > 0.0) and (v_h_void < 0.5)): raise ValueError( - "The thickness of the wall must be in (0.01 and 0.49)" + "The thickness of the wall must be in (0.0 and 0.5)" ) spline_list = [] diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 8d7846ded..7e83795d3 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -140,7 +140,12 @@ def test_tile_derivatives(): def test_tile_closure(): """Check if closing tiles also lie in unit cube. Maybe also check derivatives.""" - # TODO: check closure also for extreme values of parameters + # Skip certain tile classes for testing + skip_tiles = [ + ms.tiles.EllipsVoid, # Control points easily lie outside unitcube + ms.tiles.Snappy, # Has no parameters + ] + for tile_class in all_tile_classes: # Skip tile if if does not support closure if "_closure_directions" not in dir(tile_class): @@ -156,3 +161,30 @@ def test_tile_closure(): ), "Ensure sensitivities for closure are None if no sensitivities are asked" check_control_points(tile_patches) + + # Also check non-default parameters + # Skip certain classes for testing + skip_tile_class = False + for skip_tile in skip_tiles: + if tile_class is skip_tile: + skip_tile_class = True + break + if skip_tile_class: + continue + + # Go through all extremes of parameters and ensure that also they create + # tiles within unit square/cube + feasible_parameter_bounds = make_bounds_feasible( + tile_creator._parameter_bounds + ) + all_parameter_bounds = _cartesian_product(feasible_parameter_bounds) + # Go through all implemented closure directions + for closure_direction in tile_creator._closure_directions: + for parameter_extremes in all_parameter_bounds: + tile_patches, _ = tile_creator.create_tile( + parameters=parameter_extremes.reshape( + tile_creator._parameters_shape + ), + closure=closure_direction, + ) + check_control_points(tile_patches) From a3f9d12c6f64c74630e06d02251a5ab8b3a07d81 Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 12 Aug 2024 16:19:21 +0200 Subject: [PATCH 07/23] Restructure microstructure tests --- tests/test_microstructure.py | 57 +++++++++++++++++------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 7e83795d3..a37b43b4e 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -9,6 +9,12 @@ all_tile_classes = list(ms.tiles.everything().values()) +# Skip certain tile classes for parameters testing +skip_tiles = [ + ms.tiles.EllipsVoid, # Control points easily lie outside unitcube + ms.tiles.Snappy, # Has no "parameters" +] + def check_control_points(tile_patches): """Check if all of tile's control points all lie within unit square/cube""" @@ -48,6 +54,8 @@ def test_tile_class(): "_evaluation_points": np.ndarray, "_n_info_per_eval_point": int, "_sensitivities_implemented": bool, + "_parameter_bounds": list, + "_parameters_shape": tuple, } # Go through all available tiles @@ -89,15 +97,14 @@ def test_tile_class(): def test_tile_bounds(): - """Test if tile is still in unit cube at the bounds. Currently only checks - default parameter values.""" - # Skip certain tile classes for testing - skip_tiles = [ - ms.tiles.EllipsVoid, # Control points easily lie outside unitcube - ms.tiles.Snappy, # Has no parameters - ] - + """Test if tile is still in unit cube at the bounds. Checks default and also + non-default parameter values.""" for tile_class in all_tile_classes: + tile_creator = tile_class() + # Create tile with default parameters + tile_patches, _ = tile_creator.create_tile() + check_control_points(tile_patches) + # Skip certain classes for testing skip_tile_class = False for skip_tile in skip_tiles: @@ -107,11 +114,6 @@ def test_tile_bounds(): if skip_tile_class: continue - tile_creator = tile_class() - # Create tile with default parameters - tile_patches, _ = tile_creator.create_tile() - check_control_points(tile_patches) - # Go through all extremes of parameters and ensure that also they create # tiles within unit square/cube feasible_parameter_bounds = make_bounds_feasible( @@ -127,24 +129,8 @@ def test_tile_bounds(): check_control_points(tile_patches) -def test_tile_derivatives(): - """Testing the correctness of the tile derivatives using Finite Differences""" - # TODO - for tile_class in all_tile_classes: - tile_creator = tile_class() - # Skip test if tile class has no implemented sensitivities - if not tile_creator._sensitivities_implemented: - continue - pass - - def test_tile_closure(): - """Check if closing tiles also lie in unit cube. Maybe also check derivatives.""" - # Skip certain tile classes for testing - skip_tiles = [ - ms.tiles.EllipsVoid, # Control points easily lie outside unitcube - ms.tiles.Snappy, # Has no parameters - ] + """Check if closing tiles also lie in unit cube. TODO: also check derivatives.""" for tile_class in all_tile_classes: # Skip tile if if does not support closure @@ -188,3 +174,14 @@ def test_tile_closure(): closure=closure_direction, ) check_control_points(tile_patches) + + +def test_tile_derivatives(): + """Testing the correctness of the tile derivatives using Finite Differences""" + # TODO + for tile_class in all_tile_classes: + tile_creator = tile_class() + # Skip test if tile class has no implemented sensitivities + if not tile_creator._sensitivities_implemented: + continue + pass From 693acc01be0df16ea19899bfa841d8ec1e986e36 Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 26 Aug 2024 10:42:31 +0200 Subject: [PATCH 08/23] Add test for tile derivatives (WIP) --- splinepy/microstructure/tiles/chi.py | 2 +- splinepy/microstructure/tiles/cube_void.py | 2 +- splinepy/microstructure/tiles/ellips_v_oid.py | 2 +- tests/test_microstructure.py | 97 ++++++++++++++++++- 4 files changed, 96 insertions(+), 7 deletions(-) diff --git a/splinepy/microstructure/tiles/chi.py b/splinepy/microstructure/tiles/chi.py index dcc2c971f..827c7b8d3 100644 --- a/splinepy/microstructure/tiles/chi.py +++ b/splinepy/microstructure/tiles/chi.py @@ -16,7 +16,7 @@ class Chi(_TileBase): _dim = 2 _para_dim = 1 - _evaluation_points = _np.array([[0.5, 0.5]]) + _evaluation_points = _np.array([[0.5]]) _n_info_per_eval_point = 1 _sensitivities_implemented = True _parameter_bounds = [[-_np.pi / 2, _np.pi / 2]] diff --git a/splinepy/microstructure/tiles/cube_void.py b/splinepy/microstructure/tiles/cube_void.py index 6fd8e04c6..c435b6a88 100644 --- a/splinepy/microstructure/tiles/cube_void.py +++ b/splinepy/microstructure/tiles/cube_void.py @@ -34,7 +34,7 @@ class CubeVoid(_TileBase): [-_np.pi / 2, _np.pi / 2], [-_np.pi / 2, _np.pi / 2], ] - _parameters_shape = (1, 1, 4) + _parameters_shape = (1, 4) # Aux values _sphere_ctps = _np.array( diff --git a/splinepy/microstructure/tiles/ellips_v_oid.py b/splinepy/microstructure/tiles/ellips_v_oid.py index 4f5c830c6..84025d8bf 100644 --- a/splinepy/microstructure/tiles/ellips_v_oid.py +++ b/splinepy/microstructure/tiles/ellips_v_oid.py @@ -37,7 +37,7 @@ class EllipsVoid(_TileBase): [-_np.pi / 2, _np.pi / 2], [-_np.pi / 2, _np.pi / 2], ] - _parameters_shape = (1, 1, 4) + _parameters_shape = (1, 4) # Aux values _c0 = 0.5 / 3**0.5 diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index a37b43b4e..70bf4b2e5 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -176,12 +176,101 @@ def test_tile_closure(): check_control_points(tile_patches) -def test_tile_derivatives(): - """Testing the correctness of the tile derivatives using Finite Differences""" - # TODO +def test_tile_derivatives(np_rng, heps=1e-8): + """Testing the correctness of the tile derivatives using Finite Differences + + Parameters + --------- + heps: float + Perturbation size for finite difference evaluation + """ + # TODO: right now Chi, EllipsVoid and CubeVoid show wrong derivatives + skip_classes = [ms.tiles.Chi, ms.tiles.EllipsVoid, ms.tiles.CubeVoid] + for tile_class in all_tile_classes: + # TODO: right now skip classes with faultily implemented derivatives + if tile_class in skip_classes: + continue + tile_creator = tile_class() # Skip test if tile class has no implemented sensitivities if not tile_creator._sensitivities_implemented: continue - pass + # Choose parameter(s) as mean of extreme values + parameter_bounds = tile_creator._parameter_bounds + parameters = np.mean(np.array(parameter_bounds), axis=1).reshape( + tile_creator._parameters_shape + ) + # Create 3D identity matrix + n_eval_points = tile_creator._evaluation_points.shape[0] + n_info_per_eval_point = tile_creator._n_info_per_eval_point + parameter_sensitivities = np.zeros( + (n_eval_points, n_info_per_eval_point, 1) + ) + idx = np.arange(np.min(parameter_sensitivities.shape)) + parameter_sensitivities[idx, idx, :] = 1 + splines, derivatives = tile_creator.create_tile( + parameters=parameters, + parameter_sensitivities=parameter_sensitivities, + ) + # Evaluate splines and derivatives at random points + eval_points = np_rng.random((4, splines[0].para_dim)) + deriv_evaluations = [ + deriv.evaluate(eval_points) for deriv in derivatives[0] + ] + spline_orig_evaluations = [ + spl.evaluate(eval_points) for spl in splines + ] + + parameters_perturbed = parameters.copy() + parameters_perturbed += heps + splines_perturbed, _ = tile_creator.create_tile( + parameters=parameters_perturbed + ) + spline_perturbed_evaluations = [ + spl.evaluate(eval_points) for spl in splines_perturbed + ] + fd_sensitivities = [ + (spl_pert - spl_orig) / heps + for spl_pert, spl_orig in zip( + spline_perturbed_evaluations, spline_orig_evaluations + ) + ] + + # Go through all the parameters individually + for i_parameter in range(n_info_per_eval_point): + # Get derivatives w.r.t. one parameter + parameter_sensitivities = np.zeros( + (n_eval_points, n_info_per_eval_point, 1) + ) + parameter_sensitivities[:, i_parameter, :] = 1 + _, derivatives = tile_creator.create_tile( + parameters=parameters, + parameter_sensitivities=parameter_sensitivities, + ) + deriv_evaluations = [ + deriv.evaluate(eval_points) for deriv in derivatives[0] + ] + # Perform finite difference evaluation + parameters_perturbed = parameters.copy() + parameters_perturbed[:, i_parameter] += heps + splines_perturbed, _ = tile_creator.create_tile( + parameters=parameters_perturbed + ) + spline_perturbed_evaluations = [ + spl.evaluate(eval_points) for spl in splines_perturbed + ] + fd_sensitivities = [ + (spl_pert - spl_orig) / heps + for spl_pert, spl_orig in zip( + spline_perturbed_evaluations, spline_orig_evaluations + ) + ] + # Check every patch + for deriv_orig, deriv_fd in zip( + deriv_evaluations, fd_sensitivities + ): + assert np.allclose(deriv_orig, deriv_fd), ( + "Implemented derivative calculation does not match the derivative " + + "obtained using Finite Differences" + ) From c7c25741268ae10e17fea33a8d41b449da94036e Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 26 Aug 2024 14:28:44 +0200 Subject: [PATCH 09/23] Add derivative of HollowOctagon tile --- .../microstructure/tiles/hollow_octagon.py | 202 ++++++++++-------- tests/test_microstructure.py | 15 +- 2 files changed, 122 insertions(+), 95 deletions(-) diff --git a/splinepy/microstructure/tiles/hollow_octagon.py b/splinepy/microstructure/tiles/hollow_octagon.py index f3dbfd5e8..b05f6b74e 100644 --- a/splinepy/microstructure/tiles/hollow_octagon.py +++ b/splinepy/microstructure/tiles/hollow_octagon.py @@ -18,7 +18,7 @@ class HollowOctagon(_TileBase): _para_dim = 2 _evaluation_points = _np.array([[0.5, 0.5]]) _n_info_per_eval_point = 1 - _sensitivities_implemented = False + _sensitivities_implemented = True _closure_directions = ["x_min", "x_max", "y_min", "y_max"] _parameter_bounds = [[0.0, 0.5]] _parameters_shape = (1, 1) @@ -87,7 +87,7 @@ def _closing_tile( v_one_half = 0.5 v_one = 1.0 v_outer_c_h = contact_length * 0.5 - v_inner_c_h = contact_length * parameters[0, 0] + v_inner_c_h = contact_length * v_h_void if closure == "x_min": # set points: @@ -407,7 +407,7 @@ def _closing_tile( def create_tile( self, parameters=None, - parameter_sensitivities=None, # TODO + parameter_sensitivities=None, contact_length=0.2, closure=None, **kwargs, # noqa ARG002 @@ -456,13 +456,15 @@ def create_tile( ) if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None self.check_params(parameters) + self.check_param_derivatives(parameter_sensitivities) - v_h_void = parameters[0, 0] if not (_np.all(parameters > 0) and _np.all(parameters < 0.5)): raise ValueError( "The thickness of the wall must be in (0.01 and 0.49)" @@ -476,103 +478,125 @@ def create_tile( closure=closure, ) - v_zero = 0.0 - v_one_half = 0.5 - v_one = 1.0 - v_outer_c_h = contact_length * 0.5 - v_inner_c_h = contact_length * parameters[0, 0] + splines = [] + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + v_zero = 0.0 + v_one_half = 0.5 + v_one = 1.0 + v_h_void = parameters[0, 0] + v_outer_c_h = contact_length * 0.5 + v_inner_c_h = contact_length * v_h_void + else: + v_zero = 0.0 + v_one_half = 0.0 + v_one = 0.0 + v_h_void = parameter_sensitivities[0, 0, i_derivative - 1] + v_outer_c_h = 0.0 + v_inner_c_h = contact_length * v_h_void + + spline_list = [] - spline_list = [] + # set points: + right = _np.array( + [ + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + ] + ) - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - ] - ) + right_top = _np.array( + [ + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + ] + ) - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - ] - ) + top = _np.array( + [ + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + ] + ) - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - ] - ) + bottom_left = _np.array( + [ + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, -v_outer_c_h + v_one_half], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + ] + ) - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, -v_outer_c_h + v_one_half], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - ] - ) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + ] + ) - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + ] + ) - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + ] + ) - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + bottom_right = _np.array( + [ + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_zero], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - ] - ) + spline_list.append(_Bezier(degrees=[1, 1], control_points=right)) - spline_list.append(_Bezier(degrees=[1, 1], control_points=right)) + spline_list.append( + _Bezier(degrees=[1, 1], control_points=right_top) + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=right_top)) + spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom)) - spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom)) + spline_list.append( + _Bezier(degrees=[1, 1], control_points=bottom_left) + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_left)) + spline_list.append(_Bezier(degrees=[1, 1], control_points=left)) - spline_list.append(_Bezier(degrees=[1, 1], control_points=left)) + spline_list.append( + _Bezier(degrees=[1, 1], control_points=top_left) + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=top_left)) + spline_list.append(_Bezier(degrees=[1, 1], control_points=top)) - spline_list.append(_Bezier(degrees=[1, 1], control_points=top)) + spline_list.append( + _Bezier(degrees=[1, 1], control_points=bottom_right) + ) - spline_list.append( - _Bezier(degrees=[1, 1], control_points=bottom_right) - ) + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) - return (spline_list, None) + return (splines, derivatives) diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 70bf4b2e5..1a2b54371 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -196,11 +196,14 @@ def test_tile_derivatives(np_rng, heps=1e-8): # Skip test if tile class has no implemented sensitivities if not tile_creator._sensitivities_implemented: continue - # Choose parameter(s) as mean of extreme values - parameter_bounds = tile_creator._parameter_bounds - parameters = np.mean(np.array(parameter_bounds), axis=1).reshape( - tile_creator._parameters_shape - ) + + # Choose random parameter(s) within bounds + parameter_bounds = np.array(tile_creator._parameter_bounds) + parameters = parameter_bounds[:, 0] + np_rng.random( + len(parameter_bounds) + ) * np.ptp(parameter_bounds, axis=1) + parameters = parameters.reshape(tile_creator._parameters_shape) + # Create 3D identity matrix n_eval_points = tile_creator._evaluation_points.shape[0] n_info_per_eval_point = tile_creator._n_info_per_eval_point @@ -213,7 +216,7 @@ def test_tile_derivatives(np_rng, heps=1e-8): parameters=parameters, parameter_sensitivities=parameter_sensitivities, ) - # Evaluate splines and derivatives at random points + # Evaluate splines and derivatives at multiple random points eval_points = np_rng.random((4, splines[0].para_dim)) deriv_evaluations = [ deriv.evaluate(eval_points) for deriv in derivatives[0] From 82caf4fce33ea6af43f9dc6ffd341eb296c423da Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 26 Aug 2024 14:40:26 +0200 Subject: [PATCH 10/23] Add derivatives for closure of HollowOctagon tile --- .../microstructure/tiles/hollow_octagon.py | 631 +++++++++--------- 1 file changed, 318 insertions(+), 313 deletions(-) diff --git a/splinepy/microstructure/tiles/hollow_octagon.py b/splinepy/microstructure/tiles/hollow_octagon.py index b05f6b74e..22ace6555 100644 --- a/splinepy/microstructure/tiles/hollow_octagon.py +++ b/splinepy/microstructure/tiles/hollow_octagon.py @@ -26,7 +26,7 @@ class HollowOctagon(_TileBase): def _closing_tile( self, parameters=None, - parameter_sensitivities=None, # TODO + parameter_sensitivities=None, contact_length=0.2, closure=None, ): @@ -70,11 +70,14 @@ def _closing_tile( ) self.check_params(parameters) + self.check_param_derivatives(parameter_sensitivities) if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None v_h_void = parameters[0, 0] if not ((v_h_void > 0.0) and (v_h_void < 0.5)): @@ -82,327 +85,339 @@ def _closing_tile( "The thickness of the wall must be in (0.0 and 0.5)" ) - spline_list = [] - v_zero = 0.0 - v_one_half = 0.5 - v_one = 1.0 - v_outer_c_h = contact_length * 0.5 - v_inner_c_h = contact_length * v_h_void - - if closure == "x_min": - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - ] - ) - - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - ] - ) - - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - ] - ) - - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - ] - ) - - left = _np.array( - [ - [v_zero, v_zero], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_one], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + splines = [] + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + v_zero = 0.0 + v_one_half = 0.5 + v_one = 1.0 + v_outer_c_h = contact_length * 0.5 + v_inner_c_h = contact_length * v_h_void + else: + v_zero = 0.0 + v_one_half = 0.0 + v_one = 0.0 + v_h_void = parameter_sensitivities[0, 0, i_derivative - 1] + v_outer_c_h = 0.0 + v_inner_c_h = contact_length * v_h_void - top_left = _np.array( - [ - [v_zero, v_one], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + spline_list = [] - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + if closure == "x_min": + # set points: + right = _np.array( + [ + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - ] - ) + right_top = _np.array( + [ + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + ] + ) - elif closure == "x_max": - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, v_zero], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_one], - ] - ) + top = _np.array( + [ + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + ] + ) - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_one], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - ] - ) + bottom_left = _np.array( + [ + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, v_zero], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + ] + ) - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - ] - ) + left = _np.array( + [ + [v_zero, v_zero], + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, v_one], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + ] + ) - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, -v_outer_c_h + v_one_half], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - ] - ) + top_left = _np.array( + [ + [v_zero, v_one], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + ] + ) - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + ] + ) - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + bottom_right = _np.array( + [ + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_zero], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + ] + ) - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + elif closure == "x_max": + right = _np.array( + [ + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, v_zero], + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_one], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, v_zero], - ] - ) + right_top = _np.array( + [ + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_one], + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + ] + ) - elif closure == "y_min": - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - ] - ) + top = _np.array( + [ + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + ] + ) - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - ] - ) + bottom_left = _np.array( + [ + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, -v_outer_c_h + v_one_half], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + ] + ) - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - ] - ) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + ] + ) - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, -v_outer_c_h + v_one_half], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_zero, v_zero], - ] - ) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + ] + ) - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + ] + ) - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + bottom_right = _np.array( + [ + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_zero], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, v_zero], + ] + ) - bottom = _np.array( - [ - [v_one, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_zero, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + elif closure == "y_min": + # set points: + right = _np.array( + [ + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_one, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - ] - ) + right_top = _np.array( + [ + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + ] + ) - elif closure == "y_max": - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - ] - ) + top = _np.array( + [ + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + ] + ) - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_one, v_one], - ] - ) + bottom_left = _np.array( + [ + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, -v_outer_c_h + v_one_half], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [v_zero, v_zero], + ] + ) - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_one, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_zero, v_one], - ] - ) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + ] + ) - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, -v_outer_c_h + v_one_half], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - ] - ) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + [-v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + ] + ) - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + bottom = _np.array( + [ + [v_one, v_zero], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [v_zero, v_zero], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + ] + ) - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_zero, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + bottom_right = _np.array( + [ + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [v_one, v_zero], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + ] + ) - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + elif closure == "y_max": + # set points: + right = _np.array( + [ + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - ] - ) + right_top = _np.array( + [ + [v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_one, v_outer_c_h + v_one_half], + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_one, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=right)) + top = _np.array( + [ + [v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_one, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + [v_zero, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=right_top)) + bottom_left = _np.array( + [ + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, -v_outer_c_h + v_one_half], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom)) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_left)) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half], + [v_zero, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=left)) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [-v_outer_c_h + v_one_half, v_zero], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=top_left)) + bottom_right = _np.array( + [ + [v_inner_c_h + v_one_half, -v_h_void + v_one_half], + [v_outer_c_h + v_one_half, v_zero], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half], + [v_one, -v_outer_c_h + v_one_half], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=top)) + for control_points in [ + right, + right_top, + bottom, + bottom_left, + left, + top_left, + top, + bottom_right, + ]: + spline_list.append( + _Bezier(degrees=[1, 1], control_points=control_points) + ) - spline_list.append( - _Bezier(degrees=[1, 1], control_points=bottom_right) - ) + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) - return (spline_list, None) + return (splines, derivatives) def create_tile( self, @@ -473,7 +488,7 @@ def create_tile( if closure is not None: return self._closing_tile( parameters=parameters, - parameter_sensitivities=parameter_sensitivities, # TODO + parameter_sensitivities=parameter_sensitivities, contact_length=contact_length, closure=closure, ) @@ -570,29 +585,19 @@ def create_tile( ] ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=right)) - - spline_list.append( - _Bezier(degrees=[1, 1], control_points=right_top) - ) - - spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom)) - - spline_list.append( - _Bezier(degrees=[1, 1], control_points=bottom_left) - ) - - spline_list.append(_Bezier(degrees=[1, 1], control_points=left)) - - spline_list.append( - _Bezier(degrees=[1, 1], control_points=top_left) - ) - - spline_list.append(_Bezier(degrees=[1, 1], control_points=top)) - - spline_list.append( - _Bezier(degrees=[1, 1], control_points=bottom_right) - ) + for control_points in [ + right, + right_top, + bottom, + bottom_left, + left, + top_left, + top, + bottom_right, + ]: + spline_list.append( + _Bezier(degrees=[1, 1], control_points=control_points) + ) if i_derivative == 0: splines = spline_list.copy() From 364c21389f140cd2074ce9e5cde1f4e022740fca Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 26 Aug 2024 15:22:35 +0200 Subject: [PATCH 11/23] Add derivatives for Armadillo tile --- splinepy/microstructure/tiles/armadillo.py | 10086 +++++++++---------- 1 file changed, 5028 insertions(+), 5058 deletions(-) diff --git a/splinepy/microstructure/tiles/armadillo.py b/splinepy/microstructure/tiles/armadillo.py index 7137f6565..e9fe2a50c 100644 --- a/splinepy/microstructure/tiles/armadillo.py +++ b/splinepy/microstructure/tiles/armadillo.py @@ -20,7 +20,7 @@ class Armadillo(_TileBase): _dim = 3 _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 1 - _sensitivities_implemented = False + _sensitivities_implemented = True _closure_directions = [ "x_min", "x_max", @@ -35,7 +35,7 @@ class Armadillo(_TileBase): def _closing_tile( self, parameters=None, - parameter_sensitivities=None, # TODO + parameter_sensitivities=None, contact_length=0.3, closure=None, **kwargs, # noqa ARG002 @@ -85,4088 +85,5043 @@ def _closing_tile( ) self.check_params(parameters) + self.check_param_derivatives(parameter_sensitivities) if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None if not (_np.all(parameters > 0) and _np.all(parameters < 0.5)): raise ValueError( "The thickness of the wall must be in (0.01 and 0.49)" ) - v_wall_thickness = parameters[0, 0] - spline_list = [] - v_zero = 0.0 - v_one_half = 0.5 - v_one = 1.0 - v_half_contact_length = contact_length * 0.5 - v_inner_half_contact_length = contact_length * parameters[0, 0] - - if closure == "x_min": - # set points: - right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], + splines = [] + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + v_wall_thickness = parameters[0, 0] + v_zero = 0.0 + v_one_half = 0.5 + v_one = 1.0 + v_half_contact_length = contact_length * 0.5 + v_inner_half_contact_length = contact_length * v_wall_thickness + else: + v_wall_thickness = parameter_sensitivities[ + 0, 0, i_derivative - 1 ] - ) + v_zero = 0.0 + v_one_half = 0.0 + v_one = 0.0 + v_half_contact_length = 0.0 + v_inner_half_contact_length = contact_length * v_wall_thickness + + spline_list = [] + + if closure == "x_min": + # set points: + right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) - connection_front_right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) + connection_front_right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) - front = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) + front = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) - connection_back_left = _np.array( - [ - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_zero, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - ] - ) + connection_back_left = _np.array( + [ + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + ] + ) - left = _np.array( - [ - [ - v_zero, - v_one, - v_one, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_one, - v_zero, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_zero, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + left = _np.array( + [ + [ + v_zero, + v_one, + v_one, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_one, + v_zero, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_front_left = _np.array( - [ - [ - v_zero, - v_one, - v_one, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_one, - v_zero, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_front_left = _np.array( + [ + [ + v_zero, + v_one, + v_one, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_one, + v_zero, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - back = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + back = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_back_right = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) + connection_back_right = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) - bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - top = _np.array( - [ - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - ] - ) + top = _np.array( + [ + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + ] + ) - connection_front_bottom = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + connection_front_bottom = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - connection_front_top = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - ] - ) + connection_front_top = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + ] + ) - connection_back_bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_back_bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_back_top = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - ] - ) + connection_back_top = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + ] + ) - connection_top_right = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) + connection_top_right = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) - connection_top_left = _np.array( - [ - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_zero, - v_one, - v_one, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) + connection_top_left = _np.array( + [ + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_zero, + v_one, + v_one, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) - connection_bottom_left = _np.array( - [ - [ - v_zero, - v_one, - v_zero, - ], - [ - v_zero, - v_zero, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + connection_bottom_left = _np.array( + [ + [ + v_zero, + v_one, + v_zero, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - connection_bottom_right = _np.array( - [ - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - elif closure == "x_max": - # set points: - right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_zero, - v_one, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_zero, - v_zero, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_one, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_zero, - ], - ] - ) - - connection_front_right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_one, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) - - front = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) - - connection_back_left = _np.array( - [ - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - ] - ) - - left = _np.array( - [ - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_front_left = _np.array( - [ - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - back = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_back_right = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_zero, - v_one, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_zero, - v_zero, - ], - ] - ) - - bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - top = _np.array( - [ - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - ] - ) - - connection_front_bottom = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - connection_front_top = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - ] - ) - - connection_back_bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_back_top = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_top_right = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_one, - v_one, - ], - [ - v_one, - v_zero, - v_one, - ], - [ - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_top_left = _np.array( - [ - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_bottom_left = _np.array( - [ - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - connection_bottom_right = _np.array( - [ - [ - v_one, - v_one, - v_zero, - ], - [ - v_one, - v_zero, - v_zero, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - elif closure == "y_min": - # set points: - right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) - - connection_front_right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) - - front = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) - - connection_back_left = _np.array( - [ - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_zero, - ], - ] - ) - - left = _np.array( - [ - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_front_left = _np.array( - [ - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - back = _np.array( - [ - [ - v_one, - v_zero, - v_one, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_zero, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_zero, - v_zero, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_back_right = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_zero, - v_one, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_zero, - v_zero, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) - - bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - top = _np.array( - [ - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - ] - ) - - connection_front_bottom = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - connection_front_top = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - ] - ) - - connection_back_bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one, - v_zero, - v_zero, - ], - [ - v_zero, - v_zero, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_back_top = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_zero, - v_one, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_top_right = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_top_left = _np.array( - [ - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_bottom_left = _np.array( - [ - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - connection_bottom_right = _np.array( - [ - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - elif closure == "y_max": - # set points: - # set points: - right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) - - connection_front_right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_one, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_zero, - ], - ] - ) - - front = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_one, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_zero, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_one, - v_one, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_one, - v_zero, - ], - ] - ) - - connection_back_left = _np.array( - [ - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - ] - ) - - left = _np.array( - [ - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_bottom_right = _np.array( + [ + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - connection_top_left = _np.array( - [ - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_one, - v_one, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_one, - v_zero, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + elif closure == "x_max": + # set points: + right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_zero, + v_one, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_zero, + v_zero, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_one, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_zero, + ], + ] + ) - back = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_front_right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_one, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) - connection_back_right = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) + front = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) - bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + connection_back_left = _np.array( + [ + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + ] + ) - top = _np.array( - [ - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - ] - ) + left = _np.array( + [ + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_front_bottom = _np.array( - [ - [ - v_one, - v_one, - v_zero, - ], - [ - v_zero, - v_one, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + connection_front_left = _np.array( + [ + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_front_top = _np.array( - [ - [ - v_one, - v_one, - v_one, - ], - [ - v_zero, - v_one, - v_one, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - ] - ) + back = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_back_right = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_zero, + v_one, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_zero, + v_zero, + ], + ] + ) + + bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + top = _np.array( + [ + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + ] + ) + + connection_front_bottom = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_front_top = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + ] + ) + + connection_back_bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_back_top = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_top_right = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_one, + v_one, + ], + [ + v_one, + v_zero, + v_one, + ], + [ + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_top_left = _np.array( + [ + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_bottom_left = _np.array( + [ + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_bottom_right = _np.array( + [ + [ + v_one, + v_one, + v_zero, + ], + [ + v_one, + v_zero, + v_zero, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + elif closure == "y_min": + # set points: + right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) + + connection_front_right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) + + front = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) + + connection_back_left = _np.array( + [ + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_zero, + ], + ] + ) + + left = _np.array( + [ + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_back_bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_front_left = _np.array( + [ + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_back_top = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - ] - ) + back = _np.array( + [ + [ + v_one, + v_zero, + v_one, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_zero, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_top_right = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) + connection_back_right = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_zero, + v_one, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_zero, + v_zero, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) - connection_front_left = _np.array( - [ - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) + bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - connection_bottom_left = _np.array( - [ - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + top = _np.array( + [ + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + ] + ) + + connection_front_bottom = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_front_top = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + ] + ) + + connection_back_bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one, + v_zero, + v_zero, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_back_top = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_zero, + v_one, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_top_right = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_top_left = _np.array( + [ + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_bottom_left = _np.array( + [ + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_bottom_right = _np.array( + [ + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + elif closure == "y_max": + # set points: + # set points: + right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) + + connection_front_right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_one, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_zero, + ], + ] + ) + + front = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_one, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_zero, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_one, + v_one, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_one, + v_zero, + ], + ] + ) + + connection_back_left = _np.array( + [ + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + ] + ) + + left = _np.array( + [ + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_top_left = _np.array( + [ + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_one, + v_one, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_one, + v_zero, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + back = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_bottom_right = _np.array( - [ - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + connection_back_right = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) - elif closure == "z_max": - # set points: - right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) + bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - connection_front_right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) + top = _np.array( + [ + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + ] + ) - front = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) + connection_front_bottom = _np.array( + [ + [ + v_one, + v_one, + v_zero, + ], + [ + v_zero, + v_one, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - connection_back_left = _np.array( - [ - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - ] - ) + connection_front_top = _np.array( + [ + [ + v_one, + v_one, + v_one, + ], + [ + v_zero, + v_one, + v_one, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + ] + ) + + connection_back_bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_back_top = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_top_right = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_front_left = _np.array( + [ + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_bottom_left = _np.array( + [ + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_bottom_right = _np.array( + [ + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + elif closure == "z_max": + # set points: + right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) + + connection_front_right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) + + front = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) + + connection_back_left = _np.array( + [ + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + ] + ) + + left = _np.array( + [ + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_front_left = _np.array( + [ + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + back = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_back_right = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) + + bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - left = _np.array( - [ - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + top = _np.array( + [ + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_one, + v_one, + ], + [ + v_zero, + v_one, + v_one, + ], + [ + v_one, + v_zero, + v_one, + ], + [ + v_zero, + v_zero, + v_one, + ], + ] + ) - connection_front_left = _np.array( - [ - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_front_bottom = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) - back = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_front_top = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_one, + ], + [ + v_zero, + v_one, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + ] + ) - connection_back_right = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) + connection_back_bottom = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + connection_back_top = _np.array( + [ + [ + v_one, + v_zero, + v_one, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_top_right = _np.array( + [ + [ + v_one, + v_one, + v_one, + ], + [ + v_one, + v_zero, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_top_left = _np.array( + [ + [ + v_zero, + v_one, + v_one, + ], + [ + v_zero, + v_zero, + v_one, + ], + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) + + connection_bottom_left = _np.array( + [ + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_bottom_right = _np.array( + [ + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + elif closure == "z_min": + # set points: + # set points: + right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) + + connection_front_right = _np.array( + [ + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) + + front = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + ] + ) + + connection_back_left = _np.array( + [ + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + ] + ) + + left = _np.array( + [ + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_front_left = _np.array( + [ + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_zero, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + -v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + back = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + ] + ) + + connection_back_right = _np.array( + [ + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + -v_wall_thickness + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half + v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + ] + ) + + bottom = _np.array( + [ + [ + v_one, + v_one, + v_zero, + ], + [ + v_zero, + v_one, + v_zero, + ], + [ + v_one, + v_zero, + v_zero, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + top = _np.array( + [ + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + ] + ) + + connection_front_bottom = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half - v_half_contact_length, + ], + [ + v_one, + v_one, + v_zero, + ], + [ + v_zero, + v_one, + v_zero, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_front_top = _np.array( + [ + [ + v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_one, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + ] + ) - top = _np.array( - [ - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_one, - v_one, - ], - [ - v_zero, - v_one, - v_one, - ], - [ - v_one, - v_zero, - v_one, - ], - [ - v_zero, - v_zero, - v_one, - ], - ] - ) + connection_back_bottom = _np.array( + [ + [ + v_one, + v_zero, + v_zero, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + v_one_half + v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half - v_half_contact_length, + v_zero, + v_one_half - v_half_contact_length, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + ], + ] + ) - connection_front_bottom = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) + connection_back_top = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + -v_half_contact_length + v_one_half, + v_zero, + v_one_half + v_half_contact_length, + ], + [ + v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + [ + -v_inner_half_contact_length + v_one_half, + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + ], + ] + ) - connection_front_top = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_one, - v_one, - ], - [ - v_zero, - v_one, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - ] - ) + connection_top_right = _np.array( + [ + [ + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half + v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) - connection_back_bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - ] - ) + connection_top_left = _np.array( + [ + [ + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + v_one, + ], + [ + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + v_one, + ], + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half + v_wall_thickness, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + ], + ] + ) - connection_back_top = _np.array( - [ - [ - v_one, - v_zero, - v_one, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - ] - ) + connection_bottom_left = _np.array( + [ + [ + v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, + ], + [ + v_zero, + v_one, + v_zero, + ], + [ + v_zero, + v_zero, + v_zero, + ], + [ + v_one_half - v_wall_thickness, + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_wall_thickness, + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half - v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + connection_bottom_right = _np.array( + [ + [ + v_one, + v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_one, + -v_half_contact_length + v_one_half, + v_one_half - v_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_wall_thickness + v_one_half, + -v_inner_half_contact_length + v_one_half, + v_one_half - v_inner_half_contact_length, + ], + [ + v_one, + v_one, + v_zero, + ], + [ + v_one, + v_zero, + v_zero, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half + v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + [ + v_one_half + v_inner_half_contact_length, + v_one_half - v_inner_half_contact_length, + v_one_half - v_wall_thickness, + ], + ] + ) + + for control_points in [ + right, + connection_front_right, + front, + connection_back_left, + left, + connection_front_left, + back, + connection_back_right, + bottom, + top, + connection_front_bottom, + connection_front_top, + connection_back_bottom, + connection_back_top, + connection_top_right, + connection_top_left, + connection_bottom_left, + connection_bottom_right, + ]: + spline_list.append( + _Bezier(degrees=[1, 1, 1], control_points=control_points) + ) + + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) + + return (splines, derivatives) + + def create_tile( + self, + parameters=None, + parameter_sensitivities=None, # TODO + contact_length=0.3, + closure=None, + **kwargs, # noqa ARG002 + ): + """Create a microtile based on the parameters that describe the wall + thicknesses. + + Thickness parameters are used to describe the inner radius of the + outward facing branches + + Parameters + ---------- + parameters : np.array + One evaluation point with one parameter is used. This parameter + describes the thickness of the wall. The parameters must be a + two-dimensional np.array, where the value must be between 0.01 + and 0.49 + parameter_sensitivities: np.ndarray + Describes the parameter sensitivities with respect to some design + variable. In case the design variables directly apply to the + parameter itself, they evaluate as delta_ij + contact_length : float + the length of the wall that contacts the other microstructure + closure : str + parametric dimension that needs to be closed, given in the form + "x_min", "x_max", etc. - connection_top_right = _np.array( - [ - [ - v_one, - v_one, - v_one, - ], - [ - v_one, - v_zero, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] + Returns + ------- + microtile_list : list(splines) + derivative_list : list / None + """ + + if not isinstance(contact_length, float): + raise ValueError("Invalid Type for radius") + + if not ((contact_length > 0) and (contact_length < 0.99)): + raise ValueError("The length of a side must be in (0.01, 0.99)") + + if parameters is None: + self._logd("Setting parameters to default values (0.2)") + parameters = _np.array( + _np.ones( + (len(self._evaluation_points), self._n_info_per_eval_point) + ) + * 0.2 ) - connection_top_left = _np.array( - [ - [ - v_zero, - v_one, - v_one, - ], - [ - v_zero, - v_zero, - v_one, - ], - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] + self.check_params(parameters) + self.check_param_derivatives(parameter_sensitivities) + + if parameter_sensitivities is not None: + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None + + if not (_np.all(parameters > 0) and _np.all(parameters < 0.5)): + raise ValueError( + "The thickness of the wall must be in (0.01 and 0.49)" ) - connection_bottom_left = _np.array( - [ - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] + if closure is not None: + return self._closing_tile( + parameters=parameters, + parameter_sensitivities=parameter_sensitivities, + contact_length=contact_length, + closure=closure, + **kwargs, ) - connection_bottom_right = _np.array( - [ - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], + splines = [] + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + v_wall_thickness = parameters[0, 0] + v_zero = 0.0 + v_one_half = 0.5 + v_one = 1.0 + v_half_contact_length = contact_length * 0.5 + v_inner_half_contact_length = contact_length * v_wall_thickness + else: + v_wall_thickness = parameter_sensitivities[ + 0, 0, i_derivative - 1 ] - ) + v_zero = 0.0 + v_one_half = 0.0 + v_one = 0.0 + v_half_contact_length = 0.0 + v_inner_half_contact_length = contact_length * v_wall_thickness + + spline_list = [] - elif closure == "z_min": - # set points: # set points: right = _np.array( [ @@ -4531,23 +5486,23 @@ def _closing_tile( bottom = _np.array( [ [ - v_one, - v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, v_zero, ], [ - v_zero, - v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, v_zero, ], [ - v_one, - v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, v_zero, ], [ - v_zero, - v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, v_zero, ], [ @@ -4631,13 +5586,13 @@ def _closing_tile( v_one_half - v_half_contact_length, ], [ - v_one, - v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, v_zero, ], [ - v_zero, - v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, v_zero, ], [ @@ -4711,13 +5666,13 @@ def _closing_tile( connection_back_bottom = _np.array( [ [ - v_one, - v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, v_zero, ], [ - v_zero, - v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, v_zero, ], [ @@ -4901,13 +5856,13 @@ def _closing_tile( v_one_half - v_half_contact_length, ], [ - v_zero, - v_one, + v_one_half - v_half_contact_length, + v_one_half + v_half_contact_length, v_zero, ], [ - v_zero, - v_zero, + v_one_half - v_half_contact_length, + v_one_half - v_half_contact_length, v_zero, ], [ @@ -4956,13 +5911,13 @@ def _closing_tile( v_one_half - v_inner_half_contact_length, ], [ - v_one, - v_one, + v_one_half + v_half_contact_length, + v_one_half + v_half_contact_length, v_zero, ], [ - v_one, - v_zero, + v_one_half + v_half_contact_length, + v_one_half - v_half_contact_length, v_zero, ], [ @@ -4978,1018 +5933,33 @@ def _closing_tile( ] ) - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_bottom_left) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_bottom_right) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_bottom) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_bottom) - ) - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_top) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_top) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_top_right) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_left) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=right)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_right) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=back)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_left) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=left)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_top_left) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=front)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_right) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=bottom)) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=top)) - - return (spline_list, None) - - def create_tile( - self, - parameters=None, - parameter_sensitivities=None, # TODO - contact_length=0.3, - closure=None, - **kwargs, # noqa ARG002 - ): - """Create a microtile based on the parameters that describe the wall - thicknesses. - - Thickness parameters are used to describe the inner radius of the - outward facing branches - - Parameters - ---------- - parameters : np.array - One evaluation point with one parameter is used. This parameter - describes the thickness of the wall. The parameters must be a - two-dimensional np.array, where the value must be between 0.01 - and 0.49 - parameter_sensitivities: np.ndarray - Describes the parameter sensitivities with respect to some design - variable. In case the design variables directly apply to the - parameter itself, they evaluate as delta_ij - contact_length : float - the length of the wall that contacts the other microstructure - closure : str - parametric dimension that needs to be closed, given in the form - "x_min", "x_max", etc. - - Returns - ------- - microtile_list : list(splines) - derivative_list : list / None - """ - - if not isinstance(contact_length, float): - raise ValueError("Invalid Type for radius") - - if not ((contact_length > 0) and (contact_length < 0.99)): - raise ValueError("The length of a side must be in (0.01, 0.99)") - - if parameters is None: - self._logd("Setting parameters to default values (0.2)") - parameters = _np.array( - _np.ones( - (len(self._evaluation_points), self._n_info_per_eval_point) + for control_points in [ + right, + connection_front_right, + front, + connection_back_left, + left, + connection_front_left, + back, + connection_back_right, + bottom, + top, + connection_front_bottom, + connection_front_top, + connection_back_bottom, + connection_back_top, + connection_top_right, + connection_top_left, + connection_bottom_left, + connection_bottom_right, + ]: + spline_list.append( + _Bezier(degrees=[1, 1, 1], control_points=control_points) ) - * 0.2 - ) - - self.check_params(parameters) - - if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) - - if not (_np.all(parameters > 0) and _np.all(parameters < 0.5)): - raise ValueError( - "The thickness of the wall must be in (0.01 and 0.49)" - ) - - if closure is not None: - return self._closing_tile( - parameters=parameters, - parameter_sensitivities=parameter_sensitivities, - contact_length=contact_length, - closure=closure, - **kwargs, - ) - - v_wall_thickness = parameters[0, 0] - v_zero = 0.0 - v_one_half = 0.5 - v_one = 1.0 - v_half_contact_length = contact_length * 0.5 - v_half_contact_length = contact_length * 0.5 - v_inner_half_contact_length = contact_length * parameters[0, 0] - - spline_list = [] - - # set points: - right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) - - connection_front_right = _np.array( - [ - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) - - front = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - ] - ) - - connection_back_left = _np.array( - [ - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - ] - ) - - left = _np.array( - [ - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_front_left = _np.array( - [ - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_zero, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - -v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - back = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_back_right = _np.array( - [ - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - -v_wall_thickness + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half + v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - ] - ) - - bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - top = _np.array( - [ - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - ] - ) - - connection_front_bottom = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - connection_front_top = _np.array( - [ - [ - v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_one, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - ] - ) - - connection_back_bottom = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_zero, - v_one_half - v_half_contact_length, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - ], - ] - ) - - connection_back_top = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - -v_half_contact_length + v_one_half, - v_zero, - v_one_half + v_half_contact_length, - ], - [ - v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - [ - -v_inner_half_contact_length + v_one_half, - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_top_right = _np.array( - [ - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half + v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_top_left = _np.array( - [ - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_one, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_one, - ], - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half + v_wall_thickness, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - ], - ] - ) - - connection_bottom_left = _np.array( - [ - [ - v_zero, - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_zero, - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - ], - [ - v_one_half - v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half - v_wall_thickness, - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_wall_thickness, - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half - v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - connection_bottom_right = _np.array( - [ - [ - v_one, - v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_one, - -v_half_contact_length + v_one_half, - v_one_half - v_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_wall_thickness + v_one_half, - -v_inner_half_contact_length + v_one_half, - v_one_half - v_inner_half_contact_length, - ], - [ - v_one_half + v_half_contact_length, - v_one_half + v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_half_contact_length, - v_one_half - v_half_contact_length, - v_zero, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half + v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - [ - v_one_half + v_inner_half_contact_length, - v_one_half - v_inner_half_contact_length, - v_one_half - v_wall_thickness, - ], - ] - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=right)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_right) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=back)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_left) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=left)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_left) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=front)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_right) - ) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=bottom)) - - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=top)) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_top) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_front_bottom) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_bottom) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_back_top) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_top_right) - ) - - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_top_left) - ) - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_bottom_left) - ) - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=connection_bottom_right) - ) + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) - return (spline_list, None) + return (splines, derivatives) From 88ba9dc1b66e11498f794b2c6a055324eb2bdb4f Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 26 Aug 2024 15:38:20 +0200 Subject: [PATCH 12/23] Fix typo which led to error --- examples/show_microstructures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/show_microstructures.py b/examples/show_microstructures.py index 35d6d22b8..14d74dc04 100644 --- a/examples/show_microstructures.py +++ b/examples/show_microstructures.py @@ -346,13 +346,13 @@ def foo(x): generator.parametrization_function = foo inverse_microstructure = generator.create( - closing_face="z", seperator_distance=0.4, center_expansion=1.3 + closing_face="z", separator_distance=0.4, center_expansion=1.3 ) # Plot the results _, showables_inverse = generator.show( closing_face="z", - seperator_distance=0.4, + separator_distance=0.4, center_expansion=1.3, title="Parametrized Inverse Microstructure", control_points=False, @@ -365,7 +365,7 @@ def foo(x): # Corresponding Structure generator.microtile = splinepy.microstructure.tiles.get("Cross3D") microstructure = generator.create( - closing_face="z", seperator_distance=0.4, center_expansion=1.3 + closing_face="z", separator_distance=0.4, center_expansion=1.3 ) _, showables = generator.show( closing_face="z", From 601994a6978d70c6a94bd1effadbd6bc31dc818b Mon Sep 17 00:00:00 2001 From: markriegler Date: Mon, 26 Aug 2024 15:56:20 +0200 Subject: [PATCH 13/23] Add derivatives for HollowOctagonExtrude tile w/o closure --- .../tiles/hollow_octagon_extrude.py | 289 ++++++++++-------- 1 file changed, 158 insertions(+), 131 deletions(-) diff --git a/splinepy/microstructure/tiles/hollow_octagon_extrude.py b/splinepy/microstructure/tiles/hollow_octagon_extrude.py index 1c935be0f..16359ef49 100644 --- a/splinepy/microstructure/tiles/hollow_octagon_extrude.py +++ b/splinepy/microstructure/tiles/hollow_octagon_extrude.py @@ -18,7 +18,8 @@ class HollowOctagonExtrude(_TileBase): _para_dim = 3 _evaluation_points = _np.array([[0.5, 0.5, 0.5]]) _n_info_per_eval_point = 1 - _sensitivities_implemented = False + _sensitivities_implemented = True + # TODO: closure in create_tile still missing _closure_directions = ["x_min", "x_max", "y_min", "y_max"] _parameter_bounds = [[0.0, 0.5]] _parameters_shape = (1, 1) @@ -26,7 +27,7 @@ class HollowOctagonExtrude(_TileBase): def create_tile( self, parameters=None, - parameter_sensitivities=None, # TODO + parameter_sensitivities=None, contact_length=0.2, **kwargs, # noqa ARG002 ): @@ -70,11 +71,14 @@ def create_tile( ) if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None self.check_params(parameters) + self.check_param_derivatives(parameter_sensitivities) v_h_void = parameters[0, 0] if not ((v_h_void > 0.0) and (v_h_void < 0.5)): @@ -82,142 +86,165 @@ def create_tile( "The thickness of the wall must be in (0.0 and 0.5)" ) - v_zero = 0.0 - v_one_half = 0.5 - v_one = 1.0 - v_outer_c_h = contact_length * 0.5 - v_inner_c_h = contact_length * parameters[0, 0] - - spline_list = [] - - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_zero], - [v_one, -v_outer_c_h + v_one_half, 0.0], - [v_h_void + v_one_half, v_inner_c_h + v_one_half, 0.0], - [v_one, v_outer_c_h + v_one_half, 0.0], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], - [v_one, -v_outer_c_h + v_one_half, v_one], - [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], - [v_one, v_outer_c_h + v_one_half, v_one], - ] - ) - - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_zero], - [v_one, v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], - [v_outer_c_h + v_one_half, v_one, v_zero], - [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], - [v_one, v_outer_c_h + v_one_half, v_one], - [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], - [v_outer_c_h + v_one_half, v_one, v_one], - ] - ) - - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], - [v_outer_c_h + v_one_half, v_one, v_zero], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], - [-v_outer_c_h + v_one_half, v_one, v_zero], - [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], - [v_outer_c_h + v_one_half, v_one, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], - [-v_outer_c_h + v_one_half, v_one, v_one], - ] - ) + splines = [] + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + v_zero = 0.0 + v_one_half = 0.5 + v_one = 1.0 + v_outer_c_h = contact_length * 0.5 + v_inner_c_h = contact_length * v_h_void + else: + v_zero = 0.0 + v_one_half = 0.0 + v_one = 0.0 + v_h_void = parameter_sensitivities[0, 0, i_derivative - 1] + v_outer_c_h = 0.0 + v_inner_c_h = contact_length * v_h_void + + spline_list = [] - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_zero], - [v_zero, -v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_zero], - [-v_outer_c_h + v_one_half, v_zero, v_zero], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], - [v_zero, -v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], - [-v_outer_c_h + v_one_half, v_zero, v_one], - ] - ) - - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half, v_zero], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_zero], - [v_zero, v_outer_c_h + v_one_half, v_zero], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_zero], - [v_zero, -v_outer_c_h + v_one_half, v_one], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], - [v_zero, v_outer_c_h + v_one_half, v_one], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], - ] - ) - - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half, v_zero], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_zero], - [-v_outer_c_h + v_one_half, v_one, v_zero], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], - [v_zero, v_outer_c_h + v_one_half, v_one], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], - [-v_outer_c_h + v_one_half, v_one, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], - ] - ) - - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_zero], - [-v_outer_c_h + v_one_half, v_zero, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_zero], - [v_outer_c_h + v_one_half, v_zero, v_one], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], - [-v_outer_c_h + v_one_half, v_zero, v_one], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], - ] - ) - - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_zero], - [v_outer_c_h + v_one_half, v_zero, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_zero], - [v_one, -v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], - [v_outer_c_h + v_one_half, v_zero, v_one], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], - [v_one, -v_outer_c_h + v_one_half, v_one], - ] - ) + # set points: + right = _np.array( + [ + [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_zero], + [v_one, -v_outer_c_h + v_one_half, 0.0], + [v_h_void + v_one_half, v_inner_c_h + v_one_half, 0.0], + [v_one, v_outer_c_h + v_one_half, 0.0], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], + [v_one, -v_outer_c_h + v_one_half, v_one], + [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], + [v_one, v_outer_c_h + v_one_half, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=right)) + right_top = _np.array( + [ + [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_zero], + [v_one, v_outer_c_h + v_one_half, v_zero], + [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], + [v_outer_c_h + v_one_half, v_one, v_zero], + [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], + [v_one, v_outer_c_h + v_one_half, v_one], + [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], + [v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=right_top) - ) + top = _np.array( + [ + [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], + [v_outer_c_h + v_one_half, v_one, v_zero], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], + [v_outer_c_h + v_one_half, v_one, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], + [-v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=bottom)) + bottom_left = _np.array( + [ + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], + [-v_outer_c_h + v_one_half, v_zero, v_one], + ] + ) - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=bottom_left) - ) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_outer_c_h + v_one_half, v_zero], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_zero], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [-v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], + [v_zero, v_outer_c_h + v_one_half, v_one], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=left)) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half, v_zero], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_zero], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_zero], + [v_zero, v_outer_c_h + v_one_half, v_one], + [-v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], + [-v_outer_c_h + v_one_half, v_one, v_one], + [-v_inner_c_h + v_one_half, v_h_void + v_one_half, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=top_left)) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero, v_zero], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_zero], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_zero, v_one], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], + [-v_outer_c_h + v_one_half, v_zero, v_one], + [-v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1, 1], control_points=top)) + bottom_right = _np.array( + [ + [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_zero], + [v_outer_c_h + v_one_half, v_zero, v_zero], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_zero], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [v_inner_c_h + v_one_half, -v_h_void + v_one_half, v_one], + [v_outer_c_h + v_one_half, v_zero, v_one], + [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], + [v_one, -v_outer_c_h + v_one_half, v_one], + ] + ) + + for control_points in [ + right, + right_top, + top, + bottom_left, + left, + top_left, + bottom, + bottom_right, + ]: + spline_list.append( + _Bezier(degrees=[1, 1, 1], control_points=control_points) + ) - spline_list.append( - _Bezier(degrees=[1, 1, 1], control_points=bottom_right) - ) + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) - return (spline_list, None) + return (splines, derivatives) def _closing_tile( self, From 4d3f58cc9d20f8b519a7f41cfd4be1555708eebd Mon Sep 17 00:00:00 2001 From: markriegler Date: Tue, 27 Aug 2024 10:19:32 +0200 Subject: [PATCH 14/23] Add test for tile derivatives with tile closure --- tests/test_microstructure.py | 140 ++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 69 deletions(-) diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 1a2b54371..73f8e1b72 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -176,16 +176,25 @@ def test_tile_closure(): check_control_points(tile_patches) -def test_tile_derivatives(np_rng, heps=1e-8): - """Testing the correctness of the tile derivatives using Finite Differences +def test_tile_derivatives(np_rng, heps=1e-8, n_test_points=4): + """Testing the correctness of the tile derivatives using Finite Differences. + This includes every closure and no closure, every parameter and every patch + by evaluating at random points and for random parameters. Parameters --------- heps: float Perturbation size for finite difference evaluation + n_test_points: int + Number of testing points in the parametric domain """ - # TODO: right now Chi, EllipsVoid and CubeVoid show wrong derivatives - skip_classes = [ms.tiles.Chi, ms.tiles.EllipsVoid, ms.tiles.CubeVoid] + # TODO: right now Chi, EllipsVoid, CubeVoid and InverseCross show wrong derivatives + skip_classes = [ + ms.tiles.Chi, + ms.tiles.EllipsVoid, + ms.tiles.CubeVoid, + ms.tiles.InverseCross3D, + ] for tile_class in all_tile_classes: # TODO: right now skip classes with faultily implemented derivatives @@ -204,76 +213,69 @@ def test_tile_derivatives(np_rng, heps=1e-8): ) * np.ptp(parameter_bounds, axis=1) parameters = parameters.reshape(tile_creator._parameters_shape) - # Create 3D identity matrix + # Test no closure as well as ... + closure_directions = [None] + # ... every closure implemented + if "_closure_directions" in dir(tile_creator): + closure_directions += tile_creator._closure_directions + + # Retrieve shape values of parameters n_eval_points = tile_creator._evaluation_points.shape[0] n_info_per_eval_point = tile_creator._n_info_per_eval_point - parameter_sensitivities = np.zeros( - (n_eval_points, n_info_per_eval_point, 1) - ) - idx = np.arange(np.min(parameter_sensitivities.shape)) - parameter_sensitivities[idx, idx, :] = 1 - splines, derivatives = tile_creator.create_tile( - parameters=parameters, - parameter_sensitivities=parameter_sensitivities, - ) - # Evaluate splines and derivatives at multiple random points - eval_points = np_rng.random((4, splines[0].para_dim)) - deriv_evaluations = [ - deriv.evaluate(eval_points) for deriv in derivatives[0] - ] - spline_orig_evaluations = [ - spl.evaluate(eval_points) for spl in splines - ] - parameters_perturbed = parameters.copy() - parameters_perturbed += heps - splines_perturbed, _ = tile_creator.create_tile( - parameters=parameters_perturbed - ) - spline_perturbed_evaluations = [ - spl.evaluate(eval_points) for spl in splines_perturbed - ] - fd_sensitivities = [ - (spl_pert - spl_orig) / heps - for spl_pert, spl_orig in zip( - spline_perturbed_evaluations, spline_orig_evaluations + # Test each closure direction + for closure in closure_directions: + # Evaluate tile with given parameter and closure configuration + splines_orig, _ = tile_creator.create_tile( + parameters=parameters, closure=closure ) - ] - - # Go through all the parameters individually - for i_parameter in range(n_info_per_eval_point): - # Get derivatives w.r.t. one parameter - parameter_sensitivities = np.zeros( - (n_eval_points, n_info_per_eval_point, 1) + # Set evaluation points as 4 random spots in the parametric space + eval_points = np_rng.random( + (n_test_points, splines_orig[0].para_dim) ) - parameter_sensitivities[:, i_parameter, :] = 1 - _, derivatives = tile_creator.create_tile( - parameters=parameters, - parameter_sensitivities=parameter_sensitivities, - ) - deriv_evaluations = [ - deriv.evaluate(eval_points) for deriv in derivatives[0] + splines_orig_evaluations = [ + spl.evaluate(eval_points) for spl in splines_orig ] - # Perform finite difference evaluation - parameters_perturbed = parameters.copy() - parameters_perturbed[:, i_parameter] += heps - splines_perturbed, _ = tile_creator.create_tile( - parameters=parameters_perturbed - ) - spline_perturbed_evaluations = [ - spl.evaluate(eval_points) for spl in splines_perturbed - ] - fd_sensitivities = [ - (spl_pert - spl_orig) / heps - for spl_pert, spl_orig in zip( - spline_perturbed_evaluations, spline_orig_evaluations + # Go through all the parameters individually + for i_parameter in range(n_info_per_eval_point): + # Get derivatives w.r.t. one parameter + parameter_sensitivities = np.zeros( + (n_eval_points, n_info_per_eval_point, 1) ) - ] - # Check every patch - for deriv_orig, deriv_fd in zip( - deriv_evaluations, fd_sensitivities - ): - assert np.allclose(deriv_orig, deriv_fd), ( - "Implemented derivative calculation does not match the derivative " - + "obtained using Finite Differences" + parameter_sensitivities[:, i_parameter, :] = 1 + _, derivatives = tile_creator.create_tile( + parameters=parameters, + parameter_sensitivities=parameter_sensitivities, + closure=closure, + ) + deriv_evaluations = [ + deriv.evaluate(eval_points) for deriv in derivatives[0] + ] + # Perform finite difference evaluation + parameters_perturbed = parameters.copy() + parameters_perturbed[:, i_parameter] += heps + splines_perturbed, _ = tile_creator.create_tile( + parameters=parameters_perturbed, closure=closure ) + spline_perturbed_evaluations = [ + spl.evaluate(eval_points) for spl in splines_perturbed + ] + # Evaluate finite difference gradient + fd_sensitivities = [ + (spl_pert - spl_orig) / heps + for spl_pert, spl_orig in zip( + spline_perturbed_evaluations, splines_orig_evaluations + ) + ] + # Check every patch + n_patches = len(fd_sensitivities) + for i_patch, deriv_orig, deriv_fd in zip( + range(n_patches), deriv_evaluations, fd_sensitivities + ): + assert np.allclose(deriv_orig, deriv_fd), ( + "Implemented derivative calculation for tile class" + + f"{tile_class}, parameter " + + f"{i_parameter+1}/{n_info_per_eval_point} at patch " + + f"{i_patch+1}/{n_patches} does not match the derivative " + + "obtained using Finite Differences" + ) From d46121b5ab4370f6748e06e3a518ae4b23ade1b0 Mon Sep 17 00:00:00 2001 From: markriegler Date: Tue, 27 Aug 2024 11:20:15 +0200 Subject: [PATCH 15/23] Restructure and add derivatives for InverseCross3D tile (WIP) --- .../microstructure/tiles/inverse_cross_3d.py | 1368 +++++++++-------- 1 file changed, 712 insertions(+), 656 deletions(-) diff --git a/splinepy/microstructure/tiles/inverse_cross_3d.py b/splinepy/microstructure/tiles/inverse_cross_3d.py index 6e4f0e010..4af1b2ef6 100644 --- a/splinepy/microstructure/tiles/inverse_cross_3d.py +++ b/splinepy/microstructure/tiles/inverse_cross_3d.py @@ -32,7 +32,8 @@ class InverseCross3D(_TileBase): ] ) _n_info_per_eval_point = 1 - _sensitivities_implemented = False + # TODO: implemented sensitivities are not correct + _sensitivities_implemented = True _closure_directions = ["z_min", "z_max"] _parameter_bounds = [[0.2, 0.3]] * 6 # For default values _parameters_shape = (6, 1) @@ -44,7 +45,7 @@ def _closing_tile( closure=None, boundary_width=0.1, filling_height=0.5, - separator_distance=None, + separator_distance=0.3, **kwargs, # noqa ARG002 ): """Create a closing tile to match with closed surface. @@ -73,10 +74,6 @@ def _closing_tile( if closure is None: raise ValueError("No closing direction given") - # Set default values - if separator_distance is None: - separator_distance = 0.3 - if parameters is None: self._logd("Tile request is not parametrized, setting default 0.2") parameters = ( @@ -893,7 +890,7 @@ def create_tile( self, parameters=None, parameter_sensitivities=None, - separator_distance=None, + separator_distance=0.3, center_expansion=1.0, closure=None, **kwargs, # noqa ARG002 @@ -930,13 +927,6 @@ def create_tile( if not ((center_expansion > 0.5) and (center_expansion < 1.5)): raise ValueError("Center Expansion must be in (.5, 1.5)") - # Set default values - if separator_distance is None: - separator_distance = 0.3 - - if center_expansion is None: - center_expansion = 1.0 - # Check if all radii are in allowed range max_radius = min(0.5, (0.5 / center_expansion)) max_radius = min(max_radius, separator_distance) @@ -953,11 +943,14 @@ def create_tile( ) if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None self.check_params(parameters) + self.check_param_derivatives(parameter_sensitivities) if _np.any(parameters < min_radius) or _np.any( parameters > max_radius @@ -976,644 +969,707 @@ def create_tile( **kwargs, ) - [ - x_min_r, - x_max_r, - y_min_r, - y_max_r, - z_min_r, - z_max_r, - ] = parameters.flatten() - - # center radius - center_r = _np.sum(parameters) / 6.0 * center_expansion - - # Auxiliary values for smooothing (mid-branch thickness) - [ - aux_x_min, - aux_x_max, - aux_y_min, - aux_y_max, - aux_z_min, - aux_z_max, - ] = _np.minimum(parameters.ravel(), center_r) - # Branch midlength - hd_center = 0.5 * (0.5 + center_r) - aux_column_width = 0.5 - 2 * (0.5 - separator_distance) + splines = [] + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + [ + x_min_r, + x_max_r, + y_min_r, + y_max_r, + z_min_r, + z_max_r, + ] = parameters.flatten() + + # center radius + center_r = _np.sum(parameters) / 6.0 * center_expansion + + # Auxiliary values for smooothing (mid-branch thickness) + [ + aux_x_min, + aux_x_max, + aux_y_min, + aux_y_max, + aux_z_min, + aux_z_max, + ] = _np.minimum(parameters.ravel(), center_r) + # Branch midlength + hd_center = 0.5 * (0.5 + center_r) + aux_column_width = 0.5 - 2 * (0.5 - separator_distance) + + v_one_half = 0.5 + center_point = _np.array([0.5, 0.5, 0.5]) + else: + sensitivities_i = parameter_sensitivities[ + :, 0, i_derivative - 1 + ] + [ + x_min_r, + x_max_r, + y_min_r, + y_max_r, + z_min_r, + z_max_r, + ] = sensitivities_i + + center_r = _np.mean(sensitivities_i) * center_expansion + [ + aux_x_min, + aux_x_max, + aux_y_min, + aux_y_max, + aux_z_min, + aux_z_max, + ] = _np.where( + parameters.ravel() + < _np.mean(parameters.ravel()) * center_expansion, + sensitivities_i, + center_r, + ) + # Branch midlength + hd_center = center_r / 2.0 + aux_column_width = 0.0 + v_one_half = 0.0 + center_point = _np.zeros(3) + + # Init return type + spline_list = [] + + # Start with branch interconnections + x_min_y_min = ( + _np.array( + [ + [-v_one_half, -v_one_half, -aux_column_width], + [-separator_distance, -v_one_half, -aux_column_width], + [-y_min_r, -v_one_half, -y_min_r], + [-v_one_half, -separator_distance, -aux_column_width], + [-hd_center, -hd_center, -aux_column_width], + [-aux_y_min, -hd_center, -aux_y_min], + [-v_one_half, -x_min_r, -x_min_r], + [-hd_center, -aux_x_min, -aux_x_min], + [-center_r, -center_r, -center_r], + [-v_one_half, -v_one_half, aux_column_width], + [-separator_distance, -v_one_half, aux_column_width], + [-y_min_r, -v_one_half, y_min_r], + [-v_one_half, -separator_distance, aux_column_width], + [-hd_center, -hd_center, aux_column_width], + [-aux_y_min, -hd_center, aux_y_min], + [-v_one_half, -x_min_r, x_min_r], + [-hd_center, -aux_x_min, aux_x_min], + [-center_r, -center_r, center_r], + ] + ) + + center_point + ) - # Init return type - spline_list = [] + x_max_y_min = ( + _np.array( + [ + [y_min_r, -v_one_half, -y_min_r], + [separator_distance, -v_one_half, -aux_column_width], + [v_one_half, -v_one_half, -aux_column_width], + [aux_y_min, -hd_center, -aux_y_min], + [hd_center, -hd_center, -aux_column_width], + [v_one_half, -separator_distance, -aux_column_width], + [center_r, -center_r, -center_r], + [hd_center, -aux_x_max, -aux_x_max], + [v_one_half, -x_max_r, -x_max_r], + [y_min_r, -v_one_half, y_min_r], + [separator_distance, -v_one_half, aux_column_width], + [v_one_half, -v_one_half, aux_column_width], + [aux_y_min, -hd_center, aux_y_min], + [hd_center, -hd_center, aux_column_width], + [v_one_half, -separator_distance, aux_column_width], + [center_r, -center_r, center_r], + [hd_center, -aux_x_max, aux_x_max], + [v_one_half, -x_max_r, x_max_r], + ] + ) + + center_point + ) + + x_min_y_max = ( + _np.array( + [ + [-v_one_half, x_min_r, -x_min_r], + [-hd_center, aux_x_min, -aux_x_min], + [-center_r, center_r, -center_r], + [-v_one_half, separator_distance, -aux_column_width], + [-hd_center, hd_center, -aux_column_width], + [-aux_y_max, hd_center, -aux_y_max], + [-v_one_half, v_one_half, -aux_column_width], + [-separator_distance, v_one_half, -aux_column_width], + [-y_max_r, v_one_half, -y_max_r], + [-v_one_half, x_min_r, x_min_r], + [-hd_center, aux_x_min, aux_x_min], + [-center_r, center_r, center_r], + [-v_one_half, separator_distance, aux_column_width], + [-hd_center, hd_center, aux_column_width], + [-aux_y_max, hd_center, aux_y_max], + [-v_one_half, v_one_half, aux_column_width], + [-separator_distance, v_one_half, aux_column_width], + [-y_max_r, v_one_half, y_max_r], + ] + ) + + center_point + ) + + x_max_y_max = ( + _np.array( + [ + [center_r, center_r, -center_r], + [hd_center, aux_x_max, -aux_x_max], + [v_one_half, x_max_r, -x_max_r], + [aux_y_max, hd_center, -aux_y_max], + [hd_center, hd_center, -aux_column_width], + [v_one_half, separator_distance, -aux_column_width], + [y_max_r, v_one_half, -y_max_r], + [separator_distance, v_one_half, -aux_column_width], + [v_one_half, v_one_half, -aux_column_width], + [center_r, center_r, center_r], + [hd_center, aux_x_max, aux_x_max], + [v_one_half, x_max_r, x_max_r], + [aux_y_max, hd_center, aux_y_max], + [hd_center, hd_center, aux_column_width], + [v_one_half, separator_distance, aux_column_width], + [y_max_r, v_one_half, y_max_r], + [separator_distance, v_one_half, aux_column_width], + [v_one_half, v_one_half, aux_column_width], + ] + ) + + center_point + ) + + x_min_z_min = ( + _np.array( + [ + [-v_one_half, -aux_column_width, -v_one_half], + [-separator_distance, -aux_column_width, -v_one_half], + [-z_min_r, -z_min_r, -v_one_half], + [-v_one_half, aux_column_width, -v_one_half], + [-separator_distance, aux_column_width, -v_one_half], + [-z_min_r, z_min_r, -v_one_half], + [-v_one_half, -aux_column_width, -separator_distance], + [-hd_center, -aux_column_width, -hd_center], + [-aux_z_min, -aux_z_min, -hd_center], + [-v_one_half, aux_column_width, -separator_distance], + [-hd_center, aux_column_width, -hd_center], + [-aux_z_min, aux_z_min, -hd_center], + [-v_one_half, -x_min_r, -x_min_r], + [-hd_center, -aux_x_min, -aux_x_min], + [-center_r, -center_r, -center_r], + [-v_one_half, x_min_r, -x_min_r], + [-hd_center, aux_x_min, -aux_x_min], + [-center_r, center_r, -center_r], + ] + ) + + center_point + ) + + x_max_z_min = ( + _np.array( + [ + [z_min_r, -z_min_r, -v_one_half], + [separator_distance, -aux_column_width, -v_one_half], + [v_one_half, -aux_column_width, -v_one_half], + [z_min_r, z_min_r, -v_one_half], + [separator_distance, aux_column_width, -v_one_half], + [v_one_half, aux_column_width, -v_one_half], + [aux_z_min, -aux_z_min, -hd_center], + [hd_center, -aux_column_width, -hd_center], + [v_one_half, -aux_column_width, -separator_distance], + [aux_z_min, aux_z_min, -hd_center], + [hd_center, aux_column_width, -hd_center], + [v_one_half, aux_column_width, -separator_distance], + [center_r, -center_r, -center_r], + [hd_center, -aux_x_max, -aux_x_max], + [v_one_half, -x_max_r, -x_max_r], + [center_r, center_r, -center_r], + [hd_center, aux_x_max, -aux_x_max], + [v_one_half, x_max_r, -x_max_r], + ] + ) + + center_point + ) + + x_min_z_max = ( + _np.array( + [ + [-v_one_half, -x_min_r, x_min_r], + [-hd_center, -aux_x_min, aux_x_min], + [-center_r, -center_r, center_r], + [-v_one_half, x_min_r, x_min_r], + [-hd_center, aux_x_min, aux_x_min], + [-center_r, center_r, center_r], + [-v_one_half, -aux_column_width, separator_distance], + [-hd_center, -aux_column_width, hd_center], + [-aux_z_max, -aux_z_max, hd_center], + [-v_one_half, aux_column_width, separator_distance], + [-hd_center, aux_column_width, hd_center], + [-aux_z_max, aux_z_max, hd_center], + [-v_one_half, -aux_column_width, v_one_half], + [-separator_distance, -aux_column_width, v_one_half], + [-z_max_r, -z_max_r, v_one_half], + [-v_one_half, aux_column_width, v_one_half], + [-separator_distance, aux_column_width, v_one_half], + [-z_max_r, z_max_r, v_one_half], + ] + ) + + center_point + ) + + x_max_z_max = ( + _np.array( + [ + [center_r, -center_r, center_r], + [hd_center, -aux_x_max, aux_x_max], + [v_one_half, -x_max_r, x_max_r], + [center_r, center_r, center_r], + [hd_center, aux_x_max, aux_x_max], + [v_one_half, x_max_r, x_max_r], + [aux_z_max, -aux_z_max, hd_center], + [hd_center, -aux_column_width, hd_center], + [v_one_half, -aux_column_width, separator_distance], + [aux_z_max, aux_z_max, hd_center], + [hd_center, aux_column_width, hd_center], + [v_one_half, aux_column_width, separator_distance], + [z_max_r, -z_max_r, v_one_half], + [separator_distance, -aux_column_width, v_one_half], + [v_one_half, -aux_column_width, v_one_half], + [z_max_r, z_max_r, v_one_half], + [separator_distance, aux_column_width, v_one_half], + [v_one_half, aux_column_width, v_one_half], + ] + ) + + center_point + ) + + y_min_z_min = ( + _np.array( + [ + [-aux_column_width, -v_one_half, -v_one_half], + [aux_column_width, -v_one_half, -v_one_half], + [-aux_column_width, -separator_distance, -v_one_half], + [aux_column_width, -separator_distance, -v_one_half], + [-z_min_r, -z_min_r, -v_one_half], + [z_min_r, -z_min_r, -v_one_half], + [-aux_column_width, -v_one_half, -separator_distance], + [aux_column_width, -v_one_half, -separator_distance], + [-aux_column_width, -hd_center, -hd_center], + [aux_column_width, -hd_center, -hd_center], + [-aux_z_min, -aux_z_min, -hd_center], + [aux_z_min, -aux_z_min, -hd_center], + [-y_min_r, -v_one_half, -y_min_r], + [y_min_r, -v_one_half, -y_min_r], + [-aux_y_min, -hd_center, -aux_y_min], + [aux_y_min, -hd_center, -aux_y_min], + [-center_r, -center_r, -center_r], + [center_r, -center_r, -center_r], + ] + ) + + center_point + ) + + y_max_z_min = ( + _np.array( + [ + [-z_min_r, z_min_r, -v_one_half], + [z_min_r, z_min_r, -v_one_half], + [-aux_column_width, separator_distance, -v_one_half], + [aux_column_width, separator_distance, -v_one_half], + [-aux_column_width, v_one_half, -v_one_half], + [aux_column_width, v_one_half, -v_one_half], + [-aux_z_min, aux_z_min, -hd_center], + [aux_z_min, aux_z_min, -hd_center], + [-aux_column_width, hd_center, -hd_center], + [aux_column_width, hd_center, -hd_center], + [-aux_column_width, v_one_half, -separator_distance], + [aux_column_width, v_one_half, -separator_distance], + [-center_r, center_r, -center_r], + [center_r, center_r, -center_r], + [-aux_y_max, hd_center, -aux_y_max], + [aux_y_max, hd_center, -aux_y_max], + [-y_max_r, v_one_half, -y_max_r], + [y_max_r, v_one_half, -y_max_r], + ] + ) + + center_point + ) + + y_min_z_max = ( + _np.array( + [ + [-y_min_r, -v_one_half, y_min_r], + [y_min_r, -v_one_half, y_min_r], + [-aux_y_min, -hd_center, aux_y_min], + [aux_y_min, -hd_center, aux_y_min], + [-center_r, -center_r, center_r], + [center_r, -center_r, center_r], + [-aux_column_width, -v_one_half, separator_distance], + [aux_column_width, -v_one_half, separator_distance], + [-aux_column_width, -hd_center, hd_center], + [aux_column_width, -hd_center, hd_center], + [-aux_z_max, -aux_z_max, hd_center], + [aux_z_max, -aux_z_max, hd_center], + [-aux_column_width, -v_one_half, v_one_half], + [aux_column_width, -v_one_half, v_one_half], + [-aux_column_width, -separator_distance, v_one_half], + [aux_column_width, -separator_distance, v_one_half], + [-z_max_r, -z_max_r, v_one_half], + [z_max_r, -z_max_r, v_one_half], + ] + ) + + center_point + ) + + y_max_z_max = ( + _np.array( + [ + [-center_r, center_r, center_r], + [center_r, center_r, center_r], + [-aux_y_max, hd_center, aux_y_max], + [aux_y_max, hd_center, aux_y_max], + [-y_max_r, v_one_half, y_max_r], + [y_max_r, v_one_half, y_max_r], + [-aux_z_max, aux_z_max, hd_center], + [aux_z_max, aux_z_max, hd_center], + [-aux_column_width, hd_center, hd_center], + [aux_column_width, hd_center, hd_center], + [-aux_column_width, v_one_half, separator_distance], + [aux_column_width, v_one_half, separator_distance], + [-z_max_r, z_max_r, v_one_half], + [z_max_r, z_max_r, v_one_half], + [-aux_column_width, separator_distance, v_one_half], + [aux_column_width, separator_distance, v_one_half], + [-aux_column_width, v_one_half, v_one_half], + [aux_column_width, v_one_half, v_one_half], + ] + ) + + center_point + ) + + x_min_y_min_z_min = ( + _np.array( + [ + [-v_one_half, -v_one_half, -v_one_half], + [-separator_distance, -v_one_half, -v_one_half], + [-aux_column_width, -v_one_half, -v_one_half], + [-v_one_half, -separator_distance, -v_one_half], + [ + -separator_distance, + -separator_distance, + -v_one_half, + ], + [-aux_column_width, -separator_distance, -v_one_half], + [-v_one_half, -aux_column_width, -v_one_half], + [-separator_distance, -aux_column_width, -v_one_half], + [-z_min_r, -z_min_r, -v_one_half], + [-v_one_half, -v_one_half, -separator_distance], + [ + -separator_distance, + -v_one_half, + -separator_distance, + ], + [-aux_column_width, -v_one_half, -separator_distance], + [ + -v_one_half, + -separator_distance, + -separator_distance, + ], + [-hd_center, -hd_center, -hd_center], + [-aux_column_width, -hd_center, -hd_center], + [-v_one_half, -aux_column_width, -separator_distance], + [-hd_center, -aux_column_width, -hd_center], + [-aux_z_min, -aux_z_min, -hd_center], + [-v_one_half, -v_one_half, -aux_column_width], + [-separator_distance, -v_one_half, -aux_column_width], + [-y_min_r, -v_one_half, -y_min_r], + [-v_one_half, -separator_distance, -aux_column_width], + [-hd_center, -hd_center, -aux_column_width], + [-aux_y_min, -hd_center, -aux_y_min], + [-v_one_half, -x_min_r, -x_min_r], + [-hd_center, -aux_x_min, -aux_x_min], + [-center_r, -center_r, -center_r], + ] + ) + + center_point + ) + + x_max_y_min_z_min = ( + _np.array( + [ + [aux_column_width, -v_one_half, -v_one_half], + [separator_distance, -v_one_half, -v_one_half], + [v_one_half, -v_one_half, -v_one_half], + [aux_column_width, -separator_distance, -v_one_half], + [separator_distance, -separator_distance, -v_one_half], + [v_one_half, -separator_distance, -v_one_half], + [z_min_r, -z_min_r, -v_one_half], + [separator_distance, -aux_column_width, -v_one_half], + [v_one_half, -aux_column_width, -v_one_half], + [aux_column_width, -v_one_half, -separator_distance], + [separator_distance, -v_one_half, -separator_distance], + [v_one_half, -v_one_half, -separator_distance], + [aux_column_width, -hd_center, -hd_center], + [hd_center, -hd_center, -hd_center], + [v_one_half, -separator_distance, -separator_distance], + [aux_z_min, -aux_z_min, -hd_center], + [hd_center, -aux_column_width, -hd_center], + [v_one_half, -aux_column_width, -separator_distance], + [y_min_r, -v_one_half, -y_min_r], + [separator_distance, -v_one_half, -aux_column_width], + [v_one_half, -v_one_half, -aux_column_width], + [aux_y_min, -hd_center, -aux_y_min], + [hd_center, -hd_center, -aux_column_width], + [v_one_half, -separator_distance, -aux_column_width], + [center_r, -center_r, -center_r], + [hd_center, -aux_x_max, -aux_x_max], + [v_one_half, -x_max_r, -x_max_r], + ] + ) + + center_point + ) + + x_min_y_max_z_min = ( + _np.array( + [ + [-v_one_half, aux_column_width, -v_one_half], + [-separator_distance, aux_column_width, -v_one_half], + [-z_min_r, z_min_r, -v_one_half], + [-v_one_half, separator_distance, -v_one_half], + [-separator_distance, separator_distance, -v_one_half], + [-aux_column_width, separator_distance, -v_one_half], + [-v_one_half, v_one_half, -v_one_half], + [-separator_distance, v_one_half, -v_one_half], + [-aux_column_width, v_one_half, -v_one_half], + [-v_one_half, aux_column_width, -separator_distance], + [-hd_center, aux_column_width, -hd_center], + [-aux_z_min, aux_z_min, -hd_center], + [-v_one_half, separator_distance, -separator_distance], + [-hd_center, hd_center, -hd_center], + [-aux_column_width, hd_center, -hd_center], + [-v_one_half, v_one_half, -separator_distance], + [-separator_distance, v_one_half, -separator_distance], + [-aux_column_width, v_one_half, -separator_distance], + [-v_one_half, x_min_r, -x_min_r], + [-hd_center, aux_x_min, -aux_x_min], + [-center_r, center_r, -center_r], + [-v_one_half, separator_distance, -aux_column_width], + [-hd_center, hd_center, -aux_column_width], + [-aux_y_max, hd_center, -aux_y_max], + [-v_one_half, v_one_half, -aux_column_width], + [-separator_distance, v_one_half, -aux_column_width], + [-y_max_r, v_one_half, -y_max_r], + ] + ) + + center_point + ) + + x_max_y_max_z_min = ( + _np.array( + [ + [z_min_r, z_min_r, -v_one_half], + [separator_distance, aux_column_width, -v_one_half], + [v_one_half, aux_column_width, -v_one_half], + [aux_column_width, separator_distance, -v_one_half], + [separator_distance, separator_distance, -v_one_half], + [v_one_half, separator_distance, -v_one_half], + [aux_column_width, v_one_half, -v_one_half], + [separator_distance, v_one_half, -v_one_half], + [v_one_half, v_one_half, -v_one_half], + [aux_z_min, aux_z_min, -hd_center], + [hd_center, aux_column_width, -hd_center], + [v_one_half, aux_column_width, -separator_distance], + [aux_column_width, hd_center, -hd_center], + [hd_center, hd_center, -hd_center], + [v_one_half, separator_distance, -separator_distance], + [aux_column_width, v_one_half, -separator_distance], + [separator_distance, v_one_half, -separator_distance], + [v_one_half, v_one_half, -separator_distance], + [center_r, center_r, -center_r], + [hd_center, aux_x_max, -aux_x_max], + [v_one_half, x_max_r, -x_max_r], + [aux_y_max, hd_center, -aux_y_max], + [hd_center, hd_center, -aux_column_width], + [v_one_half, separator_distance, -aux_column_width], + [y_max_r, v_one_half, -y_max_r], + [separator_distance, v_one_half, -aux_column_width], + [v_one_half, v_one_half, -aux_column_width], + ] + ) + + center_point + ) + + x_min_y_min_z_max = ( + _np.array( + [ + [-v_one_half, -v_one_half, aux_column_width], + [-separator_distance, -v_one_half, aux_column_width], + [-y_min_r, -v_one_half, y_min_r], + [-v_one_half, -separator_distance, aux_column_width], + [-hd_center, -hd_center, aux_column_width], + [-aux_y_min, -hd_center, aux_y_min], + [-v_one_half, -x_min_r, x_min_r], + [-hd_center, -aux_x_min, aux_x_min], + [-center_r, -center_r, center_r], + [-v_one_half, -v_one_half, separator_distance], + [-separator_distance, -v_one_half, separator_distance], + [-aux_column_width, -v_one_half, separator_distance], + [-v_one_half, -separator_distance, separator_distance], + [-hd_center, -hd_center, hd_center], + [-aux_column_width, -hd_center, hd_center], + [-v_one_half, -aux_column_width, separator_distance], + [-hd_center, -aux_column_width, hd_center], + [-aux_z_max, -aux_z_max, hd_center], + [-v_one_half, -v_one_half, v_one_half], + [-separator_distance, -v_one_half, v_one_half], + [-aux_column_width, -v_one_half, v_one_half], + [-v_one_half, -separator_distance, v_one_half], + [-separator_distance, -separator_distance, v_one_half], + [-aux_column_width, -separator_distance, v_one_half], + [-v_one_half, -aux_column_width, v_one_half], + [-separator_distance, -aux_column_width, v_one_half], + [-z_max_r, -z_max_r, v_one_half], + ] + ) + + center_point + ) + + x_max_y_min_z_max = ( + _np.array( + [ + [y_min_r, -v_one_half, y_min_r], + [separator_distance, -v_one_half, aux_column_width], + [v_one_half, -v_one_half, aux_column_width], + [aux_y_min, -hd_center, aux_y_min], + [hd_center, -hd_center, aux_column_width], + [v_one_half, -separator_distance, aux_column_width], + [center_r, -center_r, center_r], + [hd_center, -aux_x_max, aux_x_max], + [v_one_half, -x_max_r, x_max_r], + [aux_column_width, -v_one_half, separator_distance], + [separator_distance, -v_one_half, separator_distance], + [v_one_half, -v_one_half, separator_distance], + [aux_column_width, -hd_center, hd_center], + [hd_center, -hd_center, hd_center], + [v_one_half, -separator_distance, separator_distance], + [aux_z_max, -aux_z_max, hd_center], + [hd_center, -aux_column_width, hd_center], + [v_one_half, -aux_column_width, separator_distance], + [aux_column_width, -v_one_half, v_one_half], + [separator_distance, -v_one_half, v_one_half], + [v_one_half, -v_one_half, v_one_half], + [aux_column_width, -separator_distance, v_one_half], + [separator_distance, -separator_distance, v_one_half], + [v_one_half, -separator_distance, v_one_half], + [z_max_r, -z_max_r, v_one_half], + [separator_distance, -aux_column_width, v_one_half], + [v_one_half, -aux_column_width, v_one_half], + ] + ) + + center_point + ) + + x_min_y_max_z_max = ( + _np.array( + [ + [-v_one_half, x_min_r, x_min_r], + [-hd_center, aux_x_min, aux_x_min], + [-center_r, center_r, center_r], + [-v_one_half, separator_distance, aux_column_width], + [-hd_center, hd_center, aux_column_width], + [-aux_y_max, hd_center, aux_y_max], + [-v_one_half, v_one_half, aux_column_width], + [-separator_distance, v_one_half, aux_column_width], + [-y_max_r, v_one_half, y_max_r], + [-v_one_half, aux_column_width, separator_distance], + [-hd_center, aux_column_width, hd_center], + [-aux_z_max, aux_z_max, hd_center], + [-v_one_half, separator_distance, separator_distance], + [-hd_center, hd_center, hd_center], + [-aux_column_width, hd_center, hd_center], + [-v_one_half, v_one_half, separator_distance], + [-separator_distance, v_one_half, separator_distance], + [-aux_column_width, v_one_half, separator_distance], + [-v_one_half, aux_column_width, v_one_half], + [-separator_distance, aux_column_width, v_one_half], + [-z_max_r, z_max_r, v_one_half], + [-v_one_half, separator_distance, v_one_half], + [-separator_distance, separator_distance, v_one_half], + [-aux_column_width, separator_distance, v_one_half], + [-v_one_half, v_one_half, v_one_half], + [-separator_distance, v_one_half, v_one_half], + [-aux_column_width, v_one_half, v_one_half], + ] + ) + + center_point + ) + + x_max_y_max_z_max = ( + _np.array( + [ + [center_r, center_r, center_r], + [hd_center, aux_x_max, aux_x_max], + [v_one_half, x_max_r, x_max_r], + [aux_y_max, hd_center, aux_y_max], + [hd_center, hd_center, aux_column_width], + [v_one_half, separator_distance, aux_column_width], + [y_max_r, v_one_half, y_max_r], + [separator_distance, v_one_half, aux_column_width], + [v_one_half, v_one_half, aux_column_width], + [aux_z_max, aux_z_max, hd_center], + [hd_center, aux_column_width, hd_center], + [v_one_half, aux_column_width, separator_distance], + [aux_column_width, hd_center, hd_center], + [hd_center, hd_center, hd_center], + [v_one_half, separator_distance, separator_distance], + [aux_column_width, v_one_half, separator_distance], + [separator_distance, v_one_half, separator_distance], + [v_one_half, v_one_half, separator_distance], + [z_max_r, z_max_r, v_one_half], + [separator_distance, aux_column_width, v_one_half], + [v_one_half, aux_column_width, v_one_half], + [aux_column_width, separator_distance, v_one_half], + [separator_distance, separator_distance, v_one_half], + [v_one_half, separator_distance, v_one_half], + [aux_column_width, v_one_half, v_one_half], + [separator_distance, v_one_half, v_one_half], + [v_one_half, v_one_half, v_one_half], + ] + ) + + center_point + ) + + # Append the control points to the spline list + for control_points, degrees in [ + (x_min_y_min, [2, 2, 1]), + (x_max_y_min, [2, 2, 1]), + (x_min_y_max, [2, 2, 1]), + (x_max_y_max, [2, 2, 1]), + (x_min_z_min, [2, 1, 2]), + (x_max_z_min, [2, 1, 2]), + (x_min_z_max, [2, 1, 2]), + (x_max_z_max, [2, 1, 2]), + (y_min_z_min, [1, 2, 2]), + (y_max_z_min, [1, 2, 2]), + (y_min_z_max, [1, 2, 2]), + (y_max_z_max, [1, 2, 2]), + (x_min_y_min_z_min, [2, 2, 2]), + (x_max_y_min_z_min, [2, 2, 2]), + (x_min_y_max_z_min, [2, 2, 2]), + (x_max_y_max_z_min, [2, 2, 2]), + (x_min_y_min_z_max, [2, 2, 2]), + (x_max_y_min_z_max, [2, 2, 2]), + (x_min_y_max_z_max, [2, 2, 2]), + (x_max_y_max_z_max, [2, 2, 2]), + ]: + spline_list.append( + _Bezier(degrees=degrees, control_points=control_points) + ) + + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) - # Start with branch interconnections - x_min_y_min = _np.array( - [ - [-0.5, -0.5, -aux_column_width], - [-separator_distance, -0.5, -aux_column_width], - [-y_min_r, -0.5, -y_min_r], - [-0.5, -separator_distance, -aux_column_width], - [-hd_center, -hd_center, -aux_column_width], - [-aux_y_min, -hd_center, -aux_y_min], - [-0.5, -x_min_r, -x_min_r], - [-hd_center, -aux_x_min, -aux_x_min], - [-center_r, -center_r, -center_r], - [-0.5, -0.5, aux_column_width], - [-separator_distance, -0.5, aux_column_width], - [-y_min_r, -0.5, y_min_r], - [-0.5, -separator_distance, aux_column_width], - [-hd_center, -hd_center, aux_column_width], - [-aux_y_min, -hd_center, aux_y_min], - [-0.5, -x_min_r, x_min_r], - [-hd_center, -aux_x_min, aux_x_min], - [-center_r, -center_r, center_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 1], control_points=x_min_y_min) - ) - - x_max_y_min = _np.array( - [ - [y_min_r, -0.5, -y_min_r], - [separator_distance, -0.5, -aux_column_width], - [0.5, -0.5, -aux_column_width], - [aux_y_min, -hd_center, -aux_y_min], - [hd_center, -hd_center, -aux_column_width], - [0.5, -separator_distance, -aux_column_width], - [center_r, -center_r, -center_r], - [hd_center, -aux_x_max, -aux_x_max], - [0.5, -x_max_r, -x_max_r], - [y_min_r, -0.5, y_min_r], - [separator_distance, -0.5, aux_column_width], - [0.5, -0.5, aux_column_width], - [aux_y_min, -hd_center, aux_y_min], - [hd_center, -hd_center, aux_column_width], - [0.5, -separator_distance, aux_column_width], - [center_r, -center_r, center_r], - [hd_center, -aux_x_max, aux_x_max], - [0.5, -x_max_r, x_max_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 1], control_points=x_max_y_min) - ) - - x_min_y_max = _np.array( - [ - [-0.5, x_min_r, -x_min_r], - [-hd_center, aux_x_min, -aux_x_min], - [-center_r, center_r, -center_r], - [-0.5, separator_distance, -aux_column_width], - [-hd_center, hd_center, -aux_column_width], - [-aux_y_max, hd_center, -aux_y_max], - [-0.5, 0.5, -aux_column_width], - [-separator_distance, 0.5, -aux_column_width], - [-y_max_r, 0.5, -y_max_r], - [-0.5, x_min_r, x_min_r], - [-hd_center, aux_x_min, aux_x_min], - [-center_r, center_r, center_r], - [-0.5, separator_distance, aux_column_width], - [-hd_center, hd_center, aux_column_width], - [-aux_y_max, hd_center, aux_y_max], - [-0.5, 0.5, aux_column_width], - [-separator_distance, 0.5, aux_column_width], - [-y_max_r, 0.5, y_max_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 1], control_points=x_min_y_max) - ) - - x_max_y_max = _np.array( - [ - [center_r, center_r, -center_r], - [hd_center, aux_x_max, -aux_x_max], - [0.5, x_max_r, -x_max_r], - [aux_y_max, hd_center, -aux_y_max], - [hd_center, hd_center, -aux_column_width], - [0.5, separator_distance, -aux_column_width], - [y_max_r, 0.5, -y_max_r], - [separator_distance, 0.5, -aux_column_width], - [0.5, 0.5, -aux_column_width], - [center_r, center_r, center_r], - [hd_center, aux_x_max, aux_x_max], - [0.5, x_max_r, x_max_r], - [aux_y_max, hd_center, aux_y_max], - [hd_center, hd_center, aux_column_width], - [0.5, separator_distance, aux_column_width], - [y_max_r, 0.5, y_max_r], - [separator_distance, 0.5, aux_column_width], - [0.5, 0.5, aux_column_width], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 1], control_points=x_max_y_max) - ) - - x_min_z_min = _np.array( - [ - [-0.5, -aux_column_width, -0.5], - [-separator_distance, -aux_column_width, -0.5], - [-z_min_r, -z_min_r, -0.5], - [-0.5, aux_column_width, -0.5], - [-separator_distance, aux_column_width, -0.5], - [-z_min_r, z_min_r, -0.5], - [-0.5, -aux_column_width, -separator_distance], - [-hd_center, -aux_column_width, -hd_center], - [-aux_z_min, -aux_z_min, -hd_center], - [-0.5, aux_column_width, -separator_distance], - [-hd_center, aux_column_width, -hd_center], - [-aux_z_min, aux_z_min, -hd_center], - [-0.5, -x_min_r, -x_min_r], - [-hd_center, -aux_x_min, -aux_x_min], - [-center_r, -center_r, -center_r], - [-0.5, x_min_r, -x_min_r], - [-hd_center, aux_x_min, -aux_x_min], - [-center_r, center_r, -center_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 1, 2], control_points=x_min_z_min) - ) - - x_max_z_min = _np.array( - [ - [z_min_r, -z_min_r, -0.5], - [separator_distance, -aux_column_width, -0.5], - [0.5, -aux_column_width, -0.5], - [z_min_r, z_min_r, -0.5], - [separator_distance, aux_column_width, -0.5], - [0.5, aux_column_width, -0.5], - [aux_z_min, -aux_z_min, -hd_center], - [hd_center, -aux_column_width, -hd_center], - [0.5, -aux_column_width, -separator_distance], - [aux_z_min, aux_z_min, -hd_center], - [hd_center, aux_column_width, -hd_center], - [0.5, aux_column_width, -separator_distance], - [center_r, -center_r, -center_r], - [hd_center, -aux_x_max, -aux_x_max], - [0.5, -x_max_r, -x_max_r], - [center_r, center_r, -center_r], - [hd_center, aux_x_max, -aux_x_max], - [0.5, x_max_r, -x_max_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 1, 2], control_points=x_max_z_min) - ) - - x_min_z_max = _np.array( - [ - [-0.5, -x_min_r, x_min_r], - [-hd_center, -aux_x_min, aux_x_min], - [-center_r, -center_r, center_r], - [-0.5, x_min_r, x_min_r], - [-hd_center, aux_x_min, aux_x_min], - [-center_r, center_r, center_r], - [-0.5, -aux_column_width, separator_distance], - [-hd_center, -aux_column_width, hd_center], - [-aux_z_max, -aux_z_max, hd_center], - [-0.5, aux_column_width, separator_distance], - [-hd_center, aux_column_width, hd_center], - [-aux_z_max, aux_z_max, hd_center], - [-0.5, -aux_column_width, 0.5], - [-separator_distance, -aux_column_width, 0.5], - [-z_max_r, -z_max_r, 0.5], - [-0.5, aux_column_width, 0.5], - [-separator_distance, aux_column_width, 0.5], - [-z_max_r, z_max_r, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 1, 2], control_points=x_min_z_max) - ) - - x_max_z_max = _np.array( - [ - [center_r, -center_r, center_r], - [hd_center, -aux_x_max, aux_x_max], - [0.5, -x_max_r, x_max_r], - [center_r, center_r, center_r], - [hd_center, aux_x_max, aux_x_max], - [0.5, x_max_r, x_max_r], - [aux_z_max, -aux_z_max, hd_center], - [hd_center, -aux_column_width, hd_center], - [0.5, -aux_column_width, separator_distance], - [aux_z_max, aux_z_max, hd_center], - [hd_center, aux_column_width, hd_center], - [0.5, aux_column_width, separator_distance], - [z_max_r, -z_max_r, 0.5], - [separator_distance, -aux_column_width, 0.5], - [0.5, -aux_column_width, 0.5], - [z_max_r, z_max_r, 0.5], - [separator_distance, aux_column_width, 0.5], - [0.5, aux_column_width, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 1, 2], control_points=x_max_z_max) - ) - - y_min_z_min = _np.array( - [ - [-aux_column_width, -0.5, -0.5], - [aux_column_width, -0.5, -0.5], - [-aux_column_width, -separator_distance, -0.5], - [aux_column_width, -separator_distance, -0.5], - [-z_min_r, -z_min_r, -0.5], - [z_min_r, -z_min_r, -0.5], - [-aux_column_width, -0.5, -separator_distance], - [aux_column_width, -0.5, -separator_distance], - [-aux_column_width, -hd_center, -hd_center], - [aux_column_width, -hd_center, -hd_center], - [-aux_z_min, -aux_z_min, -hd_center], - [aux_z_min, -aux_z_min, -hd_center], - [-y_min_r, -0.5, -y_min_r], - [y_min_r, -0.5, -y_min_r], - [-aux_y_min, -hd_center, -aux_y_min], - [aux_y_min, -hd_center, -aux_y_min], - [-center_r, -center_r, -center_r], - [center_r, -center_r, -center_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[1, 2, 2], control_points=y_min_z_min) - ) - - y_max_z_min = _np.array( - [ - [-z_min_r, z_min_r, -0.5], - [z_min_r, z_min_r, -0.5], - [-aux_column_width, separator_distance, -0.5], - [aux_column_width, separator_distance, -0.5], - [-aux_column_width, 0.5, -0.5], - [aux_column_width, 0.5, -0.5], - [-aux_z_min, aux_z_min, -hd_center], - [aux_z_min, aux_z_min, -hd_center], - [-aux_column_width, hd_center, -hd_center], - [aux_column_width, hd_center, -hd_center], - [-aux_column_width, 0.5, -separator_distance], - [aux_column_width, 0.5, -separator_distance], - [-center_r, center_r, -center_r], - [center_r, center_r, -center_r], - [-aux_y_max, hd_center, -aux_y_max], - [aux_y_max, hd_center, -aux_y_max], - [-y_max_r, 0.5, -y_max_r], - [y_max_r, 0.5, -y_max_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[1, 2, 2], control_points=y_max_z_min) - ) - - y_min_z_max = _np.array( - [ - [-y_min_r, -0.5, y_min_r], - [y_min_r, -0.5, y_min_r], - [-aux_y_min, -hd_center, aux_y_min], - [aux_y_min, -hd_center, aux_y_min], - [-center_r, -center_r, center_r], - [center_r, -center_r, center_r], - [-aux_column_width, -0.5, separator_distance], - [aux_column_width, -0.5, separator_distance], - [-aux_column_width, -hd_center, hd_center], - [aux_column_width, -hd_center, hd_center], - [-aux_z_max, -aux_z_max, hd_center], - [aux_z_max, -aux_z_max, hd_center], - [-aux_column_width, -0.5, 0.5], - [aux_column_width, -0.5, 0.5], - [-aux_column_width, -separator_distance, 0.5], - [aux_column_width, -separator_distance, 0.5], - [-z_max_r, -z_max_r, 0.5], - [z_max_r, -z_max_r, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[1, 2, 2], control_points=y_min_z_max) - ) - - y_max_z_max = _np.array( - [ - [-center_r, center_r, center_r], - [center_r, center_r, center_r], - [-aux_y_max, hd_center, aux_y_max], - [aux_y_max, hd_center, aux_y_max], - [-y_max_r, 0.5, y_max_r], - [y_max_r, 0.5, y_max_r], - [-aux_z_max, aux_z_max, hd_center], - [aux_z_max, aux_z_max, hd_center], - [-aux_column_width, hd_center, hd_center], - [aux_column_width, hd_center, hd_center], - [-aux_column_width, 0.5, separator_distance], - [aux_column_width, 0.5, separator_distance], - [-z_max_r, z_max_r, 0.5], - [z_max_r, z_max_r, 0.5], - [-aux_column_width, separator_distance, 0.5], - [aux_column_width, separator_distance, 0.5], - [-aux_column_width, 0.5, 0.5], - [aux_column_width, 0.5, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[1, 2, 2], control_points=y_max_z_max) - ) - - x_min_y_min_z_min = _np.array( - [ - [-0.5, -0.5, -0.5], - [-separator_distance, -0.5, -0.5], - [-aux_column_width, -0.5, -0.5], - [-0.5, -separator_distance, -0.5], - [-separator_distance, -separator_distance, -0.5], - [-aux_column_width, -separator_distance, -0.5], - [-0.5, -aux_column_width, -0.5], - [-separator_distance, -aux_column_width, -0.5], - [-z_min_r, -z_min_r, -0.5], - [-0.5, -0.5, -separator_distance], - [-separator_distance, -0.5, -separator_distance], - [-aux_column_width, -0.5, -separator_distance], - [-0.5, -separator_distance, -separator_distance], - [-hd_center, -hd_center, -hd_center], - [-aux_column_width, -hd_center, -hd_center], - [-0.5, -aux_column_width, -separator_distance], - [-hd_center, -aux_column_width, -hd_center], - [-aux_z_min, -aux_z_min, -hd_center], - [-0.5, -0.5, -aux_column_width], - [-separator_distance, -0.5, -aux_column_width], - [-y_min_r, -0.5, -y_min_r], - [-0.5, -separator_distance, -aux_column_width], - [-hd_center, -hd_center, -aux_column_width], - [-aux_y_min, -hd_center, -aux_y_min], - [-0.5, -x_min_r, -x_min_r], - [-hd_center, -aux_x_min, -aux_x_min], - [-center_r, -center_r, -center_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_min_y_min_z_min) - ) - - x_max_y_min_z_min = _np.array( - [ - [aux_column_width, -0.5, -0.5], - [separator_distance, -0.5, -0.5], - [0.5, -0.5, -0.5], - [aux_column_width, -separator_distance, -0.5], - [separator_distance, -separator_distance, -0.5], - [0.5, -separator_distance, -0.5], - [z_min_r, -z_min_r, -0.5], - [separator_distance, -aux_column_width, -0.5], - [0.5, -aux_column_width, -0.5], - [aux_column_width, -0.5, -separator_distance], - [separator_distance, -0.5, -separator_distance], - [0.5, -0.5, -separator_distance], - [aux_column_width, -hd_center, -hd_center], - [hd_center, -hd_center, -hd_center], - [0.5, -separator_distance, -separator_distance], - [aux_z_min, -aux_z_min, -hd_center], - [hd_center, -aux_column_width, -hd_center], - [0.5, -aux_column_width, -separator_distance], - [y_min_r, -0.5, -y_min_r], - [separator_distance, -0.5, -aux_column_width], - [0.5, -0.5, -aux_column_width], - [aux_y_min, -hd_center, -aux_y_min], - [hd_center, -hd_center, -aux_column_width], - [0.5, -separator_distance, -aux_column_width], - [center_r, -center_r, -center_r], - [hd_center, -aux_x_max, -aux_x_max], - [0.5, -x_max_r, -x_max_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_max_y_min_z_min) - ) - - x_min_y_max_z_min = _np.array( - [ - [-0.5, aux_column_width, -0.5], - [-separator_distance, aux_column_width, -0.5], - [-z_min_r, z_min_r, -0.5], - [-0.5, separator_distance, -0.5], - [-separator_distance, separator_distance, -0.5], - [-aux_column_width, separator_distance, -0.5], - [-0.5, 0.5, -0.5], - [-separator_distance, 0.5, -0.5], - [-aux_column_width, 0.5, -0.5], - [-0.5, aux_column_width, -separator_distance], - [-hd_center, aux_column_width, -hd_center], - [-aux_z_min, aux_z_min, -hd_center], - [-0.5, separator_distance, -separator_distance], - [-hd_center, hd_center, -hd_center], - [-aux_column_width, hd_center, -hd_center], - [-0.5, 0.5, -separator_distance], - [-separator_distance, 0.5, -separator_distance], - [-aux_column_width, 0.5, -separator_distance], - [-0.5, x_min_r, -x_min_r], - [-hd_center, aux_x_min, -aux_x_min], - [-center_r, center_r, -center_r], - [-0.5, separator_distance, -aux_column_width], - [-hd_center, hd_center, -aux_column_width], - [-aux_y_max, hd_center, -aux_y_max], - [-0.5, 0.5, -aux_column_width], - [-separator_distance, 0.5, -aux_column_width], - [-y_max_r, 0.5, -y_max_r], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_min_y_max_z_min) - ) - - x_max_y_max_z_min = _np.array( - [ - [z_min_r, z_min_r, -0.5], - [separator_distance, aux_column_width, -0.5], - [0.5, aux_column_width, -0.5], - [aux_column_width, separator_distance, -0.5], - [separator_distance, separator_distance, -0.5], - [0.5, separator_distance, -0.5], - [aux_column_width, 0.5, -0.5], - [separator_distance, 0.5, -0.5], - [0.5, 0.5, -0.5], - [aux_z_min, aux_z_min, -hd_center], - [hd_center, aux_column_width, -hd_center], - [0.5, aux_column_width, -separator_distance], - [aux_column_width, hd_center, -hd_center], - [hd_center, hd_center, -hd_center], - [0.5, separator_distance, -separator_distance], - [aux_column_width, 0.5, -separator_distance], - [separator_distance, 0.5, -separator_distance], - [0.5, 0.5, -separator_distance], - [center_r, center_r, -center_r], - [hd_center, aux_x_max, -aux_x_max], - [0.5, x_max_r, -x_max_r], - [aux_y_max, hd_center, -aux_y_max], - [hd_center, hd_center, -aux_column_width], - [0.5, separator_distance, -aux_column_width], - [y_max_r, 0.5, -y_max_r], - [separator_distance, 0.5, -aux_column_width], - [0.5, 0.5, -aux_column_width], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_max_y_max_z_min) - ) - - x_min_y_min_z_max = _np.array( - [ - [-0.5, -0.5, aux_column_width], - [-separator_distance, -0.5, aux_column_width], - [-y_min_r, -0.5, y_min_r], - [-0.5, -separator_distance, aux_column_width], - [-hd_center, -hd_center, aux_column_width], - [-aux_y_min, -hd_center, aux_y_min], - [-0.5, -x_min_r, x_min_r], - [-hd_center, -aux_x_min, aux_x_min], - [-center_r, -center_r, center_r], - [-0.5, -0.5, separator_distance], - [-separator_distance, -0.5, separator_distance], - [-aux_column_width, -0.5, separator_distance], - [-0.5, -separator_distance, separator_distance], - [-hd_center, -hd_center, hd_center], - [-aux_column_width, -hd_center, hd_center], - [-0.5, -aux_column_width, separator_distance], - [-hd_center, -aux_column_width, hd_center], - [-aux_z_max, -aux_z_max, hd_center], - [-0.5, -0.5, 0.5], - [-separator_distance, -0.5, 0.5], - [-aux_column_width, -0.5, 0.5], - [-0.5, -separator_distance, 0.5], - [-separator_distance, -separator_distance, 0.5], - [-aux_column_width, -separator_distance, 0.5], - [-0.5, -aux_column_width, 0.5], - [-separator_distance, -aux_column_width, 0.5], - [-z_max_r, -z_max_r, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_min_y_min_z_max) - ) - - x_max_y_min_z_max = _np.array( - [ - [y_min_r, -0.5, y_min_r], - [separator_distance, -0.5, aux_column_width], - [0.5, -0.5, aux_column_width], - [aux_y_min, -hd_center, aux_y_min], - [hd_center, -hd_center, aux_column_width], - [0.5, -separator_distance, aux_column_width], - [center_r, -center_r, center_r], - [hd_center, -aux_x_max, aux_x_max], - [0.5, -x_max_r, x_max_r], - [aux_column_width, -0.5, separator_distance], - [separator_distance, -0.5, separator_distance], - [0.5, -0.5, separator_distance], - [aux_column_width, -hd_center, hd_center], - [hd_center, -hd_center, hd_center], - [0.5, -separator_distance, separator_distance], - [aux_z_max, -aux_z_max, hd_center], - [hd_center, -aux_column_width, hd_center], - [0.5, -aux_column_width, separator_distance], - [aux_column_width, -0.5, 0.5], - [separator_distance, -0.5, 0.5], - [0.5, -0.5, 0.5], - [aux_column_width, -separator_distance, 0.5], - [separator_distance, -separator_distance, 0.5], - [0.5, -separator_distance, 0.5], - [z_max_r, -z_max_r, 0.5], - [separator_distance, -aux_column_width, 0.5], - [0.5, -aux_column_width, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_max_y_min_z_max) - ) - - x_min_y_max_z_max = _np.array( - [ - [-0.5, x_min_r, x_min_r], - [-hd_center, aux_x_min, aux_x_min], - [-center_r, center_r, center_r], - [-0.5, separator_distance, aux_column_width], - [-hd_center, hd_center, aux_column_width], - [-aux_y_max, hd_center, aux_y_max], - [-0.5, 0.5, aux_column_width], - [-separator_distance, 0.5, aux_column_width], - [-y_max_r, 0.5, y_max_r], - [-0.5, aux_column_width, separator_distance], - [-hd_center, aux_column_width, hd_center], - [-aux_z_max, aux_z_max, hd_center], - [-0.5, separator_distance, separator_distance], - [-hd_center, hd_center, hd_center], - [-aux_column_width, hd_center, hd_center], - [-0.5, 0.5, separator_distance], - [-separator_distance, 0.5, separator_distance], - [-aux_column_width, 0.5, separator_distance], - [-0.5, aux_column_width, 0.5], - [-separator_distance, aux_column_width, 0.5], - [-z_max_r, z_max_r, 0.5], - [-0.5, separator_distance, 0.5], - [-separator_distance, separator_distance, 0.5], - [-aux_column_width, separator_distance, 0.5], - [-0.5, 0.5, 0.5], - [-separator_distance, 0.5, 0.5], - [-aux_column_width, 0.5, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_min_y_max_z_max) - ) - - x_max_y_max_z_max = _np.array( - [ - [center_r, center_r, center_r], - [hd_center, aux_x_max, aux_x_max], - [0.5, x_max_r, x_max_r], - [aux_y_max, hd_center, aux_y_max], - [hd_center, hd_center, aux_column_width], - [0.5, separator_distance, aux_column_width], - [y_max_r, 0.5, y_max_r], - [separator_distance, 0.5, aux_column_width], - [0.5, 0.5, aux_column_width], - [aux_z_max, aux_z_max, hd_center], - [hd_center, aux_column_width, hd_center], - [0.5, aux_column_width, separator_distance], - [aux_column_width, hd_center, hd_center], - [hd_center, hd_center, hd_center], - [0.5, separator_distance, separator_distance], - [aux_column_width, 0.5, separator_distance], - [separator_distance, 0.5, separator_distance], - [0.5, 0.5, separator_distance], - [z_max_r, z_max_r, 0.5], - [separator_distance, aux_column_width, 0.5], - [0.5, aux_column_width, 0.5], - [aux_column_width, separator_distance, 0.5], - [separator_distance, separator_distance, 0.5], - [0.5, separator_distance, 0.5], - [aux_column_width, 0.5, 0.5], - [separator_distance, 0.5, 0.5], - [0.5, 0.5, 0.5], - ] - ) + _np.array([0.5, 0.5, 0.5]) - - spline_list.append( - _Bezier(degrees=[2, 2, 2], control_points=x_max_y_max_z_max) - ) - return (spline_list, None) + return splines, derivatives From 24d15d678c4aa56a67a4841b6ed4449ee3d4cddb Mon Sep 17 00:00:00 2001 From: markriegler Date: Wed, 9 Oct 2024 13:54:52 +0200 Subject: [PATCH 16/23] Fix derivative of Chi tile --- splinepy/microstructure/tiles/chi.py | 7 ++++--- tests/test_microstructure.py | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/splinepy/microstructure/tiles/chi.py b/splinepy/microstructure/tiles/chi.py index 827c7b8d3..0bcd215e9 100644 --- a/splinepy/microstructure/tiles/chi.py +++ b/splinepy/microstructure/tiles/chi.py @@ -83,12 +83,13 @@ def create_tile( s = r * _np.sin(alpha) c = r * _np.cos(alpha) else: - alpha = parameter_sensitivities[0, 0, i_derivative - 1] + alpha = parameters[0, 0] + _np.pi / 4 + dalpha = float(parameter_sensitivities[0, 0, i_derivative - 1]) v_one_half = 0.0 v_zero = 0.0 r = _np.sqrt(0.125) - s = r * _np.cos(alpha) - c = -r * _np.sin(alpha) + s = dalpha * r * _np.cos(alpha) + c = dalpha * -r * _np.sin(alpha) # Init return value spline_list = [] diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 73f8e1b72..edaf0b477 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -188,9 +188,8 @@ def test_tile_derivatives(np_rng, heps=1e-8, n_test_points=4): n_test_points: int Number of testing points in the parametric domain """ - # TODO: right now Chi, EllipsVoid, CubeVoid and InverseCross show wrong derivatives + # TODO: right now EllipsVoid, CubeVoid and InverseCross show wrong derivatives skip_classes = [ - ms.tiles.Chi, ms.tiles.EllipsVoid, ms.tiles.CubeVoid, ms.tiles.InverseCross3D, From c38a2e089190349a33e6abfe819d17998e687ec8 Mon Sep 17 00:00:00 2001 From: markriegler Date: Wed, 9 Oct 2024 15:47:47 +0200 Subject: [PATCH 17/23] Add/fix derivative of tile InverseCross3D --- .../microstructure/tiles/inverse_cross_3d.py | 1920 +++++++++-------- tests/test_microstructure.py | 8 +- 2 files changed, 1038 insertions(+), 890 deletions(-) diff --git a/splinepy/microstructure/tiles/inverse_cross_3d.py b/splinepy/microstructure/tiles/inverse_cross_3d.py index 4af1b2ef6..4787cd3b2 100644 --- a/splinepy/microstructure/tiles/inverse_cross_3d.py +++ b/splinepy/microstructure/tiles/inverse_cross_3d.py @@ -89,9 +89,13 @@ def _closing_tile( self.check_params(parameters) if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) + self.check_param_derivatives(parameter_sensitivities) + + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None if not (_np.all(parameters > 0) and _np.all(parameters < 0.5)): raise ValueError("Thickness out of range (0, .5)") @@ -102,789 +106,933 @@ def _closing_tile( if not (0.0 < float(filling_height) < 1.0): raise ValueError("Filling must be in (0,1)") - # Precompute auxiliary values - inv_filling_height = 1.0 - filling_height - ctps_mid_height_top = (1 + filling_height) * 0.5 - ctps_mid_height_bottom = 1.0 - ctps_mid_height_top - center_width = 1.0 - 2 * boundary_width - r_center = center_width * 0.5 - half_r_center = (r_center + 0.5) * 0.5 - aux_column_width = 0.5 - 2 * (0.5 - separator_distance) - - spline_list = [] - if closure == "z_min": - branch_thickness = parameters.flatten()[5] - branch_neighbor_x_min_ctps = _np.array( - [ - [-0.5, -r_center, filling_height], - [-half_r_center, -r_center, filling_height], - [-r_center, -r_center, filling_height], - [-0.5, r_center, filling_height], - [-half_r_center, r_center, filling_height], - [-r_center, r_center, filling_height], - [-0.5, -aux_column_width, ctps_mid_height_top], - [ - -separator_distance, - -aux_column_width, - ctps_mid_height_top, - ], - [ - -branch_thickness, - -branch_thickness, - ctps_mid_height_top, - ], - [-0.5, aux_column_width, ctps_mid_height_top], - [ - -separator_distance, - aux_column_width, - ctps_mid_height_top, - ], - [-branch_thickness, branch_thickness, ctps_mid_height_top], - [-0.5, -aux_column_width, 1.0], - [-separator_distance, -aux_column_width, 1.0], - [-branch_thickness, -branch_thickness, 1.0], - [-0.5, aux_column_width, 1.0], - [-separator_distance, aux_column_width, 1.0], - [-branch_thickness, branch_thickness, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + splines = [] + + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + # Auxiliary values + fill_height_aux = filling_height + sep_distance_aux = separator_distance + inv_filling_height = 1.0 - filling_height + ctps_mid_height_top = (1 + filling_height) * 0.5 + ctps_mid_height_bottom = 1.0 - ctps_mid_height_top + center_width = 1.0 - 2 * boundary_width + r_center = center_width * 0.5 + half_r_center = (r_center + 0.5) * 0.5 + aux_column_width = 0.5 - 2 * (0.5 - separator_distance) + v_zero = 0.0 + v_one_half = 0.5 + v_one = 1.0 + if closure == "z_min": + branch_thickness = parameters.flatten()[5] + elif closure == "z_max": + branch_thickness = parameters.flatten()[4] + else: + fill_height_aux = 0.0 + sep_distance_aux = 0.0 + inv_filling_height = 0.0 + ctps_mid_height_top = 0.0 + ctps_mid_height_bottom = 0.0 + center_width = 0.0 + r_center = 0.0 + half_r_center = 0.0 + aux_column_width = 0.0 + v_zero, v_one_half, v_one = [0.0] * 3 + if closure == "z_min": + branch_thickness = parameter_sensitivities.flatten()[5] + elif closure == "z_max": + branch_thickness = parameter_sensitivities.flatten()[4] + spline_list = [] + if closure == "z_min": + branch_neighbor_x_min_ctps = _np.array( + [ + [-v_one_half, -r_center, fill_height_aux], + [-half_r_center, -r_center, fill_height_aux], + [-r_center, -r_center, fill_height_aux], + [-v_one_half, r_center, fill_height_aux], + [-half_r_center, r_center, fill_height_aux], + [-r_center, r_center, fill_height_aux], + [-v_one_half, -aux_column_width, ctps_mid_height_top], + [ + -sep_distance_aux, + -aux_column_width, + ctps_mid_height_top, + ], + [ + -branch_thickness, + -branch_thickness, + ctps_mid_height_top, + ], + [-v_one_half, aux_column_width, ctps_mid_height_top], + [ + -sep_distance_aux, + aux_column_width, + ctps_mid_height_top, + ], + [ + -branch_thickness, + branch_thickness, + ctps_mid_height_top, + ], + [-v_one_half, -aux_column_width, v_one], + [-sep_distance_aux, -aux_column_width, v_one], + [-branch_thickness, -branch_thickness, v_one], + [-v_one_half, aux_column_width, v_one], + [-sep_distance_aux, aux_column_width, v_one], + [-branch_thickness, branch_thickness, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 1, 2], - control_points=branch_neighbor_x_min_ctps, + spline_list.append( + _Bezier( + degrees=[2, 1, 2], + control_points=branch_neighbor_x_min_ctps, + ) ) - ) - branch_neighbor_x_max_ctps = _np.array( - [ - [r_center, -r_center, filling_height], - [half_r_center, -r_center, filling_height], - [0.5, -r_center, filling_height], - [r_center, r_center, filling_height], - [half_r_center, r_center, filling_height], - [0.5, r_center, filling_height], - [branch_thickness, -branch_thickness, ctps_mid_height_top], - [ - separator_distance, - -aux_column_width, - ctps_mid_height_top, - ], - [0.5, -aux_column_width, ctps_mid_height_top], - [branch_thickness, branch_thickness, ctps_mid_height_top], + branch_neighbor_x_max_ctps = _np.array( [ - separator_distance, - aux_column_width, - ctps_mid_height_top, - ], - [0.5, aux_column_width, ctps_mid_height_top], - [branch_thickness, -branch_thickness, 1.0], - [separator_distance, -aux_column_width, 1.0], - [0.5, -aux_column_width, 1.0], - [branch_thickness, branch_thickness, 1.0], - [separator_distance, aux_column_width, 1.0], - [0.5, aux_column_width, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + [r_center, -r_center, fill_height_aux], + [half_r_center, -r_center, fill_height_aux], + [v_one_half, -r_center, fill_height_aux], + [r_center, r_center, fill_height_aux], + [half_r_center, r_center, fill_height_aux], + [v_one_half, r_center, fill_height_aux], + [ + branch_thickness, + -branch_thickness, + ctps_mid_height_top, + ], + [ + sep_distance_aux, + -aux_column_width, + ctps_mid_height_top, + ], + [v_one_half, -aux_column_width, ctps_mid_height_top], + [ + branch_thickness, + branch_thickness, + ctps_mid_height_top, + ], + [ + sep_distance_aux, + aux_column_width, + ctps_mid_height_top, + ], + [v_one_half, aux_column_width, ctps_mid_height_top], + [branch_thickness, -branch_thickness, v_one], + [sep_distance_aux, -aux_column_width, v_one], + [v_one_half, -aux_column_width, v_one], + [branch_thickness, branch_thickness, v_one], + [sep_distance_aux, aux_column_width, v_one], + [v_one_half, aux_column_width, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 1, 2], - control_points=branch_neighbor_x_max_ctps, + spline_list.append( + _Bezier( + degrees=[2, 1, 2], + control_points=branch_neighbor_x_max_ctps, + ) ) - ) - branch_neighbor_y_min_ctps = _np.array( - [ - [-r_center, -0.5, filling_height], - [r_center, -0.5, filling_height], - [-r_center, -half_r_center, filling_height], - [r_center, -half_r_center, filling_height], - [-r_center, -r_center, filling_height], - [r_center, -r_center, filling_height], - [-aux_column_width, -0.5, ctps_mid_height_top], - [aux_column_width, -0.5, ctps_mid_height_top], - [ - -aux_column_width, - -separator_distance, - ctps_mid_height_top, - ], + branch_neighbor_y_min_ctps = _np.array( [ - aux_column_width, - -separator_distance, - ctps_mid_height_top, - ], - [ - -branch_thickness, - -branch_thickness, - ctps_mid_height_top, - ], - [branch_thickness, -branch_thickness, ctps_mid_height_top], - [-aux_column_width, -0.5, 1.0], - [aux_column_width, -0.5, 1.0], - [-aux_column_width, -separator_distance, 1.0], - [aux_column_width, -separator_distance, 1.0], - [-branch_thickness, -branch_thickness, 1.0], - [branch_thickness, -branch_thickness, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + [-r_center, -v_one_half, fill_height_aux], + [r_center, -v_one_half, fill_height_aux], + [-r_center, -half_r_center, fill_height_aux], + [r_center, -half_r_center, fill_height_aux], + [-r_center, -r_center, fill_height_aux], + [r_center, -r_center, fill_height_aux], + [-aux_column_width, -v_one_half, ctps_mid_height_top], + [aux_column_width, -v_one_half, ctps_mid_height_top], + [ + -aux_column_width, + -sep_distance_aux, + ctps_mid_height_top, + ], + [ + aux_column_width, + -sep_distance_aux, + ctps_mid_height_top, + ], + [ + -branch_thickness, + -branch_thickness, + ctps_mid_height_top, + ], + [ + branch_thickness, + -branch_thickness, + ctps_mid_height_top, + ], + [-aux_column_width, -v_one_half, v_one], + [aux_column_width, -v_one_half, v_one], + [-aux_column_width, -sep_distance_aux, v_one], + [aux_column_width, -sep_distance_aux, v_one], + [-branch_thickness, -branch_thickness, v_one], + [branch_thickness, -branch_thickness, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[1, 2, 2], - control_points=branch_neighbor_y_min_ctps, + spline_list.append( + _Bezier( + degrees=[1, 2, 2], + control_points=branch_neighbor_y_min_ctps, + ) ) - ) - branch_neighbor_y_max_ctps = _np.array( - [ - [-r_center, r_center, filling_height], - [r_center, r_center, filling_height], - [-r_center, half_r_center, filling_height], - [r_center, half_r_center, filling_height], - [-r_center, 0.5, filling_height], - [r_center, 0.5, filling_height], - [-branch_thickness, branch_thickness, ctps_mid_height_top], - [branch_thickness, branch_thickness, ctps_mid_height_top], - [ - -aux_column_width, - separator_distance, - ctps_mid_height_top, - ], + branch_neighbor_y_max_ctps = _np.array( [ - aux_column_width, - separator_distance, - ctps_mid_height_top, - ], - [-aux_column_width, 0.5, ctps_mid_height_top], - [aux_column_width, 0.5, ctps_mid_height_top], - [-branch_thickness, branch_thickness, 1.0], - [branch_thickness, branch_thickness, 1.0], - [-aux_column_width, separator_distance, 1.0], - [aux_column_width, separator_distance, 1.0], - [-aux_column_width, 0.5, 1.0], - [aux_column_width, 0.5, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + [-r_center, r_center, fill_height_aux], + [r_center, r_center, fill_height_aux], + [-r_center, half_r_center, fill_height_aux], + [r_center, half_r_center, fill_height_aux], + [-r_center, v_one_half, fill_height_aux], + [r_center, v_one_half, fill_height_aux], + [ + -branch_thickness, + branch_thickness, + ctps_mid_height_top, + ], + [ + branch_thickness, + branch_thickness, + ctps_mid_height_top, + ], + [ + -aux_column_width, + sep_distance_aux, + ctps_mid_height_top, + ], + [ + aux_column_width, + sep_distance_aux, + ctps_mid_height_top, + ], + [-aux_column_width, v_one_half, ctps_mid_height_top], + [aux_column_width, v_one_half, ctps_mid_height_top], + [-branch_thickness, branch_thickness, v_one], + [branch_thickness, branch_thickness, v_one], + [-aux_column_width, sep_distance_aux, v_one], + [aux_column_width, sep_distance_aux, v_one], + [-aux_column_width, v_one_half, v_one], + [aux_column_width, v_one_half, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[1, 2, 2], - control_points=branch_neighbor_y_max_ctps, + spline_list.append( + _Bezier( + degrees=[1, 2, 2], + control_points=branch_neighbor_y_max_ctps, + ) ) - ) - branch_x_min_y_min_ctps = _np.array( - [ - [-0.5, -0.5, filling_height], - [-half_r_center, -0.5, filling_height], - [-r_center, -0.5, filling_height], - [-0.5, -half_r_center, filling_height], - [-half_r_center, -half_r_center, filling_height], - [-r_center, -half_r_center, filling_height], - [-0.5, -r_center, filling_height], - [-half_r_center, -r_center, filling_height], - [-r_center, -r_center, filling_height], - [-0.5, -0.5, ctps_mid_height_top], - [-separator_distance, -0.5, ctps_mid_height_top], - [-aux_column_width, -0.5, ctps_mid_height_top], - [-0.5, -separator_distance, ctps_mid_height_top], - [ - -separator_distance, - -separator_distance, - ctps_mid_height_top, - ], - [ - -aux_column_width, - -separator_distance, - ctps_mid_height_top, - ], - [-0.5, -aux_column_width, ctps_mid_height_top], - [ - -separator_distance, - -aux_column_width, - ctps_mid_height_top, - ], - [ - -branch_thickness, - -branch_thickness, - ctps_mid_height_top, - ], - [-0.5, -0.5, 1.0], - [-separator_distance, -0.5, 1.0], - [-aux_column_width, -0.5, 1.0], - [-0.5, -separator_distance, 1.0], - [-separator_distance, -separator_distance, 1.0], - [-aux_column_width, -separator_distance, 1.0], - [-0.5, -aux_column_width, 1.0], - [-separator_distance, -aux_column_width, 1.0], - [-branch_thickness, -branch_thickness, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_min_y_min_ctps = _np.array( + [ + [-v_one_half, -v_one_half, fill_height_aux], + [-half_r_center, -v_one_half, fill_height_aux], + [-r_center, -v_one_half, fill_height_aux], + [-v_one_half, -half_r_center, fill_height_aux], + [-half_r_center, -half_r_center, fill_height_aux], + [-r_center, -half_r_center, fill_height_aux], + [-v_one_half, -r_center, fill_height_aux], + [-half_r_center, -r_center, fill_height_aux], + [-r_center, -r_center, fill_height_aux], + [-v_one_half, -v_one_half, ctps_mid_height_top], + [-sep_distance_aux, -v_one_half, ctps_mid_height_top], + [-aux_column_width, -v_one_half, ctps_mid_height_top], + [-v_one_half, -sep_distance_aux, ctps_mid_height_top], + [ + -sep_distance_aux, + -sep_distance_aux, + ctps_mid_height_top, + ], + [ + -aux_column_width, + -sep_distance_aux, + ctps_mid_height_top, + ], + [-v_one_half, -aux_column_width, ctps_mid_height_top], + [ + -sep_distance_aux, + -aux_column_width, + ctps_mid_height_top, + ], + [ + -branch_thickness, + -branch_thickness, + ctps_mid_height_top, + ], + [-v_one_half, -v_one_half, v_one], + [-sep_distance_aux, -v_one_half, v_one], + [-aux_column_width, -v_one_half, v_one], + [-v_one_half, -sep_distance_aux, v_one], + [-sep_distance_aux, -sep_distance_aux, v_one], + [-aux_column_width, -sep_distance_aux, v_one], + [-v_one_half, -aux_column_width, v_one], + [-sep_distance_aux, -aux_column_width, v_one], + [-branch_thickness, -branch_thickness, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_min_y_min_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_min_y_min_ctps, + ) ) - ) - branch_x_min_y_max_ctps = _np.array( - [ - [-0.5, r_center, filling_height], - [-half_r_center, r_center, filling_height], - [-r_center, r_center, filling_height], - [-0.5, half_r_center, filling_height], - [-half_r_center, half_r_center, filling_height], - [-r_center, half_r_center, filling_height], - [-0.5, 0.5, filling_height], - [-half_r_center, 0.5, filling_height], - [-r_center, 0.5, filling_height], - [-0.5, aux_column_width, ctps_mid_height_top], - [ - -separator_distance, - aux_column_width, - ctps_mid_height_top, - ], - [-branch_thickness, branch_thickness, ctps_mid_height_top], - [-0.5, separator_distance, ctps_mid_height_top], - [ - -separator_distance, - separator_distance, - ctps_mid_height_top, - ], - [ - -aux_column_width, - separator_distance, - ctps_mid_height_top, - ], - [-0.5, 0.5, ctps_mid_height_top], - [-separator_distance, 0.5, ctps_mid_height_top], - [-aux_column_width, 0.5, ctps_mid_height_top], - [-0.5, aux_column_width, 1.0], - [-separator_distance, aux_column_width, 1.0], - [-branch_thickness, branch_thickness, 1.0], - [-0.5, separator_distance, 1.0], - [-separator_distance, separator_distance, 1.0], - [-aux_column_width, separator_distance, 1.0], - [-0.5, 0.5, 1.0], - [-separator_distance, 0.5, 1.0], - [-aux_column_width, 0.5, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_min_y_max_ctps = _np.array( + [ + [-v_one_half, r_center, fill_height_aux], + [-half_r_center, r_center, fill_height_aux], + [-r_center, r_center, fill_height_aux], + [-v_one_half, half_r_center, fill_height_aux], + [-half_r_center, half_r_center, fill_height_aux], + [-r_center, half_r_center, fill_height_aux], + [-v_one_half, v_one_half, fill_height_aux], + [-half_r_center, v_one_half, fill_height_aux], + [-r_center, v_one_half, fill_height_aux], + [-v_one_half, aux_column_width, ctps_mid_height_top], + [ + -sep_distance_aux, + aux_column_width, + ctps_mid_height_top, + ], + [ + -branch_thickness, + branch_thickness, + ctps_mid_height_top, + ], + [-v_one_half, sep_distance_aux, ctps_mid_height_top], + [ + -sep_distance_aux, + sep_distance_aux, + ctps_mid_height_top, + ], + [ + -aux_column_width, + sep_distance_aux, + ctps_mid_height_top, + ], + [-v_one_half, v_one_half, ctps_mid_height_top], + [-sep_distance_aux, v_one_half, ctps_mid_height_top], + [-aux_column_width, v_one_half, ctps_mid_height_top], + [-v_one_half, aux_column_width, v_one], + [-sep_distance_aux, aux_column_width, v_one], + [-branch_thickness, branch_thickness, v_one], + [-v_one_half, sep_distance_aux, v_one], + [-sep_distance_aux, sep_distance_aux, v_one], + [-aux_column_width, sep_distance_aux, v_one], + [-v_one_half, v_one_half, v_one], + [-sep_distance_aux, v_one_half, v_one], + [-aux_column_width, v_one_half, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_min_y_max_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_min_y_max_ctps, + ) ) - ) - branch_x_max_y_min_ctps = _np.array( - [ - [r_center, -0.5, filling_height], - [half_r_center, -0.5, filling_height], - [0.5, -0.5, filling_height], - [r_center, -half_r_center, filling_height], - [half_r_center, -half_r_center, filling_height], - [0.5, -half_r_center, filling_height], - [r_center, -r_center, filling_height], - [half_r_center, -r_center, filling_height], - [0.5, -r_center, filling_height], - [aux_column_width, -0.5, ctps_mid_height_top], - [separator_distance, -0.5, ctps_mid_height_top], - [0.5, -0.5, ctps_mid_height_top], - [ - aux_column_width, - -separator_distance, - ctps_mid_height_top, - ], - [ - separator_distance, - -separator_distance, - ctps_mid_height_top, - ], - [0.5, -separator_distance, ctps_mid_height_top], - [branch_thickness, -branch_thickness, ctps_mid_height_top], - [ - separator_distance, - -aux_column_width, - ctps_mid_height_top, - ], - [0.5, -aux_column_width, ctps_mid_height_top], - [aux_column_width, -0.5, 1.0], - [separator_distance, -0.5, 1.0], - [0.5, -0.5, 1.0], - [aux_column_width, -separator_distance, 1.0], - [separator_distance, -separator_distance, 1.0], - [0.5, -separator_distance, 1.0], - [branch_thickness, -branch_thickness, 1.0], - [separator_distance, -aux_column_width, 1.0], - [0.5, -aux_column_width, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_max_y_min_ctps = _np.array( + [ + [r_center, -v_one_half, fill_height_aux], + [half_r_center, -v_one_half, fill_height_aux], + [v_one_half, -v_one_half, fill_height_aux], + [r_center, -half_r_center, fill_height_aux], + [half_r_center, -half_r_center, fill_height_aux], + [v_one_half, -half_r_center, fill_height_aux], + [r_center, -r_center, fill_height_aux], + [half_r_center, -r_center, fill_height_aux], + [v_one_half, -r_center, fill_height_aux], + [aux_column_width, -v_one_half, ctps_mid_height_top], + [sep_distance_aux, -v_one_half, ctps_mid_height_top], + [v_one_half, -v_one_half, ctps_mid_height_top], + [ + aux_column_width, + -sep_distance_aux, + ctps_mid_height_top, + ], + [ + sep_distance_aux, + -sep_distance_aux, + ctps_mid_height_top, + ], + [v_one_half, -sep_distance_aux, ctps_mid_height_top], + [ + branch_thickness, + -branch_thickness, + ctps_mid_height_top, + ], + [ + sep_distance_aux, + -aux_column_width, + ctps_mid_height_top, + ], + [v_one_half, -aux_column_width, ctps_mid_height_top], + [aux_column_width, -v_one_half, v_one], + [sep_distance_aux, -v_one_half, v_one], + [v_one_half, -v_one_half, v_one], + [aux_column_width, -sep_distance_aux, v_one], + [sep_distance_aux, -sep_distance_aux, v_one], + [v_one_half, -sep_distance_aux, v_one], + [branch_thickness, -branch_thickness, v_one], + [sep_distance_aux, -aux_column_width, v_one], + [v_one_half, -aux_column_width, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_max_y_min_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_max_y_min_ctps, + ) ) - ) - branch_x_max_y_max_ctps = _np.array( - [ - [r_center, r_center, filling_height], - [half_r_center, r_center, filling_height], - [0.5, r_center, filling_height], - [r_center, half_r_center, filling_height], - [half_r_center, half_r_center, filling_height], - [0.5, half_r_center, filling_height], - [r_center, 0.5, filling_height], - [half_r_center, 0.5, filling_height], - [0.5, 0.5, filling_height], - [branch_thickness, branch_thickness, ctps_mid_height_top], - [ - separator_distance, - aux_column_width, - ctps_mid_height_top, - ], - [0.5, aux_column_width, ctps_mid_height_top], - [ - aux_column_width, - separator_distance, - ctps_mid_height_top, - ], - [ - separator_distance, - separator_distance, - ctps_mid_height_top, - ], - [0.5, separator_distance, ctps_mid_height_top], - [aux_column_width, 0.5, ctps_mid_height_top], - [separator_distance, 0.5, ctps_mid_height_top], - [0.5, 0.5, ctps_mid_height_top], - [branch_thickness, branch_thickness, 1.0], - [separator_distance, aux_column_width, 1.0], - [0.5, aux_column_width, 1.0], - [aux_column_width, separator_distance, 1.0], - [separator_distance, separator_distance, 1.0], - [0.5, separator_distance, 1.0], - [aux_column_width, 0.5, 1.0], - [separator_distance, 0.5, 1.0], - [0.5, 0.5, 1.0], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_max_y_max_ctps = _np.array( + [ + [r_center, r_center, fill_height_aux], + [half_r_center, r_center, fill_height_aux], + [v_one_half, r_center, fill_height_aux], + [r_center, half_r_center, fill_height_aux], + [half_r_center, half_r_center, fill_height_aux], + [v_one_half, half_r_center, fill_height_aux], + [r_center, v_one_half, fill_height_aux], + [half_r_center, v_one_half, fill_height_aux], + [v_one_half, v_one_half, fill_height_aux], + [ + branch_thickness, + branch_thickness, + ctps_mid_height_top, + ], + [ + sep_distance_aux, + aux_column_width, + ctps_mid_height_top, + ], + [v_one_half, aux_column_width, ctps_mid_height_top], + [ + aux_column_width, + sep_distance_aux, + ctps_mid_height_top, + ], + [ + sep_distance_aux, + sep_distance_aux, + ctps_mid_height_top, + ], + [v_one_half, sep_distance_aux, ctps_mid_height_top], + [aux_column_width, v_one_half, ctps_mid_height_top], + [sep_distance_aux, v_one_half, ctps_mid_height_top], + [v_one_half, v_one_half, ctps_mid_height_top], + [branch_thickness, branch_thickness, v_one], + [sep_distance_aux, aux_column_width, v_one], + [v_one_half, aux_column_width, v_one], + [aux_column_width, sep_distance_aux, v_one], + [sep_distance_aux, sep_distance_aux, v_one], + [v_one_half, sep_distance_aux, v_one], + [aux_column_width, v_one_half, v_one], + [sep_distance_aux, v_one_half, v_one], + [v_one_half, v_one_half, v_one], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_max_y_max_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_max_y_max_ctps, + ) ) - ) - - return (spline_list, None) - elif closure == "z_max": - branch_thickness = parameters.flatten()[4] - branch_neighbor_x_min_ctps = _np.array( - [ - [-0.5, -aux_column_width, 0.0], - [-separator_distance, -aux_column_width, 0.0], - [-branch_thickness, -branch_thickness, 0.0], - [-0.5, aux_column_width, 0.0], - [-separator_distance, aux_column_width, 0.0], - [-branch_thickness, branch_thickness, 0.0], - [-0.5, -aux_column_width, ctps_mid_height_bottom], - [ - -separator_distance, - -aux_column_width, - ctps_mid_height_bottom, - ], - [ - -branch_thickness, - -branch_thickness, - ctps_mid_height_bottom, - ], - [-0.5, aux_column_width, ctps_mid_height_bottom], + elif closure == "z_max": + branch_neighbor_x_min_ctps = _np.array( [ - -separator_distance, - aux_column_width, - ctps_mid_height_bottom, - ], - [ - -branch_thickness, - branch_thickness, - ctps_mid_height_bottom, - ], - [-0.5, -r_center, inv_filling_height], - [-half_r_center, -r_center, inv_filling_height], - [-r_center, -r_center, inv_filling_height], - [-0.5, r_center, inv_filling_height], - [-half_r_center, r_center, inv_filling_height], - [-r_center, r_center, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + [-v_one_half, -aux_column_width, v_zero], + [-sep_distance_aux, -aux_column_width, v_zero], + [-branch_thickness, -branch_thickness, v_zero], + [-v_one_half, aux_column_width, v_zero], + [-sep_distance_aux, aux_column_width, v_zero], + [-branch_thickness, branch_thickness, v_zero], + [ + -v_one_half, + -aux_column_width, + ctps_mid_height_bottom, + ], + [ + -sep_distance_aux, + -aux_column_width, + ctps_mid_height_bottom, + ], + [ + -branch_thickness, + -branch_thickness, + ctps_mid_height_bottom, + ], + [ + -v_one_half, + aux_column_width, + ctps_mid_height_bottom, + ], + [ + -sep_distance_aux, + aux_column_width, + ctps_mid_height_bottom, + ], + [ + -branch_thickness, + branch_thickness, + ctps_mid_height_bottom, + ], + [-v_one_half, -r_center, inv_filling_height], + [-half_r_center, -r_center, inv_filling_height], + [-r_center, -r_center, inv_filling_height], + [-v_one_half, r_center, inv_filling_height], + [-half_r_center, r_center, inv_filling_height], + [-r_center, r_center, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 1, 2], - control_points=branch_neighbor_x_min_ctps, + spline_list.append( + _Bezier( + degrees=[2, 1, 2], + control_points=branch_neighbor_x_min_ctps, + ) ) - ) - branch_neighbor_x_max_ctps = _np.array( - [ - [branch_thickness, -branch_thickness, 0.0], - [separator_distance, -aux_column_width, 0.0], - [0.5, -aux_column_width, 0.0], - [branch_thickness, branch_thickness, 0.0], - [separator_distance, aux_column_width, 0.0], - [0.5, aux_column_width, 0.0], - [ - branch_thickness, - -branch_thickness, - ctps_mid_height_bottom, - ], - [ - separator_distance, - -aux_column_width, - ctps_mid_height_bottom, - ], - [0.5, -aux_column_width, ctps_mid_height_bottom], - [ - branch_thickness, - branch_thickness, - ctps_mid_height_bottom, - ], + branch_neighbor_x_max_ctps = _np.array( [ - separator_distance, - aux_column_width, - ctps_mid_height_bottom, - ], - [0.5, aux_column_width, ctps_mid_height_bottom], - [r_center, -r_center, inv_filling_height], - [half_r_center, -r_center, inv_filling_height], - [0.5, -r_center, inv_filling_height], - [r_center, r_center, inv_filling_height], - [half_r_center, r_center, inv_filling_height], - [0.5, r_center, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + [branch_thickness, -branch_thickness, v_zero], + [sep_distance_aux, -aux_column_width, v_zero], + [v_one_half, -aux_column_width, v_zero], + [branch_thickness, branch_thickness, v_zero], + [sep_distance_aux, aux_column_width, v_zero], + [v_one_half, aux_column_width, v_zero], + [ + branch_thickness, + -branch_thickness, + ctps_mid_height_bottom, + ], + [ + sep_distance_aux, + -aux_column_width, + ctps_mid_height_bottom, + ], + [ + v_one_half, + -aux_column_width, + ctps_mid_height_bottom, + ], + [ + branch_thickness, + branch_thickness, + ctps_mid_height_bottom, + ], + [ + sep_distance_aux, + aux_column_width, + ctps_mid_height_bottom, + ], + [v_one_half, aux_column_width, ctps_mid_height_bottom], + [r_center, -r_center, inv_filling_height], + [half_r_center, -r_center, inv_filling_height], + [v_one_half, -r_center, inv_filling_height], + [r_center, r_center, inv_filling_height], + [half_r_center, r_center, inv_filling_height], + [v_one_half, r_center, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 1, 2], - control_points=branch_neighbor_x_max_ctps, + spline_list.append( + _Bezier( + degrees=[2, 1, 2], + control_points=branch_neighbor_x_max_ctps, + ) ) - ) - branch_neighbor_y_min_ctps = _np.array( - [ - [-aux_column_width, -0.5, 0.0], - [aux_column_width, -0.5, 0.0], - [-aux_column_width, -separator_distance, 0.0], - [aux_column_width, -separator_distance, 0.0], - [-branch_thickness, -branch_thickness, 0.0], - [branch_thickness, -branch_thickness, 0.0], - [-aux_column_width, -0.5, ctps_mid_height_bottom], - [aux_column_width, -0.5, ctps_mid_height_bottom], - [ - -aux_column_width, - -separator_distance, - ctps_mid_height_bottom, - ], + branch_neighbor_y_min_ctps = _np.array( [ - aux_column_width, - -separator_distance, - ctps_mid_height_bottom, - ], - [ - -branch_thickness, - -branch_thickness, - ctps_mid_height_bottom, - ], - [ - branch_thickness, - -branch_thickness, - ctps_mid_height_bottom, - ], - [-r_center, -0.5, inv_filling_height], - [r_center, -0.5, inv_filling_height], - [-r_center, -half_r_center, inv_filling_height], - [r_center, -half_r_center, inv_filling_height], - [-r_center, -r_center, inv_filling_height], - [r_center, -r_center, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + [-aux_column_width, -v_one_half, v_zero], + [aux_column_width, -v_one_half, v_zero], + [-aux_column_width, -sep_distance_aux, v_zero], + [aux_column_width, -sep_distance_aux, v_zero], + [-branch_thickness, -branch_thickness, v_zero], + [branch_thickness, -branch_thickness, v_zero], + [ + -aux_column_width, + -v_one_half, + ctps_mid_height_bottom, + ], + [ + aux_column_width, + -v_one_half, + ctps_mid_height_bottom, + ], + [ + -aux_column_width, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + aux_column_width, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + -branch_thickness, + -branch_thickness, + ctps_mid_height_bottom, + ], + [ + branch_thickness, + -branch_thickness, + ctps_mid_height_bottom, + ], + [-r_center, -v_one_half, inv_filling_height], + [r_center, -v_one_half, inv_filling_height], + [-r_center, -half_r_center, inv_filling_height], + [r_center, -half_r_center, inv_filling_height], + [-r_center, -r_center, inv_filling_height], + [r_center, -r_center, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[1, 2, 2], - control_points=branch_neighbor_y_min_ctps, + spline_list.append( + _Bezier( + degrees=[1, 2, 2], + control_points=branch_neighbor_y_min_ctps, + ) ) - ) - branch_neighbor_y_max_ctps = _np.array( - [ - [-branch_thickness, branch_thickness, 0.0], - [branch_thickness, branch_thickness, 0.0], - [-aux_column_width, separator_distance, 0.0], - [aux_column_width, separator_distance, 0.0], - [-aux_column_width, 0.5, 0.0], - [aux_column_width, 0.5, 0.0], + branch_neighbor_y_max_ctps = _np.array( [ - -branch_thickness, - branch_thickness, - ctps_mid_height_bottom, - ], - [ - branch_thickness, - branch_thickness, - ctps_mid_height_bottom, - ], - [ - -aux_column_width, - separator_distance, - ctps_mid_height_bottom, - ], - [ - aux_column_width, - separator_distance, - ctps_mid_height_bottom, - ], - [-aux_column_width, 0.5, ctps_mid_height_bottom], - [aux_column_width, 0.5, ctps_mid_height_bottom], - [-r_center, r_center, inv_filling_height], - [r_center, r_center, inv_filling_height], - [-r_center, half_r_center, inv_filling_height], - [r_center, half_r_center, inv_filling_height], - [-r_center, 0.5, inv_filling_height], - [r_center, 0.5, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + [-branch_thickness, branch_thickness, v_zero], + [branch_thickness, branch_thickness, v_zero], + [-aux_column_width, sep_distance_aux, v_zero], + [aux_column_width, sep_distance_aux, v_zero], + [-aux_column_width, v_one_half, v_zero], + [aux_column_width, v_one_half, v_zero], + [ + -branch_thickness, + branch_thickness, + ctps_mid_height_bottom, + ], + [ + branch_thickness, + branch_thickness, + ctps_mid_height_bottom, + ], + [ + -aux_column_width, + sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + aux_column_width, + sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + -aux_column_width, + v_one_half, + ctps_mid_height_bottom, + ], + [aux_column_width, v_one_half, ctps_mid_height_bottom], + [-r_center, r_center, inv_filling_height], + [r_center, r_center, inv_filling_height], + [-r_center, half_r_center, inv_filling_height], + [r_center, half_r_center, inv_filling_height], + [-r_center, v_one_half, inv_filling_height], + [r_center, v_one_half, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[1, 2, 2], - control_points=branch_neighbor_y_max_ctps, + spline_list.append( + _Bezier( + degrees=[1, 2, 2], + control_points=branch_neighbor_y_max_ctps, + ) ) - ) - branch_x_min_y_min_ctps = _np.array( - [ - [-0.5, -0.5, 0.0], - [-separator_distance, -0.5, 0.0], - [-aux_column_width, -0.5, 0.0], - [-0.5, -separator_distance, 0.0], - [-separator_distance, -separator_distance, 0.0], - [-aux_column_width, -separator_distance, 0.0], - [-0.5, -aux_column_width, 0.0], - [-separator_distance, -aux_column_width, 0.0], - [-branch_thickness, -branch_thickness, 0.0], - [-0.5, -0.5, ctps_mid_height_bottom], - [-separator_distance, -0.5, ctps_mid_height_bottom], - [-aux_column_width, -0.5, ctps_mid_height_bottom], - [-0.5, -separator_distance, ctps_mid_height_bottom], - [ - -separator_distance, - -separator_distance, - ctps_mid_height_bottom, - ], - [ - -aux_column_width, - -separator_distance, - ctps_mid_height_bottom, - ], - [-0.5, -aux_column_width, ctps_mid_height_bottom], - [ - -separator_distance, - -aux_column_width, - ctps_mid_height_bottom, - ], - [ - -branch_thickness, - -branch_thickness, - ctps_mid_height_bottom, - ], - [-0.5, -0.5, inv_filling_height], - [-half_r_center, -0.5, inv_filling_height], - [-r_center, -0.5, inv_filling_height], - [-0.5, -half_r_center, inv_filling_height], - [-half_r_center, -half_r_center, inv_filling_height], - [-r_center, -half_r_center, inv_filling_height], - [-0.5, -r_center, inv_filling_height], - [-half_r_center, -r_center, inv_filling_height], - [-r_center, -r_center, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_min_y_min_ctps = _np.array( + [ + [-v_one_half, -v_one_half, v_zero], + [-sep_distance_aux, -v_one_half, v_zero], + [-aux_column_width, -v_one_half, v_zero], + [-v_one_half, -sep_distance_aux, v_zero], + [-sep_distance_aux, -sep_distance_aux, v_zero], + [-aux_column_width, -sep_distance_aux, v_zero], + [-v_one_half, -aux_column_width, v_zero], + [-sep_distance_aux, -aux_column_width, v_zero], + [-branch_thickness, -branch_thickness, v_zero], + [-v_one_half, -v_one_half, ctps_mid_height_bottom], + [ + -sep_distance_aux, + -v_one_half, + ctps_mid_height_bottom, + ], + [ + -aux_column_width, + -v_one_half, + ctps_mid_height_bottom, + ], + [ + -v_one_half, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + -sep_distance_aux, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + -aux_column_width, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + -v_one_half, + -aux_column_width, + ctps_mid_height_bottom, + ], + [ + -sep_distance_aux, + -aux_column_width, + ctps_mid_height_bottom, + ], + [ + -branch_thickness, + -branch_thickness, + ctps_mid_height_bottom, + ], + [-v_one_half, -v_one_half, inv_filling_height], + [-half_r_center, -v_one_half, inv_filling_height], + [-r_center, -v_one_half, inv_filling_height], + [-v_one_half, -half_r_center, inv_filling_height], + [-half_r_center, -half_r_center, inv_filling_height], + [-r_center, -half_r_center, inv_filling_height], + [-v_one_half, -r_center, inv_filling_height], + [-half_r_center, -r_center, inv_filling_height], + [-r_center, -r_center, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_min_y_min_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_min_y_min_ctps, + ) ) - ) - branch_x_max_y_max_ctps = _np.array( - [ - [branch_thickness, branch_thickness, 0.0], - [separator_distance, aux_column_width, 0.0], - [0.5, aux_column_width, 0.0], - [aux_column_width, separator_distance, 0.0], - [separator_distance, separator_distance, 0.0], - [0.5, separator_distance, 0.0], - [aux_column_width, 0.5, 0.0], - [separator_distance, 0.5, 0.0], - [0.5, 0.5, 0.0], - [ - branch_thickness, - branch_thickness, - ctps_mid_height_bottom, - ], - [ - separator_distance, - aux_column_width, - ctps_mid_height_bottom, - ], - [0.5, aux_column_width, ctps_mid_height_bottom], - [ - aux_column_width, - separator_distance, - ctps_mid_height_bottom, - ], - [ - separator_distance, - separator_distance, - ctps_mid_height_bottom, - ], - [0.5, separator_distance, ctps_mid_height_bottom], - [aux_column_width, 0.5, ctps_mid_height_bottom], - [separator_distance, 0.5, ctps_mid_height_bottom], - [0.5, 0.5, ctps_mid_height_bottom], - [r_center, r_center, inv_filling_height], - [half_r_center, r_center, inv_filling_height], - [0.5, r_center, inv_filling_height], - [r_center, half_r_center, inv_filling_height], - [half_r_center, half_r_center, inv_filling_height], - [0.5, half_r_center, inv_filling_height], - [r_center, 0.5, inv_filling_height], - [half_r_center, 0.5, inv_filling_height], - [0.5, 0.5, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_max_y_max_ctps = _np.array( + [ + [branch_thickness, branch_thickness, v_zero], + [sep_distance_aux, aux_column_width, v_zero], + [v_one_half, aux_column_width, v_zero], + [aux_column_width, sep_distance_aux, v_zero], + [sep_distance_aux, sep_distance_aux, v_zero], + [v_one_half, sep_distance_aux, v_zero], + [aux_column_width, v_one_half, v_zero], + [sep_distance_aux, v_one_half, v_zero], + [v_one_half, v_one_half, v_zero], + [ + branch_thickness, + branch_thickness, + ctps_mid_height_bottom, + ], + [ + sep_distance_aux, + aux_column_width, + ctps_mid_height_bottom, + ], + [v_one_half, aux_column_width, ctps_mid_height_bottom], + [ + aux_column_width, + sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + sep_distance_aux, + sep_distance_aux, + ctps_mid_height_bottom, + ], + [v_one_half, sep_distance_aux, ctps_mid_height_bottom], + [aux_column_width, v_one_half, ctps_mid_height_bottom], + [sep_distance_aux, v_one_half, ctps_mid_height_bottom], + [v_one_half, v_one_half, ctps_mid_height_bottom], + [r_center, r_center, inv_filling_height], + [half_r_center, r_center, inv_filling_height], + [v_one_half, r_center, inv_filling_height], + [r_center, half_r_center, inv_filling_height], + [half_r_center, half_r_center, inv_filling_height], + [v_one_half, half_r_center, inv_filling_height], + [r_center, v_one_half, inv_filling_height], + [half_r_center, v_one_half, inv_filling_height], + [v_one_half, v_one_half, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_max_y_max_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_max_y_max_ctps, + ) ) - ) - branch_x_max_y_min_ctps = _np.array( - [ - [aux_column_width, -0.5, 0.0], - [separator_distance, -0.5, 0.0], - [0.5, -0.5, 0.0], - [aux_column_width, -separator_distance, 0.0], - [separator_distance, -separator_distance, 0.0], - [0.5, -separator_distance, 0.0], - [branch_thickness, -branch_thickness, 0.0], - [separator_distance, -aux_column_width, 0.0], - [0.5, -aux_column_width, 0.0], - [aux_column_width, -0.5, ctps_mid_height_bottom], - [separator_distance, -0.5, ctps_mid_height_bottom], - [0.5, -0.5, ctps_mid_height_bottom], - [ - aux_column_width, - -separator_distance, - ctps_mid_height_bottom, - ], - [ - separator_distance, - -separator_distance, - ctps_mid_height_bottom, - ], - [0.5, -separator_distance, ctps_mid_height_bottom], - [ - branch_thickness, - -branch_thickness, - ctps_mid_height_bottom, - ], - [ - separator_distance, - -aux_column_width, - ctps_mid_height_bottom, - ], - [0.5, -aux_column_width, ctps_mid_height_bottom], - [r_center, -0.5, inv_filling_height], - [half_r_center, -0.5, inv_filling_height], - [0.5, -0.5, inv_filling_height], - [r_center, -half_r_center, inv_filling_height], - [half_r_center, -half_r_center, inv_filling_height], - [0.5, -half_r_center, inv_filling_height], - [r_center, -r_center, inv_filling_height], - [half_r_center, -r_center, inv_filling_height], - [0.5, -r_center, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_max_y_min_ctps = _np.array( + [ + [aux_column_width, -v_one_half, v_zero], + [sep_distance_aux, -v_one_half, v_zero], + [v_one_half, -v_one_half, v_zero], + [aux_column_width, -sep_distance_aux, v_zero], + [sep_distance_aux, -sep_distance_aux, v_zero], + [v_one_half, -sep_distance_aux, v_zero], + [branch_thickness, -branch_thickness, v_zero], + [sep_distance_aux, -aux_column_width, v_zero], + [v_one_half, -aux_column_width, v_zero], + [ + aux_column_width, + -v_one_half, + ctps_mid_height_bottom, + ], + [ + sep_distance_aux, + -v_one_half, + ctps_mid_height_bottom, + ], + [v_one_half, -v_one_half, ctps_mid_height_bottom], + [ + aux_column_width, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + sep_distance_aux, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + v_one_half, + -sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + branch_thickness, + -branch_thickness, + ctps_mid_height_bottom, + ], + [ + sep_distance_aux, + -aux_column_width, + ctps_mid_height_bottom, + ], + [ + v_one_half, + -aux_column_width, + ctps_mid_height_bottom, + ], + [r_center, -v_one_half, inv_filling_height], + [half_r_center, -v_one_half, inv_filling_height], + [v_one_half, -v_one_half, inv_filling_height], + [r_center, -half_r_center, inv_filling_height], + [half_r_center, -half_r_center, inv_filling_height], + [v_one_half, -half_r_center, inv_filling_height], + [r_center, -r_center, inv_filling_height], + [half_r_center, -r_center, inv_filling_height], + [v_one_half, -r_center, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_max_y_min_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_max_y_min_ctps, + ) ) - ) - branch_x_min_y_max_ctps = _np.array( - [ - [-0.5, aux_column_width, 0.0], - [-separator_distance, aux_column_width, 0.0], - [-branch_thickness, branch_thickness, 0.0], - [-0.5, separator_distance, 0.0], - [-separator_distance, separator_distance, 0.0], - [-aux_column_width, separator_distance, 0.0], - [-0.5, 0.5, 0.0], - [-separator_distance, 0.5, 0.0], - [-aux_column_width, 0.5, 0.0], - [-0.5, aux_column_width, ctps_mid_height_bottom], - [ - -separator_distance, - aux_column_width, - ctps_mid_height_bottom, - ], - [ - -branch_thickness, - branch_thickness, - ctps_mid_height_bottom, - ], - [-0.5, separator_distance, ctps_mid_height_bottom], - [ - -separator_distance, - separator_distance, - ctps_mid_height_bottom, - ], - [ - -aux_column_width, - separator_distance, - ctps_mid_height_bottom, - ], - [-0.5, 0.5, ctps_mid_height_bottom], - [-separator_distance, 0.5, ctps_mid_height_bottom], - [-aux_column_width, 0.5, ctps_mid_height_bottom], - [-0.5, r_center, inv_filling_height], - [-half_r_center, r_center, inv_filling_height], - [-r_center, r_center, inv_filling_height], - [-0.5, half_r_center, inv_filling_height], - [-half_r_center, half_r_center, inv_filling_height], - [-r_center, half_r_center, inv_filling_height], - [-0.5, 0.5, inv_filling_height], - [-half_r_center, 0.5, inv_filling_height], - [-r_center, 0.5, inv_filling_height], - ] - ) + _np.array([0.5, 0.5, 0.0]) + branch_x_min_y_max_ctps = _np.array( + [ + [-v_one_half, aux_column_width, v_zero], + [-sep_distance_aux, aux_column_width, v_zero], + [-branch_thickness, branch_thickness, v_zero], + [-v_one_half, sep_distance_aux, v_zero], + [-sep_distance_aux, sep_distance_aux, v_zero], + [-aux_column_width, sep_distance_aux, v_zero], + [-v_one_half, v_one_half, v_zero], + [-sep_distance_aux, v_one_half, v_zero], + [-aux_column_width, v_one_half, v_zero], + [ + -v_one_half, + aux_column_width, + ctps_mid_height_bottom, + ], + [ + -sep_distance_aux, + aux_column_width, + ctps_mid_height_bottom, + ], + [ + -branch_thickness, + branch_thickness, + ctps_mid_height_bottom, + ], + [ + -v_one_half, + sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + -sep_distance_aux, + sep_distance_aux, + ctps_mid_height_bottom, + ], + [ + -aux_column_width, + sep_distance_aux, + ctps_mid_height_bottom, + ], + [-v_one_half, v_one_half, ctps_mid_height_bottom], + [ + -sep_distance_aux, + v_one_half, + ctps_mid_height_bottom, + ], + [ + -aux_column_width, + v_one_half, + ctps_mid_height_bottom, + ], + [-v_one_half, r_center, inv_filling_height], + [-half_r_center, r_center, inv_filling_height], + [-r_center, r_center, inv_filling_height], + [-v_one_half, half_r_center, inv_filling_height], + [-half_r_center, half_r_center, inv_filling_height], + [-r_center, half_r_center, inv_filling_height], + [-v_one_half, v_one_half, inv_filling_height], + [-half_r_center, v_one_half, inv_filling_height], + [-r_center, v_one_half, inv_filling_height], + ] + ) + _np.array([v_one_half, v_one_half, v_zero]) - spline_list.append( - _Bezier( - degrees=[2, 2, 2], control_points=branch_x_min_y_max_ctps + spline_list.append( + _Bezier( + degrees=[2, 2, 2], + control_points=branch_x_min_y_max_ctps, + ) ) - ) + else: + raise ValueError("Corner Type not supported") - return (spline_list, None) - else: - raise ValueError("Corner Type not supported") + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) + + return (splines, derivatives) def create_tile( self, @@ -922,7 +1070,7 @@ def create_tile( """ if not isinstance(center_expansion, float): - raise ValueError("Invalid Type") + raise ValueError("Invalid type for center_expansion") if not ((center_expansion > 0.5) and (center_expansion < 1.5)): raise ValueError("Center Expansion must be in (.5, 1.5)") @@ -942,16 +1090,17 @@ def create_tile( * 0.2 ) + self.check_params(parameters) + if parameter_sensitivities is not None: + self.check_param_derivatives(parameter_sensitivities) + n_derivatives = parameter_sensitivities.shape[2] derivatives = [] else: n_derivatives = 0 derivatives = None - self.check_params(parameters) - self.check_param_derivatives(parameter_sensitivities) - if _np.any(parameters < min_radius) or _np.any( parameters > max_radius ): @@ -999,6 +1148,8 @@ def create_tile( v_one_half = 0.5 center_point = _np.array([0.5, 0.5, 0.5]) + + sep_distance = separator_distance else: sensitivities_i = parameter_sensitivities[ :, 0, i_derivative - 1 @@ -1032,6 +1183,8 @@ def create_tile( v_one_half = 0.0 center_point = _np.zeros(3) + sep_distance = 0.0 + # Init return type spline_list = [] @@ -1040,18 +1193,18 @@ def create_tile( _np.array( [ [-v_one_half, -v_one_half, -aux_column_width], - [-separator_distance, -v_one_half, -aux_column_width], + [-sep_distance, -v_one_half, -aux_column_width], [-y_min_r, -v_one_half, -y_min_r], - [-v_one_half, -separator_distance, -aux_column_width], + [-v_one_half, -sep_distance, -aux_column_width], [-hd_center, -hd_center, -aux_column_width], [-aux_y_min, -hd_center, -aux_y_min], [-v_one_half, -x_min_r, -x_min_r], [-hd_center, -aux_x_min, -aux_x_min], [-center_r, -center_r, -center_r], [-v_one_half, -v_one_half, aux_column_width], - [-separator_distance, -v_one_half, aux_column_width], + [-sep_distance, -v_one_half, aux_column_width], [-y_min_r, -v_one_half, y_min_r], - [-v_one_half, -separator_distance, aux_column_width], + [-v_one_half, -sep_distance, aux_column_width], [-hd_center, -hd_center, aux_column_width], [-aux_y_min, -hd_center, aux_y_min], [-v_one_half, -x_min_r, x_min_r], @@ -1066,20 +1219,20 @@ def create_tile( _np.array( [ [y_min_r, -v_one_half, -y_min_r], - [separator_distance, -v_one_half, -aux_column_width], + [sep_distance, -v_one_half, -aux_column_width], [v_one_half, -v_one_half, -aux_column_width], [aux_y_min, -hd_center, -aux_y_min], [hd_center, -hd_center, -aux_column_width], - [v_one_half, -separator_distance, -aux_column_width], + [v_one_half, -sep_distance, -aux_column_width], [center_r, -center_r, -center_r], [hd_center, -aux_x_max, -aux_x_max], [v_one_half, -x_max_r, -x_max_r], [y_min_r, -v_one_half, y_min_r], - [separator_distance, -v_one_half, aux_column_width], + [sep_distance, -v_one_half, aux_column_width], [v_one_half, -v_one_half, aux_column_width], [aux_y_min, -hd_center, aux_y_min], [hd_center, -hd_center, aux_column_width], - [v_one_half, -separator_distance, aux_column_width], + [v_one_half, -sep_distance, aux_column_width], [center_r, -center_r, center_r], [hd_center, -aux_x_max, aux_x_max], [v_one_half, -x_max_r, x_max_r], @@ -1094,20 +1247,20 @@ def create_tile( [-v_one_half, x_min_r, -x_min_r], [-hd_center, aux_x_min, -aux_x_min], [-center_r, center_r, -center_r], - [-v_one_half, separator_distance, -aux_column_width], + [-v_one_half, sep_distance, -aux_column_width], [-hd_center, hd_center, -aux_column_width], [-aux_y_max, hd_center, -aux_y_max], [-v_one_half, v_one_half, -aux_column_width], - [-separator_distance, v_one_half, -aux_column_width], + [-sep_distance, v_one_half, -aux_column_width], [-y_max_r, v_one_half, -y_max_r], [-v_one_half, x_min_r, x_min_r], [-hd_center, aux_x_min, aux_x_min], [-center_r, center_r, center_r], - [-v_one_half, separator_distance, aux_column_width], + [-v_one_half, sep_distance, aux_column_width], [-hd_center, hd_center, aux_column_width], [-aux_y_max, hd_center, aux_y_max], [-v_one_half, v_one_half, aux_column_width], - [-separator_distance, v_one_half, aux_column_width], + [-sep_distance, v_one_half, aux_column_width], [-y_max_r, v_one_half, y_max_r], ] ) @@ -1122,18 +1275,18 @@ def create_tile( [v_one_half, x_max_r, -x_max_r], [aux_y_max, hd_center, -aux_y_max], [hd_center, hd_center, -aux_column_width], - [v_one_half, separator_distance, -aux_column_width], + [v_one_half, sep_distance, -aux_column_width], [y_max_r, v_one_half, -y_max_r], - [separator_distance, v_one_half, -aux_column_width], + [sep_distance, v_one_half, -aux_column_width], [v_one_half, v_one_half, -aux_column_width], [center_r, center_r, center_r], [hd_center, aux_x_max, aux_x_max], [v_one_half, x_max_r, x_max_r], [aux_y_max, hd_center, aux_y_max], [hd_center, hd_center, aux_column_width], - [v_one_half, separator_distance, aux_column_width], + [v_one_half, sep_distance, aux_column_width], [y_max_r, v_one_half, y_max_r], - [separator_distance, v_one_half, aux_column_width], + [sep_distance, v_one_half, aux_column_width], [v_one_half, v_one_half, aux_column_width], ] ) @@ -1144,15 +1297,15 @@ def create_tile( _np.array( [ [-v_one_half, -aux_column_width, -v_one_half], - [-separator_distance, -aux_column_width, -v_one_half], + [-sep_distance, -aux_column_width, -v_one_half], [-z_min_r, -z_min_r, -v_one_half], [-v_one_half, aux_column_width, -v_one_half], - [-separator_distance, aux_column_width, -v_one_half], + [-sep_distance, aux_column_width, -v_one_half], [-z_min_r, z_min_r, -v_one_half], - [-v_one_half, -aux_column_width, -separator_distance], + [-v_one_half, -aux_column_width, -sep_distance], [-hd_center, -aux_column_width, -hd_center], [-aux_z_min, -aux_z_min, -hd_center], - [-v_one_half, aux_column_width, -separator_distance], + [-v_one_half, aux_column_width, -sep_distance], [-hd_center, aux_column_width, -hd_center], [-aux_z_min, aux_z_min, -hd_center], [-v_one_half, -x_min_r, -x_min_r], @@ -1170,17 +1323,17 @@ def create_tile( _np.array( [ [z_min_r, -z_min_r, -v_one_half], - [separator_distance, -aux_column_width, -v_one_half], + [sep_distance, -aux_column_width, -v_one_half], [v_one_half, -aux_column_width, -v_one_half], [z_min_r, z_min_r, -v_one_half], - [separator_distance, aux_column_width, -v_one_half], + [sep_distance, aux_column_width, -v_one_half], [v_one_half, aux_column_width, -v_one_half], [aux_z_min, -aux_z_min, -hd_center], [hd_center, -aux_column_width, -hd_center], - [v_one_half, -aux_column_width, -separator_distance], + [v_one_half, -aux_column_width, -sep_distance], [aux_z_min, aux_z_min, -hd_center], [hd_center, aux_column_width, -hd_center], - [v_one_half, aux_column_width, -separator_distance], + [v_one_half, aux_column_width, -sep_distance], [center_r, -center_r, -center_r], [hd_center, -aux_x_max, -aux_x_max], [v_one_half, -x_max_r, -x_max_r], @@ -1201,17 +1354,17 @@ def create_tile( [-v_one_half, x_min_r, x_min_r], [-hd_center, aux_x_min, aux_x_min], [-center_r, center_r, center_r], - [-v_one_half, -aux_column_width, separator_distance], + [-v_one_half, -aux_column_width, sep_distance], [-hd_center, -aux_column_width, hd_center], [-aux_z_max, -aux_z_max, hd_center], - [-v_one_half, aux_column_width, separator_distance], + [-v_one_half, aux_column_width, sep_distance], [-hd_center, aux_column_width, hd_center], [-aux_z_max, aux_z_max, hd_center], [-v_one_half, -aux_column_width, v_one_half], - [-separator_distance, -aux_column_width, v_one_half], + [-sep_distance, -aux_column_width, v_one_half], [-z_max_r, -z_max_r, v_one_half], [-v_one_half, aux_column_width, v_one_half], - [-separator_distance, aux_column_width, v_one_half], + [-sep_distance, aux_column_width, v_one_half], [-z_max_r, z_max_r, v_one_half], ] ) @@ -1229,15 +1382,15 @@ def create_tile( [v_one_half, x_max_r, x_max_r], [aux_z_max, -aux_z_max, hd_center], [hd_center, -aux_column_width, hd_center], - [v_one_half, -aux_column_width, separator_distance], + [v_one_half, -aux_column_width, sep_distance], [aux_z_max, aux_z_max, hd_center], [hd_center, aux_column_width, hd_center], - [v_one_half, aux_column_width, separator_distance], + [v_one_half, aux_column_width, sep_distance], [z_max_r, -z_max_r, v_one_half], - [separator_distance, -aux_column_width, v_one_half], + [sep_distance, -aux_column_width, v_one_half], [v_one_half, -aux_column_width, v_one_half], [z_max_r, z_max_r, v_one_half], - [separator_distance, aux_column_width, v_one_half], + [sep_distance, aux_column_width, v_one_half], [v_one_half, aux_column_width, v_one_half], ] ) @@ -1249,12 +1402,12 @@ def create_tile( [ [-aux_column_width, -v_one_half, -v_one_half], [aux_column_width, -v_one_half, -v_one_half], - [-aux_column_width, -separator_distance, -v_one_half], - [aux_column_width, -separator_distance, -v_one_half], + [-aux_column_width, -sep_distance, -v_one_half], + [aux_column_width, -sep_distance, -v_one_half], [-z_min_r, -z_min_r, -v_one_half], [z_min_r, -z_min_r, -v_one_half], - [-aux_column_width, -v_one_half, -separator_distance], - [aux_column_width, -v_one_half, -separator_distance], + [-aux_column_width, -v_one_half, -sep_distance], + [aux_column_width, -v_one_half, -sep_distance], [-aux_column_width, -hd_center, -hd_center], [aux_column_width, -hd_center, -hd_center], [-aux_z_min, -aux_z_min, -hd_center], @@ -1275,16 +1428,16 @@ def create_tile( [ [-z_min_r, z_min_r, -v_one_half], [z_min_r, z_min_r, -v_one_half], - [-aux_column_width, separator_distance, -v_one_half], - [aux_column_width, separator_distance, -v_one_half], + [-aux_column_width, sep_distance, -v_one_half], + [aux_column_width, sep_distance, -v_one_half], [-aux_column_width, v_one_half, -v_one_half], [aux_column_width, v_one_half, -v_one_half], [-aux_z_min, aux_z_min, -hd_center], [aux_z_min, aux_z_min, -hd_center], [-aux_column_width, hd_center, -hd_center], [aux_column_width, hd_center, -hd_center], - [-aux_column_width, v_one_half, -separator_distance], - [aux_column_width, v_one_half, -separator_distance], + [-aux_column_width, v_one_half, -sep_distance], + [aux_column_width, v_one_half, -sep_distance], [-center_r, center_r, -center_r], [center_r, center_r, -center_r], [-aux_y_max, hd_center, -aux_y_max], @@ -1305,16 +1458,16 @@ def create_tile( [aux_y_min, -hd_center, aux_y_min], [-center_r, -center_r, center_r], [center_r, -center_r, center_r], - [-aux_column_width, -v_one_half, separator_distance], - [aux_column_width, -v_one_half, separator_distance], + [-aux_column_width, -v_one_half, sep_distance], + [aux_column_width, -v_one_half, sep_distance], [-aux_column_width, -hd_center, hd_center], [aux_column_width, -hd_center, hd_center], [-aux_z_max, -aux_z_max, hd_center], [aux_z_max, -aux_z_max, hd_center], [-aux_column_width, -v_one_half, v_one_half], [aux_column_width, -v_one_half, v_one_half], - [-aux_column_width, -separator_distance, v_one_half], - [aux_column_width, -separator_distance, v_one_half], + [-aux_column_width, -sep_distance, v_one_half], + [aux_column_width, -sep_distance, v_one_half], [-z_max_r, -z_max_r, v_one_half], [z_max_r, -z_max_r, v_one_half], ] @@ -1335,12 +1488,12 @@ def create_tile( [aux_z_max, aux_z_max, hd_center], [-aux_column_width, hd_center, hd_center], [aux_column_width, hd_center, hd_center], - [-aux_column_width, v_one_half, separator_distance], - [aux_column_width, v_one_half, separator_distance], + [-aux_column_width, v_one_half, sep_distance], + [aux_column_width, v_one_half, sep_distance], [-z_max_r, z_max_r, v_one_half], [z_max_r, z_max_r, v_one_half], - [-aux_column_width, separator_distance, v_one_half], - [aux_column_width, separator_distance, v_one_half], + [-aux_column_width, sep_distance, v_one_half], + [aux_column_width, sep_distance, v_one_half], [-aux_column_width, v_one_half, v_one_half], [aux_column_width, v_one_half, v_one_half], ] @@ -1352,39 +1505,39 @@ def create_tile( _np.array( [ [-v_one_half, -v_one_half, -v_one_half], - [-separator_distance, -v_one_half, -v_one_half], + [-sep_distance, -v_one_half, -v_one_half], [-aux_column_width, -v_one_half, -v_one_half], - [-v_one_half, -separator_distance, -v_one_half], + [-v_one_half, -sep_distance, -v_one_half], [ - -separator_distance, - -separator_distance, + -sep_distance, + -sep_distance, -v_one_half, ], - [-aux_column_width, -separator_distance, -v_one_half], + [-aux_column_width, -sep_distance, -v_one_half], [-v_one_half, -aux_column_width, -v_one_half], - [-separator_distance, -aux_column_width, -v_one_half], + [-sep_distance, -aux_column_width, -v_one_half], [-z_min_r, -z_min_r, -v_one_half], - [-v_one_half, -v_one_half, -separator_distance], + [-v_one_half, -v_one_half, -sep_distance], [ - -separator_distance, + -sep_distance, -v_one_half, - -separator_distance, + -sep_distance, ], - [-aux_column_width, -v_one_half, -separator_distance], + [-aux_column_width, -v_one_half, -sep_distance], [ -v_one_half, - -separator_distance, - -separator_distance, + -sep_distance, + -sep_distance, ], [-hd_center, -hd_center, -hd_center], [-aux_column_width, -hd_center, -hd_center], - [-v_one_half, -aux_column_width, -separator_distance], + [-v_one_half, -aux_column_width, -sep_distance], [-hd_center, -aux_column_width, -hd_center], [-aux_z_min, -aux_z_min, -hd_center], [-v_one_half, -v_one_half, -aux_column_width], - [-separator_distance, -v_one_half, -aux_column_width], + [-sep_distance, -v_one_half, -aux_column_width], [-y_min_r, -v_one_half, -y_min_r], - [-v_one_half, -separator_distance, -aux_column_width], + [-v_one_half, -sep_distance, -aux_column_width], [-hd_center, -hd_center, -aux_column_width], [-aux_y_min, -hd_center, -aux_y_min], [-v_one_half, -x_min_r, -x_min_r], @@ -1399,29 +1552,29 @@ def create_tile( _np.array( [ [aux_column_width, -v_one_half, -v_one_half], - [separator_distance, -v_one_half, -v_one_half], + [sep_distance, -v_one_half, -v_one_half], [v_one_half, -v_one_half, -v_one_half], - [aux_column_width, -separator_distance, -v_one_half], - [separator_distance, -separator_distance, -v_one_half], - [v_one_half, -separator_distance, -v_one_half], + [aux_column_width, -sep_distance, -v_one_half], + [sep_distance, -sep_distance, -v_one_half], + [v_one_half, -sep_distance, -v_one_half], [z_min_r, -z_min_r, -v_one_half], - [separator_distance, -aux_column_width, -v_one_half], + [sep_distance, -aux_column_width, -v_one_half], [v_one_half, -aux_column_width, -v_one_half], - [aux_column_width, -v_one_half, -separator_distance], - [separator_distance, -v_one_half, -separator_distance], - [v_one_half, -v_one_half, -separator_distance], + [aux_column_width, -v_one_half, -sep_distance], + [sep_distance, -v_one_half, -sep_distance], + [v_one_half, -v_one_half, -sep_distance], [aux_column_width, -hd_center, -hd_center], [hd_center, -hd_center, -hd_center], - [v_one_half, -separator_distance, -separator_distance], + [v_one_half, -sep_distance, -sep_distance], [aux_z_min, -aux_z_min, -hd_center], [hd_center, -aux_column_width, -hd_center], - [v_one_half, -aux_column_width, -separator_distance], + [v_one_half, -aux_column_width, -sep_distance], [y_min_r, -v_one_half, -y_min_r], - [separator_distance, -v_one_half, -aux_column_width], + [sep_distance, -v_one_half, -aux_column_width], [v_one_half, -v_one_half, -aux_column_width], [aux_y_min, -hd_center, -aux_y_min], [hd_center, -hd_center, -aux_column_width], - [v_one_half, -separator_distance, -aux_column_width], + [v_one_half, -sep_distance, -aux_column_width], [center_r, -center_r, -center_r], [hd_center, -aux_x_max, -aux_x_max], [v_one_half, -x_max_r, -x_max_r], @@ -1434,31 +1587,31 @@ def create_tile( _np.array( [ [-v_one_half, aux_column_width, -v_one_half], - [-separator_distance, aux_column_width, -v_one_half], + [-sep_distance, aux_column_width, -v_one_half], [-z_min_r, z_min_r, -v_one_half], - [-v_one_half, separator_distance, -v_one_half], - [-separator_distance, separator_distance, -v_one_half], - [-aux_column_width, separator_distance, -v_one_half], + [-v_one_half, sep_distance, -v_one_half], + [-sep_distance, sep_distance, -v_one_half], + [-aux_column_width, sep_distance, -v_one_half], [-v_one_half, v_one_half, -v_one_half], - [-separator_distance, v_one_half, -v_one_half], + [-sep_distance, v_one_half, -v_one_half], [-aux_column_width, v_one_half, -v_one_half], - [-v_one_half, aux_column_width, -separator_distance], + [-v_one_half, aux_column_width, -sep_distance], [-hd_center, aux_column_width, -hd_center], [-aux_z_min, aux_z_min, -hd_center], - [-v_one_half, separator_distance, -separator_distance], + [-v_one_half, sep_distance, -sep_distance], [-hd_center, hd_center, -hd_center], [-aux_column_width, hd_center, -hd_center], - [-v_one_half, v_one_half, -separator_distance], - [-separator_distance, v_one_half, -separator_distance], - [-aux_column_width, v_one_half, -separator_distance], + [-v_one_half, v_one_half, -sep_distance], + [-sep_distance, v_one_half, -sep_distance], + [-aux_column_width, v_one_half, -sep_distance], [-v_one_half, x_min_r, -x_min_r], [-hd_center, aux_x_min, -aux_x_min], [-center_r, center_r, -center_r], - [-v_one_half, separator_distance, -aux_column_width], + [-v_one_half, sep_distance, -aux_column_width], [-hd_center, hd_center, -aux_column_width], [-aux_y_max, hd_center, -aux_y_max], [-v_one_half, v_one_half, -aux_column_width], - [-separator_distance, v_one_half, -aux_column_width], + [-sep_distance, v_one_half, -aux_column_width], [-y_max_r, v_one_half, -y_max_r], ] ) @@ -1469,31 +1622,31 @@ def create_tile( _np.array( [ [z_min_r, z_min_r, -v_one_half], - [separator_distance, aux_column_width, -v_one_half], + [sep_distance, aux_column_width, -v_one_half], [v_one_half, aux_column_width, -v_one_half], - [aux_column_width, separator_distance, -v_one_half], - [separator_distance, separator_distance, -v_one_half], - [v_one_half, separator_distance, -v_one_half], + [aux_column_width, sep_distance, -v_one_half], + [sep_distance, sep_distance, -v_one_half], + [v_one_half, sep_distance, -v_one_half], [aux_column_width, v_one_half, -v_one_half], - [separator_distance, v_one_half, -v_one_half], + [sep_distance, v_one_half, -v_one_half], [v_one_half, v_one_half, -v_one_half], [aux_z_min, aux_z_min, -hd_center], [hd_center, aux_column_width, -hd_center], - [v_one_half, aux_column_width, -separator_distance], + [v_one_half, aux_column_width, -sep_distance], [aux_column_width, hd_center, -hd_center], [hd_center, hd_center, -hd_center], - [v_one_half, separator_distance, -separator_distance], - [aux_column_width, v_one_half, -separator_distance], - [separator_distance, v_one_half, -separator_distance], - [v_one_half, v_one_half, -separator_distance], + [v_one_half, sep_distance, -sep_distance], + [aux_column_width, v_one_half, -sep_distance], + [sep_distance, v_one_half, -sep_distance], + [v_one_half, v_one_half, -sep_distance], [center_r, center_r, -center_r], [hd_center, aux_x_max, -aux_x_max], [v_one_half, x_max_r, -x_max_r], [aux_y_max, hd_center, -aux_y_max], [hd_center, hd_center, -aux_column_width], - [v_one_half, separator_distance, -aux_column_width], + [v_one_half, sep_distance, -aux_column_width], [y_max_r, v_one_half, -y_max_r], - [separator_distance, v_one_half, -aux_column_width], + [sep_distance, v_one_half, -aux_column_width], [v_one_half, v_one_half, -aux_column_width], ] ) @@ -1504,31 +1657,31 @@ def create_tile( _np.array( [ [-v_one_half, -v_one_half, aux_column_width], - [-separator_distance, -v_one_half, aux_column_width], + [-sep_distance, -v_one_half, aux_column_width], [-y_min_r, -v_one_half, y_min_r], - [-v_one_half, -separator_distance, aux_column_width], + [-v_one_half, -sep_distance, aux_column_width], [-hd_center, -hd_center, aux_column_width], [-aux_y_min, -hd_center, aux_y_min], [-v_one_half, -x_min_r, x_min_r], [-hd_center, -aux_x_min, aux_x_min], [-center_r, -center_r, center_r], - [-v_one_half, -v_one_half, separator_distance], - [-separator_distance, -v_one_half, separator_distance], - [-aux_column_width, -v_one_half, separator_distance], - [-v_one_half, -separator_distance, separator_distance], + [-v_one_half, -v_one_half, sep_distance], + [-sep_distance, -v_one_half, sep_distance], + [-aux_column_width, -v_one_half, sep_distance], + [-v_one_half, -sep_distance, sep_distance], [-hd_center, -hd_center, hd_center], [-aux_column_width, -hd_center, hd_center], - [-v_one_half, -aux_column_width, separator_distance], + [-v_one_half, -aux_column_width, sep_distance], [-hd_center, -aux_column_width, hd_center], [-aux_z_max, -aux_z_max, hd_center], [-v_one_half, -v_one_half, v_one_half], - [-separator_distance, -v_one_half, v_one_half], + [-sep_distance, -v_one_half, v_one_half], [-aux_column_width, -v_one_half, v_one_half], - [-v_one_half, -separator_distance, v_one_half], - [-separator_distance, -separator_distance, v_one_half], - [-aux_column_width, -separator_distance, v_one_half], + [-v_one_half, -sep_distance, v_one_half], + [-sep_distance, -sep_distance, v_one_half], + [-aux_column_width, -sep_distance, v_one_half], [-v_one_half, -aux_column_width, v_one_half], - [-separator_distance, -aux_column_width, v_one_half], + [-sep_distance, -aux_column_width, v_one_half], [-z_max_r, -z_max_r, v_one_half], ] ) @@ -1539,31 +1692,31 @@ def create_tile( _np.array( [ [y_min_r, -v_one_half, y_min_r], - [separator_distance, -v_one_half, aux_column_width], + [sep_distance, -v_one_half, aux_column_width], [v_one_half, -v_one_half, aux_column_width], [aux_y_min, -hd_center, aux_y_min], [hd_center, -hd_center, aux_column_width], - [v_one_half, -separator_distance, aux_column_width], + [v_one_half, -sep_distance, aux_column_width], [center_r, -center_r, center_r], [hd_center, -aux_x_max, aux_x_max], [v_one_half, -x_max_r, x_max_r], - [aux_column_width, -v_one_half, separator_distance], - [separator_distance, -v_one_half, separator_distance], - [v_one_half, -v_one_half, separator_distance], + [aux_column_width, -v_one_half, sep_distance], + [sep_distance, -v_one_half, sep_distance], + [v_one_half, -v_one_half, sep_distance], [aux_column_width, -hd_center, hd_center], [hd_center, -hd_center, hd_center], - [v_one_half, -separator_distance, separator_distance], + [v_one_half, -sep_distance, sep_distance], [aux_z_max, -aux_z_max, hd_center], [hd_center, -aux_column_width, hd_center], - [v_one_half, -aux_column_width, separator_distance], + [v_one_half, -aux_column_width, sep_distance], [aux_column_width, -v_one_half, v_one_half], - [separator_distance, -v_one_half, v_one_half], + [sep_distance, -v_one_half, v_one_half], [v_one_half, -v_one_half, v_one_half], - [aux_column_width, -separator_distance, v_one_half], - [separator_distance, -separator_distance, v_one_half], - [v_one_half, -separator_distance, v_one_half], + [aux_column_width, -sep_distance, v_one_half], + [sep_distance, -sep_distance, v_one_half], + [v_one_half, -sep_distance, v_one_half], [z_max_r, -z_max_r, v_one_half], - [separator_distance, -aux_column_width, v_one_half], + [sep_distance, -aux_column_width, v_one_half], [v_one_half, -aux_column_width, v_one_half], ] ) @@ -1576,29 +1729,29 @@ def create_tile( [-v_one_half, x_min_r, x_min_r], [-hd_center, aux_x_min, aux_x_min], [-center_r, center_r, center_r], - [-v_one_half, separator_distance, aux_column_width], + [-v_one_half, sep_distance, aux_column_width], [-hd_center, hd_center, aux_column_width], [-aux_y_max, hd_center, aux_y_max], [-v_one_half, v_one_half, aux_column_width], - [-separator_distance, v_one_half, aux_column_width], + [-sep_distance, v_one_half, aux_column_width], [-y_max_r, v_one_half, y_max_r], - [-v_one_half, aux_column_width, separator_distance], + [-v_one_half, aux_column_width, sep_distance], [-hd_center, aux_column_width, hd_center], [-aux_z_max, aux_z_max, hd_center], - [-v_one_half, separator_distance, separator_distance], + [-v_one_half, sep_distance, sep_distance], [-hd_center, hd_center, hd_center], [-aux_column_width, hd_center, hd_center], - [-v_one_half, v_one_half, separator_distance], - [-separator_distance, v_one_half, separator_distance], - [-aux_column_width, v_one_half, separator_distance], + [-v_one_half, v_one_half, sep_distance], + [-sep_distance, v_one_half, sep_distance], + [-aux_column_width, v_one_half, sep_distance], [-v_one_half, aux_column_width, v_one_half], - [-separator_distance, aux_column_width, v_one_half], + [-sep_distance, aux_column_width, v_one_half], [-z_max_r, z_max_r, v_one_half], - [-v_one_half, separator_distance, v_one_half], - [-separator_distance, separator_distance, v_one_half], - [-aux_column_width, separator_distance, v_one_half], + [-v_one_half, sep_distance, v_one_half], + [-sep_distance, sep_distance, v_one_half], + [-aux_column_width, sep_distance, v_one_half], [-v_one_half, v_one_half, v_one_half], - [-separator_distance, v_one_half, v_one_half], + [-sep_distance, v_one_half, v_one_half], [-aux_column_width, v_one_half, v_one_half], ] ) @@ -1613,27 +1766,27 @@ def create_tile( [v_one_half, x_max_r, x_max_r], [aux_y_max, hd_center, aux_y_max], [hd_center, hd_center, aux_column_width], - [v_one_half, separator_distance, aux_column_width], + [v_one_half, sep_distance, aux_column_width], [y_max_r, v_one_half, y_max_r], - [separator_distance, v_one_half, aux_column_width], + [sep_distance, v_one_half, aux_column_width], [v_one_half, v_one_half, aux_column_width], [aux_z_max, aux_z_max, hd_center], [hd_center, aux_column_width, hd_center], - [v_one_half, aux_column_width, separator_distance], + [v_one_half, aux_column_width, sep_distance], [aux_column_width, hd_center, hd_center], [hd_center, hd_center, hd_center], - [v_one_half, separator_distance, separator_distance], - [aux_column_width, v_one_half, separator_distance], - [separator_distance, v_one_half, separator_distance], - [v_one_half, v_one_half, separator_distance], + [v_one_half, sep_distance, sep_distance], + [aux_column_width, v_one_half, sep_distance], + [sep_distance, v_one_half, sep_distance], + [v_one_half, v_one_half, sep_distance], [z_max_r, z_max_r, v_one_half], - [separator_distance, aux_column_width, v_one_half], + [sep_distance, aux_column_width, v_one_half], [v_one_half, aux_column_width, v_one_half], - [aux_column_width, separator_distance, v_one_half], - [separator_distance, separator_distance, v_one_half], - [v_one_half, separator_distance, v_one_half], + [aux_column_width, sep_distance, v_one_half], + [sep_distance, sep_distance, v_one_half], + [v_one_half, sep_distance, v_one_half], [aux_column_width, v_one_half, v_one_half], - [separator_distance, v_one_half, v_one_half], + [sep_distance, v_one_half, v_one_half], [v_one_half, v_one_half, v_one_half], ] ) @@ -1671,5 +1824,4 @@ def create_tile( splines = spline_list.copy() else: derivatives.append(spline_list) - - return splines, derivatives + return (splines, derivatives) diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index edaf0b477..339efd219 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -189,11 +189,7 @@ def test_tile_derivatives(np_rng, heps=1e-8, n_test_points=4): Number of testing points in the parametric domain """ # TODO: right now EllipsVoid, CubeVoid and InverseCross show wrong derivatives - skip_classes = [ - ms.tiles.EllipsVoid, - ms.tiles.CubeVoid, - ms.tiles.InverseCross3D, - ] + skip_classes = [ms.tiles.EllipsVoid, ms.tiles.CubeVoid] for tile_class in all_tile_classes: # TODO: right now skip classes with faultily implemented derivatives @@ -273,7 +269,7 @@ def test_tile_derivatives(np_rng, heps=1e-8, n_test_points=4): ): assert np.allclose(deriv_orig, deriv_fd), ( "Implemented derivative calculation for tile class" - + f"{tile_class}, parameter " + + f"{tile_class}, with closure {closure}, parameter " + f"{i_parameter+1}/{n_info_per_eval_point} at patch " + f"{i_patch+1}/{n_patches} does not match the derivative " + "obtained using Finite Differences" From 61b384652d5f17cb6095824b7319c88431f8c86d Mon Sep 17 00:00:00 2001 From: markriegler Date: Wed, 9 Oct 2024 16:53:32 +0200 Subject: [PATCH 18/23] Fix CubeVoid derivatives --- splinepy/microstructure/tiles/cube_void.py | 2 +- tests/test_microstructure.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/splinepy/microstructure/tiles/cube_void.py b/splinepy/microstructure/tiles/cube_void.py index c435b6a88..9eeb3a33b 100644 --- a/splinepy/microstructure/tiles/cube_void.py +++ b/splinepy/microstructure/tiles/cube_void.py @@ -64,7 +64,7 @@ def _rotation_matrix_y(self, angle): def _rotation_matrix_y_deriv(self, angle): cc, ss = _np.cos(angle), _np.sin(angle) - return _np.array([[-ss, 0, -cc], [0, 1, 0], [cc, 0, -ss]]) + return _np.array([[-ss, 0, -cc], [0, 0, 0], [cc, 0, -ss]]) def create_tile( self, diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 339efd219..009cbabf4 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -176,7 +176,7 @@ def test_tile_closure(): check_control_points(tile_patches) -def test_tile_derivatives(np_rng, heps=1e-8, n_test_points=4): +def test_tile_derivatives(np_rng, heps=1e-7, n_test_points=10): """Testing the correctness of the tile derivatives using Finite Differences. This includes every closure and no closure, every parameter and every patch by evaluating at random points and for random parameters. @@ -188,8 +188,8 @@ def test_tile_derivatives(np_rng, heps=1e-8, n_test_points=4): n_test_points: int Number of testing points in the parametric domain """ - # TODO: right now EllipsVoid, CubeVoid and InverseCross show wrong derivatives - skip_classes = [ms.tiles.EllipsVoid, ms.tiles.CubeVoid] + # TODO: right now EllipsVoid shows wrong derivatives + skip_classes = [ms.tiles.EllipsVoid] for tile_class in all_tile_classes: # TODO: right now skip classes with faultily implemented derivatives From e41898968cdb390c4bef47b19b3b1aa6ba171921 Mon Sep 17 00:00:00 2001 From: markriegler Date: Wed, 9 Oct 2024 17:22:06 +0200 Subject: [PATCH 19/23] Fix Ellipsvoid derivatives --- splinepy/microstructure/tiles/ellips_v_oid.py | 2 +- tests/test_microstructure.py | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/splinepy/microstructure/tiles/ellips_v_oid.py b/splinepy/microstructure/tiles/ellips_v_oid.py index 84025d8bf..67f31b6fd 100644 --- a/splinepy/microstructure/tiles/ellips_v_oid.py +++ b/splinepy/microstructure/tiles/ellips_v_oid.py @@ -91,7 +91,7 @@ def _rotation_matrix_y(self, angle): def _rotation_matrix_y_deriv(self, angle): cc, ss = _np.cos(angle), _np.sin(angle) - return _np.array([[-ss, 0, -cc], [0, 1, 0], [cc, 0, -ss]]) + return _np.array([[-ss, 0, -cc], [0, 0, 0], [cc, 0, -ss]]) def create_tile( self, diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 009cbabf4..260ee2fa2 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -188,14 +188,8 @@ def test_tile_derivatives(np_rng, heps=1e-7, n_test_points=10): n_test_points: int Number of testing points in the parametric domain """ - # TODO: right now EllipsVoid shows wrong derivatives - skip_classes = [ms.tiles.EllipsVoid] for tile_class in all_tile_classes: - # TODO: right now skip classes with faultily implemented derivatives - if tile_class in skip_classes: - continue - tile_creator = tile_class() # Skip test if tile class has no implemented sensitivities if not tile_creator._sensitivities_implemented: From 9baa5f12474003e9fb230372a808f51cec36ad80 Mon Sep 17 00:00:00 2001 From: markriegler Date: Thu, 10 Oct 2024 09:23:36 +0200 Subject: [PATCH 20/23] Change to more appropriate name test_microtiles --- tests/{test_microstructure.py => test_microtiles.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{test_microstructure.py => test_microtiles.py} (100%) diff --git a/tests/test_microstructure.py b/tests/test_microtiles.py similarity index 100% rename from tests/test_microstructure.py rename to tests/test_microtiles.py From cf13b7eb6c182adb213ce7ca7916df7e56f68ced Mon Sep 17 00:00:00 2001 From: markriegler Date: Thu, 10 Oct 2024 11:40:47 +0200 Subject: [PATCH 21/23] Add microstructure closure test --- tests/test_microstructure.py | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/test_microstructure.py diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py new file mode 100644 index 000000000..65cbc9c9f --- /dev/null +++ b/tests/test_microstructure.py @@ -0,0 +1,81 @@ +import splinepy.microstructure as ms +from splinepy.helpme.create import box +from splinepy.helpme.integrate import volume + +all_tile_classes = list(ms.tiles.everything().values()) + +TILING = [2, 2, 2] +BOX_DIMENSIONS = [1, 1, 1] +EPS = 1e-7 + +# TODO: the following tiles fail the closure test +CLOSURE_FAILS = [ms.tiles.HollowOctagonExtrude, ms.tiles.InverseCross3D] + + +def test_closing_face(): + def check_if_closed(multipatch, closure_direction): + """Helper function to see if multipatch has a closing surface + + Parameters + ---------- + multipatch: splinepy Multipatch + Microstructure multipatch + closure_direction: str + Direction in which the closure has been applied + """ + direction_index_dict = {"x": 0, "y": 1, "z": 2} + direction_index = direction_index_dict[closure_direction] + + def min_identifier(points): + return points[:, direction_index] < EPS + + def max_identifier(points): + return ( + points[:, direction_index] + > BOX_DIMENSIONS[direction_index] - EPS + ) + + multipatch.boundary_from_function(min_identifier, boundary_id=2) + multipatch.boundary_from_function(max_identifier, boundary_id=3) + + min_patches = multipatch.boundary_multipatch(2) + max_patches = multipatch.boundary_multipatch(3) + + # Check if the closing surface has a surface area of 1 + face_min_area = sum([volume(patch) for patch in min_patches.patches]) + face_max_area = sum([volume(patch) for patch in max_patches.patches]) + + assert ( + face_min_area > 1.0 - EPS + ), f"The closure of the {closure_direction}_min surface is not complete" + assert ( + face_max_area > 1.0 - EPS + ), f"The closure of the {closure_direction}_max surface is not complete" + + for tile_class in all_tile_classes: + # Skip tile if it doesn't support closure + if "_closure_directions" not in dir(tile_class): + continue + + # TODO: right now skip tiles which have faulty closures + if tile_class in CLOSURE_FAILS: + continue + + tile_creator = tile_class() + generator = ms.microstructure.Microstructure( + deformation_function=box(*BOX_DIMENSIONS[: tile_creator._dim]), + microtile=tile_creator, + tiling=TILING[: tile_creator._para_dim], + ) + # Go through all implemented closure direction + closure_directions = { + directionname[0] + for directionname in tile_creator._closure_directions + } + for closure_direction in closure_directions: + multipatch = generator.create(closing_face=closure_direction) + check_if_closed(multipatch, closure_direction) + + +def test_macro_sensitivities(): + pass From 2a316ed6781b77279be472134a3a09f7a22405d0 Mon Sep 17 00:00:00 2001 From: markriegler Date: Fri, 11 Oct 2024 15:46:35 +0200 Subject: [PATCH 22/23] Add test for microstructure macro sensitivities --- splinepy/microstructure/microstructure.py | 17 ++--- tests/test_microstructure.py | 76 ++++++++++++++++++++++- tests/test_microtiles.py | 6 +- 3 files changed, 85 insertions(+), 14 deletions(-) diff --git a/splinepy/microstructure/microstructure.py b/splinepy/microstructure/microstructure.py index bb34246c6..298df64be 100644 --- a/splinepy/microstructure/microstructure.py +++ b/splinepy/microstructure/microstructure.py @@ -427,8 +427,8 @@ def _compute_tiling_prerequisites( def create( self, closing_face=None, - knot_span_wise=None, - macro_sensitivities=None, + knot_span_wise=True, + macro_sensitivities=False, **kwargs, ): """Create a Microstructure. @@ -455,11 +455,12 @@ def create( if not self._sanity_check(): raise ValueError("Not enough information provided, abort") - # Set default values - if knot_span_wise is None: - knot_span_wise = True - if macro_sensitivities is None: - macro_sensitivities = False + assert isinstance( + knot_span_wise, bool + ), "knot_span_wise must be a bool" + assert isinstance( + macro_sensitivities, bool + ), "macro_senstivities must be a bool" # check if user wants closed structure if closing_face is not None: @@ -533,7 +534,7 @@ def create( if macro_sensitivities or parameter_sensitivities: spline_list_derivs = [ [] - for i in range( + for _ in range( n_parameter_sensitivities + n_macro_sensitivities ) ] diff --git a/tests/test_microstructure.py b/tests/test_microstructure.py index 65cbc9c9f..b0b9ed916 100644 --- a/tests/test_microstructure.py +++ b/tests/test_microstructure.py @@ -1,3 +1,5 @@ +import numpy as np + import splinepy.microstructure as ms from splinepy.helpme.create import box from splinepy.helpme.integrate import volume @@ -13,6 +15,8 @@ def test_closing_face(): + """Check if closing face is working""" + def check_if_closed(multipatch, closure_direction): """Helper function to see if multipatch has a closing surface @@ -65,7 +69,7 @@ def max_identifier(points): generator = ms.microstructure.Microstructure( deformation_function=box(*BOX_DIMENSIONS[: tile_creator._dim]), microtile=tile_creator, - tiling=TILING[: tile_creator._para_dim], + tiling=TILING[: tile_creator._dim], ) # Go through all implemented closure direction closure_directions = { @@ -77,5 +81,71 @@ def max_identifier(points): check_if_closed(multipatch, closure_direction) -def test_macro_sensitivities(): - pass +def test_macro_sensitivities(np_rng, heps=1e-7, n_test_points=10): + """Testing the correctness of the derivatives of the whole microstructure w.r.t. + the deformation function's control points. It is tested by evaluating the derivative + obtained via finite differences. The values are evaluated at random points. + + Parameters + ---------- + heps: float + Perturbation size for finite difference evaluation + n_test_points: int + Number of testing points int the parametric domain""" + + for tile_class in all_tile_classes: + tile_creator = tile_class() + deformation_function_orig = box(*BOX_DIMENSIONS[: tile_creator._dim]) + generator = ms.microstructure.Microstructure( + deformation_function=deformation_function_orig, + microtile=tile_creator, + tiling=TILING[: tile_creator._dim], + ) + multipatch = generator.create(macro_sensitivities=True) + dim = multipatch.dim + n_cps = deformation_function_orig.cps.shape[0] + + # Set evaluation points as random spots in the parametric space + eval_points = np_rng.random((n_test_points, tile_creator._para_dim)) + microstructure_orig_evaluations = [ + patch.evaluate(eval_points) for patch in multipatch.patches + ] + n_patches = len(multipatch.patches) + + # Go through derivatives of every deformation function's control point + for ii_ctps in range(n_cps): + # Gradient through finite differences + deformation_function_perturbed = deformation_function_orig.copy() + deformation_function_perturbed.cps[ii_ctps, :] += heps + generator.deformation_function = deformation_function_perturbed + multipatch_perturbed = generator.create() + microstructure_perturbed_evaluations = [ + patch.evaluate(eval_points) + for patch in multipatch_perturbed.patches + ] + # Evaluate finite difference gradient + fd_sensitivity = [ + (patch_perturbed - patch_orig) / heps + for patch_perturbed, patch_orig in zip( + microstructure_orig_evaluations, + microstructure_perturbed_evaluations, + ) + ] + + # Go through each direction + for jj_dim in range(dim): + deriv_orig = multipatch.fields[ii_ctps * dim + jj_dim] + deriv_evaluations = [ + patch.evaluate(eval_points) for patch in deriv_orig.patches + ] + for k_patch, patch_deriv_implemented, patch_deriv_fd in zip( + range(n_patches), deriv_evaluations, fd_sensitivity + ): + assert np.allclose( + -patch_deriv_implemented[:, jj_dim], + patch_deriv_fd[:, jj_dim], + ), ( + "Implemented derivative calculation for tile class" + + f"{tile_class}, at patch {k_patch+1}/{n_patches} does not " + + "match the derivative obtained using Finite Differences" + ) diff --git a/tests/test_microtiles.py b/tests/test_microtiles.py index 260ee2fa2..87e306e39 100644 --- a/tests/test_microtiles.py +++ b/tests/test_microtiles.py @@ -76,7 +76,7 @@ def test_tile_class(): required_param in create_parameters ), f"create_tile() must have '{required_param}' as an input parameter" - # Ensure closure can be correctly handled + # Ensure closure can be handled correctly if "closure" in create_parameters: assert "_closure_directions" in members, ( "Tile class has closure ability. The available closure directions " @@ -130,7 +130,7 @@ def test_tile_bounds(): def test_tile_closure(): - """Check if closing tiles also lie in unit cube. TODO: also check derivatives.""" + """Check if closing tiles also lie in unit cube.""" for tile_class in all_tile_classes: # Skip tile if if does not support closure @@ -218,7 +218,7 @@ def test_tile_derivatives(np_rng, heps=1e-7, n_test_points=10): splines_orig, _ = tile_creator.create_tile( parameters=parameters, closure=closure ) - # Set evaluation points as 4 random spots in the parametric space + # Set evaluation points as random spots in the parametric space eval_points = np_rng.random( (n_test_points, splines_orig[0].para_dim) ) From 8501ad87ac77bb18ee2e22d4e8e8f6839b125e3c Mon Sep 17 00:00:00 2001 From: markriegler Date: Fri, 11 Oct 2024 17:33:02 +0200 Subject: [PATCH 23/23] Add working closure to HollowOctagonExtrude --- .../tiles/hollow_octagon_extrude.py | 1254 +++++++++++++---- 1 file changed, 961 insertions(+), 293 deletions(-) diff --git a/splinepy/microstructure/tiles/hollow_octagon_extrude.py b/splinepy/microstructure/tiles/hollow_octagon_extrude.py index 16359ef49..1ad07f70f 100644 --- a/splinepy/microstructure/tiles/hollow_octagon_extrude.py +++ b/splinepy/microstructure/tiles/hollow_octagon_extrude.py @@ -29,6 +29,7 @@ def create_tile( parameters=None, parameter_sensitivities=None, contact_length=0.2, + closure=None, **kwargs, # noqa ARG002 ): """Create a microtile based on the parameters that describe the wall @@ -77,6 +78,15 @@ def create_tile( n_derivatives = 0 derivatives = None + if closure is not None: + return self._closing_tile( + parameters=parameters, + parameter_sensitivities=parameter_sensitivities, + closure=closure, + contact_length=contact_length, + **kwargs, + ) + self.check_params(parameters) self.check_param_derivatives(parameter_sensitivities) @@ -108,9 +118,9 @@ def create_tile( right = _np.array( [ [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_zero], - [v_one, -v_outer_c_h + v_one_half, 0.0], - [v_h_void + v_one_half, v_inner_c_h + v_one_half, 0.0], - [v_one, v_outer_c_h + v_one_half, 0.0], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_zero], + [v_one, v_outer_c_h + v_one_half, v_zero], [v_h_void + v_one_half, -v_inner_c_h + v_one_half, v_one], [v_one, -v_outer_c_h + v_one_half, v_one], [v_h_void + v_one_half, v_inner_c_h + v_one_half, v_one], @@ -298,334 +308,992 @@ def _closing_tile( self.check_params(parameters) if parameter_sensitivities is not None: - raise NotImplementedError( - "Derivatives are not implemented for this tile yet" - ) + self.check_param_derivatives(parameter_sensitivities) + n_derivatives = parameter_sensitivities.shape[2] + derivatives = [] + else: + n_derivatives = 0 + derivatives = None + # Check whether parameter is within bounds v_h_void = parameters[0, 0] - if not ((v_h_void > 0.01) and (v_h_void < 0.5)): + para_bound_lower, para_bound_upper = self._parameter_bounds[0] + if not ( + (v_h_void > para_bound_lower) and (v_h_void < para_bound_upper) + ): raise ValueError( - "The thickness of the wall must be in (0.01 and 0.49)" + f"The thickness of the wall must be in ({para_bound_lower} and " + + f"{para_bound_upper})" ) - spline_list = [] - v_zero = 0.0 - v_one_half = 0.5 - v_one = 1.0 - v_outer_c_h = contact_length * 0.5 - v_inner_c_h = contact_length * parameters[0, 0] - - if closure == "x_min": - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - ] - ) - - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - ] - ) - - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - ] - ) - - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - ] - ) - - left = _np.array( - [ - [v_zero, v_zero], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_one], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + splines = [] + for i_derivative in range(n_derivatives + 1): + if i_derivative == 0: + v_zero = 0.0 + v_one_half = 0.5 + v_one = 1.0 + v_outer_c_h = contact_length * 0.5 + v_inner_c_h = contact_length * parameters[0, 0] + else: + v_h_void = parameter_sensitivities[0, 0, i_derivative - 1] + v_zero, v_one_half, v_one = [0.0, 0.0, 0.0] + v_outer_c_h = 0.0 + v_inner_c_h = contact_length * v_h_void - top_left = _np.array( - [ - [v_zero, v_one], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + spline_list = [] - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + if closure == "x_min": + # set points: + right = _np.array( + [ + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_outer_c_h + v_one_half, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, -v_outer_c_h + v_one_half, v_one], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_outer_c_h + v_one_half, v_one], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - ] - ) + right_top = _np.array( + [ + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_outer_c_h + v_one_half, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_one, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_outer_c_h + v_one_half, v_one], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - elif closure == "x_max": - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, v_zero], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_one], - ] - ) + top = _np.array( + [ + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_one], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - ] - ) + bottom_left = _np.array( + [ + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_zero, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, v_zero, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_zero, v_one], + ] + ) - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - ] - ) + left = _np.array( + [ + [v_zero, v_zero, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_one, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_zero, v_one], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, v_one, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + ] + ) - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, -v_outer_c_h + v_one_half], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - ] - ) + top_left = _np.array( + [ + [v_zero, v_one, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_zero, v_one, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + ] + ) - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_zero, v_one], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_zero, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + ] + ) - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + bottom_right = _np.array( + [ + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_zero, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_zero, v_one], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, -v_outer_c_h + v_one_half, v_one], + ] + ) - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + elif closure == "x_max": + right = _np.array( + [ + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_zero, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_one, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_zero, v_one], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_one, v_one], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, v_zero], - ] - ) + right_top = _np.array( + [ + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_one, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_one, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_one, v_one], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - elif closure == "y_min": - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - ] - ) + top = _np.array( + [ + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - ] - ) + bottom_left = _np.array( + [ + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_zero, v_one], + ] + ) - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - ] - ) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + ] + ) - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, -v_outer_c_h + v_one_half], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_zero, v_zero], - ] - ) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_zero, v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + ] + ) - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_zero, v_one], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_zero, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + ] + ) - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [-v_outer_c_h + v_one_half, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + bottom_right = _np.array( + [ + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_zero, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_zero, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_zero, v_one], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_zero, v_one], + ] + ) - bottom = _np.array( - [ - [v_one, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_zero, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + elif closure == "y_min": + # set points: + right = _np.array( + [ + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_outer_c_h + v_one_half, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, -v_outer_c_h + v_one_half, v_one], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_outer_c_h + v_one_half, v_one], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_one, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - ] - ) + right_top = _np.array( + [ + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_outer_c_h + v_one_half, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_one, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_outer_c_h + v_one_half, v_one], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - elif closure == "y_max": - # set points: - right = _np.array( - [ - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - ] - ) + top = _np.array( + [ + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_one, v_one], + ] + ) - right_top = _np.array( - [ - [v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_one, v_outer_c_h + v_one_half], - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_one, v_one], - ] - ) + bottom_left = _np.array( + [ + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_zero, v_zero, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [v_zero, v_zero, v_one], + ] + ) - top = _np.array( - [ - [v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_one, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - [v_zero, v_one], - ] - ) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + ] + ) - bottom_left = _np.array( - [ - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, -v_outer_c_h + v_one_half], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - ] - ) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_zero, v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + ] + ) - left = _np.array( - [ - [v_zero, -v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - ] - ) + bottom = _np.array( + [ + [v_one, v_zero, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_zero, v_zero, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_one, v_zero, v_one], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [v_zero, v_zero, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + ] + ) - top_left = _np.array( - [ - [v_zero, v_outer_c_h + v_one_half], - [-v_h_void + v_one_half, v_inner_c_h + v_one_half], - [v_zero, v_one], - [-v_inner_c_h + v_one_half, v_h_void + v_one_half], - ] - ) + bottom_right = _np.array( + [ + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_one, v_zero, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [v_one, v_zero, v_one], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, -v_outer_c_h + v_one_half, v_one], + ] + ) - bottom = _np.array( - [ - [v_outer_c_h + v_one_half, v_zero], - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [-v_outer_c_h + v_one_half, v_zero], - [-v_inner_c_h + v_one_half, -v_h_void + v_one_half], - ] - ) + elif closure == "y_max": + # set points: + right = _np.array( + [ + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_outer_c_h + v_one_half, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, -v_outer_c_h + v_one_half, v_one], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_outer_c_h + v_one_half, v_one], + ] + ) - bottom_right = _np.array( - [ - [v_inner_c_h + v_one_half, -v_h_void + v_one_half], - [v_outer_c_h + v_one_half, v_zero], - [v_h_void + v_one_half, -v_inner_c_h + v_one_half], - [v_one, -v_outer_c_h + v_one_half], - ] - ) + right_top = _np.array( + [ + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, v_outer_c_h + v_one_half, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_one, v_one, v_zero], + [ + v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_one, v_outer_c_h + v_one_half, v_one], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_one, v_one, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=right)) + top = _np.array( + [ + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_one, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_zero, v_one, v_zero], + [ + v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_one, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + [v_zero, v_one, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=right_top)) + bottom_left = _np.array( + [ + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_zero, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom)) + left = _np.array( + [ + [v_zero, -v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, -v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=bottom_left)) + top_left = _np.array( + [ + [v_zero, v_outer_c_h + v_one_half, v_zero], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_zero, + ], + [v_zero, v_one, v_zero], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_zero, + ], + [v_zero, v_outer_c_h + v_one_half, v_one], + [ + -v_h_void + v_one_half, + v_inner_c_h + v_one_half, + v_one, + ], + [v_zero, v_one, v_one], + [ + -v_inner_c_h + v_one_half, + v_h_void + v_one_half, + v_one, + ], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=left)) + bottom = _np.array( + [ + [v_outer_c_h + v_one_half, v_zero, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [-v_outer_c_h + v_one_half, v_zero, v_zero], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_zero, v_one], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [-v_outer_c_h + v_one_half, v_zero, v_one], + [ + -v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=top_left)) + bottom_right = _np.array( + [ + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_zero, + ], + [v_outer_c_h + v_one_half, v_zero, v_zero], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_zero, + ], + [v_one, -v_outer_c_h + v_one_half, v_zero], + [ + v_inner_c_h + v_one_half, + -v_h_void + v_one_half, + v_one, + ], + [v_outer_c_h + v_one_half, v_zero, v_one], + [ + v_h_void + v_one_half, + -v_inner_c_h + v_one_half, + v_one, + ], + [v_one, -v_outer_c_h + v_one_half, v_one], + ] + ) - spline_list.append(_Bezier(degrees=[1, 1], control_points=top)) + for control_points in [ + right, + right_top, + bottom, + bottom_left, + left, + top_left, + top, + bottom_right, + ]: + spline_list.append( + _Bezier(degrees=[1, 1, 1], control_points=control_points) + ) - spline_list.append( - _Bezier(degrees=[1, 1], control_points=bottom_right) - ) + if i_derivative == 0: + splines = spline_list.copy() + else: + derivatives.append(spline_list) - return (spline_list, None) + return (splines, derivatives)