4.3.2 pde.grids.coordinates package

Package collecting classes representing orthonormal coordinate systems.

BipolarCoordinates

2-dimensional bipolar coordinates.

BisphericalCoordinates

3-dimensional bispherical coordinates.

CartesianCoordinates

N-dimensional Cartesian coordinates.

CylindricalCoordinates

3-dimensional cylindrical coordinates.

PolarCoordinates

2-dimensional polar coordinates.

SphericalCoordinates

3-dimensional spherical coordinates.

class BipolarCoordinates(scale_parameter: float = 1)[source]

Bases: CoordinatesBase

2-dimensional bipolar coordinates.

basis_rotation(points: FloatingArray) → FloatingArray

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: FloatingArray, c_high: FloatingArray) → FloatingArray

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

distance(p1: FloatingArray, p2: FloatingArray, *, axis: int = -1) → float

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: FloatingArray) → FloatingArray

Returns the Jacobian matrix of the coordinate mapping.

Parameters:

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

Returns:

The Jacobian

Return type:

ndarray

metric(points: FloatingArray) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray) → FloatingArray

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: FloatingArray, components: FloatingArray) → FloatingArray

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: FloatingArray) → ArrayLike

Calculate the volume factors at various points.

Parameters:

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

Returns:

Volume factors at the points

Return type:

ndarray

class BisphericalCoordinates(scale_parameter: float = 1)[source]

Bases: CoordinatesBase

3-dimensional bispherical coordinates.

basis_rotation(points: FloatingArray) → FloatingArray

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: FloatingArray, c_high: FloatingArray) → FloatingArray

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

distance(p1: FloatingArray, p2: FloatingArray, *, axis: int = -1) → float

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: FloatingArray) → FloatingArray

Returns the Jacobian matrix of the coordinate mapping.

Parameters:

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

Returns:

The Jacobian

Return type:

ndarray

metric(points: FloatingArray) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray) → FloatingArray

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: FloatingArray, components: FloatingArray) → FloatingArray

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: FloatingArray) → ArrayLike

Calculate the volume factors at various points.

Parameters:

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

Returns:

Volume factors at the points

Return type:

ndarray

class CartesianCoordinates(dim: int)[source]

Bases: CoordinatesBase

N-dimensional Cartesian coordinates.

Parameters:

dim (int) – Dimension of the Cartesian coordinate system

basis_rotation(points: FloatingArray) → FloatingArray

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: FloatingArray, c_high: FloatingArray) → FloatingArray

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

distance(p1: FloatingArray, p2: FloatingArray, *, axis: int = -1) → float

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: FloatingArray) → FloatingArray

Returns the Jacobian matrix of the coordinate mapping.

Parameters:

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

Returns:

The Jacobian

Return type:

ndarray

metric(points: FloatingArray) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray) → FloatingArray

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: FloatingArray, components: FloatingArray) → FloatingArray

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: FloatingArray) → ArrayLike

Calculate the volume factors at various points.

Parameters:

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

Returns:

Volume factors at the points

Return type:

ndarray

class CylindricalCoordinates[source]

Bases: CoordinatesBase

3-dimensional cylindrical coordinates.

basis_rotation(points: FloatingArray) → FloatingArray

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: FloatingArray, c_high: FloatingArray) → FloatingArray

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

distance(p1: FloatingArray, p2: FloatingArray, *, axis: int = -1) → float

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: FloatingArray) → FloatingArray

Returns the Jacobian matrix of the coordinate mapping.

Parameters:

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

Returns:

The Jacobian

Return type:

ndarray

metric(points: FloatingArray) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray) → FloatingArray

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: FloatingArray, components: FloatingArray) → FloatingArray

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: FloatingArray) → ArrayLike

Calculate the volume factors at various points.

Parameters:

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

Returns:

Volume factors at the points

Return type:

ndarray

class PolarCoordinates[source]

Bases: CoordinatesBase

2-dimensional polar coordinates.

basis_rotation(points: FloatingArray) → FloatingArray

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: FloatingArray, c_high: FloatingArray) → FloatingArray

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

distance(p1: FloatingArray, p2: FloatingArray, *, axis: int = -1) → float

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: FloatingArray) → FloatingArray

Returns the Jacobian matrix of the coordinate mapping.

Parameters:

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

Returns:

The Jacobian

Return type:

ndarray

metric(points: FloatingArray) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray) → FloatingArray

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: FloatingArray, components: FloatingArray) → FloatingArray

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: FloatingArray) → ArrayLike

Calculate the volume factors at various points.

Parameters:

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

Returns:

Volume factors at the points

Return type:

ndarray

class SphericalCoordinates[source]

Bases: CoordinatesBase

3-dimensional spherical coordinates.

basis_rotation(points: FloatingArray) → FloatingArray

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: FloatingArray, c_high: FloatingArray) → FloatingArray

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

distance(p1: FloatingArray, p2: FloatingArray, *, axis: int = -1) → float

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: FloatingArray) → FloatingArray

Returns the Jacobian matrix of the coordinate mapping.

Parameters:

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

Returns:

The Jacobian

Return type:

ndarray

metric(points: FloatingArray) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray, *, axis: int = -1) → FloatingArray

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: FloatingArray) → FloatingArray

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: FloatingArray, components: FloatingArray) → FloatingArray

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: FloatingArray) → ArrayLike

Calculate the volume factors at various points.

Parameters:

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

Returns:

Volume factors at the points

Return type:

ndarray