MPCD system snapshot


MPCD system data


Creates an empty MPCD system snapshot


MPCD data structures


MPCD data is currently initialized in a secondary step from HOOMD using a snapshot interface. Even if only MPCD particles are present in the system, an empty HOOMD system must first be created. Once the HOOMD system has been initialized (see hoomd.init), an MPCD snapshot can be created using:

>>> snap =

The MPCD system can then initialized from the snapshot (see hoomd.mpcd.init):

>>> mpcd.init.read_snapshot(snap)

Because the MPCD data is stored separately from the HOOMD data, special care must be taken when using certain commands that operate on the HOOMD system data. For example, the HOOMD box size is not permitted to be changed after the MPCD particle data has been initialized (see hoomd.mpcd.init), so any resizes or replications of the HOOMD system must occur before then:

>>> hoomd_sys.replicate(2,2,2)
>>> snap.replicate(2,2,2)
>>> mpcd_sys = mpcd.init.read_snapshot(snap)
>>> hoomd_sys.replicate(2,1,1)

Similarly, box_resize will also fail after the MPCD system has been initialized.

During a simulation, the MPCD particle data can be read, modified, and restored using take_snapshot() and restore_snapshot():

snap = mpcd_sys.take_snapshot()
# modify snapshot


MPCD supports MPI parallelization through domain decomposition. The MPCD data in the snapshot is only valid on rank 0, and is distributed to all ranks through the snapshot collective calls.

Particle data

All MPCD particle data is accessible through the particles snapshot property. The size of the MPCD particle data N can be resized:

>>> snap.particles.resize(200)
>>> print(snap.particles.N)

Because the number of MPCD particles in a simulation is large, fewer particle properties are tracked per particle than for standard HOOMD particles. All particle data can be set as for standard snapshots using numpy arrays. Each particle is assigned a tag from 0 to N (exclusive) that is tracked. The following particle properties are recorded:

  • Particle positions are stored as an Nx3 numpy array:

    >>> snap.particles.position[4] = [1., 2., 3.]
    >>> print(snap.particles.position[4])
    [ 1. 2. 3.]

    By default, all positions are initialized with zeros.

  • Particle velocities can similarly be manipulated as an Nx3 numpy array:

    >>> snap.particles.velocity[2] = [0.5, 1.5, -0.25]
    >>> print(snap.particles.velocity[2])
    [0.5 1.5 -0.25]

    By default, all velocities are initialized with zeros. It is important to reassign these to a sensible value consistent with the temperature of the system.

  • Each particle can be assigned a type (a name for the kind of the particle). First, a list of possible types for the system should be set:

    >>> snap.particles.types = ['A','B']

    Then, an index is assigned to each particle corresponding to the type:

    >>> snap.particles.typeid[1] = 1 # B
    >>> snap.particles.typeid[2] = 0 # A

    By default, all particles are assigned a type index of 0, and no types are set. If no types are specified, type A is created by default at initialization.

  • All MPCD particles have the same mass, which can be accessed or set:

    >>> snap.particles.mass = 1.5
    >>> print(snap.mass)

    By default, all particles are assigned unit mass.

Creates an empty MPCD system snapshot


N (int) – Number of MPCD particles in the snapshot


MPCD snapshot

Return type

snap (


snap =
snap =


The HOOMD system must be initialized before the MPCD snapshot is taken, or an error will be raised.


MPCD system snapshot


sys_snap (object) – The C++ representation of the system data snapshot

The MPCD system snapshot must be initialized after the HOOMD system.

This class is not intended to be initialized directly by the user, but rather returned by make_snapshot() or take_snapshot().

property particles

MPCD particle data snapshot

replicate(nx=1, ny=1, nz=1)

Replicate the MPCD system snapshot

  • nx (int) – Number of times to replicate snapshot in x

  • ny (int) – Number of times to replicate snapshot in y

  • nz (int) – Number of times to replicate snapshot in z



This method is intended only to be used with prior to initialization of the MPCD system. The MPCD snapshot must be replicated to a size consistent with the system at the time of initialization. An error will be raised otherwise.


MPCD system data


sysdata (object) – C++ representation of the MPCD system data

This class is not intended to be initialized by the user, but is the result returned by hoomd.mpcd.init.


Replaces the current MPCD system state


snapshot ( – MPCD system snapshot

The MPCD system data is replaced by the contents of snapshot.


snap = mpcd_sys.take_snapshot()
snap.particles.typeid[2] = 1

Set parameters of the MPCD system


cell (float) – Edge length of an MPCD cell.

Every MPCD system is given a cell list for binning particles (see mpcd.collide). The size of the cell list sets the length scale over which hydrodynamic interactions are resolved. By default, the system is given a cell size of 1.0, i.e., the cell sets the unit of length, which is typical for most use cases. If your simulation has a different fundamental unit of length, you can adjust the cell size, but be aware that this will also change the fluid properties.


Takes a snapshot of the current state of the MPCD system


particles (bool) – If true, include particle data in snapshot


snap = mpcd_sys.take_snapshot()