tersoff/tag question

Hi Lammps,

I have another tersoff question. There's a block of code which I am not
sure I understand well:

    for (jj = 0; jj < jnum; jj++) {
      j = jlist[jj];
      jtag = tag[j];

      if (itag > jtag) {
        if ((itag+jtag) 2 == 0\) continue; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\} else if \(itag &lt; jtag\) \{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if \(\(itag\+jtag\) 2 == 1) continue;
      } else {
        if (x[j][2] < x[i][2]) continue;
        if (x[j][2] == ztmp && x[j][1] < ytmp) continue;
        if (x[j][2] == ztmp && x[j][1] == ytmp && x[j][0] < xtmp) continue;
      }

What is going on with the comparison of coordinates (e.g. x[j][2] <
x[i][2])) at the end of this block?

The jlist array comes from the first nearest neighbor list of ilist[i].
The Erhart & Albe paper gives the tersoff energy in the form of a sum of
repulsive pair and attractive three body terms for index i > j. So why not
just use the condition of itag > jtag? I don't understand these loop
conditions. Any comments or explanation would be greatly appreciated.

Thanks,
John

The problem is that for a small periodic
box, an atom can be its own neighbor,
hence itag = jtag. The logic in the last
branch of the if statement is to account
for that and skip 1/2 the interactions.

We also don't simple do i < j, as that
can lead to poor load balance when atoms
are numbered consecutively. Hence the
(itag+jtag) % 2 logic.

Steve