Beispiel #1
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
Beispiel #2
0
class TestCGBF(unittest.TestCase):
    """
    """
    def setUp(self):
        self.gto = CGBF((0,0,0),(1,0,0))
    def testAddGTO(self):
        pgto = PGBF(0.4,(0,1,1),(0,0,0))
        self.gto.add_primitive(0.4,0.5)
Beispiel #3
0
    def __init__(self, atoms, basis_data=None, **opts):
        """
        
        """
        # Option to omit f basis functions from imported basis sets
        omit_f = opts.get('omit_f', False)
        if not basis_data:
            from PyQuante.Basis.p631ss import basis_data
        elif type(basis_data) == type(''):
            # Assume this is a name of a basis set, e.g. '6-31g**'
            #  and import dynamically
            basis_data = get_basis_data(basis_data)

        # Creating the function lists, by shell and by arbitrary order
        bfs = []  # Basis list
        shells = []  # Shell list
        n = 0
        LIST1 = [
        ]  # list of atoms and basis function number      # GLOBULION ADD
        LIST2 = [
        ]  # list of atoms and basis function type        # GLOBULION ADD
        for atom in atoms:
            bs = basis_data[atom.atno]
            for sym, prims in bs:  # Shell Symbol S,P,D,F
                A = sym2powerlist[sym]  # GLOBULION ADD
                for ni in xrange(len(sym2powerlist[sym])):  # GLOBULION ADD
                    LIST1.append(n)  # GLOBULION ADD
                    LIST2.append(A[ni])
                if omit_f and sym == "F": continue
                shell = Shell(sym)
                for power in sym2powerlist[sym]:
                    cgbf = CGBF(atom.pos(), power, atom.atid)

                    #exps,coefs = zip(*prims)
                    #primlist = [PrimitiveGTO(alpha,atom.pos(),power) for alpha in exps]

                    #bf = ContractedGTO(primlist,coefs)
                    #bf.normalize()
                    [cgbf.add_primitive(alpha, coef) for alpha, coef in prims]
                    bfs.append(cgbf)  # Normal ordering

                    # Shell ordering
                    bfs_index = len(bfs) - 1  # last added
                    shell.append(cgbf, bfs_index)
                shells.append(shell)
            n += 1
        self.bfs = bfs
        self.shells = shells
        self.LIST1 = LIST1  # GLOBULION ADD
        self.LIST2 = LIST2  # GLOBULION ADD
Beispiel #4
0
def pyquante_basis(molfbasis,atoms):
    from PyQuante.Ints import sym2powerlist
    from PyQuante.CGBF import CGBF
    
    bfs = []
    for type,atomnum,primlist in molfbasis:
        for power in sym2powerlist[type]:
            symi,atnoi,xi,yi,zi = atoms[atomnum-1]
            x,y,z = toBohr3(xi,yi,zi)
            bf = CGBF((x,y,z),power)
            for expnt,coef in primlist:
                bf.add_primitive(expnt,coef)
            bf.normalize()
            bfs.append(bf)
    return bfs
Beispiel #5
0
 def __init__(self, atoms, basis_data = None, **opts):
     """
     
     """
     # Option to omit f basis functions from imported basis sets
     omit_f = opts.get('omit_f',False)
     if not basis_data:
         from PyQuante.Basis.p631ss import basis_data
     elif type(basis_data) == type(''):
         # Assume this is a name of a basis set, e.g. '6-31g**'
         #  and import dynamically
         basis_data = get_basis_data(basis_data)
     
     # Creating the function lists, by shell and by arbitrary order
     bfs = []   # Basis list
     shells = []# Shell list
     n = 0
     LIST1  = []# list of atoms and basis function number      # GLOBULION ADD
     LIST2  = []# list of atoms and basis function type        # GLOBULION ADD
     for atom in atoms:
         bs = basis_data[atom.atno]
         for sym,prims in bs: # Shell Symbol S,P,D,F
             A = sym2powerlist[sym]                            # GLOBULION ADD
             for ni in xrange(len(sym2powerlist[sym])):        # GLOBULION ADD
                 LIST1.append(n)                  # GLOBULION ADD
                 LIST2.append(A[ni])
             if omit_f and sym == "F": continue
             shell = Shell(sym)
             for power in sym2powerlist[sym]:
                 cgbf = CGBF(atom.pos(), power, atom.atid)
                 
                 #exps,coefs = zip(*prims)
                 #primlist = [PrimitiveGTO(alpha,atom.pos(),power) for alpha in exps]
                 
                 #bf = ContractedGTO(primlist,coefs)
                 #bf.normalize()
                 [cgbf.add_primitive(alpha,coef) for alpha,coef in prims]
                 bfs.append(cgbf) # Normal ordering
                 
                 # Shell ordering
                 bfs_index = len(bfs)-1 # last added
                 shell.append(cgbf, bfs_index) 
             shells.append(shell)
         n+=1
     self.bfs = bfs
     self.shells = shells
     self.LIST1 = LIST1                                       # GLOBULION ADD
     self.LIST2 = LIST2                                       # GLOBULION ADD
Beispiel #6
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
Beispiel #7
0
def make_pyquante_basis(atoms,input_bfs):
    from PyQuante.Ints import sym2powerlist
    from PyQuante.CGBF import CGBF
    bfs = []
    for atom_index,info in input_bfs:
        x,y,z = atoms[atom_index-1].pos()
        for type,primlist in info:
            for power in sym2powerlist[type]:
                bf = CGBF((x,y,z),power)
                for expnt,coef in primlist:
                    bf.add_primitive(expnt,coef)
                bf.normalize()
                bfs.append(bf)
    return bfs
Beispiel #8
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
Beispiel #9
0
    def make_basis(self):
        try:
            from PyQuante.CGBF import CGBF
            from PyQuante.Ints import sym2powerlist
        except:
            print "PyQuante not available, using slower routines"
            print "Consider installing PyQuante to speed basis function evals"
            from Gaussian import CGBF, sym2powerlist

        self.pyq_basis = []
        for iat,atbasis in self.basis:
            origin = tuple(self.geo.atoms[iat-1].get_position())
            for type,prims in atbasis:
                for power in sym2powerlist[type]:
                    bf = CGBF(origin,power)
                    for expnt,coef in prims:
                        bf.add_primitive(expnt,coef)
                    bf.normalize()
                    self.pyq_basis.append(bf)
        return
Beispiel #10
0
 def setUp(self):
     self.gto = CGBF((0,0,0),(1,0,0))
    print(integral_os)

    # take the gradient in the X direction
    rp = get_bi_center(za, zb, ra, rb)
    ta = 2 * za * (rp[0] - ra[0])
    tb = 2 * zb * (rp[0] - rb[0])
    print(-(ta + tb) * integral_os)

    # ga = PGBF(za, tuple(ra), tuple(la))
    # gb = PGBF(zb, tuple(rb), tuple(lb))
    # print(ga)
    # print(gb)
    # # PyQuante includes the normalization prefactor
    # integral_pq = ga.overlap(gb) / (ga.norm * gb.norm)

    ga = CGBF(origin=tuple(ra), powers=tuple(la), atid=0)
    gb = CGBF(origin=tuple(rb), powers=tuple(lb), atid=0)
    ga.add_primitive(exponent=za, coefficient=1.0)
    gb.add_primitive(exponent=zb, coefficient=1.0)
    # print(ga)
    # print(gb)

    # PyQuante includes the normalization prefactor
    integral_pq = ga.overlap(gb) / (ga.pnorms[0] * gb.pnorms[0])
    print(integral_pq)
    print(der_overlap_element(0, ga, gb))
    # print(ga.doverlap(gb, 0))
    # print(ga.doverlap_num(gb, 0))

    # from mmd.integrals