Chemistry - Transforming AO basis electron repulsion integrals into molecular spin orbital basis?
Solution 1:
I am not sure whether this is it, but I think your equation in step 2 should be:
\begin{equation} \langle pq|rs\rangle = \left(\frac{p}{2}\frac{r}{2}\middle|\frac{q}{2}\frac{s}{2}\right) \delta_{r\%2, p\%2} \delta_{s\%2, q\%2} \end{equation}
The idea for $(pr|qs)$ is to store $\frac{N}{2}$ spatial orbitals representing $N$ spin orbitals, by remembering that each orbital appears twice (one $\alpha$, one $\beta$). So the indices $p,q,r$ and $s$ go only up to $\frac{N}{2}$ for the spatial ERIs.
Note that we use an integer division here: $\frac{3}{2}=1$ and $\frac{2}{2}=1$. Thus there are always two spin indices mapping to the same spatial index. One might also write the spin indices as compound indices, consisting of one spatial index and the spin state: $0\alpha, 0\beta, 1\alpha, 1\beta, \dots$.
But for the spin ERIs $\langle pq|rs\rangle$ the indices run up to $N$. So with $(pr|qs)$ you would try to access elements outside of it (as soon as the indices become greater then $\frac{N}{2}$). You can also find this in the code of your linked hint.
Furthermore, I think you are mixing up the different notations. Hopefully this will clarify it: According to the book by Szabo and Ostlund the notation for these integrals should be:
- $\langle ij|kl\rangle$ is physicists' notation for spin orbitals ($i$ and $j$ are bra-vectors of different electronic coordinates)
- $[ij|kl]$ is chemists' notation for spin orbitals ($i$ and $j$ are bra- and ket vector of the same electronic coordinate)
- $(ij|kl)$ denotes spatial orbitals following the ordering of the chemists' notation
There is no "physicists'-like" notation for spatial orbitals.
We can relate chemists' and physicists' notation by
\begin{equation} [ij|kl] = \left<ik|jl\right> \end{equation}
Also it defines \begin{equation} \langle pq||rs\rangle = \langle pq|rs\rangle - \langle qp|rs\rangle \end{equation}
which means your
\begin{equation} \langle pq||rs\rangle = (pr|qs) - (ps|qr) \end{equation}
should be wrong. But maybe you are already using the correct thing in your code there, just with the wrong notation?
Solution 2:
I think the answer given for Fedoran is what you are asking for, on a site note, for the implementation you are doing take a look at Coupled Cluster with Singles and Doubles (CCSD) in Python , I think I found a few mistakes in it, but it gives the overall most simple implementation. A tested to work implementation that is very equivalent to the previous link can be found here, python CCSD(T)