How to attach a lead to a particular portion(upper side of the square) of the honeycomb structure.
sym1 = kwant.TranslationalSymmetry(lat.vec((0,1))) lead1 = kwant.Builder(sym1)
def lead2_shape(pos): x, y = pos return 0<x<10
lead1[lat.shape(lead2_shape, (2,0))]=3 lead1[lat.neighbors()] = -1
The first thing to note here is that lat.vec((0,1)) is the direction along one of the primitive vectors of the triangular lattice underlying the honeycomb lattice. In real space it’s tilted by 30 degrees towards the right from vertical.
Let’s assume that you want your lead to have this orientation. As always, when you use the ‘shape’ method to add sites to the lead, you are expected to provide a shape function that is consistent with the translational symmetry of the lead. I.e. the shape should also be tilted by 30 degrees.
You could solve your problem by providing an appropriate shape function.
Kwant actually does not check that the shape function respects the symmetry. (Doing so strictly is impossible, and a heuristic check would come with its own problems. Besides it can be sometimes useful to provide such “invalid” shapes.) It only evaluates the shape function *somewhere* - after all, since the shape has the same symmetry as the lead, it should not matter where! That somewhere is in the “fundamental domain” of the symmetry, which for ‘TranslationalSymmetry’ objects, is somewhere around the origin. In the case of your snippet, the sites are added at according to your shape function at real space y=0. Due to the 30 degree tilt, this no longer corresponds to the desired region towards the top of the scattering region.
Another solution to your problem would be to use a lead that is actually vertical. This is possible by declaring the symmetry as follows:
sym1 = kwant.TranslationalSymmetry(lat.vec((-1,2)))
With this change, the lead is vertical and is attached where you wanted. But note that the number of sites in the until cell of the lead has been doubled. This is due to geometry, there is nothing Kwant can do about it.
Did this clarify things?