def solve(self, dms_output, focks_output): # interpolation only makes sense if there are two points assert self.nused >= 2 # Fill in the missing commutators self._complete_edots_matrix() assert not np.isnan(self.edots[:self.nused,:self.nused]).any() # Setup the equations b, e = self._setup_equations() # Check if solving these equations makes sense. if b.max() - b.min() == 0 and e.max() - e.min() == 0: raise NoSCFConvergence('Convergence criteria too tight for EDIIS') # solve the quadratic programming problem qps = QPSolver(b, e, np.ones((1,self.nused)), np.array([1.0]), eps=1e-6) if self.nused < 10: energy, coeffs = qps.find_brute() guess = None else: guess = np.zeros(self.nused) guess[e.argmax()] = 1.0 energy, coeffs = qps.find_local(guess, 1.0) # for debugging purposes (negligible computational overhead) try: qps.check_solution(coeffs) except: qps.log(guess) raise cn = qps.compute_cn(coeffs != 0.0) # assign extrapolated fock error = self._build_combinations(coeffs, dms_output, focks_output) return energy, coeffs, cn, 'E', error
def solve(self, dm_output, fock_output): '''Extrapolate a new density and/or fock matrix that should have the smallest commutator norm. **Arguments:** dm_output The output for the density matrix. If set to None, this is argument is ignored. fock_output The output for the Fock matrix. If set to None, this is argument is ignored. ''' # interpolation only makes sense if there are two points assert self.nused >= 2 # Fill in the missing commutators self._complete_edots_matrix() assert not np.isnan(self.edots[:self.nused, :self.nused]).any() # Setup the equations b, e = self._setup_equations() # Check if solving these equations makes sense. if b.max() - b.min() == 0 and e.max() - e.min() == 0: raise NoSCFConvergence('Convergence criteria too tight for EDIIS') # solve the quadratic programming problem qps = QPSolver(b, e, np.ones((1, self.nused)), np.array([1.0]), eps=1e-6) if self.nused < 10: energy, coeffs = qps.find_brute() guess = None else: guess = np.zeros(self.nused) guess[e.argmax()] = 1.0 energy, coeffs = qps.find_local(guess, 1.0) # for debugging purposes try: qps.check_solution(coeffs) except: qps.log(guess) raise cn = qps.compute_cn(coeffs != 0.0) # assign extrapolated fock self._build_combinations(coeffs, dm_output, fock_output) return energy, coeffs, cn, 'E'
def solve(self, dm_output, fock_output): '''Extrapolate a new density and/or fock matrix that should have the smallest commutator norm. **Arguments:** dm_output The output for the density matrix. If set to None, this is argument is ignored. fock_output The output for the Fock matrix. If set to None, this is argument is ignored. ''' # interpolation only makes sense if there are two points assert self.nused >= 2 # Fill in the missing commutators self._complete_edots_matrix() assert not np.isnan(self.edots[:self.nused,:self.nused]).any() # Setup the equations b, e = self._setup_equations() # Check if solving these equations makes sense. if b.max() - b.min() == 0 and e.max() - e.min() == 0: raise NoSCFConvergence('Convergence criteria too tight for EDIIS') # solve the quadratic programming problem qps = QPSolver(b, e, np.ones((1,self.nused)), np.array([1.0]), eps=1e-6) if self.nused < 10: energy, coeffs = qps.find_brute() guess = None else: guess = np.zeros(self.nused) guess[e.argmax()] = 1.0 energy, coeffs = qps.find_local(guess, 1.0) # for debugging purposes try: qps.check_solution(coeffs) except: qps.log(guess) raise cn = qps.compute_cn(coeffs != 0.0) # assign extrapolated fock self._build_combinations(coeffs, dm_output, fock_output) return energy, coeffs, cn, 'E'