droplets.tools.spherical module
Module collecting functions for handling spherical geometry
The coordinate systems use the following convention for polar coordinates \((r, \phi)\), where \(r\) is the radial coordinate and \(\phi\) is the polar angle:
Similarly, for spherical coordinates \((r, \theta, \phi)\), where \(r\) is the radial coordinate, \(\theta\) is the azimuthal angle, and \(\phi\) is the polar angle, we use
The module also provides functions for handling spherical harmonics. These spherical harmonics are described by the degree \(l\) and the order \(m\) or, alternatively, by the mode \(k\). The relation between these values is
and
We will use these indices interchangeably, although the mode \(k\) is preferred internally. Note that we also consider axisymmetric spherical harmonics, where the order is always zero and the degree \(l\) and the mode \(k\) are thus identical.
Return the radius of a sphere with a given volume |
|
|
Return the volume of a sphere with a given radius |
Return the surface area of a sphere with a given radius |
|
Return the radius of a sphere with a given surface area |
|
Return a function calculating the radius of a sphere with a given volume |
|
Return a function calculating the volume of a sphere with a given radius |
|
Return a function calculating the surface area of a sphere |
|
Convert points from Cartesian to spherical coordinates |
|
Convert points from spherical to Cartesian coordinates |
|
return polar coordinates associated with grid points |
|
returns the mode k from the degree degree and order order |
|
returns the degree l and the order m from the mode k |
|
return the number of modes for all indices <= l |
|
checks whether the modes captures all orders for maximal degree |
|
axisymmetric spherical harmonics with degree degree, so m=0. |
|
real spherical harmonics of degree l and order m |
|
real spherical harmonics described by mode k |
- make_radius_from_volume_compiled(dim)[source]
Return a function calculating the radius of a sphere with a given volume
- Parameters:
dim (int) – Dimension of the space
- Returns:
A function that takes a volume and returns the radius
- Return type:
function
- make_radius_from_volume_nd_compiled()[source]
Return a function calculating the radius of a sphere with a given volume
- Returns:
A function that calculate the radius from a volume and dimension
- Return type:
function
- make_surface_from_radius_compiled(dim)[source]
Return a function calculating the surface area of a sphere
- Parameters:
dim (int) – Dimension of the space
- Returns:
A function that takes a radius and returns the surface area
- Return type:
function
- make_volume_from_radius_compiled(dim)[source]
Return a function calculating the volume of a sphere with a given radius
- Parameters:
dim (int) – Dimension of the space
- Returns:
A function that takes a radius and returns the volume
- Return type:
function
- make_volume_from_radius_nd_compiled()[source]
Return a function calculating the volume of a sphere with a given radius
- Returns:
A function that calculates the volume using a radius and dimension
- Return type:
function
- points_cartesian_to_spherical(points)[source]
Convert points from Cartesian to spherical coordinates
- points_spherical_to_cartesian(points)[source]
Convert points from spherical to Cartesian coordinates
- polar_coordinates(grid: GridBase, *, origin: np.ndarray | None = None, ret_angle: Literal[False] = False) ndarray [source]
- polar_coordinates(grid: GridBase, *, origin: np.ndarray | None = None, ret_angle: Literal[True]) tuple[ndarray, ...]
return polar coordinates associated with grid points
- Parameters:
grid (
GridBase
) – The grid whose cell coordinates are used.origin (
ndarray
, optional) – Cartesian coordinates of the origin at which polar coordinates are anchored.ret_angle (bool) – Determines whether angles are returned alongside the distance. If False only the distance to the origin is returned for each support point of the grid. If True, the distance and angles are returned. For a 1d system system, the angle is defined as the sign of the difference between the point and the origin, so that angles can either be 1 or -1. For 2d systems and 3d systems, polar coordinates and spherical coordinates are used, respectively.
- Returns:
Coordinates values in polar coordinates
- Return type:
- spherical_harmonic_real(degree, order, θ, φ)[source]
real spherical harmonics of degree l and order m
- Parameters:
- Returns:
The value of the spherical harmonics
- Return type:
- spherical_harmonic_real_k(k, θ, φ)[source]
real spherical harmonics described by mode k
- Parameters:
- Returns:
The value of the spherical harmonics
- Return type:
- spherical_harmonic_symmetric(degree, θ)[source]
axisymmetric spherical harmonics with degree degree, so m=0.
- spherical_index_count(l)[source]
return the number of modes for all indices <= l
The returned value is one less than the maximal mode k required.
- spherical_index_count_optimal(k_count)[source]
checks whether the modes captures all orders for maximal degree
- spherical_index_k(degree, order=0)[source]
returns the mode k from the degree degree and order order
- Parameters:
- Raises:
ValueError – if order < -degree or order > degree
- Returns:
a combined index k
- Return type: