pele.optimize._quench#

Module source

wrappers for the various optimizers.

warning: we’ve tried to make the most common options the same but there are still differences

we should make this consistent with scipy. scipy.minimize would do a similar thing

pele.optimize._quench.lbfgs_scipy()[source]

Source

def lbfgs_scipy(coords, pot, iprint=-1, tol=1e-3, nsteps=15000):

a wrapper function for lbfgs routine in scipy

Warning

the scipy version of lbfgs uses linesearch based only on energy which can make the minimization stop early. When the step size is so small that the energy doesn’t change to within machine precision (times the parameter factr) the routine declares success and stops. This sounds fine, but if the gradient is analytical the gradient can still be not converged. This is because in the vicinity of the minimum the gradient changes much more rapidly then the energy. Thus we want to make factr as small as possible. Unfortunately, if we make it too small the routine realizes that the linesearch routine isn’t working and declares failure and exits.

So long story short, if your tolerance is very small (< 1e-6) this routine will probably stop before truly reaching that tolerance. If you reduce factr too much to mitigate this lbfgs will stop anyway, but declare failure misleadingly.

pele.optimize._quench.fire()[source]

Source

def fire(coords, pot, tol=1e-3, nsteps=100000, **kwargs):

A wrapper function for the pele FIRE implementation

pele.optimize._quench.cg()[source]

Source

def cg(coords, pot, iprint=-1, tol=1e-3, nsteps=5000, **kwargs):

a wrapper function for conjugate gradient routine in scipy

pele.optimize._quench.steepest_descent()[source]

Source

def steepest_descent(
    x0,
    pot,
    iprint=-1,
    dx=1e-4,
    nsteps=10000000,
    tol=1e-4,
    maxstep=-1.0,
    events=None,
):

steepest descent minimization

Notes

this should never be used except for testing purposes. It is a bad implementation of a terrible minimization routine. It will be very slow.

pele.optimize._quench.bfgs_scipy()[source]

Source

def bfgs_scipy(coords, pot, iprint=-1, tol=1e-3, nsteps=5000, **kwargs):

a wrapper function for the scipy BFGS algorithm

pele.optimize._quench.lbfgs_cpp()[source]

Source

def lbfgs_cpp(coords, pot, **kwargs):

Minimize a configuration with the C++ LBFGS implementation.

Parameters:
coordsarray_like

Initial coordinates for the minimization.

potobject

Potential supplying the energy and gradient.

**kwargsdict, optional

Additional constructor arguments passed unchanged to pele.optimize.LBFGS_CPP.

Returns:
resultpele.optimize.Result

The optimizer’s run() result, including final coordinates, energy, gradient, and convergence status.

See also

pele.optimize.LBFGS_CPP

The native optimizer class.

pele.optimize._quench.modifiedfire_cpp()[source]

Source

def modifiedfire_cpp(coords, pot, **kwargs):

Minimize a configuration with the C++ modified FIRE implementation.

Parameters:
coordsarray_like

Initial coordinates for the minimization.

potobject

Potential supplying the energy and gradient.

**kwargsdict, optional

Additional constructor arguments passed unchanged to pele.optimize.ModifiedFireCPP.

Returns:
resultpele.optimize.Result

The optimizer’s run() result, including final coordinates, energy, gradient, and convergence status.

See also

pele.optimize.ModifiedFireCPP

The native optimizer class.

pele.optimize.fire

The Python FIRE wrapper.

pele.optimize._quench.quench_cvode_opt()[source]

Source

def quench_cvode_opt(potential, initial_coordinates, nsteps=1000000, **kwargs):

“Subroutine” for quenching steepest descent, add subtract yada yada to control how information gets returned, basically simply passing potential, initial_coordinates with these default parameters should give identical results between different pieces.

pele.optimize._quench.ode_scipy_naive()[source]

Source

def ode_scipy_naive(
    coords,
    pot,
    t_bound=1000,
    tol=1e-4,
    nsteps=20000,
    convergence_check=None,
    solver_type="rk45",
    **kwargs
):

This uses rk45 in a minimizer like approach to find the ode

The idea is to solve for the path:

dx/dt = - \grad{E}
Parameters:
coordsarray

coords input for the quench

potarray

potential class that has a getenergygradient function that we need for stepping

nstepsint

maximum number of steps

tolfloat

gives a tolerance for making sure that we have found the minima

kwargs…

extra arguments for the integrator

Returns:
resultResult

result container with steps and function evaluations