Hi all,

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

Thanks in advance,

Wiktor

Hi all,

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

Thanks in advance,

Wiktor

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.
# https://github.com/psi4/psi4numpy/blob/master/Tutorials/04_Density_Functional_Theory/ks_helper.py#L88-L106
h2o = psi4.geometry("""
symmetry c1
O
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 = psi4.energy("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.
wfn.jk().J()[0].print_out()
```

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,

Wiktor

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

`wfn.jk().J()[0].to_array()`