Custom optimization routine

Hello,

I am a new user of psi4.

I want to create a customized simple optimization cycle using the energy(), gradient(), and optking() routines. I am attaching a test.py file with water optimization as example (the steps are copied from the optimize() routine of psi4 obviously). Although I am able to optimize the water molecule, the condition at line 32 seems never satisfy and thus the while loop continues until the end (the function optking() returns number not logical value hence, the condition never satisfy).

So, my question is: is it possible to check the geometry optimization convergence this way?

Thank you in advance.
test.py (1.0 KB)

You can either follow the optimize routine (something like if optimization_status == psi4.core.PsiReturnType.EndLoop:) or use the numbers directly. The number should correspond to these:
enum PsiReturnType { Success, Failure, Balk, EndLoop }; (see psi4-dec.h)

You can of course also test convergence yourself using the energy and gradient you compute.

Thank you very much.

That solved the problem.