Update Hofstadter_butterfly_of_graphene_ribbon.py
This commit is contained in:
		| @@ -9,7 +9,7 @@ import cmath | |||||||
| import functools  | import functools  | ||||||
| import guan | import guan | ||||||
|  |  | ||||||
| def hamiltonian(B, k, N, M, t1):  # graphene哈密顿量(N是条带的宽度参数) | def hamiltonian(B, k, N, M, t1, a):  # graphene哈密顿量(N是条带的宽度参数) | ||||||
|     # 初始化为零矩阵 |     # 初始化为零矩阵 | ||||||
|     h00 = np.zeros((4*N, 4*N), dtype=complex) |     h00 = np.zeros((4*N, 4*N), dtype=complex) | ||||||
|     h01 = np.zeros((4*N, 4*N), dtype=complex) |     h01 = np.zeros((4*N, 4*N), dtype=complex) | ||||||
| @@ -20,11 +20,11 @@ def hamiltonian(B, k, N, M, t1):  # graphene哈密顿量(N是条带的宽度 | |||||||
|         h00[i*4+2, i*4+2] = M |         h00[i*4+2, i*4+2] = M | ||||||
|         h00[i*4+3, i*4+3] = -M |         h00[i*4+3, i*4+3] = -M | ||||||
|         # 最近邻 |         # 最近邻 | ||||||
|         h00[i*4+0, i*4+1] = t1*cmath.exp(-2*pi*1j*B*(3*i+1/4)*(np.sqrt(3)/2)) |         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+0] = np.conj(h00[i*4+0, i*4+1]) | ||||||
|         h00[i*4+1, i*4+2] = t1 |         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+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*i+7/4)*(np.sqrt(3)/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]) |         h00[i*4+3, i*4+2] = np.conj(h00[i*4+2, i*4+3]) | ||||||
|     for i in range(N-1): |     for i in range(N-1): | ||||||
|         # 最近邻 |         # 最近邻 | ||||||
| @@ -33,17 +33,18 @@ def hamiltonian(B, k, N, M, t1):  # graphene哈密顿量(N是条带的宽度 | |||||||
|     # 原胞间的跃迁h01 |     # 原胞间的跃迁h01 | ||||||
|     for i in range(N): |     for i in range(N): | ||||||
|         # 最近邻 |         # 最近邻 | ||||||
|         h01[i*4+1, i*4+0] = t1*cmath.exp(-2*pi*1j*B*(3*i+1/4)*(np.sqrt(3)/2)) |         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*i+7/4)*(np.sqrt(3)/2)) |         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*k) + h01.transpose().conj()*cmath.exp(-1j*k) |     matrix = h00 + h01*cmath.exp(1j*k) + h01.transpose().conj()*cmath.exp(-1j*k) | ||||||
|     return matrix |     return matrix | ||||||
|  |  | ||||||
| def main(): | def main(): | ||||||
|     N = 30 |     N = 30 | ||||||
|     hamiltonian_function0 = functools.partial(hamiltonian, k=0, N=N, M=0, t1=1) |     a = 1 | ||||||
|     B_array = np.linspace(0, 1/(3*np.sqrt(3)/2), 100) |     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) |     eigenvalue_array = guan.calculate_eigenvalue_with_one_parameter(B_array, hamiltonian_function0) | ||||||
|     BS_array = B_array*(3*np.sqrt(3)/2) |     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) |     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) | ||||||
|     |     | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user