From be2571120e041ba8ba168906bdbd5823733bc7bb Mon Sep 17 00:00:00 2001 From: Matthew R Hermes Date: Wed, 17 Jul 2024 17:00:15 -0500 Subject: [PATCH] first lasscf_async combine_o1 3-frag convergence The problem in the previous commit was actually due to the evaluation of the convergence tolerance. In the subproblem, the gradient was lower than the tolerance, but the overall gradient norm was larger than it, so the iteration just stopped making progress. Enforce a minimum of 1 cycle through the subproblem iteration brute-force solves this issue for now. --- my_pyscf/mcscf/lasci.py | 1 + my_pyscf/mcscf/lasci_sync.py | 8 +++++--- my_pyscf/mcscf/lasscf_async/combine.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/my_pyscf/mcscf/lasci.py b/my_pyscf/mcscf/lasci.py index a92e713b..7bae5cb1 100644 --- a/my_pyscf/mcscf/lasci.py +++ b/my_pyscf/mcscf/lasci.py @@ -910,6 +910,7 @@ def __init__(self, mf, ncas, nelecas, ncore=None, spin_sub=None, frozen=None, fr self.ah_level_shift = 1e-8 self.max_cycle_macro = 50 self.max_cycle_micro = 5 + self.min_cycle_macro = 0 keys = set(('e_states', 'fciboxes', 'nroots', 'weights', 'ncas_sub', 'nelecas_sub', 'conv_tol_grad', 'conv_tol_self', 'max_cycle_macro', 'max_cycle_micro', 'ah_level_shift', 'states_converged', 'chkfile', 'e_lexc')) diff --git a/my_pyscf/mcscf/lasci_sync.py b/my_pyscf/mcscf/lasci_sync.py index 4718af8a..a8d9a4b5 100644 --- a/my_pyscf/mcscf/lasci_sync.py +++ b/my_pyscf/mcscf/lasci_sync.py @@ -128,9 +128,11 @@ def kernel (las, mo_coeff=None, ci0=None, casdm0_fr=None, conv_tol_grad=1e-4, # ('LASCI micro init : E = %.15g ; |g_orb| = %.15g ; |g_ci| = %.15g ; |x0_orb| = %.15g ' # '; |x0_ci| = %.15g'), H_op.e_tot, norm_gorb, norm_gci, norm_xorb, norm_xci) las.dump_chk (mo_coeff=mo_coeff, ci=ci1) - if (norm_gorb=las.min_cycle_macro)): + converged = True + break H_op._init_eri_() # ^ This is down here to save time in case I am already converged at initialization t1 = log.timer ('LASCI Hessian constructor', *t1) diff --git a/my_pyscf/mcscf/lasscf_async/combine.py b/my_pyscf/mcscf/lasscf_async/combine.py index f0134910..db5e005d 100644 --- a/my_pyscf/mcscf/lasscf_async/combine.py +++ b/my_pyscf/mcscf/lasscf_async/combine.py @@ -133,6 +133,8 @@ def relax (las, kf, freeze_inactive=False, frozen_frags=None): flas.__dict__.update (las.__dict__) flas.frozen = [] flas.frozen_ci = frozen_frags + # TODO: ensure robust tolerance selection so things always make progress + flas.min_cycle_macro = 1 if freeze_inactive: flas.frozen.extend (list (range (las.ncore))) for ifrag in frozen_frags: @@ -196,7 +198,6 @@ def select_aa_block (las, frags1, frags2, fock1): gmax = np.argmax (gblk) i = frags1[gmax // len (frags2)] j = frags2[gmax % len (frags2)] - print (i, j, gblk[gmax]) return i, j def combine_pair (las, kf1, kf2):