add neighbor list access tests. now we can always test for a full list.
This commit is contained in:
@ -412,6 +412,74 @@ class PythonNumpy(unittest.TestCase):
|
||||
idx, neighs = nlist.get(i)
|
||||
self.assertEqual(neighs.size,nlocal-1-i)
|
||||
|
||||
def testNeighborListZeroHalf(self):
|
||||
self.lmp.commands_string("""
|
||||
boundary f f f
|
||||
units real
|
||||
region box block -5 5 -5 5 -5 5
|
||||
create_box 1 box
|
||||
mass 1 1.0
|
||||
pair_style zero 4.0
|
||||
pair_coeff 1 1
|
||||
""")
|
||||
x = [ 0.0, 0.0, 0.0, -1.1, 0.0, 0.0, 1.0, 0.0, 0.0,
|
||||
0.0, -1.1, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.1,
|
||||
0.0, 0.0, 1.0 ]
|
||||
tags = [1, 2, 3, 4, 5, 6, 7]
|
||||
types = [1, 1, 1, 1, 1, 1, 1]
|
||||
|
||||
self.assertEqual(self.lmp.create_atoms(7, id=tags, type=types, x=x), 7)
|
||||
nlocal = self.lmp.extract_global("nlocal")
|
||||
self.assertEqual(nlocal, 7)
|
||||
|
||||
self.lmp.command("run 0 post no")
|
||||
|
||||
self.assertEqual(self.lmp.find_pair_neighlist("zero"),0)
|
||||
nlist = self.lmp.numpy.get_neighlist(0)
|
||||
self.assertEqual(nlist.size, 7)
|
||||
for i in range(0,nlist.size):
|
||||
idx, neighs = nlist.get(i)
|
||||
self.assertEqual(idx,i)
|
||||
self.assertEqual(neighs.size,nlocal-1-i)
|
||||
|
||||
# look up neighbor list by atom index
|
||||
neighs = nlist.find(2)
|
||||
self.assertEqual(neighs.size,4)
|
||||
self.assertIsNotNone(neighs,None)
|
||||
# this one will fail
|
||||
neighs = nlist.find(10)
|
||||
self.assertIsNone(neighs,None)
|
||||
|
||||
def testNeighborListZeroFull(self):
|
||||
self.lmp.commands_string("""
|
||||
boundary f f f
|
||||
units metal
|
||||
region box block -5 5 -5 5 -5 5
|
||||
create_box 1 box
|
||||
mass 1 1.0
|
||||
pair_style zero 4.0 full
|
||||
pair_coeff * *
|
||||
""")
|
||||
x = [ 0.0, 0.0, 0.0, -1.1, 0.0, 0.0, 1.0, 0.0, 0.0,
|
||||
0.0, -1.1, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, -1.1,
|
||||
0.0, 0.0, 1.0 ]
|
||||
tags = [1, 2, 3, 4, 5, 6, 7]
|
||||
types = [1, 1, 1, 1, 1, 1, 1]
|
||||
|
||||
self.assertEqual(self.lmp.create_atoms(7, id=tags, type=types, x=x), 7)
|
||||
nlocal = self.lmp.extract_global("nlocal")
|
||||
self.assertEqual(nlocal, 7)
|
||||
|
||||
self.lmp.command("run 0 post no")
|
||||
|
||||
self.assertEqual(self.lmp.find_pair_neighlist("zero"),0)
|
||||
nlist = self.lmp.numpy.get_neighlist(0)
|
||||
self.assertEqual(nlist.size, 7)
|
||||
for i in range(0,nlist.size):
|
||||
idx, neighs = nlist.get(i)
|
||||
self.assertEqual(idx,i)
|
||||
self.assertEqual(neighs.size,nlocal-1)
|
||||
|
||||
def testNeighborListCompute(self):
|
||||
self.lmp.commands_string("""
|
||||
boundary f f f
|
||||
|
||||
Reference in New Issue
Block a user