Skip to content

Commit

Permalink
smart lindep handling in LASSI kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewRHermes committed Apr 24, 2024
1 parent 38af989 commit ec640ad
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions my_pyscf/lassi/lassi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from mrh.my_pyscf.lassi import op_o1
from mrh.my_pyscf.lassi.citools import get_lroots
from pyscf import lib, symm
from pyscf.scf.addons import canonical_orth_
from pyscf.lib.numpy_helper import tag_array
from pyscf.fci.direct_spin1 import _unpack_nelec
from itertools import combinations, product
Expand Down Expand Up @@ -418,16 +419,16 @@ def _eig_block (las, e0, h1, h2, ci_blk, nelec_blk, rootsym, soc, orbsym, wfnsym
# Error catch: linear dependencies in basis
try:
e, c = linalg.eigh (ham_blk, b=ovlp_blk)
except linalg.LinAlgError as e:
except linalg.LinAlgError as err:
ovlp_det = linalg.det (ovlp_blk)
lc = 'checking if LASSI basis has lindeps: |ovlp| = {:.6e}'.format (ovlp_det)
lib.logger.info (las, 'Caught error %s, %s', str (e), lc)
lib.logger.info (las, 'Caught error %s, %s', str (err), lc)
if ovlp_det < LINDEP_THRESH:
err_str = ('LASSI basis appears to have linear dependencies; '
'double-check your state list.\n'
'|ovlp| = {:.6e}').format (ovlp_det)
raise RuntimeError (err_str) from e
else: raise (e) from None
x = canonical_orth_(ovlp_blk, thr=LINDEP_THRESH)
xhx = x.conj ().T @ ham_blk @ x
e, c = linalg.eigh (xhx)
c = x @ c
else: raise (err) from None
return e, c, s2_blk

def make_stdm12s (las, ci=None, orbsym=None, soc=False, break_symmetry=False, opt=1):
Expand Down

0 comments on commit ec640ad

Please sign in to comment.