hpmc.tune¶
Overview
Tunes HPMCIntegrator move sizes to targeted acceptance rate. |
Details
-
class
hoomd.hpmc.tune.
MoveSize
(trigger, moves, target, solver, types=None, max_move_size=None)¶ Tunes HPMCIntegrator move sizes to targeted acceptance rate.
For most common creation of a
MoveSize
tuner seeMoveSize.secant_solver
andMoveSize.scale_solver
respectively.- Parameters
trigger (hoomd.trigger.Trigger) –
Trigger
to determine when to run the tuner.moves (list[str]) – A list of types of moves to tune. Available options are ‘a’ and ‘d’.
target (float) – The acceptance rate for trial moves that is desired. The value should be between 0 and 1.
solver (
hoomd.tune.SolverStep
) – A solver that tunes move sizes to reach the specified target.types (list[str]) – A list of string particle types to tune the move size for, defaults to None which upon attaching will tune all types in the system currently.
max_translation_move (float) – The maximum value of a translational move size to attempt.
max_rotation_move (float) – The maximum value of a rotational move size to attempt.
-
trigger
¶ Trigger
to determine when to run the tuner.
-
target
¶ The acceptance rate for trial moves that is desired. The value should be between 0 and 1.
- Type
-
solver
¶ A solver that tunes move sizes to reach the specified target.
-
types
¶ A list of string particle types to tune the move size for, defaults to None which upon attaching will tune all types in the system currently.
Note
Limiting the maximum move sizes can lead to the inability to converge to the desired acceptance rate. Also, not limiting the move size can lead to move sizes that require the use of multiple periodic images to check for overlaps, especially in low density systems since the acceptance rate tends towards 1. Therefore, it is recommended to pick a moderate maximum move size for at least the translational moves to prevent requiring checking periodic images.
-
property
tuned
¶ Whether or not the moves sizes have converged to the desired acceptance rate.
- Type
-
classmethod
scale_solver
(trigger, moves, target, types=None, max_translation_move=None, max_rotation_move=None, max_scale=2.0, gamma=1.0, tol=0.01)¶ Create a
MoveSize
tuner with ahoomd.tune.ScaleSolver
.- Parameters
trigger (hoomd.trigger.Trigger) –
Trigger
to determine when to run the tuner.moves (list[str]) – A list of types of moves to tune. Available options are ‘a’ and ‘d’.
target (float) – The acceptance rate for trial moves that is desired. The value should be between 0 and 1.
types (list[str]) – A list of string particle types to tune the move size for, defaults to None which upon attaching will tune all types in the system currently.
max_translation_move (float) – The maximum value of a translational move size to attempt.
max_rotation_move (float) – The maximum value of a rotational move size to attempt.
gamma (float) – The value of gamma to pass through to
hoomd.tune.ScaleSolver
. Controls the size of corrections to the move size (larger values increase stability while increasing convergence time).tol (float) – The absolute tolerance to allow between the current acceptance rate and the target before the move sizes are considered tuned. The tolerance should not be too much lower than the default of 0.01 as acceptance rates can vary significantly at typical tuning rates.
-
classmethod
secant_solver
(trigger, moves, target, types=None, max_translation_move=None, max_rotation_move=None, gamma=0.8, tol=0.01)¶ Create a
MoveSize
tuner with ahoomd.tune.SecantSolver
.This solver can be faster than
hoomd.tune.ScaleSolver
, but depending on the system slightly less stable. In general, with the default value of gamma this should not be a problem.- Parameters
trigger (hoomd.trigger.Trigger) –
Trigger
to determine when to run the tuner.moves (list[str]) – A list of types of moves to tune. Available options are ‘a’ and ‘d’.
target (float) – The acceptance rate for trial moves that is desired. The value should be between 0 and 1.
types (list[str]) – A list of string particle types to tune the move size for, defaults to None which upon attaching will tune all types in the system currently.
max_translation_move (float) – The maximum value of a translational move size to attempt, defaults to
None
which represents no maximum move size.max_rotation_move (float) – The maximum value of a rotational move size to attempt, defaults to
None
which represents no maximum move size.gamma (float) – The value of gamma to pass through to
hoomd.tune.SecantSolver
. Controls the size of corrections to the move size (smaller values increase stability). Should be between 0 and 1, defaults to 0.8.tol (float) – The absolute tolerance to allow between the current acceptance rate and the target before the move sizes are considered tuned. The tolerance should not be too much lower than the default of 0.01 as acceptance rates can vary significantly at typical tuning rates.
Note
Increasing
gamma
towards 1 does not necessarily speed up convergence and can slow it done. In addition, large values ofgamma
can make the solver unstable especially when tuning frequently.