예제 #1
0
class MP2:
    """
    Spinorbital version of MP2 (i.e. MP2 using an unrestricted reference)
    """

    def __init__(self, mol, mints):
        self.uhf = UHF(mol, mints)
        self.uhf.compute_energy()
        self.gmo = transform_tei(self.uhf.g, self.uhf.C)

    def compute_energy(self):
        uhf = self.uhf
        e, nocc, norb, gmo = self.uhf.e, self.uhf.nocc, self.uhf.norb, self.gmo

        Ec = 0.0
        for i in range(nocc):
            for j in range(nocc):
                for a in range(nocc, norb):
                    for b in range(nocc, norb):
                        Ec += (1/4.0) * gmo[i, j, a, b]**2 / (e[i]+e[j]-e[a]-e[b])

        self.E = uhf.E + Ec

        psi4.print_out('MP2            E                  Ec\n')
        psi4.print_out('     {:20.15f}  {:20.15f}'.format(self.E, Ec))

        return Ec
예제 #2
0
 def __init__(self, mol, mints):
     uhf = UHF(mol, mints)
     uhf.compute_energy()
     self.g = transform_tei(
         uhf.g, uhf.C
     )  # antisymmetrized two-electron integrals, spin-orbital (MO) basis
     self.uhf = uhf
예제 #3
0
 def __init__(self, mol, mints):
   uhf = UHF(mol, mints)
   uhf.compute_energy()
   self.nocc = uhf.nocc
   self.norb = uhf.norb
   self.ndet = self.nocc * (self.norb - self.nocc)
   self.E0   = uhf.E
   self.e    = uhf.e
   self.g    = transform_tei(uhf.g, uhf.C) # antisymmetrized two-electron integrals, spin-orbital (MO) basis
예제 #4
0
    def __init__(self,mol,mints):
        self.nocc = get_nocc(mol)
        self.nbf = get_nbf(mints)
        self.norb = 2*self.nbf
        self.conv = get_conv()
        self.maxiter = get_maxiter()

        uhf = UHF(mol,mints)
        uhf.get_energy()
        self.E0 = uhf.E
        self.e = uhf.e
        self.g = uhf.g
        self.C = uhf.C
예제 #5
0
    def __init__(self, mol, mints):

        uhf = UHF(mol, mints)
        uhf.compute_energy()

        nbf = uhf.nbf
        self.nocc = uhf.nocc
        self.nvirtual = 2 * nbf - self.nocc
        self.ndet = self.nvirtual * self.nocc

        self.E0 = uhf.E
        self.e = uhf.e
        self.C = uhf.C
        self.g = uhf.g
예제 #6
0
파일: mp2.py 프로젝트: aewiens/chem8950b
	def __init__(self,options):

		self.options = options

		self.Ec    = 0.0
		uhf = UHF(options)
		self.E0    = uhf.computeEnergy()
		self.nocc  = uhf.nelec
		self.norb  = uhf.norb
		self.mol   = uhf.mol
		self.e     = uhf.e
		self.C     = uhf.C
		self.uhf   = uhf
		self.df    = int( options['MP2']['df'] )
		self.GMO   = self.transformTEI( uhf.G, uhf.C )	
예제 #7
0
    def __init__(self,mol,mints):

        self.nbf = get_nbf(mints)
        self.nocc = get_nocc(mol)

        uhf = UHF(mol,mints)
        uhf.get_energy()
        self.E0 = uhf.E
        self.e = uhf.e

        self.Gmo = transform_integrals(uhf.g, uhf.C)

        self.norb = 2*self.nbf
        self.nvirtual = self.norb - self.nocc
        self.ndet = self.nvirtual*self.nocc
예제 #8
0
    def __init__(self, options):

        self.conv = 10**(-int(options['CEPA0']['conv']))
        self.tConv = 10**(-int(options['CEPA0']['t_conv']))
        self.maxiter = int(options['CEPA0']['max_iter'])
        self.options = options

        uhf = UHF(options)
        mp2 = MP2(options)

        self.E0 = uhf.computeEnergy()
        self.uhf = uhf
        self.mp2 = mp2

        self.t = np.zeros((uhf.nelec, uhf.nelec, uhf.nvirt, uhf.nvirt))
        self.Ec = 0.0
예제 #9
0
    def __init__(self, mol, mints):
        """
        Create a class to compute ccd energy
        """

        uhf = UHF(mol, mints)
        uhf.compute_energy()

        # import from uhf
        self.e, self.C, self.G = uhf.e, uhf.C, uhf.g
        self.maxiter, self.conv = uhf.maxiter, uhf.conv

        self.nbf, self.nocc = uhf.nbf, uhf.nocc
        self.nvirt = 2 * self.nbf - self.nocc

        self.Ec = 0.0
        self.t = np.zeros((self.nocc, self.nocc, self.nvirt, self.nvirt))
예제 #10
0
    def __init__(self, options):

        self.conv = 10**(-int(options['CCD']['conv']))
        self.tConv = 10**(-int(options['CCD']['t_conv']))
        self.maxiter = int(options['CCD']['max_iter'])
        self.options = options

        uhf = UHF(options)
        mp2 = MP2(options)

        self.E0 = uhf.computeEnergy()
        self.e = uhf.e
        self.Ec = 0.0
        self.nocc = uhf.nelec
        self.nvirt = uhf.norb - uhf.nelec
        self.GMO = mp2.transformTEI(uhf.G, uhf.C)
        self.t = np.zeros((self.nocc, self.nocc, self.nvirt, self.nvirt))
예제 #11
0
파일: cis.py 프로젝트: CCQC/summer-program
	def __init__(self,options):

		uhf = UHF( options )

		uhf.computeEnergy()

		self.nocc  = uhf.nocc
		self.nvirt = uhf.norb - self.nocc
		self.E0    = uhf.E
		self.e     = uhf.e

		mp2 = MP2( options )
		self.GMO   = mp2.transformTEI( uhf.G, uhf.C )

		print( "-----------------------------------" )
		print( "| Output for CI Singles Procedure |" )
		print( "-----------------------------------" )
		print( "\n @UHF Energy:   %f" % uhf.E )
예제 #12
0
    def __init__(self, options):

        uhf = UHF(options)

        uhf.computeEnergy()

        self.nocc = uhf.nocc
        self.nvirt = uhf.norb - self.nocc
        self.E0 = uhf.E
        self.e = uhf.e

        mp2 = MP2(options)
        self.GMO = mp2.transformTEI(uhf.G, uhf.C)

        print("-----------------------------------")
        print("| Output for CI Singles Procedure |")
        print("-----------------------------------")
        print("\n @UHF Energy:   %f" % uhf.E)
예제 #13
0
파일: mp2.py 프로젝트: CCQC/summer-program
	def __init__(self,options):

		self.options = options

		self.Ec    = 0.0
		uhf = UHF(options)
		self.E0    = uhf.computeEnergy()
		self.nocc  = uhf.nocc
		self.norb  = uhf.norb
		self.mol   = uhf.mol
		self.e     = uhf.e
		self.C     = uhf.C
		self.uhf   = uhf
		self.df    = int( options['MP2']['df'] )

		self.G     = uhf.G - uhf.G.transpose(( 0,1,3,2 ))
		self.Gmo   = self.transformTEI( uhf.G, uhf.C )	

		self.dfBasisName = ""
예제 #14
0
    def __init__(self, options):

        self.options = options

        self.Ec = 0.0
        uhf = UHF(options)
        self.E0 = uhf.computeEnergy()
        self.nocc = uhf.nocc
        self.norb = uhf.norb
        self.mol = uhf.mol
        self.e = uhf.e
        self.C = uhf.C
        self.uhf = uhf
        self.df = int(options['MP2']['df'])

        self.G = uhf.G - uhf.G.transpose((0, 1, 3, 2))
        self.Gmo = self.transformTEI(uhf.G, uhf.C)

        self.dfBasisName = ""
예제 #15
0
파일: ccd.py 프로젝트: CCQC/summer-program
	def __init__(self,options):

		self.conv    = 10**( -int( options['CCD']['conv'] )) 
		self.tConv   = 10**( -int( options['CCD']['t_conv'] )) 
		self.maxiter = int( options['CCD']['max_iter'] )
		self.options = options

		uhf = UHF(options)
		mp2 = MP2(options)

		self.E0    = uhf.computeEnergy()
		self.e     = uhf.e
		self.Ec    = 0.0 
		self.nocc  = uhf.nelec
		self.nvirt = uhf.norb - uhf.nelec
		self.GMO   = mp2.transformTEI( uhf.G, uhf.C )
		self.uhf   = uhf

		##  initialize t-amplitudes  ##
		self.t = np.zeros((self.nocc,self.nocc,self.nvirt,self.nvirt))
예제 #16
0
파일: mp2.py 프로젝트: aewiens/chem8950b
    def __init__(self, options):

        uhf = UHF(options)

        self.E0 = uhf.computeEnergy()
        self.e = uhf.e
        self.C = uhf.C
        self.nocc = uhf.nelec
        self.norb = uhf.norb
        self.uhf = uhf

        df = int(options['MP2']['df'])

        if df:
            dfBasisName = options['DEFAULT']['df_basis']
            dfBasis = psi4.core.BasisSet.build(uhf.mol,
                                               "DF_BASIS_MP2",
                                               dfBasisName,
                                               puream=0)
            self.G = self.densityFit(options, dfBasis)

        else:
            self.G = self.transformTEI(uhf.G, uhf.C)
예제 #17
0
def spin_block_oei(hao):
    hao = la.block_diag(hao,hao)
    return hao

def int_trans_oei(hao, C):

    return np.einsum('pQ, pP -> PQ',
           np.einsum('pq, qQ -> pQ', hao, C),C)

def int_trans(gao, C):

    return np.einsum('pQRS, pP -> PQRS',
           np.einsum('pqRS, qQ -> pQRS',
           np.einsum('pqrS, rR -> pqRS',
           np.einsum('pqrs, sS -> pqrS', gao, C),C),C),C)


if __name__ == '__main__':
    uhf = UHF('Options1.ini')
    uhf.get_energy()
    omp2 = OMP2(uhf)
    omp2.get_energy()
    psi4.set_options({'basis':'sto-3g',
                        'scf_type': 'pk',
                        'MP2_type' : 'conv',
                        'puream' : False,
                        'reference': 'uhf',
                        'guess' : 'core',
                        'e_convergence' : 1e-10})
    #psi4.energy('omp2')
예제 #18
0
파일: ccd.py 프로젝트: CCQC/summer-program
        Update the CC amplitudes (differs for each theory level)
        """
        g = self.gmo
        o  = slice(None, self.nocc)
        v  = slice(self.nocc, None)
        w0 = g[o, o, v, v]
        w1 = 1/2 * np.einsum('abcd,ijcd->ijab', g[v, v, v, v], t)
        w2 = 1/2 * np.einsum('klij,klab->ijab', g[o, o, o, o], t)
        w3 = np.einsum('akic,jkbc->ijab', g[v, o, o, v], t)
        w3 += -w3.transpose((0, 1, 3, 2)) - w3.transpose(1, 0, 2, 3) - w3.transpose((1, 0, 3, 2))
        w4 = np.einsum('klcd,ijac,klbd->ijab', g[o, o, v, v], t, t)
        w4 += -w4.transpose((0, 1, 3, 2))
        w5 = 1/2 * np.einsum('klcd,ikab,jlcd->ijab', g[o, o, v, v], t, t)
        w5 += w5.transpose((1, 0, 2, 3))
        w6 = 1/4 * np.einsum('klcd,ijcd,klab->ijab', g[o, o, v, v], t, t)
        w7 = 1/4 * np.einsum('klcd,ikac,jlbd->ijab', g[o, o, v, v], t, t)
        w7 += w7.transpose((1, 0, 2, 3))

        return w0 + w1 + w2 + w3 + w4 + w5 + w6 + w7


if __name__ == "__main__":
    import sys
    sys.path.insert(0, '../../5/jevandezande')
    from uhf import UHF
    uhf = UHF('../../3/jevandezande/Options.ini')
    uhf.energy()
    ccd = CCD(uhf)
    ccd.energy()
    ccd.plot_convergence()
예제 #19
0
                                                                        b - 1]
                    if b >= 2:
                        I[a, b] += (b - 1) / (2 * alpha) * I[a, b - 2]

            xyz.append(I)

        return xyz


if __name__ == '__main__':
    config = configparser.ConfigParser()
    config.read('Options.ini')

    mol = psi4.geometry(config['DEFAULT']['molecule'])
    basis = psi4.core.BasisSet.build(mol,
                                     'BASIS',
                                     config['DEFAULT']['basis'],
                                     puream=0)
    mints = psi4.core.MintsHelper(basis)

    scf = config['SCF']
    maxit = scf['max_iter']
    conv = scf['conv']

    uhf = UHF(mol, mints, maxit, conv)
    integrals = Integrals(basis, mol, uhf)

    #print( integrals.computeOverlap() - uhf.S)
    #print( integrals.computeKinetic() - uhf.T )
    print("Dipole moment= ", integrals.computeDipole())
예제 #20
0
        g = self.gmo
        o = slice(None, self.nocc)
        v = slice(self.nocc, None)
        w0 = g[o, o, v, v]
        w1 = 1 / 2 * np.einsum('abcd,ijcd->ijab', g[v, v, v, v], t)
        w2 = 1 / 2 * np.einsum('klij,klab->ijab', g[o, o, o, o], t)
        w3 = np.einsum('akic,jkbc->ijab', g[v, o, o, v], t)
        w3 += -w3.transpose(
            (0, 1, 3, 2)) - w3.transpose(1, 0, 2, 3) - w3.transpose(
                (1, 0, 3, 2))
        w4 = np.einsum('klcd,ijac,klbd->ijab', g[o, o, v, v], t, t)
        w4 += -w4.transpose((0, 1, 3, 2))
        w5 = 1 / 2 * np.einsum('klcd,ikab,jlcd->ijab', g[o, o, v, v], t, t)
        w5 += w5.transpose((1, 0, 2, 3))
        w6 = 1 / 4 * np.einsum('klcd,ijcd,klab->ijab', g[o, o, v, v], t, t)
        w7 = 1 / 4 * np.einsum('klcd,ikac,jlbd->ijab', g[o, o, v, v], t, t)
        w7 += w7.transpose((1, 0, 2, 3))

        return w0 + w1 + w2 + w3 + w4 + w5 + w6 + w7


if __name__ == "__main__":
    import sys
    sys.path.insert(0, '../../5/jevandezande')
    from uhf import UHF
    uhf = UHF('../../3/jevandezande/Options.ini')
    uhf.energy()
    ccd = CCD(uhf)
    ccd.energy()
    ccd.plot_convergence()
예제 #21
0
파일: mp2.py 프로젝트: CCQC/summer-program
        self.e = uhf.e                      # gets orbital energies from UHF
        self.nocc = uhf.nocc                # gets number off occupied orbitals from UHF
        self.nto = uhf.nto                  # gets total number of spin orbitals from UHF
        self.E0 = uhf.E_SCF                 # UHF energy

    def transform_integrals(self, C, g_ao): #Transforms from AO to MO
        return np.einsum('pqrs, pP, qQ, rR, sS-> PQRS',g_ao, C, C, C, C)
         
    def get_energy(self):
        # calls transform_integrals function on uhf coeffiecients and two-electron integral
        g_mo = self.transform_integrals(uhf.C, uhf.g)
        e, E0, nocc, nto = self.e, self.E0, self.nocc, self.nto
        E = 0.0
        for i in range(nocc):
            for j in range(nocc):
                for a in range(nocc, nto):
                    for b in range(nocc, nto):
                        E += ((1/4)*g_mo[i,j,a,b]**2)/(e[i]+e[j]-e[a]-e[b])  # MP2 energy expression

        print('The second order energy correction is {:20.14f}'.format(E)) 
        print('The total MP2 energy is {:20.14f}'.format(E0+E))
        return E

# testing
if __name__=='__main__':

    uhf = UHF('../../5/bz3wp/Options.ini')
    uhf.get_energy()
    mp2 = MP2(uhf)
    mp2.get_energy()
예제 #22
0
파일: mp2.py 프로젝트: bzhang25/Chem8950
def int_trans_1(gao, C):
    return np.einsum('pqrs, pP, qQ, rR, sS -> PQRS', gao, C, C, C, C)


def int_trans_2(gao, C):

    return np.einsum(
        'pQRS, pP -> PQRS',
        np.einsum(
            'pqRS, qQ -> pQRS',
            np.einsum('pqrS, rR -> pqRS', np.einsum('pqrs, sS -> pqrS', gao,
                                                    C), C), C), C)


if __name__ == '__main__':
    uhf = UHF('Optionsoooh.ini')
    uhf.get_energy()
    mp2 = MP2(uhf)
    mp2.get_energy()
    psi4.set_options({
        'basis': 'sto-3g',
        'scf_type': 'pk',
        'MP2_type': 'conv',
        'puream': False,
        'reference': 'uhf',
        'guess': 'core',
        'e_convergence': 1e-10
    })
    psi4.energy('mp2')
예제 #23
0
 def __init__(self, mol, mints):
     self.uhf = UHF(mol, mints)
     self.uhf.compute_energy()
     self.gmo = transform_tei(self.uhf.g, self.uhf.C)
예제 #24
0
import psi4
import numpy as np
import sys
import scipy.linalg as la
sys.path.insert(0, '../../5/bz3wp')
from uhf import UHF

class CCD:
        
    def __init__(self, uhf):                             # getting class variables from UHF
        self.e = uhf.e                                   # UHF orbital energies
        self.E0 = uhf.E_SCF                              # UHF energy
        self.nocc = uhf.nocc                             # number of occupied orbitals
        self.nto = uhf.nto                               # total number of spin orbitals
        self.vir = self.nto - self.nocc                  # number of virtual orbitals
        self.ndet = self.nocc*self.vir
        self.C = uhf.C                                   # MO coefficients
    
    
# testing
if __name__=='__main__':

    uhf = UHF('../../5/bz3wp/Options.ini')
    uhf.get_energy()
예제 #25
0
 def __init__(self, mol, mints):
   uhf = UHF(mol, mints)
   uhf.compute_energy()
   self.g   = transform_tei(uhf.g, uhf.C) # antisymmetrized two-electron integrals, spin-orbital (MO) basis
   self.uhf = uhf
예제 #26
0
class UMP2:
    
    def __init__(self,mol,mints):
        self.nocc = get_nocc(mol)
        self.nbf = get_nbf(mints)
        self.norb = 2*self.nbf
        self.conv = get_conv()
        self.maxiter = get_maxiter()
        self.uhf = UHF(mol,mints)
        self.E_uhf = self.uhf.get_energy()
        self.e = self.uhf.e
        self.g = self.uhf.g
        self.C = self.uhf.C

    def get_mp2(self):

        # rename class variables
        nocc, nbf, conv, maxiter,norb = self.nocc, self.nbf, self.conv, self.maxiter,self.norb
        E_uhf, e = self.E_uhf, self.e


        ####  4 different algorithms for integral transformation

        #1 
        Gmo = self.transform_integrals_einsum_faster()
        #2  Gmo = self.transform_integrals_einsum()
        #3  Gmo = self.transform_integrals_einsum_noddy()
        #4  Gmo = self.transform_integrals_noddy()


        Gmo = Gmo - Gmo.swapaxes(2,3)                       ####  Antisymmetrize integrals
        Ecorr = 0.0
        for i in range(nocc):
            for j in range(nocc):
                for a in range(nocc,norb):
                    for b in range(nocc,norb):
                        Ecorr += 0.25 * (Gmo[i,j,a,b])**2 / (e[i] + e[j] - e[a] - e[b])
        return E_uhf + Ecorr


    def transform_integrals_einsum_noddy(self):
        g, C = self.g, self.C
        return np.einsum("PQRS,Pp,Qq,Rr,Ss->pqrs",g,C,C,C,C)

    def transform_integrals_noddy(self):
        g, C = self.g, self.C
        Gmo = np.zeros(g.shape)
        for p in range(self.norb):
            for q in range(self.norb):
                for r in range(self.norb):
                    for s in range(self.norb):
                        for P in range(self.norb):
                            for Q in range(self.norb):
                                for R in range(self.norb):
                                    for S in range(self.norb):
                                        Gmo[p,q,r,s] += C[P,p]*C[Q,q]*C[R,r]*C[S,s] * g[P,Q,R,S]
        return Gmo


    def transform_integrals_einsum_faster(self):
        g,C = self.g, self.C
        return np.einsum("Pp,Pqrs->pqrs",C,
                    np.einsum("Qq,PQrs->Pqrs",C,
                        np.einsum("Rr,PQRs->PQrs",C,
                            np.einsum("Ss,PQRS->PQRs",C,g))))


    def transform_integrals_faster(self):
        g,C,norb = self.g, self.C, self.norb

        Gmo1 = np.zeros(g.shape)
        for P in range(norb):
            for Q in range(norb):
                for R in range(norb):
                    for S in range(norb):
                        for s in range(norb):
                            Gmo1[P,Q,R,s] += C[S,s] * g[P,Q,R,S] 

        Gmo2 = np.zeros(g.shape)
        for P in range(norb):
            for Q in range(norb):
                for R in range(norb):
                    for s in range(norb):
                        for r in range(norb):
                            Gmo2[P,Q,r,s] += C[R,r] * Gmo1[P,Q,R,s] 

        Gmo3 = np.zeros(g.shape)
        for P in range(norb):
            for Q in range(norb):
                for r in range(norb):
                    for s in range(norb):
                        for q in range(norb):
                            Gmo3[P,q,r,s] += C[Q,q] * Gmo2[P,Q,r,s] 

        Gmo = np.zeros(g.shape)
        for P in range(norb):
            for q in range(norb):
                for r in range(norb):
                    for s in range(norb):
                        for p in range(norb):
                            Gmo[p,q,r,s] += C[P,p] * Gmo3[P,q,r,s] 

        return Gmo