msd_layer_serial

Calculate the mean displacement (MD) and the mean squared displacement (MSD) of a given compound as function of its initial position.

Options

-f

Trajectory file. See supported coordinate formats of MDAnalysis. Important: This scripts requires an unwrapped trajectory! At least the selection compounds must be unwrapped in order to get the correct displacements. If you want to calculate center-of-mass displacements, the selection compounds need to be whole, too. You can use e.g. scripts.trajectory.unwrap_trj to unwrap a wrapped trajectory and make broken molecules whole.

-s

Topology file. See supported topology formats of MDAnalysis.

-o

Output filename pattern. There will be created seven output files:

  • OUTFILE_msd_layer.txt contains the total MSD.

  • OUTFILE_m[s]dx_layer.txt contains the x-component of the M[S]D.

  • OUTFILE_m[s]dy_layer.txt contains the y-component of the M[S]D.

  • OUTFILE_m[s]dz_layer.txt contains the z-component of the M[S]D.

If --nblocks is greater than one, seven additional files are created that contain the respective standard deviations.

-b

First frame to read from the trajectory. Frame numbering starts at zero. Default: 0.

-e

Last frame to read from the trajectory. This is exclusive, i.e. the last frame read is actually END - 1. A value of -1 means to read the very last frame. Default: -1.

--every

Read every n-th frame from the trajectory. Default: 1.

--nblocks

Number of blocks for block averaging. The trajectory will be split in NBLOCKS equally sized blocks, which will be analyzed independently, like if they were different trajectories. Finally, the average and standard deviation over all blocks will be calculated. Default: 1.

--restart

Number of frames between restarting points for calculating the MD and MSD. Must be an integer multiple of --every. Default: 100.

--sel

Selection string to select a group of atoms for the analysis. See MDAnalysis’ selection syntax for possible choices.

--com

{None, “group”, “segments”, “residues”, “fragments”}

If None, use the displacements of each individual atom in the selection group for the calculation of the M(S)D’s. Otherwise, use the center-of-mass displacements of the given compound. Compounds can be ‘group’ (the entire selection group), ‘segments’, ‘residues’, or ‘fragments’. Refer to the MDAnalysis’ user guide for an explanation of these terms. Default: None. TODO

-d

{“x”, “x”, “z”}

The spatial dimension in which to bin the displacements according to the initial position of the selection compounds. Default: "z".

--bin-num

Number of equidistant bins (not bin edges!) to use for discretizing the given spatial dimension. Binning always ranges from zero to the box length in the given spatial dimension. The bins are scaled with a possibly fluctuating simulation box. Default: 10.

--bins

Text file containing custom bin edges in Angstrom. Bin edges are read from the first column, lines starting with ‘#’ are ignored. The file must be formatted such that the bin edges can be read with the command numpy.loadtxt(BINFILE, usecols=0). Bins do not need to be equidistant. All bin edges must lie within the simulation box as obtained from the first frame read. The given bin edges are sorted ascending order and and duplicate bin edges are removed. --bins takes precedence over --bin-num.

--debug

Run in debug mode.

See also

scripts.dynamics.msd_layer_parallel

A parallelized version of this script

scripts.dynamics.plot_msd_layer

Plot the MSD as function of diffusion time for different initial particle positions

scripts.dynamics.plot_msd_layer_heatmap

Plot the MSD as function of the initial particle position and the diffusion time in a heatmap

scripts.dynamics.plot_msd_layer_cross_section_at_constant_time

Plot (one component of) the MSD as function of the initial particle position at a constant diffusion time(s)

scripts.dynamics.plot_msd_layer_cross_section_xyz_at_constant_time

Plot the x-, y- and z-component of the MSD as function of the initial particle position at a constant diffusion time

scripts.dynamics.plot_msd_layer_cross_section_xyz_at_constant_msd

Plot the diffusion time at which the x-, y- and z-component of the MSD reach a certain value as function of the initial particle position

Notes

The MD is computed, because it might happen that the net-displacement of compounds in a bin is not zero. To account for non-zero net-displacements, the square of the MD should be subtracted from the MSD to calculate the displacement variance:

\[\sigma_r^2 = \langle r^2 \rangle - \langle r \rangle^2\]

Functions

msd_layer

Calculate the mean displacement (MD) and the mean squared displacement (MSD) as function of the particle's initial position.

parse_user_input

Parse command-line input using argparse.