Obtaining result from oeprop in Python API

Dear all,

After I have computed a wavefunction, I am trying to obtain one-electron properties, e.g. the molecule’s dipole moment. Doing

p4mol = psi4.core.Molecule.from_string(xyz_str, dtype="xyz+", name="mymol", fix_com=True)
E, wfn = psi4.energy("hf", molecule=p4mol)
oeprop = psi4.core.OEProp(wfn)

does not throw an error, but I cannot find any results under oeprop.Exvals(), oeprop.Eyvals(), oeprop.Ezvals(), or oeprop.Vvals() and I do not see any files written to disk.
I’d be grateful if somebody could point me towards what I’m doing wrong.

Thank you and best regards,

These are only for specific grid-based properties.

Secondly, you need to request the wfn from the energy function with E,wfn=energy('hf',..,return_wfn=True)

The dipole moments should be available as PSI variables.
Is this still version 1.3.2?

For 1.3.2 you can use:
psi4.core.variable(' DIPOLE X') will return a scalar in a.u.

For the current development version and upcoming 1.4
wfn.variable('DIPOLE') will return an array in Debye (not 100% sure about units now)

Thank you very much for the quick reply (and all your past replies, for that matter)! I forgot to include return_wfn=True when retyping the commands, thanks for pointing that out. And yes, I’m using version 1.3.2. I couldn’t find instructions on how to access PSI variables in the Python API.

I think I don’t understand what you mean with this relating to oeprop.Exvals(), could you please elaborate?

The manual entry is here: http://psicode.org/psi4manual/1.3.2/psithoninput.html#psi-variables
The psi4.core.get_variable() command used there will be deprecated (you’ll get a warning what to psi4.core.variable()).

What Exvals()contains is mentioned at the bottom:

Thank you very much for pointing me in the right direction, this was very helpful. I’ll briefly document my understanding for anyone who stumbles over this post (and possibly my future self).

Exvals(), Eyvals(), and Ezvals() only ever contain the x, y and z components of the electric field, and only if it was previously computed using something like

level_of_theory = "hf"
E, wfn = psi4.energy(level_of_theory, return_wfn=True)
oeprop = psi4.core.OEProp(wfn)

The values are then computed on the grid specified in grid.dat and are accessible through oeprop.Exvals() etc.

The same goes for oeprop.Vvals(), which contains the electrostatic potential on the given grid if computed with oeprop.add("GRID_ESP"); oeprop.compute().

All other one-electron properties can be computed using the same syntax, which adds them to psi4.core.variables(). They are accessible through psi4.core.variable(<variable_name>).

Could you mark the topic solved?

Also note that in future versions of PSI4 we are switching to wfn.variables(), i.e. variables are local to the wfn object. The psi4.core.variables() are sort of global will be overwrritten if a second calculation is run.

Thanks for the heads-up!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.