Dear Gabriel,

Try this:


from matplotlib import pyplot as plt
from matplotlib import backends
import kwant


t = 1 # hopping parameter
L=5
lat = kwant.lattice.general([(1,0),(0,1)],[(0,0),(.5,0)], norbs=1)
a, b = lat.sublattices

syst = kwant.Builder()

# Scattering region
for i in range(L):
    syst[a(i, 0)] = 0
    syst[b(i, 0)] = 0

syst[kwant.builder.HoppingKind((0, 0), a, b)] = -t
syst[kwant.builder.HoppingKind((1, 0), a, b)] = -t


#syst[lat.neighbors()]=-t
kwant.plot(syst)
plt.show()

# leaft lead (lead 1)



lat_lead1 = kwant.lattice.general([(1,0),(0,1)],[(0,0)], norbs=1).sublattices[0]
sym_lead1 = kwant.TranslationalSymmetry((-1, 0))


syst[lat_lead1(-1,0)] = 0
syst[lat_lead1(-1,0),lat_lead1(0,0)] = -t

syst[lat_lead1(5,0)] = 0
syst[lat_lead1(5,0),b(4,0)] = -t

lead1 = kwant.Builder(sym_lead1)

lead1[lat_lead1(0,0)] = 0
lead1[lat_lead1.neighbors()] = -t



syst.attach_lead(lead1)
syst.attach_lead(lead1.reversed())
kwant.plot(syst)


# In[77]:


import numpy as np
sysf=syst.finalized()


# In[78]:


Trans=[]
energies=np.linspace(-1.99,1.99,100)
for energy in energies:
    SM=kwant.smatrix(sysf,energy)
    T=SM.transmission(0,1)
    Trans.append(T)


# In[79]:


from matplotlib import pyplot
pyplot.plot(energies,Trans)
pyplot.show()



Regards,

On Wed, Jun 7, 2023 at 10:41 PM Gabriel Garcia <gqgarcia99@gmail.com> wrote:
Dear Adel,

Thanks for answering me. I saw the FAQ and I try to reproduce for my case, but unfortunately didn't work. I changed the lead command:

# Lead a direita (lead 1)
lat_lead1 = kwant.lattice.square(C)
sym_lead1 = kwant.TranslationalSymmetry((-C, 0))

lead1 = kwant.Builder(sym_lead1)

lead1[(lat_lead1(0, 0))] = 0
lead1[lat_lead1(0,0), lat_lead1(1,0)] = -t

syst[(a(0,0), lat_lead1(-1,0))] = -1

syst.attach_lead(lead1)

kwant.plot(syst)
plt.show()

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-8-df1e018f6b56> in <module>
      8 lead1[lat_lead1(0,0), lat_lead1(1,0)] = -t
      9
---> 10 syst[(a(0,0), lat_lead1(-1,0))] = -1
     11
     12 syst.attach_lead(lead1)

~\anaconda3\lib\site-packages\kwant\builder.py in __setitem__(self, key, value)
   1160                 func = (self._set_site if isinstance(sh, Site)
   1161                         else self._set_hopping)
-> 1162             func(sh, value)
   1163
   1164     def _del_site(self, site):

~\anaconda3\lib\site-packages\kwant\builder.py in _set_hopping(self, hopping, value)
   1136             # of identical sites.
   1137             a2 = a = self.H[a][0]
-> 1138             b2 = b = self.H[b][0]
   1139         else:
   1140             b2, a2 = sym.to_fd(b, a)

KeyError: Site(kwant.lattice.Monatomic([[2.0, 0.0], [0.0, 2.0]], [0.0, 0.0], '', None), array([-1, 0]))

If anyone can help me, i appreciate. Thaks.

Gabriel Garcia


--
Abbout Adel