Skip to content

Commit

Permalink
Filter duplicate spaces in lassis
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewRHermes committed Oct 16, 2023
1 parent 67fe3dc commit 1fedc6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion my_pyscf/lassi/excitations.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ def test_locmin (self, e0, ci, norb, nelec, h0e, h1e, h2e, warntag='Apparent loc
return False
def solve_e0 (self, h0e, h1e, h2e, norb, nelec, ket):
# TODO: figure out how to modify this for p>1
log = lib.logger.new_logger (self, self.verbose)
hket_p = self.undressed_contract_2e (self.absorb_h1e (h1e, h2e, norb, nelec, 0.5),
ket, norb, nelec)
e_p = np.dot (np.ravel (ket), np.ravel (hket_p)) + h0e
Expand All @@ -588,6 +589,8 @@ def solve_e0 (self, h0e, h1e, h2e, norb, nelec, ket):
ham_pq = np.diag (e_pq)
ham_pq[0,1:] = v_q
ham_pq[1:,0] = v_q
log.debug2 ('v_q = {}'.format (v_q))
log.debug2 ('e_pq = {}'.format (e_pq))
e0 = lowest_refovlp_eigval (ham_pq)
return e0
def kernel (self, h1e, h2e, norb, nelec, ecore=0, ci0=None, orbsym=None, **kwargs):
Expand Down Expand Up @@ -630,7 +633,7 @@ def kernel (self, h1e, h2e, norb, nelec, ecore=0, ci0=None, orbsym=None, **kwarg
converged = True
break
self.test_locmin (e0, ci1, norb, nelec, ecore, h1e, h2e)
self.converged = (converged and self.converged)
self.converged = (converged and np.all (self.converged))
#print (lib.fp (ci1), self.denom_q)#np.stack ([ci1[0].ravel (), ci1[1].ravel ()], axis=-1))
return e, ci1
# I don't feel like futzing around with MRO
Expand Down
5 changes: 4 additions & 1 deletion my_pyscf/lassi/lassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def cisolve (sm):
log.info ("LASSIS fragment %d spin down (%de,%do;2S+1=%d)",
ifrag, nelec, norb, smult-2)
smults1_i.extend ([smult-2,]*(smult-2))
spins1_i.extend (list (range (smult-1, -(smult-1)-1, -2)))
spins1_i.extend (list (range (smult-3, -(smult-3)-1, -2)))
ci1_i.extend (cisolve (smult-2))
min_npair = max (0, nelec-norb)
max_smult = (nelec - 2*min_npair) + 1
Expand Down Expand Up @@ -233,6 +233,9 @@ def _spin_halfexcitation_products (spaces, spin_halfexcs, nroots_ref=1, frozen_f
# Filter by smult orthogonality
spaces = [space for space in spaces
if (not (all (space.is_orthogonal_by_smult (spaces_ref))))]
seen = set ()
# Filter duplicates!
spaces = [space for space in spaces if not ((space in seen) or seen.add (space))]
return spaces

def spin_halfexcitation_products (las2, spin_halfexcs, nroots_ref=1):
Expand Down

0 comments on commit 1fedc6e

Please sign in to comment.