felixmusil / torch_nl Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.