Skip to content

Commit

Permalink
first lasscf_async combine_o1 3-frag convergence
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MatthewRHermes committed Jul 17, 2024
1 parent c8cb6a6 commit be25711
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions my_pyscf/mcscf/lasci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
8 changes: 5 additions & 3 deletions my_pyscf/mcscf/lasci_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<conv_tol_grad and norm_gci<conv_tol_grad)or((norm_gorb+norm_gci)<norm_gx/10):
converged = True
break
if (((norm_gorb<conv_tol_grad and norm_gci<conv_tol_grad)
or ((norm_gorb+norm_gci)<norm_gx/10))
and (it>=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)
Expand Down
3 changes: 2 additions & 1 deletion my_pyscf/mcscf/lasscf_async/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit be25711

Please sign in to comment.