How can I pass an array to set the UHF occupation numbers?

Hello,

I have installed the PSIXAS plugin (GitHub - Masterluke87/psixas: A PSI4 plugin for X-ray absorption spectra (XPS, NEXAFS, PP-NEXAFS))

A step in the plugin consists of assigning the eigenvalues and occupation numbers to the UHF wavefunction, and this is the syntax used, where ‘uhf’ is a psi4.core.UHF:

    uhf.epsilon_a().np[:] = epsa
    uhf.epsilon_b().np[:] = epsb

    uhf.occupation_a().np[:] = occa
    uhf.occupation_b().np[:] = occb

epsa, epsb, occa, and occb are arrays. The uhf.epsilon_x().np[:] returns an array of the correct size, but UHF.occupation_x().np contains an empty array, so this syntax returns a “could not broadcast input array” error from shape (X,) to shape (0,).

My guess is that this syntax worked for previous versions of psi4, but that some more recent change to the code resulted in an empty array being created for the occupations. What is the correct way of passing an array to set the UHF occupation numbers?

(Note: For the plugin’s intended purpose, I can simply remove those occupation number assignments and nothing seems to break, but I would like to find a cleaner solution)

I am using v1.5a1.dev151.
Thank you,
Max

At least as far back as the 1.3 release in 2019, occupation_a has never actually been set in Psi4 and has been used only when writing molden files. You can just ignore this, and nothing will break. I’ll file an issue to get this either actually set or removed altogether. (Probably the latter.)

1 Like