mdtraj.density

mdtraj.density(traj, masses=None)[source]

Calculate the mass density of each frame in a trajectory.

Parameters:
  • traj (Trajectory) – An mdtraj trajectory.

  • masses (np.ndarray, optional, default=None) – If not None, use these masses when calculating the density. If None, then use the standard elemental masses associated with traj.topology.atoms.

Returns:

density_trace – The mass density of each frame.

Return type:

np.array, shape=(n_frames), dtype=float