using DelimitedFiles, Plots include("../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 Es = n1s = l1s = n2s = l2s = mask1 = mask2 = 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 EC_basis = hcat(training_vecs...) N_EC = transpose(EC_basis) * EC_basis 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, N_EC) push!(extrapolated, nearest(evals, current_E)) end open("temp/NCSM.training.csv", "w") do f; writedlm(f, hcat(reim(training)...)); end open("temp/NCSM.exact.csv", "w") do f; writedlm(f, hcat(reim(exact)...)); end open("temp/NCSM.extrapolated.csv", "w") do f; writedlm(f, hcat(reim(extrapolated)...)); end 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")