Esempio n. 1
0
 def construct1RDM_response( self, doSCF, umat_loc, NOrotation ):
     
     # This part works in the original local AO / lattice basis!
     OEI = self.locints.loc_rhf_fock() + umat_loc
     if ( doSCF == True ):
         DMloc = self.construct1RDM_base( OEI, self.numPairs )
         if ( self.locints.ERIinMEM == True ):
             DMloc = rhf.solve_ERI( self.locints.loc_oei() + umat_loc, self.locints.loc_tei(), DMloc, self.numPairs )
         else:
             DMloc = rhf.solve_JK( self.locints.loc_oei() + umat_loc, self.locints.mol, self.locints.ao2loc, DMloc, self.numPairs )
         OEI = self.locints.loc_rhf_fock_bis( DMloc ) + umat_loc
     
     # This part works in the rotated NO basis if NOrotation is specified
     rdm_deriv_rot = np.ones( [ self.locints.Norbs * self.locints.Norbs * self.Nterms ], dtype=ctypes.c_double )
     if ( NOrotation != None ):
         OEI = np.dot( np.dot( NOrotation.T, OEI ), NOrotation )
     OEI = np.array( OEI.reshape( (self.locints.Norbs * self.locints.Norbs) ), dtype=ctypes.c_double )
     
     lib_qcdmet.rhf_response( ctypes.c_int( self.locints.Norbs ),
                              ctypes.c_int( self.Nterms ),
                              ctypes.c_int( self.numPairs ),
                              self.H1start.ctypes.data_as( ctypes.c_void_p ),
                              self.H1row.ctypes.data_as( ctypes.c_void_p ),
                              self.H1col.ctypes.data_as( ctypes.c_void_p ),
                              OEI.ctypes.data_as( ctypes.c_void_p ),
                              rdm_deriv_rot.ctypes.data_as( ctypes.c_void_p ) )
     
     rdm_deriv_rot = rdm_deriv_rot.reshape( (self.Nterms, self.locints.Norbs, self.locints.Norbs), order='C' )
     return rdm_deriv_rot
Esempio n. 2
0
 def construct1RDM_loc( self, doSCF, umat_loc ):
     
     # Everything in this functions works in the original local AO / lattice basis!
     OEI   = self.locints.loc_rhf_fock() + umat_loc
     DMloc = self.construct1RDM_base( OEI, self.numPairs )
     if ( doSCF == True ):
         if ( self.locints.ERIinMEM == True ):
             DMloc = rhf.solve_ERI( self.locints.loc_oei() + umat_loc, self.locints.loc_tei(), DMloc, self.numPairs )
         else:
             DMloc = rhf.solve_JK( self.locints.loc_oei() + umat_loc, self.locints.mol, self.locints.ao2loc, DMloc, self.numPairs )
     return DMloc
Esempio n. 3
0
 def debug_matrixelements( self ):
 
     eigvals, eigvecs = np.linalg.eigh( self.activeFOCK )
     eigvecs = eigvecs[ :, eigvals.argsort() ]
     assert( self.Nelec % 2 == 0 )
     numPairs = self.Nelec / 2
     DMguess = 2 * np.dot( eigvecs[ :, :numPairs ], eigvecs[ :, :numPairs ].T )
     if ( self.ERIinMEM == True ):
         DMloc = rhf.solve_ERI( self.activeOEI, self.activeERI, DMguess, numPairs )
     else:
         DMloc = rhf.solve_JK( self.activeOEI, self.mol, self.ao2loc, DMguess, numPairs )
     newFOCKloc = self.loc_rhf_fock_bis( DMloc )
     newRHFener = self.activeCONST + 0.5 * np.einsum( 'ij,ij->', DMloc, self.activeOEI + newFOCKloc )
     print "2-norm difference of RDM(self.activeFOCK) and RDM(self.active{OEI,ERI})  =", np.linalg.norm( DMguess - DMloc )
     print "2-norm difference of self.activeFOCK and FOCK(RDM(self.active{OEI,ERI})) =", np.linalg.norm( self.activeFOCK - newFOCKloc )
     print "RHF energy of mean-field input           =", self.fullEhf
     print "RHF energy based on self.active{OEI,ERI} =", newRHFener
Esempio n. 4
0
    def construct1RDM_loc(self, doSCF, umat_loc):

        # Everything in this functions works in the original local AO / lattice basis!
        if self.altcf and self.minFunc == 'OEI':
            OEI = self.locints.loc_oei() + umat_loc
        elif self.altcf and self.minFunc == 'FOCK_INIT':
            OEI = self.locints.loc_rhf_fock() + umat_loc
        else:
            OEI = self.locints.loc_rhf_fock() + umat_loc
        DMloc = self.construct1RDM_base(OEI, self.numPairs)
        if (doSCF == True):
            if (self.locints.ERIinMEM == True):
                DMloc = rhf.solve_ERI(self.locints.loc_oei() + umat_loc,
                                      self.locints.loc_tei(), DMloc,
                                      self.numPairs)
            else:
                DMloc = rhf.solve_JK(self.locints.loc_oei() + umat_loc,
                                     self.locints.mol, self.locints.ao2loc,
                                     DMloc, self.numPairs)
        return DMloc
Esempio n. 5
0
    def construct1RDM_response(self, doSCF, umat_loc, NOrotation):

        # This part works in the original local AO / lattice basis!
        OEI = self.locints.loc_rhf_fock() + umat_loc
        if (doSCF == True):
            DMloc = self.construct1RDM_base(OEI, self.numPairs)
            if (self.locints.ERIinMEM == True):
                DMloc = rhf.solve_ERI(self.locints.loc_oei() + umat_loc,
                                      self.locints.loc_tei(), DMloc,
                                      self.numPairs)
            else:
                DMloc = rhf.solve_JK(self.locints.loc_oei() + umat_loc,
                                     self.locints.mol, self.locints.ao2loc,
                                     DMloc, self.numPairs)
            OEI = self.locints.loc_rhf_fock_bis(DMloc) + umat_loc

        # This part works in the rotated NO basis if NOrotation is specified
        rdm_deriv_rot = np.ones(
            [self.locints.Norbs * self.locints.Norbs * self.Nterms],
            dtype=ctypes.c_double)
        if (NOrotation != None):
            OEI = np.dot(np.dot(NOrotation.T, OEI), NOrotation)
        OEI = np.array(OEI.reshape((self.locints.Norbs * self.locints.Norbs)),
                       dtype=ctypes.c_double)

        lib_qcdmet.rhf_response(ctypes.c_int(self.locints.Norbs),
                                ctypes.c_int(self.Nterms),
                                ctypes.c_int(self.numPairs),
                                self.H1start.ctypes.data_as(ctypes.c_void_p),
                                self.H1row.ctypes.data_as(ctypes.c_void_p),
                                self.H1col.ctypes.data_as(ctypes.c_void_p),
                                OEI.ctypes.data_as(ctypes.c_void_p),
                                rdm_deriv_rot.ctypes.data_as(ctypes.c_void_p))

        rdm_deriv_rot = rdm_deriv_rot.reshape(
            (self.Nterms, self.locints.Norbs, self.locints.Norbs), order='C')
        return rdm_deriv_rot