Parallelized V matrix construction

This commit is contained in:
Nuwan Yapa 2024-03-27 18:09:22 -04:00
parent 84a3c61cd5
commit 47b02cf78a
1 changed files with 3 additions and 3 deletions

View File

@ -71,14 +71,14 @@ function sp_T_matrix(ns, ls; ω=1.0, μ=1.0)
end end
function sp_V_matrix(V_l, ns, ls; dtype=Float64) function sp_V_matrix(V_l, ns, ls; dtype=Float64)
mat = spzeros(dtype, length(ns), length(ns)) mat = zeros(dtype, length(ns), length(ns))
for idx in CartesianIndices(mat) Threads.@threads for idx in CartesianIndices(mat)
(i, j) = Tuple(idx) (i, j) = Tuple(idx)
if ls[i] == ls[j] if ls[i] == ls[j]
mat[idx] = V_l(ls[i], ns[i], ns[j]) mat[idx] = V_l(ls[i], ns[i], ns[j])
end end
end end
return mat return sparse(mat)
end end
function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ) function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ)