本文整理汇总了Python中pele.optimize.LBFGS.attachEvent方法的典型用法代码示例。如果您正苦于以下问题:Python LBFGS.attachEvent方法的具体用法?Python LBFGS.attachEvent怎么用?Python LBFGS.attachEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pele.optimize.LBFGS
的用法示例。
在下文中一共展示了LBFGS.attachEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runtest
# 需要导入模块: from pele.optimize import LBFGS [as 别名]
# 或者: from pele.optimize.LBFGS import attachEvent [as 别名]
def runtest(X, pot, natoms = 100, iprint=-1):
from _lbfgs_py import PrintEvent
tol = 1e-5
maxstep = 0.005
Xinit = np.copy(X)
e, g = pot.getEnergyGradient(X)
print "energy", e
lbfgs = LBFGS(X, pot, maxstep = 0.1, nsteps=10000, tol=tol,
iprint=iprint, H0=2.)
printevent = PrintEvent( "debugout.xyz")
lbfgs.attachEvent(printevent)
ret = lbfgs.run()
print ret
print ""
print "now do the same with scipy lbfgs"
from pele.optimize import lbfgs_scipy as quench
ret = quench(Xinit, pot, tol = tol)
print ret
#print ret[1], ret[2], ret[3]
if False:
print "now do the same with scipy bfgs"
from pele.optimize import bfgs as oldbfgs
ret = oldbfgs(Xinit, pot, tol = tol)
print ret
if False:
print "now do the same with gradient + linesearch"
import _bfgs
gpl = _bfgs.GradientPlusLinesearch(Xinit, pot, maxstep = 0.1)
ret = gpl.run(1000, tol = 1e-6)
print ret
if False:
print "calling from wrapper function"
from pele.optimize import lbfgs_py
ret = lbfgs_py(Xinit, pot, tol = tol)
print ret
if True:
print ""
print "now do the same with lbfgs_py"
from pele.optimize import lbfgs_py
ret = lbfgs_py(Xinit, pot, tol = tol)
print ret
try:
import pele.utils.pymolwrapper as pym
pym.start()
for n, coords in enumerate(printevent.coordslist):
coords=coords.reshape(natoms, 3)
pym.draw_spheres(coords, "A", n)
except ImportError:
print "error loading pymol"