Some atoms get included twice in neighbor list

I made a custom pair style that uses a full neighbor list. When I increase the cutoff past a certain level, some atoms get included twice (although the cutoff is still smaller than the box size).

Specifically, when looping over atoms “ii”, the pair atoms “jj” are listed with

jlist = firstneigh[i];
jnum = numneigh[i];

In my case, when I reach a certain cutoff, “jlist” starts to include atoms of the same tag more than once.

Are there any reasons this would happen? I can provide source code if necessary.

I made a custom pair style that uses a full neighbor list. When I increase
the cutoff past a certain level, some atoms get included twice (although the
cutoff is still smaller than the box size).

you mean half the box size, right?

Specifically, when looping over atoms "ii", the pair atoms "jj" are listed
with

    jlist = firstneigh[i];
    jnum = numneigh[i];

In my case, when I reach a certain cutoff, "jlist" starts to include atoms
of the same tag more than once.

Are there any reasons this would happen? I can provide source code if
necessary.

yes, this is intentional.
for this reason, LAMMPS is not subject to minimum image conventions,
but can use cutoffs large than half the (shortest) box length.
please note that the cutoff for the neighborlist is usually larger
than the largest pairwise cutoff, due to the use of the neighbor list
skin, which in turn allows to reuse the same neighbor list for
multiple steps (if atoms move slow enough).

axel.

Right, it is half the box size. Didn’t realize until now. That all makes sense in order to avoid the minimum image convention.

Anyways, is there a way to avoid the double counting?

Drew Rohskopf | Graduate Research Assistant

Atomistic Simulation & Energy Group

Georgia Institute of Technology

(404)403-0313

Right, it is half the box size. Didn't realize until now. That all makes
sense in order to avoid the minimum image convention.

Anyways, is there a way to avoid the double counting?

you can add a test, where you simply don't allow a cutoff where:

MAX(comm->cutghostuser,neighbor->cutneighmax) > 0.5*
MIN(domain->xprd,MIN(domain->yprd,domain->zpdr))

axel.

I tried doing something similar, but unfortunately I have a strange situation where I need a cutoff greater than half the box size (this is a potential where different parameters are defined for each atom pair).

I was wondering if there is a way to avoid double counting even when the cutoff is greater than half the box size. Ideally my cutoff should be the box size in the case of this special potential.

Drew Rohskopf | Graduate Research Assistant

Atomistic Simulation & Energy Group

Georgia Institute of Technology

(404)403-0313

I tried doing something similar, but unfortunately I have a strange
situation where I need a cutoff greater than half the box size (this is a
potential where different parameters are defined for each atom pair).

I was wondering if there is a way to avoid double counting even when the
cutoff is greater than half the box size. Ideally my cutoff should be the
box size in the case of this special potential.

but then you have to properly consider periodic images and address the
fact that you will have multiple atoms with the same tag accordingly.
this is not double counting, but proper counting of the interactions.

axel.

If I understand correctly, you want to include the nearest periodic image of j in the neighbor list of i, and exclude all other periodic images. This problem is already solved by LAMMPS by constructing special neighbor lists for things like harmonic or FENE bonds. See neigh_bond.cpp and bond_harmonic.cpp. If you don’t want to modify your neighbor list because you are using it for others interactions, then you will have to add some code to your force loop over the jnum neighbors of i, storing each new value of jtag in a temporary list, and skipping the force calculation for recurring values.

In domain.cpp there are a couple methods closest_image() that

return which atom J is the closest to atom I, for the case where

there are several (image) atoms with different J indices which

are all images of the same atom (with the same (ID).

However, Axel’s comment is correct. The neighbor list is

not double counting, it is the proper enumeration. The same

atom ID may appear multiple times, but the coords of those

images will be different, b/c the multiple atoms are images

of each other, displaced by box lengths.

Steve