Coder Social home page Coder Social logo

torch_nl's People

Contributors

felixmusil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

torch_nl's Issues

Doesn't seem to work for atoms that are separated by multiple periodic images

Hi @felixmusil, firstly thanks for making this it is very useful!!

I have an issue, when I compute a neighbour list for a configuration where the atoms are all separated by several periodic boxes then the torch_nl compute_neighborlist does not correctly compute the neighbour list, it misses all the interactions. Here is an example comparing it with ASE which I am assuming to be working correctly:

from ase.neighborlist import primitive_neighbor_list
from torch_nl import compute_neighborlist
import torch

# cell of 10 x 10 x 10
cell = torch.eye(3)*10.0
pbc = torch.tensor([True, True, True],dtype=bool)

cutoff = 4.5 # a bit smaller than half box length

# make 10 points that are spread out over many periodic images
x = torch.randn(10,3)*100.0


# ASE
i, j, S = primitive_neighbor_list(
    quantities="ijS",
    pbc=pbc.numpy(),
    cell=cell.numpy(),
    positions=x.numpy(),
    cutoff=cutoff,
    self_interaction=True,  
    use_scaled_positions=False,  
)


# torch nl
tnl_ij, _, tnl_S = compute_neighborlist(cutoff=cutoff, pos=x, cell=cell, pbc=pbc, batch=torch.zeros(10,dtype=torch.int), self_interaction=True)
tnl_i = tnl_ij[0]
tnl_j = tnl_ij[1]

#They should give the same 
i=list(i)
j=list(j)

tnl_i = [ int(a) for a in tnl_i]
tnl_j = [ int(a) for a in tnl_j]

print("ASE:",[i,j])
print("torch-nl:",[tnl_i, tnl_j])

assert( i == tnl_i)

The output I get is:

ASE: [[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9], [6, 7, 2, 8, 1, 3, 4, 0, 7, 1, 3, 0, 3, 7, 9, 5, 0, 2, 4, 1, 3, 0, 2, 4, 3, 4, 0, 2, 9, 5, 4, 9, 7, 5, 2, 0, 6, 1, 9, 7, 5, 2, 8, 0, 0, 8, 7, 9, 7, 5, 2, 4]]
torch-nl: [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]
Traceback (most recent call last):
    assert( i == tnl_i)
AssertionError

Running on M2 Mac with pytorch=1.12.1, torch-nl=0.2, ASE=3.22.1

I would expect this to work, am I doing something wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.