[ENHANCEMENT] change correlation function so that the number of configurations used to determine the average is the same for all times
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.
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.
Jobs to check
Dynamics
- [x] Angular correlation #444
- [x] CurrentCorrleationFunction #566
- [x] DOS #444
- [ ] GeneralAutoCorrelationFunction
- [x] MSD #444
- [ ] OrderParameter
- [x] PACF #444
- [x] VACF #444
Structure
- [x] AreaPerMolecule
- [x] DensityProfile
- [x] Eccentricity
- [x] MolecularTrace
- [x] RadiusOfGyration
- [x] RootMeanSquareDeviation
- [x] RootMeanSquareFluctuation
- [x] SolventAccessibleSurface
- [x] Voronoi
- [x] CoordinationNumber
- [x] PairDistributionFunction
- [x] StaticStructureFactor
- [x] XRayStaticStructureFactor
Scattering
- [x] DynamicCoherentStructureFactor #467
- [x] DynamicIncoherentStructureFactor #456
- [x] ElasticIncoherentStructureFactor
- [x] GuassianDynamicIncoherentStructureFactor #456
- [x] NeutronDynamicStructureFactor
- [x] StructureFactorFromScatteringFunction
Thermodynamics
- [x] Density
- [x] Temperature
Infrared
- [x] Infrared #449
- [x] DipoleAutoCorrelationFunction #449
Virutal Instruments
- [x] McStasVirtualInstruments
Update Documentation
- [x] Updated documentation
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
After
DOS is much cleaner as a result. Although overall shape of the DOS is the same.
Before
After
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.