-
Notifications
You must be signed in to change notification settings - Fork 0
/
bose_hubbard_classical.py
295 lines (255 loc) · 9.1 KB
/
bose_hubbard_classical.py
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# Code for numerical integration of the non-linear Bose-Hubbard equations
# of motion for the boson field in the \hat{b} -> b approximation.
import numpy as np
import scipy
from matplotlib import pyplot as plt
from matplotlib import colors
from matplotlib.colors import LogNorm
from matplotlib.colors import Normalize
from scipy import integrate as inte
import matplotlib as mpl
SMALL_SIZE = 20
MEDIUM_SIZE = 23
BIGGER_SIZE = 25
mpl.rcParams['axes.titlesize'] = SMALL_SIZE # fontsize of the axes title
mpl.rcParams['axes.labelsize'] = MEDIUM_SIZE # fontsize of the x and y labels
mpl.rcParams['xtick.labelsize'] = SMALL_SIZE # fontsize of the tick labels
mpl.rcParams['ytick.labelsize'] = SMALL_SIZE # fontsize of the tick labels
mpl.rcParams['legend.fontsize'] = SMALL_SIZE # legend fontsize
mpl.rcParams['figure.titlesize'] = BIGGER_SIZE # fontsize of the figure title
mpl.rcParams['figure.constrained_layout.use'] = True
import distinctipy
import cmasher as cmr
import colorcet as cc
# hopping matrix for the sawtooth lattice
def hop_sawtooth(n_cells,tAA,tAB):
n_sites = 2*n_cells + 1
hop = np.zeros([n_sites,n_sites],dtype=complex)
for n in range(n_cells):
hop[2*(n+1),2*n] = tAA
hop[2*n,2*(n+1)] = np.conj(tAA)
hop[2*n+1,2*n] = tAB
hop[2*n,2*n+1] = np.conj(tAB)
hop[2*(n+1),2*n+1] = tAB
hop[2*n+1,2*(n+1)] = np.conj(tAB)
return hop
def hop_linear(n_cells,t):
n_sites = n_cells
hop = np.zeros([n_sites,n_sites],dtype=complex)
for n in range(n_cells-1):
hop[n+1,n] = t
hop[n,n+1] = np.conj(t)
return hop
def hop_diamond(n_cells,flux):
n_sites = 3*n_cells+1
hop = np.zeros([n_sites,n_sites],dtype=complex)
for n in range(n_cells):
# Convention of PHYSICAL REVIEW A 99, 013826 (2019)
# hop[3*n,3*n+1] = np.exp(-1.0j*flux/2) # a_n,b_n
# hop[3*n+1,3*n] = np.exp(1.0j*flux/2) # b_n,a_n
# hop[3*n,3*n+2] = 1.0 # a_n,c_n
# hop[3*n+2,3*n] = 1.0 # c_n,a_n
# hop[3*n+1,3*(n+1)] = 1.0 # b_n,a_{n+1}
# hop[3*(n+1),3*n+1] = 1.0 # a_{n+1},b_n
# hop[3*n+2,3*(n+1)] = np.exp(1.0j*flux/2) # c_n,a_{n+1}
# hop[3*(n+1),3*n+2] = np.exp(-1.0j*flux/2) # a_{n+1},c_n
# Convention of PHYSICAL REVIEW A 100, 043829 (2019)
# hop[3*n,3*n+1] = np.exp(1.0j*flux) # a_n,b_n
# hop[3*n+1,3*n] = np.exp(-1.0j*flux) # b_n,a_n
# hop[3*n,3*n+2] = 1.0 # a_n,c_n
# hop[3*n+2,3*n] = 1.0 # c_n,a_n
# hop[3*n+1,3*(n+1)] = 1.0 # b_n,a_{n+1}
# hop[3*(n+1),3*n+1] = 1.0 # a_{n+1},b_n
# hop[3*n+2,3*(n+1)] = 1.0 # c_n,a_{n+1}
# hop[3*(n+1),3*n+2] = 1.0 # a_{n+1},c_n
# Own convention :)
hop[3*n,3*n+1] = -1.0 # a_n,b_n
hop[3*n+1,3*n] = -1.0 # b_n,a_n
hop[3*n,3*n+2] = -1.0 # a_n,c_n
hop[3*n+2,3*n] = -1.0 # c_n,a_n
hop[3*n+1,3*(n+1)] = -np.exp(1.0j*flux) # b_n,a_{n+1}
hop[3*(n+1),3*n+1] = -np.exp(-1.0j*flux) # a_{n+1},b_n
hop[3*n+2,3*(n+1)] = -1.0 # c_n,a_{n+1}
hop[3*(n+1),3*n+2] = -1.0 # a_{n+1},c_n
return hop
def hop_three_site(rAB,tAC,tAB,epsC):
n_sites = 3
tBC = -rAB*tAC
epsA = tAB*(tBC/tAC-tAC/tBC)
hop = np.zeros([n_sites,n_sites],dtype=complex)
hop[0,2] = -tAC
hop[2,0] = -np.conj(tAC)
hop[0,1] = -tAB
hop[1,0] = -np.conj(tAB)
hop[1,2] = -tBC
hop[2,1] = -np.conj(tBC)
hop[0,0] = epsA
hop[2,2] = epsC
return hop
# Calculate the non-linear Hamiltonian with given field values b
def Hb(b,hop,U):
n_sites = b.size
nl_coeff = 2.0*U*np.abs(b)**2
Hb = np.matmul(hop,b) + nl_coeff*b
return Hb
# model independent parameters
Np = 1 # number of particles
n_cells = 2
U = 1.0
gain = 0.0
loss = 0.1
logscale = False
# Start and stop time
start = 0.0
stop = 1000.0
max_step = (stop-start)/1000
lattice = "three_site"
init_type = "left_edge_site"
if lattice == "three_site":
# model parameters, sawtooth
rAB = -5
name = "three_site_"+str(rAB)+"_"
n_sites = 3
tAC = -1.0
tAB = 0.0
VB = 0.0
epsC = 0.0
hop = hop_three_site(rAB,tAC,tAB,epsC)
hop[-1,-1] += -1.0j*loss
hop[0,0] += 1.0j*gain
b0 = np.zeros(n_sites,dtype=complex)
if init_type == "left_edge_site":
b0[0] = 1.0
if init_type == "left_edge_state":
b0[0] = rAB
b0[1] = 1.0
b0 *= np.sqrt(Np)/np.linalg.norm(b0)
if lattice == "sawtooth":
# model parameters, sawtooth
name = "sawtooth"+str(n_cells)
n_sites = 2*n_cells+1
tAA = -1.0
tAB = -np.sqrt(2)
VB = -1.0*tAA
mu = 0.0
hop = hop_sawtooth(n_cells,tAA,tAB)
np.fill_diagonal(hop,-mu)
hop[0,0] += VB
hop[-1,-1] += VB
hop[-1,-1] += -1.0j*loss
hop[0,0] += 1.0j*gain
init_loc = 2
eigs,vecs = np.linalg.eigh(-hop)
print(eigs)
b0 = np.zeros(n_sites,dtype=complex)
if init_type == "left_edge_site":
b0[0] = np.sqrt(Np)
if init_type == "left_edge_state":
b0[0] = np.sqrt(2.0/3.0)*np.sqrt(Np)
b0[1] = -np.sqrt(1.0/3.0)*np.sqrt(Np)
if init_type == "Vstate":
b0[init_loc*2] = -np.sqrt(2)
b0[init_loc*2+1] = 1.0
b0[init_loc*2-1] = 1.0
b0 *= np.sqrt(Np)/np.linalg.norm(b0)
if lattice == "diamond":
# model parameters, diamond
name = "diamond"+str(n_cells)
n_sites = 3*n_cells+1
flux = np.pi
mu = 0.0
#alpha = 1.0/0.1
alpha = 1/0.1
init_loc = 1
hop = hop_diamond(n_cells,flux)
np.fill_diagonal(hop,-mu)
VB = 0.0
hop[-1,-1] += -1.0j*loss
hop[0,0] += 1.0j*gain
b0 = np.zeros(n_sites,dtype=complex)
if init_type == "ABcage":
b0[init_loc*3] = alpha
b0[init_loc*3+1] = -1.0
b0[init_loc*3+2] = 1.0
b0[init_loc*3-1] = 1.0
b0[init_loc*3-2] = 1.0
b0 *= np.sqrt(Np)/np.linalg.norm(b0)
if init_type == "left_edge_site":
b0[0] = np.sqrt(Np)
if init_type == "left_edge_state":
b0[0] = np.sqrt(2)
b0[1] = 1.0
b0[2] = 1.0
b0 *= np.sqrt(Np)/np.linalg.norm(b0)
if lattice == "linear":
# model parameters, linear
n_sites = n_cells
t = -1.0
mu = 0.0
VB = 0.0
hop = hop_linear(n_cells,t)
np.fill_diagonal(hop,-mu)
hop[-1,-1] += -1.0j*loss
hop[0,0] += 1.0j*gain
b0 = np.zeros(n_sites,dtype=complex)
if init_type == "left_edge_site":
b0[0] = 1.0
schr_right = lambda t,b: -1.0j*Hb(b,hop,U)
# time integration
solver = inte.RK45(schr_right,start,b0,stop,max_step=max_step,rtol=1.0e-8)
ts = [0.0]
bs = [b0]
while(solver.status != 'finished'):
solver.step()
ts.append(solver.t)
bs.append(solver.y)
ts = np.asarray(ts)
bs = np.asarray(bs)
# Analysis
fig,ax = plt.subplots()
ns = np.abs(bs.transpose())**2/Np
if logscale:
pos = ax.pcolor(ts,np.linspace(1,n_sites,n_sites),ns,norm=colors.LogNorm(vmin=1e-6, vmax=1.0),cmap=cc.cm.fire,rasterized=True,shading='auto')
else:
pos = ax.pcolor(ts,np.linspace(1,n_sites,n_sites),ns,cmap=cc.cm.fire,shading='auto',norm=Normalize(vmin=1e-4,vmax=Np,clip=True),rasterized=True)
ax.set_xlabel("Time")
ax.set_ylabel("Site")
ax.set_yticks(np.arange(1,n_sites+1,step=1))
cbar = fig.colorbar(pos,ax=ax,pad=0.05)
cbar.set_label("Intensity")
fig2,ax2 = plt.subplots()
ax2.plot(ts,np.sum(np.abs(bs)**2/Np,1))
dcolors = distinctipy.get_colors(3)
bcolors = [(27.0/256,158.0/256,119.0/256),(217.0/256,95.0/256,2.0/256),(117.0/256,112.0/256,179.0/256)]
bcolors = [(27.0/256,158.0/256,119.0/256),\
(217.0/256,95.0/256,2.0/256),\
(117.0/256,112.0/256,179.0/256),\
(231.0/256,41.0/256,138.0/256)]
fig3,ax3 = plt.subplots()
if lattice == "diamond" and n_cells > 1:
ax3.plot(ts,np.sum(ns[0:3,:],0), color = bcolors[0], label="1+2+3")
ax3.plot(ts,np.sum(ns[-3:,:],0), color = bcolors[1], label=str(n_sites-2)+"+"+str(n_sites-1)+"+"+str(n_sites))
elif lattice == "diamond" and n_cells == 1:
ax3.plot(ts,ns[0,:],color = bcolors[0], label ="Left edge site")
ax3.plot(ts,np.sum(ns[1:-1,:],0),color = bcolors[1], label ="Middle sites")
ax3.plot(ts,ns[-1,:],color = bcolors[2], label ="Right edge site")
elif lattice == "sawtooth" and n_cells > 1:
ax3.plot(ts,np.sum(ns[0:2,:],0), color = bcolors[0], label="1+2")
ax3.plot(ts,np.sum(ns[-2:,:],0), color = bcolors[1], label=str(n_sites-1)+"+"+str(n_sites))
elif lattice == "sawtooth" and n_cells == 1:
ax3.plot(ts,ns[0,:],color = bcolors[0], label ="Left edge site")
ax3.plot(ts,ns[1,:],color = bcolors[1], label ="Middle site")
ax3.plot(ts,ns[-1,:],color = bcolors[2], label ="Right edge site")
elif lattice == "three_site":
ax3.plot(ts,ns[0,:],color = bcolors[0], label ="Site 1")
ax3.plot(ts,np.sum(ns[1:,:],0),color = bcolors[1], label ="Sites 2+3")
#ax3.plot(ts,ns[-1,:],color = bcolors[2], label ="Site 3")
#ax3.plot(ts,np.sum(ns[0:2,:],0)/Nb)
ax3.set_xlim([start,stop])
ax3.set_ylim([1e-6,Np+0.05])
ax3.set_xlabel("Time")
ax3.set_ylabel("Intensity")
ax3.legend()
fig.savefig("./Figures/"+name+"_pnum_vs_site_time_classical_U"+str(U)+"_gammaR"+str(loss)+"_VB"+str(VB)+"_"+init_type+".svg",format='svg')
fig3.savefig("./Figures/"+name+"_pnum_vs_time_classical_U"+str(U)+"_VB"+str(VB)+"_"+init_type+".svg",format='svg')
plt.show()