How to obtain the Hartree Fock Coulomb and Exchange Matrix

Hi all,

is it possible to obtain the Coulomb matrix J and the exchange matrix K from the wavefunction?

Thanks in advance,

Sounds like a job for the JK class.

# If you want to run the job with symmetry but get J and K without, you'll need to build and recompute after the HF.
h2o = psi4.geometry("""
symmetry c1
H 1 0.96
H 1 0.96 2 104.5

set {
  # If you don't include this command, Psi4 won't know to save the matrices!
  save_jk true

eng, wfn ="scf/sto-3g", molecule=h2o, return_wfn=True)

# Calling J() returns a list for some reason I don't understand, but there's only one element in it,
# so that's the one we want. K probably will as well.

I forgot to mention that I use Python. Is it also possible with Python (I don’t see a function “jk()” of wavefunction)?

Thanks in advance,

Found the solution, it’s basically the same code for extracting the matrices