ISISNeutronMuon / MDANSE

MDANSE: Molecular Dynamics Analysis for Neutron Scattering Experiments
https://www.isis.stfc.ac.uk/Pages/MDANSEproject.aspx
GNU General Public License v3.0
21 stars 5 forks source link

[ENHANCEMENT] change correlation function so that the number of configurations used to determine the average is the same for all times #435

Open ChiCheng45 opened 4 months ago

ChiCheng45 commented 4 months ago

Is your feature request related to a problem? Please describe. Currently, the correlation calculation is done so that the number of configurations it averages over is different for different times $t_0 + \Delta t$. This is usually why we see slightly larger correlations at the large $t_0 + \Delta t$.

For example the autocorrelation of 1 1 2 3

t_0 - averages over 4 configurations

1 1 2 3
1 1 2 3

t_1 - averages over 3 configurations

  1 1 2 3
1 1 2 3

t_2 - averages over 2 configurations

    1 1 2 3
1 1 2 3

t_3 - averages over 1 configuration

      1 1 2 3
1 1 2 3

Describe the solution you'd like The trajectory should be halved or some other fraction and then correlated with the full trajectory.

E.g. with the 1 1 2 3 trajectory

t_0

1 1
1 1 2 3

t_1

  1 1
1 1 2 3

t_2

    1 1
1 1 2 3

Although the number of steps $t_0 + \Delta t$ decreases and the number of configurations they average over is smaller for some times, they all average over the same number of configurations. This can be offset by running longer MD simulations. With the old scheme, you will probably always see some spuriously large correlations at the large $t_0 + \Delta t$ time no matter how long you run the MD simulation for.

Describe alternatives you've considered A truncation procedure could be done. This would be similar in the end but I think it is preferable to use the above since it means the same number of configurations are used for each time step. Additionally, the proposed method is similar to the correlation function defined in mcquarrie statistical mechanics.

image

You see here that the window is of a fixed size (before taking the limit). The truncation procedure always has smaller sized windows at a large time leading to an asymmetry.

Additional context Here is an example PACF from #212. We can see that the correlation spuriously increases at the very end. image

Jobs to check

Dynamics

Structure

Scattering

Thermodynamics

Infrared

Virutal Instruments

Update Documentation

ChiCheng45 commented 4 months ago

I've tested the idea out and I think this is an improvement. Here I use the long DLPOLY water trajectory and for the new scheme I use 1/2 trajectory correlated with the full trajectory.

Velocity autocorrelation is more well-behaved for long times.

Before image

After image

DOS is much cleaner as a result. Although overall shape of the DOS is the same.

Before image

After image

MBartkowiakSTFC commented 4 months ago

Looks good. Should we give the users a choice of how long the trajectory segment will be? For very expensive, slow simulations they may want to use as much as possible, but in most cases the noise reduction demonstrated here will have the priority.