This commit is contained in:
guanjihuan 2021-12-27 16:39:28 +08:00
parent b39bf04dd4
commit 5e4375af09
3 changed files with 100 additions and 1 deletions

View File

@ -32,7 +32,7 @@ def main():
def hamiltonian(width, length, B): # 方格子哈密顿量 def hamiltonian(width, length, B): # 方格子哈密顿量
h = np.zeros((width*length, width*length))*(1+0j) h = np.zeros((width*length, width*length), dtype=complex)
# y方向的跃迁 # y方向的跃迁
for x in range(length): for x in range(length):
for y in range(width-1): for y in range(width-1):

View File

@ -0,0 +1,57 @@
"""
This code is supported by the website: https://www.guanjihuan.com
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/18306
"""
import numpy as np
from math import *
import cmath
import functools
import guan
def hamiltonian(kx, ky, Ny, a, B):
h00 = np.zeros((4*Ny, 4*Ny), dtype=complex)
h01 = np.zeros((4*Ny, 4*Ny), dtype=complex)
t1= 1
M = 0
for i in range(Ny):
h00[i*4+0, i*4+0] = M
h00[i*4+1, i*4+1] = -M
h00[i*4+2, i*4+2] = M
h00[i*4+3, i*4+3] = -M
h00[i*4+0, i*4+1] = t1*cmath.exp(-2*pi*1j*B*(3*a*i+1/4*a)*(np.sqrt(3)/2*a))
h00[i*4+1, i*4+0] = np.conj(h00[i*4+0, i*4+1])
h00[i*4+1, i*4+2] = t1
h00[i*4+2, i*4+1] = np.conj(h00[i*4+1, i*4+2])
h00[i*4+2, i*4+3] = t1*cmath.exp(2*pi*1j*B*(3*a*i+7/4*a)*(np.sqrt(3)/2)*a)
h00[i*4+3, i*4+2] = np.conj(h00[i*4+2, i*4+3])
for i in range(Ny-1):
h00[i*4+3, (i+1)*4+0] = t1
h00[(i+1)*4+0, i*4+3] = t1
h00[(Ny-1)*4+3, 0+0] = t1*cmath.exp(1j*ky)
h00[0+0, (Ny-1)*4+3] = t1*cmath.exp(-1j*ky)
for i in range(Ny):
h01[i*4+1, i*4+0] = t1*cmath.exp(-2*pi*1j*B*(3*a*i+1/4*a)*(np.sqrt(3)/2*a))
h01[i*4+2, i*4+3] = t1*cmath.exp(-2*pi*1j*B*(3*a*i+7/4*a)*(np.sqrt(3)/2*a))
matrix = h00 + h01*cmath.exp(1j*kx) + h01.transpose().conj()*cmath.exp(-1j*kx)
return matrix
def main():
Ny = 10
a = 1
k_array = np.linspace(-pi, pi, 100)
H_k = functools.partial(hamiltonian, ky=0, Ny=Ny, a=a, B=1/(3*a*Ny))
eigenvalue_array = guan.calculate_eigenvalue_with_one_parameter(k_array, H_k)
guan.plot(k_array, eigenvalue_array, xlabel='kx', ylabel='E', type='k')
H_k = functools.partial(hamiltonian, Ny=Ny, a=a, B=1/(3*a*Ny))
chern_number = guan.calculate_chern_number_for_square_lattice(H_k, precision=100)
print(chern_number)
print(sum(chern_number))
if __name__ == '__main__':
main()

View File

@ -0,0 +1,42 @@
"""
This code is supported by the website: https://www.guanjihuan.com
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/18306
"""
import numpy as np
from math import *
import cmath
import functools
import guan
def hamiltonian(kx, ky, Ny, B):
h00 = np.zeros((Ny, Ny), dtype=complex)
h01 = np.zeros((Ny, Ny), dtype=complex)
t = 1
for iy in range(Ny-1):
h00[iy, iy+1] = t
h00[iy+1, iy] = t
h00[Ny-1, 0] = t*cmath.exp(1j*ky)
h00[0, Ny-1] = t*cmath.exp(-1j*ky)
for iy in range(Ny):
h01[iy, iy] = t*cmath.exp(-2*np.pi*1j*B*iy)
matrix = h00 + h01*cmath.exp(1j*kx) + h01.transpose().conj()*cmath.exp(-1j*kx)
return matrix
def main():
Ny = 40
k_array = np.linspace(-pi, pi, 100)
H_k = functools.partial(hamiltonian, ky=0, Ny=Ny, B=1/Ny)
eigenvalue_array = guan.calculate_eigenvalue_with_one_parameter(k_array, H_k)
guan.plot(k_array, eigenvalue_array, xlabel='kx', ylabel='E', type='k')
H_k = functools.partial(hamiltonian, Ny=Ny, B=1/Ny)
chern_number = guan.calculate_chern_number_for_square_lattice(H_k, precision=100)
print(chern_number)
print(sum(chern_number))
if __name__ == '__main__':
main()