# Coefficients of the density fitting

Hello,

I have been trying to do density fittings. I would like to obtain the coefficients of the expansion of the density in the auxiliary basis.

Is there a way to output the coefficients when running a Psi4 calculation with scf_type=df?

Liss

To my knowledge, there is no way to print more details about the density fitting process currently in the code. The coefficients you want are:
\sum_{D} (D | P )^{-1/2}
where D and P are auxiliary basis functions, right ?

I think it would not be difficult to modify the code to print them, if it is for a SCF procedure. I can tell you where to look.

I actually want the coefficients
D_mna = \Sum_a (mn | a)[J^{-1}]_ab
where J is the repulsion integral between the auxiliary basis functions |a> and |b>, |m> and |n> are from the primary basis.
But now thinking again, maybe the codes do not compute those coefficients but only the ones you mention to get (kl|mn)?. In that case, maybe I can get one from the other. I appreciate if you could tell me where to look in the code or if there is a way to have access to the integrals (mn | a) and [J^{-1}]_ab.

Probably the easiest way to do this is through the psi4numpy project: https://github.com/dgasmith/psi4numpy

An example Psi4 input code is shown below:

import numpy as np

molecule mol {
O
H 1 1.1
H 1 1.1 2 108
symmetry c1
}

set {
basis sto-3g
df_basis_scf cc-pVDZ-ri
}

energy('SCF')
wfn = wavefunction()
df = DFTensor(wfn, "DF_BASIS_SCF")

Qso =  np.array(df.Qso())
print Qso

df_ao_eri = np.einsum('pqQ, rsQ->pqrs', Qso, Qso)
print df_ao_eri

mints = MintsHelper()
exact_ao_eri = mints.ao_eri()


This will print out | Q | ao , ao> and then the reformed two electron integrals. We are undergoing some infrastructure changes so this piece of code is in a bit of flux. If it breaks, let me know and I can get you an updated copy.

The inverse coulomb metric is not exposed python side, all 3index tensors are pre-contracted with this. The metric code is in the following file /src/lib/lib3index/fittingmetric.cc.

Oh, okay! Yes, the code is forming the symmetric density-fitted tensors
b_{\mu \nu}^{D} = \sum_{D} (\mu \nu | D) (D | P )^{-1/2}

So we don’t directly have the coefficients you want. You can use what dgasmith indicated with Psi4NumPy to get the b_{\mu \nu}^{D} tensor (the Qso NumPy array in his example).
The inverse Coulomb matrix is not explicitly computed, but in addition to looking into /src/lib/lib3index/fittingmetric.cc as suggested, you can also check out /src/lib/libfock/DFJK.cc, in particular the initialize_JK_core subroutine. Around line 550 (if it did not change too much) is where (D|P)^{-1/2} is built (this part of the code may not be executed for your particular case, though, because we also have initialize_JK_disk, but it is more difficult to understand).

Thank you all!
I’m looking at the code where you indicated.
The input runs perfectly. I’m running it now and leaning how it works. Very helpful! Thanks!