Unverified Commit cf192be4 authored by Gao, Xiang's avatar Gao, Xiang Committed by GitHub
Browse files

Test non-rectangular PBC (#139)

parent d8168e7e
......@@ -7,6 +7,7 @@ import torchani
import unittest
import numpy
import itertools
import math
def get_numeric_force(atoms, eps):
......@@ -158,6 +159,24 @@ class TestASE(unittest.TestCase):
self.assertTensorEqual(neighbor_coordinate, xyz2)
def testNonRectangularPBCConnersSeeEachOther(self):
species = torch.tensor([[0, 0]])
neighborlist = torchani.ase.NeighborList(
cell=[10, 10, 10 * math.sqrt(2), 90, 45, 90], pbc=True)
xyz1 = torch.tensor([0.1, 0.1, 0.05])
xyz2 = torch.tensor([10.0, 0.1, 0.1])
mirror = torch.tensor([0.0, 0.1, 0.1])
coordinates = torch.stack([xyz1, xyz2]).unsqueeze(0)
s, _, D = neighborlist(species, coordinates, 1)
self.assertListEqual(list(s.shape), [1, 2, 1])
neighbor_coordinate = D[0][0].squeeze() + xyz1
for i in range(3):
if mirror[i] > 5:
mirror[i] -= 10
self.assertTensorEqual(neighbor_coordinate, mirror)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment