Overview Mean-squared displacement.


Deprecated analyzers.

class, groups, period, header_prefix='', r0_file=None, overwrite=False, phase=0)

Mean-squared displacement.

  • filename (str) – File to write the data to.
  • groups (list) – List of groups to calculate the MSDs of.
  • period (int) – Quantities are logged every period time steps.
  • header_prefix (str) – (optional) Specify a string to print before the header.
  • r0_file (str) – hoomd_xml file specifying the positions (and images) to use for \(\vec{r}_0\).
  • overwrite (bool) – set to True to overwrite the file filename if it exists.
  • phase (int) – When -1, start on the current time step. When >= 0, execute on steps where (step + phase) % period == 0.

Deprecated since version 2.0: will be replaced by a more general system capable of window averaging in a future release.

msd can be given any number of groups of particles. Every period time steps, it calculates the mean squared displacement of each group (referenced to the particle positions at the time step the command is issued at) and prints the calculated values out to a file.

The mean squared displacement (MSD) for each group is calculated as:

\[\langle |\vec{r} - \vec{r}_0|^2 \rangle\]

and values are correspondingly written in units of distance squared.

The file format is the same convenient delimited format used by :py:class`hoomd.analyze.log`.

msd is capable of appending to an existing msd file (the default setting) for use in restarting in long jobs. To generate a correct msd that does not reset to 0 at the start of each run, save the initial state of the system in a hoomd_xml file, including position and image data at a minimum. In the continuation job, specify this file in the r0_file argument to


msd ='msd.log', groups=[group1, group2],
                  period=100)[group1, group2, group3], period=1000,
            filename='msd.log', header_prefix='#')'msd.log', groups=[group1], period=10,
            header_prefix='Log of group1 msd, run 5\n')

A group variable (groupN above) can be created by any number of group creation functions. See group for a list.

By default, columns in the file are separated by tabs, suitable for importing as a tab-delimited spreadsheet. The delimiter can be changed to any string using :py:meth`set_params()`.

The header_prefix can be used in a number of ways. It specifies a simple string that will be printed before the header line of the output file. One handy way to use this is to specify header_prefix=’#’ so that gnuplot will ignore the header line automatically. Another use-case would be to specify a descriptive line containing details of the current run. Examples of each of these cases are given above.

If r0_file is left at the default of None, then the current state of the system at the execution of the command is used to initialize \(\vec{r}_0\).


Disable the analyzer.



Executing the disable command will remove the analyzer from the system. Any command executed after disabling an analyzer will not use that analyzer during the simulation. A disabled analyzer can be re-enabled with enable().


Enables the analyzer



See disable().


Change the parameters of the msd analysis

Parameters:delimiter (str) – New delimiter between columns in the output file (if specified).



Changes the period between analyzer executions

Parameters:period (int) – New period to set (in time steps)



While the simulation is running (, the action of each analyzer is executed every period time steps. Changing the period does not change the phase set when the analyzer was first created.