clean up tests

This commit is contained in:
Jutho Haegeman 2019-07-29 17:18:53 +02:00
parent 52d2255d64
commit 2800b274ea

View file

@ -11,8 +11,9 @@ largejlist = 0:1//2:1000
@testset "triangle coefficient" begin @testset "triangle coefficient" begin
for j1 in smalljlist, j2 in smalljlist for j1 in smalljlist, j2 in smalljlist
for j3 = abs(j1-j2):(j1+j2) for j3 = abs(j1-j2):(j1+j2)
@test Δ(j1,j2,j3) sqrt(factorial(big(Int(j1+j2-j3)))*factorial(big(Int(j1-j2+j3)))* @test Δ(j1,j2,j3) sqrt(factorial(big(Int(j1+j2-j3)))*
factorial(big(Int(j2+j3-j1)))/factorial(big(Int(j1+j2+j3+1)))) factorial(big(Int(j1-j2+j3)))*factorial(big(Int(j2+j3-j1)))/
factorial(big(Int(j1+j2+j3+1))))
end end
end end
end end
@ -50,7 +51,9 @@ end
Y = (2*j+1)*((m2+m3)*(j2*(j2+1)-j3*(j3+1)) - (m2-m3)*j*(j+1)) 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)) 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) 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 end
end end
@ -115,14 +118,17 @@ end
l3 = convert(BigFloat,rand(abs(l1-j2):min(l1+j2))) l3 = convert(BigFloat,rand(abs(l1-j2):min(l1+j2)))
for j in intersect(abs(j2-j3):(j2+j3), abs(l2-l3):(l2+l3)) 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)) 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)) + 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) ) + l2*(l2+1)*( j*(j+1) + j2*(j2+1) - j3*(j3+1) ) +
l3*(l3+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) * 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) ) (j^2-(l2-l3)^2) * ((l2+l3+1)^2-j^2) )
tol = 10 * max(abs(X), abs(Y), abs(Z)) * eps(BigFloat) 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 end
end end
@ -153,7 +159,8 @@ end
clebschgordan(j1,m1,J23,m2+m3,J) clebschgordan(j1,m1,J23,m2+m3,J)
end end
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 end
end end