ifilot / hfcxx

Hartree-Fock C++ code
GNU General Public License v3.0
28 stars 16 forks source link

benzene gives incorrect SCF energy for sto-6g basis set #5

Closed AlexB67 closed 1 year ago

AlexB67 commented 3 years ago

benzene gives incorrect SCF energy for sto-6g basis set

Hello,

Just to let you know. I didn't look into it. I use a different method for the integrals. From memory way back I think I may have spotted something in the kinetic integrals but that was for d orbitals anyway, which you don't use, but don't hold me to that.

Your project was a great help to get started and inspired me to write my own.

hfcxx

Number of orbitals: 36 Number of GTOs: 216 Number of iterations: 40 Total energy [Hartree]: -228.9254378

My code

Basis set = STO-6G Basis set type = cartesian Number of basis primitives = 144 Number of actual GTOs = 216 Number of basis functions = 36 Number of shells = 24

more stuff **

E(NUC) / Eh = 203.36795083 E(1E ) / Eh = -714.19179571 E(2E ) / Eh = 280.69350348 E(SCF) / Eh = -230.13034140

Which agrees with the psi4 pacakge.

Your sto-3g result checks out fine.

Cheers.

aromanro commented 3 years ago

As the difference between STO3G and STO6G is not that big, only the number of gaussians are different, I suspected a basis error and it appears I found something https://github.com/ifilot/hfcxx/blob/master/src/basis-sto6g.cpp#L199:

    if(type.compare("2pz")==0 && z==6) {
        addGTO_pz(30.497239499999999, 0.0037596966000000001,r);
        addGTO_pz(6.0361996009999999, 0.037679369800000001,r);
        addGTO_pz(1.876046337, 0.17389674350000001,r);
        addGTO_pz(0.72178264700000005, 0.41803643470000001,r);
        addGTO_px(0.3134706954, 0.42585954770000001,r);
        addGTO_pz(0.14368655499999999, 0.1017082955,r);
    }

It's a typo, addGTO_px should be addGTO_pz.

It's a nice program, I used it to compare some values from the computations with mine.

By the way, as a suggestion, it's not a big change to load the basis sets from files instead of hardwiring them in the code. I did that and I can load various basis sets: https://github.com/aromanro/HartreeFock

AlexB67 commented 3 years ago

As the difference between STO3G and STO6G is not that big, only the number of gaussians are different, I suspected a basis error and it appears I found something https://github.com/ifilot/hfcxx/blob/master/src/basis-sto6g.cpp#L199:

    if(type.compare("2pz")==0 && z==6) {
        addGTO_pz(30.497239499999999, 0.0037596966000000001,r);
        addGTO_pz(6.0361996009999999, 0.037679369800000001,r);
        addGTO_pz(1.876046337, 0.17389674350000001,r);
        addGTO_pz(0.72178264700000005, 0.41803643470000001,r);
        addGTO_px(0.3134706954, 0.42585954770000001,r);
        addGTO_pz(0.14368655499999999, 0.1017082955,r);
    }

It's a typo, addGTO_px should be addGTO_pz.

It's a nice program, I used it to compare some values from the computations with mine.

By the way, as a suggestion, it's not a big change to load the basis sets from files instead of hardwiring them in the code. I did that and I can load various basis sets: https://github.com/aromanro/HartreeFock

Thanks Yeah I already load basis sets from files too. Mine reads psi4 compatible basis sets. I used hfcxx earlier on to compare answers. looks like you found it anyway. :)

aromanro commented 3 years ago

My suggestion was for this program, not for yours, as I don't know yours :)

I can point for you to this: https://github.com/CrawfordGroup/ProgrammingProjects though, I doubt you implemented everything suggested there.

I started to add some things to mine from those suggestions, dipole integrals, population analysis, Moller-Plesset, CCSD(T) and DIIS. Hopefully this year CIS and TDHF/RPA will follow, maybe also Davidson-Liu.

AlexB67 commented 3 years ago

My suggestion was for this program, not for yours, as I don't know yours :)

I can point for you to this: https://github.com/CrawfordGroup/ProgrammingProjects though, I doubt you implemented everything suggested there.

I started to add some things to mine from those suggestions, dipole integrals, population analysis, Moller-Plesset, CCSD(T) and DIIS. Hopefully this year CIS and TDHF/RPA will follow, maybe also Davidson-Liu.

Thanks, Yes, i am aware of the links, It' s where I stared from. I implemented them all (CCSD can be done much faster for closed shell than is described there. See https://pycrawfordprogproj.readthedocs.io/en/latest/Project_05/Project_05.html for all needed equations) except for the DL algorithm.

Instead I focused on first and second derivative integrals to calculate gradients and the Hessian for geometry optimisation/frequencies (Cant get away from my spectroscopic roots, got to have them frequencies ::D ) , which I have implemented up to MP2 level. Much help can be found in the psi4numpy tutorials too.

It'll be uploaded one of these days/weeks/months .. but I keep adding and never feel it is quite done. but it's getting closer. I would like to optimise my integral code a bit more and do it in shells instead of per basis function before uploading.

ifilot commented 1 year ago

Thank you for reporting this error. The erroneous line

addGTO_px(0.3134706954, 0.42585954770000001,r);

has been replaced by

addGTO_pz(0.3134706954, 0.42585954770000001,r);

The STO-6g calculation of benzene has furthermore been added to the test suite.