From 2fcc63b25f63dc21a416bebd98fa86cfc8d2fb75 Mon Sep 17 00:00:00 2001 From: Matthew R Hermes Date: Fri, 13 Dec 2024 14:01:25 -0600 Subject: [PATCH] Record/report disc svals in lassis --- my_pyscf/lassi/excitations.py | 10 +++++----- my_pyscf/lassi/lassis.py | 26 +++++++++++++++----------- tests/lassi/test_excitations.py | 6 +++--- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/my_pyscf/lassi/excitations.py b/my_pyscf/lassi/excitations.py index 79e31ff1..39326612 100644 --- a/my_pyscf/lassi/excitations.py +++ b/my_pyscf/lassi/excitations.py @@ -194,7 +194,7 @@ def kernel (self, h1, h2, ecore=0, ci0=None, tdm1s_f = self.get_tdm1s_f (ci1, ci1, norb_f, nelec_f) e = 0 grad_max = conv_tol_grad * 100 - disc_sval_sum = sum (disc_svals) + disc_sval_max = max (list(disc_svals)+[0.0,]) converged = False log.info ('Entering product-state fixed-point CI iteration') for it in range (max_cycle_macro): @@ -204,8 +204,8 @@ def kernel (self, h1, h2, ecore=0, ci0=None, e, si = self.eig1 (ham_pq, ci0) _, u, si_p, si_q, vh = self.schmidt_trunc (si, ci0, nroots=nroots) ci1 = self.truncrot_ci (ci0, u, vh) - log.info ('Cycle %d: max grad = %e ; e = %e, |delta| = %e, ||discarded|| = %e', - it, grad_max, e, e - e_last, disc_sval_sum) + log.info ('Cycle %d: max grad = %e ; e = %e, |delta| = %e, max (discarded) = %e', + it, grad_max, e, e - e_last, disc_sval_max) if ((grad_max < conv_tol_grad) and (abs (e-e_last) < conv_tol_self)): converged = True break @@ -247,7 +247,7 @@ def kernel (self, h1, h2, ecore=0, ci0=None, hci_pspace_diag = self.truncrot_hci_pspace_diag (hci_pspace_diag, u, vh) tdm1s_f = self.truncrot_tdm1s_f (tdm1s_f, u, vh) log.debug ('Discarded singular values: {}'.format (disc_svals)) - disc_sval_sum = sum (disc_svals) + disc_sval_max = max (list (disc_svals) + [0.0,]) conv_str = ['NOT converged','converged'][int (converged)] log.info (('Product_state fixed-point CI iteration {} after {} ' 'cycles').format (conv_str, it)) @@ -261,7 +261,7 @@ def kernel (self, h1, h2, ecore=0, ci0=None, for ifrag, c in zip (self.excited_frags, ci1_active): ci1[ifrag] = np.asarray (c) t1 = self.log.timer ('ExcitationPSFCISolver kernel', *t0) - return converged, energy_elec, ci1 + return converged, energy_elec, ci1, disc_sval_max def get_nq (self): lroots = get_lroots ([self.ci_ref[ifrag] for ifrag in self.excited_frags]) diff --git a/my_pyscf/lassi/lassis.py b/my_pyscf/lassi/lassis.py index 5b35ebaa..3cf86097 100644 --- a/my_pyscf/lassi/lassis.py +++ b/my_pyscf/lassi/lassis.py @@ -96,13 +96,13 @@ def prepare_fbf (lsi, ci_ref, ci_sf, ci_ch, ncharge=1, nspin=0, sa_heff=True, # 3. Charge excitations if ncharge: las2 = all_single_excitations (las1) - conv_ch, ci_ch = single_excitations_ci ( + conv_ch, ci_ch, max_disc_sval = single_excitations_ci ( lsi, las2, las1, ci_ch, ncharge=ncharge, sa_heff=sa_heff, deactivate_vrv=deactivate_vrv, spin_flips=spin_flips, crash_locmin=crash_locmin, ham_2q=ham_2q ) log.timer ("LASSIS fragment basis functions preparation", *t0) - return conv_sf and conv_ch, ci_sf, ci_ch + return conv_sf and conv_ch, ci_sf, ci_ch, max_disc_sval def filter_single_excitation_spin_shuffles (lsi, spaces, nroots_ref=1): spaces_ref = spaces[:nroots_ref] @@ -202,6 +202,7 @@ def single_excitations_ci (lsi, las2, las1, ci_ch, ncharge=1, sa_heff=True, deac converged = True spaces = filter_single_excitation_spin_shuffles (lsi, spaces, nroots_ref=las1.nroots) keys = set () + max_max_disc = 0 for i in range (las1.nroots, len (spaces)): # compute lroots psref_ix = [j for j, space in enumerate (spaces[:las1.nroots]) @@ -264,10 +265,10 @@ def single_excitations_ci (lsi, las2, las1, ci_ch, ncharge=1, sa_heff=True, deac ci0[1] = mdown (ci0[1], norb_a, nelec_a, smult_a) if lroots[afrag,i] == 1 and ci0[1].ndim==3: ci0[1] = ci0[1][0] ci0 = [ci0[int (afrag