Create ctypes only neighbor list API variant
This moves the lammps.get_neighlist() method to lammps.numpy.get_neighlist(). lammps.get_neighlist() now returns a NeighList object, while the NumPy variants returns a NumPyNeighList object. The main difference between the two is that while the ctypes variant returns neighlist elements as atom idx (int), numneighs (int), neighbors (POINTER(c_int)) the NumPy variant returns atom idx (int), neighbors (numpy.array)
This commit is contained in:
@ -32,8 +32,9 @@ def post_force_callback(lmp, v):
|
||||
t = L.extract_global("ntimestep", 0)
|
||||
print(pid_prefix, "### POST_FORCE ###", t)
|
||||
|
||||
#mylist = L.get_neighlist(0)
|
||||
mylist = L.find_pair_neighlist("lj/cut", request=0)
|
||||
#mylist = L.numpy.get_neighlist(0)
|
||||
idx = L.find_pair_neighlist("lj/cut", request=0)
|
||||
mylist = L.numpy.get_neighlist(idx)
|
||||
print(pid_prefix, mylist)
|
||||
nlocal = L.extract_global("nlocal")
|
||||
nghost = L.extract_global("nghost")
|
||||
@ -43,8 +44,8 @@ def post_force_callback(lmp, v):
|
||||
v = L.numpy.extract_atom("v", nelem=nlocal+nghost, dim=3)
|
||||
f = L.numpy.extract_atom("f", nelem=nlocal+nghost, dim=3)
|
||||
|
||||
for iatom, numneigh, neighs in mylist:
|
||||
print(pid_prefix, "- {}".format(iatom), x[iatom], v[iatom], f[iatom], " : ", numneigh, "Neighbors")
|
||||
for iatom, neighs in mylist:
|
||||
print(pid_prefix, "- {}".format(iatom), x[iatom], v[iatom], f[iatom], " : ", len(neighs), "Neighbors")
|
||||
for jatom in neighs:
|
||||
if jatom < nlocal:
|
||||
print(pid_prefix, " * ", jatom, x[jatom], v[jatom], f[jatom])
|
||||
|
||||
Reference in New Issue
Block a user