forked from naezzell/topological-spin-transport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspectrum_calculation.jl
143 lines (131 loc) · 3.05 KB
/
spectrum_calculation.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
##
using OpenQuantumTools, OrdinaryDiffEq, Plots, LaTeXStrings
using OpenQuantumBase, Optim
include("helperFuncs.jl")
##
# Step 0: Get a sense of Δ(Γ)
##
J = 1
nt = 1
xaxis = []
yaxis = []
for Γ in 0.0:0.01:1
push!(xaxis, Γ)
adj_mat = build_triangular_chain_adjacency_matrix(nt);
x_part, z_part = form_static_ham_ops(adj_mat, J, Γ)
h_static = z_part - x_part
spec = eigvals(h_static)
E0 = spec[1]
j = 2
E1 = spec[j]
while isapprox(E1, E0)
j += 1
E1 = spec[j]
end
Δ = E1 - E0
push!(yaxis, Δ)
end
plot(xaxis, yaxis, label="nt=$(nt)")
title!("Triangular plaquette")
xlabel!("Γ")
ylabel!("Δ")
##
# Step 1: Find Hamiltonian J and Γ values with
# smallest spectrum by minimization
##
function compute_delta(Γ, nt=1)
"""
Computes Δ = E₁-E₀, difference
in energies between ground
sub-space and 1st excited sub-space.
Inputs
Γ -- float, trasverse field strength
nt -- number triangular plaquettes
"""
adj_mat = build_triangular_chain_adjacency_matrix(nt);
x_part, z_part = form_static_ham_ops(adj_mat, J, Γ)
h_static = z_part - x_part
spec = eigvals(h_static)
E0 = spec[1]
j = 2
E1 = spec[j]
while isapprox(E1, E0)
j += 1
E1 = spec[j]
end
Δ = E1 - E0;
return Δ
end
##
##
for Γ=0:0.1:2
adj_mat = build_triangular_chain_adjacency_matrix(nt);
x_part, z_part = form_static_ham_ops(adj_mat, J, Γ)
h_static = z_part - x_part
E = eigvals(h_static)
push!(energy_list, E)
end
##
##
nt = 1
adj_mat = build_triangular_chain_adjacency_matrix(nt);
x_part, z_part = form_static_ham_ops(adj_mat, J, Γ)
h_static = z_part - x_part
H = DenseHamiltonian([(s)-> s, (s)->1-s], [z_part, x_part])
##
##
Γ = 0.1
adj_mat = build_triangular_chain_adjacency_matrix(1);
x_part, z_part = form_static_ham_ops(adj_mat, J, Γ)
h_static = z_part - x_part
E = eigvals(h_static)
##
## perform optimizations
##
nt1_optim = optimize(x -> compute_delta(x, 1), 0.0, 1.0)
nt2_optim = optimize(x -> compute_delta(x, 2), 0.0, 1.0)
nt3_optim = optimize(x -> compute_delta(x, 3), 0.0, 1.0)
##
## step 2a: make combined plot data
##
xaxis=0.0:0.01:1
yaxis = [[], [], []]
for nt=1:3
for Γ in xaxis
push!(yaxis[nt], compute_delta(Γ, nt))
end
end
plot(xaxis, yaxis, label=["nₜ=$(k)" for k=(1:3)'])
xlabel!("Γ")
ylabel!("Δ")
title!("Triangular plaquette")
#for k=2:3
# plot!(xaxis, yaxis[k], label="nₜ = $(k)")
#end
##
## step 2b: make combined plot
##
function find_min_spec(Γmin, Γmax, Δi, iter, Γprev)
"""
Finds minimum spectrum of h_static by
bisection search.
"""
iter += 1
Γ = (Γmax + Γmin) / 2
Δ_iplus1 = compute_delta(Γ)
if iter > 100
if Δ_iplus1 < Δi
return Γ, Δ_iplus1
else
return Γprev, Δi
end
elseif Δ_iplus1 < Δi
Γmax = Γ
find_min_spec(Γmin, Γmax, Δ_iplus1, iter, Γ)
else
Γmin = Γ
find_min_spec(Γmin, Γmax, Δ_iplus1, iter, Γ)
end
end
Γ, Δ = find_min_spec(0, 1, 100, 0, 100)
##