diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index b838717..2e9a003 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.74 +version = 0.0.75 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index a2cac61..96861a1 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -19,7 +19,7 @@ # import packages import numpy as np -from math import * +import math import cmath import copy import guan @@ -359,12 +359,12 @@ def hamiltonian_of_ssh_model(k, v=0.6, w=1): hamiltonian[1,0] = v+w*cmath.exp(1j*k) return hamiltonian -def hamiltonian_of_graphene(k1, k2, M=0, t=1, a=1/sqrt(3)): +def hamiltonian_of_graphene(k1, k2, M=0, t=1, a=1/math.sqrt(3)): h0 = np.zeros((2, 2), dtype=complex) # mass term h1 = np.zeros((2, 2), dtype=complex) # nearest hopping h0[0, 0] = M h0[1, 1] = -M - h1[1, 0] = t*(cmath.exp(1j*k2*a)+cmath.exp(1j*sqrt(3)/2*k1*a-1j/2*k2*a)+cmath.exp(-1j*sqrt(3)/2*k1*a-1j/2*k2*a)) + h1[1, 0] = t*(cmath.exp(1j*k2*a)+cmath.exp(1j*math.sqrt(3)/2*k1*a-1j/2*k2*a)+cmath.exp(-1j*math.sqrt(3)/2*k1*a-1j/2*k2*a)) h1[0, 1] = h1[1, 0].conj() hamiltonian = h0 + h1 return hamiltonian @@ -392,20 +392,20 @@ def hamiltonian_of_graphene_with_zigzag_in_quasi_one_dimension(k, N=10, M=0, t=1 hamiltonian = guan.one_dimensional_fourier_transform(k, unit_cell=h00, hopping=h01) return hamiltonian -def hamiltonian_of_haldane_model(k1, k2, M=2/3, t1=1, t2=1/3, phi=pi/4, a=1/sqrt(3)): +def hamiltonian_of_haldane_model(k1, k2, M=2/3, t1=1, t2=1/3, phi=math.pi/4, a=1/math.sqrt(3)): h0 = np.zeros((2, 2), dtype=complex) # mass term h1 = np.zeros((2, 2), dtype=complex) # nearest hopping h2 = np.zeros((2, 2), dtype=complex) # next nearest hopping h0[0, 0] = M h0[1, 1] = -M - h1[1, 0] = t1*(cmath.exp(1j*k2*a)+cmath.exp(1j*sqrt(3)/2*k1*a-1j/2*k2*a)+cmath.exp(-1j*sqrt(3)/2*k1*a-1j/2*k2*a)) + h1[1, 0] = t1*(cmath.exp(1j*k2*a)+cmath.exp(1j*math.sqrt(3)/2*k1*a-1j/2*k2*a)+cmath.exp(-1j*math.sqrt(3)/2*k1*a-1j/2*k2*a)) h1[0, 1] = h1[1, 0].conj() - h2[0, 0] = t2*cmath.exp(-1j*phi)*(cmath.exp(1j*sqrt(3)*k1*a)+cmath.exp(-1j*sqrt(3)/2*k1*a+1j*3/2*k2*a)+cmath.exp(-1j*sqrt(3)/2*k1*a-1j*3/2*k2*a)) - h2[1, 1] = t2*cmath.exp(1j*phi)*(cmath.exp(1j*sqrt(3)*k1*a)+cmath.exp(-1j*sqrt(3)/2*k1*a+1j*3/2*k2*a)+cmath.exp(-1j*sqrt(3)/2*k1*a-1j*3/2*k2*a)) + h2[0, 0] = t2*cmath.exp(-1j*phi)*(cmath.exp(1j*math.sqrt(3)*k1*a)+cmath.exp(-1j*math.sqrt(3)/2*k1*a+1j*3/2*k2*a)+cmath.exp(-1j*math.sqrt(3)/2*k1*a-1j*3/2*k2*a)) + h2[1, 1] = t2*cmath.exp(1j*phi)*(cmath.exp(1j*math.sqrt(3)*k1*a)+cmath.exp(-1j*math.sqrt(3)/2*k1*a+1j*3/2*k2*a)+cmath.exp(-1j*math.sqrt(3)/2*k1*a-1j*3/2*k2*a)) hamiltonian = h0 + h1 + h2 + h2.transpose().conj() return hamiltonian -def hamiltonian_of_haldane_model_in_quasi_one_dimension(k, N=10, M=2/3, t1=1, t2=1/3, phi=pi/4): +def hamiltonian_of_haldane_model_in_quasi_one_dimension(k, N=10, M=2/3, t1=1, t2=1/3, phi=math.pi/4): h00 = np.zeros((4*N, 4*N), dtype=complex) # hopping in a unit cell h01 = np.zeros((4*N, 4*N), dtype=complex) # hopping between unit cells for i in range(N): @@ -448,10 +448,10 @@ def hamiltonian_of_haldane_model_in_quasi_one_dimension(k, N=10, M=2/3, t1=1, t2 def hamiltonian_of_one_QAH_model(k1, k2, t1=1, t2=1, t3=0.5, m=-1): hamiltonian = np.zeros((2, 2), dtype=complex) - hamiltonian[0, 1] = 2*t1*cos(k1)-1j*2*t1*cos(k2) - hamiltonian[1, 0] = 2*t1*cos(k1)+1j*2*t1*cos(k2) - hamiltonian[0, 0] = m+2*t3*sin(k1)+2*t3*sin(k2)+2*t2*cos(k1+k2) - hamiltonian[1, 1] = -(m+2*t3*sin(k1)+2*t3*sin(k2)+2*t2*cos(k1+k2)) + hamiltonian[0, 1] = 2*t1*math.cos(k1)-1j*2*t1*math.cos(k2) + hamiltonian[1, 0] = 2*t1*math.cos(k1)+1j*2*t1*math.cos(k2) + hamiltonian[0, 0] = m+2*t3*math.sin(k1)+2*t3*math.sin(k2)+2*t2*math.cos(k1+k2) + hamiltonian[1, 1] = -(m+2*t3*math.sin(k1)+2*t3*math.sin(k2)+2*t2*math.cos(k1+k2)) return hamiltonian def hamiltonian_of_BBH_model(kx, ky, gamma_x=0.5, gamma_y=0.5, lambda_x=1, lambda_y=1): @@ -614,13 +614,13 @@ def rotation_of_degenerate_vectors(vector1, vector2, index1, index2, precision=0 vector1 = np.array(vector1) vector2 = np.array(vector2) if np.abs(vector1[index2])>criterion or np.abs(vector2[index1])>criterion: - for theta in np.arange(0, 2*pi, precision): + for theta in np.arange(0, 2*math.pi, precision): if show_theta==1: print(theta) - for phi1 in np.arange(0, 2*pi, precision): - for phi2 in np.arange(0, 2*pi, precision): - vector1_test = cmath.exp(1j*phi1)*vector1*cos(theta)+cmath.exp(1j*phi2)*vector2*sin(theta) - vector2_test = -cmath.exp(-1j*phi2)*vector1*sin(theta)+cmath.exp(-1j*phi1)*vector2*cos(theta) + for phi1 in np.arange(0, 2*math.pi, precision): + for phi2 in np.arange(0, 2*math.pi, precision): + vector1_test = cmath.exp(1j*phi1)*vector1*math.cos(theta)+cmath.exp(1j*phi2)*vector2*math.sin(theta) + vector2_test = -cmath.exp(-1j*phi2)*vector1*math.sin(theta)+cmath.exp(-1j*phi1)*vector2*math.cos(theta) if np.abs(vector1_test[index2])L2 and -(L1-kx)*tan(pi/3)<=ky<=(L1-kx)*tan(pi/3)) or (kx<-L2 and -(kx-(-L1))*tan(pi/3)<=ky<=(kx-(-L1))*tan(pi/3)): + if (-L2<=kx<=L2) or (kx>L2 and -(L1-kx)*math.tan(math.pi/3)<=ky<=(L1-kx)*math.tan(math.pi/3)) or (kx<-L2 and -(kx-(-L1))*math.tan(math.pi/3)<=ky<=(kx-(-L1))*math.tan(math.pi/3)): H = hamiltonian_function(kx, ky) vector = guan.calculate_eigenvector(H) H_delta_kx = hamiltonian_function(kx+delta1, ky) @@ -1379,10 +1379,10 @@ def calculate_chern_number_for_honeycomb_lattice(hamiltonian_function, a=1, prec Uy_x = np.dot(np.conj(vector_delta_kx_i), vector_delta_kx_ky_i)/abs(np.dot(np.conj(vector_delta_kx_i), vector_delta_kx_ky_i)) F = cmath.log(Ux*Uy_x*(1/Ux_y)*(1/Uy)) chern_number[i] = chern_number[i] + F - chern_number = chern_number/(2*pi*1j) + chern_number = chern_number/(2*math.pi*1j) return chern_number -def calculate_wilson_loop(hamiltonian_function, k_min=-pi, k_max=pi, precision=100, print_show=0): +def calculate_wilson_loop(hamiltonian_function, k_min=-math.pi, k_max=math.pi, precision=100, print_show=0): k_array = np.linspace(k_min, k_max, precision) dim = np.array(hamiltonian_function(0)).shape[0] wilson_loop_array = np.ones(dim, dtype=complex)