Lammps command:compute stress/atom

When I use compute stress/atom command to decompose per-atom stress tensor into kinetic energy term and the virial term,I just simply build three atoms without bond in a simulation box to compute every atom stress tensor,According to the formula given on the manual of the figure below, I output the atoms information x,y,z,vx, vy,vz,fx,fy,fz to verify the formula,but something went wrong,I have the following questions:1.When I only build 2 atoms without bond,I can verify the sxx=-mvxmvx-0.5(r1xf1x+r2x*f2x),but it’s wrong when there are three atoms,Is the force of the formula on the official website the component of each item?2.The original words on the manual “ r1 and r2 are the positions of the 2 atoms in the pairwise interaction, and F1 and F2 are the forces on the 2 atoms resulting from the pairwise interaction.” Is r1 the coordinate? Is F1 the resultant force or the component force?

It won’t work like that. The expression you are looking at is for the forces for individual interactions (e.g. for each interacting pair of atoms), while the force you are outputting is the sum of all tallied pairwise forces. That is why the results match for a pair of atoms but not beyond. Please note in the source code of pair styles the calls to ev_tally() function in the Pair class. Those will tally the (atomic) stress contributions for each pair of atoms from positions and force between the two atoms. The ev_tally() function will then process the force into the vector components you see in the manual and determine the stress tensor components from that (if that property is requested, i.e. vflag_atom is set).