Dear Shrushti,
The error you see is due to the edge_disorder function you have defined.
Surprisingly the function outputs that error while using *and/or argument* in
the function (x<X1 and 3<y<W-3). It works only if we *remove the
boolean *conditions
(and/or). At this point, *kwant developer might state why!.*

However, your problem might be solved by averting the boolean condition in
your onsite function.
I see that you have used so many conditions in the onsite function (which
might be written with fewer scripts) and your code is also hardly
organized.

The following propositions (two steps) have solved your issue with fewer
codes.
1-Fist you need to define the* pn-junction* and *disorder* by separate
functions
def *onsite_pn*(site):
    return -pot if site.pos[0]<X1 else +pot
def *onsite_disorder*(site,salt=8, w0=3):
    return 0 if -(W/2-w0)<site.pos[1]< (W/2-w0) else
 U0*(kwant.digest.uniform(repr(site), repr(salt))-0.5)+2
2-merge them in one onsite function called *onsite_PN_and_disorder* and
given as
def *onsite_PN_and_disorder*(site):
    return onsite_pn(site)+onsite_disorder(site,salt=8).

Final remark.* You said*
*I can include it, but I am not able to calculate the conductance/( in my
case valley transmission). *
I am surprised that the transmittance is given by kwant function
*smatrix.transmission(0,
1)* gives you the valley transmittance (as you said).
What I do know is that the valley transmittance is somehow more tricky than
you think.
Best, Adel

*Here is the corrected code:*

W=8
w0=2
t = 2.7                    # hopping parameters
pot=0.25                                 # Potential value in eV
                                                           # angle of wings
with x axis
X1=L/2
a_uc=0.246
U0=6
salt=8
#%%Functions
def shape(pos):
    x,y=pos
    rectangle= 0 <= x <= L and -W/2<= y <= W/2
    return  rectangle

# def onsite(site):
#     x, y = site.pos
#     if x<X1:
#         return -pot
#     if x>X1:
#         return pot


# def edge_disorder(site,salt=8):
#     x,y= site.pos
#     if x<X1 and 3<y<W-3:
#         return  - pot
#     if x>X1 and 3<y<W-3:
#         return  +pot
#     if  0<y<3 or W-3<y<W:
#         return U0 * (kwant.digest.uniform(repr(site), repr(salt))-0.5)+2
#     else :
#         return 0

def onsite_pn(site):
    return -pot if site.pos[0]<X1 else +pot
def onsite_disorder(site,salt=8, w0=w0):
    return 0 if -(W/2-w0)<site.pos[1]< (W/2-w0) else
 U0*(kwant.digest.uniform(repr(site), repr(salt))-0.5)+2
def onsite_PN_and_disorder(site):
    return onsite_pn(site)+onsite_disorder(site,salt=8)


def site_color(site):
    return onsite_scattering(site)


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))
    plt.figure()
    plt.plot(energies, data)
    plt.xlabel("energy [t]")
    plt.ylabel("conductance [e^2/h]")
    plt.show()

#------------------------------------------------------------------------------------------------------------------------------
#                             defining complete lattice structure and
plotting
#------------------------------------------------------------------------------------------------------------------------------

graphene = kwant.lattice.honeycomb(a=a_uc,norbs=1)
a, b = graphene.sublattices
syst = kwant.Builder()
syst[graphene.shape(shape, (0,0))] = onsite_PN_and_disorder
hoppings = (((0, 0), a, b), ((0, 1), a, b),((-1, 1), a, b))
syst[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = -t
syst.eradicate_dangling()
#
kwant.plot(syst, site_color=site_color)

# Left Lead
sym0 = kwant.TranslationalSymmetry(graphene.vec((-1, 0)))
def lead0_shape(pos):
    x,y=pos
    return (-W/2<y<W/2)

lead = kwant.Builder(sym0)
sym0.add_site_family(graphene.sublattices[0], other_vectors=[(-1, 2)])

sym0.add_site_family(graphene.sublattices[1], other_vectors=[(-1, 2)])
lead[graphene.shape(lead0_shape, (0, -0))] = 0.001
lead[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = -t
lead.eradicate_dangling()

syst.attach_lead(lead,add_cells=0)
syst.attach_lead(lead.reversed(),add_cells=0)


syst=syst.finalized()
params=dict(pot=pot,salt=8,U0=U0)
kwant.plot(syst)
plt.show()


#%%
n=10
energies= [0+ (0.091* i) for i in range(n)]
plot_conductance(syst, energies)
#%%-------------------------------------------------------------

Le ven. 23 juil. 2021 à 11:55, Shrushti Tapar <shrushti.tapa...@gmail.com>
a écrit :

> Thanks a lot for clarifying my doubts, just first I wanted to observed
> deformation and now I will be trying to incorporate hopping parametrization.
> Regards,
> Shrushti
>
> On Fri, Jul 23, 2021 at 3:32 PM Adel Belayadi <adelp...@gmail.com> wrote:
>
>> Dear Shrushti,
>>
>> From a tight binding point of view, once we have defined our lattice and
>> shape, we need to care  about the hopping and on-site energy, not the
>> positions. In your case and in order to parameterise the hopping in the
>> strained region you need to know the position transforms. In fact,
>> parameterizing the hopping is the most important task. In strained
>> graphene, parameterising the hopping is somehow similar to adding a
>> magnetic field in the system.
>>
>> *In your script you have written: syst=pos_transform((5,0),0.05,pi/2)*
>>
>> This is completely wrong and Kwant will not be able to recognize the
>> system. Since you are recently discovering Kwant, I recommend you to go
>> through Kwant FAQ: https://kwant-project.org/doc/dev/tutorial/faq
>>
>> Back to your issue, I guess you are caring to see the strained shape. In
>> this case, you need to use pos_transorm like:
>> *kwant.plot(syst, pos_transform=lambda pos:
>> pos_transform(pos,c=c,angle=angle), *
>>
>> Just one more thing, donot forget to uncommenthoppings = (((0, 0), a, b), 
>> ((0, 1), a, b), ((-1, 1), a, b))syst[[kwant.builder.HoppingKind(*hopping) 
>> for hopping in hoppings]] = totherwise you will not be able to see the 
>> strained position.
>>
>> Finally, you need to focus on using the correct hopping BestAdel
>>
>>
>>
>> Le jeu. 22 juil. 2021 à 09:48, Shrushti Tapar <shrushti.tapa...@gmail.com>
>> a écrit :
>>
>>> Dear Adel Belayadi,
>>> I am new to Kwant, as per our previous discussion, here I am attaching
>>> my program, I have defined my strain region and function for uniaxial
>>> strain in armchair direction. Now I struggling with *how to introduce
>>> this function* in the program.  Please correct me if I have understood
>>> it wrongly, Firstly we have to define graphene, by using the position of
>>> lattice points we have to apply pos_transform in a specified region, which
>>> will use the values of x and y co-ordinate from lattice placement due to
>>> lattice structure. The next doubt is like, as I using uniaxial strain in Y
>>> direction, it will squeeze lattice in X direction. So, the unstrained
>>> lattice point also has to shift accordingly. Right now I am only focusing
>>> on position displacement and not hopping.
>>> import numpy as np
>>> import scipy.io as spio
>>> from numpy import *
>>> import scipy.linalg as la
>>> import matplotlib as mpl
>>> import sympy as sym
>>> import kwant
>>>
>>> #%%######################
>>> # parameters
>>> L=20                            # Length of device on both sides
>>> W=5                            # Width of device
>>> t=-2.7
>>> pot=0.5
>>> c=0.05
>>> angle=pi/2
>>> # lattice type
>>> graphene = kwant.lattice.general([(1, 0), (sin(pi/6), cos(pi/6))],
>>>                                  [(0, 0), (0, 1 / sqrt(3))],
>>>                                  norbs=1)
>>> a, b = graphene.sublattices
>>> # scattering region
>>> def rectangle(pos):
>>>     x, y = pos
>>>     return 0 <= x <= L and 0<= y <= W
>>>
>>> # strain_pos
>>> def pos_transform(pos,c,angle):
>>>     x,y= pos
>>>     if 5<x<10:
>>>         ux=(cos(angle)**2-0.165*sin(angle)**2)*c*x
>>>         uy=(sin(angle)**2-0.165*cos(angle)**2)*c*y
>>>         return x+ux,y+uy
>>>     else:
>>>         return x,y
>>>
>>> syst = kwant.Builder()
>>> syst[graphene.shape(rectangle, (0, 0))] = 0
>>> syst=pos_transform((5,0),0.05,pi/2)
>>> #hoppings = (((0, 0), a, b), ((0, 1), a, b), ((-1, 1), a, b))
>>> #syst[[kwant.builder.HoppingKind(*hopping) for hopping in hoppings]] = t
>>> kwant.plot(syst);
>>>
>>> Thanks in advance.
>>> Regards,
>>> shrushti
>>>
>>> On Fri, Jul 16, 2021 at 2:38 AM Adel Belayadi <adelp...@gmail.com>
>>> wrote:
>>>
>>>> Dear Shrushti,
>>>> it is straightforward to deal with strained graphene.
>>>> In the region you want to make strain, just set the function which
>>>> modifies the site position (this mainly depends on the amount and type of
>>>> the strain). Second, once you have shifted the site position you need to
>>>> shift the hopping as illustrated in the file provided by Mr. Antonio.
>>>> here you find a simple script about how to shift the site position in
>>>> the case of uniaxial strain (adjusted to you case)
>>>>
>>>> def Triaxial_transform(pos, center, I):
>>>>     """ I is a parameter that lets us to control the intensity of the 
>>>> strain"""
>>>>     x, y = pos
>>>>     cx, cy = center[0], center[1] # the center of the strain
>>>>     r=sqrt((x-cx)**2+(y-cy)**2)
>>>>     if r<sigma:
>>>>         ux = 2*I * x*y
>>>>         uy = I * (x**2 - y**2)
>>>>         return x + ux, y + uy
>>>>     else:
>>>>         return x, y
>>>>
>>>> Then use this position to set your hopping as illustrated in a previous
>>>> discussion [Ref-1].
>>>>
>>>> You have to be careful in case you are using a strain in the z axis
>>>> since you will not be able to plot the current.  It is somehow tricky in
>>>> this scenario.
>>>>
>>>> [Ref-1]
>>>> https://www.mail-archive.com/kwant-discuss@kwant-project.org/msg00574.html
>>>>
>>>> I hop this will help
>>>> Best wishes
>>>>
>>>> Le jeu. 15 juil. 2021 à 14:19, <shrushti.tapa...@gmail.com> a écrit :
>>>>
>>>>> I want to create the graphene strained superlattice-like structure,
>>>>> having uniaxial strain defined at the specified region. Please, someone 
>>>>> can
>>>>> suggest to me how to define the strained region and interface between
>>>>> unstrained and strained graphene regions.
>>>>> Thanks in Advance
>>>>> Shrushti
>>>>>
>>>>

Reply via email to