RelaxDimer¶
- RelaxDimer(dimer, max_forces=None, max_steps=None, max_step_length=None, finite_difference_method=None, constraints=None, trajectory_filename=None, trajectory_object_id=None, log_filename_prefix=<class 'NL.ComputerScienceUtilities.NLFlag._NLFlag.Automatic'>, trajectory_interval=None, restart_strategy=None, post_step_hook=None, remove_drift=None, enable_optimization_stop_file=None, trial_step_length=None, min_rot_force=None, max_rot_force=None, trial_angle=None, max_number_of_rotations=None, extrapolate_rot_force=None)¶
Run dimer saddle point relaxation.
- Parameters:
dimer (
DimerConfiguration
) – The dimer to be optimized.max_forces (PhysicalQuantity with force units) – The maximum force convergence criterion. Default: 0.05 * eV / Angstrom
max_steps (int) – The maximum number of optimization steps allowed. Default: 200
max_step_length (PhysicalQuantity with length units) – The maximum step length the optimizer may take. Default: 0.2 * Angstrom
finite_difference_method (
NLFlag
(Forward
|Central
)) – The finite difference scheme to use.Forward
uses only one configuration for the force calculation, whileCentral
uses two configurations. Thus,Forward
is about a third faster thanCentral
. However,Central
is more accurate and stable which can result in overall fewer steps to convergence. IfForward
is used, it is recommended to adjust thedimer_separation
parameter in the class:`~.DimerConfiguration object to a smaller value. Default:Central
constraints (list of ints | None) – List of atom indices that are kept fixed during optimization. Default: [].
trajectory_filename (str | None) – The filename to write the trajectory to. Default: The trajectory is not saved.
trajectory_object_id (str | None) – The object id to use when saving to HDF5. If the object-id already exists in the given file, it will be overwritten. Default: None
log_filename_prefix (
Automatic
| str | None) – The logging output from each dimer endpoint will be written to filenames starting with this value. If it is set to Automatic then the prefix will be the name of the calling python script. If it is set to None, then all output will be written to stdout. Default:Automatic
.trajectory_interval (int | PhysicalQuantity of type time) – The resolution used in saving steps to a trajectory file. This can either be given as an integer (a value of 1 results in all steps being saved; a value of 2 results in every second step being saved; etc.) or as a time interval. Default:
1
restart_strategy (
NoRestart
|RestartFromTrajectory
) – The restart mechanism based on trajectory data saved in a given file. Default:RestartFromTrajectory()
remove_drift (bool) – Controls if the drift is removed from the forces. Default: True
post_step_hook (A callable method, function or instance) – An optional user-defined function which will be called just after each optimization step. The signature of the function requires the arguments (step, configuration). The return status is ignored. Unhandled exceptions will terminate the optimization. Default: None
enable_optimization_stop_file (bool) – Determines whether to enable a file for stopping the dimer relaxation. If
True
, creation of the stop file will stop the relaxation at the next step. The name of the stop file will be shown in the log output; it will bestop-dimer-relaxation-uniqueID
, whereuniqueID
is a randomly generated identifier for this relaxation. The file must be created in the current working directory. Default:True
trial_step_length (PhysicalQuantity of type length) – The trial step to determine the ideal step. Default: 0.001 * Angstrom
min_rot_force (PhysicalQuantity of type force) – The minimum rotational force necessary to attempt a rotation. Default: 0.1 * eV/Angstrom
max_rot_force (PhysicalQuantity of type force) – The maximum rotational force that terminates the eigenmode optimization. A rotation will always be performed before checking this parameter. Default: 1.0 * eV/Angstrom
trial_angle (float) – The trial angle in radians. Default: pi / 4.0 (45 degrees)
max_number_of_rotations (Positive int) – The maximum number of rotations. Default: 1
extrapolate_rot_force (bool) – Use an extrapolation scheme to estimate the rotational force. This reduces the number of force evaluations per rotation from 2 to 1. This parameter only has an effect if the maximum number of rotations is greater than 1. Default: False
- Returns:
The optimized dimer.
- Return type:
Usage Examples¶
The Dimer method [1][2] is a saddle search method that can be used
to relax a configuration into a nearby transition state following the smallest eigenmode. Unlike
other methods, it does so without requiring the calculation of second derivatives. Instead, the
Dimer method uses a finite difference approximation to the gradient of the potential energy
surface to find the smallest eigenmode. This makes the dimer method computationally very efficient
[3], especially when compared to the climbing-image
NudgedElasticBand
method, which requires more images.
The initial configuration and search direction are supplied to the RelaxDimer()
function
through a DimerConfiguration
object. The search direction can either be randomly
generated or correspond to an initial guess of the minimum eigenmode.
# Get the coordinates of the transition state estimate and a local minimum.
ts_coordinates = ts.cartesianCoordinates()
minimum_coordinates = minimum.cartesianCoordinates()
# Calculate an initial displacement.
norm = (ts_coordinates - minimum_coordinates).norm()
# Normalize the displacement vector and divide by 10 to get a small displacement.
displacement_vector = ((ts_coordinates - minimum_coordinates) / norm) / 10
dimer = DimerConfiguration(
configuration=ts,
displacement=displacement_vector * Angstrom
)
relaxed_dimer = RelaxDimer(
dimer=dimer,
trajectory_filename='dimer_relaxation.hdf5',
# Translation.
max_forces=0.05 * eV / Angstrom,
max_steps=50,
max_step_length=0.2 * Angstrom,
constraints=None,
trial_step_length=0.001 * Angstrom,
# Rotation.
min_rot_force=0.1 * eV/Angstrom,
max_rot_force=1.0 * eV/Angstrom,
trial_angle=pi / 4.0,
max_number_of_rotations=5
)
relaxed_ts = relaxed_dimer.configuration()
However, the simplest way to generate the initial guess is to use the dimerFromNEB()
function. This way, one can combine the robustness of the NEB method with the efficiency of the
Dimer method.
dimer = dimerFromNEB(nudged_elastic_band)
The log output of the Dimer method can give some insight into how the relaxation is proceeding.
The rotational force indicates how well the dimer is aligned with the smallest eigenmode. If it is too large multiple rotations might be necessary. Likewise, the angle should decrease during subsequent rotations.
The curvature must become negative to indicate that the dimer is moving towards a saddle point.