Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Euclidian distance between nodes in nk.graph.lattice #1682

Open
oliviersimard opened this issue Jan 5, 2024 · 3 comments
Open

[FR] Euclidian distance between nodes in nk.graph.lattice #1682

oliviersimard opened this issue Jan 5, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@oliviersimard
Copy link

oliviersimard commented Jan 5, 2024

Hi,

Netket provides a method comprised in the class "netket.graph.Lattice" named "distances" which prints out the Manhattan distance between all nodes of the lattice graph (https://netket.readthedocs.io/en/latest/api/_generated/graph/netket.graph.Lattice.html#netket.graph.Lattice.distances). It would be nice to have a similar method that would provide the Euclidian distance between the nodes, taking into account the periodic boundary conditions, having the form:

@partial(jax.vmap, in_axes=(0,None), out_axes=0)
@partial(jax.vmap, in_axes=(None,0), out_axes=0)
def euclidian_distances(p, q):
    assert p.shape == (2,)
    assert q.shape == (2,)

    return jnp.linalg.norm(p-q)

Note that the function above does not consider the periodic boundary conditions.

Thanks :)

@PhilipVinc PhilipVinc added the enhancement New feature or request label Jan 5, 2024
@gcarleo
Copy link
Member

gcarleo commented Apr 9, 2024

Hi, on a graph it is generally not well specified what the euclidean distance is, so that's why we have not implemented it in the general case.
To get the euclidean distance you would need to work with specific geometries that are embedded in an euclidean space, for example netket.graph.Lattice. In this case I agree it might be nice to have a distance function (I thought we already had it though? @gpescia maybe knows)

@gpescia
Copy link
Collaborator

gpescia commented Apr 9, 2024

There is a distance function, taking into account periodic boundary conditions, for a given geometry here: #1583

@oliviersimard I'd say you can use that code for the lattice as well. You just have to define the basis vectors for your lattice (e.g. in a 2D square lattice of size 4x5 the basis vectors would be e1=(4,0) and e2=(0,5)) and express your state vectors in terms of these lattice vectors (e.g. a spin at site (3,1) would have position (3/4 e1 + 1/5 e2)). This conversion should already be provided using from_standard_to_basis in the same PR.

@PhilipVinc
Copy link
Member

This issue is just a reminder that we should implement a distance function for the lattice class.

@PhilipVinc PhilipVinc changed the title Euclidian distance between nodes in Netket graph [FR] Euclidian distance between nodes in nk.graph.lattice Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants