Dear all I am having a problem defining a system which matches leads I want. '''I start by defining a rectangular graphene lattice of size 0<=x<L in the x direction and 0<=x<W in the y direction. (By "rectangular" I mean in the real space coordinates, not the crystallographic coordinates.) I want to attach a lead to the left-had end of this rectangle, going to minus infinity. Therefore, I define a lead with translational symmetry (-1,0) and the appropriate hopping. I attach the lead and plot the system. When I plot the system, I find that the lead has been attached along the (0,1) crystallographic direction (so, that is along the (1/2, sqrt(3)/3) real space vector). A triangle of extra sites have been added for x<0 (real space) so that the total shape of the scattering region is now not rectangular.''' This is David's question.Link is https://mailman-mail5.webfaction.com/pipermail/kwant-discuss/2014-October/00.... and Anton had givern the answer:"We should use add_site_family" I use "add_site_family",but it didn't work. *In summary,I don't know how to use "add_site_family" exactly in kwant.Then I can't create armchair nonaribbon and four leads* *or six leads hall bar (The up and down leads are wrong.Left and right leads are right according to my code.The central scattering* * region is rectangle).Can you explain "add_site_family" in detail or * *give me a six leads hall bar code to compare with my code .I have spent a lot of time but I can't solve it.* This is my code 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() Thanks in advance. Bill Yang