import kwant
from numpy import sqrt,sin,cos,pi,sinh
# For plotting
from matplotlib import pyplot
def make_system(a=1, t=1.0, W=10, L=30,V0=0):
lat = kwant.lattice.square(a)
sys = kwant.Builder()
sys[(lat(x, y) for x in range(L) for y in range(W))] = 4*t+V0
sys[lat.neighbors()] = -t
#### Define and attach the leads. ####
lead = kwant.Builder(kwant.TranslationalSymmetry((-a, 0)))
lead[(lat(0, j) for j in range(W))] = 4 * t
lead[lat.neighbors()] = -t
sys.attach_lead(lead)
sys.attach_lead(lead.reversed())
return sys
def plot_conductance(sys, energies):
# Compute conductance
data = []
for energy in energies:
smatrix = kwant.smatrix(sys, energy)
data.append(smatrix.transmission(1, 0))
# pyplot.figure()
pyplot.plot(energies, data,lw=2,label="numerics")
pyplot.xlabel("well depth [t]")
pyplot.ylabel("conductance [e^2/h]")
pyplot.legend()
pyplot.show()
def main():
V0=0.1
sys = make_system(V0=V0)
# Check that the system looks as intended.
# kwant.plot(sys)
# Finalize the system.
sys = sys.finalized()
e1=2-2*cos(pi/11) #energy of the first transverse mode
def Cond(E,V0,L=30):
if E-e1-V0<=0:
k=sqrt(-E+e1+V0)
return 1/(1+((V0*sinh(k*L))**2 )/(4*(E-e1)*(-E+e1+V0)))
else:
k=sqrt(E-e1-V0)
return 1/(1+((V0*sin(k*L))**2 )/(4*(E-e1)*(E-e1-V0)))
energies=[0.1+0.001 * i for i in range(300)]
Cond_analytic=[Cond(E,V0) for E in energies]
pyplot.plot(energies,Cond_analytic,"ro",label="analytic")
# We should see conductance steps.
plot_conductance(sys, energies)
# Call the main function if the script gets executed (as opposed to imported).
if __name__ == '__main__':
main()