Closed jhrmnn closed 6 years ago
Seeing a similar fail on cyclopentene with PySCF (B3LYP/6-31G*) (pyberny ea3038ef), however it is fine with ethene at the same theory/basis.
I've been looking into this problem briefly, and it seems that there is a problem in general with cyclic structures. Once the cycle becomes almost perfectly planar, the structure of the eigenvalues of the Hessian changes, and the optimization blows up. I'm not sure why it happens though. The algorithm is supposed to handle redundant coordinates. I feel that this may be solved by adding additional internal coordinates to the points of planarity, but I'm not sure how yet.
Thanks for the overview and also thanks for coding this project all up. You have a nice logging system in place; I'll try and look into this to see if I can see anything as well.
Is there any reason for the difference between eq. 1.10 and https://github.com/azag0/pyberny/blob/6ba5a4cc113b146a3d67217d8b809f7c81fb59ed/berny/berny.py#L140
Ah, that seems to be just a typo in my thesis. The algorithm is taken from Fletcher's book and there it is as (eq 5.1.6):
Many thanks for the clarification.
OK, I think I have localised this. There is an issue in the general angle Dihedral differentiating code starting here: https://github.com/azag0/pyberny/blob/6ba5a4cc113b146a3d67217d8b809f7c81fb59ed/berny/coords.py#L166 If one removes this and the conditioning statements and the just uses the code from here https://github.com/azag0/pyberny/blob/6ba5a4cc113b146a3d67217d8b809f7c81fb59ed/berny/coords.py#L145 for differentiating, I can optimise the example sugar above, as well as other examples I have locally that were not working.
Amazing! This makes sense given that planar molecules are problematic. I guess the general-angle code itself is ok, so are the thresholds of 1e-6 incorrect?
I did have a little play with that, but it did not make much difference. I think it's something specific to the general angle case. But, by all means, do have a play with this aspect.
I also suspect there may be a problem here: https://github.com/azag0/pyberny/blob/6ba5a4cc113b146a3d67217d8b809f7c81fb59ed/berny/geomlib.py#L109
Should it be -1?
If one removes this and the conditioning statements and the just uses the code from here
I've looked into this too, and I don't think it's that simple. By using only the phi = pi limit for calculating the derivatives, I suspect that the dihedral angles simply do not change at all, and so the molecule never gets to the particular geometry where it blows up. So rather than pointing to the problem, it rather sidesteps it.
So rather than pointing to the problem, it rather sidesteps it.
Agreed.
OK, I think I have it. The following: https://github.com/azag0/pyberny/blob/6ba5a4cc113b146a3d67217d8b809f7c81fb59ed/berny/coords.py#L129
should be:
v2 = (coords[self.l]-coords[self.k])/bohr
With the above sugar example, and only this change, the following is seen:
(pyscf) mw529@rabbit:~/code/pyscf/examples/opt$ python sugar.py | grep "converged SCF energy"
converged SCF energy = -600.63274719127
converged SCF energy = -600.648966473777
converged SCF energy = -600.650860701134
converged SCF energy = -600.651526777412
converged SCF energy = -600.651688496354
converged SCF energy = -600.651714384974
converged SCF energy = -600.651721501987
converged SCF energy = -600.65172298699
converged SCF energy = -600.651723317869
Yep! Also fixes #6. Great catch, I'm surprised it causes problems only for planar molecules.
Feel free to create a pull request, I'll be happy to merge it.
Ok, I think I understand. The difference is basically between measuring the dihedral angle clockwise or anticlockwise, so it doesn't matter as long as the formulas for general and ~0, ~pi angles are consistent, and they weren't, they differed in this convention. So once any dihedral swapped from the general to the limiting regime, the angle jumped by 2*pi (or perhaps pi, not sure), which blowed up the algorithm.
At least I think that's what was happening.