BergEC-jl/calculations/3body_HO_R2R_EC.jl

56 lines
1.7 KiB
Julia

using DelimitedFiles, Plots
include("../ho_basis_3body_resonance.jl")
current_E = 5.9673 - 0.0006im
training_c = 2.0 : -0.2 : 1.2
extrapolating_c = 1.05 .- [0.0 : 0.1 : 0.4; 0.45 : 0.05 : 0.60]
@time "H0" H0 = T1 + T2
# free memory
basis = T1 = T2 = V1_cache = V_relative_cache = V1 = V_relative = U = V2 = nothing
GC.gc()
exact = ComplexF64[]
training = ComplexF64[]
extrapolated = ComplexF64[]
training_vecs = Vector{ComplexF64}[]
for c in training_c
println("Training for c = $c")
local H = H0 + c .* V
local evals, evecs = eigs(H, nev=3, ncv=24, which=:LI, maxiter=5000, tol=1e-5, ritzvec=true, check=1)
global current_E = nearest(evals, current_E)
push!(training, current_E)
push!(training_vecs, evecs[:, nearestIndex(evals, current_E)])
end
println("Original EC dimensionality = $(length(training_vecs))")
@time "Gram-Schmidt" training_vecs = gram_schmidt!(training_vecs; verbose=true) # orthonormalization
EC_basis = hcat(training_vecs...)
H0_EC = transpose(EC_basis) * H0 * EC_basis
V_EC = transpose(EC_basis) * V * EC_basis
for c in extrapolating_c
println("Extrapolating for c = $c")
local H = H0 + c .* V
local evals, evecs = eigs(H, nev=3, ncv=24, which=:LI, maxiter=5000, tol=1e-5, ritzvec=true, check=1)
global current_E = nearest(evals, current_E)
push!(exact, current_E)
# extrapolation
H_EC = H0_EC + c .* V_EC
evals = eigvals(H_EC)
push!(extrapolated, nearest(evals, current_E))
end
exportCSV("temp/NCSM.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/NCSM.pdf")