Error about parallel computing when modify the fix_addforce.cpp

Dear All,

I make some changes about the fix_addforce.cpp,hoping to add a special force.

int nlocal = atom->nlocal;
+ int index,l,j3,j4,j5,j7,j8,j9,j10;

if (update->ntimestep % nevery) return;

foriginal[1] += f[i][0];
foriginal[2] += f[i][1];
foriginal[3] += f[i][2];
index = atom->tag[i];
/*
printf("%d %d %lf lf \n",i,index,sforce[i][0],atom->x[i][0]);* _*/_ *if (xstyle == ATOM) {* *if ((index 10) == 2 ) {
j3 = atom->map(index + 1);
j4 = atom->map(index + 2);
j5 = atom->map(index + 3);
j7 = atom->map(index + 5);
j8 = atom->map(index + 6);
j9 = atom->map(index + 7);
j10 = atom->map(index + 8);
f[i][0] += (sforce[j4][0] - sforce[j5][0])*0.125;
f[j3][0] += -(sforce[j4][0] - sforce[j5][0])*0.125;
f[j7][0] += -(sforce[j9][0] - sforce[j10][0])*0.125;
f[j8][0] += (sforce[j9][0] - sforce[j10][0])*0.125;
// printf("%d %d %d %d %lf %lf %lf lf \n",index,i,j,l,sforce[i][0],sforce[j][0],sforce[l][0],f[i][0]);* *}* *else f[i][0] += 0;* *}* *else if (xstyle) f[i][0] += xvalue;* *if (ystyle == ATOM) {* *if ((index 10) == 2 ) {
j3 = atom->map(index + 1);
j4 = atom->map(index + 2);
j5 = atom->map(index + 3);
j7 = atom->map(index + 5);
j8 = atom->map(index + 6);
j9 = atom->map(index + 7);
j10 = atom->map(index + 8);
f[i][1] += (sforce[j4][1] - sforce[j5][1])*0.125;
f[j3][1] += -(sforce[j4][1] - sforce[j5][1])*0.125;
f[j7][1] += -(sforce[j9][1] - sforce[j10][1])*0.125;
f[j8][1] += (sforce[j9][1] - sforce[j10][1])*0.125;
}
else f[i][1] += 0;
}
else if (ystyle) f[i][1] += yvalue;
if (zstyle == ATOM) f[i][2] += sforce[i][2];
else if (zstyle) f[i][2] += zvalue;

When parallel computing,the job break down.However,it works well serially.I have no idea about that problem.

Could you give me some advice?

Best wishes!

Sincerely yours,
Chen Wang

You’ll have to debug your own code.

Two quick ideas.

atom->map() can return -1 which means

the atom wasn’t found (too far away from this

processor). You’re not accounting for that

possibiliity.

The atom you do find may be a ghost atom,

which means you are updating a ghost force.

Unless you insure those forces are communicated

back to the proc that owns the atom,

that force will be lost.

Steve