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.Optimizerthat determines how move sizes are updated. This class also provides class methods to create aNeighborListBuffertuner with built-in solvers; seeNeighborListBuffer.with_gridandNeighborListBuffer.with_gradient_descent.- Parameters:
trigger (hoomd.trigger.trigger_like) –
Triggerto 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¶
Triggerto 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.GPUdevice, 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_gridgenerally performs better thanNeighborListBuffer.with_gradient_descentdue to the stocastic nature of TPS.- property best_buffer_size¶
The buffer size corresponding to
max_tpsduring tuning.(
Loggable: category=”scalar”)- Type:
- property final_bin¶
Boundaries of grid search optimization.
Property is only available when a
hoomd.tune.GridOptimizeris 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
Truewhen solving twice consecutively. Seehoomd.tunefor 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
NeighborListBufferwith a gradient descent solver.See
hoomd.tune.solve.GradientDescentfor more information on the solver.- Parameters:
trigger (hoomd.trigger.trigger_like) –
Triggerto 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)).alphascales the corrections to x each iteration. Larger values ofalphalead to larger changes while aalphaof 0 leads to no change in x at all.kappa (
numpy.ndarrayoffloat, optional) – A NumPy array of floats which are weight applied to the last of the gradients to add to the current gradient as well, where 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 toNonewhich does not limit step size).
Note
Given the stocasticity of TPS, a non none
kappais 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
NeighborListBufferwith ahoomd.tune.GridOptimizer.- Parameters:
trigger (hoomd.trigger.trigger_like) –
Triggerto 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_binwhich gives the final bin boundaries after tuning forn_rounds.