Function for constructing V matrix

This commit is contained in:
Nuwan Yapa 2024-03-07 20:47:50 -05:00
parent 9741b0bb60
commit 13f315dc56
3 changed files with 20 additions and 6 deletions

View File

@ -54,8 +54,6 @@ function get_2p_basis(E_max)
return (Es, n1s, l1s, n2s, l2s) return (Es, n1s, l1s, n2s, l2s)
end end
get_V_matrix(V_l, ls, ns) = throw("unimplemented")
function sp_T_matrix(ns, ls; ω=1.0, μ=1.0) function sp_T_matrix(ns, ls; ω=1.0, μ=1.0)
mat = spzeros(length(ns), length(ns)) mat = spzeros(length(ns), length(ns))
for idx in CartesianIndices(mat) for idx in CartesianIndices(mat)
@ -74,6 +72,17 @@ function sp_T_matrix(ns, ls; ω=1.0, μ=1.0)
return (ω / μ) .* mat return (ω / μ) .* mat
end end
function sp_V_matrix(V_l, ns, ls; dtype=Float64)
mat = spzeros(dtype, length(ns), length(ns))
for idx in CartesianIndices(mat)
(i, j) = Tuple(idx)
if ls[i] == ls[j]
mat[idx] = V_l(ls[i], ns[i], ns[j])
end
end
return mat
end
get_H_matrix(V_l, ns, ls) = get_T_matrix(ns, ls) + get_V_matrix(V_l, ns, ls) get_H_matrix(V_l, ns, ls) = get_T_matrix(ns, ls) + get_V_matrix(V_l, ns, ls)
function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ) function Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ)

View File

@ -15,7 +15,9 @@ ns = collect(0:n_max)
ls = fill(l, n_max + 1) ls = fill(l, n_max + 1)
T = sp_T_matrix(ns, ls; ω=ω, μ=μ) T = sp_T_matrix(ns, ls; ω=ω, μ=μ)
V = V1 .* V_Gaussian.(R1, l, ns, transpose(ns); ω=ω) + V2 .* V_Gaussian.(R2, l, ns, transpose(ns); ω=ω)
V_l(l, n1, n2) = V1 * V_Gaussian(R1, l, n1, n2; ω=ω) + V2 * V_Gaussian(R2, l, n1, n2; ω=ω)
V = sp_V_matrix(V_l, ns, ls; dtype=ComplexF64)
cs = range(1.25, 0.25, 10) cs = range(1.25, 0.25, 10)
@ -24,7 +26,7 @@ bench_E = similar(cs, ComplexF64)
for (j, c) in enumerate(cs) for (j, c) in enumerate(cs)
H = T + c .* V H = T + c .* V
evals = eigvals(H) evals = eigvals(collect(H))
bench_E[j] = quick_pole_E((p, q) -> c*(V1*g0(R1, p, q) + V2*g0(R2, p, q)), μ; cs_angle=0.4, meshpoints=512) bench_E[j] = quick_pole_E((p, q) -> c*(V1*g0(R1, p, q) + V2*g0(R2, p, q)), μ; cs_angle=0.4, meshpoints=512)
i = argmin(abs.(evals .- bench_E[j])) i = argmin(abs.(evals .- bench_E[j]))
E[j] = evals[i] E[j] = evals[i]

View File

@ -10,7 +10,10 @@ ns = collect(0:n_max)
ls = fill(l, n_max + 1) ls = fill(l, n_max + 1)
T = sp_T_matrix(ns, ls) T = sp_T_matrix(ns, ls)
V = V0 .* V_Gaussian.(R, l, ns, transpose(ns))
V_l(l, n1, n2) = V0 * V_Gaussian(R, l, n1, n2)
V = sp_V_matrix(V_l, ns, ls)
H = T + V H = T + V
eigvals(H) eigvals(collect(H))