Dear Abbout, Josef and Nafiss, Good day. As it was stated by Mr. Abbout adel, it seems somehow tricky to do it. In my point of view this is because we are dealing with no orthogonal primitive vectors. I have fixed this issue by ussing orthogonal primitive vectors. However in this case, we have to use super-cell instead of a simple honeycomb lattice.
Please, In the script bellow we will find the code.In the comment, a little explanation of each part of the code is provided. Additionally, you might find the enclosed file which contains the python script of the code. On think to care about. In the sym = kwant.TranslationalSymmetry(Super_cell_latt.vec((-Num,0))), Num should be carefully chosen since it depends on the boundaries rectangle shape. Finally, If you need to have only two families in the plot. Simply use def family_colors(site): return 0 or give a color you like if site.family == Sub_A1 or Sub_A2 else 1 or give another color you like Finally, I hope this is useful for you. Here you are the script ############################################################################################# ### I think to solve the problem we need to creat supercell with orthogonal primitive vector import kwant import matplotlib.pyplot as plt from math import sqrt d = 1.42; hbar_square_over_m = 7.62 Ep = -11.07; Vpppi = -0.63*hbar_square_over_m*(1/d)*2 ## In the following, we will define a super cell of 4 atoms ## we define four atoms in the unit cell where A2 equivalent(==) to A1 and B2==B1. ## Bear in minde that this kind ofthinking is generally used in python as aliases ## In kwant i dont know how to use aliases but we will assume the A2 and A1 have the same on-site energy ## (or let us say the same familly). Also the the B2 and B1 have the same on-site energy ## So let us start a1 = d*sqrt(3); a2 = 3*d; primitive_vector_1 = (a1, 0); primitive_vector_2 = (0, a2); ### here premitive vectors are perpondicular: primitive_vector_1.primitive_vector_1 = 0 ## Now let us define the atoms positions of the unit cell Pos_A1 = ( 0, -d/2) Pos_B1 = ( 0, d/2) Pos_A2 = ( a1/2, d) Pos_B2 = ( a1/2, 2*d) Super_cell_latt = kwant.lattice.general([primitive_vector_1, primitive_vector_2], [Pos_A1, Pos_B1, Pos_A2, Pos_B2]) Sub_A1, Sub_B1, Sub_A2, Sub_B2 = Super_cell_latt.sublattices syst= kwant.Builder() #................................................................................... def rectangle(pos): x, y = pos z=x**2+y**2 return -4.75*a1<x<4.75*a1 and -8*d<y<8*d syst[Super_cell_latt.shape(rectangle, (1,1))]=Ep def delet(pos): x, y = pos z=x**2+y**2 return z<(1*a1)**2 del syst[Super_cell_latt.shape(delet, (1,1))] #nearest neighbors............................................................. ## Be carfull if you consider second nearest neighbors ## ========================================================= ## Hopping within unit cell ================================ syst[[kwant.builder.HoppingKind((0,0),Sub_A1,Sub_B1)]] = Vpppi syst[[kwant.builder.HoppingKind((0,0),Sub_B1,Sub_A2)]] = Vpppi syst[[kwant.builder.HoppingKind((0,0),Sub_A2,Sub_B2)]] = Vpppi ## Hopping between neighbouring unit cell======================= syst[[kwant.builder.HoppingKind((+1, +1),Sub_A1,Sub_B2)]] = Vpppi syst[[kwant.builder.HoppingKind(( 0, +1),Sub_A1,Sub_B2)]] = Vpppi syst[[kwant.builder.HoppingKind((+1, 0),Sub_B1,Sub_A2)]] = Vpppi # Plot the closed system without leads. kwant.plot(syst) Num = 8; sym = kwant.TranslationalSymmetry(Super_cell_latt.vec((-Num,0))) lead = kwant.Builder(sym) def lead_shape(pos): x, y = pos return -8*d<y<8*d lead[Super_cell_latt.shape(lead_shape, (1,1))] = Ep del lead[Super_cell_latt.shape(delet, (1,1))] ## ========================================================= ## Hopping within unit cell ================================ lead[[kwant.builder.HoppingKind((0,0),Sub_A1,Sub_B1)]] = Vpppi lead[[kwant.builder.HoppingKind((0,0),Sub_B1,Sub_A2)]] = Vpppi lead[[kwant.builder.HoppingKind((0,0),Sub_A2,Sub_B2)]] = Vpppi ## Hopping between neighbouring unit cell======================= lead[[kwant.builder.HoppingKind((+1, +1),Sub_A1,Sub_B2)]] = Vpppi lead[[kwant.builder.HoppingKind(( 0, +1),Sub_A1,Sub_B2)]] = Vpppi lead[[kwant.builder.HoppingKind((+1, 0),Sub_B1,Sub_A2)]] = Vpppi syst.attach_lead(lead,add_cells=3) syst.attach_lead(lead.reversed(),add_cells=3) # Plot the closed system without leads. kwant.plot(syst) plt.show() Best A. BELAYADI Le jeu. 10 oct. 2019 à 22:44, Abbout Adel <abbout.a...@gmail.com> a écrit : > Dear Nafise, > > You are right, this might be annoying when you try to construct a uniform > system (central+leads). Indeed, a lot of concentration is needed in some > cases because the lead usually adds some extra sites until it meats the > system. > There is an easy trick to overcome this small issue. > > 1) Create a system which can stop a lead (any shape for the system). > 2) Attach one lead: syst.attach_lead(lead,add_cells=0) > 3) Save the sites of the system: sites=list(syst.finalized().sites) > 4) Delete the lead: del syst.leads[0] > 5) Attach again the lead with one extra > cell: syst.attach_lead(lead,add_cells=1) > 6) Delete the previous sites of the system: del syst[sites] > > By doing this last step, all the previous sites are deleted and only one > full unit cell remains in the central system (the one added by the lead). > 7) the last step is : syst.attach_lead(lead.reversed(),add_cells=1) > > And that is it! > Your program is summarized below. > I hope this helps, > > Regards, > Adel > > > > ######################################################################################### > import kwant > import matplotlib.pyplot as plt > import math > > d=1.42; > a1=d*math.sqrt(3); > t=-0.033; > > latt = kwant.lattice.general([(a1,0),(a1*0.5,a1*math.sqrt(3)/2)], > [(a1/2,-d/2),(a1/2,d/2)]) > a,b = latt.sublattices > syst= kwant.Builder() > > > #................................................................................... > def rectangle(pos): > x, y = pos > z=x**2+y**2 > return -4.75*a1<x<4.75*a1 and -8*d<y<8*d > > syst[latt.shape(rectangle, (1,1))]=0 > > def delet(pos): > x, y = pos > z=x**2+y**2 > return z<(1*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 > > > sym = kwant.TranslationalSymmetry(latt.vec((-4,0))) > > sym.add_site_family(latt.sublattices[0], other_vectors=[(-1, 2)]) > sym.add_site_family(latt.sublattices[1], other_vectors=[(-1, 2)]) > lead = kwant.Builder(sym) > > > def lead_shape(pos): > x, y = pos > return -8*d<y<8*d > > lead[latt.shape(lead_shape, (1,1))] = 0 > > def delet_lead(pos): > x, y = pos > z=x**2+y**2 > return z<(1*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) > del syst.leads[0] > sites=list(syst.finalized().sites) > syst.attach_lead(lead,add_cells=1) > > del syst[sites] > #syst.attach_lead(lead.reversed(),add_cells=3) > syst.attach_lead(lead.reversed(),add_cells=1) > ax=kwant.plot(syst); > > > > > > > > > del syst[sites] > > On Thu, Oct 10, 2019 at 11:01 AM Nafise Nouri <nafise.n...@gmail.com> > wrote: > >> Dear Joseph Weston >> Thank you very much for your quick response. >> Of course, I can post you my cod example. It is in the following: >> >> import kwant >> import matplotlib.pyplot as plt >> import math >> >> d=1.42; >> a1=d*math.sqrt(3); >> t=-0.033; >> >> latt = kwant.lattice.general([(a1,0),(a1*0.5,a1*math.sqrt(3)/2)], >> [(a1/2,-d/2),(a1/2,d/2)]) >> a,b = latt.sublattices >> syst= kwant.Builder() >> >> >> #................................................................................... >> def rectangle(pos): >> x, y = pos >> z=x**2+y**2 >> return -4.75*a1<x<4.75*a1 and -8*d<y<8*d >> >> syst[latt.shape(rectangle, (1,1))]=0 >> >> def delet(pos): >> x, y = pos >> z=x**2+y**2 >> return z<(1*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 >> >> >> sym = kwant.TranslationalSymmetry(latt.vec((-4,0))) >> >> sym.add_site_family(latt.sublattices[0], other_vectors=[(-1, 2)]) >> sym.add_site_family(latt.sublattices[1], other_vectors=[(-1, 2)]) >> lead = kwant.Builder(sym) >> >> >> def lead_shape(pos): >> x, y = pos >> return -8*d<y<8*d >> >> lead[latt.shape(lead_shape, (1,1))] = 0 >> >> def delet_lead(pos): >> x, y = pos >> z=x**2+y**2 >> return z<(1*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=3) >> syst.attach_lead(lead.reversed(),add_cells=3) >> >> ax=kwant.plot(syst); >> >> Best wishes, >> Nafise >> >> Sorry for double email. The first email was not as reply. >> >> Best, >> Nafise >> >> >> On Tue, Oct 8, 2019 at 3:08 PM Nafise Nouri <nafise.n...@gmail.com> >> wrote: >> >>> Hi, >>> Of course. >>> I sent it to you and also to the mailing list, >>> >>> Best regards, >>> Nafise >>> >>> On Tue, Oct 8, 2019 at 11:31 AM Joseph Weston <joseph.westo...@gmail.com> >>> wrote: >>> >>>> Hi, >>>> >>>> Can you post this as a reply to your query in the mailing list? I >>>> accidentally replied directly to you when I should have CC'd the mailing >>>> list also. >>>> >>>> Thanks, >>>> >>>> Joe >>>> On 10/6/19 7:43 AM, Nafise Nouri wrote: >>>> >>>> Dear Joseph Weston >>>> Thank you very much for your quick response. >>>> Of course, I can post you my cod example. It is in the following: >>>> >>>> import kwant >>>> import matplotlib.pyplot as plt >>>> import math >>>> >>>> d=1.42; >>>> a1=d*math.sqrt(3); >>>> t=-0.033; >>>> >>>> latt = kwant.lattice.general([(a1,0),(a1*0.5,a1*math.sqrt(3)/2)], >>>> [(a1/2,-d/2),(a1/2,d/2)]) >>>> a,b = latt.sublattices >>>> syst= kwant.Builder() >>>> >>>> >>>> #................................................................................... >>>> def rectangle(pos): >>>> x, y = pos >>>> z=x**2+y**2 >>>> return -4.75*a1<x<4.75*a1 and -8*d<y<8*d >>>> >>>> syst[latt.shape(rectangle, (1,1))]=0 >>>> >>>> def delet(pos): >>>> x, y = pos >>>> z=x**2+y**2 >>>> return z<(1*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 >>>> >>>> >>>> sym = kwant.TranslationalSymmetry(latt.vec((-4,0))) >>>> >>>> sym.add_site_family(latt.sublattices[0], other_vectors=[(-1, 2)]) >>>> sym.add_site_family(latt.sublattices[1], other_vectors=[(-1, 2)]) >>>> lead = kwant.Builder(sym) >>>> >>>> >>>> def lead_shape(pos): >>>> x, y = pos >>>> return -8*d<y<8*d >>>> >>>> lead[latt.shape(lead_shape, (1,1))] = 0 >>>> >>>> def delet_lead(pos): >>>> x, y = pos >>>> z=x**2+y**2 >>>> return z<(1*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=3) >>>> syst.attach_lead(lead.reversed(),add_cells=3) >>>> >>>> ax=kwant.plot(syst); >>>> >>>> Best wishes, >>>> Nafise >>>> >>>> On Sat, Oct 5, 2019 at 12:57 PM Joseph Weston < >>>> joseph.westo...@gmail.com> wrote: >>>> >>>>> Hi Nafise >>>>> >>>>> >>>>> I need to make a periodic lattice with hole. In fact I should make holes >>>>> on the scattering region and also on the leads. Although I can make this >>>>> kind of lattice by kwant, I have problem about the distances between >>>>> holes. I want to make a periodic holes on the nanoribbon but the distance >>>>> between holes in the scattering region is different from the distance >>>>> between holes in the other regions. Would you please let me know How Can >>>>> I make a same distance between holes? Should I work on the translational >>>>> symmetry in the leads? >>>>> >>>>> >>>>> Because the leads need to be translationally invariant if you want a >>>>> very large distance between defects then your unit cell in the leads needs >>>>> to be correspondingly large. >>>>> >>>>> If you post a code example of what your problem is specifically we may >>>>> be able to help more. >>>>> >>>>> >>>>> Happy Kwanting, >>>>> >>>>> Joe >>>>> >>>>> >>>>> P.S. sorry for the double reply; I forgot to send to the mailing list >>>>> also >>>>> >>>>> > > -- > Abbout Adel >
### I think to solve the problem we need to creat supercell with orthogonal primitive vector import kwant import matplotlib.pyplot as plt from math import sqrt d = 1.42; hbar_square_over_m = 7.62 Ep = -11.07; Vpppi = -0.63*hbar_square_over_m*(1/d)*2 ## In the following, we will define a super cell of 4 atoms ## we define four atoms in the unit cell where A2 equivalent(==) to A1 and B2==B1. ## Bear in minde that this kind ofthinking is generally used in python as aliases ## In kwant i dont know how to use aliases but we will assume the A2 and A1 have the same on-site energy ## (or let us say the same familly). Also the the B2 and B1 have the same on-site energy ## So let us start a1 = d*sqrt(3); a2 = 3*d; primitive_vector_1 = (a1, 0); primitive_vector_2 = (0, a2); ### here premitive vectors are perpondicular: primitive_vector_1.primitive_vector_1 = 0 ## Now let us define the atoms positions of the unit cell Pos_A1 = ( 0, -d/2) Pos_B1 = ( 0, d/2) Pos_A2 = ( a1/2, d) Pos_B2 = ( a1/2, 2*d) Super_cell_latt = kwant.lattice.general([primitive_vector_1, primitive_vector_2], [Pos_A1, Pos_B1, Pos_A2, Pos_B2]) Sub_A1, Sub_B1, Sub_A2, Sub_B2 = Super_cell_latt.sublattices syst= kwant.Builder() #................................................................................... def rectangle(pos): x, y = pos z=x**2+y**2 return -4.75*a1<x<4.75*a1 and -8*d<y<8*d syst[Super_cell_latt.shape(rectangle, (1,1))]= Ep def delet(pos): x, y = pos z=x**2+y**2 return z<(1*a1)**2 del syst[Super_cell_latt.shape(delet, (1,1))] #nearest neighbors............................................................. ## Be carfull if you consider second nearest neighbors ## ========================================================= ## Hopping within unit cell ================================ syst[[kwant.builder.HoppingKind((0,0),Sub_A1,Sub_B1)]] = Vpppi syst[[kwant.builder.HoppingKind((0,0),Sub_B1,Sub_A2)]] = Vpppi syst[[kwant.builder.HoppingKind((0,0),Sub_A2,Sub_B2)]] = Vpppi ## Hopping between neighbouring unit cell======================= syst[[kwant.builder.HoppingKind((+1, +1),Sub_A1,Sub_B2)]] = Vpppi syst[[kwant.builder.HoppingKind(( 0, +1),Sub_A1,Sub_B2)]] = Vpppi syst[[kwant.builder.HoppingKind((+1, 0),Sub_B1,Sub_A2)]] = Vpppi # Plot the closed system without leads. kwant.plot(syst) Num = 8; sym = kwant.TranslationalSymmetry(Super_cell_latt.vec((-Num,0))) lead = kwant.Builder(sym) def lead_shape(pos): x, y = pos return -8*d<y<8*d lead[Super_cell_latt.shape(lead_shape, (1,1))] = Ep del lead[Super_cell_latt.shape(delet, (1,1))] ## ========================================================= ## Hopping within unit cell ================================ lead[[kwant.builder.HoppingKind((0,0),Sub_A1,Sub_B1)]] = Vpppi lead[[kwant.builder.HoppingKind((0,0),Sub_B1,Sub_A2)]] = Vpppi lead[[kwant.builder.HoppingKind((0,0),Sub_A2,Sub_B2)]] = Vpppi ## Hopping between neighbouring unit cell======================= lead[[kwant.builder.HoppingKind((+1, +1),Sub_A1,Sub_B2)]] = Vpppi lead[[kwant.builder.HoppingKind(( 0, +1),Sub_A1,Sub_B2)]] = Vpppi lead[[kwant.builder.HoppingKind((+1, 0),Sub_B1,Sub_A2)]] = Vpppi syst.attach_lead(lead,add_cells=3) syst.attach_lead(lead.reversed(),add_cells=3) # Plot the closed system without leads. kwant.plot(syst) plt.show()