Domain Decomposition and Atom->Map

LAMMPS Version: 3Mar2020

I am writing a custom fix that needs to read the global atom ID’s that are provided in the read_data file. To circumvent local identity change by domain decomposition as atoms shift processors, I am using the atom->map() function:

LAMMPS Version: 3Mar2020

I am writing a custom fix that needs to read the global atom ID’s that are provided in the read_data file. To circumvent local identity change by domain decomposition as atoms shift processors, I am using the atom->map() function:

this is wrong. the atom->map function converts from the (global) atom ID to the local index (or -1 if the atom is not present).
to get the global ID, you use atom->tag[i], while i loops over local atoms.


tagint **bond_atom = atom->bond_atom;

int *num_bond = atom->num_bond;

int atom1, atom2;

double rsq,delx,dely,delz;

for (int i = 0; i < nlocal; i++) {

atom1 = atom->map(i);

for (int j = 0; j < num_bond[atom1]; j++) {

atom2 = atom->map(bond_atom[atom1][j]);

if ((direction = 1 && atom2>atom1) || (direction = -1 && atom2<atom1)){

delx = x[j][0]-x[i][0];

dely = x[j][1]-x[i][1];

delz = x[j][2]-x[i][2];

rsq = delxdelx + delydely + delz*delz;

xvalue = fMagnitude * delx/sqrt(rsq);

yvalue = fMagnitude * dely/sqrt(rsq);

zvalue = fMagnitude * delz/sqrt(rsq);

}
}
}


Can anybody tell me if the above code snippet does (or will do without major debugging) the following:

  • Loop through all atoms (i) in the system and extract their global atom id’s (atom1)

no.

  • For each atom i, identify all its bonded atoms (j) and extract their global id’s (atom2)

no.

please look into compute_bond_local.cpp for an example of a code that loops over all local bonds (and considers each bond globally exactly once).

axel.

I managed to implement global atom ID’s in my fix using atom->tag[ ] and the example in compute_bond_local.cpp (thank you).

Follow up question:

In pair potential.cpp files, usually “i” loops over all atoms in “inum”, which is derived from “ilist”. Does “atom->tag[i]” return the global atom id when “i” is looping over this quantity as well? If not, is there a way to obtain the global atom ID’s given this setup?

S

This was already explained.