using LinearAlgebra, SparseArrays, Arpack include("helper.jl") include("p_space.jl") include("berggren.jl") println("No of threads = ", Threads.nthreads()) atol = 10^-5 maxevals = 10^5 Λ = 0 m = 1.0 μ1 = m * 1/2 μ2 = m * 2/3 Va = -2 Ra = 2 V_of_r(r) = Va * exp(-r^2 / Ra^2) V_l(j, k, kp) = Vl_mat_elem(V_of_r, j, k, kp; atol=atol, maxevals=maxevals, R_cutoff=16) vertices = [0, 0.5 - 0.3im, 1, 4] subdivisions = [10, 10, 10] ks, ws = get_mesh(vertices, subdivisions) jmax = 4 tri((j1, j2)) = triangle_ineq(j1, j2, Λ) js = collect(Iterators.filter(tri, Iterators.product(0:jmax, 0:jmax))) basis = collect(Iterators.product(zip(ks, ws), zip(ks, ws), js))[:] basis_size = length(ks)^2 * length(js) @assert length(basis) == basis_size "Something wrong with the basis" println("Basis size = $basis_size") @time "T" begin T_blocks = [kron_sum(get_T_matrix(ks, μ1), get_T_matrix(ks, μ2)) for _ in js] T = blockdiag(sparse.(T_blocks)...) end @time "V1" begin V1_blocks = [kron(get_V_matrix((k, kp) -> V_l(j1, k, kp), ks, ws), I(length(ks))) for (j1, _) in js] V1 = blockdiag(sparse.(V1_blocks)...) end E_max = 30 μω_global = 0.5 μ1ω1 = μω_global * 1/2 μ2ω2 = μω_global * 2 basis_HO = get_2p_basis(E_max, Λ) Es, n1s, l1s, n2s, l2s = basis_HO l_max = max(maximum(l1s), maximum(l2s)) n_max = max(maximum(n1s), maximum(n2s)) mask1 = (n2s .== n2s') .&& (l2s .== l2s') mask2 = (n1s .== n1s') .&& (l1s .== l1s') V_relative_elem(l, n1, n2) = V_numerical(V_of_r, l, n1, n2; μω_gen=μω_global, atol=atol, maxevals=maxevals) V_relative_cache = LRU{Tuple{UInt8, UInt8, UInt8}, Float64}(maxsize=(1+l_max)*(1+n_max)^2) @time "V relative" V_relative = sp_V_matrix(V_relative_elem, n1s, l1s; mask=mask1, dtype=Float64, cache=V_relative_cache) + sp_V_matrix(V_relative_elem, n2s, l2s; mask=mask2, dtype=Float64, cache=V_relative_cache) @time "Moshinsky brackets" U = Moshinsky_transform(Es, n1s, l1s, n2s, l2s, Λ) @time "V2_HO" V2_HO = U' * V_relative * U @time "W_right" W_right = get_W_matrix(basis, basis_HO, μ1ω1, μ2ω2; weights=true) @time "W_left" W_left = get_W_matrix(basis, basis_HO, μ1ω1, μ2ω2; weights=false) @time "V2" V2 = W_left * V2_HO * transpose(W_right) @time "H" H = T + V1 + V2 @time "Eigenvalues" evals, _ = eigs(H, nev=3, ncv=24, which=:SR, maxiter=5000, tol=1e-5, ritzvec=false, check=1) display(evals)