XZ comparison in p-space vs HO
This commit is contained in:
parent
59c22cd3bc
commit
5dbc19bf06
|
|
@ -4,20 +4,6 @@ include("../../EC.jl")
|
||||||
include("../../ho_basis.jl")
|
include("../../ho_basis.jl")
|
||||||
include("../../p_space.jl")
|
include("../../p_space.jl")
|
||||||
|
|
||||||
function solve_E(H0, H1, c_vals, near_E)
|
|
||||||
out_E = ComplexF64[]
|
|
||||||
for c in c_vals
|
|
||||||
println("Solving for c = $c")
|
|
||||||
|
|
||||||
H = H0 + c .* H1
|
|
||||||
|
|
||||||
evals, _ = eigs(H, sigma=near_E, maxiter=5000, ritzvec=false, check=1)
|
|
||||||
new_E = nearest(evals, near_E)
|
|
||||||
push!(out_E, new_E)
|
|
||||||
end
|
|
||||||
return out_E
|
|
||||||
end
|
|
||||||
|
|
||||||
# paramters of the system
|
# paramters of the system
|
||||||
|
|
||||||
angle = 0.0 * pi
|
angle = 0.0 * pi
|
||||||
|
|
@ -29,12 +15,15 @@ V2 = 2
|
||||||
R2 = sqrt(10)
|
R2 = sqrt(10)
|
||||||
|
|
||||||
n_EC = 8
|
n_EC = 8
|
||||||
train_cs = (0.7 .+ 0.05 * randn(n_EC)) - 1im * (0.2 .+ 0.05 * randn(n_EC))
|
train_cs = (0.7 .+ 0.03 * randn(n_EC)) - 1im * (0.2 .+ 0.03 * randn(n_EC))
|
||||||
near_E = 0.2 + 0.2im
|
near_E = 0.2 + 0.2im
|
||||||
|
|
||||||
|
target_c = 0.5
|
||||||
|
exact_E = 0.20845136860234303 - 0.07100640993695649im
|
||||||
|
|
||||||
# HO basis
|
# HO basis
|
||||||
|
|
||||||
HO_Es = zeros(ComplexF64, n_EC)
|
global EC_HO
|
||||||
begin
|
begin
|
||||||
println("HO basis calculation")
|
println("HO basis calculation")
|
||||||
μω_gen = 0.5 * exp(-1im * angle)
|
μω_gen = 0.5 * exp(-1im * angle)
|
||||||
|
|
@ -45,12 +34,14 @@ begin
|
||||||
T = get_sp_T_matrix(ns, ls; μω_gen=μω_gen, μ=μ)
|
T = get_sp_T_matrix(ns, ls; μω_gen=μω_gen, μ=μ)
|
||||||
V = V1 .* V_Gaussian.(R1, l, ns, transpose(ns); μω_gen=μω_gen) + V2 .* V_Gaussian.(R2, l, ns, transpose(ns); μω_gen=μω_gen)
|
V = V1 .* V_Gaussian.(R1, l, ns, transpose(ns); μω_gen=μω_gen) + V2 .* V_Gaussian.(R2, l, ns, transpose(ns); μω_gen=μω_gen)
|
||||||
|
|
||||||
HO_Es .= solve_E(T, V, train_cs, near_E)
|
global EC_HO = affine_EC(T, V)
|
||||||
|
train!(EC_HO, train_cs; ref_eval=near_E, CAEC=false)
|
||||||
|
extrapolate!(EC_HO, [target_c]; precalculated_exact_E=[exact_E])
|
||||||
end
|
end
|
||||||
|
|
||||||
# p-space
|
# p-space
|
||||||
|
|
||||||
p_space_Es = zeros(ComplexF64, n_EC)
|
global EC_p_space
|
||||||
begin
|
begin
|
||||||
println("p-space calculation")
|
println("p-space calculation")
|
||||||
vertices = [0, 4 * exp(-1im * angle)]
|
vertices = [0, 4 * exp(-1im * angle)]
|
||||||
|
|
@ -62,13 +53,19 @@ begin
|
||||||
V = get_V_matrix(V_mat_elem, ks, ws)
|
V = get_V_matrix(V_mat_elem, ks, ws)
|
||||||
T = get_T_matrix(ks, μ)
|
T = get_T_matrix(ks, μ)
|
||||||
|
|
||||||
p_space_Es .= solve_E(T, V, train_cs, near_E)
|
global EC_p_space = affine_EC(T, V)
|
||||||
|
train!(EC_p_space, train_cs; ref_eval=near_E, CAEC=false)
|
||||||
|
extrapolate!(EC_p_space, [target_c]; precalculated_exact_E=[exact_E])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Plotting
|
# Plotting
|
||||||
|
|
||||||
scatter(real.(HO_Es), imag.(HO_Es), label="HO basis", marker=:circle, color=:blue)
|
scatter([real(exact_E)], [imag(exact_E)], label="Exact", marker=:circle, markercolor=:white)
|
||||||
scatter!(real.(p_space_Es), imag.(p_space_Es), label="p-space", marker=:circle, color=:red)
|
scatter!(real.(EC_HO.training_E), imag.(EC_HO.training_E), label="HO basis training", marker=:circle, color=:blue)
|
||||||
|
scatter!(real.(EC_HO.extrapolated_E), imag.(EC_HO.extrapolated_E), label="HO basis extrapolated", marker=:x, color=:blue)
|
||||||
|
scatter!(real.(EC_p_space.training_E), imag.(EC_p_space.training_E), label="p-space training", marker=:circle, color=:red)
|
||||||
|
scatter!(real.(EC_p_space.extrapolated_E), imag.(EC_p_space.extrapolated_E), label="p-space extrapolated", marker=:x, color=:red)
|
||||||
|
plot!(legend=:bottomleft)
|
||||||
xlabel!("Re(E)")
|
xlabel!("Re(E)")
|
||||||
ylabel!("Im(E)")
|
ylabel!("Im(E)")
|
||||||
savefig("temp/2b_p_space_vs_HO.pdf")
|
savefig("temp/2b_p_space_vs_HO.pdf")
|
||||||
Loading…
Reference in New Issue