Dear nafise, Good day, it seem that you have problem with symmetry. To some up you have to fix the following issues: 1. define the lattice.general correctly 2. provide larger limit along x for the rectangle, so we might avoid isolated atoms(unconnected) 3. chose the symmetry as Num = 8*(a1*sqrt(3)/2) and then use sym = kwant.TranslationalSymmetry([0, Num]) 4. shift the origin of y direction in your delet function by (y-a1*sqrt(3))**2 intead of y**2 5. the boundary in lead_shape is for x not y. If we use y the code will bug (infinity system) Please, you have one thing left to do. kindly make sure that the lead is 100% armchair, perhaps Mrs Josefe or About would be for a help. I have plotted the bands for the lead, it seems armchair but I still do not muster 100% the source code of kwant.plotter.bands. Please check this pont. See the code with explanation Happy kwanting
Best Adel import kwant from math import sqrt import matplotlib.pyplot as plt import tinyarray import numpy as np import math import cmath #import scipy.linalg as la import matplotlib d=1.42; a1=d*sqrt(3); #on-site energy................................................... t=-2.7; latt = kwant.lattice.general([[a1, 0], [a1/2, a1*sqrt(3)/2]], # lattice vectors [[0, 0], [0, a1/sqrt(3)]]) # Coordinates of the sites a, b = latt.sublattices syst= kwant.Builder() ## you have to provide quite big boundaries to avoid isolated atoms so abs(x)=4*a1 def rectangle(pos): x, y = pos z=x**2+y**2 return -4*a1<x<4*a1 and -6*d<y<7*d syst[latt.shape(rectangle,(1,1))]=0 ## you have to shift the origine of your diffect by a1*sqrt(3) def delet(pos, shift = a1*sqrt(3)): x, y = pos z=x**2+(y-shift)**2 return z<(2*a1)**2 del syst[latt.shape(delet, (1,1))] #nearestneighbors............................................................. syst[[kwant.builder.HoppingKind((0,0),a,b)]]=t syst[[kwant.builder.HoppingKind((0,1),a,b)]]=t syst[[kwant.builder.HoppingKind((-1,1),a,b)]]=t ## using [0, Num] as True Num = 8*(a1*sqrt(3)/2) sym = kwant.TranslationalSymmetry([0, Num]) lead = kwant.Builder(sym) ##the lead shape must be lilited in x not y def lead_shape(pos): x, y = pos return -4*a1<x<4*a1 lead[latt.shape(lead_shape, (0,0))]=0 ##or use the folowing lambda form ##lead[latt.shape((lambda pos: abs(pos[0]) < 4*a1 ), (0, 0))] = 0 def delet_lead(pos, shift = +a1*sqrt(3)): x, y = pos z=x**2+(y-shift)**2 return z<(2*a1)**2 del lead[latt.shape(delet_lead, (1,1))] lead[[kwant.builder.HoppingKind((0,0),a,b)]]=t lead[[kwant.builder.HoppingKind((0,1),a,b)]]=t lead[[kwant.builder.HoppingKind((-1,1),a,b)]]=t syst.attach_lead(lead,add_cells=0) kwant.plot(syst); syst.attach_lead(lead.reversed(),add_cells=0) kwant.plot(syst); ### for armchair -pi/3*d<ky<pi/3*d from numpy import pi, linspace momenta = list(linspace(-pi/3, pi/3, 50)) kwant.plotter.bands(lead.finalized(), momenta); Le dim. 3 nov. 2019 à 10:55, Nafise Nouri <nafise.n...@gmail.com> a écrit : > Dear Joseph > > At first thank you for kwant team. My problem for zigzag nanoribbon with > defect (hole) was solved with your help. Now I have a bit problem with > armchair nanoribbon. I have changed zigzag nanoribbon according to making > the armchair nanoribbon. It is OK when we have no defect on the system but > when I try to make hole on the scattering region and leads I have a > problem. The shape of holes on the scattering region and leads are not > same. My code is as the following. That is very king of you if you help me > where is the problem. > > Thanks In advance for your help. > > Beat wishes, > Nafise > > import kwant > from math import sqrt > import matplotlib.pyplot as plt > import tinyarray > import numpy as np > import math > import cmath > #import scipy.linalg as la > import matplotlib > d=1.42; > a1=d*math.sqrt(3); > > #on-site energy................................................... > t=-2.7; > > latt = kwant.lattice.general([(0,a1),(a1*math.sqrt(3)/2,a1*0.5)], > [(-d/2,a1/2),(d/2,a1/2)]) > a,b = latt.sublattices > syst= kwant.Builder() > > def rectangle(pos): > x, y = pos > z=x**2+y**2 > return -2.4*a1<x<2.4*a1 and -5*d<y<5*d > > syst[latt.shape(rectangle,(1,1))]=0 > > def delet(pos): > x, y = pos > z=x**2+y**2 > return z<(2*a1)**2 > > del syst[latt.shape(delet, (1,1))] > > #nearest > neighbors............................................................. > syst[[kwant.builder.HoppingKind((0,0),a,b)]] =t > syst[[kwant.builder.HoppingKind((0,1),a,b)]] =t > syst[[kwant.builder.HoppingKind((-1,1),a,b)]] =t > > ax=kwant.plot(syst); > > sym = kwant.TranslationalSymmetry(latt.vec((-2,4))) > > lead = kwant.Builder(sym) > > def lead_shape(pos): > x, y = pos > return -5*d<y<5*d > > lead[latt.shape(lead_shape, (1,1))]=0 > > def delet_lead(pos): > x, y = pos > z=x**2+y**2 > return z<(2*a1)**2 > > del lead[latt.shape(delet_lead, (1,1))] > > lead[[kwant.builder.HoppingKind((0,0),a,b)]]=t > lead[[kwant.builder.HoppingKind((0,1),a,b)]]=t > lead[[kwant.builder.HoppingKind((-1,1),a,b)]]=t > > syst.attach_lead(lead,add_cells=0) > syst.attach_lead(lead.reversed(),add_cells=0) > ax=kwant.plot(syst); >