diff --git a/calculations/3body_dis_HO_EC.jl b/calculations/3body_dis_HO_EC.jl new file mode 100644 index 0000000..d123813 --- /dev/null +++ b/calculations/3body_dis_HO_EC.jl @@ -0,0 +1,97 @@ +using Arpack, SparseArrays, LRUCache +using DelimitedFiles, Plots +include("../ho_basis.jl") + +Λ = 0 +m = 1.0 + +# Distinguishable particles: V12 = bound and V13 & V23 = resonant +Va_of_r(r) = -2 * exp(-r^2/4) +Vb_of_r(r) = -exp(-r^2 / 3) + exp(-r^2 / 10) + +E_max = 40 +μω_global = 0.4 * exp(-2im * pi / 9) + +# due to Jacobi coordinates +μ1ω1 = μω_global * 1/2 +μ2ω2 = μω_global * 2 +μ1 = m * 1/2 +μ2 = m * 2/3 + +println("No of threads = ", Threads.nthreads()) + +Es, n1s, l1s, n2s, l2s = get_2p_basis(E_max, Λ) +l_max = max(maximum(l1s), maximum(l2s)) +n_max = max(maximum(n1s), maximum(n2s)) +mask1 = (n2s .== n2s') .&& (l2s .== l2s') +mask2 = (n1s .== n1s') .&& (l1s .== l1s') + +println("Basis size = ", length(Es)) + +@time "T1" T1 = get_sp_T_matrix(n1s, l1s; mask=mask1, μω_gen=μ1ω1, μ=μ1) +@time "T2" T2 = get_sp_T_matrix(n2s, l2s; mask=mask2, μω_gen=μ2ω2, μ=μ2) + +@time "Va" Va = get_jacobi_V1_matrix(Va_of_r, E_max, Λ, μ1ω1) +@time "Vb" Vb = get_jacobi_V2_matrix(Vb_of_r, E_max, Λ, μω_global) + +@time "Ha" Ha = T1 + T2 + Va +@time "Eigenvalues" target_evals, _ = eigs(Ha, nev=5, ncv=50, which=:SR, maxiter=5000, tol=1e-5, ritzvec=false, check=1) + +display(target_evals) + +# free memory +Es = n1s = l1s = n2s = l2s = mask1 = mask2 = T1 = T2 = V1_cache = V_relative_cache = V1 = V_relative = U = V2 = nothing +GC.gc() + +training_c = [-0.5, -0.65, -0.8, -1, -1.2] +extrapolating_c = [0.8, 0.6, 0.4, 0.2, 0.1, 0.0, -0.1, -0.2, -0.3] + +current_E = -0.5173809356244544 + +exact = ComplexF64[] +training = ComplexF64[] +extrapolated = ComplexF64[] +training_vecs = Vector{ComplexF64}[] + +for c in training_c + print("Training for c = $c: ") + H = Ha + c .* Vb + evals, evecs = eigs(H, nev=3, ncv=24, which=:SR, maxiter=5000, tol=1e-5, ritzvec=true, check=1) + + global current_E = nearest(evals, current_E) + println(current_E) + push!(training, current_E) + push!(training_vecs, evecs[:, nearestIndex(evals, current_E)]) +end + +# CA-EC +training_vecs = vcat(training_vecs, conj(training_vecs)) + +EC_basis = hcat(training_vecs...) +N_EC = transpose(EC_basis) * EC_basis +Ha_EC = transpose(EC_basis) * Ha * EC_basis +Vb_EC = transpose(EC_basis) * Vb * EC_basis + +current_E = -0.3005521915662689 - 0.13612069020686351im + +for c in extrapolating_c + print("Extrapolating for c = $c: ") + H = Ha + c .* Vb + evals, evecs = eigs(H, nev=3, ncv=24, which=:SR, maxiter=5000, tol=1e-5, ritzvec=true, check=1) + + global current_E = nearest(evals, current_E) + println(current_E) + push!(exact, current_E) + + # extrapolation + H_EC = Ha_EC + c .* Vb_EC + evals = eigvals(H_EC, N_EC) + push!(extrapolated, nearest(evals, current_E)) +end + +# exportCSV("temp/dis_HO_B2R.csv", (training, exact, extrapolated), ("training", "exact", "extrapolated")) + +scatter(real.(training),imag.(training), label="training") +scatter!(real.(exact),imag.(exact), label="exact") +scatter!(real.(extrapolated),imag.(extrapolated), label="extrapolated") +savefig("temp/dis_HO_B2R.pdf") \ No newline at end of file diff --git a/ho_basis.jl b/ho_basis.jl index 0d1bcf0..ef2d316 100644 --- a/ho_basis.jl +++ b/ho_basis.jl @@ -141,6 +141,12 @@ function pick_Moshinsky_bracket(BRAC, n1′, l1′, n2′, l2′, n1, l1, n2, l2 end function get_jacobi_V_matrix(V_of_r, E_max, Λ, μ1ω1, μω_global; atol=10^-6, maxevals=10^5) + V1 = get_jacobi_V1_matrix(V_of_r, E_max, Λ, μ1ω1; atol=atol, maxevals=maxevals) + V2 = get_jacobi_V2_matrix(V_of_r, E_max, Λ, μω_global; atol=atol, maxevals=maxevals) + return V1 + V2 +end + +function get_jacobi_V1_matrix(V_of_r, E_max, Λ, μ1ω1; atol=10^-6, maxevals=10^5) _, n1s, l1s, n2s, l2s = get_2p_basis(E_max, Λ) l_max = max(maximum(l1s), maximum(l2s)) n_max = max(maximum(n1s), maximum(n2s)) @@ -150,9 +156,7 @@ function get_jacobi_V_matrix(V_of_r, E_max, Λ, μ1ω1, μω_global; atol=10^-6, V1_cache = LRU{Tuple{UInt8, UInt8, UInt8}, ComplexF64}(maxsize=(1+l_max)*(1+n_max)^2) V1 = get_sp_V_matrix(V1_elem, n1s, l1s; mask=mask1, dtype=ComplexF64, cache=V1_cache) - V2 = get_jacobi_V2_matrix(V_of_r, E_max, Λ, μω_global; atol=atol, maxevals=maxevals) - - return V1 + V2 + return V1 end function get_jacobi_V2_matrix(V_of_r, E_max, Λ, μω_global; atol=10^-6, maxevals=10^5)