4.2.2.1 pde.grids.coordinates.base module

class CoordinatesBase[source]

Bases: object

Base class for orthonormal coordinate systems.

axes: list[str]

name of each coordinate axis

Type:

list

basis_rotation(points)[source]

Returns rotation matrix rotating basis vectors to Cartesian coordinates.

Parameters:

points (ndarray) – Coordinates of the point(s)

Returns:

Rotation matrices for all points. The returned array has the shape (dim, dim) + points_shape, assuming points has the shape points_shape + (dim,).

Return type:

ndarray

cell_volume(c_low, c_high)[source]

Calculate the volume between coordinate lines.

Parameters:
  • c_low (ndarray) – Lower values of the coordinate lines enclosing the volume

  • c_high (ndarray) – Upper values of the coordinate lines enclosing the volume

Returns:

Enclosed volumes for all given cells

Return type:

ndarray

coordinate_limits: list[tuple[float, float]]

the limits of each coordinate axis

Type:

list of tuple

dim: int

spatial dimension of the coordinate system

Type:

int

distance(p1, p2, *, axis=-1)[source]

Calculate the distance between two points.

Parameters:
  • p1 (ndarray) – First position

  • p2 (ndarray) – Second position

  • axis (int) – Determines the axis along which the coordinates of the points are given

Returns:

Distance between the two positions

Return type:

float

mapping_jacobian(points)[source]

Returns the Jacobian matrix of the coordinate mapping.

Parameters:

points (ndarray) – Coordinates of the point(s)

Returns:

The Jacobian

Return type:

ndarray

metric(points)[source]

Calculate the metric tensor at coordinate points.

Parameters:

points (ndarray) – The coordinates of the points

Returns:

Metric tensor at the points

Return type:

ndarray

pos_from_cart(points, *, axis=-1)[source]

Convert Cartesian coordinates to coordinates in this system.

Parameters:
  • points (ndarray) – Points given in Cartesian coordinates.

  • axis (int) – Determines the axis along which the coordinates of the points are given

Returns:

Points given in the coordinates of this system

Return type:

ndarray

pos_to_cart(points, *, axis=-1)[source]

Convert coordinates to Cartesian coordinates.

Parameters:
  • points (ndarray) – The coordinates of points in the current coordinate system

  • axis (int) – Determines the axis along which the coordinates of the points are given

Returns:

Cartesian coordinates of the points

Return type:

ndarray

scale_factors(points)[source]

Calculate the scale factors at various points.

Parameters:

points (ndarray) – The coordinates of the points

Returns:

Scale factors at the points

Return type:

ndarray

vec_to_cart(points, components)[source]

Convert the vectors at given points to a Cartesian basis.

Parameters:
  • points (ndarray) – The coordinates of the point(s) where the vectors are specified.

  • components (ndarray) – The components of the vectors at the given points

Returns:

The vectors specified at the same position but with components given in Cartesian coordinates.

Return type:

ndarray

volume_factor(points)[source]

Calculate the volume factors at various points.

Parameters:

points (ndarray) – Coordinates of the point(s)

Returns:

Volume factors at the points

Return type:

ndarray

exception DimensionError[source]

Bases: ValueError

Exception indicating that dimensions were inconsistent.