bluemira.utilities.positioning ============================== .. py:module:: bluemira.utilities.positioning .. autoapi-nested-parse:: A collection of tools used for position interpolation. Classes ------- .. autoapisummary:: bluemira.utilities.positioning.XZGeometryInterpolator bluemira.utilities.positioning.PathInterpolator bluemira.utilities.positioning.RegionInterpolator bluemira.utilities.positioning.PositionMapper Module Contents --------------- .. py:class:: XZGeometryInterpolator(geometry: bluemira.geometry.wire.BluemiraWire) Bases: :py:obj:`abc.ABC` .. autoapi-inheritance-diagram:: bluemira.utilities.positioning.XZGeometryInterpolator :parts: 1 :private-bases: Abstract base class for 2-D x-z geometry interpolation to normalised [0, 1] space. By convention, normalised x-z space is oriented counter-clockwise w.r.t. [0, 1, 0]. :param geometry: Geometry to interpolate with .. py:attribute:: geometry .. py:method:: _get_xz_coordinates(num_pts) Get discretised x-z coordinates of the geometry. :returns: The xz coordinates .. py:method:: to_xz(l_values: numpy.typing.ArrayLike) -> tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray] :abstractmethod: Convert parametric-space 'L' values to physical x-z space. .. py:method:: to_L(x: numpy.typing.ArrayLike, z: numpy.typing.ArrayLike) -> float | numpy.ndarray :abstractmethod: Convert physical x-z space values to parametric-space 'L' values. .. py:property:: dimension :type: int :abstractmethod: The dimension of the parametric space .. py:class:: PathInterpolator(geometry: bluemira.geometry.wire.BluemiraWire) Bases: :py:obj:`XZGeometryInterpolator` .. autoapi-inheritance-diagram:: bluemira.utilities.positioning.PathInterpolator :parts: 1 :private-bases: Sets up an x-z path for a point to move along. The path is treated as flat in the x-z plane. .. py:method:: to_xz(l_values: numpy.typing.ArrayLike) -> tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray] Convert parametric-space 'L' values to physical x-z space. :returns: The xz coordinates .. py:method:: to_L(x: numpy.typing.ArrayLike, z: numpy.typing.ArrayLike) -> float | numpy.ndarray Convert physical x-z space values to parametric-space 'L' values. :returns: The normalised coordinates .. py:property:: dimension :type: int Dimension of the parametric space of the PathInterpolator .. py:class:: RegionInterpolator(geometry: bluemira.geometry.wire.BluemiraWire) Bases: :py:obj:`XZGeometryInterpolator` .. autoapi-inheritance-diagram:: bluemira.utilities.positioning.RegionInterpolator :parts: 1 :private-bases: Sets up an x-z region for a point to move within. The region is treated as a flat x-z surface. The normalisation occurs by cutting the shape in two axes and normalising over the cut length within the region. Currently this is limited to convex polygons. Generalisation to all polygons is possible but unimplemented and possibly quite slow when converting from normalised to real coordinates. When the point position provided is outside the given region the point will be moved to the closest edge of the region. The mapping from outside to the edge of the region is not strictly defined. The only certainty is that the point will be moved into the region. :param geometry: Region to interpolate within .. py:attribute:: z_min .. py:attribute:: z_max .. py:method:: _check_geometry_feasibility(geometry: bluemira.geometry.wire.BluemiraWire) Checks the provided region is convex. This is a current limitation of RegionInterpolator not providing a 'smooth' interpolation surface. :param geometry: Region to check :raises PositionerError: When geometry is not a convex .. py:method:: to_xz(l_values: numpy.typing.ArrayLike | tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray]) -> tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray] Convert parametric-space 'L' values to physical x-z space. :param l_values: Coordinates in normalised space :returns: * *x* -- x coordinate in real space * *z* -- z coordinate in real space :raises PositionerError: When loop is not a Convex Hull .. py:method:: to_L(x: numpy.typing.ArrayLike, z: numpy.typing.ArrayLike) -> tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray] Convert physical x-z space values to parametric-space 'L' values. :param x: x coordinate in real space :param z: z coordinate in real space :returns: * *l_1* -- Coordinate 1 in normalised space * *l_2* -- Coordinate 2 in normalised space :raises GeometryError: When loop is not a Convex Hull .. py:method:: _intersect_filter(x: float, l_1: float, intersect: bluemira.geometry.plane.BluemiraPlane) -> tuple[float, float] Checks where points are based on number of intersections with a plane. Should initially be called with a plane involving z. No intersection could mean above 1 edge therefore a plane in xy is checked before recalling this function. If there is one intersection point we are on an edge (either bottom or top), if there is two intersection points we are in the region, otherwise the region is not a convex hull. :param x: x coordinate :param l_1: Normalised z coordinate :param intersect: A plane through xz :returns: * *l_1* -- Coordinate 1 in normalised space * *l_2* -- Coordinate 2 in normalised space :raises PositionerError: When geometry is not a convex .. py:property:: dimension Dimension of the parametric space of the RegionInterpolator .. py:class:: PositionMapper(interpolators: dict[str, XZGeometryInterpolator]) Positioning tool for use in optimisation :param interpolators: The ordered list of geometry interpolators .. py:attribute:: interpolators .. py:method:: _check_length(thing) Check that something is the same length as the number of available interpolators. :raises PositionerError: the number of iterators is not equal to the number of objects .. py:method:: _vector_to_list(l_values) Convert a vector of l_values into a ragged list if necessary :returns: The list of normalised values .. py:method:: to_xz(l_values: numpy.ndarray) -> numpy.typing.NDArray[numpy.float64] Convert a set of parametric-space values to physical x-z coordinates. :param l_values: The set of parametric-space values to convert :returns: * *x* -- Array of x coordinates * *z* -- Array of z coordinates .. py:method:: to_xz_dict(l_values: numpy.ndarray) -> dict[str, numpy.ndarray] Convert a set of parametric space values to physical coordinates in a dictionary form. :param l_values: The set of parametric-space values to convert :rtype: Dictionary of x-z values corresponding to each interpolator .. py:method:: to_L(x: numpy.ndarray, z: numpy.ndarray) -> numpy.ndarray Convert a set of physical x-z coordinates to parametric-space values. :param x: The x coordinates to convert :param z: The z coordinates to convert :returns: The set of parametric-space values :rtype: l_values .. py:property:: dimension :type: int The total dimension of the parametric space .. py:property:: interpolator_names :type: list[str] The names of the interpolators