How to continuously vary potential parameters#

To continuously vary potential parameters (and other non-variant parameters) during a HOOMD-blue simulation:

  1. Write a class that subclasses hoomd.custom.Action and implements the desired change as a function of timestep in act.

  2. Create a hoomd.update.CustomUpdater and pass an instance of your action.

  3. Add the updater to the simulation operations.

For example:

import hoomd

# Preparation: Create a MD simulation.
simulation = hoomd.util.make_example_simulation()

lj =
lj.params[('A', 'A')] = dict(epsilon=1.0, sigma=1.0)
lj.r_cut[('A', 'A')] = 2.5

langevin =, kT=1.5)
simulation.operations.integrator =,

# Step 1: Subclass hoomd.custom.Action.
class LJParameterModifer(hoomd.custom.Action):

    def __init__(self, lj):
        self.lj = lj

    def act(self, timestep):
        epsilon = 1.0 + 4.0 * timestep / 1e6
        self.lj.params[('A', 'A')] = dict(epsilon=epsilon, sigma=1)

# Step 2: Create a hoomd.update.CustomUpdater
lj_parameter_modifier = LJParameterModifer(lj)
lj_parameter_updater = hoomd.update.CustomUpdater(
    trigger=hoomd.trigger.Periodic(1), action=lj_parameter_modifier)

# Step 3: Add the updater to the operations