HybridMonteCarlo¶
- HybridMonteCarlo(configuration, trajectory_filename=None, steps=None, log_interval=None, mc_method=None, md_method=None, hook_functions=None, write_velocities=True, write_forces=True, write_stresses=None, trajectory_interval=None, trajectory_object_id=None, constraints=None, pre_step_hook=None, post_step_hook=None, measurement_hook=None)¶
Function for performing a hybrid Monte Carlo molecular dynamics simulation.
- Parameters:
configuration (
MoleculeConfiguration
|BulkConfiguration
|DeviceConfiguration
|SurfaceConfiguration
) – The initial configuration.trajectory_filename (str | None) – The filename of the file to be used for storing the trajectory, or None if no trajectory should be written. A trajectory filename should not be given if configuration is a trajectory. Default:
None
.steps (int) – The number of time-steps to take in simulation. Default:
50
.log_interval (int) – The interval at which information, such as time, energy, temperature, etc. is written to the log output. Default: 1.
mc_method (
MCMethod
) – The Monte Carlo method used for the simulation. Default:MCMethod
.md_method (
BaseMDmethod
|ForceBiasMonteCarlo
) – The molecular dynamics or FBMC method used for the simulation. Default:NVEVelocityVerlet
.hook_functions (HookFunctions) – An optional HookFunctions object, which contains user-defined functions or a list of functions which will be called just before (pre-step) or just after (post-step) the forces evaluation. It can also contain measurement hooks, which are called at the end of each configuration move step. Default:
None
.write_velocities (bool) – Write the velocities to the trajectory file every
log_interval
steps. Default: True.write_forces (bool) – Write the forces to the trajectory file every
log_interval
steps. Default: True.write_stresses (bool) – Write the stress to the trajectory file every
log_interval
steps. A value of None means thatwrite_stresses
is True by default for NPT methods and False otherwise. This is to avoid the additional work of calculating the stress when it is not needed. Default: None.trajectory_interval (int) – The resolution used in saving steps to a trajectory file. A value of 1 results in all steps being saved; a value of 2 results in every second step being saved; etc. If
configuration
is a trajectory (i.e. this is a restart MD simulation) this parameter will use the same value as was used in the previous trajectory. Default: The same value aslog_interval
.trajectory_object_id (str | None) – The object id of the trajectory written to
trajectory_filename
. If a value ofNone
is given, then an object id will be chosen automatically. Default:None
.constraints (list of ints | list of
BaseConstraint
) – The constraints in the system.pre_step_hook (function | list of functions | None) – A function to be called before each simulation step.
post_step_hook (function | list of functions | None) – A function to be called after each simulation step.
measurement_hook (function | list of functions | None) – A function to be called at the end of each simulation step, after all constraints have been applied.
- Returns:
The molecular dynamics trajectory.
- Return type:
Notes¶
The HybridMonteCarlo()
method implements the hybrid Monte Carlo simulation method.
In this method the equilibrium properties of a system in a thermodynamic ensemble are sampled.
Samples are generated using alternating dynamical (molecular dynamics or force-bias Monte Carlo) and
stochastic (Monte Carlo) cycles. The method works similarly to MolecularDynamics()
in that
it takes a starting configuration as input and then generates a trajectory of samples in the given
thermodynamic ensemble. As in some ensembles used in Monte Carlo the number or type of atoms can
change, HybridMonteCarlo generates a ConfigurationDataContainer
rather than a
MDTrajectory
as an output trajectory. In hybrid Monte Carlo simulations the properties
being sampled are written to the trajectory as measurements.
The dynamics method is specified using the method
keyword. This works in the same way as
in MolecularDynamics()
or TimeStampedForceBiasMonteCarlo()
. For pure Monte Carlo
simulations where no dynamics are performed a StaticMonteCarlo
object can also be given.
In hybrid Monte Carlo it is assumed that the dynamics method is simply sampling the same ensemble
as the Monte Carlo method. Dynamics steps can therefore be uniformly accepted because the ensemble
is maintained.
The Monte Carlo method is specified as a pre-step hook method. Currently only the semi-grand
canonical ensemble can be sampled using the SemiGrandCanonicalMonteCarloHook
and
SemiGrandCanonicalTransitionMatrixHook
methods.
Hybrid Monte Carlo is more limited in features than regular molecular dynamics. Hybrid Monte Carlo does not support distributed parallel calculations with MPI. It also does not support adding constraints to the dynamics of the system.