# Math operations on pair/local dist

Hello everybody.
I wanted to compute the trace of the dynamical matrix for a Lennard-Jones liquid argon system. Since I need to do this computation every n steps I wanted to implement the formula for only the trace instead of computing all the dynamical matrix and then extract in post processing the trace.
The derivatives of the lennard jonnes potential include some power law of the pair distances.
All the pair distances can be accessed with:
“compute rij all pair/local dist”
But if then I try to write something like:
"variable rijpowerlaw atom c_rij^(-14) -c_rij^(-8) "
"variable trace equal sum(rijpowerlaw) "
I receive “Mismatched compute in variable formula” due to the first line. The same error appears if I use “vector” or “equal” instead of atom.
Indeed I have read in the documentation variable command — LAMMPS documentation that local values can not be used as variable, but I don’t know how else could I write this operation. Is there any way to apply mathematical operation on local values? (Apart from compute reduce, which does not have power law)

Thank you in advance for any suggestion/advice.
Best regards,
Alfredo

The most straightforward way to approach this kind of problem would be to use dump local to write the data to a file and then post-process it. The LAMMPS input script is not meant to be a full featured programming language.

The next best option would be to try doing this through the LAMMPS python module.

The most efficient way (in case performance of the resulting computation matters) would be to make a copy of the dynamical_matrix command source code and adapt it for your needs.

Thank you for the response. Yes, indeed for the moment the easiest thing to do is apply the analytical formula in the post processing of the trajectory.
Now I was doing some tests with the Lennard jones potential, but surely if I want to use more complicated potential I will have to study how to modify the dynamical_matrix command to only compute the trace