Hello Joseph, One problem that I see is that I can only get neighbors() from Builders and lattices (using site.family). Using something like this: def first_neighbors(to_site, from_site): return to_site in from_site.family.neighbors(1) is a good idea, but am I really comparing two sites? -------------------------------- for i in x.family.neighbors(1): print(i) HoppingKind((1, 0, 0), <Monatomic lattice 13>) HoppingKind((0, 1, 0), <Monatomic lattice 13>) ------------------------------------------- Also, since this is very expensive computationally, is there any other way to find the hopping distance between two sites? Eleni Quoting Joseph Weston <joseph.weston08@gmail.com>:
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.Polyatom...
-- Dr. Eleni Chatzikyriakou Computational Physics lab Aristotle University of Thessaloniki elchatz@auth.gr - tel:+30 2310 998109