duartegroup / autodE

automated reaction profile generation
https://duartegroup.github.io/autodE/
MIT License
165 stars 51 forks source link

Add trust-radius quasi-Newton optimiser #262

Closed shoubhikraj closed 1 year ago

shoubhikraj commented 1 year ago

Major changes:

Minor changes:


Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #262 (6437fe3) into v1.4.0 (7b89cd2) will increase coverage by 0.00%. The diff coverage is 97.57%.

@@           Coverage Diff            @@
##           v1.4.0     #262    +/-   ##
========================================
  Coverage   97.26%   97.27%            
========================================
  Files         195      197     +2     
  Lines       20417    21006   +589     
========================================
+ Hits        19859    20434   +575     
- Misses        558      572    +14     
Flag Coverage Δ
unittests 97.27% <97.57%> (+<0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
autode/opt/optimisers/base.py 98.19% <92.85%> (-0.50%) :arrow_down:
autode/plotting.py 96.05% <94.59%> (-0.62%) :arrow_down:
autode/opt/optimisers/trm.py 95.00% <95.00%> (ø)
autode/exceptions.py 100.00% <100.00%> (ø)
autode/opt/coordinates/base.py 100.00% <100.00%> (ø)
autode/opt/coordinates/dic.py 100.00% <100.00%> (ø)
autode/opt/optimisers/__init__.py 100.00% <100.00%> (ø)
autode/opt/optimisers/crfo.py 99.13% <100.00%> (ø)
autode/opt/optimisers/hessian_update.py 97.61% <100.00%> (+0.66%) :arrow_up:
autode/opt/optimisers/rfo.py 100.00% <100.00%> (ø)
... and 6 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

shoubhikraj commented 1 year ago

Comparison:

HybridTRIMOptimiser

QARFO_opt_plot

RFOptimiser

(only works if unconverged backtransfrom is allowed for the geometry step)

RFO_opt_plot

For a random organic molecule (opt-test.xyz). opt-test.xyz.txt

Only tested one molecule, trends might be different for others.

t-young31 commented 1 year ago

The optimiser also has a damping feature which detects oscillations in energy and gradient, and interpolates between the last two coordinates to damp the oscillation.

How well does this work? could we also add it to the PRFO for TS optimisations?

shoubhikraj commented 1 year ago

How well does this work? could we also add it to the PRFO for TS optimisations?

Yes I think this can be added to PRFO optimiser as well. I don't know how well this works, I got the idea from reading Baker's paper on constrained optimisation in cartesian coordinates. In his case, he uses gradient of the lagrangian multipliers. In simple minimisation I didn't know what to use, so I simply used the gradient norm and energy. If they both oscillate in the last three iterations (i.e. up, down, up; or down, up, down) then it takes the average of the last two iters. It's entirely my idea and there might be better ways of doing this. In my very limited tests, there was only one damping event in the total optimisation.

I cannot find any reference anywhere else about damping oscillations (strange!). I remember having lots of problems with oscillation in the Gaussian optimiser.

Do you think it would be better to do something like energy oscillating in the last two iterations, and energy has not gone down in the last 4-5 iterations? (because oscillation is not always two iteration periodic, sometimes I saw oscillations that are 3 iteration periodic as in up, up, down in Gaussian with DFT)

shoubhikraj commented 1 year ago

@t-young31 Could you please leave the PR open? I planned to include polynomial line search but forgot about it, so I will have to add it. I will add it in a later PR.

shoubhikraj commented 1 year ago

@t-young31 I am finished with the changes. Please could you have a look and if you don't have anymore suggestions, feel free to merge this.