def GetBasis(gaussResult, quiet=False): """Get PyQuante representation of a basis from a gaussian output file""" # Create representation of molecule within PyQuante PQMol = cclib.bridge.makepyquante(gaussResult.atomcoords[-1], gaussResult.atomnos) # Get PyQuante representation of basis set basis = Ints.getbasis(PQMol, gaussResult.basisname) # Check that PyQuante and g09 have the same basis set ordering nbasis = gaussResult.nbasis assert len(basis.bfs) == nbasis, ( "Gaussian and PyQuante have " "different basis sets. Did you specify the same basis for each?" ) overlap_py = np.array(Ints.getS(basis)) maxdefect = 0.0 if hasattr(gaussResult, "mocoeffs_sao"): sao = gaussResult.mocoeffs_sao else: sao = gaussResult.aooverlaps if not quiet: for i, vals in enumerate(zip(overlap_py.flat, sao.flat)): pq, g9 = vals x, y = np.unravel_index(i, (nbasis, nbasis)) denom = max(pq, g9) if denom < 10 ** -13: continue if min(pq, g9) == 0: denom = 1.0 defect = abs((pq - g9) / denom) if defect > maxdefect: maxdefect = defect if defect > 1e-3 and x <= y: print pq, g9, (x, y), 100 * abs(pq - g9) / denom print "Maximum error between G09 and PyQuante overlap matrices:", maxdefect if maxdefect > 1e-3: print "WARNING!!!! Calculated overlap matrix does not match basis set!" print "Basis sets might not match!\n\n\n" return nbasis, basis
from PyQuante.NumWrap import eigh, matrixmultiply from PyQuante import hartree_fock as HF #Global Variables############################ convergenceLimit = 1.0 * pow(10, -6) maxCycle = 50 #Section 1############################ #specify a molecule molecule = Molecule("H2", [(1, (0, 0, 0)), (1, (0, 0, 1)), (8, (-1, 0, 0))]) basisSet = Ints.getbasis(molecule, "sto-3g") #Section 2############################ #Overlap Matrix S = Ints.getS(basisSet) #Follwing Two matrices compose the core Hamiltonian #KE Matrix KE = Ints.getT(basisSet) #External Potential, Nuclear - Electron Attraction Vext = Ints.getV(basisSet, molecule) #Form Hcore Hcore = KE + Vext #calculate two electron integrals elecRepulsion = Ints.get2ints(basisSet) #Section 3############################