# Does the sign of the shear vector components remain the same when i and j indices are swapped?

I noticed that the components of the shear vector describing contact properties change signs between two runs if the i and j indices are swapped. Such as the case below where I track the values of the shear vector between a specific pair of atoms for the 5000th timestep and the setup run of the 5000th timestep:

end of 5000th timestep (first run)
i 3124 j 3170 tagi 1471 tagj 1256  shear0 3.57807e-07 shear1 -3.44611e-06 shear2 3.66999e-06
beginning of setup phase of 5000th timestep (second run).
i 3131 j 3136 tagi 1256 tagj 1471  shear0 -3.57807e-07 shear1 3.44611e-06 shear2 -3.66999e-06


This makes sense for frictional forces (shear[0],[1] and [2] dependent effects) because the force is looked in the perspective of one atom over another but is it possible to keep the sign of some other components of the shear vector unchanged. My pair potential has a much larger shear vector with 10+ history-dependent components (than the default 3) and these terms describe the normal component of the force not the tangential.

I would like for these values to be unchanged by the change in sign and was wondering if anyone would happen to know how to do it?

Why would it ever not be the case that \mathbf{F}_{ji} = -\mathbf{F}_{ij}?

If a quantity is symmetric in ij then surely the correct way to calculate it will preserve that symmetry. For example, in every pairwise radial pair force you will find something like the following lines:

double dx, dy, dz, rsq;
...
dx = x[i][0] - x[j][0];
dy = x[i][1] - x[j][1];
dz = x[i][2] - x[j][2];
rsq = dx*dx + dy*dy + dz*dz;


You can verify both by inspection and by debugging that rsq is identical when i and j are interchanged.

yes totally agree with that. It is just that I store some contact level properties in the shear vector that are not responsible for force but for other calculations like energy. For example I store the work done by that contact force which is an integral that gets messed up if it all of a sudden appears with a different change in sign. It would be nice to keep these elements in the array unaffected by these changes.

You need a persistent 2D array to accumulate components by ij, and you need a programming mentor or collaborator. If this were your first question I’d say more, but you have been hammering away at this for over a year and, in my view, you need an intervention. Me not answering this question any further is, I hope, such an intervention (unless you have a specific question which indicates that you are reading the existing code together with an experienced programmer by your side and there is a particular aspect of source code, with line number, that you would like clarification on).