attribute *sametag

Dear all,

When i read the source code file create_bonds.cpp , i noticed that a notation at line 256 writes "if I,J tags equal, do not bond atom to itself",but how could a ilist local atom id "I " euqal to its firstneigh local atom id “J”? Does this mean that the I atom’s neighbor (fiestneigh[i]) always contain itself?
Also,when i read the atom.h file, i can hardly understand the meaning of the attribute *sametag . I searched for it in the whole code files, but found that it was only set in the file atom_map.cpp as sametag[i]=map_array[tag[i]], but map_array[i] was initialized as -1, and this setting seems meaningless , is there anywhere else that the *sametag was set?

Sincerely thanks,
XiaonengRan

Dear all,

When i read the source code file create_bonds.cpp , i noticed that a notation at line 256 writes "if I,J tags equal, do not bond atom to itself",but how could a ilist local atom id "I " euqal to its firstneigh local atom id “J”?

no, but you are overlooking that LAMMPS is not subject to minimum image conventions, because it has “ghost” atoms which are real copies of atoms from neighboring subdomains and for small systems, that could be also copies of the same atom, i.e. atoms that have the same value for Atom::tag[]
please note, that the code in question does not compare the I and J indices, but rather the corresponding value of Atom::tag[].

Does this mean that the I atom’s neighbor (fiestneigh[i]) always contain itself?

no, but it may contain a copy of itself.

Also,when i read the atom.h file, i can hardly understand the meaning of the attribute *sametag . I searched for it in the whole code files, but found that it was only set in the file atom_map.cpp as sametag[i]=map_array[tag[i]], but map_array[i] was initialized as -1, and this setting seems meaningless , is there anywhere else that the *sametag was set?

you are overlooking the meaning of map_array[] (which is only used for map_style 1, otherwise a hash is used). both are required for the Atom::map() function, which will return the local atom index for a given atom tag (or atom id). these are set in the Atom::map_set() function. now, since it is possible that you may have multiple atoms with the same tag (or atom ID) on any given sub-domain, only one of them is the “canonical” index, that is the atom pointed to by Atom::sametag[].

if you inspect the data in of a running program, you will see that it works. understanding this really all hinges on understanding how LAMMPS manages domain decomposition and implicitly with it also handling of periodic replica. you can experiment with this by setting up a system with only a small number of atoms, but a cutoff that is (much) larger than half the box length. LAMMPS will allow this and function correctly up to a point where the size of the communication cutoff becomes too large so it may miss communicating all needed ghost atom information across borders.

axel.