I dont know much about autocorrelation functions in the general sense, but I recently have had to do some calculations of self diffusion coefficients via a mathematical expression involving the velocity autocorrelation function, specifically. For a first moment, I tried to reason myself the meaning behind that function, which, in principle, could maybe be regarded as a mathematical definition per se in order to quantify something useful for a given context. I can give you my go on the conclusions I got to. I am also gonna give the example for an atomic system (i.e. some compounds whose structural unit is an atom and not a molecule or ion). If it is a molecular or ionic compound, just exchange the word “atom” in the text below by “molecule” or “ion” accordingly.
If you think about it, the velocity autocorrelation function is a scalar function of time given by the dot product between the velocity vector at time 0 (arbitrarily chosen reference), v(t=0), with the velocity vector at any point,v(t), averaged over all atoms. But dont think about the averaging over all atoms just yet, but rather about its meaning for a single atom moving around. Regardless if we are in the solid, liquid or gas state, that given atom will be moving around according to the force it experiences from its interactions with its neighborhood. Now, we can split the observation of its motion into several time intervals. Within a given time interval, the features in the trajectory this atom has are not so dissociated from its starting point: what I mean is that the direction and even the magnitude of the velocity vector probably didnt change that drastically just yet (same for the force vector, even, to some extent). Now think about what a dot product between two whatever vectors, w and u, correspond to: it is equivalent of multiplying (i) the magnitude of u, (ii) the magnitude of v and (iii) the cosine of the angle between them.* In other “words”, w.u = mod(u) x mod(v) x cos(theta), with theta being the angle between u and w. It is then obvious that at times close to your t = 0 reference, the velocity vector at a given time t, v(t), is somewhat similar to what it was at t=0 (i.e. its magnitude and direction has not changed drastically). Moreover, if your atom collides (not necessarily in the literal sense) with something that forces it to travel in the opposite’ish direction, we will start having an angle theta between [90, 180] deg. (think about it), and thus cos(theta) becomes negative, causing the whole dot product to be negative at these times. This is why sometimes (but not always, since the atom may not be forced back into the opposite’ish direction), the velocity autocorrelation function can be negative. It’s not an “official” source, but you may find this useful to see the possible cases you can have for the motion of the atom and its consequence in the velocity autocorrelation function: Democritus: The Velocity Autocorrelation Function . Now, naturally, as a lot of time passes, the atom already interacted with its neighborhood in such a way that it is in a trajectory that is not even correlated with the one we were first observing within that time interval that features the t = 0 of your choice: e.g. it experienced forces that sent it back into directions that are not correlated with that “initial” one. This is the case especially in a liquid or a gas, but maybe not so much in a crystalline solid as (i) the atom/molecule is stuck in a cage (i.e. negligible translational motion) and (ii) there are specific phonons going on (PS: pls confirm that bit bcs I am not sure if being a crystalline solid means you are always in a “fixed” trajectory-ish and so correlation always exists). So, excluding the xtalline solid case, the dot product v(t=0).v(t) can be whatever as a result since the magnitude and direction of v(t) can be whatever relative to v(t=0). As this holds for all atoms/molecules in the system and is somewhat random for each individual atom depending on its particular motion, you should have a random distribution of values for the dot product whose average must be centerred around 0’ish (I guess this part is intuitive?!) at all times t provided that you have a sufficiently large number of atoms in your system: this is why the velocity autocorrelation function, which is an average over all atoms, tend to 0 at large time instants (and ofc noise can perfectly well exist).
Now, from the velocity autocorrelation function to the self diffusion coefficient, I remember seeing (but I confess I didnt read through carefully) a proof of how the former function and a mean-square-displacement-related-expression are mathematically related in the book of Daan Frenkel and Berend Smit (https://www.sciencedirect.com/book/monograph/9780122673511/understanding-molecular-simulation). From there, you can understand how the self diffusion coefficient can be calculated from the velocity autocorrelation function. I had vibes that the proof was good (as in, I was able to understand it, which is not always the case when I read derivation of expressions
).
*You can find the mathematical proof for this in an analytical geometry book.
I hope this helps with the theoretical part ! Then, from the expression of the function, writing a code to calculate it is not exactly very challenging….. in fact you dont need to do it yourself if you dont want it as LAMMPS has commands to compute the velocity autocorrelation function both for atoms and for molecules (i.e. suitable for atomic and molecular compounds) 