# OptimizeNudgedElasticBand¶

OptimizeNudgedElasticBand(neb, max_forces=None, max_stress=None, max_steps=None, max_step_length=None, constraints=None, trajectory_filename=None, log_interval=None, spring_constant=None, climbing_image=None, preoptimization=None, optimizer_method=None, log_filename_prefix=<class 'NL.ComputerScienceUtilities.NLFlag._NLFlag.Automatic'>, pre_step_hook=None, post_step_hook=None, disable_stress=None, target_stress=None, trajectory_interval=None, restart_strategy=None)

Function for performing a NEB optimization.

Parameters: neb (NudgedElasticBand) – The nudged elastic band configuration to optimize. max_forces (PhysicalQuantity of type eV/Ang) – The maximum forces when the optimization should stop. Default: 0.05*eV/Ang max_steps (int) – The maximum number of steps to take before the NEB relaxation stops. Default: 200 max_step_length (PhysicalQuantity of type length) – The maximum step length the optimizer may take. Default: 0.2*Ang constraints (list of ints) – List of atom indices that are kept fixed during optimization. Default: [] trajectory_filename (str) – The filename used to store the trajectory. If the value is None then no trajectory file will be written. Default: None spring_constant (PhysicalQuantity of type eV/Ang**2) – The spring constant used for the NEB relaxation. Default: 5.0*(eV/Ang**2) climbing_image (bool) – Flag indicating if the climbing image algorithm should be used to find a transition state. Default: False preoptimization (bool) – Flag indicating if the endpoints should be optimized before the NEB optimization. Default: False optimizer_method (FIRE | LBFGS) – The optimizer to use for optimizing the structure. Default: LBFGS log_filename_prefix (Automatic | str | None) – The logging output from each image 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 pre_step_hook (A callable function or method) – An optional user-defined function which will be called just before each optimization step. The signature of the function requires the arguments (step, neb_configuration). The return status is ignored. Unhandled exceptions will abort the optimization. Default: None post_step_hook (A callable function or method) – An optional user-defined function which will be called just after each optimizaton step. The signature of the function requires the arguments (step, neb_configuration). The return status is ignored. Unhandled exceptions will abort the optimization. Default: None max_stress (PhysicalQuantity of type pressure) – The convergence criterion for the maximum difference between the internal stress and the target stress. Default: 0.1*GPa disable_stress (bool) – If it is None, it will be set automatically according to the NEB configuration. If the NEB configuration is composed of configurations with the type MoleculeConfiguration | SurfaceConfiguration | DeviceConfiguration, it is set True. If the NEB configuration is composed of configurations of the type BulkConfiguration and the lattice vectors of the configurations are different, it is set to False; otherwise it is True. Default: None target_stress (PhysicalQuantity of type pressure) – The target internal stress (tensor) of the system. Can be given as a single value in case of isotropic pressure, or as an internal stress vector in Voigt notation or as a 3x3-matrix. Default: 0*GPa 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) – The restart mechanism based on trajectory data saved in a given file. Default: NoRestart log_interval – Deprecated since version 2019.12: Use trajectory_interval instead. The optimized NEB configuration. The returned optimized NEB configuration is assigned the self-consistent calculation associated with the final step of the optimization loop. NudgedElasticBand

## Usage Examples¶

Find the reaction path for conversion of ethane to ethene, i.e.

$\mathrm{C}_2\mathrm{H}_6 \rightarrow \mathrm{C}_2\mathrm{H}_4 +\mathrm{H}_2$
# Find the reaction pathway
optimized_neb = OptimizeNudgedElasticBand(
neb_configuration,
max_forces=0.05*eV/Ang)


neb_c6h6.py

The two following examples demonstrate how to calculate the reaction path for rock-salt to wurtzite in CdSe. The first example is with a very small unit cell that results in a fully-concerted reaction mechanism, while the second is in a larger unit cell that first forms a line defect.

# Perform a VC-NEB optimization
neb_configuration = OptimizeNudgedElasticBand(
neb_configuration,
max_forces=0.01*eV/Ang,
max_stress=0.01*GPa,
max_steps=500,
climbing_image=True,
disable_stress=False,
)


## Variable Cell NEB¶

It is possible to study phase transitions using OptimizeNudgedElasticBand. When a NudgedElasticBand contains images that are bulk configurations and have different lattice vectors then the generalized solid-state nudged elastic band method (GSS-NEB) [SXC+12] algorithm is used. The algorithm optimizes both the atomic and lattice degrees of freedom along the reaction pathway and can be used to determine the reaction mechanism and energy barrier of a phase change. The target_stress parameter can be set to apply pressure or arbitrary stress.

There are two important points to be made aware of when using this technique:

1. In order to get an accurate estimate of the energy barrier one must use very large unit cells. This is because if a small unit cell is used, then all atoms will move during the phase transition. This is almost certainly not the favorable pathway in real systems. A large enough unit cell should permit the formation of a local nucleation process that occurs in either the initial or final phase of the material. After the local nucleation event the new crystal structure should then propagate across the unit cell. For more details, see for instance Sec. III.C. and Fig. 9 in Ref. [SXC+12].
2. Great care must be taken when constructing the initial and final images. Just as in the regular NEB algorithm, the atom indices in the initial and final structure must match. Atom #1 in the initial structure will be moved to atom #1 in the final structure. This means that you cannot simply take two different crystal structures with the same number of atoms and expect the resulting pathway to be correct.

## Notes¶

The number of processes used to calculate the energy and forces on each image is determined by the ParallelParameters object that has been set on the attached calculator. By default, the update is parallelized over images and then over the per-image energy/force calculation.

Care should be taken to ensure that the total number of MPI processes is divisible by the number of “interior” (moving) NEB images to achieve good load balancing. For example, if there are 7 images total, then 5 of them are interior images that move during the simulation and the total number of MPI processes should be a multiple of 5. The calculation will still run if the number of MPI processes is not a multiple of the number of interior images, however, a warning will be printed and the calculation of some images will be slower than others reducing the parallel efficiency of the overall calculation.

The output from the calculation will be logged to a separate file for each image whose name is the specified by the log_filename_prefix parameter with the image number appended to it. If the log files already exist, they will be appended to.

If preoptimization is selected and there are enough MPI processes for at least two images to be calculated in parallel, then the preoptimization will be performed in parallel and its output will be logged to files starting with the log_filename_prefix followed by “_preoptimization”.

 [SXC+12] (1, 2) Daniel Sheppard, Penghao Xiao, William Chemelewski, Duane D. Johnson, and Graeme Henkelman. A generalized solid-state nudged elastic band method. The Journal of Chemical Physics, 136(7):074103, 2012. doi:10.1063/1.3684549.