Fock Matrix in Original Basis

Following SCF calculations I am trying to output the Fock matrix in the original (AO) basis - without success. I have tried using the method Fa_subset( , ) but this is not recognised by the computation, despite many different attempts with different syntax. Any help appreciated. Thanks.

Something like this?

e,wfn =energy('hf',return_wfn=True)
F_ao = wfn.Fa_subset("AO").to_array() # psi4 object to numpy array; see core.Vector class

Many thanks for your reply - still having problems. See input and error message below (testing optimizer).

memory 600 mb

molecule ch4 {
C 0 0 0
H 1 0 0.1
H -0.5 0.1 0.5
H -0.5 0.5 -0.6
H -0.6 -0.5 -0.5

set basis cc-pVDZ

Optimizer: Optimization complete!
Traceback (most recent call last):
File “/home/donald/psi4conda/bin/psi4”, line 269, in
File “”, line 34, in

AttributeError: ‘psi4.core.RHF’ object has no attribute ‘Fa_subset’

What am I missing? Thanks in anticipation.

What version of Psi4 do you have?

Output files show Psi4 1.2.1

You may need Psi4 1.3+ to use this feature.

Hi again. Further to this subject - can you advise? I am using psi4 in psithon mode. I have the statements:


I have a problem understanding some of the arguments in - “append=True”. Append what? This is a general problem for me with psi4; I find it difficult to find detailed information on function arguments and what they mean in the psi4 manual (I am a real novice with ab initio calculations). Is there a repository of detailed information that I am missing maybe? Please don’t misunderstand me - I think psi4 is awesome !!

I use the lower triangular Fock matrix with Multiwfn to derive localized orbitals. However, for some simple molecules and basis sets I find that only returns the non-zero entries. Is that what you would expect?

Hope you can help. Many thanks.

You are right about the missing documentation. Active developers are facing the same problems.
The C++ source code has strings for documentation( doxygen ), but they are not picked up by the documentation mechanism with sphinx. And the manual transfer (or some other solution) has not happened.

The C++ Matrix class is “documented” here:
The available python bindings are here (which you probably already use, but just for completeness):

append=True would mean that the file is not overwritten but the next matrix is appended.

Not sure about that. Is does not print the full triangle?

Many thanks for the very useful response (hokru - I note you are one of the main responders on the forum. Many thanks for taking the time; you are such a good guy!).

Fock matrix return - I attach an “in” file with corresponding “out” and “Fock” files. The Fock file contains only the non-zero values. Can you advise if my “in” file contains errors? Many thanks.h2o.out.dat (150.7 KB) (469 Bytes) h2o.Fock.dat (1.9 KB)

From what I gather, the original plan was that developers would fill in the documentation as they needed it themselves. …And that never really happened, so you have the current state of affairs. One of the other developers (Lori) says she plans to do a documentation pass, so I’m hopeful for some improvements soon. In the meantime, I’m adding documentation that I find I need.

For your case, you’re misinterpreting what the third keyword to “save” does. saveLowerTriangle does not mean save the lower triangle also but save the lower triangle only. To get the entire matrix, just set that keyword to False.

I think you should stay away from this particular save function.
It only writes values >1e-12, which makes it ill-suited for data exchange where small values might occur.

Going via the numpy route is saver:


This will print the full matrix and you can modify the print out (

There surely are also smart ways to get only the upper/lower part if you need it.