From 22b0b98c212e43a0b0322527dafaf09dec004cb1 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Tue, 11 Jan 2022 19:01:19 +0800 Subject: [PATCH] update --- .../calculation_of_local_currents.py | 4 +- ...alculation_of_local_currents_with_Kwant.py | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents_with_Kwant.py diff --git a/academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents.py b/academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents.py index b9792d8..75d0fb7 100755 --- a/academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents.py +++ b/academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents.py @@ -48,13 +48,13 @@ def matrix_center(width=10, length=300): # 中心区哈密顿量 # 中间加势垒 for j0 in range(6): for i0 in range(6): - hamiltonian[width*(np.int(length/2)-3+j0)+np.int(width/2)-3+i0, width*(np.int(length/2)-3+j0)+np.int(width/2)-3+i0]= 1e8 + 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 = 1 + fermi_energy = 0 width = 60 length = 100 h00 = matrix_00(width) diff --git a/academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents_with_Kwant.py b/academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents_with_Kwant.py new file mode 100644 index 0000000..00ad8fb --- /dev/null +++ b/academic_codes/2020.01.03_1_calculation_of_local_currents/calculation_of_local_currents_with_Kwant.py @@ -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() \ No newline at end of file