from math import pi, sqrt, tanh
import kwant
# For computing eigenvalues
import scipy.sparse.linalg as sla
# For plotting
from matplotlib import pyplot
#Paramter
LeftLength=0.5 #width of scattering region
RightLength=5
UpWidth=0
DownWidth=2*4+1#length of scattering region
UnitCell=int((DownWidth-1)/2)+1 #unit cell
# Define the graphene lattice
sin_30, cos_30 = (1 / 2, sqrt(3) / 2)
graphene = kwant.lattice.general([(1, 0), (sin_30, cos_30)],
[(0, 0), (0, 1 / sqrt(3))])
a,b=graphene.sublattices
#graphene2 = graphene = kwant.lattice.general([(sqrt(3)/2, 1/2), (0, 1)],
#[(0, 0), (1 / (2*sqrt(3)),1/2)])
def make_system(LeftLength,RightLength,UpWidth,DownWidth):
#### Define the scattering region. ####
# circular scattering region
def circle(pos):
x, y = pos
return (-LeftLength <= x <= RightLength and (-(sqrt(3)/2*DownWidth+1/2/sqrt(3))<=y<=sqrt(3)/2*UpWidth))
syst = kwant.Builder()
# w: width and pot: potential maximum of the p-n junction
def potential(pos):
#def potential(pos):
(x, y) = pos
return 0
syst[graphene.shape(circle, (0, 0))] = potential
# specify the hoppings of the graphene lattice in the
# format expected by builder.HoppingKind
hoppings = (((0, 0), a, b), ((0, 1), a, b), ((-1, 1), a, b))
syst[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = -1
# Lead left and right
sym0 = kwant.TranslationalSymmetry(graphene.vec((-1, 0)))
sym0.add_site_family(graphene.sublattices[0], other_vectors=[(1, -2)])
sym0.add_site_family(graphene.sublattices[1], other_vectors=[(1, -2)])
def lead0_shape(pos):
x, y = pos
return (-(sqrt(3)/2*DownWidth+1/2/sqrt(3))<=y<=sqrt(3)/2*UpWidth)
lead0= kwant.Builder(sym0)
lead0[graphene.shape(lead0_shape, (0, 0))] = 0
lead0[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = -1
#Lead up and down
sym1 = kwant.TranslationalSymmetry(graphene.vec((-1, 2)))
#sym1.add_site_family(graphene.sublattices[0], other_vectors=[(1,1)])
#sym1.add_site_family(graphene.sublattices[1], other_vectors=[(1,1)])
def lead1_shape(pos):
x, y = pos
return (-1<x<6)
lead1= kwant.Builder(sym1)
lead1[graphene.shape(lead1_shape, (0, 0))] = 0
lead1[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = -1
return syst, [lead0,lead0.reversed(),lead1,lead1.reversed()]
def compute_evs(syst):
# Compute some eigenvalues of the closed system
sparse_mat = syst.hamiltonian_submatrix(sparse=True)
evs = sla.eigs(sparse_mat, 2)[0]
print(evs.real)
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()
def plot_bandstructure(flead, momenta):
bands = kwant.physics.Bands(flead)
energies = [bands(k) for k in momenta]
pyplot.figure()
pyplot.plot(momenta, energies)
pyplot.xlabel("momentum [(lattice constant)^-1]")
pyplot.ylabel("energy [t]")
pyplot.show()
def main():
pot = 0
syst, leads = make_system(LeftLength,RightLength,UpWidth,DownWidth)
# To highlight the two sublattices of graphene, we plot one with
# a filled, and the other one with an open circle:
def family_colors(site):
return 0 if site.family == a else 1
# Plot the closed system without leads.
#kwant.plot(syst, site_color=family_colors, site_lw=0.1, colorbar=False)
# Attach the leads to the system.
for lead in leads:
syst.attach_lead(lead)
# Then, plot the system with leads.
kwant.plot(syst, site_color=family_colors, site_lw=0.1,
lead_site_lw=0, colorbar=False)
# Finalize the system.
syst = syst.finalized()
# Plot conductance.
'''energies = []
for ie in range(1,400):
energy = ie * 0.01
energies.append(energy)
plot_conductance(syst, energies)'''
# Call the main function if the script gets executed (as opposed to imported).
# See <http://docs.python.org/library/__main__.html>.
if __name__ == '__main__':
main()