본문 바로가기
소프트웨어 (계산용 프로그램)/Kwant

[Kwant-example] simple 1D chain

by Physics 2020. 4. 3.
728x90

Kwant coder for simple 1D chain

■ Kwant code - 1

######## Step-1. Importing Kwant and package program 
import kwant
from matplotlib import pyplot

######## Step-2. Define the Tight-binding system 

def make_system(L=10, t = 1.):
# 2-1. Call Builder()
# syst - the TBM system that will be defined in this example
# L    - the number of lattice in scattering region
#      - its default value is 10  
# t    - hopping integral (default value = 1.0)      
    syst      = kwant.builder.Builder()
# 2-2. Define lattice structure
# lattice1D : 1D chain in TBM
# in this example, we assume that the lattice constant is 1 
    lattice1D = kwant.lattice.chain(a=1) 
# 2-3. Define the matrix element of TBM hamiltonian 
#      : the elements of TBM hamiltonian are on-site hamiltonian and hopping integrals
# 2-3-1. Define the on-site Hamiltonian      
    syst[(lattice1D(i) for i in range (L))] = 2*t
# 2-3-2. Define the hopping elements 
#      : In this example, we only consider the nearest neighbor hopping 
    syst[lattice1D.neighbors()] = -t 
# 2-4. Define the leads 
# 2-4-1 
    lead_symmetry = kwant.TranslationalSymmetry([-1])
    left_lead     = kwant.builder.Builder(lead_symmetry)
# 2-4-2. Define the on-site elements and hopping elements for leads 
    left_lead[lattice1D(0)] = 2*t               # on-site element for left lead
    left_lead[lattice1D.neighbors()] = -t       # hopping element for left lead
# 2-4-3. Setting a right lead 
# The basic structure for a right lead is identical to that of left lead. Thus, 
# we simply use command "reversed()"
    return syst, left_lead

# plotting conductance 
def plot_conductance(syst, energies):
    # Compute transmission as a function of energy
    data = []
    for energy in energies:
        smatrix = kwant.smatrix(syst, energy)
        data.append(smatrix.transmission(0, 1))

    pyplot.figure()
    pyplot.plot(energies, data)
    pyplot.xlabel("energy [t]")
    pyplot.ylabel("conductance [e^2/h]")
    pyplot.show()

# plotting band_structure of lead 
def plot_bandstructure(lead):
    
    kwant.plotter.bands(lead, show=False)
    pyplot.xlabel("momentum [(lattice constant)^-1]")
    pyplot.ylabel("energy [t]")
    pyplot.show()
    
def main():
    TBM_system, TBM_lead = make_system(L=20)

    kwant.plot(TBM_system)
    kwant.plot(TBM_lead)
    plot_bandstructure(TBM_lead.finalized())
# Attaching leads to a scattering region, which is TBM_lead. 
    TBM_system.attach_lead(TBM_lead)
    TBM_system.attach_lead(TBM_lead.reversed())
    
    Finalized_system = TBM_system.finalized()
    plot_conductance(Finalized_system, energies=[0.02* i + 1e-6 for i in range(300)])

 

728x90

댓글