Sergey wrote:
I use the following construction to connect the incommensurate lattices: lat_e (graphene) and lat_e1 (square)
for x in list(lat_e1.shape(rectangle1, (0, 0))()): for neighbour in lat_e.sublattices[0].n_closest(x.pos): sys[(x, lat_e.sublattices[0](*neighbour))] = t01 for neighbour in lat_e.sublattices[1].n_closest(x.pos): sys[(x, lat_e.sublattices[1](*neighbour))] = t01
I hope it's clear why I want to improve n_closest
Because you want to connect x to all the sites of the other lattice within a given radius?
Probably I can do that myself.
For now it’s enough to choose a sufficiently large n and then only keep the points that are close enough. But repeatedly calling n_closest is certainly not an efficient solution to this problem, it will scale badly with the number of sites. A routine that knows two sets of sites (A and B) and is to find all the pairs of a ∈ A and b ∈ B within a certain maximal distance from each other could be made efficient.
The above construction may indeed be in the core of readymade function to connect the two lattices.
So, indeed, let’s say that we have some function that returns pairs of sites (a, b) as described above. Would this be useful? I reckon it would, as I imagine that you are using some simple model for the hopping integrals between the commensurate lattices. So one could write something like this: for a, b in connect(A, B): sys[a, b] = exp(-norm(a - b) / range) (One could also use an equivalent value function.) Any comments? Christoph