Skip to content

Commit

Permalink
finalize lassis conv_tol_self
Browse files Browse the repository at this point in the history
Including a reset of one unittest's reference due to tighter
convergence now
  • Loading branch information
MatthewRHermes committed Jan 26, 2024
1 parent d4e4d26 commit f9f471a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
9 changes: 6 additions & 3 deletions my_pyscf/lassi/excitations.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def set_excited_fragment_(self, ifrag, nelec, smult, weights=None):
self.fcisolvers = [self.fcisolvers[i] for i in idx]

def kernel (self, h1, h2, ecore=0,
conv_tol_grad=1e-4, conv_tol_self=1e-8, max_cycle_macro=50,
conv_tol_grad=1e-4, conv_tol_self=1e-6, max_cycle_macro=50,
serialfrag=False, _add_vrv_energy=False, **kwargs):
h0, h1, h2 = self.get_excited_h (ecore, h1, h2)
norb_f = np.asarray ([self.norb_ref[ifrag] for ifrag in self.excited_frags])
Expand Down Expand Up @@ -614,6 +614,7 @@ def kernel (self, h1e, h2e, norb, nelec, ecore=0, ci0=None, orbsym=None, **kwarg
log.debug ("Self-energy singularities in VRVSolver: {}".format (self.e_q))
log.debug ("Denominators in VRVSolver: {}".format (self.denom_q))
self.test_locmin (e0, ci1, norb, nelec, ecore, h1e, h2e, warntag='Saddle-point initial guess')
h2eff = self.absorb_h1e (h1e, h2e, norb, nelec, 0.5)
for it in range (max_cycle_e0):
e, ci1 = self.undressed_kernel (
h1e, h2e, norb, nelec, ecore=ecore, ci0=ci1, orbsym=orbsym, **kwargs
Expand All @@ -622,9 +623,11 @@ def kernel (self, h1e, h2e, norb, nelec, ecore=0, ci0=None, orbsym=None, **kwarg
# be checked in the impure-state case
if isinstance (e, (list,tuple,np.ndarray)):
for i in range (len (e)):
e[i] -= np.dot (ci1[i].ravel (), self.contract_vrv (ci1[i]).ravel ())
hci = self.undressed_contract_2e (h2eff, ci1[i], norb, nelec)
e[i] = ecore + np.dot (ci1[i].ravel (), hci.ravel ())
else:
e -= np.dot (ci1.ravel (), self.contract_vrv (ci1).ravel ())
hci = self.undressed_contract_2e (h2eff, ci1, norb, nelec)
e = ecore + np.dot (ci1.ravel (), hci.ravel ())
e0_last = e0
e0 = self.solve_e0 (ecore, h1e, h2e, norb, nelec, ket)
self.denom_q = e0 - self.e_q
Expand Down
5 changes: 3 additions & 2 deletions my_pyscf/lassi/lassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def single_excitations_ci (lsi, las2, las1, ncharge=1, sa_heff=True, deactivate_
else: weights[0] = 1.0
psexc.set_excited_fragment_(k, (neleca[k],nelecb[k]), smults[k], weights=weights)
conv, e_roots[i], ci1 = psexc.kernel (h1, h2, ecore=h0,
max_cycle_macro=lsi.max_cycle_macro)
#conv_tol_self=sys.float_info.max)
max_cycle_macro=lsi.max_cycle_macro,
conv_tol_self=lsi.conv_tol_self)
spin_shuffle_ref = all ([spaces[j].is_spin_shuffle_of (spaces[0])
for j in range (1,las1.nroots)])
for k in np.where (~excfrags)[0]:
Expand Down Expand Up @@ -309,6 +309,7 @@ def __init__(self, las, ncharge='s', nspin='s', sa_heff=True, deactivate_vrv=Fal
self.crash_locmin = crash_locmin
self.e_states_meaningless = True # a tag to silence an invalid warning
LASSI.__init__(self, las, opt=opt, **kwargs)
self.conv_tol_self = 1e-6
if las.nroots>1:
logger.warn (self, ("LASSIS builds the model space for you! I don't know what will "
"happen if you build a model space by hand!"))
Expand Down
2 changes: 1 addition & 1 deletion my_pyscf/mcscf/lasci.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ def __init__(self, mf, ncas, nelecas, ncore=None, spin_sub=None, frozen=None, **
assert (len (self.nelecas_sub) == self.nfrags)
self.frozen = frozen
self.conv_tol_grad = 1e-4
self.conv_tol_self = 1e-8
self.conv_tol_self = 1e-10
self.ah_level_shift = 1e-8
self.max_cycle_macro = 50
self.max_cycle_micro = 5
Expand Down
2 changes: 1 addition & 1 deletion my_pyscf/mcscf/productstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, fcisolvers, stdout=None, verbose=0, **kwargs):
self.log = lib.logger.new_logger (self, verbose)

def kernel (self, h1, h2, norb_f, nelec_f, ecore=0, ci0=None, orbsym=None,
conv_tol_grad=1e-4, conv_tol_self=1e-8, max_cycle_macro=50,
conv_tol_grad=1e-4, conv_tol_self=1e-10, max_cycle_macro=50,
serialfrag=False, **kwargs):
log = self.log
converged = False
Expand Down
2 changes: 1 addition & 1 deletion tests/lassi/test_c2h4n4.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_lassis_slow (self):
for opt in (0,1):
with self.subTest (opt=opt):
lsis = LASSIS (las1).run (opt=opt)
self.assertAlmostEqual (lsis.e_roots[0], -295.52103109, 7)
self.assertAlmostEqual (lsis.e_roots[0], -295.52103116343307, 7)
self.assertTrue (lsis.converged)

if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tests/lassi/test_lassis_targets_slow.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def test_c2h4n4_2frag (self):
# equil
mol = struct (0.0, 0.0, '6-31g', symmetry=False)
mol.spin = 0
mol.verbose = 5 #0
mol.output = 'equil.log' #'/dev/null'
mol.verbose = 0
mol.output = '/dev/null'
mol.build ()
mf = scf.RHF (mol).run ()
las = lasscf_async.LASSCF (mf, (5,5), ((3,2),(2,3)))
Expand Down

0 comments on commit f9f471a

Please sign in to comment.