Improved error message when using incorrect reference type

Dear all,

I noticed that when accidentally using RHF reference for an open-shell system and running Psi4 via the Python package, I get an error like

SystemError: <built-in method __init__ of PyCapsule object at 0x2ad0f92b5240> returned NULL without setting an error

Call stack:

psi4/driver/procrouting/, line 1005, in scf_wavefunction_factory
    wfn = core.RHF(ref_wfn, superfunc)

This was confusing to me initially and took me a little while to figure out. A simple check at the beginning of a run whether a compatible reference method was chosen for the given system, along with an informative error message, might save new users from such mistakes.

Could you please provide a minimal example? And which psi4 version is this?
Usually the error message for an incompatible reference is more explicit.

The problem is not that we are missing a check, but that the error message we already have isn’t firing. When I try to run water cation as an RHF system, I get an error message like you requested.

molecule {
1 2
H 1 1.0 
H 1 1.0 2 104.5

set reference rhf 
!                                                                                  !
! Fatal Error: RHF: RHF reference is only for singlets.                            !
! Error occurred in file:                                                          !
!     /Users/jonathonmisiewicz/psi4/psi4/src/psi4/libscf_solver/ on line: 92 !
! The most recent 5 function calls were:                                           !
!                                                                                  !

As Holger said, we need more information. Steps 4 and 5 of our guidance for posting help topics are not optional. In addition to what Holger requested, I need to know how you ran your input. I’ve seen one error message about PyCapsule before, and that was a problem specific to when Psi was running in a Jupyter notebook.

Dear all,

Apologies for the late reply and for not providing a better problem description earlier. When I just tried to create a minimal reproducible example, I was unable to reproduce this observation and did in fact get the expected RHF reference is only for singlets error message. This was with Psi4 1.3.2 running from the Python interface. I’ll let you know in case I do manage to reproduce this.

Have a good weekend!