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

Reply via email to