MintsHelper mo_eri error

I am trying to get electron repulsion integrals in the MO basis with MintsHelper.

I initiated the class instance with the basisset and tried to get mo_eri() but it throws up an error. I am nit sure what’s going wrong here?

Also, scf_wfn is the wavefunction object returned by psi4.energy(‘hf’, return_wfn=True).

My code snippet:

Ca = np.asarray(scf_wfn.Ca_subset('AO','ALL'))
basis = scf_wfn.basisset()
mints = psi4.core.MintsHelper(basis)
ao_eri = mints.ao_eri()
mo_eri_pis4 = mints.mo_eri(Ca,Ca,Ca,Ca)

The error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_381763/1076174165.py in <module>
      3 mints = psi4.core.MintsHelper(basis)
      4 ao_eri = mints.ao_eri()
----> 5 mo_eri_pis4 = mints.mo_eri(Ca,Ca,Ca,Ca)

TypeError: mo_eri(): incompatible function arguments. The following argument types are supported:
    1. (self: psi4.core.MintsHelper, C1: psi4.core.Matrix, C2: psi4.core.Matrix, C3: psi4.core.Matrix, C4: psi4.core.Matrix) -> psi4.core.Matrix

Invoked with: <psi4.core.MintsHelper object at 0x7fe8d98300f0>, array([[ 1.72637853e-04,  9.96107580e-01,  1.34603787e-03,
         1.42351865e-01,  1.50625253e-01,  4.93247679e-02,

The Ca in your snippet are numpy arrays but the mo_eri() function requires psi4.core.Matrix objects as arguments.
Interconversion does not happen automatically.

Removing the numpy conversion should work:

Ca = scf_wfn.Ca_subset('AO','ALL')

Oh! that seems strange, when I tried to convert the array into matrix with numpy.matrix() This for the case where tried to manipulate the tuple generated by scf_wfn.Ca().nph into a single array then to a matrix.

Though it seems to work if I just pass scf_wfn.Ca_subset('AO','ALL')

Thanks!

numpy.matrix() is something else.
psi4 has it’s own Matrix class.

numpy<->psi4.core.Matrix conversion help can be found here: Interface to NumPy