NeighborListBuffer¶
- class hoomd.md.tune.NeighborListBuffer(self, trigger: hoomd.trigger.Trigger, nlist: hoomd.md.nlist.NeighborList, solver: hoomd.tune.solve.Optimizer, maximum_buffer: float)¶
Optimize neighbor list buffer size for maximum TPS.
Tip
Direct instantiation of this class requires a
hoomd.tune.Optimizer
that determines how move sizes are updated. This class also provides class methods to create aNeighborListBuffer
tuner with built-in solvers; seeNeighborListBuffer.with_grid
andNeighborListBuffer.with_gradient_descent
.- Parameters:
trigger (hoomd.trigger.trigger_like) –
Trigger
to determine when to run the tuner.nlist (hoomd.md.nlist.NeighborList) – Neighbor list instance to tune.
solver (
hoomd.tune.solve.Optimizer
) – A solver that tunes the neighbor list buffer to maximize TPS.maximum_buffer (float) – The largest buffer value to allow.
minimum_buffer (
float
, optional) – The smallest buffer value to allow (defaults to 0).
- trigger¶
Trigger
to determine when to run the tuner.- Type:
- solver¶
A solver that tunes the neighbor list buffer to maximize TPS.
Warning
When using with a
hoomd.device.GPU
device, kernel launch parameter autotuning can prevent convergence. Run the simulation for 25,000 steps before adding the tuner to allow the autotuning to converge first results in better TPS optimization.Note
NeighborListBuffer.with_grid
generally performs better thanNeighborListBuffer.with_gradient_descent
due to the stocastic nature of TPS.- property best_buffer_size¶
The buffer size corresponding to
max_tps
during tuning.(
Loggable
: category=”scalar”)- Type:
- property final_bin¶
Boundaries of grid search optimization.
Property is only available when a
hoomd.tune.GridOptimizer
is used, and tuning is finished. Otherwise, the property isNone
.
- property tuned¶
Whether the neighbor list buffer is considered tuned.
The tuner is considered tune when the specified solver returns
True
when solving twice consecutively. Seehoomd.tune
for more information on tuning criteria.- Type:
- classmethod with_gradient_descent(trigger: Trigger | int, nlist: NeighborList, maximum_buffer: float, minimum_buffer: float = 0.0, alpha: Variant | float = hoomd._hoomd.VariantRamp, kappa: ndarray | None = (0.33, 0.165), tol: float = 1e-05, max_delta: float | None = None)¶
Create a
NeighborListBuffer
with a gradient descent solver.See
hoomd.tune.solve.GradientDescent
for more information on the solver.- Parameters:
trigger (hoomd.trigger.trigger_like) –
Trigger
to determine when to run the tuner.nlist (hoomd.md.nlist.NeighborList) – Neighbor list buffer to maximize TPS.
maximum_buffer (float) – The largest buffer value to allow.
minimum_buffer (
float
, optional) – The smallest buffer value to allow (defaults to 0).alpha (
hoomd.variant.variant_like
, optional) – Number between 0 and 1 or variant used to dampen the rate of change in x (defaults tohoomd.variant.Ramp(1e-5, 1e-6, 0, 30)
).alpha
scales the corrections to x each iteration. Larger values ofalpha
lead to larger changes while aalpha
of 0 leads to no change in x at all.kappa (
numpy.ndarray
offloat
, optional) – A NumPy array of floats which are weight applied to the last \(N\) of the gradients to add to the current gradient as well, where \(N\) is the size of the array (defaults to(0.33, 0.165)
).tol (
float
, optional) – The absolute tolerance for convergence of y (defaults to 1e-5).max_delta (
float
, optional) – The maximum iteration step allowed (defaults toNone
which does not limit step size).
Note
Given the stocasticity of TPS, a non none
kappa
is recommended.Tip
For better convergence choose an alpha in the range of 0.01 divided by the expected order of magnitude of the TPS. The default value assumes a TPS in the thousands.
Tip
When using the
hoomd.tune.solve.GradientDescent
, optimization is improved by starting at lower buffer values, as this has the steepest gradient.
- classmethod with_grid(trigger: Trigger | int, nlist: NeighborList, maximum_buffer: float, minimum_buffer: float = 0.0, n_bins: int = 5, n_rounds: int = 1)¶
Create a
NeighborListBuffer
with ahoomd.tune.GridOptimizer
.- Parameters:
trigger (hoomd.trigger.trigger_like) –
Trigger
to determine when to run the tuner.nlist (hoomd.md.nlist.NeighborList) – Neighbor list buffer to maximize TPS.
maximum_buffer (float) – The largest buffer value to allow.
minimum_buffer (
float
, optional) – The smallest buffer value to allow (defaults to 0).n_bins (
int
, optional) – The number of bins in the range to test (defaults to 5).n_rounds (
int
, optional) – The number of rounds to perform the optimization over (defaults to 1).
Note
Using this method adds another attribue
final_bin
which gives the final bin boundaries after tuning forn_rounds
.