When you are connecting the edges you have to use proper lattice index. Here is a working example for armchair (V1.0.1).
from math import sqrt
import kwant
from matplotlib import pyplot
# Define the graphene lattice
sin_30, cos_30 = (1 / 2., sqrt(3) / 2.)
#armchair
graphene = kwant.lattice.general([(0, 1), (cos_30, sin_30)],
[(0, 0), (1 / sqrt(3), 0)])
a, b = graphene.sublattices
hoppings = (((0, 0), a, b), ((0, 1), a, b), ((-1, 1), a, b))
def aclead(w, onsite=0,t=-1):
sym = kwant.TranslationalSymmetry(graphene.vec((-1,2)))
def lead0_shape(pos):
x, y = pos
return 0<=y<w+0.6
lead = kwant.Builder(sym)
lead[graphene.shape(lead0_shape, (0, 0))] = onsite
lead[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = t
lead[b(0, 0), a(w, 1)] = t
return lead
def acsys(w, onsite=0,t=-1):
def box(pos):
x , y = pos
return -0.1<=x<1.2 and 0<=y<w+0.6
sys=kwant.Builder()
sys[graphene.shape(box, (0, 0))] = onsite
sys[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = t
sys[b(0, 0), a(w, 1)] = t
return sys
for w in range(4,7):
sys = acsys(w)
sys.attach_lead(aclead(w))
sys.attach_lead(aclead(w).reversed())
kwant.plot(sys)
lead = aclead(w).finalized()
kwant.plotter.bands(lead)