VelocityAutocorrelation¶
- 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.
- Parameters:
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
- data()¶
- Returns:
The normalized velocity autocorrelation values.
- Return type:
array
- times()¶
Return the time values.
Usage Examples¶
Load an MDTrajectory and calculate the VelocityAutocorrelation function of the oxygen atoms in the simulation:
md_trajectory = nlread('alumina_trajectory.nc')[-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 = 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)')
pylab.ylabel('VACF(t)')
pylab.legend()
pylab.show()
Notes¶
The VelocityAutocorrelation function is normalized to one at \(t=0\) and weighted with the atomic masses, i.e.
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
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.