catlearn.optimize package¶
Submodules¶
catlearn.optimize.constraints module¶
-
catlearn.optimize.constraints.
apply_mask
(list_to_mask=None, mask_index=None)¶
-
catlearn.optimize.constraints.
create_mask
(ini, constraints)¶
-
catlearn.optimize.constraints.
unmask_geometry
(org_list, masked_geom, mask_index)¶
catlearn.optimize.convergence module¶
catlearn.optimize.functions_calc module¶
-
class
catlearn.optimize.functions_calc.
GoldsteinPrice
(**kwargs)¶ Bases:
ase.calculators.calculator.Calculator
GoldsteinPrice potential.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
-
class
catlearn.optimize.functions_calc.
Himmelblau
(**kwargs)¶ Bases:
ase.calculators.calculator.Calculator
Himmelblau potential.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
-
class
catlearn.optimize.functions_calc.
ModifiedHimmelblau
(**kwargs)¶ Bases:
ase.calculators.calculator.Calculator
Himmelblau potential.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
-
class
catlearn.optimize.functions_calc.
MullerBrown
(**kwargs)¶ Bases:
ase.calculators.calculator.Calculator
Muller-brown potential.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
default_parameters
= {'p1': [-200.0, -1.0, 0.0, -10.0, 1.0, 0.0], 'p2': [-100.0, -1.0, 0.0, -10.0, 0.0, 0.5], 'p3': [-170.0, -6.5, 11.0, -6.5, -0.5, 1.5], 'p4': [15.0, 0.7, 0.6, 0.7, -1.0, 1.0]}¶
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
-
class
catlearn.optimize.functions_calc.
MultiModal
(**kwargs)¶ Bases:
ase.calculators.calculator.Calculator
MultiModal potential.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
-
class
catlearn.optimize.functions_calc.
NoiseHimmelblau
(**kwargs)¶ Bases:
ase.calculators.calculator.Calculator
NoiseHimmelblau potential.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
-
class
catlearn.optimize.functions_calc.
Rosenbrock
(**kwargs)¶ Bases:
ase.calculators.calculator.Calculator
Himmelblau potential.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
catlearn.optimize.get_real_values module¶
catlearn.optimize.io module¶
-
catlearn.optimize.io.
array_to_ase
(input_array, num_atoms)¶ Converts a flat array into an ase structure (list).
Parameters: - input_array (ndarray) – Structure.
- num_atoms (int) – Number of atoms.
Returns: pos_ase – Position of the atoms in ASE format.
Return type: list
-
catlearn.optimize.io.
array_to_atoms
(input_array)¶ Converts an input flat array into atoms shape for ASE.
Parameters: input_array (ndarray) – Structure. Returns: - pos_ase (list)
- Position of the atoms in ASE format.
-
catlearn.optimize.io.
ase_to_catlearn
(list_atoms)¶ Converts a trajectory file from ASE to a list of train, targets and gradients. The first and last images of the trajectory file are also included in this dictionary.
- list_atoms : string
- List Atoms objects in ASE format. The file must be in the current working directory.
- results: dict
- Dictionary that contains list of train (including constraints), targets and gradients, number of atoms for the atomistic structure, images included in the trajectory file and Atoms structures of the initial and final endpoints of the NEB.
-
catlearn.optimize.io.
print_cite_mlmin
()¶
-
catlearn.optimize.io.
print_cite_mlneb
()¶
-
catlearn.optimize.io.
print_info
(self)¶ Output of the ML-Min surrogate machine learning algorithm.
-
catlearn.optimize.io.
print_info_neb
(self)¶ Prints the information of the surrogate model convergence at each step.
-
catlearn.optimize.io.
print_time
()¶
-
catlearn.optimize.io.
print_version
(version)¶
-
catlearn.optimize.io.
store_results_neb
(self)¶ Function that dumps the predicted discrete and interpolated M.E.P. curves in csv files for plotting
-
catlearn.optimize.io.
store_trajectory_neb
(self)¶
catlearn.optimize.mlneb module¶
-
class
catlearn.optimize.mlneb.
ASECalc
(gp, index_constraints, scaling_targets, finite_step=0.0001, **kwargs)¶ Bases:
ase.calculators.calculator.Calculator
CatLearn/ASE calculator.
-
calculate
(atoms=None, properties=['energy', 'forces'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])¶ Do the calculation.
- properties: list of str
- List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
- List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute.
-
implemented_properties
= ['energy', 'forces']¶
-
nolabel
= True¶
-
-
class
catlearn.optimize.mlneb.
MLNEB
(start, end, prev_calculations=None, n_images=0.25, k=None, interpolation='linear', mic=False, neb_method='improvedtangent', ase_calc=None, restart=True, force_consistent=None)¶ Bases:
object
-
run
(fmax=0.05, unc_convergence=0.05, steps=500, trajectory='ML_NEB_catlearn.traj', acquisition='acq_5', dt=0.025, ml_steps=750, max_step=0.25, sequential=False, full_output=False)¶ Executing run will start the NEB optimization process.
Parameters: - fmax (float) – Convergence criteria (in eV/Angs).
- unc_convergence (float) – Maximum uncertainty for convergence (in eV).
- steps (int) – Maximum number of iterations in the surrogate model.
- trajectory (string) – Filename to store the output.
- acquisition (string) – Acquisition function.
- dt (float) – dt parameter for MDMin.
- ml_steps (int) – Maximum number of steps for the NEB optimization on the predicted landscape.
- max_step (float) – Early stopping criteria. Maximum uncertainty before stopping the optimization in the predicted landscape.
- sequential (boolean) – When sequential is set to True, the ML-NEB algorithm starts with only one moving image. After finding a saddle point the algorithm adds all the images selected in the MLNEB class (the total number of NEB images is defined in the ‘n_images’ flag).
- full_output (boolean) – Whether to print on screen the full output (True) or not (False).
Returns: Return type: Minimum Energy Path from the initial to the final states.
-
-
catlearn.optimize.mlneb.
create_ml_neb
(is_endpoint, fs_endpoint, images_interpolation, n_images, constraints, index_constraints, scaling_targets, iteration, gp=None)¶ Generates input NEB for the GPR.
-
catlearn.optimize.mlneb.
eval_and_append
(self, interesting_point)¶ - Evaluates the energy and forces (ASE) of the point of interest
- for a given atomistic structure.
Parameters: - self (arrays) – Previous information from the CatLearn optimizer.
- interesting_point (ndarray) – Atoms positions or point in space.
Returns: Return type: Append function evaluation and forces values to the training set.
-
catlearn.optimize.mlneb.
get_energy_catlearn
(self, x=None)¶ Evaluates the objective function at a given point in space.
Parameters: - self (arrays) – Previous information from the CatLearn optimizer.
- x (array) – Array containing the atomic positions (flatten).
Returns: energy – The function evaluation value.
Return type: float
-
catlearn.optimize.mlneb.
get_fmax
(gradients_flatten)¶ Function that print a list of max. individual atom forces.
-
catlearn.optimize.mlneb.
get_forces_catlearn
(self, x=None)¶ Evaluates the forces (ASE) or the Jacobian of the objective function at a given point in space.
Parameters: - self (arrays) – Previous information from the CatLearn optimizer.
- x (array) – Atoms positions or point in space.
Returns: forces – Forces of the atomic structure (flatten).
Return type: array
-
catlearn.optimize.mlneb.
get_results_predicted_path
(self)¶ Obtain results from the predicted NEB.
-
catlearn.optimize.mlneb.
train_gp_model
(list_train, list_targets, list_gradients, index_mask, path_distance, fullout=False)¶ Train Gaussian process
catlearn.optimize.tools module¶
-
catlearn.optimize.tools.
plotneb
(trajectory='ML_NEB_catlearn.traj', view_path=True)¶ Plot NEB path from a trajectory file containing the optimized images. This is meant to be used with ML-NEB. The error bars show the uncertainty for each image along the path.