« first day (733 days earlier)      last day (625 days later) » 

9:19 PM
4
Q: Hartree Fock Algorithm too high values for Molecules

lela2011I am working on a high school graduation paper on Hartree Fock and have gotten pretty far already. With help from this community, I managed to generate all the necessary integrals and implement the algorithm in python. I am currently checking whether the algorithm is actually doing what it's supp...

Haven't gotten a chance to look at your code, but the fact that it works for atoms, but not molecules suggests you have something wrong with how distance between basis functions affects the results of 1 or 2 electron integrals. You are comparing the end result with pyscf, but have you tried directly comparing your 1 or 2 electron integrals with those produced by pyscf? — Tyberius ♦ Aug 27 at 22:14
@Tyberius that can't be the issue. At least that's what I believe. I straight up copy the integrals from pyscf. All the necessary numerical values are generated by pyscf. In other words: I will calculate the integrals at some later point but right now I'm using precalculated ones. — lela2011 Aug 28 at 6:58
You are computing the total energy as the sum of eigenvalues, but that will miss the nuclear repulsion energy (the interaction between different nuclei). Give it a try computing it yourself! — AwakenYesterday Aug 28 at 9:15
@AwakenYesterday I am aware of that. I am however comparing the array of energies with the value called mo_e that is returned on line 108 in the pyscf example. For Atoms these match up. Isn't the mo_e value only the array of eigenenergies returned by diagonalization or am I missing something? — lela2011 Aug 28 at 9:44
I wouldn't be surprised if a random guess were to give you an energy that's too high. Sometimes even with the default initial guess in MRCC, which is scfiguess=sad or "Superpositions of atomic densities. For each atom a density-fitting UHF calculation is performed, and the initial one-particle density matrix is constructed from the averaged alpha and beta atomic densities" I don't get the right energy so I change to ao which is "Atomic density initial guess. The initial one-particle density matrix is constructed from...". — Nike Dattani 2 days ago
@NikeDattani I don't quite understand what you're proposition. If I try to use the '1e' initial guess in pyscf it also results the same result that's different from mine. — lela2011 2 days ago
Are you saying that two different initial guesses in PySCF gave the same answer? My proposition is for you to use the same initial guess as PySCF or MRCC, rather than a random one. However, when you said "I've also tried generating completely random initial guesses. I get the exact same results as well" it probably means that you tried something in addition to the random guess. Was it the same as what PySCF does? I don't see where in your question you tell us what initial guess you tried other than the random one! — Nike Dattani 2 days ago
@NikeDattani Okay. So this is what's going on. My standard initial guess is the "1e"-guess. E.g. a zero-matrix. This returns too high vaues. I then tried generating a random matrix between -100 and 100 as it's values. This returns the same too high values. I then checked whether the initial guess was wrong. So I calculated the energies using PySCF with the "1e"-guess. This returned the same values as PySCF using the "minao" guess (pyscf.org/user/scf.html). So PySCF returns the same value for different guesses but these values are different to my results. — lela2011 2 days ago
I have some suggestions for you to check your code: If you use 1e, 2e integrals and converged MO coefficients from PySCF, can you get exactly the same HF energy as that of PySCF? If you obtain the same HF energy at the 1st cycle but it takes more than 3 cycles to converge, or it converges to any higher energy, it means that there is something wrong in your SCF iteration (e.g. wrong implementation of DIIS). If you cannot even obtain the same HF energy at the 1st cycle, it means that your HF energy formula is wrong. — jxzou 10 hours ago
@jxzou (1) Okay. I think we're getting closer to the problem. I'll quickly explain what I've done for checking my code till now: All the stuff I described in the comments (comparing results with standard PySCF calculation for same starting guess). In the last few days I checked all my matrices. E.g. is the generated core matrix the same as mine, is the Overlap matrix the same and is the fock matrix for a given density matrix the same as the fock matrix PySCF generates for the same density matrix. Those matrices all match and are the same. Let me quickly explain how I implemented the algorithm. — lela2011 2 hours ago
@jxzou (2) I generate the fock matrix for a given density matrix. I use the transformation matrix to generate F'. I then diagonalize F' and transform the coefficients back to the not transformed coefficients. These coefficients I feed back into the algorithm in the form of a density matrix. I do no such thing as DIIS, level shifting or damping. Might that be the issue? — lela2011 2 hours ago
@jxzou (3) I added my algorithm and what I've tried in an update in the post. — lela2011 1 hour ago
What convergence criteria are you using? Change in energy, change in coefficients, etc? — Tyberius ♦ 8 mins ago
@Tyberius I sum the orbital energies and check the difference to the sum of the energies of the last iteration. If the difference is less than 0.0001 I say that it converges. — lela2011 8 mins ago
@lela2011 And how different are the orbital energies from the PySCF ones? I don't know of any QM package that uses the orbital energies themselves to determine convergence, but with whatever approach is used, they try to ensure a convergence of the energy to around 10^-12.
 
For a HF molecule it is between 1
*between 1.1 and 1.7 eV higher than the molecular energies provided by PySCF
 
So I wouldn't be surprised if your seemingly much less strict criteria didn't lead to convergence. Also are you just summing the orbital energies to get the total energy? The HF energy is not just the sum of the orbital energies chemistry.stackexchange.com/questions/153590/…
 
@Tyberius I guess you mean 0.0001 eV? Because 0.0001 Hartree isn't a very tight convergence criterion.
Oops! That was supposed to go to @lela2011!
I clicked the "reply" button no lela's message which was transferred here by Tyberius and it automatically pinged Tyberius instead.
 
I am using the mo_energy return value that you can see here: pyscf.org/_modules/pyscf/scf/hf.html (docstring for kernel method) I believe this this is not the HF energy being returned but the diagonal values of the energy matrix.
And yes. My convergence criterion is 0.0001 eV
 
9:44 PM
@lela2011 I didn't see your response since I didn't get an @ ping. I was lucky that I saw that you wrote something, because I was browsing the rooms randomly. Tyberius might not have seen your reply either. I'm pinging him (@Tyberius) in case he wanted to see your answer about how you were calculating the energies.
 
@NikeDattani I'm sorry. I totally forgot to direct my answer to you two
 

« first day (733 days earlier)      last day (625 days later) »