Extracting optimized geometry

I want to extract the optimized geometry. Is there a way this can be done using the API or should I parse it out of the log file?

Many Thanks,

Chris

Sure, using the Psi4 API it can be accessed in two ways:

import numpy as np
import psi4

water = psi4.geometry("""
O 0.0  0.0  0.0
H 0.0  0.0  2.0
H 0.0  2.0  0.0
units bohr
""")

scf_e, scf_wfn = psi4.optimize("B3LYP/sto-3g", molecule=water, return_wfn=True)

print(np.array(scf_wfn.molecule().geometry()))
print(np.array(water.geometry()))

Note that the output is in Bohr.

Awesome, thank you very much!

Chris

Is the output always in Bohr?
Say, if I enter the geometry in Angstrom and then print the geometry to an array as you showed. Are the units converted to Bohr?

Also, if now I want to alter the numpy array and then pass the changed geometry to psi4 to take it as an input. How do I convert the numpy array to a psi4 type geometry matrix?

Please read the documentation before asking a question.

Yes, units are always in bohr.

Our page on the NumPy interface has a dedicated section on converting between np.array and psi4 Matrix objects.