Geometry Optimisation with arbitrary wavefunction

Dear Psi4 team,

I’ve been using your program (python interface) to build an SCF method with corrections for dispersion added to the core Hamiltonian, with good results. We’d like to move to performing geometry optimisations, but this is notably limited to the built in methods.

I note that the optimise function works by repeatedly calling gradients and OPTKING. Assuming I can generate the gradients for the additional terms independently (analytically/numerically/whatever), is there a straightforward way to add them to the optimisation step?


This is something I’ve needed for my own research! I’m going to warn you that this part of the interface is going to be changing soon as part of a larger change to the driver logic and the optimizer.

Here’s what you can do for now:
Call psi4.optimize(your-function-here, dertype=1, molecule=your-molecule-here). The signature Psi expects of your function is shown here. gradient is Psi’s own gradient method, which is passed as the first argument for historical reasons. Your function must return a Psi4 Matrix object as the first argument and a second argument. Although Psi expects this to be a wavefunction, nothing bad will happen if you have something else as your second argument, as long as you don’t pass return_wfn=True to your psi4.optimize call.

In your case, your gradient function will probably be a regular Psi4 gradient call, a call to your dispersion function, and then returning the sum of the two.

Thanks Jonathan, appreciate the quick reply. I’ll give it a try and see how we go.

Great minds on the research :wink: