Move B2R into a seperate file

This commit is contained in:
ysyapa 2024-02-15 17:45:15 +00:00
parent 2a19f64f6c
commit 7b5d572247
2 changed files with 46 additions and 43 deletions

46
B2R_test.jl Normal file
View File

@ -0,0 +1,46 @@
using Plots, LinearAlgebra
include("p_space.jl")
vertices = (0, 0.4 - 0.15im, 0.8, 6)
subdivisions = 128
p, w = get_mesh(vertices, subdivisions)
mesh_E = p.*p ./ (2*0.5)
# ResonanceEC: Eq. (20)
V_system(c) = (p, q) -> c*(-5*g0(sqrt(3), p, q) + 2*g0(sqrt(10), p, q))
training_points = range(1.35, 0.9, 5)
training_E = Vector{ComplexF64}(undef, length(training_points))
EC_basis = Matrix{ComplexF64}(undef, length(p), length(training_points))
for (j, c) in enumerate(training_points)
evals, evecs = eigen(get_H_matrix(V_system(c), p, w))
i = identify_pole_i(p, evals)
training_E[j] = evals[i]
EC_basis[:, j] = evecs[:, i]
end
EC_basis = hcat(EC_basis, conj.(EC_basis)) # CA-EC
EC_basis_w = EC_basis .* w
N_EC = transpose(EC_basis_w) * EC_basis
extrapolate_points = range(0.75, 0.40, 8)
exact_E = Vector{ComplexF64}(undef, length(extrapolate_points))
extrapolate_E = Vector{ComplexF64}(undef, length(extrapolate_points))
for (j, c) in enumerate(extrapolate_points)
exact_E[j] = quick_pole_E(V_system(c))
H = get_H_matrix(V_system(c), p, w)
H_EC = transpose(EC_basis_w) * H * EC_basis
evals = eigvals(H_EC, N_EC)
i = argmin(abs.(evals .- exact_E[j]))
extrapolate_E[j] = evals[i]
end
scatter(real.(training_E), imag.(training_E), label="training")
scatter!(real.(exact_E), imag.(exact_E), label="exact")
scatter!(real.(extrapolate_E), imag.(extrapolate_E), label="extrapolated")
plot!(real.(mesh_E), imag.(mesh_E), label="contour")
xlims!(-0.7,0.7)

View File

@ -80,49 +80,6 @@
"plot!(real.(mesh_E), imag.(mesh_E), label=\"contour\")\n", "plot!(real.(mesh_E), imag.(mesh_E), label=\"contour\")\n",
"xlims!(0,1)" "xlims!(0,1)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"training_points = range(1.35, 0.9, 5)\n",
"training_E = Vector{ComplexF64}(undef, length(training_points))\n",
"EC_basis = Matrix{ComplexF64}(undef, length(p), length(training_points))\n",
"\n",
"for (j, c) in enumerate(training_points)\n",
" evals, evecs = eigen(get_H_matrix(V_system(c), p, w))\n",
" i = identify_pole_i(p, evals)\n",
" training_E[j] = evals[i]\n",
" EC_basis[:, j] = evecs[:, i]\n",
"end\n",
"\n",
"EC_basis = hcat(EC_basis, conj.(EC_basis)) # CA-EC\n",
"EC_basis_w = EC_basis .* w\n",
"N_EC = transpose(EC_basis_w) * EC_basis\n",
"\n",
"extrapolate_points = range(0.75, 0.40, 8)\n",
"\n",
"exact_E = Vector{ComplexF64}(undef, length(extrapolate_points))\n",
"extrapolate_E = Vector{ComplexF64}(undef, length(extrapolate_points))\n",
"\n",
"for (j, c) in enumerate(extrapolate_points)\n",
" exact_E[j] = quick_pole_E(V_system(c))\n",
"\n",
" H = get_H_matrix(V_system(c), p, w)\n",
" H_EC = transpose(EC_basis_w) * H * EC_basis\n",
" evals = eigvals(H_EC, N_EC)\n",
" i = argmin(abs.(evals .- exact_E[j]))\n",
" extrapolate_E[j] = evals[i]\n",
"end\n",
"\n",
"scatter(real.(training_E), imag.(training_E), label=\"training\")\n",
"scatter!(real.(exact_E), imag.(exact_E), label=\"exact\")\n",
"scatter!(real.(extrapolate_E), imag.(extrapolate_E), label=\"extrapolated\")\n",
"plot!(real.(mesh_E), imag.(mesh_E), label=\"contour\")\n",
"xlims!(-0.7,0.7)"
]
} }
], ],
"metadata": { "metadata": {