Helper#

class optking.opt_helper.Helper(params={}, **kwargs)[source]#

Bases: ABC

Base class for CustomHelper (accepts user provided gradients) and EngineHelper (uses MolSSI’s QCEngine for gradients)

A step may be taken by setting the class attributes gX and E, then calling the compute() and take_step() methods. The class attribute HX may also be set at any time as desired, if this is not set then OptKing will perform its normal update/guess procedure.

If full_hess_every has been set, the optimizer will require that hessians be provided every n steps. The properties required by the optimizer can be queried by calling get_requirements() test_convergence may be used to determine compliance with optking’s convergence criteria

OptKing will create a OptimizationResult as output in this process. This will be written upon calling close()

Attributes Summary

Methods Summary

attempt_fromiter(array)

build_coordinates()

Create coordinates for optimization.

close()

compute()

Get the energy, gradient, and hessian.

from_dict(d)

Construct as far as possible the helper.

post_step_str()

Returns a formatted string to summarize the step taken after calling take_step()

pre_step_str()

Returns a formatted string to summarize molecular system before taking a step or calling compute

show()

status([str_mode])

get string message describing state of optimizer

summarize_result()

Return final energy and geometry

take_step()

Must call compute before calling this method.

test_convergence([str_mode])

Check the final two steps for convergence.

to_dict()

Attributes Documentation

E: float | None#
HX: ndarray | None#
gX: ndarray | None#
geom#

Methods Documentation

static attempt_fromiter(array)[source]#
build_coordinates()[source]#

Create coordinates for optimization. print to logger

close()[source]#
compute()[source]#

Get the energy, gradient, and hessian. Project redundancies and apply constraints / forces

classmethod from_dict(d)[source]#

Construct as far as possible the helper. Child class will need to update computer

post_step_str()[source]#

Returns a formatted string to summarize the step taken after calling take_step()

pre_step_str()[source]#

Returns a formatted string to summarize molecular system before taking a step or calling compute

show()[source]#
status(str_mode=None, **kwargs)[source]#

get string message describing state of optimizer

Returns:

‘FAILED’ if unrecoverable ‘UNFINISHED-FAILED’ if recoverable error ‘UNFINISHED’ optimization has not converged ‘FINISHED’ optimization converged

Return type:

str

summarize_result()[source]#

Return final energy and geometry

take_step()[source]#

Must call compute before calling this method. Takes the next step.

test_convergence(str_mode=None, **kwargs)[source]#

Check the final two steps for convergence. If the algorithm uses linesearching, linesearches are not considered

Return type:

bool

to_dict()[source]#