Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slab neighborhood search is broken #4517

Closed
jngrad opened this issue May 25, 2022 · 0 comments · Fixed by #4516
Closed

Slab neighborhood search is broken #4517

jngrad opened this issue May 25, 2022 · 0 comments · Fixed by #4516
Labels

Comments

@jngrad
Copy link
Member

jngrad commented May 25, 2022

The system.analysis.nbhood(pos=None, r_catch=None, plane='3d') function has two search mode: spherical region (default) and slab region. The slab search is incorrect, because the bitmask is inverted. Instead of searching for particles within a distance r_catch of a plane, it searches for particles in a cylinder of radius r_catch perpendicular to the plane. There is no python test for the slab search mode. The slab search mode was already incorrect in the Tcl version of ESPResSo, and it doesn't take Lees-Edwards boundary conditions into account.

MWE:

import espressomd
import numpy as np
system = espressomd.System(box_l=3 * [10])
origin = np.array([10., 10., 0.])
offset = 4.
search_dist = 1.
system.part.add(pos=origin + [0., 0., 0.]) # inside sphere, distance to center is 0
system.part.add(pos=origin + [0., 0., offset]) # inside cylinder, distance to z-axis is 0
system.part.add(pos=origin + [offset, 0., 0.]) # inside slab, distance to xy-plane is 0
print(system.analysis.nbhood(origin, search_dist, plane='3d'))
print(system.analysis.nbhood(origin, search_dist, plane='xy'))

Output:

[0]
[0, 1]

Expected output:

[0]
[0, 2]

Visual inspection (only particles in the neighborhood appear in the visualizer):

import espressomd.visualization
system = espressomd.System(box_l=[10] * 3, time_step=0.1)
system.cell_system.skin = 0.
for i in range(10):
    for j in range(10):
        for k in range(10):
            system.part.add(pos=[i,j,k])

ids = system.analysis.nbhood([5., 5., 5.], 4.5, plane='xy')
coords = system.part.by_ids(ids).pos
system.part.clear()
for pos in coords:
    system.part.add(pos=pos)

espressomd.visualization.openGLLive(system).run(0)
@jngrad jngrad added the Bug label May 25, 2022
@kodiakhq kodiakhq bot closed this as completed in #4516 May 31, 2022
kodiakhq bot added a commit that referenced this issue May 31, 2022
Description of changes:
- user guide:
   - cleanup code examples and fix bond breakage documentation (e.g. mode `"bind_centers"` vs. `"bond_centers"`)
   - document ghost particles side-effects on observables
   - where changes were made, wrap text to ~80 chars per line to make git diffs more readable
- python testsuite:
   - reduce code duplication by merging similar tests together and by using `tests_common.py` more often
   - improve code coverage by rewriting assertions
- bug fixes:
   - the incorrectly implemented slab search mode of  `system.analysis.nbhood()` was removed (fixes #4517)
   - `TabulatedNonBonded.is_active()` now returns `False` instead of `None` when the bond is inactive
   - always checks for runtime errors when the cell system changes or when a `ScriptInterface` object is instantiated
- API changes:
   - script interface methods no longer return `True` to signal they didn't raise an exception
- script interface improvements:
   - simplify `System` class and document why the `_Globals` class (now renamed to `_BoxGeometry`) has to exist
   - simplify `ScriptInterfaceHelper` classes using automatically generated member methods
   - simplify several core functions that are included in pxd files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant