Dear Christoph, 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 Probably I can do that myself. The above construction may indeed be in the core of readymade function to connect the two lattices. Best wishes, Sergey
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
Dear Christoph, Yes, such function would be definitely useful. Sometimes, it is useful to play with some reasonable, but a bit ad-hoc hoppings. I propose that that the function "connect" must take a function name "crit" as an input parameter. Where "crit" is a function taking two sites as parameters, e.g. crit(A,B): if norm(A-B) < 2 and 0<np.abs(A.pos[3] - B.pos[3])<1: return true else: return false It could be nice to have an efficient realization of "connect" . Is there a way to do it faster than N^2 ? Best wishes, Sergey On 10/07/15 15:17, Christoph Groth wrote:
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
Sergey wrote:
Yes, such function would be definitely useful. Sometimes, it is useful to play with some reasonable, but a bit ad-hoc hoppings. I propose that that the function "connect" must take a function name "crit" as an input parameter. Where "crit" is a function taking two sites as parameters, e.g.
crit(A,B): if norm(A-B) < 2 and 0<np.abs(A.pos[3] - B.pos[3])<1: return true else: return false
It could be nice to have an efficient realization of "connect" . Is there a way to do it faster than N^2 ?
I believe that it can be made something like O(N log N) by using an appropriate data structure, perhaps a k-d tree. But it's clearly O(N^2) if crit is to be called for all pairs of sites. How about, instead of crit, having a function that returns all hoppings within some maximum distance. If you want to use crit, you can do something like this: sys[ (hop for hop in connect(A, B) if crit(hop)) ] = value Wouldn't that be the same as your suggestion, only more generic? Christoph
Here is a simple working example of connect function that helps to define hoppings. def crit(site1,site2): x,y,z =site1.pos-site2.pos if abs(z)==1 and y==0 and x==0: return True else: return False def connect(sys,crit): result=[] for site1 in sys.sites(): for site2 in sys.sites(): if crit(site1,site2): result.append((site1,site2)) return iter(result) #example usage lead[connect(lead,crit)] = tz It could be improved by reducing iterating only over i<j sites, but I do not know of simple way to code that. Best wishes, Sergey On 10/07/15 16:25, Christoph Groth wrote:
Sergey wrote:
Yes, such function would be definitely useful. Sometimes, it is useful to play with some reasonable, but a bit ad-hoc hoppings. I propose that that the function "connect" must take a function name "crit" as an input parameter. Where "crit" is a function taking two sites as parameters, e.g.
crit(A,B): if norm(A-B) < 2 and 0<np.abs(A.pos[3] - B.pos[3])<1: return true else: return false
It could be nice to have an efficient realization of "connect" . Is there a way to do it faster than N^2 ?
I believe that it can be made something like O(N log N) by using an appropriate data structure, perhaps a k-d tree.
But it's clearly O(N^2) if crit is to be called for all pairs of sites. How about, instead of crit, having a function that returns all hoppings within some maximum distance. If you want to use crit, you can do something like this:
sys[ (hop for hop in connect(A, B) if crit(hop)) ] = value
Wouldn't that be the same as your suggestion, only more generic?
Christoph
participants (2)
-
Christoph Groth
-
Sergey