# velocity auto correlation function

Dear Lammps users,

I'd like to calculated velocity auto correlation function however
don't understand how to keep initial velocities
The straightforward script gives me 1. It always substitute v0 to
current velocity.

#Part of the script:

reset_timestep 0

variable vx0 atom vx
variable vy0 atom vy
variable vz0 atom vz

variable V0X2 atom (v_vx0*v_vx0)
variable V0Y2 atom (v_vy0*v_vy0)
variable V0Z2 atom (v_vz0*v_vz0)

compute J0X2 all reduce sum v_V0X2
compute J0Y2 all reduce sum v_V0Y2
compute J0Z2 all reduce sum v_V0Z2

run 1

reset_timestep 0

variable VX2 atom (v_vx0*vx)
variable VY2 atom (v_vy0*vy)
variable VZ2 atom (v_vz0*vz)

compute JX2 all reduce sum v_VX2
compute JY2 all reduce sum v_VY2
compute JZ2 all reduce sum v_VZ2

variable ACF equal (c_JX2+c_JY2+c_JZ2)/(c_J0X2+c_J0Y2+c_J0Z2)

thermo_style custom step temp press etotal pe v_ACF vol

run 50

I would appreciate any help.

Best,

German Samolyuk

This topic has been discussed before on the mail
list. You could use fix store/state to store an
old velocity (with each atom, which is required).
But doing a VACF more generally requires many
(e.g. 100s) of old velocities per atom. Which means
the atoms have to carry them around as they migrate
and it requires big storage. So it's not necessarily
a good idea. Probably better via post processing.

That said, a per-atom version of fix ave/correlate
could be written to do this. I'll probably do it at
some point and let users use it abusively.

Steve