bluemira.utilities.positioning
A collection of tools used for position interpolation.
Classes
Abstract base class for 2-D x-z geometry interpolation to normalised [0, 1] space. |
|
Sets up an x-z path for a point to move along. |
|
Sets up an x-z region for a point to move within. |
|
Positioning tool for use in optimisation |
Module Contents
- class bluemira.utilities.positioning.XZGeometryInterpolator(geometry: bluemira.geometry.wire.BluemiraWire)
Bases:
abc.ABCAbstract 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].
- Parameters:
geometry (bluemira.geometry.wire.BluemiraWire) – Geometry to interpolate with
- geometry
- _get_xz_coordinates(num_pts)
Get discretised x-z coordinates of the geometry.
- Returns:
The xz coordinates
- abstract 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.
- Parameters:
l_values (numpy.typing.ArrayLike)
- Return type:
tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray]
- abstract to_L(x: numpy.typing.ArrayLike, z: numpy.typing.ArrayLike) float | numpy.ndarray
Convert physical x-z space values to parametric-space ‘L’ values.
- Parameters:
x (numpy.typing.ArrayLike)
z (numpy.typing.ArrayLike)
- Return type:
float | numpy.ndarray
- property dimension: int
- Abstractmethod:
- Return type:
int
The dimension of the parametric space
- class bluemira.utilities.positioning.PathInterpolator(geometry: bluemira.geometry.wire.BluemiraWire)
Bases:
XZGeometryInterpolatorSets up an x-z path for a point to move along.
The path is treated as flat in the x-z plane.
- Parameters:
geometry (bluemira.geometry.wire.BluemiraWire)
- 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
- Parameters:
l_values (numpy.typing.ArrayLike)
- Return type:
tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray]
- 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
- Parameters:
x (numpy.typing.ArrayLike)
z (numpy.typing.ArrayLike)
- Return type:
float | numpy.ndarray
- property dimension: int
Dimension of the parametric space of the PathInterpolator
- Return type:
int
- class bluemira.utilities.positioning.RegionInterpolator(geometry: bluemira.geometry.wire.BluemiraWire)
Bases:
XZGeometryInterpolatorSets 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.
- Parameters:
geometry (bluemira.geometry.wire.BluemiraWire) – Region to interpolate within
- z_min
- z_max
- _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.
- Parameters:
geometry (bluemira.geometry.wire.BluemiraWire) – Region to check
- Raises:
PositionerError – When geometry is not a convex
- 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.
- Parameters:
l_values (numpy.typing.ArrayLike | tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray]) – 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
- Return type:
tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray]
- 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.
- Parameters:
x (numpy.typing.ArrayLike) – x coordinate in real space
z (numpy.typing.ArrayLike) – 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
- Return type:
tuple[float, float] | tuple[numpy.ndarray, numpy.ndarray]
- _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.
- Parameters:
x (float) – x coordinate
l_1 (float) – Normalised z coordinate
intersect (bluemira.geometry.plane.BluemiraPlane) – 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
- Return type:
tuple[float, float]
- property dimension
Dimension of the parametric space of the RegionInterpolator
- class bluemira.utilities.positioning.PositionMapper(interpolators: dict[str, XZGeometryInterpolator])
Positioning tool for use in optimisation
- Parameters:
interpolators (dict[str, XZGeometryInterpolator]) – The ordered list of geometry interpolators
- interpolators
- _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
- _vector_to_list(l_values)
Convert a vector of l_values into a ragged list if necessary
- Returns:
The list of normalised values
- to_xz(l_values: numpy.ndarray) numpy.typing.NDArray[numpy.float64]
Convert a set of parametric-space values to physical x-z coordinates.
- Parameters:
l_values (numpy.ndarray) – The set of parametric-space values to convert
- Returns:
x – Array of x coordinates
z – Array of z coordinates
- Return type:
numpy.typing.NDArray[numpy.float64]
- 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.
- Parameters:
l_values (numpy.ndarray) – The set of parametric-space values to convert
- Return type:
Dictionary of x-z values corresponding to each interpolator
- to_L(x: numpy.ndarray, z: numpy.ndarray) numpy.ndarray
Convert a set of physical x-z coordinates to parametric-space values.
- Parameters:
x (numpy.ndarray) – The x coordinates to convert
z (numpy.ndarray) – The z coordinates to convert
- Returns:
The set of parametric-space values
- Return type:
l_values
- property dimension: int
The total dimension of the parametric space
- Return type:
int
- property interpolator_names: list[str]
The names of the interpolators
- Return type:
list[str]