Compute Wigner 3j and Clebsch-Gordan coefficients
Maintained. Last release 5 months ago, commits in 3 of the last 26 weeks. Weaker on commit activity and release cadence.
pip install wignersREADME as published on PyPI with version 0.4.1.
Calculation of Wigner symbols and related constants
This package computes Wigner 3j coefficients, Clebsch-Gordan coefficients, and
complex Wigner D-matrices in pure Rust. The 3j/CG calculation is based on the
prime factorization of the different factorials involved in the coefficients,
keeping the values in a rational root form (sign * \sqrt{s / n}) for as long
as possible. The Wigner D-matrix uses the Risbo/Trapani-Navaza recurrence to
compute all matrices for j from 0 to j_max simultaneously.
Wigner 3j / Clebsch-Gordan algorithm:
H. T. Johansson and C. Forssén, SIAM Journal on Scientific Compututing 38 (2016) 376-384
Wigner D-matrix algorithm:
- T. Risbo, "Fourier-transform summation of Legendre series by D-matrix transform", https://doi.org/10.1007/BF01090814
- S. Trapani & J. Navaza, "Calculation of spherical harmonics and Wigner d functions by FFT.", https://doi.org/10.1107/S0108767306017478
This implementation takes a lot of inspiration from the WignerSymbols Julia implementation (and even started as a direct translation of it), many thanks to them! This package is available under the same license as the Julia package.
Usage
From python
pip install wigners
And then call one of the exported function:
import wigners
w3j = wigners.wigner_3j(j1, j2, j3, m1, m2, m3)
cg = wigners.clebsch_gordan(j1, m1, j2, m1, j3, m3)
# full array of Clebsch-Gordan coefficients, computed in parallel
cg_array = wigners.clebsch_gordan_array(ji, j2, j3)
# we have an internal cache for recently computed CG coefficients, if you
# need to clean it up you can use this function
wigners.clear_wigner_3j_cache()
# Wigner D matrices for all j up to max_j, using ZYZ Euler angles
matrices = wigners.wigner_D_array(max_j, alpha, beta, gamma)
# matrices[j] is a (2*j+1) x (2*j+1) complex128 matrix
From rust
Add this crate to your Cargo.toml dependencies section:
wigners = "0.3"