-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZeroPoints.py
94 lines (84 loc) · 3.23 KB
/
ZeroPoints.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
"""
Plot the energy spectra for the Hamiltonian of two coupled SSH chains
system defined in the article:
Li, C., Lin, S., Zhang, G., & Song, Z. (2017). Topological nodal
points in two coupled Su-Schrieffer-Heeger chains. Physical Review B,
96(12), 125418.
as a function of the hoppings v/t on a 2xN ladder with open boundary
condition. The script is able to reproduce FIG.3. from Li, et al.
(2017)
Author: Carla Borja Espinosa
Date: October 2019
Example command line in terminal to run the program:
$ python3 ZeroPoints.py 10 1 figure.png
"""
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
from numpy import linalg as la
from sympy.printing.str import StrPrinter
from sys import argv
from sympy.abc import v, w
class Hamiltonian(object):
"""Diagonalization of the system hamiltonian"""
def __init__(self):
"""Variables"""
self.N = 2*int(argv[1]) # Number of ladders
self.t = float(argv[2]) # Value of the interchain hopping
self.filePNG = argv[3] # Name of the file to store the plot
"""Functions"""
self.HamiltonianMatrix()
self.EigenvalsPlot()
def HamiltonianMatrix(self):
"""Construct the matrix representation of the system
hamiltonian up to N ladders"""
self.Inter = sp.Matrix([[0,self.t],[self.t,0]])
self.Intra1 = sp.Matrix([[0,v],[w,0]])
self.Intra2 = sp.Matrix([[0,w],[v,0]])
H = sp.Matrix([])
for i in range(1, self.N+1):
fila = sp.Matrix([])
for j in range(1, self.N+1):
if j==i:
fila = fila.row_join(self.Inter)
elif j==i+1:
fila = fila.row_join(self.Intra1)
elif j==i-1:
fila = fila.row_join(self.Intra2)
else:
fila = fila.row_join(sp.Matrix([[0,0],[0,0]]))
H = H.col_join(fila)
H.simplify()
#printer = StrPrinter()
#print(H.table(printer,align='center'))
self.H = H
def EigenvalsPlot(self):
"""Plot the eigenvalues as a function of v/t for different
relations of the hopping parameters
(uncomment the desired case)"""
Hfv = sp.lambdify(('v','w'), self.H)
v_vals = np.arange(-1.5, 1.5+0.03 ,0.03)
w_vals = self.t + v_vals # case a
#w_vals = v_vals # case b
#w_vals = 2*self.t - v_vals # case c
#w_vals = -v_vals # case d
size_v = np.size(v_vals)
size_aut = self.H.shape[1]
graph = np.empty([size_v,size_aut])
for i in range(0,size_v):
energies,vectors = la.eig(Hfv(v_vals[i],w_vals[i]))
energies = np.sort(np.real(energies))
graph[i] = energies
graph = np.insert(graph, [0], v_vals.reshape(-1,1), axis = 1)
graph = np.matrix(graph)
#with open(self.filetxt, "w+") as f:
# for line in graph:
# np.savetxt(f,line)
for i in range(0, size_aut):
plt.plot(v_vals,graph[:,i+1],'g')
plt.xlim(-1.5,0.5)
plt.ylim(-3,3)
plt.savefig(self.filePNG)
#plt.savefig(self.filePNG, format='eps', dpi=1200)
#plt.show()
Hamiltonian()