Particles within cutoff radius of arbitrary locations

Dear all,

I’d like to get a list of particles that lie within the force-cutoff radius from an arbitrary location in space. If I can get the particles in the computational “bins” surrounding the location, that would certainly be a great start.

I’m developing an algorithm that needs the potential energy and force (on a test-particle) at a series of points in the domain, which are determined dynamically at run-time. This process is part of a calculation that is not part of the integration of the equations of motion, so all other particles can be considered fixed. Bearing this in mind, I’d like to avoid unnecessary re-building of the bin- and neighbor-lists. There will also be many of these calculations, so a loop over all of the processor’s atoms is equally undesirable!

I’ve been digging through the source code a little, and see that Neighbor::coord2bin(…) and Neighbor::binhead can (I think) give me the data I’m after. However, both are protected members of the Neighbor class and are therefore unavailable to my new fix. I’d obviously like to avoid hacking up any internal LAMMPS classes - is there an easy way for me to get the information I need? I’m new to LAMMPS, so may have missed something very obvious.

Many thanks in advance,

David

(LAMMPS version: 9 Sep 2015)

Dear all,

I'd like to get a list of particles that lie within the force-cutoff
radius from an arbitrary location in space. If I can get the particles in
the computational "bins" surrounding the location, that would certainly be
a great start.

I'm developing an algorithm that needs the potential energy and force (on
a test-particle) at a series of points in the domain, which are determined
dynamically at run-time. This process is part of a calculation that is
*not* part of the integration of the equations of motion, so all other
particles can be considered fixed. Bearing this in mind, I'd like to avoid
unnecessary re-building of the bin- and neighbor-lists. There will also be
many of these calculations, so a loop over all of the processor's atoms is
equally undesirable!

I've been digging through the source code a little, and see that
Neighbor::coord2bin(...) and Neighbor::binhead can (I think) give me the
data I'm after. However, both are protected members of the Neighbor class
and are therefore unavailable to my new fix. I'd obviously like to avoid
hacking up any internal LAMMPS classes - is there an easy way for me to get
the information I need? I'm new to LAMMPS, so may have missed something
very obvious.

​the most straightforward approach that i could think of is to include
additional particles at the desired locations that generate no forces or
energy. you could use pair style hybrid and then loop within the compute
function of a custom pair style for these special particles over the
neighbors.

if you then also write a fix that will update the positions of these
particles as needed​ and exclude their DoFs from the overall temperature
and pressure calculation, you should be on your way. hacking into the
neighbor list classes is something i would advise to avoid unless you know
what you are doing.

axel.

I’d suggest you write your own fix or compute that simply

loops over the atoms (owned and ghost) on a proc and

puts them in bins. It’s not a complicated operation, nor does
it take much memory, and you could borrow code/modify from the Neighbor class to do it.

If the atoms you want to bin aren’t moving, then you only

have to do it once. Then your fix/compute can easily

find neighbors for any test particle that is in that proc’s domain.

Then your entire fix/compute is self-contained.

Steve

Many thanks for your help, Steve and Axel. I’ll give that a shot.

All the best,

David