Skip to content

Commit

Permalink
Some CSF configuration printout (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewRHermes committed Sep 18, 2024
1 parent 97904d9 commit 5c4cd25
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
15 changes: 12 additions & 3 deletions my_pyscf/fci/csf.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,17 @@ def pspace (self, h1e, eri, norb, nelec, hdiag_det=None, hdiag_csf=None, npsp=20
return pspace (self, h1e, eri, norb, nelec, self.transformer, hdiag_det=hdiag_det,
hdiag_csf=hdiag_csf, npsp=npsp, max_memory=max_memory)

def log_transformer_cache (self, tverbose=lib.logger.INFO, **kwargs):
if len (kwargs):
self.__dict__.update (kwargs)
self.check_transformer_cache ()
if self.transformer is None:
return
log = lib.logger.new_logger (self, self.verbose)
printer = (lambda *args, **kwargs: None, log.error, log.warn, log.note, log.info,
log.debug, log.debug1, log.debug2, log.debug3, log.debug4)[tverbose]
self.transformer.print_config (printer)

class FCISolver (CSFFCISolver, direct_spin1.FCISolver):
r''' get_init_guess uses csfstring.py and csdstring.py to construct a spin-symmetry-adapted initial guess, and the Davidson algorithm is carried
out in the CSF basis. However, the ci attribute is put in the determinant basis at the end of it all, and "ci0" is also assumed
Expand All @@ -541,15 +552,14 @@ def get_init_guess(self, norb, nelec, nroots, hdiag_csf, **kwargs):
self.check_transformer_cache ()
return get_init_guess (norb, nelec, nroots, hdiag_csf, self.transformer)



def kernel(self, h1e, eri, norb, nelec, ci0=None, **kwargs):
self.norb = norb
self.nelec = nelec
if 'smult' in kwargs:
self.smult = kwargs['smult']
kwargs.pop ('smult')
self.check_transformer_cache ()
self.log_transformer_cache (lib.logger.DEBUG)
e, c = kernel (self, h1e, eri, norb, nelec, smult=self.smult,
idx_sym=None, ci0=ci0, transformer=self.transformer, **kwargs)
self.eci, self.ci = e, c
Expand All @@ -562,4 +572,3 @@ def check_transformer_cache (self):
self.transformer = CSFTransformer (self.norb, neleca, nelecb, self.smult)
else:
self.transformer._update_spin_cache (self.norb, neleca, nelecb, self.smult)

4 changes: 3 additions & 1 deletion my_pyscf/fci/csf_symm.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ def kernel(self, h1e, eri, norb, nelec, ci0=None, **kwargs):
self.wfnsym = wfnsym
kwargs['wfnsym'] = wfnsym
self.check_transformer_cache ()
self.log_transformer_cache (logger.DEBUG)

idx_sym = self.transformer.confsym[self.transformer.econf_csf_mask] == wfnsym
e, c = kernel (self, h1e, eri, norb, nelec, smult=self.smult, idx_sym=idx_sym, ci0=ci0, transformer=self.transformer, **kwargs)
e, c = kernel (self, h1e, eri, norb, nelec, smult=self.smult, idx_sym=idx_sym, ci0=ci0,
transformer=self.transformer, **kwargs)
self.eci, self.ci = e, c

self.orbsym = orbsym_back
Expand Down
10 changes: 10 additions & 0 deletions my_pyscf/fci/csfstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ def ncsf (self):
if self.wfnsym is None or self._orbsym is None: return self.econf_csf_mask.size
return (np.count_nonzero (self.confsym[self.econf_csf_mask] == self.wfnsym))

def print_config (self, printer=print):
printer ('***** CSFTransformer configuration *****')
printer ('norb = {}'.format (self.norb))
printer ('neleca, nelecb = {}, {}'.format (self.neleca, self.nelecb))
printer ('smult = {}'.format (self.smult))
printer ('orbsym = {}'.format (self.orbsym))
printer ('wfnsym = {}'.format (self.wfnsym))
printer ('ndeta, ndetb = {}, {}'.format (self.ndeta, self.ndetb))
printer ('ncsf = {}'.format (self.ncsf))

def unpack_sym_ci (ci, idx, vec_on_cols=False):
if idx is None: return ci
tot_len = idx.size
Expand Down

0 comments on commit 5c4cd25

Please sign in to comment.