4.2.2.1 pde.grids.coordinates.base module

class CoordinatesBase[source]

Bases: object

Base class for orthonormal coordinate systems

axes: list[str]

Names of all axes that are described by the grid

Type:

list

basis_rotation(points)[source]

returns the basis vectors of the grid in Cartesian coordinates

Parameters:

points (ndarray) – Coordinates of the point(s) where the basis determined

Returns:

Arrays of vectors giving the direction of the grid

unit vectors in Cartesian coordinates. The returnd 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, which is an array with one dimension less than the given coordinate lines

Return type:

ndarray

coordinate_limits: list[tuple[float, float]]

the limits of the actual coordinates

Type:

list of tuple

dim: int

spatial dimension of the coordinates

Type:

int

distance(p1, p2)[source]

Calculate the distance between two points given in real coordinates

This takes periodic boundary conditions into account if necessary.

Parameters:
  • p1 (ndarray) – First position

  • p2 (ndarray) – Second position

  • coords (str) – The coordinate system in which the points are specified. Valid values are cartesian, cell, and grid; see transform().

Returns:

Distance between the two positions

Return type:

float

mapping_jacobian(points)[source]

returns the Jacobian matrix of the cooridinate 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_diff(p1, p2)[source]

return Cartesian vector(s) pointing from p1 to p2

In case of periodic boundary conditions, the shortest vector is returned.

Parameters:
Returns:

The difference vectors between the points with periodic boundary conditions applied.

Return type:

ndarray

pos_from_cart(points)[source]

convert Cartesian coordinates to coordinates in this system

Parameters:

points (ndarray) – Points given in Cartesian coordinates.

Returns:

Points given in the coordinates of this system

Return type:

ndarray

pos_to_cart(points)[source]

convert coordinates to Cartesian coordinates

Parameters:

points (ndarray) – The coordinates of points in the current coorindate system

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 into 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 elements at various points

Parameters:

points (ndarray) – The grid coordinates of the points

Returns:

Scale factors at the points

Return type:

ndarray

exception DimensionError[source]

Bases: ValueError

exception indicating that dimensions were inconsistent