For the water research I've been doing, it is useful to get the velocity autocorrelation function, which gives the density of states of the system. Here is how I ended up doing it:
One of the things that always trips me up in LAMMPS is the difference between using variables created by the user (e.g.
vel_x above) and using variables LAMMPS provides (e.g.
step.) When using them in, for example, a
fix print, user-created variables must be wrapped in curly brackets, while the LAMMPS-provided variables must be wrapped in parens.