class DensityProfile(md_trajectory, start_time=None, end_time=None, resolution=None, atom_selection=None, direction_index=None, time_resolution=None, info_panel=None)

Constructor for the DensityProfile object.

  • md_trajectory (MDTrajectory | AtomicConfiguration) – The MDTrajectory or configuration to calculate the density profile for.
  • start_time (PhysicalQuantity of type time) – The start time.
    Default: 0.0 * fs
  • end_time (PhysicalQuantity of the type time) – The end time.
    Default: the last time frame.
  • resolution (PhysicalQuantity of type length) – The bin size, which determines the resolution of the profile.
    Default: 2.0 * Angstrom
  • atom_selection (PeriodicTableElement | str | list of ints) – Only include contributions from this atom selection. The atoms can be selected by element i.e. PeriodicTableElement, tag or a list of atomic indices.
    Default: All elements are considered
  • direction_index (int) – The index of the cell vector along which the profile should be calculated. Can only be an element of [0, 1, 2].
    Default: 2
  • 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

Return the density profile.


Return the positions of the bins associated with the density profile.

Usage Examples

Load an MDTrajectory and calculate the mass density profile along the A-vector of the cell:

md_trajectory = nlread('')[-1]

# Calculate the mass density profile along the A-vector of the cell.
density_profile = DensityProfile(md_trajectory,

# Get the mass density in gram/ccm and the positions of the bin centers.
mass_density =**3)/1000.0
bin_centers  = density_profile.zValues().inUnitsOf(Angstrom)

# Plot the data using pylab.
import pylab

pylab.plot(bin_centers, mass_density,
           label='Mass density of alumina along A-vector')
pylab.xlabel('a (Angstrom)')
pylab.ylabel('d(a) (g/cm**3)')