category
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
"""
|
||||
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/948
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import copy
|
||||
import time
|
||||
|
||||
|
||||
def matrix_00(width=10): # 不赋值时默认为10
|
||||
h00 = np.zeros((width, width))
|
||||
for width0 in range(width-1):
|
||||
h00[width0, width0+1] = 1
|
||||
h00[width0+1, width0] = 1
|
||||
return h00
|
||||
|
||||
|
||||
def matrix_01(width=10): # 不赋值时默认为10
|
||||
h01 = np.identity(width)
|
||||
return h01
|
||||
|
||||
|
||||
def main():
|
||||
start_time = time.time()
|
||||
h00 = matrix_00(width=5)
|
||||
h01 = matrix_01(width=5)
|
||||
fermi_energy_array = np.arange(-4, 4, .01)
|
||||
plot_conductance_energy(fermi_energy_array, h00, h01)
|
||||
end_time = time.time()
|
||||
print('运行时间=', end_time-start_time)
|
||||
|
||||
|
||||
def plot_conductance_energy(fermi_energy_array, h00, h01): # 画电导与费米能关系图
|
||||
dim = fermi_energy_array.shape[0]
|
||||
cond = np.zeros(dim)
|
||||
i0 = 0
|
||||
for fermi_energy0 in fermi_energy_array:
|
||||
cond0 = np.real(conductance(fermi_energy0 + 1e-12j, h00, h01))
|
||||
cond[i0] = cond0
|
||||
i0 += 1
|
||||
plt.plot(fermi_energy_array, cond, '-k')
|
||||
plt.show()
|
||||
|
||||
|
||||
def transfer_matrix(fermi_energy, h00, h01, dim): # 转移矩阵T。dim是传递矩阵h00和h01的维度
|
||||
transfer = np.zeros((2*dim, 2*dim), dtype=complex)
|
||||
transfer[0:dim, 0:dim] = np.dot(np.linalg.inv(h01), fermi_energy*np.identity(dim)-h00) # np.dot()等效于np.matmul()
|
||||
transfer[0:dim, dim:2*dim] = np.dot(-1*np.linalg.inv(h01), h01.transpose().conj())
|
||||
transfer[dim:2*dim, 0:dim] = np.identity(dim)
|
||||
transfer[dim:2*dim, dim:2*dim] = 0 # a:b代表 a <= x < b,左闭右开
|
||||
return transfer # 返回转移矩阵
|
||||
|
||||
|
||||
def green_function_lead(fermi_energy, h00, h01, dim): # 电极的表面格林函数
|
||||
transfer = transfer_matrix(fermi_energy, h00, h01, dim)
|
||||
eigenvalue, eigenvector = np.linalg.eig(transfer)
|
||||
ind = np.argsort(np.abs(eigenvalue))
|
||||
temp = np.zeros((2*dim, 2*dim), dtype=complex)
|
||||
i0 = 0
|
||||
for ind0 in ind:
|
||||
temp[:, i0] = eigenvector[:, ind0]
|
||||
i0 += 1
|
||||
s1 = temp[dim:2*dim, 0:dim]
|
||||
s2 = temp[0:dim, 0:dim]
|
||||
s3 = temp[dim:2*dim, dim:2*dim]
|
||||
s4 = temp[0:dim, dim:2*dim]
|
||||
right_lead_surface = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01, s2), np.linalg.inv(s1)))
|
||||
left_lead_surface = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01.transpose().conj(), s3), np.linalg.inv(s4)))
|
||||
return right_lead_surface, left_lead_surface # 返回右电极的表面格林函数和左电极的表面格林函数
|
||||
|
||||
|
||||
def self_energy_lead(fermi_energy, h00, h01, dim): # 电极的自能
|
||||
right_lead_surface, left_lead_surface = green_function_lead(fermi_energy, h00, h01, dim)
|
||||
right_self_energy = np.dot(np.dot(h01, right_lead_surface), h01.transpose().conj())
|
||||
left_self_energy = np.dot(np.dot(h01.transpose().conj(), left_lead_surface), h01)
|
||||
return right_self_energy, left_self_energy # 返回右边电极自能和左边电极自能
|
||||
|
||||
|
||||
def conductance(fermi_energy, h00, h01, nx=300): # 计算电导
|
||||
dim = h00.shape[0]
|
||||
right_self_energy, left_self_energy = self_energy_lead(fermi_energy, h00, h01, dim)
|
||||
for ix in range(nx):
|
||||
if ix == 0:
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00-left_self_energy)
|
||||
green_0n_n = copy.deepcopy(green_nn_n) # 如果直接用等于,两个变量会指向相同的id,改变一个值,另外一个值可能会发生改变,容易出错,所以要用上这个COPY
|
||||
elif ix != nx-1:
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01.transpose().conj(), green_nn_n), h01))
|
||||
green_0n_n = np.dot(np.dot(green_0n_n, h01), green_nn_n)
|
||||
else:
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01.transpose().conj(), green_nn_n), h01)-right_self_energy)
|
||||
green_0n_n = np.dot(np.dot(green_0n_n, h01), green_nn_n)
|
||||
gamma_right = (right_self_energy - right_self_energy.transpose().conj())*(0+1j)
|
||||
gamma_left = (left_self_energy - left_self_energy.transpose().conj())*(0+1j)
|
||||
transmission = np.trace(np.dot(np.dot(np.dot(gamma_left, green_0n_n), gamma_right), green_0n_n.transpose().conj()))
|
||||
return transmission # 返回电导值
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,8 @@
|
||||
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', style='-')
|
@@ -0,0 +1,56 @@
|
||||
"""
|
||||
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/2033
|
||||
"""
|
||||
|
||||
import kwant
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def main():
|
||||
L = 3
|
||||
W = 2
|
||||
|
||||
lat = kwant.lattice.square(a=1, norbs=1) # 定义lattice
|
||||
print('\nlat:\n', lat)
|
||||
|
||||
syst = kwant.Builder() # 定义中心区的Builder
|
||||
print('\nsyst:\n', syst)
|
||||
|
||||
syst_finalized = syst.finalized()
|
||||
hamiltonian = syst_finalized.hamiltonian_submatrix() # 查看哈密顿量
|
||||
print('\nhamiltonian_1(定义):\n', hamiltonian)
|
||||
|
||||
syst[(lat(x, y) for x in range(L) for y in range(W))] = 0 # 晶格初始化为0
|
||||
|
||||
kwant.plot(syst) # 画出syst的示意图
|
||||
|
||||
syst_finalized = syst.finalized()
|
||||
hamiltonian = syst_finalized.hamiltonian_submatrix() # 查看哈密顿量
|
||||
print('\nhamiltonian_2(初始化):\n', hamiltonian)
|
||||
|
||||
syst[lat.neighbors()] = 1 # 添加最近邻跃迁
|
||||
|
||||
kwant.plot(syst) # 画出syst的示意图
|
||||
|
||||
syst_finalized = syst.finalized()
|
||||
hamiltonian = syst_finalized.hamiltonian_submatrix() # 查看哈密顿量
|
||||
print('\nhamiltonian_3(最近邻赋值):\n', hamiltonian)
|
||||
|
||||
lead = kwant.Builder(kwant.TranslationalSymmetry((-1, 0))) # 定义电极的Builder
|
||||
lead[(lat(0, j) for j in range(W))] = 0 # 电极晶格初始化
|
||||
lead[lat.neighbors()] = 1 # 添加最近邻跃迁
|
||||
syst.attach_lead(lead) # 中心区加上左电极
|
||||
syst.attach_lead(lead.reversed()) # 用reversed()方法得到右电极
|
||||
|
||||
# 画出syst的示意图
|
||||
kwant.plot(syst)
|
||||
|
||||
# 查看哈密顿量(加了电极后,并不影响syst哈密顿量)
|
||||
syst_finalized = syst.finalized()
|
||||
hamiltonian = syst_finalized.hamiltonian_submatrix()
|
||||
print('\nhamiltonian_4(加了电极后):\n', hamiltonian)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,94 @@
|
||||
"""
|
||||
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/2033
|
||||
"""
|
||||
|
||||
import kwant
|
||||
import numpy as np
|
||||
from matplotlib import pyplot
|
||||
|
||||
|
||||
def make_system():
|
||||
a = 1 # 晶格常数
|
||||
lat = kwant.lattice.square(a) # 创建晶格,方格子
|
||||
|
||||
syst = kwant.Builder() # 建立中心体系
|
||||
t = 1.0 # hopping值
|
||||
W = 5 # 中心体系宽度
|
||||
L = 40 # 中心体系长度
|
||||
|
||||
# 给中心体系赋值
|
||||
for i in range(L):
|
||||
for j in range(W):
|
||||
syst[lat(i, j)] = 0
|
||||
if j > 0:
|
||||
syst[lat(i, j), lat(i, j-1)] = -t # hopping in y-direction
|
||||
if i > 0:
|
||||
syst[lat(i, j), lat(i-1, j)] = -t # hopping in x-direction
|
||||
|
||||
sym_left_lead = kwant.TranslationalSymmetry((-a, 0)) # 电极的平移对称性,(-a, 0)代表远离中心区的方向,向左
|
||||
left_lead = kwant.Builder(sym_left_lead) # 建立左电极体系
|
||||
# 给电极体系赋值
|
||||
for j in range(W):
|
||||
left_lead[lat(0, j)] = 0
|
||||
if j > 0:
|
||||
left_lead[lat(0, j), lat(0, j - 1)] = -t
|
||||
left_lead[lat(1, j), lat(0, j)] = -t # 这里写一个即可,因为平移对称性已经声明了
|
||||
syst.attach_lead(left_lead) # 把左电极接在中心区
|
||||
|
||||
sym_right_lead = kwant.TranslationalSymmetry((a, 0))
|
||||
right_lead = kwant.Builder(sym_right_lead)
|
||||
for j in range(W):
|
||||
right_lead[lat(0, j)] = 0
|
||||
if j > 0:
|
||||
right_lead[lat(0, j), lat(0, j - 1)] = -t
|
||||
right_lead[lat(1, j), lat(0, j)] = -t
|
||||
syst.attach_lead(right_lead) # 把右电极接在中心区
|
||||
|
||||
kwant.plot(syst) # 把电极-中心区-电极图画出来,通过图像可以看出有没有写错
|
||||
syst = syst.finalized() # 结束体系的制作。这个语句不可以省。这个语句是把Builder对象转换成可计算的对象。
|
||||
return syst
|
||||
|
||||
|
||||
def make_system_with_less_code():
|
||||
a = 1 # 晶格常数
|
||||
lat = kwant.lattice.square(a) # 创建晶格,方格子
|
||||
|
||||
syst = kwant.Builder() # 建立中心体系
|
||||
t = 1.0 # hopping值
|
||||
W = 5 # 中心体系宽度
|
||||
L = 40 # 中心体系长度
|
||||
|
||||
# 中心区
|
||||
syst[(lat(x, y) for x in range(L) for y in range(W))] = 0
|
||||
syst[lat.neighbors()] = -t # 用neighbors()方法
|
||||
|
||||
# 电极
|
||||
lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0)))
|
||||
lead[(lat(0, j) for j in range(W))] = 0
|
||||
lead[lat.neighbors()] = -t # 用neighbors()方法
|
||||
syst.attach_lead(lead) # 左电极
|
||||
syst.attach_lead(lead.reversed()) # 用reversed()方法得到右电极
|
||||
|
||||
kwant.plot(syst) # 把电极-中心区-电极图画出来,通过图像可以看出有没有写错
|
||||
syst = syst.finalized() # 结束体系的制作。这个语句不可以省。这个语句是把Builder对象转换成可计算的对象。
|
||||
return syst
|
||||
|
||||
|
||||
def main():
|
||||
syst = make_system()
|
||||
# syst = make_system_with_less_code() # 和上面的一样,只是用更少的代码写
|
||||
energies = np.linspace(-4, 4, 200)
|
||||
data = []
|
||||
for energy in energies:
|
||||
smatrix = kwant.smatrix(syst, energy) # compute the transmission probability from lead 0 to lead 1
|
||||
data.append(smatrix.transmission(1, 0))
|
||||
pyplot.plot(energies, data)
|
||||
pyplot.xlabel("energy [t]")
|
||||
pyplot.ylabel("conductance [e^2/h]")
|
||||
pyplot.show()
|
||||
# pyplot.savefig('conductance' + '.eps')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,129 @@
|
||||
"""
|
||||
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/3888
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import time
|
||||
|
||||
|
||||
def matrix_00(width=10): # 电极元胞内跃迁,width不赋值时默认为10
|
||||
h00 = np.zeros((width, width))
|
||||
for width0 in range(width-1):
|
||||
h00[width0, width0+1] = 1
|
||||
h00[width0+1, width0] = 1
|
||||
return h00
|
||||
|
||||
|
||||
def matrix_01(width=10): # 电极元胞间跃迁,width不赋值时默认为10
|
||||
h01 = np.identity(width)
|
||||
return h01
|
||||
|
||||
|
||||
def matrix_LC(width=10, length=300): # 左电极跳到中心区
|
||||
h_LC = np.zeros((width, width*length))
|
||||
for width0 in range(width):
|
||||
h_LC[width0, width0] = 1
|
||||
return h_LC
|
||||
|
||||
|
||||
def matrix_CR(width=10, length=300): # 中心区跳到右电极
|
||||
h_CR = np.zeros((width*length, width))
|
||||
for width0 in range(width):
|
||||
h_CR[width*(length-1)+width0, width0] = 1
|
||||
return h_CR
|
||||
|
||||
|
||||
def matrix_center(width=10, length=300): # 中心区哈密顿量
|
||||
hamiltonian = np.zeros((width*length, width*length))
|
||||
for length0 in range(length-1):
|
||||
for width0 in range(width):
|
||||
hamiltonian[width*length0+width0, width*(length0+1)+width0] = 1 # 长度方向跃迁
|
||||
hamiltonian[width*(length0+1)+width0, width*length0+width0] = 1
|
||||
for length0 in range(length):
|
||||
for width0 in range(width-1):
|
||||
hamiltonian[width*length0+width0, width*length0+width0+1] = 1 # 宽度方向跃迁
|
||||
hamiltonian[width*length0+width0+1, width*length0+width0] = 1
|
||||
# 中间加势垒
|
||||
for j0 in range(6):
|
||||
for i0 in range(6):
|
||||
hamiltonian[width*(int(length/2)-3+j0)+int(width/2)-3+i0, width*(int(length/2)-3+j0)+int(width/2)-3+i0]= 1e8
|
||||
return hamiltonian
|
||||
|
||||
|
||||
def main():
|
||||
start_time = time.time()
|
||||
fermi_energy = 0
|
||||
width = 60
|
||||
length = 100
|
||||
h00 = matrix_00(width)
|
||||
h01 = matrix_01(width)
|
||||
G_n = Green_n(fermi_energy+1j*1e-9, h00, h01, width, length)
|
||||
# 下面是提取数据并画图
|
||||
direction_x = np.zeros((width, length))
|
||||
direction_y = np.zeros((width, length))
|
||||
for length0 in range(length-1):
|
||||
for width0 in range(width):
|
||||
direction_x[width0, length0] = G_n[width*length0+width0, width*(length0+1)+width0]
|
||||
for length0 in range(length):
|
||||
for width0 in range(width-1):
|
||||
direction_y[width0, length0] = G_n[width*length0+width0, width*length0+width0+1]
|
||||
# print(direction_x)
|
||||
# print(direction_y)
|
||||
X, Y = np.meshgrid(range(length), range(width))
|
||||
plt.quiver(X, Y, direction_x, direction_y)
|
||||
plt.show()
|
||||
end_time = time.time()
|
||||
print('运行时间=', end_time-start_time)
|
||||
|
||||
|
||||
|
||||
def transfer_matrix(fermi_energy, h00, h01, dim): # 转移矩阵T。dim是传递矩阵h00和h01的维度
|
||||
transfer = np.zeros((2*dim, 2*dim), dtype=complex)
|
||||
transfer[0:dim, 0:dim] = np.dot(np.linalg.inv(h01), fermi_energy*np.identity(dim)-h00) # np.dot()等效于np.matmul()
|
||||
transfer[0:dim, dim:2*dim] = np.dot(-1*np.linalg.inv(h01), h01.transpose().conj())
|
||||
transfer[dim:2*dim, 0:dim] = np.identity(dim)
|
||||
transfer[dim:2*dim, dim:2*dim] = 0 # a:b代表 a <= x < b
|
||||
return transfer # 返回转移矩阵
|
||||
|
||||
|
||||
def green_function_lead(fermi_energy, h00, h01, dim): # 电极的表面格林函数
|
||||
transfer = transfer_matrix(fermi_energy, h00, h01, dim)
|
||||
eigenvalue, eigenvector = np.linalg.eig(transfer)
|
||||
ind = np.argsort(np.abs(eigenvalue))
|
||||
temp = np.zeros((2*dim, 2*dim))*(1+0j)
|
||||
i0 = 0
|
||||
for ind0 in ind:
|
||||
temp[:, i0] = eigenvector[:, ind0]
|
||||
i0 += 1
|
||||
s1 = temp[dim:2*dim, 0:dim]
|
||||
s2 = temp[0:dim, 0:dim]
|
||||
s3 = temp[dim:2*dim, dim:2*dim]
|
||||
s4 = temp[0:dim, dim:2*dim]
|
||||
right_lead_surface = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01, s2), np.linalg.inv(s1)))
|
||||
left_lead_surface = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01.transpose().conj(), s3), np.linalg.inv(s4)))
|
||||
return right_lead_surface, left_lead_surface # 返回右电极的表面格林函数和左电极的表面格林函数
|
||||
|
||||
|
||||
def self_energy_lead(fermi_energy, h00, h01, width, length): # 电极的自能
|
||||
h_LC = matrix_LC(width, length)
|
||||
h_CR = matrix_CR(width, length)
|
||||
right_lead_surface, left_lead_surface = green_function_lead(fermi_energy, h00, h01, width)
|
||||
right_self_energy = np.dot(np.dot(h_CR, right_lead_surface), h_CR.transpose().conj())
|
||||
left_self_energy = np.dot(np.dot(h_LC.transpose().conj(), left_lead_surface), h_LC)
|
||||
return right_self_energy, left_self_energy # 返回右电极的自能和左电极的自能
|
||||
|
||||
|
||||
def Green_n(fermi_energy, h00, h01, width, length): # 计算G_n
|
||||
right_self_energy, left_self_energy = self_energy_lead(fermi_energy, h00, h01, width, length)
|
||||
hamiltonian = matrix_center(width, length)
|
||||
green = np.linalg.inv(fermi_energy*np.identity(width*length)-hamiltonian-left_self_energy-right_self_energy)
|
||||
right_self_energy = (right_self_energy - right_self_energy.transpose().conj())*1j
|
||||
left_self_energy = (left_self_energy - left_self_energy.transpose().conj())*1j
|
||||
G_n = np.imag(np.dot(np.dot(green, left_self_energy), green.transpose().conj()))
|
||||
return G_n
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
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/3888
|
||||
"""
|
||||
|
||||
import kwant
|
||||
|
||||
|
||||
def make_system():
|
||||
a = 1
|
||||
lat = kwant.lattice.square(a, norbs=1) # 创建晶格,方格子
|
||||
syst = kwant.Builder()
|
||||
t = 1.0
|
||||
W = 60 # 中心体系宽度
|
||||
L = 100 # 中心体系长度
|
||||
# 给中心体系赋值
|
||||
for i in range(L):
|
||||
for j in range(W):
|
||||
syst[lat(i, j)] = 0
|
||||
if j > 0:
|
||||
syst[lat(i, j), lat(i, j-1)] = -t # hopping in y-direction
|
||||
if i > 0:
|
||||
syst[lat(i, j), lat(i-1, j)] = -t # hopping in x-direction
|
||||
if 47<=i<53 and 27<=j<33: # 势垒
|
||||
syst[lat(i, j)] = 1e8
|
||||
# 电极
|
||||
lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0)))
|
||||
lead[(lat(0, j) for j in range(W))] = 0
|
||||
lead[lat.neighbors()] = -t # 用neighbors()方法
|
||||
syst.attach_lead(lead) # 左电极
|
||||
syst.attach_lead(lead.reversed()) # 用reversed()方法得到右电极
|
||||
# 制作结束
|
||||
kwant.plot(syst)
|
||||
syst = syst.finalized()
|
||||
return syst
|
||||
|
||||
|
||||
def main():
|
||||
syst = make_system()
|
||||
psi = kwant.wave_function(syst)(0)[29]
|
||||
current = kwant.operator.Current(syst)(psi)
|
||||
kwant.plotter.current(syst, current)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
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/3888
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import time
|
||||
import guan
|
||||
|
||||
def matrix_00(width=10): # 电极元胞内跃迁,width不赋值时默认为10
|
||||
h00 = np.zeros((width, width))
|
||||
for width0 in range(width-1):
|
||||
h00[width0, width0+1] = 1
|
||||
h00[width0+1, width0] = 1
|
||||
return h00
|
||||
|
||||
|
||||
def matrix_01(width=10): # 电极元胞间跃迁,width不赋值时默认为10
|
||||
h01 = np.identity(width)
|
||||
return h01
|
||||
|
||||
|
||||
def matrix_LC(width=10, length=300): # 左电极跳到中心区
|
||||
h_LC = np.zeros((width, width*length))
|
||||
for width0 in range(width):
|
||||
h_LC[width0, width0] = 1
|
||||
return h_LC
|
||||
|
||||
|
||||
def matrix_CR(width=10, length=300): # 中心区跳到右电极
|
||||
h_CR = np.zeros((width*length, width))
|
||||
for width0 in range(width):
|
||||
h_CR[width*(length-1)+width0, width0] = 1
|
||||
return h_CR
|
||||
|
||||
|
||||
def matrix_center(width=10, length=300): # 中心区哈密顿量
|
||||
hamiltonian = np.zeros((width*length, width*length))
|
||||
for length0 in range(length-1):
|
||||
for width0 in range(width):
|
||||
hamiltonian[width*length0+width0, width*(length0+1)+width0] = 1 # 长度方向跃迁
|
||||
hamiltonian[width*(length0+1)+width0, width*length0+width0] = 1
|
||||
for length0 in range(length):
|
||||
for width0 in range(width-1):
|
||||
hamiltonian[width*length0+width0, width*length0+width0+1] = 1 # 宽度方向跃迁
|
||||
hamiltonian[width*length0+width0+1, width*length0+width0] = 1
|
||||
# 中间加势垒
|
||||
for j0 in range(6):
|
||||
for i0 in range(6):
|
||||
hamiltonian[width*(int(length/2)-3+j0)+int(width/2)-3+i0, width*(int(length/2)-3+j0)+int(width/2)-3+i0]= 1e8
|
||||
return hamiltonian
|
||||
|
||||
|
||||
def main():
|
||||
start_time = time.time()
|
||||
fermi_energy = 0
|
||||
width = 60
|
||||
length = 100
|
||||
h00 = matrix_00(width)
|
||||
h01 = matrix_01(width)
|
||||
h_LC = matrix_LC(width, length)
|
||||
h_CR = matrix_CR(width, length)
|
||||
hamiltonian = matrix_center(width, length)
|
||||
|
||||
G_n = guan.electron_correlation_function_green_n_for_local_current(fermi_energy, h00, h01, h_LC, h_CR, hamiltonian)
|
||||
|
||||
direction_x = np.zeros((width, length))
|
||||
direction_y = np.zeros((width, length))
|
||||
for length0 in range(length-1):
|
||||
for width0 in range(width):
|
||||
direction_x[width0, length0] = G_n[width*length0+width0, width*(length0+1)+width0]
|
||||
for length0 in range(length):
|
||||
for width0 in range(width-1):
|
||||
direction_y[width0, length0] = G_n[width*length0+width0, width*length0+width0+1]
|
||||
|
||||
X, Y = np.meshgrid(range(length), range(width))
|
||||
plt.quiver(X, Y, direction_x, direction_y)
|
||||
plt.show()
|
||||
end_time = time.time()
|
||||
print('运行时间=', end_time-start_time)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,240 @@
|
||||
"""
|
||||
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/6352
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from math import *
|
||||
import copy
|
||||
import time
|
||||
# import os
|
||||
# os.chdir('D:/data')
|
||||
|
||||
|
||||
def main():
|
||||
start_time = time.time()
|
||||
h00 = matrix_00() # 方格子模型
|
||||
h01 = matrix_01() # 方格子模型
|
||||
fermi_energy = 0.1
|
||||
write_transmission_matrix(fermi_energy, h00, h01) # 输出无散射的散射矩阵
|
||||
end_time = time.time()
|
||||
print('运行时间=', end_time - start_time, '秒')
|
||||
|
||||
|
||||
def matrix_00(width=4):
|
||||
h00 = np.zeros((width, width))
|
||||
for width0 in range(width-1):
|
||||
h00[width0, width0+1] = 1
|
||||
h00[width0+1, width0] = 1
|
||||
return h00
|
||||
|
||||
|
||||
def matrix_01(width=4):
|
||||
h01 = np.identity(width)
|
||||
return h01
|
||||
|
||||
|
||||
def transfer_matrix(fermi_energy, h00, h01, dim): # 转移矩阵
|
||||
transfer = np.zeros((2*dim, 2*dim))*(0+0j)
|
||||
transfer[0:dim, 0:dim] = np.dot(np.linalg.inv(h01), fermi_energy*np.identity(dim)-h00)
|
||||
transfer[0:dim, dim:2*dim] = np.dot(-1*np.linalg.inv(h01), h01.transpose().conj())
|
||||
transfer[dim:2*dim, 0:dim] = np.identity(dim)
|
||||
transfer[dim:2*dim, dim:2*dim] = 0
|
||||
return transfer
|
||||
|
||||
|
||||
def complex_wave_vector(fermi_energy, h00, h01, dim): # 获取通道的复数波矢,并按照波矢的实部Re(k)排序
|
||||
transfer = transfer_matrix(fermi_energy, h00, h01, dim)
|
||||
eigenvalue, eigenvector = np.linalg.eig(transfer)
|
||||
k_channel = np.log(eigenvalue)/1j
|
||||
ind = np.argsort(np.real(k_channel))
|
||||
k_channel = np.sort(k_channel)
|
||||
temp = np.zeros((2*dim, 2*dim))*(1+0j)
|
||||
temp2 = np.zeros((2*dim))*(1+0j)
|
||||
i0 = 0
|
||||
for ind0 in ind:
|
||||
temp[:, i0] = eigenvector[:, ind0]
|
||||
temp2[i0] = eigenvalue[ind0]
|
||||
i0 += 1
|
||||
eigenvalue = copy.deepcopy(temp2)
|
||||
temp = normalization_of_eigenvector(temp[0:dim, :], dim)
|
||||
velocity = np.zeros((2*dim))*(1+0j)
|
||||
for dim0 in range(2*dim):
|
||||
velocity[dim0] = eigenvalue[dim0]*np.dot(np.dot(temp[0:dim, :].transpose().conj(), h01),temp[0:dim, :])[dim0, dim0]
|
||||
velocity = -2*np.imag(velocity)
|
||||
eigenvector = copy.deepcopy(temp)
|
||||
return k_channel, velocity, eigenvalue, eigenvector # 返回通道的对应的波矢、费米速度、本征值、本征态
|
||||
|
||||
|
||||
def normalization_of_eigenvector(eigenvector, dim): # 波函数归一化
|
||||
factor = np.zeros(2*dim)*(1+0j)
|
||||
for dim0 in range(dim):
|
||||
factor = factor+np.square(np.abs(eigenvector[dim0, :]))
|
||||
for dim0 in range(2*dim):
|
||||
eigenvector[:, dim0] = eigenvector[:, dim0]/np.sqrt(factor[dim0])
|
||||
return eigenvector
|
||||
|
||||
|
||||
def calculation_of_lambda_u_f(fermi_energy, h00, h01, dim): # 对所有通道(包括active和evanescent)进行分类,并计算F
|
||||
k_channel, velocity, eigenvalue, eigenvector = complex_wave_vector(fermi_energy, h00, h01, dim)
|
||||
ind_right_active = 0; ind_right_evanescent = 0; ind_left_active = 0; ind_left_evanescent = 0
|
||||
k_right = np.zeros(dim)*(1+0j); k_left = np.zeros(dim)*(1+0j)
|
||||
velocity_right = np.zeros(dim)*(1+0j); velocity_left = np.zeros(dim)*(1+0j)
|
||||
lambda_right = np.zeros(dim)*(1+0j); lambda_left = np.zeros(dim)*(1+0j)
|
||||
u_right = np.zeros((dim, dim))*(1+0j); u_left = np.zeros((dim, dim))*(1+0j)
|
||||
for dim0 in range(2*dim):
|
||||
if_active = if_active_channel(k_channel[dim0])
|
||||
direction = direction_of_channel(velocity[dim0], k_channel[dim0])
|
||||
if direction == 1: # 向右运动的通道
|
||||
if if_active == 1: # 可传播通道(active channel)
|
||||
k_right[ind_right_active] = k_channel[dim0]
|
||||
velocity_right[ind_right_active] = velocity[dim0]
|
||||
lambda_right[ind_right_active] = eigenvalue[dim0]
|
||||
u_right[:, ind_right_active] = eigenvector[:, dim0]
|
||||
ind_right_active += 1
|
||||
else: # 衰减通道(evanescent channel)
|
||||
k_right[dim-1-ind_right_evanescent] = k_channel[dim0]
|
||||
velocity_right[dim-1-ind_right_evanescent] = velocity[dim0]
|
||||
lambda_right[dim-1-ind_right_evanescent] = eigenvalue[dim0]
|
||||
u_right[:, dim-1-ind_right_evanescent] = eigenvector[:, dim0]
|
||||
ind_right_evanescent += 1
|
||||
else: # 向左运动的通道
|
||||
if if_active == 1: # 可传播通道(active channel)
|
||||
k_left[ind_left_active] = k_channel[dim0]
|
||||
velocity_left[ind_left_active] = velocity[dim0]
|
||||
lambda_left[ind_left_active] = eigenvalue[dim0]
|
||||
u_left[:, ind_left_active] = eigenvector[:, dim0]
|
||||
ind_left_active += 1
|
||||
else: # 衰减通道(evanescent channel)
|
||||
k_left[dim-1-ind_left_evanescent] = k_channel[dim0]
|
||||
velocity_left[dim-1-ind_left_evanescent] = velocity[dim0]
|
||||
lambda_left[dim-1-ind_left_evanescent] = eigenvalue[dim0]
|
||||
u_left[:, dim-1-ind_left_evanescent] = eigenvector[:, dim0]
|
||||
ind_left_evanescent += 1
|
||||
lambda_matrix_right = np.diag(lambda_right)
|
||||
lambda_matrix_left = np.diag(lambda_left)
|
||||
f_right = np.dot(np.dot(u_right, lambda_matrix_right), np.linalg.inv(u_right))
|
||||
f_left = np.dot(np.dot(u_left, lambda_matrix_left), np.linalg.inv(u_left))
|
||||
return k_right, k_left, velocity_right, velocity_left, f_right, f_left, u_right, u_left, ind_right_active
|
||||
# 分别返回向右和向左的运动的波矢k、费米速度velocity、F值、U值、可向右传播的通道数
|
||||
|
||||
|
||||
def if_active_channel(k_channel): # 判断是可传播通道还是衰减通道
|
||||
if np.abs(np.imag(k_channel)) < 1e-7:
|
||||
if_active = 1
|
||||
else:
|
||||
if_active = 0
|
||||
return if_active
|
||||
|
||||
|
||||
def direction_of_channel(velocity, k_channel): # 判断通道对应的费米速度方向
|
||||
if if_active_channel(k_channel) == 1:
|
||||
direction = np.sign(velocity)
|
||||
else:
|
||||
direction = np.sign(np.imag(k_channel))
|
||||
return direction
|
||||
|
||||
|
||||
def calculation_of_green_function(fermi_energy, h00, h01, dim, scatter_type=0, scatter_intensity=0.2, scatter_length=20): # 计算格林函数
|
||||
k_right, k_left, velocity_right, velocity_left, f_right, f_left, u_right, u_left, ind_right_active = calculation_of_lambda_u_f(fermi_energy, h00, h01, dim)
|
||||
right_self_energy = np.dot(h01, f_right)
|
||||
left_self_energy = np.dot(h01.transpose().conj(), np.linalg.inv(f_left))
|
||||
nx = 300
|
||||
for nx0 in range(nx):
|
||||
if nx0 == 0:
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00-left_self_energy)
|
||||
green_00_n = copy.deepcopy(green_nn_n)
|
||||
green_0n_n = copy.deepcopy(green_nn_n)
|
||||
green_n0_n = copy.deepcopy(green_nn_n)
|
||||
elif nx0 != nx-1:
|
||||
if scatter_type == 0: # 无散射
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01.transpose().conj(), green_nn_n), h01))
|
||||
elif scatter_type == 1: # 势垒散射
|
||||
h00_scatter = h00 + scatter_intensity * np.identity(dim)
|
||||
if int(nx/2)-int(scatter_length/2) <= nx0 < int(nx/2)+int((scatter_length+1)/2):
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00_scatter - np.dot(np.dot(h01.transpose().conj(), green_nn_n), h01))
|
||||
else:
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01.transpose().conj(), green_nn_n), h01))
|
||||
else:
|
||||
green_nn_n = np.linalg.inv(fermi_energy*np.identity(dim)-h00-right_self_energy-np.dot(np.dot(h01.transpose().conj(), green_nn_n), h01))
|
||||
|
||||
green_00_n = green_00_n+np.dot(np.dot(np.dot(np.dot(green_0n_n, h01), green_nn_n), h01.transpose().conj()), green_n0_n)
|
||||
green_0n_n = np.dot(np.dot(green_0n_n, h01), green_nn_n)
|
||||
green_n0_n = np.dot(np.dot(green_nn_n, h01.transpose().conj()), green_n0_n)
|
||||
return green_00_n, green_n0_n, k_right, k_left, velocity_right, velocity_left, f_right, f_left, u_right, u_left, ind_right_active
|
||||
|
||||
|
||||
def transmission_with_detailed_modes(fermi_energy, h00, h01, scatter_type=0, scatter_intensity=0.2, scatter_length=20): # 计算散射矩阵
|
||||
dim = h00.shape[0]
|
||||
green_00_n, green_n0_n, k_right, k_left, velocity_right, velocity_left, f_right, f_left, u_right, u_left, ind_right_active = calculation_of_green_function(fermi_energy, h00, h01, dim, scatter_type, scatter_intensity, scatter_length)
|
||||
temp = np.dot(h01.transpose().conj(), np.linalg.inv(f_right)-np.linalg.inv(f_left))
|
||||
transmission_matrix = np.dot(np.dot(np.linalg.inv(u_right), np.dot(green_n0_n, temp)), u_right)
|
||||
reflection_matrix = np.dot(np.dot(np.linalg.inv(u_left), np.dot(green_00_n, temp)-np.identity(dim)), u_right)
|
||||
for dim0 in range(dim):
|
||||
for dim1 in range(dim):
|
||||
if_active = if_active_channel(k_right[dim0])*if_active_channel(k_right[dim1])
|
||||
if if_active == 1:
|
||||
transmission_matrix[dim0, dim1] = np.sqrt(np.abs(velocity_right[dim0]/velocity_right[dim1])) * transmission_matrix[dim0, dim1]
|
||||
reflection_matrix[dim0, dim1] = np.sqrt(np.abs(velocity_left[dim0] / velocity_right[dim1]))*reflection_matrix[dim0, dim1]
|
||||
else:
|
||||
transmission_matrix[dim0, dim1] = 0
|
||||
reflection_matrix[dim0, dim1] = 0
|
||||
sum_of_tran_refl_array = np.sum(np.square(np.abs(transmission_matrix[0:ind_right_active, 0:ind_right_active])), axis=0)+np.sum(np.square(np.abs(reflection_matrix[0:ind_right_active, 0:ind_right_active])), axis=0)
|
||||
for sum_of_tran_refl in sum_of_tran_refl_array:
|
||||
if sum_of_tran_refl > 1.001:
|
||||
print('错误警告:散射矩阵的计算结果不归一! Error Alert: scattering matrix is not normalized!')
|
||||
return transmission_matrix, reflection_matrix, k_right, k_left, velocity_right, velocity_left, ind_right_active
|
||||
|
||||
|
||||
def write_transmission_matrix(fermi_energy, h00, h01, scatter_type=0, scatter_intensity=0.2, scatter_length=20): # 输出
|
||||
transmission_matrix, reflection_matrix, k_right, k_left, velocity_right, velocity_left, ind_right_active, \
|
||||
= transmission_with_detailed_modes(fermi_energy, h00, h01, scatter_type, scatter_intensity, scatter_length)
|
||||
dim = h00.shape[0]
|
||||
np.set_printoptions(suppress=True) # 取消科学计数法输出
|
||||
print('\n可传播的通道数(向右)active_channel (right) = ', ind_right_active)
|
||||
print('衰减的通道数(向右) evanescent_channel (right) = ', dim-ind_right_active, '\n')
|
||||
print('向右可传播的通道数对应的波矢 k_right:\n', np.real(k_right[0:ind_right_active]))
|
||||
print('向左可传播的通道数对应的波矢 k_left:\n', np.real(k_left[0:ind_right_active]), '\n')
|
||||
print('向右可传播的通道数对应的费米速度 velocity_right:\n', np.real(velocity_right[0:ind_right_active]))
|
||||
print('向左可传播的通道数对应的费米速度 velocity_left:\n', np.real(velocity_left[0:ind_right_active]), '\n')
|
||||
print('透射矩阵 transmission_matrix:\n', np.square(np.abs(transmission_matrix[0:ind_right_active, 0:ind_right_active])))
|
||||
print('反射矩阵 reflection_matrix:\n', np.square(np.abs(reflection_matrix[0:ind_right_active, 0:ind_right_active])), '\n')
|
||||
print('透射矩阵列求和 total transmission of channels =\n', np.sum(np.square(np.abs(transmission_matrix[0:ind_right_active, 0:ind_right_active])), axis=0))
|
||||
print('反射矩阵列求和 total reflection of channels =\n',np.sum(np.square(np.abs(reflection_matrix[0:ind_right_active, 0:ind_right_active])), axis=0))
|
||||
print('透射以及反射矩阵列求和 sum of transmission and reflection of channels =\n', np.sum(np.square(np.abs(transmission_matrix[0:ind_right_active, 0:ind_right_active])), axis=0) + np.sum(np.square(np.abs(reflection_matrix[0:ind_right_active, 0:ind_right_active])), axis=0))
|
||||
print('总电导 total conductance = ', np.sum(np.square(np.abs(transmission_matrix[0:ind_right_active, 0:ind_right_active]))), '\n')
|
||||
|
||||
# 下面把以上信息写入文件中
|
||||
with open('a.txt', 'w') as f:
|
||||
f.write('Active_channel (right or left) = ' + str(ind_right_active) + '\n')
|
||||
f.write('Evanescent_channel (right or left) = ' + str(dim - ind_right_active) + '\n\n')
|
||||
f.write('Channel K Velocity\n')
|
||||
for ind0 in range(ind_right_active):
|
||||
f.write(' '+str(ind0 + 1) + ' | '+str(np.real(k_right[ind0]))+' ' + str(np.real(velocity_right[ind0]))+'\n')
|
||||
f.write('\n')
|
||||
for ind0 in range(ind_right_active):
|
||||
f.write(' -' + str(ind0 + 1) + ' | ' + str(np.real(k_left[ind0])) + ' ' + str(np.real(velocity_left[ind0])) + '\n')
|
||||
f.write('\n\nScattering_matrix:\n ')
|
||||
for ind0 in range(ind_right_active):
|
||||
f.write(str(ind0+1)+' ')
|
||||
f.write('\n')
|
||||
for ind1 in range(ind_right_active):
|
||||
f.write(' '+str(ind1+1)+' ')
|
||||
for ind2 in range(ind_right_active):
|
||||
f.write('%f' % np.square(np.abs(transmission_matrix[ind1, ind2]))+' ')
|
||||
f.write('\n')
|
||||
f.write('\n')
|
||||
for ind1 in range(ind_right_active):
|
||||
f.write(' -'+str(ind1+1)+' ')
|
||||
for ind2 in range(ind_right_active):
|
||||
f.write('%f' % np.square(np.abs(reflection_matrix[ind1, ind2]))+' ')
|
||||
f.write('\n')
|
||||
f.write('\n')
|
||||
f.write('Total transmission of channels:\n'+str(np.sum(np.square(np.abs(transmission_matrix[0:ind_right_active, 0:ind_right_active])), axis=0))+'\n')
|
||||
f.write('Total conductance = '+str(np.sum(np.square(np.abs(transmission_matrix[0:ind_right_active, 0:ind_right_active]))))+'\n')
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,180 @@
|
||||
"""
|
||||
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/6075
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import copy
|
||||
import time
|
||||
|
||||
|
||||
def get_lead_h00(width):
|
||||
h00 = np.zeros((width, width))
|
||||
for i0 in range(width-1):
|
||||
h00[i0, i0+1] = 1
|
||||
h00[i0+1, i0] = 1
|
||||
return h00
|
||||
|
||||
|
||||
def get_lead_h01(width):
|
||||
h01 = np.identity(width)
|
||||
return h01
|
||||
|
||||
|
||||
def get_center_hamiltonian(Nx, Ny):
|
||||
h = np.zeros((Nx*Ny, Nx*Ny))
|
||||
for x0 in range(Nx-1):
|
||||
for y0 in range(Ny):
|
||||
h[x0*Ny+y0, (x0+1)*Ny+y0] = 1 # x方向的跃迁
|
||||
h[(x0+1)*Ny+y0, x0*Ny+y0] = 1
|
||||
for x0 in range(Nx):
|
||||
for y0 in range(Ny-1):
|
||||
h[x0*Ny+y0, x0*Ny+y0+1] = 1 # y方向的跃迁
|
||||
h[x0*Ny+y0+1, x0*Ny+y0] = 1
|
||||
return h
|
||||
|
||||
|
||||
def main():
|
||||
start_time = time.time()
|
||||
width = 5
|
||||
length = 50
|
||||
fermi_energy_array = np.arange(-4, 4, .01)
|
||||
|
||||
# 中心区的哈密顿量
|
||||
H_center = 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)
|
||||
# 表面格林函数
|
||||
right_lead_surface, left_lead_surface = surface_green_function_lead(fermi_energy + 1e-9j, lead_h00, lead_h01, dim=width)
|
||||
|
||||
# 由于镜面对称以及xy各项同性,因此这里六个电极的表面格林函数具有相同的形式
|
||||
lead_1 = copy.deepcopy(right_lead_surface) # 镜面对称使得lead_1=lead_4
|
||||
lead_2 = copy.deepcopy(right_lead_surface) # xy各向同性使得lead_2=lead_4
|
||||
lead_3 = copy.deepcopy(right_lead_surface)
|
||||
lead_4 = copy.deepcopy(right_lead_surface)
|
||||
lead_5 = copy.deepcopy(right_lead_surface)
|
||||
lead_6 = copy.deepcopy(right_lead_surface)
|
||||
|
||||
# 几何形状如下所示:
|
||||
# lead2 lead3
|
||||
# lead1(L) lead4(R)
|
||||
# lead6 lead5
|
||||
|
||||
# 电极到中心区的跃迁矩阵
|
||||
H_lead_1_to_center = np.zeros((width, width*length), dtype=complex)
|
||||
H_lead_2_to_center = np.zeros((width, width*length), dtype=complex)
|
||||
H_lead_3_to_center = np.zeros((width, width*length), dtype=complex)
|
||||
H_lead_4_to_center = np.zeros((width, width*length), dtype=complex)
|
||||
H_lead_5_to_center = np.zeros((width, width*length), dtype=complex)
|
||||
H_lead_6_to_center = np.zeros((width, width*length), dtype=complex)
|
||||
move = 0 # the step of leads 2,3,6,5 moving to center
|
||||
for i0 in range(width):
|
||||
H_lead_1_to_center[i0, i0] = 1
|
||||
H_lead_2_to_center[i0, width*(move+i0)+(width-1)] = 1
|
||||
H_lead_3_to_center[i0, width*(length-move-1-i0)+(width-1)] = 1
|
||||
H_lead_4_to_center[i0, width*(length-1)+i0] = 1
|
||||
H_lead_5_to_center[i0, width*(length-move-1-i0)+0] = 1
|
||||
H_lead_6_to_center[i0, width*(move+i0)+0] = 1
|
||||
|
||||
# 自能
|
||||
self_energy_1 = np.dot(np.dot(H_lead_1_to_center.transpose().conj(), lead_1), H_lead_1_to_center)
|
||||
self_energy_2 = np.dot(np.dot(H_lead_2_to_center.transpose().conj(), lead_2), H_lead_2_to_center)
|
||||
self_energy_3 = np.dot(np.dot(H_lead_3_to_center.transpose().conj(), lead_3), H_lead_3_to_center)
|
||||
self_energy_4 = np.dot(np.dot(H_lead_4_to_center.transpose().conj(), lead_4), H_lead_4_to_center)
|
||||
self_energy_5 = np.dot(np.dot(H_lead_5_to_center.transpose().conj(), lead_5), H_lead_5_to_center)
|
||||
self_energy_6 = np.dot(np.dot(H_lead_6_to_center.transpose().conj(), lead_6), H_lead_6_to_center)
|
||||
|
||||
# 整体格林函数
|
||||
green = np.linalg.inv(fermi_energy*np.eye(width*length)-H_center-self_energy_1-self_energy_2-self_energy_3-self_energy_4-self_energy_5-self_energy_6)
|
||||
|
||||
# Gamma矩阵
|
||||
gamma_1 = 1j*(self_energy_1-self_energy_1.transpose().conj())
|
||||
gamma_2 = 1j*(self_energy_2-self_energy_2.transpose().conj())
|
||||
gamma_3 = 1j*(self_energy_3-self_energy_3.transpose().conj())
|
||||
gamma_4 = 1j*(self_energy_4-self_energy_4.transpose().conj())
|
||||
gamma_5 = 1j*(self_energy_5-self_energy_5.transpose().conj())
|
||||
gamma_6 = 1j*(self_energy_6-self_energy_6.transpose().conj())
|
||||
|
||||
# Transmission
|
||||
transmission_12 = np.trace(np.dot(np.dot(np.dot(gamma_1, green), gamma_2), green.transpose().conj()))
|
||||
transmission_13 = np.trace(np.dot(np.dot(np.dot(gamma_1, green), gamma_3), green.transpose().conj()))
|
||||
transmission_14 = np.trace(np.dot(np.dot(np.dot(gamma_1, green), gamma_4), green.transpose().conj()))
|
||||
transmission_15 = np.trace(np.dot(np.dot(np.dot(gamma_1, green), gamma_5), green.transpose().conj()))
|
||||
transmission_16 = np.trace(np.dot(np.dot(np.dot(gamma_1, green), gamma_6), 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))
|
||||
|
||||
Plot_Line(fermi_energy_array, transmission_12_array, xlabel='Fermi energy', ylabel='Transmission_12', title='', filename='a')
|
||||
Plot_Line(fermi_energy_array, transmission_13_array, xlabel='Fermi energy', ylabel='Transmission_13', title='', filename='a')
|
||||
Plot_Line(fermi_energy_array, transmission_14_array, xlabel='Fermi energy', ylabel='Transmission_14', title='', filename='a')
|
||||
Plot_Line(fermi_energy_array, transmission_15_array, xlabel='Fermi energy', ylabel='Transmission_15', title='', filename='a')
|
||||
Plot_Line(fermi_energy_array, transmission_16_array, xlabel='Fermi energy', ylabel='Transmission_16', title='', filename='a')
|
||||
Plot_Line(fermi_energy_array, transmission_1_all_array, xlabel='Fermi energy', ylabel='Transmission_1_all', title='', filename='a')
|
||||
end_time = time.time()
|
||||
print('运行时间=', end_time-start_time)
|
||||
|
||||
|
||||
|
||||
def Plot_Line(x, y, xlabel='x', ylabel='y', title='', filename='a'):
|
||||
import matplotlib.pyplot as plt
|
||||
fig, ax = plt.subplots()
|
||||
plt.subplots_adjust(bottom=0.20, left=0.18)
|
||||
ax.plot(x, y, '-')
|
||||
ax.grid()
|
||||
ax.set_title(title, fontsize=20, fontfamily='Times New Roman')
|
||||
ax.set_xlabel(xlabel, fontsize=20, fontfamily='Times New Roman')
|
||||
ax.set_ylabel(ylabel, fontsize=20, fontfamily='Times New Roman')
|
||||
ax.tick_params(labelsize=20)
|
||||
labels = ax.get_xticklabels() + ax.get_yticklabels()
|
||||
[label.set_fontname('Times New Roman') for label in labels]
|
||||
# plt.savefig(filename+'.jpg', dpi=300)
|
||||
plt.show()
|
||||
plt.close('all')
|
||||
|
||||
def transfer_matrix(fermi_energy, h00, h01, dim): # 转移矩阵T
|
||||
transfer = np.zeros((2*dim, 2*dim))*(0+0j)
|
||||
transfer[0:dim, 0:dim] = np.dot(np.linalg.inv(h01), fermi_energy*np.identity(dim)-h00)
|
||||
transfer[0:dim, dim:2*dim] = np.dot(-1*np.linalg.inv(h01), h01.transpose().conj())
|
||||
transfer[dim:2*dim, 0:dim] = np.identity(dim)
|
||||
transfer[dim:2*dim, dim:2*dim] = 0
|
||||
return transfer # 返回转移矩阵
|
||||
|
||||
|
||||
def surface_green_function_lead(fermi_energy, h00, h01, dim): # 电极的表面格林函数
|
||||
transfer = transfer_matrix(fermi_energy, h00, h01, dim)
|
||||
eigenvalue, eigenvector = np.linalg.eig(transfer)
|
||||
ind = np.argsort(np.abs(eigenvalue))
|
||||
temp = np.zeros((2*dim, 2*dim))*(1+0j)
|
||||
i0 = 0
|
||||
for ind0 in ind:
|
||||
temp[:, i0] = eigenvector[:, ind0]
|
||||
i0 += 1
|
||||
s1 = temp[dim:2*dim, 0:dim]
|
||||
s2 = temp[0:dim, 0:dim]
|
||||
s3 = temp[dim:2*dim, dim:2*dim]
|
||||
s4 = temp[0:dim, dim:2*dim]
|
||||
right_lead_surface = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01, s2), np.linalg.inv(s1)))
|
||||
left_lead_surface = np.linalg.inv(fermi_energy*np.identity(dim)-h00-np.dot(np.dot(h01.transpose().conj(), s3), np.linalg.inv(s4)))
|
||||
return right_lead_surface, left_lead_surface # 返回右电极的表面格林函数和左电极的表面格林函数
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,87 @@
|
||||
"""
|
||||
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/6075
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import time
|
||||
import guan
|
||||
|
||||
def get_lead_h00(width):
|
||||
h00 = np.zeros((width, width))
|
||||
for i0 in range(width-1):
|
||||
h00[i0, i0+1] = 1
|
||||
h00[i0+1, i0] = 1
|
||||
return h00
|
||||
|
||||
|
||||
def get_lead_h01(width):
|
||||
h01 = np.identity(width)
|
||||
return h01
|
||||
|
||||
|
||||
def get_center_hamiltonian(Nx, Ny):
|
||||
h = np.zeros((Nx*Ny, Nx*Ny))
|
||||
for x0 in range(Nx-1):
|
||||
for y0 in range(Ny):
|
||||
h[x0*Ny+y0, (x0+1)*Ny+y0] = 1 # x方向的跃迁
|
||||
h[(x0+1)*Ny+y0, x0*Ny+y0] = 1
|
||||
for x0 in range(Nx):
|
||||
for y0 in range(Ny-1):
|
||||
h[x0*Ny+y0, x0*Ny+y0+1] = 1 # y方向的跃迁
|
||||
h[x0*Ny+y0+1, x0*Ny+y0] = 1
|
||||
return h
|
||||
|
||||
|
||||
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_12, transmission_13, transmission_14, transmission_15, transmission_16 = guan.calculate_six_terminal_transmissions_from_lead_1(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_12)
|
||||
transmission_13_array.append(transmission_13)
|
||||
transmission_14_array.append(transmission_14)
|
||||
transmission_15_array.append(transmission_15)
|
||||
transmission_16_array.append(transmission_16)
|
||||
transmission_1_all_array.append(\
|
||||
transmission_12+transmission_13+transmission_14+transmission_15+transmission_16)
|
||||
|
||||
# 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)/60)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@@ -0,0 +1,94 @@
|
||||
"""
|
||||
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/6075
|
||||
"""
|
||||
|
||||
import kwant
|
||||
import numpy as np
|
||||
from matplotlib import pyplot
|
||||
|
||||
def make_system():
|
||||
a = 1
|
||||
lat = kwant.lattice.square(a)
|
||||
syst = kwant.Builder()
|
||||
t = 1.0
|
||||
W = 5
|
||||
L = 50
|
||||
syst[(lat(x, y) for x in range(L) for y in range(W))] = 0
|
||||
syst[lat.neighbors()] = -t
|
||||
# 几何形状如下所示:
|
||||
# lead2 lead3
|
||||
# lead1(L) lead4(R)
|
||||
# lead6 lead5
|
||||
|
||||
move = 0 # the step of leads 2,3,6,5 moving to center
|
||||
|
||||
lead1 = kwant.Builder(kwant.TranslationalSymmetry((-a, 0)))
|
||||
lead1[(lat(0, j) for j in range(W))] = 0
|
||||
lead1[lat.neighbors()] = -t
|
||||
syst.attach_lead(lead1)
|
||||
|
||||
lead2 = kwant.Builder(kwant.TranslationalSymmetry((0, -a)))
|
||||
lead2[(lat(move+j, 0) for j in range(W))] = 0
|
||||
lead2[lat.neighbors()] = -t
|
||||
syst.attach_lead(lead2)
|
||||
|
||||
lead3 = kwant.Builder(kwant.TranslationalSymmetry((0, -a)))
|
||||
lead3[(lat(j+(L-W-move), 0) for j in range(W))] = 0
|
||||
lead3[lat.neighbors()] = -t
|
||||
syst.attach_lead(lead3)
|
||||
|
||||
syst.attach_lead(lead1.reversed()) # lead4
|
||||
syst.attach_lead(lead3.reversed()) # lead5
|
||||
syst.attach_lead(lead2.reversed()) # lead6
|
||||
|
||||
kwant.plot(syst)
|
||||
syst = syst.finalized()
|
||||
return syst
|
||||
|
||||
|
||||
def main():
|
||||
syst = make_system()
|
||||
energies = np.linspace(-4, 4, 800)
|
||||
data1 = []
|
||||
data2 = []
|
||||
data3 = []
|
||||
data4 = []
|
||||
data5 = []
|
||||
data6 = []
|
||||
for energy in energies:
|
||||
smatrix = kwant.smatrix(syst, energy)
|
||||
data1.append(smatrix.transmission(1, 0)) # compute the transmission probability from lead 0 to lead 1
|
||||
data2.append(smatrix.transmission(2, 0))
|
||||
data3.append(smatrix.transmission(3, 0))
|
||||
data4.append(smatrix.transmission(4, 0))
|
||||
data5.append(smatrix.transmission(5, 0))
|
||||
data6.append(smatrix.transmission(1, 0)+smatrix.transmission(2, 0)+smatrix.transmission(3, 0)+smatrix.transmission(4, 0)+smatrix.transmission(5, 0))
|
||||
pyplot.plot(energies, data1)
|
||||
pyplot.xlabel("energy [t]")
|
||||
pyplot.ylabel("Transmission_12 [e^2/h]")
|
||||
pyplot.show()
|
||||
pyplot.plot(energies, data2)
|
||||
pyplot.xlabel("energy [t]")
|
||||
pyplot.ylabel("Transmission_13 [e^2/h]")
|
||||
pyplot.show()
|
||||
pyplot.plot(energies, data3)
|
||||
pyplot.xlabel("energy [t]")
|
||||
pyplot.ylabel("Transmission_14 [e^2/h]")
|
||||
pyplot.show()
|
||||
pyplot.plot(energies, data4)
|
||||
pyplot.xlabel("energy [t]")
|
||||
pyplot.ylabel("Transmission_15 [e^2/h]")
|
||||
pyplot.show()
|
||||
pyplot.plot(energies, data5)
|
||||
pyplot.xlabel("energy [t]")
|
||||
pyplot.ylabel("Transmission_16 [e^2/h]")
|
||||
pyplot.show()
|
||||
pyplot.plot(energies, data6)
|
||||
pyplot.xlabel("energy [t]")
|
||||
pyplot.ylabel("Transmission_1_all [e^2/h]")
|
||||
pyplot.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user