def mylbfgs(coords, pot, **kwargs): if not hasattr(pot, "getEnergyGradient"): # for compatibility with old quenchers. # assume pot is a getEnergyGradient function pot = _getEnergyGradientWrapper(pot) lbfgs = MYLBFGS(coords, pot, **kwargs) return lbfgs.run()
def _mylbfgs(coords, pot, **kwargs): lbfgs = MYLBFGS(coords, pot, **kwargs) ret = lbfgs.run() coords = ret.coords e = ret.energy rms = ret.rms funcalls = ret.nfev return coords, e, rms, funcalls, ret
def findLowestEigenVector(coords, pot, eigenvec0=None, H0=None, orthogZeroEigs=0, dx=1e-3, **kwargs): """ find the eigenvector corresponding to the lowest eigenvalue using LowestEigPot and the LBFGS minimizer ***orthogZeroEigs is system dependent, don't forget to set it*** Parameters ---------- coords : the coordinates at which to find the lowest eigenvector pot : potential object eigenvec0 : the initial guess for the lowest eigenvector (will be random if not passed) H0 : float the initial guess for the diagonal component of the inverse Hermissian orthogZeroEigs : callable this function makes a vector orthogonal to the known zero eigenvectors orthogZeroEigs=0 : default behavior, assume translational and rotational symmetry orthogZeroEigs=None : the vector is unchanged kwargs : any additional keyword arguments are passed to the minimizer See Also -------- FindTransitionState : uses this class """ #combine kwargs with defaults.lowestEigenvectorQuenchParams kwargs = dict([("iprint", 400), ("tol", 1e-6), ("nsteps", 500)] + kwargs.items()) if not kwargs.has_key("logger"): kwargs["logger"] = logging.getLogger( "pygmin.connect.findTS.leig_quench") if eigenvec0 is None: #this random vector should be distributed uniformly on a hypersphere. eigenvec0 = rotations.vec_random_ndim(coords.shape) #set up potential for minimization eigpot = LowestEigPot(coords, pot, orthogZeroEigs=orthogZeroEigs, dx=dx) #minimize, using the last eigenvector as a starting point #and starting with H0 from last minimization quencher = MYLBFGS(eigenvec0, eigpot, rel_energy=True, H0=H0, **kwargs) res = quencher.run() #res = Result() res.eigenval = res.energy res.eigenvec = res.coords / np.linalg.norm(res.coords) delattr(res, "energy") delattr(res, "coords") res.H0 = quencher.H0 #res.success = res.rms <= tol return res
def findLowestEigenVector(coords, pot, eigenvec0=None, H0=None, orthogZeroEigs=0, dx=1e-3, **kwargs): """ find the eigenvector corresponding to the lowest eigenvalue using LowestEigPot and the LBFGS minimizer ***orthogZeroEigs is system dependent, don't forget to set it*** Parameters ---------- coords : the coordinates at which to find the lowest eigenvector pot : potential object eigenvec0 : the initial guess for the lowest eigenvector (will be random if not passed) H0 : float the initial guess for the diagonal component of the inverse Hermissian orthogZeroEigs : callable this function makes a vector orthogonal to the known zero eigenvectors orthogZeroEigs=0 : default behavior, assume translational and rotational symmetry orthogZeroEigs=None : the vector is unchanged kwargs : any additional keyword arguments are passed to the minimizer See Also -------- FindTransitionState : uses this class """ #combine kwargs with defaults.lowestEigenvectorQuenchParams kwargs = dict([("iprint",400), ("tol",1e-6), ("nsteps", 500)] + kwargs.items()) if not kwargs.has_key("logger"): kwargs["logger"] = logging.getLogger("pygmin.connect.findTS.leig_quench") if eigenvec0 is None: #this random vector should be distributed uniformly on a hypersphere. eigenvec0 = rotations.vec_random_ndim(coords.shape) #set up potential for minimization eigpot = LowestEigPot(coords, pot, orthogZeroEigs=orthogZeroEigs, dx=dx) #minimize, using the last eigenvector as a starting point #and starting with H0 from last minimization quencher = MYLBFGS(eigenvec0, eigpot, rel_energy=True, H0=H0, **kwargs) res = quencher.run() #res = Result() res.eigenval = res.energy res.eigenvec = res.coords / np.linalg.norm(res.coords) delattr(res, "energy") delattr(res, "coords") res.H0 = quencher.H0 #res.success = res.rms <= tol return res