Dear LAMMPS Users,
I am trying to reproduce the pressure tensor calculated using the compute pressure command. I have decided to calculate the virial using pairwise forces between particles in my system. I use the compute pair/local command to output the pairwise interactions in my system. This command can provide the pairwise distance (dx, dy, dz) and the corresponding force (fx, fy, fz) necessary for my calculation. While the convention for the direction of dx,dy, and dz seems to be from the atom with higher to atom with lower atom ID, the convention for fx,fy, and fz seems arbitrary. To be clear, when the dx = x2 - x1, I expect the force fx to follow the same convention, however, the force sometimes points in the direction of dx and other times in the direction of -dx. Could you help me understand this better?
This is the command I use -
compute pair_calc all pair/local dx dy dz fx fy fz
Thanks
The compute pressure
command doesn’t compute anything. It just uses data that is computed by the various force styles including the pair style. Which is or are the styles that you want to check?
The order of atoms would depend on the order of atoms in the neighbor list.
You can try applying this modification to LAMMPS and let us know, if that results in forces consistent with the sign of dx, dy, and dz.
diff --git a/src/compute_pair_local.cpp b/src/compute_pair_local.cpp
index 57f15264f0..6118243ab3 100644
--- a/src/compute_pair_local.cpp
+++ b/src/compute_pair_local.cpp
@@ -298,16 +298,16 @@ int ComputePairLocal::compute_pairs(int flag)
ptr[n] = eng;
break;
case FORCE:
- ptr[n] = sqrt(rsq) * fpair;
+ ptr[n] = sqrt(rsq) * fpair * directionCorrection;
break;
case FX:
- ptr[n] = delx * fpair;
+ ptr[n] = delx * fpair * directionCorrection;
break;
case FY:
- ptr[n] = dely * fpair;
+ ptr[n] = dely * fpair * directionCorrection;
break;
case FZ:
- ptr[n] = delz * fpair;
+ ptr[n] = delz * fpair * directionCorrection;
break;
case PN:
ptr[n] = pair->svector[pindex[n]];