# VelocityDistribution¶

class VelocityDistribution(md_trajectory, start_time=None, end_time=None, maximum_velocity=None, resolution=None, atom_selection=None, time_resolution=None, info_panel=None)

Class for calculating the velocity distribution of an MD simulation.

Parameters: md_trajectory (MDTrajectory | AtomicConfiguration) – The MDTrajectory or configuration to calculate the velocity distribution. 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 maximum_velocity (PhysicalQuantity of type length/time) – Upper limit of considered velocities. Default: the maximum velocity of the trajectory resolution (PhysicalQuantity of type length/time.) – The bin size, which determines the resolution of the histogram. Default: 0.001 * Angstrom / fs 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()

Return the velocity distribution histogram.

velocities()

Return the velocity values associated with the histogram.

## Usage Examples¶

Load an MDTrajectory and calculate the VelocityDistribution:

md_trajectory = nlread('alumina_trajectory.nc')[-1]

v_distribution = VelocityDistribution(md_trajectory)

# Get the bin_centers and the histogram of the velocity distribution.
velocities = v_distribution.velocities().inUnitsOf(Ang/fs)
histogram  = v_distribution.data()

# Plot the data using pylab.
import pylab

pylab.bar(velocities, histogram, label='Velocity distribution', width=0.001)
pylab.xlabel('v (Ang/fs)')
pylab.ylabel('Histogram')
pylab.legend()

pylab.show()


velocity_distribution.py

## Notes¶

By default, all elements are taken into account.

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.