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.batch_sph_harm(l: int, theta: Float[Array, '*batch'], phi: Float[Array, '*batch']) Float[Array, '*batch m'][source]#
Compute the spherical harmonics for a batch of points.
this function is used to compute the sum of spherical harmonics:
\[Y_{l, m}(theta, phi)\]
- jrystal.pseudopotential.spherical.batch_sph_harm_real(l: int, theta: Float[Array, '*batch'], phi: Float[Array, '*batch']) Float[Array, '*batch m'][source]#
Compute the real form of spherical harmonics for a batch of points.
- 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
Warning
The definition of theta and phi is different from the jax convention.
- Returns:
Spherical coordinates (r, θ, φ) with same batch shape
- Return type:
Float[Array, “*n 3”]
- jrystal.pseudopotential.spherical.legendre_kernel_trick(l: int = 0) Callable[source]#
Decompose legendre polynomials via kernel trick:
(2l+1) P_l (x^Ty) = phi(x)^T phi(y)
Return phi
- Parameters:
l (int, optional) – The degree of the legendre polynomial. Defaults to 0.
- Returns:
return a function that map from shape [n1 n2 n3 3] to [n1 n2 n3 new_dim] where new_dim is decided using kernel trick.
- Return type:
callable
- jrystal.pseudopotential.spherical.legendre_to_sph_harm(l: int = 0, l_max: int = 4) 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.