HOMO LUMO extracting energies does not work

Hi, I am trying to extract HOMO LUMO energies from the wavefuction in this way:

HOMO = scf_wfn.epsilon_a_subset(“AO”, “ALL”)[scf_wfn.nalpha()]
LUMO = scf_wfn.epsilon_a_subset(“AO”, “ALL”)[scf_wfn.nalpha() + 1]

it works perfectly with the 1.1 version, but when I use version 1.2.1 , I got the following error:

HOMO = scf_wfn.epsilon_a_subset(“AO”, “ALL”)[scf_wfn.nalpha()]
TypeError: ‘psi4.core.Vector’ object does not support indexing

Any ideas?

That error message could be a lot clearer, and in 1.3, it will be. (For devs, the error message change is included in Py-Findif.) I’m assuming that @dgasmith changed how Psi interfaces with NumPy between 1.1 and 1.2, and that’s what caused the change.

When you call epsilon_a_subset, it doesn’t return a NumPy array directly. It returns a Vector object, from Psi’s internals. This can be useful in some more advanced cases, but if you just want a list of the energies for orbitals with alpha spin, here’s what you can do:

HOMO = scf_wfn.epsilon_a_subset("AO", "ALL").np[scf_wfn.nalpha()]
LUMO = scf_wfn.epsilon_a_subset("AO", "ALL").np[scf_wfn.nalpha() + 1]

.np will let you access the elements of scf_wfn.epsilon_a_subset("AO", "ALL") just like it was a NumPy array!

1 Like

Awesome, thank you, it works!!!