xtb icon indicating copy to clipboard operation
xtb copied to clipboard

Geometry optimization with C API

Open retinavr opened this issue 5 years ago • 4 comments

Is your feature request related to a problem? Please describe. I am looking into implementing xTB for a VR platform I am developing. So far I have been using the C API, but there does not seem to be any optimization scheme in the C API.

Describe the solution you'd like I imagine it might not be too difficult to implement optimization in the C API as it is already possible through the exe interface.

Describe alternatives you've considered If not possible, maybe point me in a direction so I can write an optimization scheme myself using gradient from xTB.

Ps. I am very rookie at C++ and C, so please be very descriptive in your answers. Thank you.

Kind regards

retinavr avatar Dec 27 '20 18:12 retinavr

Unentangling the geometry optimizer from the xtb source code in a thread-safe way is a bigger project. This means it is not something that can be easily created by exposing the Fortran implementation via iso_c_bindings, but requires some internal restructuring first. For the standalone executable this is easier because we only have one process to care about.

Also, we would have to devise a robust scheme for a driver object in the C-API first to support all internal calculators and potentially external calculators as well.

The current alternative are external optimization programs coupled to xtb via the C-API or the Python-API, but depending on the framework used the algorithm might require many single point evaluations or the optimization step itself can become quite expensive.

To use the xtb internal optimizers the simplest solution would be to extract the optimizer implementation from xtb to another project (still a lot of work).

awvwgk avatar Dec 27 '20 19:12 awvwgk

Thank you for your answer. I understand now why it has not been done yet. Do you think an external optimizer as fx LBFGS++ can be used? I have used the ASE optimizer with xtb-python, but the performance is very poor for my purpose as i need a 5 step optimization to be run in approx 0.015 seconds.

retinavr avatar Dec 27 '20 19:12 retinavr

Certainly it can, you have to write the interface to communicate the geometry change from LBFGS++ to xtb and the energy and gradient back from xtb to LBFGS++. The details depend on how well you can map the representation used in LBFGS++ to the one used in xtb.

The calculation speed on the other hand heavily depends on the system size, the compilation options and the available hardware.

awvwgk avatar Dec 27 '20 20:12 awvwgk

Okay thank you for your help. Very much appreciated.

retinavr avatar Dec 27 '20 20:12 retinavr