amepproject / amep

The Active Matter Evaluation Package (AMEP) - a Python library for the analysis of particle-based and continuum simulation data of soft and active matter systems
https://amepproject.de/
GNU General Public License v3.0
9 stars 2 forks source link

BUG: 'exclude' option does not work for 'order.nearest_neighbors' and 'order.k_nearest_neighbors' when 'other_coords' is specified #38

Open aritra-mukhopadhyay opened 3 weeks ago

aritra-mukhopadhyay commented 3 weeks ago

Description:

order.nearest_neighbors and order.k_nearest_neighbors counts the particle itself when counting its neighbors when other_coords is specified explicitly.

Code for reproduction:

import amep

traj = amep.load.traj('./examples/data/lammps')
frame = traj[-1]

# calculate nearest neighbours of particle id 2
nnn, distances, neighbors = amep.order.nearest_neighbors(
    frame.coords()[2, None], frame.box, other_coords=frame.coords(), exclude=True, pbc=True
)

#nnn, distances, neighbors = amep.order.k_nearest_neighbors(
#    frame.coords()[2, None], frame.box, other_coords=frame.coords(), pbc=True
#)

print(nnn) # number of nearest neighbors
print(distances) # nearest-neighbor distances
print(neighbors) # nearest neighbor ids

Error message:

No response

Python and AMEP versions:

Python 3.12.3 AMEP 1.0.1

Additional information:

No response

How did you install AMEP?

conda