DensityProfile¶
- 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.
- Parameters:
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 considereddirection_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
- data()¶
Return the density profile.
- zValues()¶
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('alumina_trajectory.nc')[-1]
# Calculate the mass density profile along the A-vector of the cell.
density_profile = DensityProfile(md_trajectory,
direction_index=0)
# Get the mass density in gram/ccm and the positions of the bin centers.
mass_density = density_profile.data().inUnitsOf(kiloGram/Meter**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)')
pylab.legend()
pylab.show()