def guess_wfnsym(self, norb, nelec, fcivec=None, orbsym=None, wfnsym=None, **kwargs): ''' Guess point group symmetry of the FCI wavefunction. If fcivec is given, the symmetry of fcivec is used. Otherwise the symmetry is based on the HF determinant. ''' if orbsym is None: orbsym = self.orbsym nelec = _unpack_nelec(nelec, self.spin) if fcivec is None: wfnsym = _id_wfnsym(self, norb, nelec, orbsym, wfnsym) else: # TODO: if wfnsym is given in the input, check whether the # symmetry of fcivec is consistent with given wfnsym. wfnsym = addons.guess_wfnsym(fcivec, norb, nelec, orbsym) verbose = kwargs.get('verbose', None) log = logger.new_logger(self, verbose) log.debug('Guessing CI wfn symmetry = %s', wfnsym) return wfnsym
def guess_wfnsym(self, norb, nelec, fcivec=None, orbsym=None, wfnsym=None, **kwargs): ''' Guess point group symmetry of the FCI wavefunction. If fcivec is given, the symmetry of fcivec is used. Otherwise the symmetry is based on the HF determinant. ''' if orbsym is None: orbsym = self.orbsym verbose = kwargs.get('verbose', None) log = logger.new_logger(self, verbose) nelec = _unpack_nelec(nelec, self.spin) if fcivec is None: # guess wfnsym if initial guess is not given wfnsym = _id_wfnsym(self, norb, nelec, orbsym, wfnsym) log.debug('Guessing CI wfn symmetry = %s', wfnsym) elif wfnsym is None: wfnsym = addons.guess_wfnsym(fcivec, norb, nelec, orbsym) log.debug('Guessing CI wfn symmetry = %s', wfnsym) else: # verify if the input wfnsym is consistent with the symmetry of fcivec neleca, nelecb = nelec strsa = numpy.asarray(cistring.make_strings(range(norb), neleca)) strsb = numpy.asarray(cistring.make_strings(range(norb), nelecb)) na, nb = strsa.size, strsb.size orbsym_in_d2h = numpy.asarray(orbsym) % 10 airreps = numpy.zeros(na, dtype=numpy.int32) birreps = numpy.zeros(nb, dtype=numpy.int32) for i, ir in enumerate(orbsym_in_d2h): airreps[numpy.bitwise_and(strsa, 1 << i) > 0] ^= ir birreps[numpy.bitwise_and(strsb, 1 << i) > 0] ^= ir wfnsym = _id_wfnsym(self, norb, nelec, orbsym, wfnsym) mask = (airreps.reshape(-1, 1) ^ birreps) == wfnsym if isinstance(fcivec, numpy.ndarray) and fcivec.ndim <= 2: fcivec = [fcivec] if all(abs(c.reshape(na, nb)[mask]).max() < 1e-5 for c in fcivec): raise RuntimeError( 'Input wfnsym is not consistent with fcivec coefficients') return wfnsym
def guess_wfnsym(self, norb, nelec, fcivec=None, wfnsym=None, **kwargs): if fcivec is None: wfnsym = direct_spin1_symm._id_wfnsym(self, norb, nelec, wfnsym) else: wfnsym = addons.guess_wfnsym(fcivec, norb, nelec, self.orbsym) if 'verbose' in kwargs: if isinstance(kwargs['verbose'], logger.Logger): log = kwargs['verbose'] else: log = logger.Logger(self.stdout, kwargs['verbose']) log.debug('Guessing CI wfn symmetry = %s', wfnsym) else: logger.debug(self, 'Guessing CI wfn symmetry = %s', wfnsym) return wfnsym
def guess_wfnsym(self, norb, nelec, fcivec=None, wfnsym=None, **kwargs): if fcivec is None: wfnsym = direct_spin1_symm._id_wfnsym(self, norb, nelec, wfnsym) else: wfnsym = addons.guess_wfnsym(fcivec, norb, nelec, self.orbsym) if 'verbose' in kwargs: if isinstance(kwargs['verbose'], logger.Logger): log = kwargs['verbose'] else: log = logger.Logger(self.stdout, kwargs['verbose']) log.debug('Guessing CI wfn symmetry = %s', wfnsym) else: logger.debug(self, 'Guessing CI wfn symmetry = %s', wfnsym) return wfnsym
def guess_wfnsym(self, norb, nelec, fcivec=None, orbsym=None, wfnsym=None, **kwargs): if orbsym is None: orbsym = self.orbsym if fcivec is None: wfnsym = direct_spin1_symm._id_wfnsym(self, norb, nelec, orbsym, wfnsym) else: wfnsym = addons.guess_wfnsym(fcivec, norb, nelec, orbsym) verbose = kwargs.get('verbose', None) log = logger.new_logger(self, verbose) log.debug('Guessing CI wfn symmetry = %s', wfnsym) return wfnsym
def guess_wfnsym(self, norb, nelec, fcivec=None, orbsym=None, wfnsym=None, **kwargs): ''' Guess point group symmetry of the FCI wavefunction. If fcivec is given, the symmetry of fcivec is used. Otherwise the symmetry is based on the HF determinant. ''' if orbsym is None: orbsym = self.orbsym nelec = _unpack_nelec(nelec, self.spin) if fcivec is None: wfnsym = _id_wfnsym(self, norb, nelec, orbsym, wfnsym) else: # TODO: if wfnsym is given in the input, check whether the # symmetry of fcivec is consistent with given wfnsym. wfnsym = addons.guess_wfnsym(fcivec, norb, nelec, orbsym) verbose = kwargs.get('verbose', None) log = logger.new_logger(self, verbose) log.debug('Guessing CI wfn symmetry = %s', wfnsym) return wfnsym
def guess_wfnsym(self, norb, nelec, fcivec=None, wfnsym=None, **kwargs): ''' Guess point group symmetry of the FCI wavefunction. If fcivec is given, the symmetry of fcivec is used. Otherwise the symmetry is based on the HF determinant. ''' if fcivec is None: wfnsym = _id_wfnsym(self, norb, nelec, wfnsym) else: # TODO: if wfnsym is given in the input, check whether the # symmetry of fcivec is consistent with given wfnsym. wfnsym = addons.guess_wfnsym(fcivec, norb, nelec, self.orbsym) if 'verbose' in kwargs: if isinstance(kwargs['verbose'], logger.Logger): log = kwargs['verbose'] else: log = logger.Logger(self.stdout, kwargs['verbose']) log.debug('Guessing CI wfn symmetry = %s', wfnsym) else: logger.debug(self, 'Guessing CI wfn symmetry = %s', wfnsym) return wfnsym