def main(): N = 30 a = 1 hamiltonian_function0 = functools.partial(hamiltonian, k=0, N=N, M=0, t1=1, a=a) B_array = np.linspace(0, 1 / (3 * np.sqrt(3) / 2 * a * a), 100) eigenvalue_array = guan.calculate_eigenvalue_with_one_parameter( B_array, hamiltonian_function0) BS_array = B_array * (3 * np.sqrt(3) / 2 * a * a) guan.plot(BS_array, eigenvalue_array, xlabel='Flux (BS/phi_0)', ylabel='E', title='Ny=%i' % N, filename='a', show=1, save=0, type='k.', y_min=None, y_max=None, markersize=3)
def main(): Ny = 21 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))
def main(): Num_kx = 100 Num_ky = 100 kx_array = np.linspace(-pi, pi, Num_kx) ky_array = np.linspace(-pi, pi, Num_ky) nu_x_array = [] for ky in ky_array: vector1_array = [] vector2_array = [] for kx in kx_array: eigenvalue, eigenvector = np.linalg.eigh(hamiltonian(kx, ky)) if kx != pi: vector1_array.append(eigenvector[:, 0]) vector2_array.append(eigenvector[:, 1]) else: # 这里是为了-pi和pi有相同的波函数,使得Wilson loop的值与波函数规范无关。 vector1_array.append(vector1_array[0]) vector2_array.append(vector2_array[0]) W_x_k = np.eye(2, dtype=complex) for i0 in range(Num_kx - 1): F = np.zeros((2, 2), dtype=complex) F[0, 0] = np.dot(vector1_array[i0 + 1].transpose().conj(), vector1_array[i0]) F[1, 1] = np.dot(vector2_array[i0 + 1].transpose().conj(), vector2_array[i0]) F[0, 1] = np.dot(vector1_array[i0 + 1].transpose().conj(), vector2_array[i0]) F[1, 0] = np.dot(vector2_array[i0 + 1].transpose().conj(), vector1_array[i0]) W_x_k = np.dot(F, W_x_k) eigenvalue, eigenvector = np.linalg.eig(W_x_k) nu_x = np.log(eigenvalue) / 2 / pi / 1j for i0 in range(2): if np.real(nu_x[i0]) < 0: nu_x[i0] += 1 nu_x = np.sort(nu_x) nu_x_array.append(nu_x.real) import guan guan.plot(ky_array, nu_x_array, xlabel='ky', ylabel='nu_x', type='-', y_min=0, y_max=1)
def main(): kx = np.arange(-pi, pi, 0.05) ky = np.arange(-pi, pi, 0.05) eigenvalue_array = guan.calculate_eigenvalue_with_two_parameters( kx, ky, hamiltonian) guan.plot_3d_surface(kx, ky, eigenvalue_array, xlabel='kx', ylabel='ky', zlabel='E', title='BBH bands') hamiltonian0 = functools.partial(hamiltonian, ky=0) eigenvalue_array = guan.calculate_eigenvalue_with_one_parameter( kx, hamiltonian0) guan.plot(kx, eigenvalue_array, xlabel='kx', ylabel='E', title='BBH bands ky=0')
import numpy as np from math import * import cmath import guan v = 0.6 w = 1 k_array = np.linspace(-pi, pi, 100) def hamiltonian_1(k): matrix = np.zeros((2, 2), dtype=complex) matrix[0, 1] = v + w * cmath.exp(-1j * k) matrix[1, 0] = v + w * cmath.exp(1j * k) return matrix def hamiltonian_2(k): matrix = np.zeros((2, 2), dtype=complex) matrix[0, 1] = v * cmath.exp(1j * k / 2) + w * cmath.exp(-1j * k / 2) matrix[1, 0] = v * cmath.exp(-1j * k / 2) + w * cmath.exp(1j * k / 2) return matrix E_1_array = guan.calculate_eigenvalue_with_one_parameter( k_array, hamiltonian_1) guan.plot(k_array, E_1_array, xlabel='k', ylabel='E_1') E_2_array = guan.calculate_eigenvalue_with_one_parameter( k_array, hamiltonian_2) guan.plot(k_array, E_2_array, xlabel='k', ylabel='E_2')
def main(): start_time = time.time() width = 21 length = 72 fermi_energy_array = np.arange(-4, 4, .05) # 中心区的哈密顿量 H_cetner = get_center_hamiltonian(Nx=length, Ny=width, B=1 / width) # 电极的h00和h01 lead_h00 = get_lead_h00(width) lead_h01 = get_lead_h01(width) transmission_12_array = [] transmission_13_array = [] transmission_14_array = [] transmission_15_array = [] transmission_16_array = [] transmission_1_all_array = [] for fermi_energy in fermi_energy_array: print(fermi_energy) # 几何形状如下所示: # lead2 lead3 # lead1(L) lead4(R) # lead6 lead5 # 电极到中心区的跃迁矩阵 h_lead1_to_center = np.zeros((width, width * length), dtype=complex) h_lead2_to_center = np.zeros((width, width * length), dtype=complex) h_lead3_to_center = np.zeros((width, width * length), dtype=complex) h_lead4_to_center = np.zeros((width, width * length), dtype=complex) h_lead5_to_center = np.zeros((width, width * length), dtype=complex) h_lead6_to_center = np.zeros((width, width * length), dtype=complex) move = 10 # the step of leads 2,3,6,5 moving to center for i0 in range(width): h_lead1_to_center[i0, i0] = 1 h_lead2_to_center[i0, width * (move + i0) + (width - 1)] = 1 h_lead3_to_center[i0, width * (length - move - 1 - i0) + (width - 1)] = 1 h_lead4_to_center[i0, width * (length - 1) + i0] = 1 h_lead5_to_center[i0, width * (length - move - 1 - i0) + 0] = 1 h_lead6_to_center[i0, width * (i0 + move) + 0] = 1 # 自能 self_energy1, gamma1 = guan.self_energy_of_lead_with_h_lead_to_center( fermi_energy, lead_h00, lead_h01, h_lead1_to_center) self_energy2, gamma2 = guan.self_energy_of_lead_with_h_lead_to_center( fermi_energy, lead_h00, lead_h01, h_lead2_to_center) self_energy3, gamma3 = guan.self_energy_of_lead_with_h_lead_to_center( fermi_energy, lead_h00, lead_h01, h_lead3_to_center) self_energy4, gamma4 = guan.self_energy_of_lead_with_h_lead_to_center( fermi_energy, lead_h00, lead_h01, h_lead4_to_center) self_energy5, gamma5 = guan.self_energy_of_lead_with_h_lead_to_center( fermi_energy, lead_h00, lead_h01, h_lead5_to_center) self_energy6, gamma6 = guan.self_energy_of_lead_with_h_lead_to_center( fermi_energy, lead_h00, lead_h01, h_lead6_to_center) # 整体格林函数 green = np.linalg.inv(fermi_energy * np.eye(width * length) - H_cetner - self_energy1 - self_energy2 - self_energy3 - self_energy4 - self_energy5 - self_energy6) # Transmission transmission_12 = np.trace( np.dot(np.dot(np.dot(gamma1, green), gamma2), green.transpose().conj())) transmission_13 = np.trace( np.dot(np.dot(np.dot(gamma1, green), gamma3), green.transpose().conj())) transmission_14 = np.trace( np.dot(np.dot(np.dot(gamma1, green), gamma4), green.transpose().conj())) transmission_15 = np.trace( np.dot(np.dot(np.dot(gamma1, green), gamma5), green.transpose().conj())) transmission_16 = np.trace( np.dot(np.dot(np.dot(gamma1, green), gamma6), green.transpose().conj())) transmission_12_array.append(np.real(transmission_12)) transmission_13_array.append(np.real(transmission_13)) transmission_14_array.append(np.real(transmission_14)) transmission_15_array.append(np.real(transmission_15)) transmission_16_array.append(np.real(transmission_16)) transmission_1_all_array.append( np.real(transmission_12 + transmission_13 + transmission_14 + transmission_15 + transmission_16)) guan.plot(fermi_energy_array, transmission_12_array, xlabel='Fermi energy', ylabel='Transmission_12') guan.plot(fermi_energy_array, transmission_13_array, xlabel='Fermi energy', ylabel='Transmission_13') guan.plot(fermi_energy_array, transmission_14_array, xlabel='Fermi energy', ylabel='Transmission_14') guan.plot(fermi_energy_array, transmission_15_array, xlabel='Fermi energy', ylabel='Transmission_15') guan.plot(fermi_energy_array, transmission_16_array, xlabel='Fermi energy', ylabel='Transmission_16') guan.plot(fermi_energy_array, transmission_1_all_array, xlabel='Fermi energy', ylabel='Transmission_1_all') end_time = time.time() print('运行时间=', end_time - start_time)
import guan import numpy as np fermi_energy_array = np.linspace(-4, 4, 400) h00 = guan.hamiltonian_of_finite_size_system_along_one_direction(4) h01 = np.identity(4) conductance_array = guan.calculate_conductance_with_fermi_energy_array( fermi_energy_array, h00, h01) guan.plot(fermi_energy_array, conductance_array, xlabel='E', ylabel='Conductance', type='-')
def main(): start_time = time.time() width = 5 length = 50 fermi_energy_array = np.arange(-4, 4, .01) # 中心区的哈密顿量 center_hamiltonian = get_center_hamiltonian(Nx=length, Ny=width) # 电极的h00和h01 lead_h00 = get_lead_h00(width) lead_h01 = get_lead_h01(width) transmission_12_array = [] transmission_13_array = [] transmission_14_array = [] transmission_15_array = [] transmission_16_array = [] transmission_1_all_array = [] for fermi_energy in fermi_energy_array: print(fermi_energy) # 几何形状如下所示: # lead2 lead3 # lead1(L) lead4(R) # lead6 lead5 transmission_matrix = guan.calculate_six_terminal_transmission_matrix( fermi_energy, h00_for_lead_4=lead_h00, h01_for_lead_4=lead_h01, h00_for_lead_2=lead_h00, h01_for_lead_2=lead_h01, center_hamiltonian=center_hamiltonian, width=width, length=length, internal_degree=1, moving_step_of_leads=0) transmission_12_array.append(transmission_matrix[0, 1]) transmission_13_array.append(transmission_matrix[0, 2]) transmission_14_array.append(transmission_matrix[0, 3]) transmission_15_array.append(transmission_matrix[0, 4]) transmission_16_array.append(transmission_matrix[0, 5]) transmission_1_all_array.append(transmission_matrix[0, 1] + transmission_matrix[0, 2] + transmission_matrix[0, 3] + transmission_matrix[0, 4] + transmission_matrix[0, 5]) guan.plot(fermi_energy_array, transmission_12_array, xlabel='Fermi energy', ylabel='Transmission_12') guan.plot(fermi_energy_array, transmission_13_array, xlabel='Fermi energy', ylabel='Transmission_13') guan.plot(fermi_energy_array, transmission_14_array, xlabel='Fermi energy', ylabel='Transmission_14') guan.plot(fermi_energy_array, transmission_15_array, xlabel='Fermi energy', ylabel='Transmission_15') guan.plot(fermi_energy_array, transmission_16_array, xlabel='Fermi energy', ylabel='Transmission_16') guan.plot(fermi_energy_array, transmission_1_all_array, xlabel='Fermi energy', ylabel='Transmission_1_all') end_time = time.time() print('运行时间=', end_time - start_time)
def main(): Num_kx = 30 # for wilson loop and nested wilson loop Num_ky = 30 # for wilson loop and nested wilson loop Num_kx2 = 20 # plot precision Num_ky2 = 20 # plot precision kx_array = np.linspace(-pi, pi, Num_kx) ky_array = np.linspace(-pi, pi, Num_ky) kx2_array = np.linspace(-pi, pi, Num_kx2) ky2_array = np.linspace(-pi, pi, Num_ky2) # Part I: calculate p_y_for_nu_x p_y_for_nu_x_array = [] for kx in kx2_array: print('kx=', kx) w_vector_for_nu1_array = [] vector1_array = [] vector2_array = [] i0 = -1 for ky in ky_array: eigenvalue, eigenvector = np.linalg.eigh(hamiltonian(kx, ky)) if ky != pi: vector1_array.append(eigenvector[:, 0]) vector2_array.append(eigenvector[:, 1]) else: vector1_array.append(vector1_array[0]) vector2_array.append(vector2_array[0]) i0 = 0 for ky in ky_array: if ky != pi: nu_x_vector_1, nu_x_vector_2 = get_nu_x_vector(kx_array, ky) # the Wannier band subspaces w_vector_for_nu1 = vector1_array[i0] * nu_x_vector_1[ 0] + vector2_array[i0] * nu_x_vector_1[1] w_vector_for_nu1_array.append(w_vector_for_nu1) else: w_vector_for_nu1_array.append(w_vector_for_nu1_array[0]) i0 += 1 W_y_k_for_nu_x = 1 for i0 in range(Num_ky - 1): F_for_nu_x = np.dot( w_vector_for_nu1_array[i0 + 1].transpose().conj(), w_vector_for_nu1_array[i0]) W_y_k_for_nu_x = F_for_nu_x * W_y_k_for_nu_x p_y_for_nu_x = np.log(W_y_k_for_nu_x) / 2 / pi / 1j if np.real(p_y_for_nu_x) < 0: p_y_for_nu_x += 1 p_y_for_nu_x_array.append(p_y_for_nu_x.real) print('p_y_for_nu_x=', p_y_for_nu_x) guan.plot(kx2_array, p_y_for_nu_x_array, xlabel='kx', ylabel='p_y_for_nu_x', type='-o', y_min=0, y_max=1) # Part II: calculate p_x_for_nu_y p_x_for_nu_y_array = [] for ky in ky2_array: w_vector_for_nu1_array = [] vector1_array = [] vector2_array = [] for kx in kx_array: eigenvalue, eigenvector = np.linalg.eigh(hamiltonian(kx, ky)) if kx != pi: vector1_array.append(eigenvector[:, 0]) vector2_array.append(eigenvector[:, 1]) else: vector1_array.append(vector1_array[0]) vector2_array.append(vector2_array[0]) i0 = 0 for kx in kx_array: if kx != pi: nu_y_vector_1, nu_y_vector_2 = get_nu_y_vector(kx, ky_array) # the Wannier band subspaces w_vector_for_nu1 = vector1_array[i0] * nu_y_vector_1[ 0] + vector2_array[i0] * nu_y_vector_1[1] w_vector_for_nu1_array.append(w_vector_for_nu1) else: w_vector_for_nu1_array.append(w_vector_for_nu1_array[0]) i0 += 1 W_x_k_for_nu_y = 1 for i0 in range(Num_ky - 1): F_for_nu_y = np.dot( w_vector_for_nu1_array[i0 + 1].transpose().conj(), w_vector_for_nu1_array[i0]) W_x_k_for_nu_y = F_for_nu_y * W_x_k_for_nu_y p_x_for_nu_y = np.log(W_x_k_for_nu_y) / 2 / pi / 1j if np.real(p_x_for_nu_y) < 0: p_x_for_nu_y += 1 p_x_for_nu_y_array.append(p_x_for_nu_y.real) print('p_x_for_nu_y=', p_x_for_nu_y) # print(sum(p_x_for_nu_y_array)/len(p_x_for_nu_y_array)) guan.plot(ky2_array, p_x_for_nu_y_array, xlabel='ky', ylabel='p_x_for_nu_y', type='-o', y_min=0, y_max=1)