# pbc and distance calculations

Dear all,
while I am trying to solve some problems that I faced in use of a new pair potential, I realised that one point was not clear to me, concerning pbc and the calculation of distances.
The pbc() method is called when neighbor list are re-calculated and that’s fine. By looping on the elements of this list the pair interactions are calculated, but what about the distances?
I guess there might be some flags that indicate whether or not - and if so, how many times - the pbc have been applied on an atom. Depending on these flags ( the difference, maybe) the distance are calculated directly from the x[type][axis] array or by adding/subtracting the corresponding box length. I checked with the src file of some pair potentials already implemented but I can see how this mechanism would work, given that for the calculation of distances it seems that only the the arrays x[type][axis] are used. In other words, why would this calculate the correct distance for two atoms within the cut-off distance if they are interacting through the boundaries?

``````for (ii = 0; ii < inum; ii++) {
``````
``````    i = ilist[ii];
``````
``````    qtmp = q[i];
``````
``````    xtmp = x[i];
``````
``````    ytmp = x[i];
``````
``````    ztmp = x[i];
``````
``````    itype = type[i];
``````
``````    itag = tag[i];
``````
``````    jlist = firstneigh[i];
``````
``````    jnum = numneigh[i];
``````
``````
``````
``````    for (jj = 0; jj < jnum; jj++) {
``````
``````      j = jlist[jj];
``````
``````      //factor_lj = special_lj[sbmask(j)];
``````
``````      //factor_coul = special_coul[sbmask(j)];
``````
``````      j &= NEIGHMASK;
``````
``````      delx = xtmp - x[j];
``````
``````      dely = ytmp - x[j];
``````
``````      delz = ztmp - x[j];
``````
``````      rsq = delx*delx + dely*dely + delz*delz;
``````
``````      dr = sqrt(rsq);
``````

Can anyone give me a clue where to find the answer in the code? Tnx

Giovanni Doni
PhD Student
Physics Department
King’s College London
Strand
London WC2R 2LS
(Tel: +44 (0)7710641129)
Email: [email protected]…4386…

Please read in the lammps paper and previous discussions in the mailing list archives about ghost atoms.

Lammps does not require minimum image conventions since its periodic images are real copies (as ghosts).

Axel

More specifically, the list of atoms in jlist contain both local and
ghost atoms. The ghost atoms are periodic images of local atoms,
whose coordinates are shifted accordingly. This is not easy to find
out, as it happens in functions like:

AtomVecAtomic::pack_comm()

Aidan