Estoy tratando de hacer un Hartree-Fock solver, usando Python, siguiendo Daniel Crawford guía.
He tenido éxito con los primeros cuatro pasos. Sin embargo, estoy teniendo algunos problemas con esta parte en el paso 5:
$$ F^0_c C^{'}_0 = C^{'}_0 \epsilon_0 $$
I have the correct transformed Fock matrix (I can verify this as the site as step-by-step matrices that you can check against). My problem is that the MO coefficient matrix I get does not quite match the one on the site. I obtain it by multiplying the above equation by $C^{' -1}_0$ on the right:
$$ F^0_c = C^{'}_0 \epsilon_0 C^{' -1}_0 $$
Now it's in diagonalized form, which means $C^{'}_0$, the transformed MO coefficients, is the eigenvectors of $F^0_c$ and $\epsilon_0$ is a diagonal matrix of the eigenvalues. After I obtain $C^{'}_0$, I obtain the original untransformed MO coefficients $C_0$ using the next equation on the site:
$$ C_0 = S^{-1/2} C^{'}_0 $$
where $S^{-1/2}$ is the transformation matrix used to get the transformed Fock matrix from earlier. My transformation matrix, by the way, matches exactly the one on the site.
This is where my problem comes in. The $C_0$ matrix I get is this:
The one the website has as a reference is this:
If you look carefully, you will notice that mine and the reference one have the same columns; however, some are swapped around, and some have sign flips. This causes problems with the next steps, such as finding the density matrix.
I thought maybe the order should be such that $\epsilon_0$ is in order. The $\epsilon_0$ matrix I get is indeed out of order, and the same permutations and sign flips that will make it in order also makes my $C_0$ match the reference one in terms of where each column is, but NOT sign. Sadly the reference site does not have a $\epsilon_0$ matrix or $C{'}_0$ for me to compare with, only the final $C_0$, so I'm not sure if those are coming out of order also.
My first question is, will these sign flips matter? Is ordering the $C_0$ matrix in terms of getting $\epsilon_0$ the right thing to do?
I am carrying out these matrix operations with basic NumPy functions such as numpy.linalg.eig
and numpy.dot
. Nothing fancy there. It's worth noting that finding the transformation matrix, $S^{-1/2}$, requires diagonalizing in a similar way, but I didn't have any column switching problems there. It came out exactly as expected.
My second question relates to building the density matrix at the end of step 5. The website has this equation:
$$ D^0_{\mu\nu} = \sum_{m}^{oc} (C_0)^m_\mu (C_0)^m_\nu $$
It says sum over the occupied MOs. The molecule being used in the example calculation is water, so two H's, and one O, so there are 10 electrons, so 5 orbitals. If I sum using the correct $C_0$ matrix I get on the reference website, from m = 1 to 5, I get the correct $D^0_{\mu\nu}$ result. However my textbook (Szabo and Ostlund, Modern Quantum Chemistry) has this equation (changing some of the notation to match):
$$ D^0_{\mu\nu} = 2 \sum_{m}^{N/2} (C_0)^m_\mu (C_0)^m_\nu $$
Donde N es el número de electrones. Bueno, 10/5 es 5, así que me voy a sumar de 1 a 5, de nuevo, pero ahora hay un 2 en la parte delantera, por lo que la suma será doble. Ahora, usando la una en la web me pone la respuesta correcta, pero ¿podría este 2 en el libro significa?