spherical#

Spherical coordinate system utilities and spherical harmonics transformations.

This module provides functions for working with spherical coordinates and spherical harmonics, particularly useful for quantum mechanical calculations and pseudopotential transformations.

jrystal.pseudopotential.spherical.cartesian_to_spherical(x: Float[Array, '*n 3'], eps=1e-10) Float[Array, '*n 3'][source]#

Convert Cartesian coordinates to spherical coordinates.

Transforms 3D Cartesian coordinates (x, y, z) to spherical coordinates (r, θ, φ), where:

  • r is the radial distance from the origin

  • θ (theta) is the azimuthal angle in the x-y plane from the x-axis (0 ≤ θ < 2π)

  • φ (phi) is the polar angle from the z-axis (0 ≤ φ ≤ π)

For the special case of the origin (0, 0, 0), returns (0, NaN, π/2).

Parameters:

x – Float[Array, “*n 3”]: Cartesian coordinates with shape (…, 3) where … represents arbitrary batch dimensions

Returns:

Spherical coordinates (r, θ, φ) with same batch shape

Return type:

Float[Array, “*n 3”]

jrystal.pseudopotential.spherical.legendre_to_sph_harm(l: int = 0) Callable[[Float[Array, '*batch 3']], Float[Array, '*batch m']][source]#

Convert Legendre polynomials to spherical harmonics decomposition.

Implements the decomposition of Legendre polynomials into spherical harmonics according to the formula:

\[(2l+1) P_l(x^Ty) = 4\pi \sum_m Y_{l, m}(x) Y^*_{l, m}(y)\]

where:

  • l is the angular momentum quantum number

  • P_l is the Legendre polynomial of order l

  • Y_{l,m} are the spherical harmonics

  • m is the magnetic quantum number ranging from -l to +l

This transformation is particularly useful for efficient computation of P_l(G^T G’) in quantum mechanical calculations, as it allows replacing expensive pairwise inner products of G vectors with faster spherical harmonics calculations.

Parameters:

l (int) – Angular momentum quantum number (default: 0)

Returns:

Callable that takes Cartesian coordinates of shape (*batch, 3) and returns spherical harmonics coefficients of shape (*batch, m), where m = 2l+1