mirror of
https://github.com/tgorordo/WignerSymbols.jl.git
synced 2026-06-05 15:42:15 -07:00
clean up tests
This commit is contained in:
parent
52d2255d64
commit
2800b274ea
1 changed files with 18 additions and 11 deletions
|
|
@ -11,8 +11,9 @@ largejlist = 0:1//2:1000
|
|||
@testset "triangle coefficient" begin
|
||||
for j1 in smalljlist, j2 in smalljlist
|
||||
for j3 = abs(j1-j2):(j1+j2)
|
||||
@test Δ(j1,j2,j3) ≈ sqrt(factorial(big(Int(j1+j2-j3)))*factorial(big(Int(j1-j2+j3)))*
|
||||
factorial(big(Int(j2+j3-j1)))/factorial(big(Int(j1+j2+j3+1))))
|
||||
@test Δ(j1,j2,j3) ≈ sqrt(factorial(big(Int(j1+j2-j3)))*
|
||||
factorial(big(Int(j1-j2+j3)))*factorial(big(Int(j2+j3-j1)))/
|
||||
factorial(big(Int(j1+j2+j3+1))))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -40,17 +41,19 @@ end
|
|||
# test recurrence relations: Phys Rev E 57, 7274 (1998)
|
||||
@testset "wigner3j: test recurrence relations" begin
|
||||
for k = 1:10
|
||||
j2 = convert(BigFloat,rand(0:1//2:1000))
|
||||
j3 = convert(BigFloat,rand(0:1//2:1000))
|
||||
m2 = convert(BigFloat,rand(-j2:j2))
|
||||
m3 = convert(BigFloat,rand(-j3:j3))
|
||||
j2 = convert(BigFloat, rand(0:1//2:1000))
|
||||
j3 = convert(BigFloat, rand(0:1//2:1000))
|
||||
m2 = convert(BigFloat, rand(-j2:j2))
|
||||
m3 = convert(BigFloat, rand(-j3:j3))
|
||||
|
||||
for j in max(abs(j2-j3),abs(m2+m3))+1:(j2+j3)-1
|
||||
X = j*sqrt(((j+1)^2-(j2-j3)^2)*((j2+j3+1)^2-(j+1)^2)*((j+1)^2-(m2+m3)^2))
|
||||
Y = (2*j+1)*((m2+m3)*(j2*(j2+1)-j3*(j3+1)) - (m2-m3)*j*(j+1))
|
||||
Z = (j+1)*sqrt((j^2-(j2-j3)^2)*((j2+j3+1)^2-j^2)*(j^2-(m2+m3)^2))
|
||||
tol = 10*max(abs(X),abs(Y),abs(Z))*eps(BigFloat)
|
||||
@test (X*wigner3j(BigFloat,j+1,j2,j3,-m2-m3,m2,m3) + Z*wigner3j(BigFloat,j-1,j2,j3,-m2-m3,m2,m3))≈(-Y*wigner3j(BigFloat,j,j2,j3,-m2-m3,m2,m3)) atol=tol
|
||||
@test (X*wigner3j(BigFloat,j+1,j2,j3,-m2-m3,m2,m3) +
|
||||
Z*wigner3j(BigFloat,j-1,j2,j3,-m2-m3,m2,m3)) ≈
|
||||
(-Y*wigner3j(BigFloat,j,j2,j3,-m2-m3,m2,m3)) atol=tol
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -115,14 +118,17 @@ end
|
|||
l3 = convert(BigFloat,rand(abs(l1-j2):min(l1+j2)))
|
||||
|
||||
for j in intersect(abs(j2-j3):(j2+j3), abs(l2-l3):(l2+l3))
|
||||
X = j*sqrt(((j+1)^2-(j2-j3)^2)*((j2+j3+1)^2-(j+1)^2)*((j+1)^2-(l2-l3)^2)*((l2+l3+1)^2 - (j+1)^2))
|
||||
Y = (2*j+1)*( j*(j+1)*( -j*(j+1) + j2*(j2+1) + j3*(j3+1) - 2*l1*(l1+1)) +
|
||||
X = j * sqrt( ((j+1)^2-(j2-j3)^2) * ((j2+j3+1)^2-(j+1)^2) *
|
||||
((j+1)^2-(l2-l3)^2) * ((l2+l3+1)^2 - (j+1)^2) )
|
||||
Y = (2*j+1) * ( j*(j+1)*( -j*(j+1) + j2*(j2+1) + j3*(j3+1) - 2*l1*(l1+1)) +
|
||||
l2*(l2+1)*( j*(j+1) + j2*(j2+1) - j3*(j3+1) ) +
|
||||
l3*(l3+1)*( j*(j+1) - j2*(j2+1) + j3*(j3+1) ) )
|
||||
Z = (j+1) * sqrt( (j^2-(j2-j3)^2) * ((j2+j3+1)^2-j^2) *
|
||||
(j^2-(l2-l3)^2) * ((l2+l3+1)^2-j^2) )
|
||||
tol = 10 * max(abs(X), abs(Y), abs(Z)) * eps(BigFloat)
|
||||
@test (X*wigner6j(BigFloat,j+1,j2,j3,l1,l2,l3) + Z*wigner6j(BigFloat,j-1,j2,j3,l1,l2,l3))≈(-Y*wigner6j(BigFloat,j,j2,j3,l1,l2,l3)) atol=tol
|
||||
@test (X*wigner6j(BigFloat, j+1, j2, j3, l1, l2, l3) +
|
||||
Z*wigner6j(BigFloat, j-1, j2, j3, l1, l2, l3)) ≈
|
||||
(-Y*wigner6j(BigFloat, j, j2, j3, l1, l2, l3)) atol=tol
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -153,7 +159,8 @@ end
|
|||
clebschgordan(j1,m1,J23,m2+m3,J)
|
||||
end
|
||||
end
|
||||
@test racahW(j1,j2,J,j3,J12,J23) ≈ dot(V2,V1)/sqrt((2*J12+1)*(2*J23+1)) atol=10*eps(Float64)
|
||||
@test racahW(j1,j2,J,j3,J12,J23) ≈
|
||||
dot(V2,V1)/sqrt((2*J12+1)*(2*J23+1)) atol=10*eps(Float64)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue