Atoms exchange between processors during minimization process

Dear Lammps-users,

I am trying to realize minimization using my own code in LAMMPS and I am using LAMMPS as an library.

The code is similar to the min.cpp. In the minimization loop, I first evaluate the force on each atom and then calculate the new position for each atom. Atoms are moved to the new position. In order to evaluate energy and force of the system with new coordinates, I write a function similar to the energy_force() in min.cpp as can be seen in the attachment.

The code works well with one processor. However, when I run the code with two cores (parallel), the force and potential energy becomes wired when there is atom exchange between processors. The outputs are attached here.

I think the neighbor is not correctly built after atom exchange and as a result the force and energy evaluation is wrong. How can I modify my code to correct it? Do I need to add any fix to the system before I run my minimization code? Many thanks!!!

Screen Shot 2015-05-13 at 3.28.52 PM.png

Screen Shot 2015-05-13 at 3.29.06 PM.png

Screen Shot 2015-05-13 at 3.31.22 PM.pngSincerely,
Vivian

I doubt anyone is going to figure out your code for you.

If you are adding code to LAMMPS then you have

to be able/willing to debug it. I suggest you look

at the simpest possible problem, e.g. 2 atoms, 1 on

each proc and see if you can cause the error. Then

start adding print statements and see what is going wrong.

Steve

Screen Shot 2015-05-13 at 3.28.52 PM.png

Screen Shot 2015-05-13 at 3.31.22 PM.png

Screen Shot 2015-05-13 at 3.29.06 PM.png