diff --git a/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/calculation_of_Chern_number_by_definition_method.py b/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/calculation_of_Chern_number_by_definition_method.py index 729f666..3ca0785 100755 --- a/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/calculation_of_Chern_number_by_definition_method.py +++ b/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/calculation_of_Chern_number_by_definition_method.py @@ -4,8 +4,7 @@ The newest version of this code is on the web page: https://www.guanjihuan.com/a """ import numpy as np -import matplotlib.pyplot as plt -from math import * # 引入pi, cos等 +from math import * import time @@ -14,7 +13,7 @@ def hamiltonian(kx, ky): # 量子反常霍尔QAH模型(该参数对应的陈 t2 = 1.0 t3 = 0.5 m = -1.0 - matrix = np.zeros((2, 2))*(1+0j) + matrix = np.zeros((2, 2), dtype=complex) matrix[0, 1] = 2*t1*cos(kx)-1j*2*t1*cos(ky) matrix[1, 0] = 2*t1*cos(kx)+1j*2*t1*cos(ky) matrix[0, 0] = m+2*t3*sin(kx)+2*t3*sin(ky)+2*t2*cos(kx+ky) diff --git a/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/find_smooth_gauge_and_calculate_Chern_number.py b/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/find_smooth_gauge_and_calculate_Chern_number.py index 38696c1..6701ca2 100755 --- a/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/find_smooth_gauge_and_calculate_Chern_number.py +++ b/academic_codes/2020.01.05_calculation_of_Chern_number_by_definition_method/find_smooth_gauge_and_calculate_Chern_number.py @@ -4,8 +4,7 @@ The newest version of this code is on the web page: https://www.guanjihuan.com/a """ import numpy as np -import matplotlib.pyplot as plt -from math import * # 引入pi, cos等 +from math import * import time import cmath @@ -15,7 +14,7 @@ def hamiltonian(kx, ky): # 量子反常霍尔QAH模型(该参数对应的陈 t2 = 1.0 t3 = 0.5 m = -1.0 - matrix = np.zeros((2, 2))*(1+0j) + matrix = np.zeros((2, 2), dtype=complex) matrix[0, 1] = 2*t1*cos(kx)-1j*2*t1*cos(ky) matrix[1, 0] = 2*t1*cos(kx)+1j*2*t1*cos(ky) matrix[0, 0] = m+2*t3*sin(kx)+2*t3*sin(ky)+2*t2*cos(kx+ky) @@ -76,7 +75,7 @@ def find_vector_with_the_same_gauge(vector_1, vector_0): for i0 in range(n_test): test_1 = np.sum(np.abs(vector_1*cmath.exp(1j*phase_1_pre) - vector_0)) test_2 = np.sum(np.abs(vector_1*cmath.exp(1j*phase_2_pre) - vector_0)) - if test_1 < 1e-6: + if test_1 < 1e-8: phase = phase_1_pre # print('Done with i0=', i0) break diff --git a/academic_codes/2021.07.26_calculation_of_Berry_curvature_and_Chern_number_by_another_method/calculation_of_Berry_curvature_and_Chern_number_by_another_method.py b/academic_codes/2021.07.26_calculation_of_Berry_curvature_and_Chern_number_by_another_method/calculation_of_Berry_curvature_and_Chern_number_by_another_method.py new file mode 100644 index 0000000..18d51f6 --- /dev/null +++ b/academic_codes/2021.07.26_calculation_of_Berry_curvature_and_Chern_number_by_another_method/calculation_of_Berry_curvature_and_Chern_number_by_another_method.py @@ -0,0 +1,50 @@ +""" +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/16148 +""" + +import numpy as np +from math import * +import time + + +def hamiltonian(kx, ky): # 量子反常霍尔QAH模型(该参数对应的陈数为2) + t1 = 1.0 + t2 = 1.0 + t3 = 0.5 + m = -1.0 + matrix = np.zeros((2, 2), dtype=complex) + matrix[0, 1] = 2*t1*cos(kx)-1j*2*t1*cos(ky) + matrix[1, 0] = 2*t1*cos(kx)+1j*2*t1*cos(ky) + matrix[0, 0] = m+2*t3*sin(kx)+2*t3*sin(ky)+2*t2*cos(kx+ky) + matrix[1, 1] = -(m+2*t3*sin(kx)+2*t3*sin(ky)+2*t2*cos(kx+ky)) + return matrix + + +def main(): + start_time = time.time() + n = 200 + delta = 2*pi/n + chern_number = 0 + for kx in np.arange(-pi, pi, delta): + for ky in np.arange(-pi, pi,delta): + H = hamiltonian(kx, ky) + eigenvalue, eigenvector = np.linalg.eig(H) + vector_0 = eigenvector[:, np.argsort(np.real(eigenvalue))[0]] + vector_1 = eigenvector[:, np.argsort(np.real(eigenvalue))[1]] + eigenvalue = np.sort(np.real(eigenvalue)) + + H_delta_kx = hamiltonian(kx+delta, ky)-hamiltonian(kx, ky) + H_delta_ky = hamiltonian(kx, ky+delta)-hamiltonian(kx, ky) + + berry_curvature = 1j*(np.dot(np.dot(np.dot(np.dot(np.dot(vector_0.transpose().conj(), H_delta_kx/delta), vector_1), vector_1.transpose().conj()), H_delta_ky/delta), vector_0)- np.dot(np.dot(np.dot(np.dot(np.dot(vector_0.transpose().conj(), H_delta_ky/delta), vector_1), vector_1.transpose().conj()), H_delta_kx/delta), vector_0))/(eigenvalue[0]-eigenvalue[1])**2 + + chern_number = chern_number + berry_curvature*(2*pi/n)**2 + chern_number = chern_number/(2*pi) + print('Chern number = ', chern_number) + end_time = time.time() + print('运行时间(min)=', (end_time-start_time)/60) + + +if __name__ == '__main__': + main() \ No newline at end of file