예제 #1
0
natoms = 1000
system = LJCluster(natoms)
#system.params.structural_quench_params.debug = True
#system.params.structural_quench_params.iprint = 100
db = system.create_database()
bh = system.get_basinhopping(db)
bh.run(1)

m = db.minima()[0]
coords = m.coords

potential = system.get_potential()
energy, gradient, hessian = potential.getEnergyGradientHessian(coords)

dummy_vec = ts.gramm_schmidt(ts.zeroEV_cluster(coords))

shifted_hess = hessian.copy()

for i in range(6):
    shifted_hess += np.outer(dummy_vec[i], dummy_vec[i])

shifted_eval, shifted_evec = get_sorted_eig(shifted_hess)

print "First log sum: ", np.sum(np.log(shifted_eval[6:]))

sparse_hess = scipy.sparse.csc_matrix(shifted_hess)
factor = cholmod.cholesky(sparse_hess)

diagonal = np.diagonal(factor.L().todense())
예제 #2
0
파일: dimer.py 프로젝트: js850/PyGMIN
 def get_eigenvecs(self, x0):
     zev = []
     if(self.zeroEigenVecs):
         zev = self.zeroEigenVecs(x0)
     # print "lenzev", len(zev)
     return gramm_schmidt(zev + [v[0] for v in self.tau_ignore])
예제 #3
0
파일: dimer.py 프로젝트: js850/PyGMIN
    def updateRotation(self, x0, E0, grad0_):
        iter_rot = 0
        
        # get the zero eigenvalues
        zev = []
        if(self.zeroEigenVecs):
            zev = self.zeroEigenVecs(x0)

        # remove zero eigenvalues from gradient
        grad0 = grad0_.copy()
        evecs = gramm_schmidt(zev + [v[0] for v in self.tau_ignore])
        self.orthogonalize(grad0, evecs)

        #print u
        #print np.dot(u[3],u[4]),np.dot(u[3],u[5]),np.dot(u[5],u[4])
        #print self.potential.getEnergy(x0) - self.potential.getEnergy(x0 + 1e-8*u[3]/1e-8),\
        #self.potential.getEnergy(x0) - self.potential.getEnergy(x0 + 1e-8*u[4]/1e-8),\
        #self.potential.getEnergy(x0) - self.potential.getEnergy(x0 + 1e-8*u[5]/1e-8)
        #print gramm_schmidt(zev)
        # update ignore list for eigenvalues
        for t in self.tau_ignore:
            E,grad1 = self.potential.getEnergyGradient(x0 + t[0]*self.delta)
            #grad1 = self.getOrthogonalGradient(x0 + t[1]*self.delta, zev)
            t[1] = np.dot((grad1 - grad0), t[0])/self.delta
            
        while iter_rot < self.max_rotsteps:
            #self.tau = self.tau/np.linalg.norm(self.tau)
            # construct dimer image and get energy + gradient
            
            # remove zero eigenvalues from tau
            self.orthogonalize(self.tau, evecs)
            self.tau /= np.linalg.norm(self.tau)
            
            x1 = x0 + self.tau*self.delta
            grad1 = self.getOrthogonalGradient(x1, evecs)
            
            # calculate the rotational force of dimer
            F_rot = -2.*(grad1 - grad0) + 2.*np.dot(grad1 - grad0, self.tau)*self.tau
            
            # For now just use steepest descent search direction for rotation.
            # Replace this by LBFGS
            Theta = F_rot / np.linalg.norm(F_rot)
            
            # calculate curvature C and derivative of curvature
            C = np.dot((grad1 - grad0), self.tau)/self.delta
            dC = 2.*np.dot((grad1 - grad0), Theta)/self.delta
            #print C,self.tau
            # calculate estimated rotation angle
            theta1=-0.5*np.arctan(dC/(2.*np.abs(C)))
            
            # do we need to rotate or already smaller than cutoff?
            if np.abs(theta1) < self.theta_cut:
                return
            
            # create rotated trial dimer
            taup = self.rotate(self.tau, Theta, theta1)
            # remove zero eigenvalues from tau
            self.orthogonalize(taup, evecs)
            taup /= np.linalg.norm(taup)
            
            x1p = x0 + self.delta * taup
            
            # get the new energy and gradient at trial conviguration
            grad1p = self.getOrthogonalGradient(x1p, evecs)

            #grad1p = -grad1p
            # get curvature for trial point
            Cp = np.dot((grad1p - grad0), taup)/self.delta
            
            # calculate optimum rotation angle theta_min and taumin
            b1 = 0.5*dC
            a1 = (C - Cp + b1*np.sin(2.*theta1))/(1. - np.cos(2.*theta1))
            theta_min=0.5*np.arctan(b1/a1)
            self.tau = self.rotate(self.tau, Theta, theta_min)
            
            # remove zero eigenvalues from tau
            self.orthogonalize(self.tau, evecs)
            self.tau /= np.linalg.norm(self.tau)
            

            if np.abs(theta_min) < self.theta_cut:
                return
            iter_rot+=1
예제 #4
0
파일: cholesky.py 프로젝트: js850/PyGMIN
natoms = 1000
system = LJCluster(natoms)
#system.params.structural_quench_params.debug = True
#system.params.structural_quench_params.iprint = 100
db = system.create_database()
bh = system.get_basinhopping(db)
bh.run(1)

m = db.minima()[0]
coords = m.coords

potential = system.get_potential()
energy, gradient, hessian = potential.getEnergyGradientHessian(coords)

dummy_vec = ts.gramm_schmidt(ts.zeroEV_cluster(coords))

shifted_hess = hessian.copy()

for i in range(6):
    shifted_hess += np.outer(dummy_vec[i], dummy_vec[i])

shifted_eval, shifted_evec = get_sorted_eig(shifted_hess)

print "First log sum: ", np.sum(np.log(shifted_eval[6:]))

sparse_hess = scipy.sparse.csc_matrix(shifted_hess)
factor = cholmod.cholesky(sparse_hess)

diagonal = np.diagonal(factor.L().todense())