Exemplo n.º 1
0
    def getbfs(ccdata):
        from cclib.bridge import cclib2pyquante

        pymol = cclib2pyquante.makepyquante(ccdata)

        bfs = []
        for i, atom in enumerate(pymol):  # `atom` is instance of pyquante2.geo.atom.atom class.
            basis = ccdata.gbasis[i]  # `basis` is basis coefficients stored in ccData.
            for sym, primitives in basis:
                for power in sym2powerlist[sym]:  # `sym` is S, P, D, F and is used as key here.
                    exponentlist = []
                    coefficientlist = []

                    for exponents, coefficients in primitives:
                        exponentlist.append(exponents)
                        coefficientlist.append(coefficients)

                    basisfunction = cgbf(
                        atom.atuple()[1:4], powers=power, exps=exponentlist, coefs=coefficientlist,
                    )
                    basisfunction.normalize()
                    bfs.append(basisfunction)

        del cclib2pyquante

        return bfs
Exemplo n.º 2
0
def getbfs(coords, gbasis):
    """Convenience function for both wavefunction and density based on PyQuante Ints.py."""
    if not _HAS_PYQUANTE:
        raise Exception("You need to have PyQuante installed")
    mymol = cclib2pyquante.makepyquante(coords, [0 for _ in coords])

    sym2powerlist = {
        'S': [(0, 0, 0)],
        'P': [(1, 0, 0), (0, 1, 0), (0, 0, 1)],
        'D': [(2, 0, 0), (0, 2, 0), (0, 0, 2), (1, 1, 0), (0, 1, 1),
              (1, 0, 1)],
        'F': [(3, 0, 0), (2, 1, 0), (2, 0, 1), (1, 2, 0), (1, 1, 1), (1, 0, 2),
              (0, 3, 0), (0, 2, 1), (0, 1, 2), (0, 0, 3)]
    }

    bfs = []
    for i, atom in enumerate(mymol):
        bs = gbasis[i]
        for sym, prims in bs:
            for power in sym2powerlist[sym]:
                bf = CGBF(atom.pos(), power)
                for expnt, coef in prims:
                    bf.add_primitive(expnt, coef)
                bf.normalize()
                bfs.append(bf)

    return bfs
Exemplo n.º 3
0
def getbfs(coords, gbasis):
    """Convenience function for both wavefunction and density based on PyQuante Ints.py."""
    if not _HAS_PYQUANTE:
        raise Exception("You need to have PyQuante installed")
    mymol = cclib2pyquante.makepyquante(coords, [0 for _ in coords])

    sym2powerlist = {
        'S' : [(0, 0, 0)],
        'P' : [(1, 0, 0), (0, 1, 0), (0, 0, 1)],
        'D' : [(2, 0, 0), (0, 2, 0), (0, 0, 2), (1, 1, 0), (0, 1, 1), (1, 0, 1)],
        'F' : [(3, 0, 0), (2, 1, 0), (2, 0, 1), (1, 2, 0), (1, 1, 1), (1, 0, 2),
               (0, 3, 0), (0, 2, 1), (0, 1, 2), (0, 0, 3)]
        }

    bfs = []
    for i, atom in enumerate(mymol):
        bs = gbasis[i]
        for sym, prims in bs:
            for power in sym2powerlist[sym]:
                bf = CGBF(atom.pos(), power)
                for expnt, coef in prims:
                    bf.add_primitive(expnt, coef)
                bf.normalize()
                bfs.append(bf)

    return bfs
Exemplo n.º 4
0
 def test_makepyquante(self):
     from PyQuante.hartree_fock import hf
     atomnos = numpy.array([1, 8, 1],"i")
     a = numpy.array([[-1, 1, 0], [0, 0, 0], [1, 1, 0]], "f")
     pyqmol = cclib2pyquante.makepyquante(a, atomnos)
     en, orbe, orbs = hf(pyqmol)
     ref = -75.824754
     assert abs(en - ref) < 1.0e-6
Exemplo n.º 5
0
 def test_makepyquante(self):
     from PyQuante.hartree_fock import hf
     atomnos = numpy.array([1, 8, 1], "i")
     a = numpy.array([[-1, 1, 0], [0, 0, 0], [1, 1, 0]], "f")
     pyqmol = cclib2pyquante.makepyquante(a, atomnos)
     en, orbe, orbs = hf(pyqmol)
     ref = -75.824754
     assert abs(en - ref) < 1.0e-6
Exemplo n.º 6
0
    def getbfs(ccdata):
        from cclib.bridge import cclib2pyquante
        pymol = cclib2pyquante.makepyquante(ccdata)

        bfs = []
        for i, atom in enumerate(pymol):
            bs = ccdata.gbasis[i]
            for sym, prims in bs:
                for power in sym2powerlist[sym]:
                    bf = CGBF(atom.pos(), power)
                    for expnt, coef in prims:
                        bf.add_primitive(expnt, coef)
                    bf.normalize()
                    bfs.append(bf)
        
        del cclib2pyquante
        
        return bfs
Exemplo n.º 7
0
    def test_makepyquante(self):
        # Test older PyQuante bridge
        from PyQuante.hartree_fock import hf
        from PyQuante.Molecule import Molecule

        reference = Molecule(
            "h2o",
            [
                (8, (0, 0, 0.119159)),
                (1, (0, 0.790649, -0.476637)),
                (1, (0, -0.790649, -0.476637)),
            ],
            units="Angstroms",
        )
        refen, reforbe, reforbs = hf(reference)

        pyqmol = cclib2pyquante.makepyquante(self.data)
        en, orbe, orbs = hf(pyqmol)

        self.assertAlmostEqual(en, refen, delta=1.0e-6)
Exemplo n.º 8
0
    def test_makepyquante(self):
        # Test pyquante2 bridge
        from pyquante2 import molecule, rhf, h2o, basisset

        bfs = basisset(h2o)
        # Copied from water_ccsd.log
        refmol = molecule(
            [(8, 0.0, 0.0, 0.119159), (1, 0, 0.790649, -0.476637),
             (1, 0, -0.790649, -0.476637)],
            units="Angstroms",
        )
        refsolver = rhf(refmol, bfs)
        refsolver.converge()

        pyqmol = cclib2pyquante.makepyquante(self.data)
        pyqsolver = rhf(pyqmol, bfs)
        pyqsolver.converge()

        assert_array_almost_equal(refsolver.energies[-1],
                                  pyqsolver.energies[-1],
                                  decimal=6)