*Dear Nafise,* As the first part was explained by Mr. About. I would like to give you some illustrations and explanations about getting armchair and zigzag ribbons.
It is quite easy, only you have to care about translation symmetry. See the explanations in the comments'part of the code. or see the enclosed python scripts *### =====================Armchair=================* *import kwant* *from numpy import sqrt* *graphene = kwant.lattice.general([[1, 0], [1/2, sqrt(3)/2]], # lattice vectors* *[[0, 0], [0, 1/sqrt(3)]]) # Coordinates of the sites* *a, b = graphene.sublattices* *## To get armchair ribbons we need to make translation True along y direction* *## Be carfull, using graphene.vec((0, Num)), instead of simply [0, Num] provide some incovenience.* *## we can bet rid of this by avoiding dangling* *###============= A comparaison between translation symmetry graphene.vec((0, Num)) vs [0, Num] * *## ------------------ METHODE 1----------------* *## using graphene.vec((0, 1)) as True* *from math import sqrt* *Num1 = 4* *armchair_ribbon = kwant.Builder(kwant.TranslationalSymmetry(graphene.vec((0, Num1))))* *armchair_ribbon[graphene.shape((lambda pos: abs(pos[0]) < 3), (0, 0))] = 0* *armchair_ribbon[graphene.neighbors(1)] = 1* *kwant.plot(armchair_ribbon)* *kwant.plotter.bands(armchair_ribbon.finalized(), fig_size=(12, 8));* *## ------------------ METHODE 2----------------------* *## using [0, Num] as True* *Num2 = 2*sqrt(3)* *armchair_ribbon = kwant.Builder(kwant.TranslationalSymmetry([0, Num2]))* *armchair_ribbon[graphene.shape((lambda pos: abs(pos[0]) < 3), (0, 0))] = 0* *armchair_ribbon[graphene.neighbors(1)] = 1* *kwant.plot(armchair_ribbon)* *kwant.plotter.bands(armchair_ribbon.finalized(), fig_size=(12, 8));* *### I beleive using second method is better. Set Num according to your structure (or need)* *## be careful graphene.vec((0, 1)) is not the same as * *### to see the difference see* *print(graphene.vec((0, Num1))[0]==[0, Num2])* *print(graphene.vec((0, Num1))[1]== Num2)* *print(graphene.vec((0, Num1))[0]== 0)* *### =====================zigzag=================* import kwant from numpy import sqrt graphene = kwant.lattice.general([[1, 0], [1/2, sqrt(3)/2]], # lattice vectors [[0, 0], [0, 1/sqrt(3)]]) # Coordinates of the sites a, b = graphene.sublattices ## To get zigzag ribbons we need to make translation True along x direction ## we put here simply [Num, 0]. In this case by chance: graphene.vec((1, 0)) //(parallel to) Num* [1, 0] ## so be careful in the next case(armchair) Num = 1 zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([Num, 0])) zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1] ) < 4), (0, 0))] = 0 zigzag_ribbon[graphene.neighbors(1)] = 1 kwant.plot(zigzag_ribbon) kwant.plotter.bands(zigzag_ribbon.finalized()); Num = 2 zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([Num, 0])) zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1] ) < 4), (0, 0))] = 0 zigzag_ribbon[graphene.neighbors(1)] = 1 kwant.plot(zigzag_ribbon) kwant.plotter.bands(zigzag_ribbon.finalized()); Num = 4 zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([Num, 0])) zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1] ) < 4), (0, 0))] = 0 zigzag_ribbon[graphene.neighbors(1)] = 1 kwant.plot(zigzag_ribbon) kwant.plotter.bands(zigzag_ribbon.finalized()); ### Set Num according to your structure (or need) Le jeu. 31 oct. 2019 à 09:23, Nafise Nouri <nafise.n...@gmail.com> a écrit : > Dear all, > Now I am trying to understand kwant specially for hexagonal structure. > > If you look at my code as 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); > > I used > sym.add_site_family(latt.sublattices[0], other_vectors=[(2,1)]) > sym.add_site_family(latt.sublattices[1], other_vectors=[(2,1)]) > but I do not exactly why I used these vectors. These vectors are for > zigzag nanoribbon, can we use them for armchair nanoribbon? > Do you know any information about an armchair nanoribbon? > > Best, > Nafise > > On Thu, Oct 31, 2019 at 1:08 AM Adel Belayadi <adelp...@gmail.com> wrote: > >> Hey naffisse. >> Sure!. I have prepared a detailed explanation with codes as illustrations. >> Please ask the question publicly (I mean add kwant.discuss) and I will >> answer you so maybe others will benefit and my efforts would be fruitful >> for others. >> Waiting you question again >> Regards >> >> Le mar. 22 oct. 2019 à 14:03, Nafise Nouri <nafise.n...@gmail.com> a >> écrit : >> >>> Hi Adel, >>> >>> Of course, maybe in future we can have a good collaboration. Now I am >>> trying to understand kwant specially for hexagonal structure. >>> >>> If you look at my code in the proviso emails, I used >>> sym.add_site_family(latt.sublattices[0], other_vectors=[(2,1)]) >>> sym.add_site_family(latt.sublattices[1], other_vectors=[(2,1)]) >>> but I do not exactly why I used these vectors. These vectors are for >>> zigzag nanoribbon, can we use them for armchair nanoribbon? >>> Do you know any information about an armchair nanoribbon? >>> >>> Best, >>> Nafise >>> >>> On Mon, Oct 21, 2019 at 10:17 PM Adel Belayadi <adelp...@gmail.com> >>> wrote: >>> >>>> Hello Nafise >>>> Sorry for my late reply.Yes, that is correct. >>>> About the result, my be because of the tight-binding parameters, or due >>>> to the masse terme (inversion symmetry) or other things such as SOC. >>>> I connot help from now thing. maybe if you email the paper would be >>>> better. >>>> If you are interested in collaboration, I am willing to work and >>>> collaborate. >>>> Best regards, Adel >>>> >>>> Le mer. 16 oct. 2019 à 09:42, Nafise Nouri <nafise.n...@gmail.com> a >>>> écrit : >>>> >>>>> Dear Adel Belayadi >>>>> >>>>> That is very kind of you for your explanation. >>>>> As I understand that the definition of limitation of scattering >>>>> region in direction of x (the direction that we exert periodic border >>>>> condition, here is x direction) is not important because the number of >>>>> symmetry vector defines the limitation of x direction in the scattering >>>>> region. Am I right? >>>>> >>>>> I am trying to reproduce of the result of a article for graphene >>>>> nanoribbon with hole, the shape of structure in kwant is OK,but the band >>>>> structure is not the same as article's. I do not know where is the >>>>> problem. >>>>> >>>>> Best, >>>>> Nafise >>>>> >>>>> On Fri, Oct 11, 2019 at 11:22 PM Adel Belayadi <adelp...@gmail.com> >>>>> wrote: >>>>> >>>>>> Hey again, >>>>>> >>>>>> I am so glad that my contribution was beneficial to you. >>>>>> >>>>>> *1- * *Why did you choose a new super cell. What is a problem when >>>>>> we use honeycomb unit cell?* >>>>>> >>>>>> In fat, it is the same thing since we have (i) a finite system and >>>>>> (ii) the obtained system has the honeycomb shape >>>>>> >>>>>> whether using honeycomb lattice or the provides supercell. >>>>>> >>>>>> In fact, the supercell where created carefully to provide the same >>>>>> shape of honeycomb lattice. >>>>>> >>>>>> However, if the case of a periodic system, the use of supercell will >>>>>> be wrong since the number of atom in the unit cell is a key factor. >>>>>> >>>>>> *2-If we change symmetry vector (for **example try it by simple >>>>>> graphene nanoribbon) some physical properties like* >>>>>> >>>>>> * band structure IS changed? why does it happen?* >>>>>> >>>>>> I have small experience in kwant since I am a new user, but >>>>>> technically let us say: >>>>>> >>>>>> (a) The lead is considered as an infinite system, so the number of >>>>>> atom in the unit cell should be carefully selected or we will get extra >>>>>> usefulness >>>>>> >>>>>> modes in bands. For example, In the case of perfect lead, we do have >>>>>> to set sym = >>>>>> kwant.TranslationalSymmetry(Super_cell_latt.vec((Num=-1,0))) >>>>>> >>>>>> since for Num =1 is the primitive unit cell which provide the whole >>>>>> lead. However, If we set (Num=-2 or more), we will get the same lead >>>>>> >>>>>> but with non primitive cell (or let's say Conventional lattice). In >>>>>> this case, you will get extract evanescent and propagating modes >>>>>> which are unnecessary. >>>>>> >>>>>> >>>>>> (b) in your case the lead is not perfect since it contains some holes >>>>>> in. For this reason you have to define Conventional lattice or shape >>>>>> which >>>>>> provide >>>>>> >>>>>> or insure periodicity to get the whole lead. >>>>>> >>>>>> >>>>>> Please see attached Pdf.file to have an idea about primitive cell and >>>>>> conventional cell (see the fcc case). >>>>>> >>>>>> >>>>>> Ps1 few examples of bands using primitive and conventional unit cell >>>>>> >>>>>> >>>>>> ### Primitive unit cell where Num is set to -1. Here 6 bands are found >>>>>> >>>>>> 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 lead_shape(pos): >>>>>> >>>>>> return -3<pos[1]<3 >>>>>> >>>>>> Num = -1 >>>>>> >>>>>> sym = kwant.TranslationalSymmetry(latt.vec((Num,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) >>>>>> >>>>>> >>>>>> lead[latt.shape(lead_shape, (1,1))] = 0 >>>>>> >>>>>> 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 >>>>>> >>>>>> kwant.plot(lead) >>>>>> >>>>>> plt.show() >>>>>> >>>>>> >>>>>> ## The unit cell of the lead is composed of 6 atoms, hence 6 bands >>>>>> could be find >>>>>> >>>>>> lead_Num1 = lead.finalized() >>>>>> >>>>>> kwant.plotter.bands(lead_Num1, show=False) >>>>>> >>>>>> plt.xlabel("momentum [(lattice constant)^-1]") >>>>>> >>>>>> plt.ylabel("energy [t]") >>>>>> >>>>>> plt.show() >>>>>> >>>>>> >>>>>> >>>>>> ## the conventional unit cell where Num is set to -2. Here 6*2=12 >>>>>> bands are found. We have 6 extrat bands which have nothing >>>>>> >>>>>> ##to do in the case of a perfect lead >>>>>> >>>>>> 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 lead_shape(pos): >>>>>> >>>>>> return -3<pos[1]<3 >>>>>> >>>>>> Num = -2 >>>>>> >>>>>> sym = kwant.TranslationalSymmetry(latt.vec((Num,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) >>>>>> >>>>>> >>>>>> lead[latt.shape(lead_shape, (1,1))] = 0 >>>>>> >>>>>> 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 >>>>>> >>>>>> kwant.plot(lead) >>>>>> >>>>>> plt.show() >>>>>> >>>>>> >>>>>> ## The unit cell of the lead is composed of 6*2 atoms, hence 6 bands >>>>>> could be find >>>>>> >>>>>> lead_Num1 = lead.finalized() >>>>>> >>>>>> kwant.plotter.bands(lead_Num1, show=False) >>>>>> >>>>>> plt.xlabel("momentum [(lattice constant)^-1]") >>>>>> >>>>>> plt.ylabel("energy [t]") >>>>>> >>>>>> plt.show() >>>>>> >>>>>> >>>>>> >>>>>> Ps2 few examples of bands using honycomb or supper celll >>>>>> >>>>>> >>>>>> ##In the following we will compare the your honycombe lattice Num =-1 >>>>>> and the proposed supper cell. >>>>>> >>>>>> ##You will see that we will get the same results in terms of bands >>>>>> >>>>>> >>>>>> import kwant >>>>>> >>>>>> import matplotlib.pyplot as plt >>>>>> >>>>>> from math import sqrt >>>>>> >>>>>> >>>>>> d = 1.42; >>>>>> >>>>>> t=-0.033; >>>>>> >>>>>> ## 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() >>>>>> >>>>>> Num = -1; >>>>>> >>>>>> sym = kwant.TranslationalSymmetry(Super_cell_latt.vec((Num,0))) >>>>>> >>>>>> lead = kwant.Builder(sym) >>>>>> >>>>>> >>>>>> def lead_shape(pos): >>>>>> >>>>>> return -3<pos[1]<3 >>>>>> >>>>>> >>>>>> lead[Super_cell_latt.shape(lead_shape, (1,1))] = 0 >>>>>> >>>>>> >>>>>> >>>>>> ## ========================================================= >>>>>> >>>>>> ## Hopping within unit cell ================================ >>>>>> >>>>>> lead[[kwant.builder.HoppingKind((0,0),Sub_A1,Sub_B1)]] = t >>>>>> >>>>>> lead[[kwant.builder.HoppingKind((0,0),Sub_B1,Sub_A2)]] = t >>>>>> >>>>>> lead[[kwant.builder.HoppingKind((0,0),Sub_A2,Sub_B2)]] = t >>>>>> >>>>>> ## Hopping between neighbouring unit cell======================= >>>>>> >>>>>> lead[[kwant.builder.HoppingKind((+1, +1),Sub_A1,Sub_B2)]] = t >>>>>> >>>>>> lead[[kwant.builder.HoppingKind(( 0, +1),Sub_A1,Sub_B2)]] = t >>>>>> >>>>>> lead[[kwant.builder.HoppingKind((+1, 0),Sub_B1,Sub_A2)]] = t >>>>>> >>>>>> >>>>>> kwant.plot(lead) >>>>>> >>>>>> plt.show() >>>>>> >>>>>> >>>>>> ## The unit cell of the lead is composed of 6 atoms, hence 6 bands >>>>>> could be find >>>>>> >>>>>> lead_Num1 = lead.finalized() >>>>>> >>>>>> kwant.plotter.bands(lead_Num1, show=False) >>>>>> >>>>>> plt.xlabel("momentum [(lattice constant)^-1]") >>>>>> >>>>>> plt.ylabel("energy [t]") >>>>>> >>>>>> plt.show() >>>>>> >>>>>> Le ven. 11 oct. 2019 à 09:24, Nafise Nouri <nafise.n...@gmail.com> a >>>>>> écrit : >>>>>> >>>>>>> Dear Adel Belayadi >>>>>>> Thank you so much for your benefit response. But I did not >>>>>>> understand completely. Why did you choose a new super cell? What is a >>>>>>> problem when we use honeycomb unit cell? >>>>>>> >>>>>>> Also I have one more question, That is very kind of you if you help >>>>>>> m: >>>>>>> * If we change symmetry vector (for **example** try it by simple >>>>>>> graphene nanoribbon) some physical properties like band structure IS >>>>>>> changed? why does it happen?* >>>>>>> * Do you know what is the concept of symmetry vector in kwant?* >>>>>>> >>>>>>> *Thank you in advance for your help.* >>>>>>> >>>>>>> *Best wishes,* >>>>>>> *Nafise* >>>>>>> >>>>>>> On Fri, Oct 11, 2019 at 3:56 AM Adel Belayadi <adelp...@gmail.com> >>>>>>> wrote: >>>>>>> >>>>>>>> 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 >>>>>>>>> >>>>>>>>
import kwant from numpy import sqrt graphene = kwant.lattice.general([[1, 0], [1/2, sqrt(3)/2]], # lattice vectors [[0, 0], [0, 1/sqrt(3)]]) # Coordinates of the sites a, b = graphene.sublattices ## To get armchair ribbons we need to make translation True along y direction ## Be carfull, using graphene.vec((0, Num)), instead of simply [0, Num] provide some incovenience. ## we can bet rid of this by avoiding dangling ###============= A comparaison between translation symmetry graphene.vec((0, Num)) vs [0, Num] ## ------------------ METHODE 1---------------- ## using graphene.vec((0, 1)) as True from math import sqrt Num1 = 4 armchair_ribbon = kwant.Builder(kwant.TranslationalSymmetry(graphene.vec((0, Num1)))) armchair_ribbon[graphene.shape((lambda pos: abs(pos[0]) < 3), (0, 0))] = 0 armchair_ribbon[graphene.neighbors(1)] = 1 kwant.plot(armchair_ribbon) kwant.plotter.bands(armchair_ribbon.finalized(), fig_size=(12, 8)); ## ------------------ METHODE 2---------------------- ## using [0, Num] as True Num2 = 2*sqrt(3) armchair_ribbon = kwant.Builder(kwant.TranslationalSymmetry([0, Num2])) armchair_ribbon[graphene.shape((lambda pos: abs(pos[0]) < 3), (0, 0))] = 0 armchair_ribbon[graphene.neighbors(1)] = 1 kwant.plot(armchair_ribbon) kwant.plotter.bands(armchair_ribbon.finalized(), fig_size=(12, 8)); ### I beleive using second method is better. Set Num according to your structure (or need) ## be careful graphene.vec((0, 1)) is not the same as ### to see the difference see print(graphene.vec((0, Num1))[0]==[0, Num2]) print(graphene.vec((0, Num1))[1]== Num2) print(graphene.vec((0, Num1))[0]== 0)
import kwant from numpy import sqrt graphene = kwant.lattice.general([[1, 0], [1/2, sqrt(3)/2]], # lattice vectors [[0, 0], [0, 1/sqrt(3)]]) # Coordinates of the sites a, b = graphene.sublattices ## To get zigzag ribbons we need to make translation True along x direction ## we put here simply [Num, 0]. In this case by chance: graphene.vec((1, 0)) //(parallel to) Num* [1, 0] ## so be careful in the next case(armchair) Num = 1 zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([Num, 0])) zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1] ) < 4), (0, 0))] = 0 zigzag_ribbon[graphene.neighbors(1)] = 1 kwant.plot(zigzag_ribbon) kwant.plotter.bands(zigzag_ribbon.finalized()); Num = 2 zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([Num, 0])) zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1] ) < 4), (0, 0))] = 0 zigzag_ribbon[graphene.neighbors(1)] = 1 kwant.plot(zigzag_ribbon) kwant.plotter.bands(zigzag_ribbon.finalized()); Num = 4 zigzag_ribbon = kwant.Builder(kwant.TranslationalSymmetry([Num, 0])) zigzag_ribbon[graphene.shape((lambda pos: abs(pos[1] ) < 4), (0, 0))] = 0 zigzag_ribbon[graphene.neighbors(1)] = 1 kwant.plot(zigzag_ribbon) kwant.plotter.bands(zigzag_ribbon.finalized()); ### Set Num according to your structure (or need)