API
Types
CGcoefficient.SqrtRational — Type
SqrtRational <: RealStore exact value of a Rational's square root. It is stored in s√r format, and we do not simplify it during arithmetics. You can use the simplify function to simplify it.
Some useful function
CGcoefficient.iphase — Function
iphase(n::Integer)$(-1)^n$
CGcoefficient.is_same_parity — Function
is_same_parity(x::T, y::T) where {T <: Integer}judge if two integers are same odd or same even
CGcoefficient.check_jm — Function
check_jm(dj::T, dm::T) where {T <: Integer}check if the m-quantum number if one of the components of the j-quantum number, in other words, m and j has the same parity, and abs(m) < j
CGcoefficient.check_couple — Function
check_couple(dj1::T, dj2::T, dj3::T) where {T <: Integer}check if three angular monentum number j1, j2, j3 can couple
CGcoefficient.binomial_data_size — Function
binomial_data_size(n::Int)::IntStore (half) binomial data in the order of
# n - data
0 1
1 1
2 1 2
3 1 3
4 1 4 6
5 1 5 10
6 1 6 15 20Return the total number of the stored data.
CGcoefficient.binomial_index — Function
binomial_index(n::Int, k::Int)::IntReturn the index of the binomial coefficient in the table.
CGcoefficient.check_CG — Function
check_CG(dj1::T, dj2::T, dj3::T, dm1::T, dm2::T, dm3::T) where {T <: Integer}Check if the Clebsch-Gordan coefficient is valid.
CGcoefficient.check_3j — Function
check_3j(dj1::T, dj2::T, dj3::T, dm1::T, dm2::T, dm3::T) where {T <: Integer}Check if the Wigner 3-j symbol is valid.
CGcoefficient.check_6j — Function
check_6j(dj1::T, dj2::T, dj3::T, dj4::T, dj5::T, dj6::T) where {T <: Integer}Check if the Wigner 6-j symbol is valid.
CGcoefficient.check_9j — Function
check_9j(dj1::T, dj2::T, dj3::T, dj4::T, dj5::T, dj6::T, dj7::T, dj8::T, dj9::T) where {T <: Integer}Check if the Wigner 9-j symbol is valid.
CGcoefficient.check_Gaunt — Function
check_Gaunt(l1::T, l2::T, l3::T, m1::T, m2::T, m3::T) where {T <: Integer}Check if the Gaunt coefficient is valid.
CGcoefficient.check_Moshinsky — Function
check_Moshinsky(N::T, L::T, n::T, l::T, n1::T, l1::T, n2::T, l2::T, Λ::T) where {T <: Integer}Check if the Moshinsky coefficient is valid.
CGcoefficient.exact_sqrt — Function
exact_sqrt(r::Union{Integer, Rational})Get exact √r using SqrtRational type.
Base.float — Method
float(x::SqrtRational{T})::float(T)Convert a SqrtRational to float.
CGcoefficient.simplify — Method
simplify(n::Integer)Simplify a integer n = x * t^2 to (x, t)
CGcoefficient.simplify — Method
simplify(x::SqrtRational)Simplify a SqrtRational.
Exact functions
The default functions give out exact result in the format of SqrtRational. The results are simplified to give out shotest possible result. Their arguments are Real (but only allow twice of which can be convert into integer).
CGcoefficient.CG — Function
CG(j1::Real, j2::Real, j3::Real, m1::Real, m2::Real, m3::Real)CG coefficient $\langle j_1m_1 j_2m_2 | j_3m_3 \rangle$
CGcoefficient.CG0 — Function
CG0(j1::Integer, j2::Integer, j3::Integer)CG coefficient special case: $\langle j_1 0 j_2 0 | j_3 0 \rangle$.
CGcoefficient.threeJ — Function
threeJ(j1::Real, j2::Real, j3::Real, m1::Real, m2::Real, m3::Real)Wigner 3j-symbol
\[\begin{pmatrix} j_1 & j_2 & j_3 \\ m_1 & m_2 & m_3 \end{pmatrix}\]
CGcoefficient.xGaunt — Function
xGaunt(l1::Integer, l2::Integer, l3::Integer, m1::Integer, m2::Integer, m3::Integer)Gaunt coefficient with out $1/\sqrt{\pi}$ factor. (This package can only handle integer arithmetic, it is easy to add the factor mannually.)
\[\begin{aligned} \mathrm{Gaunt}(l_1 l_2 l_3 m_1 m_2 m_3) &= \int Y_{l_1 m_1}(\theta, \phi) Y_{l_2 m_2}(\theta, \phi) Y_{l_3 m_3}(\theta, \phi) d\Omega \\ &= \sqrt{\frac{(2l_1 + 1)(2l_2 + 1)(2l_3 + 1)}{4\pi}} \begin{pmatrix} l_1 & l_2 & l_3 \\ m_1 & m_2 & m_3 \end{pmatrix} \begin{pmatrix} l_1 & l_2 & l_3 \\ 0 & 0 & 0 \end{pmatrix}. \\ \end{aligned}\]
CGcoefficient.sixJ — Function
sixJ(j1::Real, j2::Real, j3::Real, j4::Real, j5::Real, j6::Real)Wigner 6j-symbol
\[\begin{Bmatrix} j_1 & j_2 & j_3 \\ j_4 & j_5 & j_6 \end{Bmatrix}\]
CGcoefficient.nineJ — Function
nineJ(j1::Real, j2::Real, j3::Real,
j4::Real, j5::Real, j6::Real,
j7::Real, j8::Real, j9::Real)Wigner 9j-symbol
\[\begin{Bmatrix} j_1 & j_2 & j_3 \\ j_4 & j_5 & j_6 \\ j_7 & j_8 & j_9 \end{Bmatrix}\]
CGcoefficient.norm9J — Function
norm9J(j1::Real, j2::Real, j3::Real,
j4::Real, j5::Real, j6::Real,
j7::Real, j8::Real, j9::Real)normalized Wigner 9j-symbol
\[\begin{bmatrix} j_1 & j_2 & j_3 \\ j_4 & j_5 & j_6 \\ j_7 & j_8 & j_9 \end{bmatrix} = \sqrt{(2j_3+1)(2j_6+1)(2j_7+1)(2j_8+1)} \begin{Bmatrix} j_1 & j_2 & j_3 \\ j_4 & j_5 & j_6 \\ j_7 & j_8 & j_9 \end{Bmatrix}\]
CGcoefficient.lsjj — Function
lsjj(l1::Integer, l2::Integer, j1::Real, j2::Real, L::Integer, S::Integer, J::Integer)LS-coupling to jj-coupling transformation coefficient
\[\langle l_1l_2L,s_1s_2S;J|l_1s_1j_1,l_2s_2j_2;J\rangle = \begin{bmatrix}l_1 & s_1 & j_1 \\ l_2 & s_2 & j_2 \\ L & S & J\end{bmatrix}\]
CGcoefficient.Racah — Function
Racah(j1::Real, j2::Real, j3::Real, j4::Real, j5::Real, j6::Real)Racah coefficient
\[W(j_1j_2j_3j_4, j_5j_6) = (-1)^{j_1+j_2+j_3+j_4} \begin{Bmatrix} j_1 & j_2 & j_5 \\ j_4 & j_3 & j_6 \end{Bmatrix}\]
CGcoefficient.Moshinsky — Function
Moshinsky(N::Integer, L::Integer, n::Integer, l::Integer, n1::Integer, l1::Integer, n2::Integer, l2::Integer, Λ::Integer, D::Union{Rational,Integer}=1)Moshinsky bracket,Ref: Buck et al. Nuc. Phys. A 600 (1996) 387-402. This function is designed for demonstration the exact result, It only calculate the case of $\tan(\beta) = \sqrt{m_1\omega_1/m_2\omega_2} = 1$.
People often use double of angular momentum quantum number as parameters, so we can use integer as parameters. This package also offers such functions, where the d letter means double. These functions also give out exact SqrtRational results.
CGcoefficient.dCG — Function
dCG(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)CG coefficient function with double angular monentum number parameters, so that the parameters can be integer. You can calculate dCG(1, 1, 2, 1, 1, 2) to calculate the real CG(1//2, 1//2, 1, 1/2, 1//2, 1)
CGcoefficient.d3j — Function
d3j(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)3j-symbol function with double angular monentum number parameters, so that the parameters can be integer.
CGcoefficient.d6j — Function
d6j(dj1::Integer, dj2::Integer, dj3::Integer, dj4::Integer, dj5::Integer, dj6::Integer)6j-symbol function with double angular monentum number parameters, so that the parameters can be integer.
CGcoefficient.d9j — Function
d9j(dj1::Integer, dj2::Integer, dj3::Integer,
dj4::Integer, dj5::Integer, dj6::Integer,
dj7::Integer, dj8::Integer, dj9::Integer)9j-symbol function with double angular monentum number parameters, so that the parameters can be integer.
CGcoefficient.dRacah — Function
dRacah(dj1::Integer, dj2::Integer, dj3::Integer, dj4::Integer, dj5::Integer, dj6::Integer)Racah coefficient function with double angular momentum parameters, so that the parameters can be integer.
float version functions
Float version functions is always used for numeric calculation. They are designed for fast calculation. You should call wigner_init_float to reserve the inner binomial table. They only resive Integer arguments, thus fCG, f3j, f6j, fRacha, f9j only resive arguements which are double of the exact quantum number. In some functions, e.g. flsjj, some quantum number can be half-integer, the corresponding arguments start with d (which mean double of the quantum number); while some other quantum number must be integer, the corresponding arguments does not starts with d.
CGcoefficient.wigner_init_float — Function
wigner_init_float(n::Integer, mode::AbstractString, rank::Integer)We calculate the Wigner Symbols with binomials. We will store some binomials first, then when we need one binomial, we just load it. In this package, the functions starts with f character dependent on the stored binomials. The wigner_init_float function is used to extend the range of the stored binomial table.
The parameters means:
mode:"Jmax": set the maximum angular momentum in the system."2bjmax": set the maximum two-body coupled angular momentum in the system."nmax": directly set the maximum binomial number."Moshinsky": set the maximumN = 2n+lin the Moshinsky bracket.
n: the maximum angular momentum or the maximum binomial number, dependent on themode.rank:3: calculate only CG coefficients and 3j symbols.6: calculate CG coefficients, 3j symbols and 6j symbols.9: calculate CG coefficients, 3j symbols, 6j symbols and 9j symbols.
"Jmax" means the global maximum angular momentum, for every parameters. It is always safe with out any assumption.
The "2bjmax" mode means your calculation only consider two-body coupling, and no three-body coupling. This mode assumes that in all these coefficients, at least one of the angular momentun is just a single particle angular momentum. With this assumption, "2bjmax" mode will use less memory than "Jmax" mode.
The "Moshinsky" mode means you want to calculate the Moshinsky brackets. The n parameter is the maximum N = 2n+l in the Moshinsky bracket. The rank parameter is ignored.
The "nmax" mode directly set nmax, and the rank parameter is ignored.
For example
wigner_init_float(21, "Jmax", 6)means you calculate CG and 6j symbols, and donot calculate 9j symbol. The maximum angular momentum in your system is 21.
The exact values of the maximum nmax for different rank are shown in the table below (details).
| Calculate range | CG & 3j | 6j & Racah | 9j | |
|---|---|---|---|---|
meaning of type | type\rank | 3 | 6 | 9 |
| max angular momentum | "Jmax" | 3Jmax+1 | 4Jmax+1 | 5Jmax+1 |
| max two-body coupled angular momentum | "2bjmax" | 2jmax+1 | 3jmax+1 | 4jmax+1 |
| max $N = 2n+l$ for Moshinsky bracket | "Moshinsky" | 6Nmax+1 | 6Nmax+1 | 6Nmax+1 |
| max binomial | "nmax" | nmax | namx | nmax |
You do not need to rememmber those values in the table. You just need to find the maximum angular momentum in you canculation, then call the function.
The wigner_init_float function is not thread safe, so you should call it before you start your calculation.
CGcoefficient.fbinomial — Function
fbinomial(n::Integer, k::Integer)binomial with Float64 return value.
CGcoefficient.unsafe_fbinomial — Function
function unsafe_fbinomial(n::Int, k::Int)Same as fbinomial, but without bounds check. Thus for n < 0 or n > _nmax or k < 0 or k > n, the result is undefined. In Wigner symbol calculation, the mathematics guarantee that unsafe_fbinomial(n, k) is always safe.
CGcoefficient.fCG — Function
fCG(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)float64 and fast CG coefficient.
CGcoefficient.fCG0 — Function
fCG0(dj1::Integer, dj2::Integer, dj3::Integer)float64 and fast CG coefficient for m1 == m2 == m3 == 0.
CGcoefficient.fCGspin — Function
fCGspin(ds1::Integer, ds2::Integer, S::Integer)float64 and fast CG coefficient for two spin-1/2 coupling.
CGcoefficient.fCG3spin — Function
fCG3spin(ds1::Integer, ds2::Integer, ds3::Integer, S12::Integer, dS::Integer)float64 and fast CG coefficient for three spin-1/2 coupling: <S12,M12|1/2,m1;1/2,m2><S,M|S12,M12;1/2,m3>
CGcoefficient.f3j — Function
f3j(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)float64 and fast Wigner 3j symbol.
CGcoefficient.f6j — Function
f6j(dj1::Integer, dj2::Integer, dj3::Integer, dj4::Integer, dj5::Integer, dj6::Integer)float64 and fast Wigner 6j symbol.
CGcoefficient.fRacah — Function
Racah(dj1::Integer, dj2::Integer, dj3::Integer, dj4::Integer, dj5::Integer, dj6::Integer)float64 and fast Racah coefficient.
CGcoefficient.f9j — Function
f9j(dj1::Integer, dj2::Integer, dj3::Integer,
dj4::Integer, dj5::Integer, dj6::Integer,
dj7::Integer, dj8::Integer, dj9::Integer)float64 and fast Wigner 9j symbol.
CGcoefficient.fnorm9j — Function
fnorm9j(dj1::Integer, dj2::Integer, dj3::Integer,
dj4::Integer, dj5::Integer, dj6::Integer,
dj7::Integer, dj8::Integer, dj9::Integer)float64 and fast normalized Wigner 9j symbol.
CGcoefficient.flsjj — Function
lsjj(l1::Integer, l2::Integer, dj1::Integer, dj2::Integer, L::Integer, S::Integer, J::Integer)float64 and fast lsjj coefficient.
CGcoefficient.fMoshinsky — Function
fMoshinsky(N::Integer, L::Integer, n::Integer, l::Integer, n1::Integer, l1::Integer, n2::Integer, l2::Integer, tanβ::Float64 = 1.0)float64 and fast Moshinsky bracket.
CGcoefficient.dfunc — Function
dfunc(dj::Integer, dm1::Integer, dm2::Integer, β::Float64)Wigner d-function.
prime factorization version
I implement a primary version of the prime factorization algorithm, based on the wigxjpf library.
CGcoefficient.PFRational — Type
PFRational{T<:Integer} <: RealA positive rational number in prime factorization form.
\[q = \prod_{i=1}^{n} p_i^{e_i}\]
where $p_i$ is the $i$-th prime number and $e_i$ can be negative.
CGcoefficient.wigner_init_pf — Function
wigner_init_pf(n::Integer, mode::AbstractString, rank::Integer)Initialize the prime factorization tables for Wigner symbols. The parameters are similar to wigner_inif_float. You must call this function before using the e and ef versions of Wigner symbols.
CGcoefficient.pf_binomial — Function
pf_binomial(n::Integer, k::Integer)::PFRational{Int16}Return the stored binomial coefficient C(n, k) in prime factorization form.
CGcoefficient.eCG — Function
eCG(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)::SqrtRational{BigInt}Exact CG coefficient using prime factorization algorithm.
CGcoefficient.eCG0 — Function
eCG0(j1::Integer, j2::Integer, j3::Integer)::SqrtRational{BigInt}Exact CG coefficient (m1 = m2 = m3 = 0) using prime factorization algorithm.
CGcoefficient.e3j — Function
e3j(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)::SqrtRational{BigInt}Exact 3j symbol using prime factorization algorithm.
CGcoefficient.e6j — Function
e6j(j1::Integer, j2::Integer, j3::Integer, j4::Integer, j5::Integer, j6::Integer)::SqrtRational{BigInt}Exact 6j symbol using prime factorization algorithm.
CGcoefficient.efCG — Function
efCG(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)::Float64Exact CG coefficient (Float64) using prime factorization algorithm.
CGcoefficient.efCG0 — Function
efCG0(j1::Integer, j2::Integer, j3::Integer)::Float64Exact CG coefficient (m1 = m2 = m3 = 0) (Float64) using prime factorization algorithm.
CGcoefficient.ef3j — Function
ef3j(dj1::Integer, dj2::Integer, dj3::Integer, dm1::Integer, dm2::Integer, dm3::Integer)::Float64Exact 3j symbol (Float64) using prime factorization algorithm.
CGcoefficient.ef6j — Function
ef6j(j1::Integer, j2::Integer, j3::Integer, j4::Integer, j5::Integer, j6::Integer)::Float64Exact 6j symbol (Float64) using prime factorization algorithm.