Hello,

I try to write a new pair potential. For each atom *I*, I want a sub-loop that goes through all the atoms *J* in the simulation box, regardless of the distance between atoms *I* and *J*. In this case, the usual (full) neighbor list cannot be applied.

- For serial calculations, we can try to first store the positions of all atoms. Then for each atom
*I*, loop over all atoms in the simulation box.

```
memory->create(dp, natoms, 3, "pair:dp"); # natoms * three dimension
memory->create(sum, natoms, "pair:sum");
# Store the positions of all atoms in the simulation box
for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
itag = tag[i] - 1;
for (beta = 0; beta < 3; beta++) dp[itag][beta] = x[i][beta];
}
# For each atom i, calculate the sum of all positions in three dimensions of all atoms
for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
itag = tag[i] - 1;
sum[itag] = 0;
for (j = 0; j < natoms; j++) {
for (beta = 0; beta < 3; beta++) sum[itag] += dp[j][beta];
}
}
```

- For parallel calculations, it gives errors because of the partitioning. Another way is directly loop through all atoms for each atom
*I*.

```
memory->create(sum, natoms, "pair:sum");
# For each atom i, calculate the sum of all positions in three directions of all atoms
for (ii = 0; ii < inum; ii++) {
i = ilist[ii];
sum[itag] = 0;
for (jj = 0; jj < inum; jj++) {
j = ilist[jj];
for (beta = 0; beta < 3; beta++) sum[itag] += x[j][beta];
}
}
```

The problem is, because of partitioning, *ilist* only contains atoms that are partitioned to the local core, not the full atom list in the simulation. Communications between different cores seem not trivial.

May I ask if there are some ways to achieve this? Thanks in advance for your help.

Best regards,

Yongliang Ou