[lammps-users] Question about connection between ghost atom and real atom IDs in neighbor lists

Hello,

This may have been answered already in the mailing list, but I couldn’t find anything that matched this exactly so I figured I’d ask. I’m trying to construct a periodic graph, meaning there are no vertices for ghost atoms, only real atoms. I’ve created a pair style to do the neighbor list construction, but when I use the following lines:

inum = list->inum;

ilist = list->ilist;

numneigh = list->numneigh;

firstneigh = list->firstneigh;

for(ii = 0; ii < inum; ii++){

i = ilist[ii];

itype = map[type[i]];

xtmp = x[i][0];

ytmp = x[i][1];

ztmp = x[i][2];

jlist = firstneigh[i];

jnum = numneigh[i];

for(jj = 0; j < jnum; j++){

j = jlist[jj];

j &= NEIGHMASK;

delx = xtmp – x[j][0];

dely = ytmp – x[j][1];

delz = ztmp – x[j][2];

rsq = delxdelx + delydely + delz*delz;

if(rsq > 0 && rsq < cut*cut){

const double r = sqrt(rsq);

int neighbor = j;

double neighbor_dist = r;

}

}

}

The issue is that the value for j is sometimes greater than the total number of atoms, which I’m assuming means that it’s the ID of a ghost atom. Is this correct? If so, how can I access the real atom ID for the ghost atom j? Please let me know if this has already been answered or if anything is unclear.

Thanks and regards,

James

1 Like

Hello,

This may have been answered already in the mailing list, but I couldn’t find anything that matched this exactly so I figured I’d ask. I’m trying to construct a

[…]

The issue is that the value for j is sometimes greater than the total number of atoms, which I’m assuming means that it’s the ID of a ghost atom. Is this correct? If so, how can I access the real atom ID for the ghost atom j? Please let me know if this has already been answered or if anything is unclear.

this topic has been discussed frequently. the indices “i” and “j” are NOT the atom IDs, but rather the indices of the atoms in the local per-atom arrays.
those arrays always start at 0, so it cannot be the atom ID as there would be duplicates when running in parallel.

The atom IDs are stored in atom->tag array this includes ghost atoms.

axel.

Ah, that makes sense. Thanks for the explanation.

-James