help defining my own computation


I am just getting started on LAMMPS and was looking for some help on a (probably simple) question. I am trying to define my own computation during a simulation executed every 100 time steps. I initialize a system of 1000 atoms at random positions in a large box. Say the ith atom has initial position r_0^i. Then at each 100th time step, I want to compute (1/1000) *\sum_{i=1}^1000 |r_t^i - r_0^i|^4.

I have tried using the command compute X all property/atom x, to obtain the x-coordinate for each atom, and similar commands for the other coordinates. I don’t understand the syntax on how I should then perform algebraic operations on the coordinates I recorded. Nor do I see how I should average over the 1000 atoms.

Do you have any recommendations on what I could try? Or maybe where a good place to look would be? I tried reading through the documentation but it didn’t help. Though I could have been looking at the wrong command.

Many thanks,

This ought to be straightforward with a compute reduce, compute reduce ave already performs averaging over the atoms.

The only thing left is to feed it a suitable per-atom variable that calculates r(t) - r_0, which is simple enough if you have stored r_0 with a fix store/state.
Check the docs for compute reduce, fix store/state and variable atom.