Query about compute pair/local

Hi all,
In compute_pairs() of compute_pair_local.cpp there is a loop “for (ii = 0; ii < inum; ii++)”, can I just replace it with “for (i = 0; i < nlocal; i++)”? does “inum” equal “nlocal” here?
Since I want to use the force of some pairs of atom in “fix external”, and I try to write a loop as what it is like in compute_pairs() of compute_pair_local.cpp ( I add “class NeighList *list” in “fix_external.h”, and add something like “inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh;” in “fix_external.cpp” ). However, it doesn’t work. Is there any other way to do what I want? Thanks.

Wenjing Zhou

To make my question more specific, I put up my fix_replica.h and fix_replica.cpp in the attachment. I used “fix 21 flow replica region replicaRegion” in my input file, but I got error like “Killing remote processes…MPI process terminated unexpectedly”. I think the problem is due to that something is wrong with neighbor list in fix_replica.cpp, but I can’t figure out the exact problem. So can someone tell me what the problem is? Thanks in advance.

Best regards,
Wenjing Zhou

fix_replica.cpp (4.75 KB)

fix_replica.h (1.2 KB)

I don't debug other people's code. But you can just you a loop
from 0 to nlocal in a compute if you like to access the neighbor
list. The logic with inum, etc is there really for use in pair styles
when used with pair hybrid since not all atoms are then included
in the neighbor list. But they are all included in compute pair/local.

Steve

Thanks, steve. Can you tell me if it is necessary to use the following codes before access the neighbor list, and what do they exactly mean, since from the source code of Lammps it’s not easy to understand all this.
int irequest = neighbor->request((void *) this);
neighbor->requests[irequest]->pair = 0;
neighbor->requests[irequest]->fix = 1;
neighbor->requests[irequest]->half = 0;
neighbor->requests[irequest]->full = 1;

if (force->pair == NULL)
error->all(“Delete_atoms requires a pair style be defined”);

NeighList *list = neighbor->lists[irequest];
neighbor->build_one(irequest);

Best regards,
Wenjing Zhou

Those are calls/settings that the compute (in this case) makes to
request a neighbor list of a particular type. If you do not
do this (like compute pair/local) does, then of course you cannot
use a neighbor list from the compute.

Steve

Thanks, steve. I’ve solved the problem finally.

Best regards,
Wenjing Zhou