How to choose the neighbor list buffer distance#

Set the neighbor list buffer distance ( to maximize the performance of your simulation. The neighbor list recomputes itself more often when buffer is small, and the pair force computation takes more time when buffer is large. There is an optimal value between the extremes that strongly depends on system size, density, the hardware device, the pair potential, step size, and more. Test your specific model, change buffer and measure the performance to find the optimal. For example:

import hoomd

kT = 1.5
sample_steps = 1000

# Prepare a MD simulation.
device = hoomd.device.auto_select()
simulation = hoomd.Simulation(device=device)
simulation.state.thermalize_particle_momenta(filter=hoomd.filter.All(), kT=kT)

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

bussi =
constant_volume =,
simulation.operations.integrator =
    dt=0.001, methods=[constant_volume], forces=[lj])

# Complete GPU kernel autotuning before making sensitive timing measurements.
if isinstance(device, hoomd.device.GPU):
    while not simulation.operations.is_tuning_complete:

for buffer in [0, 0.05, 0.1, 0.2, 0.3]:
    neighbor_list.buffer = buffer
    device.notice(f'buffer={buffer}: TPS={simulation.tps:0.3g}, '

Example output:

buffer=0: TPS=212, num_builds=1001
buffer=0.05: TPS=584, num_builds=197
buffer=0.1: TPS=839, num_builds=102
buffer=0.2: TPS=954, num_builds=53
buffer=0.3: TPS=880, num_builds=37


Ensure that you run sufficient steps to sample many neighbor list builds to properly sample the amortized time spent per build.


Measure the optimal value of buffer in testing, then apply that fixed value in production runs to avoid wasting time at non-optimal values.

See also can automate this process.