class VelocityAutocorrelation(md, start_time=None, end_time=None, atom_selection=None, time_resolution=None, info_panel=None)

Class for calculating the velocity auto-correlation function of an MD simulation.

  • md_trajectory (MDTrajectory | AtomicConfigution) – The MDtrajectory or configuration to calculate the velocity autocorrelation for.
  • start_time (PhysicalQuantity of type time) – The start time.
    Default: 0.0 * fs
  • end_time (PhysicalQuantity of type time) – The end time.
    Default: The last time frame
  • atom_selection (PeriodicTableElement | str | list of ints) – Only include contributions from this selection. The atoms can be selected by element i.e. PeriodicTableElement, tag or a list of atomic indices.
    Default: All atoms.
  • time_resolution (PhysicalQuantity of type time) – The time interval between snapshots in the MD trajectory that are included in the analysis.
  • info_panel (InfoPanel (Plot2D)) – Info panel to show the calculation progress.
    Default: No info panel
Returns:The normalized velocity autocorrelation values.
Return type:array

Return the time values.

Usage Examples

Load an MDTrajectory and calculate the VelocityAutocorrelation function of the oxygen atoms in the simulation:

md_trajectory = nlread('')[-1]

# Calculate the velocity autocorrelation function of the oxygen atoms.
vacf = VelocityAutocorrelation(md_trajectory, atom_selection=Oxygen)

# Get the time and autocorrelation values.
times     = vacf.times().inUnitsOf(fs)
vacf_data =

# Plot the data using pylab.
import pylab

pylab.plot(times, vacf_data,
           label='Velocity autocorrelation of the oxygen atoms')
pylab.xlabel('t (fs)')


The VelocityAutocorrelation function is normalized to one at \(t=0\) and weighted with the atomic masses, i.e.

\[vacf(t) = \frac{ \sum_i \left \langle m_i \mathbf{v}_i(t) \cdot \mathbf{v}_i(0) \right \rangle } {\sum_i \left \langle m_i \mathbf{v}_i^2 \right \rangle } \, .\]

In practice, the average \(<...>\) runs over all selected atoms \(i\) in the trajectory, and an additional average over simulation time is carried out to improve the statistical sampling. That means for a given time difference \(t\) all image pairs that are separated by \(t\) are taken into account in the average, as

\[\left \langle m_i \mathbf{v}_i(t) \cdot \mathbf{v}_i(0) \right \rangle = \frac{1}{(t_{max} - t)} \sum_{t'=0}^{t_{max}-t} \mathbf{v}_i(t' + t) \cdot \mathbf{v}_i(t')\]

By default, all elements are taken into account, but a specified selection can be given as well. The atom_selection parameter accepts an element, a tag name, or a list of indices to select atoms for the velocity distribution. This can be useful, e.g. in the presence of constraints as constrained atoms should be excluded in this analysis.