Hi, > > Is it also possible to help me with this function to match first > nearest neighbor sites for the where argument in kwant.operator.Current: > > def first_neighbors(site_to, site_from): > for i in site_from.family.neighbors(1): > if(??): > return True > else > return False > > [...] > > J = kwant.operator.Current(kwant_sys, where=first_neighbors, sum=True]
Probably the following: def first_neighbors(to_site, from_site): return to_site in from_site.neighbors(1) 'neighbors' returns (per the documentation [1]) a list of sites and we can just use the 'in' operator to check for the requested site. Happy Kwanting, Joe [1]: https://kwant-project.org/doc/1.0/reference/generated/kwant.lattice.Polyatomic#kwant.lattice.Polyatomic.neighbors