How to prevent particles from moving

MD simulations

Omit the stationary particles from the filter (or filters) that you provide to your integration method (or methods) to prevent them from moving in MD simulations. For example:

import hoomd

simulation = hoomd.util.make_example_simulation()

# Select mobile particles with a filter.
stationary_particles = hoomd.filter.Tags([0])
mobile_particles = hoomd.filter.SetDifference(hoomd.filter.All(),
                                              stationary_particles)

# Integrate the equations of motion of the mobile particles.
langevin = hoomd.md.methods.Langevin(filter=mobile_particles, kT=1.5)
simulation.operations.integrator = hoomd.md.Integrator(dt=0.001,
                                                       methods=[langevin])

simulation.run(100)

HPMC simulations

To prevent a subset of particles from moving in HPMC simulations:

  1. Use different types for stationary and mobile particles.

  2. Set the move sizes of the stationary type to 0.

  3. Set the shape of the stationary type accordingly.

For example:

import hoomd

# Step 1: Use different types for stationary and mobile particles.
simulation = hoomd.util.make_example_simulation(
    particle_types=['A', 'A_no_motion'])

hpmc_ellipsoid = hoomd.hpmc.integrate.Ellipsoid()
hpmc_ellipsoid.shape['A'] = dict(a=0.5, b=0.25, c=0.125)

# Step 2: Set the move sizes of the stationary type to 0.
hpmc_ellipsoid.d['A_no_motion'] = 0
hpmc_ellipsoid.a['A_no_motion'] = 0

# Step 3: Set the shape of the stationary type accordingly.
hpmc_ellipsoid.shape['A_no_motion'] = hpmc_ellipsoid.shape['A']

simulation.operations.integrator = hpmc_ellipsoid

simulation.run(100)