Dear Gabriel,
You have a "Dimensionality mismatch": Use the same dimension for the two
lattices.
If you are still using two different lattices, then go and check the FAQ
[1] where you have a nice example about combining graphene with a square
lattice.

I hope this helps,
Adel

[1] https://kwant-project.org/doc/1/tutorial/faq

On Tue, Jun 6, 2023 at 5:55 PM Gabriel Garcia <gqgarci...@gmail.com> wrote:

> Hi devs,
>
> I am learning kwant alone, but i have doubts. I am trying to construct a
> system with a diatomic chain as scattering region and the leads as a
> monoatomic chain. But i am doing something wrong. Someone else can help me?
> Bellow i will show the code:
>
>
> #####################################################################################################################
> from matplotlib import pyplot as plt
> from matplotlib import backends
> import kwant
>
> # Defining the parameters
> L = 5 # range of scattering region
> C = 2 # primitive vector
> # Definindo o parametro de Hopping
>
> t = 5 # hopping parameter
>
> lat = kwant.lattice.general([(C,0),(0,1)],[(0,0),(1,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), b, a)] = -t
>
> kwant.plot(syst)
> plt.show()
>
> # leaft lead (lead 1)
> lat_lead1 = kwant.lattice.chain(C, norbs=1)
> sym_lead1 = kwant.TranslationalSymmetry((-C, 0))
>
> lead1 = kwant.Builder(sym_lead1)
>
> lead1[lat_lead(0,0)] = 4*t
> lead1[lat_lead1.neighbors()] = -t
>
> syst[(lat_lead1(-C, 0), a(0, 0))] = -t
>
> syst.attach_lead(lead1)
>
> kwant.plot(syst)
>
> ---------------------------------------------------------------------------
> ValueError                                Traceback (most recent call last)
> ~\anaconda3\lib\site-packages\kwant\builder.py in __new__(cls, family,
> tag, _i_know_what_i_do)
>      75         try:
> ---> 76             tag = family.normalize_tag(tag)
>      77         except (TypeError, ValueError) as e:
>
> ~\anaconda3\lib\site-packages\kwant\lattice.py in normalize_tag(self, tag)
>     475         if len(tag) != self.lattice_dim:
> --> 476             raise ValueError("Dimensionality mismatch.")
>     477         return tag
>
> ValueError: Dimensionality mismatch.
>
> During handling of the above exception, another exception occurred:
>
> ValueError                                Traceback (most recent call last)
> <ipython-input-46-3d36b05d2870> in <module>
>       8 lead1[lat_lead1.neighbors()] = -t
>       9
> ---> 10 syst[(lat_lead1(-C, 0), a(0, 0))] = -t
>      11
>      12 syst.attach_lead(lead1)
>
> ~\anaconda3\lib\site-packages\kwant\builder.py in __call__(self, *tag)
>     195             raise ValueError('Use site_family(1, 2) instead of '
>     196                              'site_family((1, 2))!')
> --> 197         return Site(self, tag)
>     198
>     199
>
> ~\anaconda3\lib\site-packages\kwant\builder.py in __new__(cls, family,
> tag, _i_know_what_i_do)
>      77         except (TypeError, ValueError) as e:
>      78             msg = 'Tag {0} is not allowed for site family {1}: {2}'
> ---> 79             raise type(e)(msg.format(repr(tag), repr(family),
> e.args[0]))
>      80         return tuple.__new__(cls, (family, tag))
>      81
>
> ValueError: Tag (-2, 0) is not allowed for site family
> kwant.lattice.Monatomic([[2.0]], [0.0], '', 1): Dimensionality mismatch.
>
>
> #############################################################################################
> Thanks!
> Gabriel Garcia
>


-- 
Abbout Adel

Reply via email to