-
Notifications
You must be signed in to change notification settings - Fork 0
/
flvphs_bsc.py
428 lines (272 loc) · 12.1 KB
/
flvphs_bsc.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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
#!/usr/bin/env python
# coding: utf-8
# In[830]:
import scipy
#import datetime
from scipy.linalg import expm,det
import scipy.sparse as sparse
from quspin.operators import hamiltonian, commutator, exp_op # Hamiltonians and operators
from quspin.basis import tensor_basis, spin_basis_1d # bases
import numpy as np # general math functions
import matplotlib.pyplot as plt # plotting library
#from numba import jit
from scipy.integrate import solve_ivp,odeint
#from functools import reuce
import sys
# In[831]:
class constructor_LGT:
def __init__(self,N,L,g,m_1,m_2,pen,bc):
self.no_checks = dict(check_pcon=False,check_symm=False,check_herm=False)
self.l = 1
self.N = N #number of lattice sites
self.L = L #number of links
self.g = g #coupling constant
self.m_1 = m_1 #mass of the 1st specie
self.m_2 = m_2 #mass of the 1st specie
self.pen = pen #lagrange multiplier in the penalty term
self.bc = bc # 0 - non-twisted bc, 1 - twisted bc
self.basis = self.initialise_basis()
self.hE_coeff_ar = self.hE_coeff() #Taylor coeff. of (-1)^E
self.Proj_even_coeff_ar = self.Proj_even_coeff() #Taylor coeff. of P_1(n = even)
self.Proj_odd_coeff_ar = self.Proj_odd_coeff() #Taylor coeff. of P_1(n = odd)
self.Proj_0_even_coeff_ar = self.Proj_0_even_coeff() #Taylor coeff. of P_1(n = even)
self.Proj_0_odd_coeff_ar = self.Proj_0_odd_coeff() #Taylor coeff. of P_0(n = odd)
self.Gauss_law_ar = [] #Gauss laws
self.Proj_ar = [] #Projectors on 1
self.Proj_0_ar = [] #Projectors on 0
self.h_E_ar = [] #(-1)^E
self.h_U_ar = [] #U
self.h_U_dag_ar = [] #U^dagger
self.interaction_1_ar = [] #\sigma^+ U \sigma^- + h.c.
for i in range(N):
self.Gauss_law_ar.append(self.Gauss_law(i))
self.Proj_ar.append(self.Proj(i))
self.Proj_0_ar.append(self.Proj_0(i))
self.h_E_ar.append(self.h_E(i))
self.h_U_ar.append(self.h_U(i))
self.h_U_dag_ar.append(self.h_U_dag(i))
self.interaction_1_ar.append(self.interaction_1(i))
def initialise_basis(self):
basis_link =spin_basis_1d(L=self.L,S = str(self.l)) #spin - d on the links
basis_aux =spin_basis_1d(L=self.N,S = "1/2",pauli = -1) #spin - 1/2 on the sites
basis=tensor_basis(basis_link,basis_aux)
return basis
def check_hermitian(self,a):
norm = scipy.sparse.linalg.norm(a-a.T.conj())
if norm <= 1e-3:
return("True")
else:
print("The norm is not zero:",norm)
return("False")
def hE_coeff(self):
A = np.zeros((int(2*self.l)+1,int(2*self.l)+1), dtype = complex)
for i in range(int(2*self.l)+1):
for j in range(int(2*self.l)+1):
A[i][j] = (-self.l+i)**j
a = np.zeros(int(2*self.l)+1,dtype = complex)
for i in range(int(2*self.l)+1):
a[i] = (-1)**(-self.l+i)
solution = scipy.linalg.solve(A,a)
x = np.zeros(int(2*3/2)+1, dtype = complex)
for i in range(int(2*self.l)+1):
x[i] = solution[i]
return x
def Proj_even_coeff(self):
B = np.zeros((int(4*self.l)+2,int(4*self.l)+2))
for i in range(int(4*self.l)+2):
for j in range(int(4*self.l)+2):
B[i][j] = (-int(2*self.l)+i-1)**j
b = np.zeros(int(4*self.l)+2)
b[int(2*self.l)+2] = 1.
solution = scipy.linalg.solve(B,b)
y = np.zeros(int(4*3/2)+2)
for i in range(int(4*self.l)+2):
y[i] = solution[i]
return y
def Proj_odd_coeff(self):
C = np.zeros((int(4*self.l)+2,int(4*self.l)+2))
for i in range(int(4*self.l)+2):
for j in range(int(4*self.l)+2):
C[i][j] = (-int(2*self.l)+i+1)**j
c = np.zeros(int(4*self.l)+2)
c[int(2*self.l)] = 1.
solution = scipy.linalg.solve(C,c)
z = np.zeros(int(4*3/2)+2)
for i in range(int(4*self.l)+2):
z[i] = solution[i]
return z
def Proj_0_even_coeff(self):
D = np.zeros((int(4*self.l)+2,int(4*self.l)+2))
for i in range(int(4*self.l)+2):
for j in range(int(4*self.l)+2):
D[i][j] = (-int(2*self.l)+i-1)**j
d = np.zeros(int(4*self.l)+2)
d[int(2*self.l)+1] = 1.
solution = scipy.linalg.solve(D,d)
yy = np.zeros(int(4*3/2)+2)
for i in range(int(4*self.l)+2):
yy[i] = solution[i]
return yy
def Proj_0_odd_coeff(self):
E = np.zeros((int(4*self.l)+2,int(4*self.l)+2))
for i in range(int(4*self.l)+2):
for j in range(int(4*self.l)+2):
E[i][j] = (-int(2*self.l)+i+1)**j
e = np.zeros(int(4*self.l)+2)
e[int(2*self.l)-1] = 1.
solution = scipy.linalg.solve(E,e)
zz = np.zeros(int(4*3/2)+2)
for i in range(int(4*self.l)+2):
zz[i] = solution[i]
return zz
def Gauss_law(self,n):
if n%2 == 0:
liste = [[1.,n]]
liste_m = [[-1.,(n-1)%self.L]]
liste_p5 = [[-0.5,n]]
gauss_law_map = [
["z|",liste],
["z|",liste_m],
["|I",liste_p5],
["|z",liste_p5],
]
gauss_law = hamiltonian(gauss_law_map,dynamic_list=[],basis=self.basis,**self.no_checks)
else:
liste = [[1.,n]]
liste2 = [[2.,n]]
liste_m = [[-1.,n-1]]
liste_p5 = [[-0.5,n]]
gauss_law_map = [
["z|",liste],
["z|",liste_m],
["I|",liste2],
["|I",liste_p5],
["|z",liste_p5],
]
gauss_law = hamiltonian(gauss_law_map,dynamic_list=[],basis=self.basis,**self.no_checks)
return gauss_law.tocsc()
def Proj(self,n):
Proj = sparse.csc_matrix((self.basis.Ns,self.basis.Ns))
g = self.Gauss_law_ar[n]
if n%2 == 0:
for j in range(int(4*self.l)+2):
Proj += self.Proj_even_coeff_ar[j]*g**j
else:
for j in range(int(4*self.l)+2):
Proj += self.Proj_odd_coeff_ar[j]*g**j
return Proj
def Proj_0(self,n):
Proj = sparse.csc_matrix((self.basis.Ns,self.basis.Ns))
g = self.Gauss_law_ar[n]
if n%2 == 0:
for j in range(int(4*self.l)+2):
Proj += self.Proj_0_even_coeff_ar[j]*g**j
else:
for j in range(int(4*self.l)+2):
Proj += self.Proj_0_odd_coeff_ar[j]*g**j
return Proj
def h_E(self,n):
const_term = [[self.hE_coeff_ar[0],n]]
linear_term = [[self.hE_coeff_ar[1],n]]
quadratic_term = [[self.hE_coeff_ar[2],n,n]]
prefactor_E = [
["I|", const_term],
["z|", linear_term],
["zz|", quadratic_term],
]
hE = hamiltonian(prefactor_E,dynamic_list = [],basis=self.basis,**self.no_checks)
return hE.tocsc()
def h_U(self,n):
op_p_val = [[1.,n]]
op_p_map = [
["+|",op_p_val],
]
hU = hamiltonian(op_p_map,dynamic_list = [],basis=self.basis,**self.no_checks)
return hU.tocsc()
def h_U_dag(self,n):
op_p_val = [[1.,n]]
op_p_map = [
["-|",op_p_val],
]
hU = hamiltonian(op_p_map,dynamic_list = [],basis=self.basis,**self.no_checks)
return hU.tocsc()
def interaction_1(self,n):
interaction_term = [[1.,n,n,(n+1)%self.L]]
int_1_map = [
["+|+-",interaction_term],
["-|-+",interaction_term],
]
hint = hamiltonian(int_1_map,dynamic_list = [],basis=self.basis,**self.no_checks)
return hint.tocsc()
def hamiltonian_matrix(self):
kin_energy = [[0.5*self.g**2,i,i] for i in range(self.L)]
mass_term_diff = [[0.5*(self.m_1-self.m_2)*(-1)**i,i] for i in range(self.N)]
mass_term_2 = [[2*self.m_2*(-1)**i,i] for i in range(self.L)]
hamiltonian_map = [
["zz|",kin_energy],
["|z",mass_term_diff],
["|I",mass_term_diff],
["z|",mass_term_2],
]
Ham_part_1 = hamiltonian(hamiltonian_map,dynamic_list = [],basis=self.basis,**self.no_checks)
ham_part_1_matrix = Ham_part_1.tocsc() # E^2 energy term + mass term
interaction_ham_1 = 0 #hopping term for the first specie
interaction_ham_2 = 0 #hopping term for the second specie
for i in range(self.L-1):
interaction_ham_1 += 1/(2*np.sqrt(self.l*(self.l+1)))*(self.h_E_ar[(i-1)%self.L]@self.interaction_1_ar[i])
interaction_ham_2 += 1/(2*np.sqrt(self.l*(self.l+1)))*self.h_E_ar[i+1]@(self.Proj_ar[i]@self.h_U_ar[i]@self.Proj_ar[i+1]+self.Proj_ar[i+1]@self.h_U_dag_ar[i]@self.Proj_ar[i])
interaction_ham_1 += 1/(2*np.sqrt(self.l*(self.l+1)))*(self.h_E_ar[self.L-2]@self.interaction_1_ar[self.L-1])
interaction_ham_2 += (-1)**self.bc*1/(2*np.sqrt(self.l*(self.l+1)))*self.h_E_ar[0]@(self.Proj_ar[self.L-1]@self.h_U_ar[self.L-1]@self.Proj_ar[0]+self.Proj_ar[0]@self.h_U_dag_ar[self.L-1]@self.Proj_ar[self.L-1])
Hamiltonian_two_flavours = ham_part_1_matrix + interaction_ham_1 + interaction_ham_2 - self.N/2*(self.m_1+self.m_2)*sparse.identity(self.basis.Ns)
G = 0 #penalty term due to the Gauss laws
if self.pen != 0:
for i in range(self.N):
g_ham = self.Gauss_law_ar[i]
G += (g_ham*(g_ham-sparse.identity(self.basis.Ns)))**2
return Hamiltonian_two_flavours + self.pen*G
def electric_field_matrix(self,n):
op_e_val = [[1.,n]]
op_e_map = [
["z|",op_e_val],
]
hEl = hamiltonian(op_e_map,dynamic_list = [],basis=self.basis,**self.no_checks)
return hEl.tocsc()
def fermion_number_matrix(self,n,specie):
number_1_val = [[0.5,n]]
number_1_map = [
["|z",number_1_val],
["|I",number_1_val],
]
ham_number = hamiltonian(number_1_map,dynamic_list = [],basis=self.basis,**self.no_checks)
ham_number_m = ham_number.tocsc()
if specie == 1:
ham_number_m = self.Gauss_law(n)
return (-1)**n*ham_number_m
# In[832]:
def sort_eigenval_and_eigenvec(x,y):
for i in range(len(x)):
swap = i + np.argmin(x[i:])
(x[i], x[swap]) = (x[swap], x[i])
(y[:,i], y[:,swap]) = (y[:,swap], y[:,i])
return x,y
# In[833]:
def main(N,L,g,m_1,m_2,pen,bc,Nst):
LGT_object = constructor_LGT(N,L,g,m_1,m_2,pen,bc)
eigenval, eigenvec = scipy.sparse.linalg.eigsh(LGT_object.hamiltonian_matrix(),k = Nst,which = "SA")
eigenval_s, eigenvec_s = sort_eigenval_and_eigenvec(eigenval, eigenvec)
psi_ground = eigenvec_s[:,0]
electric_field = []
mass_term_1 = []
mass_term_2 = []
for i in range(N):
electric_field.append(np.real(np.conj(psi_ground)@LGT_object.electric_field_matrix(i)@psi_ground))
mass_term_1.append(np.real(np.conj(psi_ground)@LGT_object.fermion_number_matrix(i,0)@psi_ground))
mass_term_2.append(np.real(np.conj(psi_ground)@LGT_object.fermion_number_matrix(i,1)@psi_ground))
f = open("twflph_N="+str(N)+"_m_1="+str(m_1)+"_m_2="+str(m_2)+"_g="+str(g)+"_bc="+str(bc)+".txt", "w")
for l in range(N):
f.write(str(l)+" "+str(electric_field[l])+" "+str(mass_term_1[l])+" "+str(mass_term_2[l])+"\n")
f.close()
pass
# In[ ]:
main(int(sys.argv[1]),int(sys.argv[1]),float(sys.argv[2]),float(sys.argv[3]),float(sys.argv[4]),float(sys.argv[5]),int(sys.argv[6]),int(sys.argv[7]))
print("Done!")