jhrmnn / pyberny

Molecular structure optimizer
Mozilla Public License 2.0
110 stars 21 forks source link

Math Findroot function error #8

Closed sunqm closed 6 years ago

sunqm commented 6 years ago

This is the issue reported by pyscf https://github.com/sunqm/pyscf/issues/147

Geometry optimisation is working well by itself, but there is a bug in the qmmm example:

/home/animal/Packages/pyberny/berny/Math.py:129: RuntimeWarning: divide by zero encountered in double_scalars
  x = x-fx/dxf
/home/animal/Packages/pyberny/berny/berny.py:182: RuntimeWarning: invalid value encountered in multiply
  return norm(np.linalg.solve(l*eye(H.shape[0])-H, g))-trust
Traceback (most recent call last):
  File "10-with_qmmm.py", line 24, in <module>
    mol1 = berny_solver.optimize(mf)
  File "/home/animal/Packages/pyscf/pyscf/geomopt/berny_solver.py", line 63, in optimize
    optimizer.send((energy, gradients))
  File "/home/animal/Packages/pyberny/berny/berny.py", line 36, in Berny
    converged = algo.step(energy, gradients, log=log)
  File "/home/animal/Packages/pyberny/berny/berny.py", line 94, in step
    dot(proj, s.interpolated.g), H_proj, s.weights, s.trust, log=log
  File "/home/animal/Packages/pyberny/berny/berny.py", line 183, in quadratic_step
    l = Math.findroot(steplength, ev[0])  # minimization on sphere
  File "/home/animal/Packages/pyberny/berny/Math.py", line 136, in findroot
    raise FindrootException()
berny.Math.FindrootException
jhrmnn commented 6 years ago

The issue here was that the trust radius got too close to zero

jhrmnn commented 6 years ago

I'll continue this issue back in sunqm/pyscf#147