carmm.build.neb package¶
Submodules¶
carmm.build.neb.WIP_neb_preselection module¶
- def pre_neb_aims(initial,
final, hpc=”hawk”, basis_set =’light’, filename=”last_predicted_path.traj”):
‘’’ This function performs a preliminary NEB calculation on user-provided structures using ML-NEB. If the calculation does not converge within 75 steps, it is terminated. Minimum Energy Path energy landscape is examined for occurence of multiple local maxima and if detected - geometry optimisations on local minima are performed.
The optimised structures can be used as alternative start/end points for further calculations making the NEB calculation easier to converge.
Parameters: hpc: string
‘hawk’, ‘isambard’, ‘archer’ see carmm.run.aims_path.set_aims_command
- basis_set: string
‘light’, ‘tight’ etc., see carmm.run.aims_path.set_aims_command
- filename: string
Name of a file containing an unconverged NEB Minimum Energy Path. Default is ‘last_predicted_path.traj’ for CatLearn MLNEB.
- initial: Atoms object
Starting geometry of a NEB calculation.
- final: Atoms object
End geometry of a NEB calculation.
‘’’ import os
- if not os.path.exists(filename):
from ase.io import read from catlearn.optimize.mlneb import MLNEB
# Set the environment parameters from carmm.run.aims_path import set_aims_command set_aims_command(hpc=hpc, basis_set=basis_set)
# your settings go here def my_calc():
# New method that gives a default calculator from carmm.run.aims_calculator import get_aims_calculator return get_aims_calculator(dimensions=2)
from carmm.build.neb.ilm import neb_identify_local_minima from carmm.build.neb.ilm import multiple_local_extrema
# Desired number of images including start and end point # Enough to show energy landscape of Minimum Energy Path n = 15
calculator = my_calc()
# Setup the Catlearn object for MLNEB neb_catlearn = MLNEB(start=initial,
end=final, ase_calc=calculator, n_images=n, interpolation=’idpp’, restart=False)
# Run the NEB optimisation. Adjust fmax to desired convergence criteria, # usually 0.01 ev/A. Max steps set to 75 for preliminary study. # MLNEB serial part is quick below 100 structures
- neb_catlearn.run(fmax=0.01,
trajectory=’ML-NEB.traj’, full_output=False, steps=75)
- if multiple_local_extrema(filename=filename) is True:
print(“Multiple extrema detected in the predicted Minimum Energy Path.”) print(“Local minima will be identified and optimised”) atoms_list, indices = neb_identify_local_minima(filename=filename)
print(len(atoms_list), “minima detected. Performing geometry optimisations.”)
from ase.optimize import BFGS from carmm.run.aims_path import set_aims_command from carmm.run.aims_calculator import get_aims_calculator set_aims_command(hpc=hpc, basis_set=basis_set)
x = 0 for atoms in atoms_list:
print(“Geometry optimisations completed.”) print(“Please consider the structures as alternative start/end points.”)
- else:
print(“No multiple extrema detected in the predicted Minimum Energy Path.”)
carmm.build.neb.bond_length_scan module¶
Created on Fri 19/06/2020
@author: Igor Kowalec, David Willock
- carmm.build.neb.bond_length_scan.dissociation(atoms, i1, i2, step_size=0.05, n_steps=20, final_distance=None, group_move=None, z_bias=False)¶
This function is a tool for investigating bond dissociation. Bond length of interest is fixed and is increased by step_size in each iteration. This aims to help with obtaining activation energies for surface calculations, e.g. hydrogenation, where metastability of optimal starting position is often low and thus hard to obtain. Returns a list of Atoms objects with changed positions and constraints applied, which can be optimised by the user.
- Parameters:
atoms – Atoms object
i1 – int Index of atom remaining as part of a molecule
i2 – int Index of atom dissociating from molecule
step_size – float Distance moved during dissociation in Angstrom per iteration, not used when final_distance is specified. If negative value - Association is examined instead
n_steps – int Total number of steps
final_distance – None/float User can specify the final distance, the increments will be then based on a fraction of n_steps/final_distance instead of step_size
group_move – list of integers User can specify a list of indices of atoms that need to be moved together with atom with index i2, e.g. OH group etc.
z_bias – boolean of float If float - bias z-coord of moving atom to approach set value WARNING - If TRUE this will make steps vary from defined step_size! Bias to adjust the Z-coordinate of atom/group moving to approach the surface in periodic calculations rather than just elongate the bond.
carmm.build.neb.geodesic module¶
carmm.build.neb.geodesic_utils module¶
carmm.build.neb.ilm module¶
- carmm.build.neb.ilm.multiple_local_extrema(filename='last_predicted_path.traj')¶
This function will detect local maxima in the trajectory file of a NEB calculation.
Parameters: filename: str
Name of the file containing latest Minimum Energy Path, default is “last_predicted_path.traj” as in MLNEB by CatLearn.
- Returns:
False for single maximum; True for multiple maxima.
- carmm.build.neb.ilm.neb_identify_local_minima(filename='last_predicted_path.traj')¶
This function will detect local minima in the trajectory file of a NEB calculation and will output the associated structures and their index. The user can then optimise these and use as an alternative starting structures for the NEB calculations.
Parameters: filename: str
Name of the file containing latest Minimum Energy Path, default is “last_predicted_path.traj” as in MLNEB by CatLearn.
carmm.build.neb.indices module¶
- carmm.build.neb.indices.sort_by_symbols(model)¶
Method for arranging the indices in the Atoms object based on their chemical symbols, enables interpolation if ‘Atomic ordering’ flags were raised.
- Parameters:
object (model - Atoms)
- carmm.build.neb.indices.switch_all_indices(model, new_indices)¶
Method to update all indices in a model all at once, assuming the new indexing order is available from e.g. compare_structures
Parameters:
- model: ASE atoms object
Input structure to be reordered
- new_indices: List of Integers
New indices for each atom in model
TODO: Add an example to the QA tests.
- carmm.build.neb.indices.switch_indices(model, A, B)¶
Function for rearranging atomic indices in the structure. Returns a changed atoms object with retained calculator and ensures array of forces is rearranged accordingly.
Parameters:
- model: Atoms object
Structure requiring atom index rearrangement.
- A, B: integer
Indices of atoms that need to be switched
carmm.build.neb.interpolation module¶
- carmm.build.neb.interpolation.check_interpolation(initial, final, n_max, interpolation='linear', verbose=True, save=True)¶
Interpolates the provided geometries with n_max total images and checks whether any bond lengths are below sane defaults. Saves the interpolation in interpolation.traj
Parameters:
- initial: Atoms object or string
Starting geometry for interpolation.
- final: Atoms object or string
End point geometry for interpolation
- n_max: integer
Desired total number of images for the interpolation including start and end point.
- interpolation: string
“linear” or “idpp”. First better for error identification, latter for use in NEB calculation
- verbose: boolean
If verbose output of information is required
- save: boolean
Whether to save the trajectory for transfer on to an NEB calculation
carmm.build.neb.neb_pathway module¶
carmm.build.neb.symmetry module¶
This file is work in progress
- carmm.build.neb.symmetry.get_lattice_constant(model)¶
Retrieve minimum M-M distance from bottom layer of a slab
Parameters: model: Atoms Object
FCC surface model that has atom tags associated with layers
- carmm.build.neb.symmetry.mirror(model, center_index, plane='y', surf='111', m_m_dist=None)¶
Function that returns a mirror image of an FCC model in the x or y axis with respect to an adsorbate and atom shifts the surface atoms accordingly.
Parameters: model: Atoms object
# TODO: This routine I think inadvertently edits the incoming model # Should we make a copy as the model comes in, and work exclusively with that? periodic FCC surface model with an adsorbate. Tags required for surface layers.
- plane: string
“x” or “y”
- center_index: integer
Index of an atom with respect to which the image will be mirrored.
- surf: string
Surface type. Supported “110”, “100” of the FCC lattice
- carmm.build.neb.symmetry.rotate_fcc(model, surf, center_index=0, m_m_dist=None)¶
Rotate FCC cell with respect to an atom by allowed increments, ie. “111” - 120 degrees “100” - 90 degrees “110” - 180 degrees
Parameters: model:in Atoms object
FCC low index surface, (111), (110) or (100)
- center_index: int
index of an atom as the center of the rotation operation
- surf: str
“111”, “110”, “100” allowed
- carmm.build.neb.symmetry.sort_by_xyz(model, surface)¶
Sorting indices by xyz coordinates for periodic surface models. Returns Atoms object with atom indices sorted.
Parameters: model: Atoms object
Periodic surface model, so far supported are monometallic FCC “111”, “110”, “100” HCP “0001”
- surface: string
Face centered cubic low index surfce - “111”, “110” or “110”
- carmm.build.neb.symmetry.sort_z(model, diff=1)¶
Function assigning tags to atomic layers within periodic surface models for easier identification and compatibility with other functionality in CARMM.
Parameters: model: Atoms object
Periodic surface model
- diff: float or int
Expected z-distance between atomic layers in Angstroms
TODO: Incorporate this functionality into other parts of the code that rely on z-tags
- carmm.build.neb.symmetry.translation(model, axis=0, surface='111', m_m_dist=None)¶
Performs a translaton of the model by manipulation of the unit cell, maintaining the optimised geometry and forces. After translation original Atoms object is permanently changed.
TODO: - FOR NOW requires surface to have tags for layers of atoms in Z-direction - functionality beyond FCC? or higher index?
Parameters: # TODO: This routine changes model in place (inadvertently).
Should it work with a copy of model for the “new model”, to prevent editing of the old model?
- model: Atoms object
XXX
- a: float
lattice parameter used in the model
- axis: integer
Choice - 0, 1 representing axis x, y
- surface: string
FCC surface - so far supports “111”, “110”, “100”
- carmm.build.neb.symmetry.wrap_fcc(model, surface)¶
- Parameters:
model
surface
Returns: