Dear Gabriel,

Could you provide the part of the code that reproduces this error?

Adel

On Tue, Oct 17, 2023 at 2:49 AM Gabriel Garcia <gqgarci...@gmail.com> wrote:

> Hi devs,
>
> * I am trying to get the Green functions between two neighboring sites,
> through the method of virtual leads. However, the following error is
> occurring:
>
> ```python
> def mount_vlead(syst, vlead_interface, norb):
>     dim = norb*len(vlead_interface)
>     print(dim)
>     zero_array = np.zeros((dim, dim), dtype=float)
>     def selfenergy_func(energy, args=()):
>         return zero_array
>
>     vlead = kwant.builder.SelfEnergyLead(selfenergy_func,
> vlead_interface,())
>     syst.leads.append(vlead)
>
> lead2 = mount_vlead(syst,[lat.sublattices[0](2, 0)], 1)
> lead3 = mount_vlead(syst,[lat.sublattices[1](3, 0)], 1)
>
> fsyst = syst.finalized()
> ```
>
> ---------------------------------------------------------------------------
> KeyError                                  Traceback (most recent call last)
> ~\anaconda3\lib\site-packages\kwant\builder.py in __init__(self, builder)
>    2060             try:
> -> 2061                 interface = [id_by_site[isite] for isite in
> lead.interface]
>    2062             except KeyError as e:
>
> ~\anaconda3\lib\site-packages\kwant\builder.py in <listcomp>(.0)
>    2060             try:
> -> 2061                 interface = [id_by_site[isite] for isite in
> lead.interface]
>    2062             except KeyError as e:
>
> KeyError: Site(kwant.lattice.Monatomic([[2.0, 0.0], [0.0, 1.0]], [1.0,
> 0.0], '1', 1), array([20, 0]))
>
> During handling of the above exception, another exception occurred:
>
> ValueError                                Traceback (most recent call last)
> <ipython-input-15-99c1026e5465> in <module>
>      12 lead3 = mount_vlead(syst,[lat.sublattices[1](3, 0)], 1)
>      13
> ---> 14 fsyst = syst.finalized()
>
> ~\anaconda3\lib\site-packages\kwant\builder.py in finalized(self)
>    1808         """
>    1809         if self.symmetry.num_directions == 0:
> -> 1810             return FiniteSystem(self)
>    1811         elif self.symmetry.num_directions == 1:
>    1812             return InfiniteSystem(self)
>
> ~\anaconda3\lib\site-packages\kwant\builder.py in __init__(self, builder)
>    2063                 msg = ("Lead {0} is attached to a site that does
> not "
>    2064                        "belong to the scattering region:\n {1}")
> -> 2065                 raise ValueError(msg.format(lead_nr, e.args[0]))
>    2066
>    2067             lead_interfaces.append(np.array(interface))
>
> ValueError: Lead 3 is attached to a site that does not belong to the
> scattering region:
>  <Site [20 0] of 1>
>
> * Where 'syst' is a diatomic network with two sublattices attached with
> two leads. How to correctly use the tags for the sites of the two
> sublattices?
>


-- 
Abbout Adel

Reply via email to