Force on ghost atoms

Hi. I am implementing a new fix in Lammps and in some point I need the forces on the ghost atoms. How can I get access to these forces ?

Many thanks.
Vitor

Can you be a bit more specific and explain what you need those for exactly?

Also, at which part of the timestep do you need them?

And, are you referring to the forces added to ghost atoms during force computation or the “full” forces?

I am referring to the “full” forces - the forces that those would have if the run were serial. I will need them just before the fix->final_integrate() part in the timestep since the new fix will act mostly there.

The fix will update the atom position and velocity based on its neighbors (and on the neighbors’ forces). Since some neighbors may be in different processors, the force on the ghost atoms will be necessary for this step. Actually, I also need the velocities of the ghost atoms. But for them, I will try to get them by setting comm_modify vel yes.

You would need to implement what is called in LAMMPS a “forward communication”. 4.5. Communication patterns — LAMMPS documentation
It should work on the original force arrays, but if you want to play it safe, you can also make a copy.

Thanks!
Could the lammps_gather_atoms_subset in the library.cpp (lammps/library.cpp at a84470383bd7ed2685e5a3e7c4db9c75c2ea8381 · lammps/lammps · GitHub) be an alternative ?

Not really. Those scatter/gather calls would distribute a global list from one process to the many or collect from many to one. That would not scale and fail for large systems.

The forward communication is exactly the pattern for sending distributed data to their corresponding ghosts.