diff --git a/API_Reference.py b/API_Reference.py index 674c7ce..86ba14b 100644 --- a/API_Reference.py +++ b/API_Reference.py @@ -246,6 +246,8 @@ guan.print_or_write_scattering_matrix(fermi_energy, h00, h01, length=100, print_ chern_number = guan.calculate_chern_number_for_square_lattice_with_efficient_method(hamiltonian_function, precision=100, print_show=0) +chern_number = guan.calculate_chern_number_for_square_lattice_with_efficient_method_for_degenerate_case(hamiltonian_function, index_of_bands=[0, 1], precision=100, print_show=0) + chern_number = guan.calculate_chern_number_for_square_lattice_with_wilson_loop(hamiltonian_function, precision_of_plaquettes=20, precision_of_wilson_loop=5, print_show=0) chern_number = guan.calculate_chern_number_for_square_lattice_with_wilson_loop_for_degenerate_case(hamiltonian_function, index_of_bands=[0, 1], precision_of_plaquettes=20, precision_of_wilson_loop=5, print_show=0) diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index fbe6eb2..f6dd3c7 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.125 +version = 0.0.126 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan.egg-info/PKG-INFO b/PyPI/src/guan.egg-info/PKG-INFO index 4f357b9..01a7503 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: guan -Version: 0.0.125 +Version: 0.0.126 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index 3e59bda..2a4cd30 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -2,7 +2,7 @@ # With this package, you can calculate band structures, density of states, quantum transport and topological invariant of tight-binding models by invoking the functions you need. Other frequently used functions are also integrated in this package, such as file reading/writing, figure plotting, data processing. -# The current version is guan-0.0.125, updated on August 25, 2022. +# The current version is guan-0.0.126, updated on August 28, 2022. # Installation: pip install --upgrade guan @@ -1551,6 +1551,71 @@ def calculate_chern_number_for_square_lattice_with_efficient_method(hamiltonian_ chern_number = chern_number/(2*math.pi*1j) return chern_number +def calculate_chern_number_for_square_lattice_with_efficient_method_for_degenerate_case(hamiltonian_function, index_of_bands=[0, 1], precision=100, print_show=0): + delta = 2*math.pi/precision + chern_number = 0 + for kx in np.arange(-math.pi, math.pi, delta): + if print_show == 1: + print(kx) + for ky in np.arange(-math.pi, math.pi, delta): + H = hamiltonian_function(kx, ky) + eigenvalue, vector = np.linalg.eigh(H) + H_delta_kx = hamiltonian_function(kx+delta, ky) + eigenvalue, vector_delta_kx = np.linalg.eigh(H_delta_kx) + H_delta_ky = hamiltonian_function(kx, ky+delta) + eigenvalue, vector_delta_ky = np.linalg.eigh(H_delta_ky) + H_delta_kx_ky = hamiltonian_function(kx+delta, ky+delta) + eigenvalue, vector_delta_kx_ky = np.linalg.eigh(H_delta_kx_ky) + dim = len(index_of_bands) + det_value = 1 + # first dot + dot_matrix = np.zeros((dim , dim), dtype=complex) + i0 = 0 + for dim1 in index_of_bands: + j0 = 0 + for dim2 in index_of_bands: + dot_matrix[dim1, dim2] = np.dot(np.conj(vector[:, dim1]), vector_delta_kx[:, dim2]) + j0 += 1 + i0 += 1 + dot_matrix = np.linalg.det(dot_matrix)/abs(np.linalg.det(dot_matrix)) + det_value = det_value*dot_matrix + # second dot + dot_matrix = np.zeros((dim , dim), dtype=complex) + i0 = 0 + for dim1 in index_of_bands: + j0 = 0 + for dim2 in index_of_bands: + dot_matrix[dim1, dim2] = np.dot(np.conj(vector_delta_kx[:, dim1]), vector_delta_kx_ky[:, dim2]) + j0 += 1 + i0 += 1 + dot_matrix = np.linalg.det(dot_matrix)/abs(np.linalg.det(dot_matrix)) + det_value = det_value*dot_matrix + # third dot + dot_matrix = np.zeros((dim , dim), dtype=complex) + i0 = 0 + for dim1 in index_of_bands: + j0 = 0 + for dim2 in index_of_bands: + dot_matrix[dim1, dim2] = np.dot(np.conj(vector_delta_kx_ky[:, dim1]), vector_delta_ky[:, dim2]) + j0 += 1 + i0 += 1 + dot_matrix = np.linalg.det(dot_matrix)/abs(np.linalg.det(dot_matrix)) + det_value = det_value*dot_matrix + # four dot + dot_matrix = np.zeros((dim , dim), dtype=complex) + i0 = 0 + for dim1 in index_of_bands: + j0 = 0 + for dim2 in index_of_bands: + dot_matrix[dim1, dim2] = np.dot(np.conj(vector_delta_ky[:, dim1]), vector[:, dim2]) + j0 += 1 + i0 += 1 + dot_matrix = np.linalg.det(dot_matrix)/abs(np.linalg.det(dot_matrix)) + det_value= det_value*dot_matrix + chern_number += cmath.log(det_value) + chern_number = chern_number/(2*math.pi*1j) + return chern_number + def calculate_chern_number_for_square_lattice_with_wilson_loop(hamiltonian_function, precision_of_plaquettes=20, precision_of_wilson_loop=5, print_show=0): delta = 2*math.pi/precision_of_plaquettes chern_number = 0