# RS-RFO Produces Geometry Convergence Problems for Constrained Optimization Scan

I’ve been attempting a constrained optimization scan along a bond formation coordinate. With a step size of 0.01 A, I observe that the steps of the scan do not converge unless I use and periodically update a hessian, and even then convergence can take over 120 iterations. Both of these effects appear to be due to optking taking a step of much larger magnitude than those immediately before, increasing the gradient, after the sudden use of RS-RFO with large values of alpha. I see trouble when it exceeds 30, and it often exceeds 1000 in my computations.

For my first attempt at a scan, I used no initial hessians.

Point 1 converges in 9 steps. The gradient measures increase at steps 7 and 8, but there may not be anything that can be done about this.
Point 2 converges in 34 steps. We see a large gradient increase on steps 3, 12, and 32. The gradient also increases for five consecutive iterations after step 16. Steps 3 and 32 are right after the use of RS-RFO. The RS-RFO before step 3 has alpha of 33.57304, and the RS-RFO before step 32 has alpha of 1909.49410. This seems rather large. I can’t see anything amonalous from the output file about step 12. Step 16 is where suddenly, several RFO roots need to be rejected.
Point 3 would not converge even after 306 steps.
We see RS-RFO used on iteration 2 with alpha of 22.7. On the next step, the gradient increases by an order of magnitude.
We see RS-RFO used on iteration 3 with alpha of 2.79. On the next step, the gradient decreases by an order of magnitude. Note that the alpha is much smaller this time.
We see RS-RFO used on iteration 24 with alpha of 1029. On the next step, the gradient increases by about a factor of 30.
We see RS-RFO used on iteration 25 with alpha of 1039. On the next step, the gradient doubles.
We see RS-RFO used yet again on iteration 26 with alpha of 1629. On the next step, the gradient doesn’t change much.
We see RS-RFO used yet again on iteration 27 with alpha of 910. The gradient doubles again, bringing us to the 10^-2 order of magnitude. We were around 10^-5 when we started this consecutive chain of RS-RFO.
It keeps using RS-RFO and not getting much of anywhere for a couple more iterations.
We see RS-RFO used on iteration 46 with alpha of 1907. On the next step, the gradient increases by an order of magnitude.

I can continue, but I think the point is pretty clear: RS-RFO with large alpha is a problem for this optimization. Is there something that can be done to cure these convergence problems?

You can access the output for scan one here. The output file for scan 2, I can supply if you’d like. It’s much of the same, but it’s currently over 2 million lines.

@Rollin_King

This is a great test case. I will look at it in detail (probably tomorrow).

The implemented algorithm to apply a non-satisfied constraint (fixed distance in this case) is a very primitive one. There is a harmonic potential added along the fixed coordinate with a corresponding force constant that is increased with each iteration. You can beef up this force more quickly using, e.g.,

fixed_coord_force_constant = 2.0

However, in this case the problem may not be the arbitrary, additional force. This system has hydrogen bonds in a dimer - along with their angular low-energy motions. This will never be easy.

If you set

simple_step_scaling = True

then the restricted-step RFO will not be used. Instead the RFO step sizes will simply be scaled down. In my very limited testing this performed very marginally better than the ‘proper’ RS-RFO step in this case. Once the step sizes are small (<0.1au is initial default), neither restriction is in effect. I tried the Newton-Raphson step

step_type = NR

and it behaved very similarly. There is steepest-descent code which may be good as a last resort. I haven’t tried it out in awhile, and it will typically take many iterations.

In conclusion, you can try simple_step_scaling to see if the iterative solution for alpha in RS-RFO is the problem. And you can try N-R steps, to see if the RFO equations are the problem. And if you are still struggling to converge, then the problem is probably just searching a near planar subsurface with a quadratic method.

I knew hydrogen bonds wouldn’t be easy, but I had forgotten they could be this bad.

Thanks for the advice. My system has thrown more pathologies at me, so I’m changing tactics from the original scan, but I’ll likely come back to the scan before long. I’ll report back with how those recommendations work.