OptimizationManager
- class optking.optimize.OptimizationManager(molsys: Molsys, history_object: History, params: OptParams, computer: ComputeWrapper)[source]
Bases:
OptimizationInterface
Recommended use of Optking’s Optimization Algorithms is to create this class and then loop over take_step. OptimizationFactory will either return the appropriate OptimizationAlgorithm or return itself if management of multiple algorithms is required (linesearching). Currently only 1 linesearch method is implemented so changing linesearch_method to anything that does not evaluate to None will turn linesearch on.
This class’ primary purpose is to abstract the interface for an OptimizationAlgorithm, Linesearch, or IRC so no special handling is needed for an IRC optimization as opposed to a NR optimization.
# TODO add dynamic_level management here
Methods Summary
alg_error_handler
(error)consumes an AlgError.
Check iterations < geom_maxiter.
clear
()Reset history (inculding all steps) and molecule
converged
(E, fq, dq[, step_number, str_mode])Test whether the optimization has finished.
finish
([error])from_dict
(d, molsys, history, params, computer)Reload attributes from the provided dictionary.
Determine action to take for how to compute a hessian.
opt_error_handler
(error)OptError indicates an unrecoverable error.
start_step
(H)Initialize coordinates and perform any coordinate transformations of gradients and hessians.
take_step
([fq, H, energy, return_str])Take whatever step (normal, linesearch, IRC, constrained IRC) is next.
to_dict
()Convert attributes to serializable form.
unknown_error_handler
(error)Unknown errors are not recoverable error.
Get the current requirements for the next step.
Methods Documentation
- converged(E, fq, dq, step_number=None, str_mode=None)[source]
Test whether the optimization has finished. An optimization can only be declared converged If a gradient has been provided (linesearching cannot terminate an optimization)
- classmethod from_dict(d, molsys, history, params, computer)[source]
Reload attributes from the provided dictionary. Create all necessary classes.
To prevent duplication, OptHelper handles converting the molsys, history, params, and computer to/from dict
- get_hessian_protocol()[source]
Determine action to take for how to compute a hessian. Handles alternate IRC behavior
- Returns
str
- Return type
one of (‘compute’, ‘update’, ‘guess’, ‘unneeded’)
- opt_error_handler(error)[source]
OptError indicates an unrecoverable error. Print information and trigger cleanup.
- start_step(H: ndarray)[source]
Initialize coordinates and perform any coordinate transformations of gradients and hessians.
- Returns
H (np.ndarray) – 2D. Hessian in appropriate coordinates
f_q (np.ndarray) – 1D. forces in appropriate coordinates
E (float) – energy
- take_step(fq=None, H=None, energy=None, return_str=False, **kwargs)[source]
Take whatever step (normal, linesearch, IRC, constrained IRC) is next.
- fq: Union[np.ndarray, None]
forces
- H: Union[np.ndarray, None]
hessian
energy: Union[np.ndarray, None] return_str: bool
if True return string with information about step (information is logged regardless)