Added triangle inequality checker

This commit is contained in:
Nuwan Yapa 2024-04-16 13:00:57 -04:00
parent ca33915f88
commit 0ff9786bef
2 changed files with 5 additions and 2 deletions

View File

@ -10,3 +10,6 @@ function better_sum(arr::Array{Float64})
end end
better_sum(arr::Array{ComplexF64}) = better_sum(real.(arr)) + 1im * better_sum(imag.(arr)) better_sum(arr::Array{ComplexF64}) = better_sum(real.(arr)) + 1im * better_sum(imag.(arr))
"The triangle inequality for angular momenta"
triangle_ineq(l1, l2, L) = abs(l1 - l2) L && L (l1 + l2)

View File

@ -36,7 +36,7 @@ function get_2p_basis(E_max)
l2s = Int[] l2s = Int[]
# E = 2*n1 + l1 + 2*n2 + l2 # E = 2*n1 + l1 + 2*n2 + l2
for E in 0 : 2*E_max for E in 2*E_max : -2 : 0
for n1 in 0 : E ÷ 2 for n1 in 0 : E ÷ 2
for n2 in 0 : (E - 2*n1) ÷ 2 for n2 in 0 : (E - 2*n1) ÷ 2
for l1 in 0 : (E - 2*n1 - 2*n2) for l1 in 0 : (E - 2*n1 - 2*n2)
@ -99,7 +99,7 @@ function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ)
(i, j) = Tuple(idx) (i, j) = Tuple(idx)
(Elhs, N, L, n, l) = s[i, :] (Elhs, N, L, n, l) = s[i, :]
(Erhs, n1, l1, n2, l2) = s[j, :] (Erhs, n1, l1, n2, l2) = s[j, :]
if Elhs == Erhs if Elhs == Erhs && triangle_ineq(L, l, Λ) && triangle_ineq(l1, l2, Λ)
mat[i, j] = NuclearToolkit.HObracket_d6j(N, L, n, l, n1, l1, n2, l2, Λ, 1.0, dtri, dcgm0, d6j) mat[i, j] = NuclearToolkit.HObracket_d6j(N, L, n, l, n1, l1, n2, l2, Λ, 1.0, dtri, dcgm0, d6j)
end end
end end