grimme-lab / xtb

Semiempirical Extended Tight-Binding Program Package
https://xtb-docs.readthedocs.io/
GNU Lesser General Public License v3.0
595 stars 148 forks source link

Get gradients at every step during geometry optimization #642

Open aizvorski opened 2 years ago

aizvorski commented 2 years ago

Is your feature request related to a problem? Please describe. I'd like to get the gradients for every step during a geometry optimization

Describe the solution you'd like xtb input.xyz --opt --grad to save the gradients for all steps in the gradients file; or possibly in a new file xtbopt.gradients

Describe alternatives you've considered I tried combining the --opt and --grad options. It apears that if --grad is first, the program does a gradient calculation only; if --opt is first then it does geometry optimization and then saves the gradient from the final structure.

Additional context I'm wondering, would gradients during optimization be almost-free / low-overhead to get? Are they available in ANC coordinates only, or both ANC and cartesian coordinates?

awvwgk commented 2 years ago

The gradients are available at every step, however since they are a rather large vector we so far refrained from printing them along the optimization trajectory.

What do you need the gradients for?

aizvorski commented 2 years ago

The gradients are available at every step, however since they are a rather large vector we so far refrained from printing them along the optimization trajectory.

What do you need the gradients for?

I need a large number of closely related structures with gradients, plus the optimized structure, to get a bit of an idea of the shape of the potential energy surface. I could calculate the optimized structure then perturb it at random (or run md) and do a bunch of single point calculations, but it seems that getting the gradients during optimization would be basically free. I think the optimization is faster than doing many separate single point calculations - does it reuse some of the SCF results?

awvwgk commented 2 years ago

Wouldn't it be easier to drive xtb by the API and provide new structures while performing single points and record the gradient? This way you could easily exploit restarting, without the extra overhead due to IO.

aizvorski commented 2 years ago

@awvwgk It seems that'd be less efficient, double the compute even with restarting. Let's say 100 steps to optimize a structure, then 100 single point calculations with gradient - vs 100 steps to optimize a structure saving gradient at each step