def casci(self, mo_coeff=None, ci0=None): if mo_coeff is None: mo_coeff = self.mo_coeff else: self.mo_coeff = mo_coeff if ci0 is None: ci0 = self.ci if self.verbose > logger.QUIET: pyscf.gto.mole.check_sanity(self, self._keys, self.stdout) self.dump_flags() #irrep_name = self.mol.irrep_name irrep_name = self.mol.irrep_id self.orbsym = pyscf.symm.label_orb_symm(self.mol, irrep_name, self.mol.symm_orb, self.mo_coeff, s=self._scf.get_ovlp()) if not hasattr(self.fcisolver, 'orbsym') or \ not self.fcisolver.orbsym: ncore = self.ncore nocc = self.ncore + self.ncas self.fcisolver.orbsym = self.orbsym[ncore:nocc] self.e_tot, e_cas, self.ci = \ casci.kernel(self, mo_coeff, ci0=ci0, verbose=self.verbose) #if self.verbose >= logger.INFO: # self.analyze(mo_coeff, self.ci, verbose=self.verbose) return self.e_tot, e_cas, self.ci
def casci(self, mo_coeff, ci0=None, eris=None): if eris is None: fcasci = copy.copy(self) fcasci.ao2mo = self.get_h2cas else: fcasci = _fake_h_for_fast_casci(self, mo_coeff, eris) log = logger.Logger(self.stdout, self.verbose) return casci.kernel(fcasci, mo_coeff, ci0=ci0, verbose=log)
def casci(self, mo_coeff, ci0=None, eris=None, verbose=None, envs=None): if eris is None: fcasci = copy.copy(self) fcasci.ao2mo = self.get_h2cas else: fcasci = _fake_h_for_fast_casci(self, mo_coeff, eris) if isinstance(verbose, logger.Logger): log = verbose else: if verbose is None: verbose = self.verbose log = logger.Logger(self.stdout, verbose) e_tot, e_ci, fcivec = casci.kernel(fcasci, mo_coeff, ci0, log) if not isinstance(e_ci, (float, numpy.number)): raise RuntimeError( 'Multiple roots are detected in fcisolver. ' 'CASSCF does not know which state to optimize.\n' 'See also mcscf.state_average or mcscf.state_specific for excited states.' ) if envs is not None and log.verbose >= logger.INFO: log.debug('CAS space CI energy = %.15g', e_ci) if hasattr(self.fcisolver, 'spin_square'): ss = self.fcisolver.spin_square(fcivec, self.ncas, self.nelecas) else: ss = None if 'imicro' in envs: # Within CASSCF iteration if ss is None: log.info( 'macro iter %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.8g', envs['imacro'], envs['njk'], envs['imicro'], e_tot, e_tot - envs['elast']) else: log.info( 'macro iter %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.8g S^2 = %.7f', envs['imacro'], envs['njk'], envs['imicro'], e_tot, e_tot - envs['elast'], ss[0]) if 'norm_gci' in envs: log.info( ' |grad[o]|=%5.3g ' '|grad[c]|= %s |ddm|=%5.3g', envs['norm_gorb0'], envs['norm_gci'], envs['norm_ddm']) else: log.info(' |grad[o]|=%5.3g |ddm|=%5.3g', envs['norm_gorb0'], envs['norm_ddm']) else: # Initialization step if ss is None: log.info('CASCI E = %.15g', e_tot) else: log.info('CASCI E = %.15g S^2 = %.7f', e_tot, ss[0]) return e_tot, e_ci, fcivec
def casci(self, mo_coeff, ci0=None, eris=None, verbose=None, envs=None): if eris is None: fcasci = copy.copy(self) fcasci.ao2mo = self.get_h2cas else: fcasci = _fake_h_for_fast_casci(self, mo_coeff, eris) if isinstance(verbose, logger.Logger): log = verbose else: if verbose is None: verbose = self.verbose log = logger.Logger(self.stdout, verbose) e_tot, e_ci, fcivec = casci.kernel(fcasci, mo_coeff, ci0, log) if not isinstance(e_ci, (float, numpy.number)): raise RuntimeError('Multiple roots are detected in fcisolver. ' 'CASSCF does not know which state to optimize.\n' 'See also mcscf.state_average or mcscf.state_specific for excited states.') if envs is not None and log.verbose >= logger.INFO: log.debug('CAS space CI energy = %.15g', e_ci) if hasattr(self.fcisolver,'spin_square'): ss = self.fcisolver.spin_square(fcivec, self.ncas, self.nelecas) else: ss = None if 'imicro' in envs: # Within CASSCF iteration if ss is None: log.info('macro iter %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.8g', envs['imacro'], envs['njk'], envs['imicro'], e_tot, e_tot-envs['elast']) else: log.info('macro iter %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.8g S^2 = %.7f', envs['imacro'], envs['njk'], envs['imicro'], e_tot, e_tot-envs['elast'], ss[0]) if 'norm_gci' in envs: log.info(' |grad[o]|=%5.3g ' '|grad[c]|= %s |ddm|=%5.3g', envs['norm_gorb0'], envs['norm_gci'], envs['norm_ddm']) else: log.info(' |grad[o]|=%5.3g |ddm|=%5.3g', envs['norm_gorb0'], envs['norm_ddm']) else: # Initialization step if ss is None: log.info('CASCI E = %.15g', e_tot) else: log.info('CASCI E = %.15g S^2 = %.7f', e_tot, ss[0]) return e_tot, e_ci, fcivec
def casci(self, mo_coeff, ci0=None, eris=None, verbose=None, envs=None): if eris is None: import copy fcasci = copy.copy(self) fcasci.ao2mo = self.get_h2cas else: fcasci = _fake_h_for_fast_casci(self, mo_coeff, eris) if isinstance(verbose, logger.Logger): log = verbose else: if verbose is None: verbose = self.verbose log = logger.Logger(self.stdout, verbose) e_tot, e_ci, fcivec = casci.kernel(fcasci, mo_coeff, ci0, log) if envs is not None and log.verbose >= logger.INFO: log.debug('CAS space CI energy = %.15g', e_ci) if hasattr(self.fcisolver,'spin_square'): ss = self.fcisolver.spin_square(fcivec, self.ncas, self.nelecas) else: ss = None if 'imicro' in envs: # Within CASSCF iteration if ss is None: log.info('macro iter %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.8g', envs['imacro'], envs['njk'], envs['imicro']+1, e_tot, e_tot-envs['elast']) else: log.info('macro iter %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.8g S^2 = %.7f', envs['imacro'], envs['njk'], envs['imicro']+1, e_tot, e_tot-envs['elast'], ss[0]) if 'norm_gci' in envs: log.info(' |grad[o]|= %4.3g ' '|grad[c]|= %s |ddm|= %4.3g', envs['norm_gorb'], envs['norm_gci'], envs['norm_ddm']) else: log.info(' |grad[o]|= %4.3g |ddm|= %4.3g', envs['norm_gorb'], envs['norm_ddm']) else: # Initialization step if ss is None: log.info('CASCI E = %.15g', e_tot) else: log.info('CASCI E = %.15g S^2 = %.7f', e_tot, ss[0]) return e_tot, e_ci, fcivec
def casci(self, mo_coeff, ci0=None, eris=None, verbose=None, envs=None): log = logger.new_logger(self, verbose) if eris is None: fcasci = copy.copy(self) fcasci.ao2mo = self.get_h2cas else: fcasci = mc1step._fake_h_for_fast_casci(self, mo_coeff, eris) e_tot, e_cas, fcivec = casci.kernel(fcasci, mo_coeff, ci0, log) if not isinstance(e_cas, (float, numpy.number)): raise RuntimeError( 'Multiple roots are detected in fcisolver. ' 'CASSCF does not know which state to optimize.\n' 'See also mcscf.state_average or mcscf.state_specific for excited states.' ) if envs is not None and log.verbose >= logger.INFO: log.debug('CAS space CI energy = %.15g', e_cas) if getattr(self.fcisolver, 'spin_square', None): ss = self.fcisolver.spin_square(fcivec, self.ncas, self.nelecas) else: ss = None if 'imacro' in envs: # Within CASSCF iteration stat = envs['stat'] if ss is None: log.info( 'macro %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.4g |grad|=%5.3g', envs['imacro'], stat.tot_hop + stat.tot_kf, stat.imic, e_tot, e_tot - envs['elast'], envs['norm_gall']) else: log.info( 'macro %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.4g |grad|=%5.3g S^2 = %.7f', envs['imacro'], stat.tot_hop + stat.tot_kf, stat.imic, e_tot, e_tot - envs['elast'], envs['norm_gall'], ss[0]) else: # Initialization step elast = envs.get('elast', 0) if ss is None: log.info('CASCI E = %.15g', e_tot) else: log.info('CASCI E = %.15g dE = %.8g S^2 = %.7f', e_tot, e_tot - elast, ss[0]) return e_tot, e_cas, fcivec
def casci(self, mo_coeff, ci0=None, eris=None, verbose=None, envs=None): log = logger.new_logger(self, verbose) if eris is None: fcasci = copy.copy(self) fcasci.ao2mo = self.get_h2cas else: fcasci = mc1step._fake_h_for_fast_casci(self, mo_coeff, eris) e_tot, e_cas, fcivec = casci.kernel(fcasci, mo_coeff, ci0, log) if not isinstance(e_cas, (float, numpy.number)): raise RuntimeError('Multiple roots are detected in fcisolver. ' 'CASSCF does not know which state to optimize.\n' 'See also mcscf.state_average or mcscf.state_specific for excited states.') if envs is not None and log.verbose >= logger.INFO: log.debug('CAS space CI energy = %.15g', e_cas) if getattr(self.fcisolver, 'spin_square', None): ss = self.fcisolver.spin_square(fcivec, self.ncas, self.nelecas) else: ss = None if 'imacro' in envs: # Within CASSCF iteration stat = envs['stat'] if ss is None: log.info('macro %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.4g |grad|=%5.3g', envs['imacro'], stat.tot_hop+stat.tot_kf, stat.imic, e_tot, e_tot-envs['elast'], envs['norm_gall']) else: log.info('macro %d (%d JK %d micro), ' 'CASSCF E = %.15g dE = %.4g |grad|=%5.3g S^2 = %.7f', envs['imacro'], stat.tot_hop+stat.tot_kf, stat.imic, e_tot, e_tot-envs['elast'], envs['norm_gall'], ss[0]) else: # Initialization step elast = envs.get('elast', 0) if ss is None: log.info('CASCI E = %.15g', e_tot) else: log.info('CASCI E = %.15g dE = %.8g S^2 = %.7f', e_tot, e_tot-elast, ss[0]) return e_tot, e_cas, fcivec