I’m working on a custom fix where my sample is binned (1D) into thin slices and some quantity is computed.
This quantitity also includes the neighbors of every atom.
For simplicity, let’s say its just the sum of all the atoms within each of these slices.
so at the end of every step the following is done.
double **x = atom->x;
double **v = atom->v;
int *mask = atom->mask;
inum = list->inum;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
//These are my test-variables
for(int ii = 0; ii < inum; ii++)
jlist = firstneigh[i];
jnum = numneigh[i];
if (mask[i] & groupbit)
//bin sample into thin slices
double xscale = (x[i] - domain->boxlo)/domain->xprd;
int ixnode = static_cast(xscale*nxnodes);
while (ixnode > nxnodes-1) ixnode -= 1;
while (ixnode < 0) ixnode += 1;
//subloop over all neighs
//just a testcase. Pick some slice. Happens to be on proc 0
//Now output on proc 0
Of course I’ve included all the necessary headers. And it runs. But the following is kind of weird:
If I run this with 3 procs I get a very different result for the magnitude of the summed velocity compared to a run on, let’s say 6 procs.
In both cases proc 0 happens to contain the same “slice” of the sample (nxnodes is the same for both scenarios)
For 3 procs, v turns out to be somewehere around 1e4, for 6 procs it’s around 1e7 (metal units)
But “count” is the same for both cases. It’s around 5e5. Should be good enough for some statistics (even though atoms sampled and counted multiple times)
The sample is equilibrated so the atomic velocities are the same on average. However, the more procs I use the larger the magnitude of the summed velocity.
I’m not saying that this quantitiy should turn out the same, but “v/count” should be very similar, shouldn’t it?
It isn’t. Since count is the same for both cases.
I’ve tried to find the bug on my own for hours now, but I guess it’s just too obvious for me to notice and I’m too tired anyway …
By the way, I’m using a cutoff of around 8 Angstrom and an EAM-potential for my metal-sample.
Can you tell me what I’m doing wrong here?