The following script loads a molecule geometry from a file (a text file containing the element names and atom coordinates) and then calculates the closed shell restricted Hartree-Fock wave function of it.
from ct8k import * from ct8kpy import * SetOutputUnits( ENERGY_ElectronVolts, DISTANCE_Angstrom ) LoadBasisLibrary( "../basis_lib/cc-pVDZ.libmol" ) def main(): Atoms = FAtomSet() Atoms.AddAtomsFromXyzFile( "../molecules/ethene.xyz", "cc-pVDZ" ) (Converged, Energy) = HartreeFock( Atoms )[:2]; assert( Converged ) print "Got HfResult Energy: ", ConvertEnergy( Energy ) main()
The output of this script then looks like:
ct8k/examples> python SimplestHartreeFock.py *** SCF-RHF-CS: Restricted Hartree-Fock/Closed Shell [Ver. 0.4] *** Input -> atom set: 6 atoms. (distance unit: A) 0 C: (-0.65935,+0.00000,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 1 C: (+0.65935,+0.00000,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 2 H: (-1.22619,-0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 3 H: (-1.22619,+0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 4 H: (+1.22619,+0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 5 H: (+1.22619,-0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' Loading basis sets.. System information: num electrons: 16 num basis functions: 48 (14 gen. contr. sol. harm. shells) num primitive GTOs: 110 nuclear repulsion energy: 917.01085292eV Calculating overlap & 1e^- Hamilton matrix.. lowest eigenvalues of overlap matrix: (small->bad) 0.00367455 0.0154379 0.0158958 0.0249222 0.026763 Calculating HF guesses for atomic densities... calculating atomic densities for 'C'/cc-pVDZ.. calculating atomic densities for 'H'/cc-pVDZ.. Preparing integrator/integrals... ##Clock 'Integral Evaluation': 0.7618s Kind of ready. Starting the SCF-procedure. Convergence limits -> Energy: 2.72e-07eV Density: 1e-05 #Iter. Etot/eV Eone/eV Etwo/eV Interpolation 0 -2142.01610699 -4586.81177746 1527.78481755 DIIS: 0 1 -2122.35083211 -4652.62624599 1613.26456096 DIIS: 1 r: 4.3490e-01 2 -2123.52289189 -4637.76102864 1597.22728383 DIIS: 2 r: 3.9007e-02 3 -2123.68592944 -4645.41322473 1604.71644236 DIIS: 3 r: 3.0940e-03 4 -2123.53796848 -4644.09879686 1603.54997546 DIIS: 4 r: 2.7315e-04 5 -2123.57319080 -4644.32034527 1603.73630155 DIIS: 5 r: 5.2206e-06 6 -2123.57209080 -4644.28450780 1603.70156408 DIIS: 6 r: 2.7713e-07 7 -2123.57163242 -4644.29468868 1603.71220335 DIIS: 6 r: 1.2716e-08 8 -2123.57180919 -4644.29253907 1603.70987696 DIIS: 6 r: 6.7513e-10 9 -2123.57180142 -4644.29278947 1603.71013514 DIIS: 6 r: 3.2725e-11 10 -2123.57180424 -4644.29268006 1603.71002290 DIIS: 6 r: 1.8806e-12 11 -2123.57180425 -4644.29269116 1603.71003400 DIIS: 6 r: 8.1221e-14 Found convergence limit to be reached after 12 iterations. ##Clock 'Average time per iteration': 0.03795s ##Clock ' Average time for cs-Fock matrix update': 0.03418s ##Clock ' Average time for Fock matrix extrapolation': 0.001497s ##Clock ' Average time for gen. eigensystem': 0.001863s Lowest entries of Hartree-Fock spectrum: [ElectronOccupancy x #Id: Energy/eV] 2x#0: -305.62348, 2x#1: -305.57490, 2x#2: -28.219770, 2x#3: -21.575263, 2x#4: -17.483021, 2x#5: -16.011425, 2x#6: -13.684664, 2x#7: -10.263784, 0x#8: 4.6661521, 0x#9: 5.5811698, 0x#10: 6.3657280, 0x#11: 6.5291721, 0x#12: 8.2866724, 0x#13: 12.723896, 0x#14: 15.692077, 0x#15: 16.686523 Nuclear repulsion energy: 917.01085eV Final kinetic energy: 2122.4216eV Final one electron energy: -4644.2927eV (Ekin,nucl.attraction) Final two electron energy: 1603.7100eV (mean field repulsion,exchange) Final total energy: -2123.5718eV (Eone+Etwo+Enucl) Dipole moment: (x:-0.00000 y:0.00000 z:0.00000) e*A Dipole moment: (x:-0.00000 y:0.00000 z:0.00000) Debye Got HfResult Energy: -2123.57180425
In the next step, additionally to the Hartree-Fock calculation, a CEPA(0) correlation calculation is performed. In this script the additional return values of the HartreeFock function of type FHartreeFockResult and FHartreeFockParams are required for the following calculations:
from ct8k import * from ct8kpy import * SetOutputUnits( ENERGY_Hartree, DISTANCE_Angstrom ) LoadBasisLibrary( "../basis_lib/cc-pVDZ.libmol" ) def main(): Atoms = FAtomSet() Atoms.AddAtomsFromXyzFile( "../molecules/ethene.xyz", "cc-pVDZ" ) (Converged, Energy, HfResult, HfParams) = HartreeFock( Atoms ); assert( Converged ) (Converged, Energy) = Cepa( HfResult, HfParams.pIntegrator, Method = METHOD_Cepa0, EnergyThreshold = 1e-6 )[:2] main()There are some options to control the calculations. They can easily be supplied by the optional arguments of the calculation functions (for example, EnergyThreshold=1e-6 on the CEPA-calculation here). Aviable options are documented in ct8kpy.py. This script produces the following output:
ct8k/examples> python SimplestCepa.py *** SCF-RHF-CS: Restricted Hartree-Fock/Closed Shell [Ver. 0.4] *** Input -> atom set: 6 atoms. (distance unit: A) 0 C: (-0.65935,+0.00000,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 1 C: (+0.65935,+0.00000,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 2 H: (-1.22619,-0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 3 H: (-1.22619,+0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 4 H: (+1.22619,+0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' 5 H: (+1.22619,-0.91163,+0.00000) basis: 'cc-pVDZ' ecp: 'none' Loading basis sets.. System information: num electrons: 16 num basis functions: 48 (14 gen. contr. sol. harm. shells) num primitive GTOs: 110 nuclear repulsion energy: 33.699529404Eh Calculating overlap & 1e^- Hamilton matrix.. lowest eigenvalues of overlap matrix: (small->bad) 0.00367455 0.0154379 0.0158958 0.0249222 0.026763 Calculating HF guesses for atomic densities... calculating atomic densities for 'C'/cc-pVDZ.. calculating atomic densities for 'H'/cc-pVDZ.. Preparing integrator/integrals... ##Clock 'Integral Evaluation': 0.7697s Kind of ready. Starting the SCF-procedure. Convergence limits -> Energy: 1e-08Eh Density: 1e-05 #Iter. Etot/Eh Eone/Eh Etwo/Eh Interpolation 0 -78.7176450001 -168.562234430 56.1450600263 DIIS: 0 1 -77.9949594320 -170.980871691 59.2863828552 DIIS: 1 r: 4.3490e-01 2 -78.0380318373 -170.434584995 58.6970237538 DIIS: 2 r: 3.9007e-02 3 -78.0440233573 -170.715798032 58.9722452709 DIIS: 3 r: 3.0940e-03 4 -78.0385858917 -170.667493696 58.9293784003 DIIS: 4 r: 2.7315e-04 5 -78.0398802881 -170.675635450 58.9362257582 DIIS: 5 r: 5.2206e-06 6 -78.0398398639 -170.674318447 58.9349491797 DIIS: 6 r: 2.7713e-07 7 -78.0398230189 -170.674692588 58.9353401653 DIIS: 6 r: 1.2716e-08 8 -78.0398295151 -170.674613591 58.9352546721 DIIS: 6 r: 6.7513e-10 9 -78.0398292295 -170.674622793 58.9352641601 DIIS: 6 r: 3.2725e-11 10 -78.0398293330 -170.674618772 58.9352600355 DIIS: 6 r: 1.8806e-12 11 -78.0398293333 -170.674619181 58.9352604434 DIIS: 6 r: 8.1221e-14 Found convergence limit to be reached after 12 iterations. ##Clock 'Average time per iteration': 0.03774s ##Clock ' Average time for cs-Fock matrix update': 0.03391s ##Clock ' Average time for Fock matrix extrapolation': 0.001377s ##Clock ' Average time for gen. eigensystem': 0.002004s Lowest entries of Hartree-Fock spectrum: [ElectronOccupancy x #Id: Energy/Eh] 2x#0: -11.231457, 2x#1: -11.229671, 2x#2: -1.0370575, 2x#3: -0.79287635, 2x#4: -0.64248921, 2x#5: -0.58840907, 2x#6: -0.50290216, 2x#7: -0.37718711, 0x#8: 0.17147794, 0x#9: 0.20510422, 0x#10: 0.23393620, 0x#11: 0.23994267, 0x#12: 0.30452961, 0x#13: 0.46759460, 0x#14: 0.57667324, 0x#15: 0.61321844 Nuclear repulsion energy: 33.699529Eh Final kinetic energy: 77.997562Eh Final one electron energy: -170.67462Eh (Ekin,nucl.attraction) Final two electron energy: 58.935260Eh (mean field repulsion,exchange) Final total energy: -78.039829Eh (Eone+Etwo+Enucl) Dipole moment: (x:-0.00000 y:0.00000 z:0.00000) e*A Dipole moment: (x:-0.00000 y:0.00000 z:0.00000) Debye *** CEPA(0)-CS: Closed Shell Coupled Electron Pairs (Singles&Doubles) *** system information: num core orbitals: 2 (frozen, i.e. no excitations from these) num internal orbitals: 6 (21 pairs) num external orbitals: 40 Partially transforming integrals into MO-basis.. ##Clock 'CISD: K,K,k,J-operator evaluation': 0.3354s Guessing starting vectors via MP2.. Pseudo-MP2 correlation energy: -0.27331889256 Kind of ready. Starting the SCF-procedure. #Iter. Ecorr/Eh norm(t^i) norm(T^ij) residual 0 -0.27331889256 0.00000000000 0.09980819442 0.12005653001 1 -0.29865007783 0.00122444559 0.12238194411 0.03468514471 2 -0.31081543524 0.00211162398 0.13853457228 0.01460499172 3 -0.31372161155 0.00274818317 0.14533322586 0.00445311251 4 -0.31444267827 0.00304773456 0.14906360688 0.00146221148 5 -0.31453961948 0.00309139317 0.14990740891 0.00037599464 6 -0.31461370867 0.00310409711 0.15025258915 0.00011804466 7 -0.31462936896 0.00310466769 0.15033564351 0.00002936723 8 -0.31463460126 0.00310475418 0.15035900364 0.00000966769 9 -0.31463487121 0.00310465023 0.15036213156 0.00000254623 Found convergence limit to be reached after 10 iterations. ##Clock 'Average time per iteration': 0.3278s ##Clock ' Average time for residual evaluation': 0.3221s ##Clock ' Average time for K(D^ij) evaluation': 0.1888s ##Clock ' Average time for G^ij evaluation': 0.1178s ##Clock ' Average time for DIIS extrapolation': 0.0045s Final CEPA(0) Correlation Energy: -0.3146348712Eh Final CEPA(0) Total Energy: -78.3544642045Eh