Skip to content

Commit

Permalink
More complete logging in LASSIS
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewRHermes committed Mar 26, 2024
1 parent 433b43d commit 6d13c64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
30 changes: 14 additions & 16 deletions my_pyscf/lassi/lassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,7 @@ def single_excitations_ci (lsi, las2, las1, ncharge=1, sa_heff=True, deactivate_
converged = True
log.info ("LASSIS electron hop spaces: %d-%d", las1.nroots, las2.nroots-1)
for i in range (las1.nroots, las2.nroots):
# spin shuffle escape
i_ssref = None
for i0 in range (las1.nroots, i):
if spaces[i].is_spin_shuffle_of (spaces[i0]):
i_ssref = i0
break
if i_ssref is not None:
spaces[i].ci = spaces[i].get_spin_shuffle_civecs (spaces[i_ssref])
log.info ("Electron hop space %d:", i)
spaces[i].table_printlog ()
log.info ("is a spin shuffle of space %d", i_ssref)
for k in range (nfrags):
ci[k][i] = spaces[i].ci[k]
t0 = log.timer ("Space {} excitations".format (i), *t0)
continue
# end spin shuffle escape
# compute lroots
psref_ix = [j for j, space in enumerate (spaces[:las1.nroots])
if spaces[i].is_single_excitation_of (space)]
psref = [spaces[j] for j in psref_ix]
Expand All @@ -133,6 +118,19 @@ def single_excitations_ci (lsi, las2, las1, ncharge=1, sa_heff=True, deactivate_
for space in psref[nref_pure:]:
space.table_printlog ()
log.info ('by %s', spaces[i].single_excitation_description_string (space))
# spin shuffle escape
i_ssref = None
for i0 in range (las1.nroots, i):
if spaces[i].is_spin_shuffle_of (spaces[i0]):
i_ssref = i0
break
if i_ssref is not None:
spaces[i].ci = spaces[i].get_spin_shuffle_civecs (spaces[i_ssref])
log.info ("and is a spin shuffle of space %d", i_ssref)
for k in range (nfrags):
ci[k][i] = spaces[i].ci[k]
t0 = log.timer ("Space {} excitations".format (i), *t0)
continue
# throat-clearing into ExcitationPSFCISolver
ciref = [[] for j in range (nfrags)]
for k in range (nfrags):
Expand Down
20 changes: 10 additions & 10 deletions my_pyscf/lassi/states.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,24 +229,24 @@ def describe_single_excitation (self, other):
e_spin = 'a' if np.any (self.neleca!=other.neleca) else 'b'
src_ds = 'u' if self.smults[src_frag]>other.smults[src_frag] else 'd'
dest_ds = 'u' if self.smults[dest_frag]>other.smults[dest_frag] else 'd'
return src_frag, dest_frag, e_spin, src_ds, dest_ds
if e_spin == 'a':
nelec, nhole = other.neleca, other.nholea
else:
nelec, nhole = other.nelecb, other.nholeb
lroots_s = min (nelec[src_frag], nhole[dest_frag])
return src_frag, dest_frag, e_spin, src_ds, dest_ds, lroots_s

def single_excitation_description_string (self, other):
src, dest, e_spin, src_ds, dest_ds = self.describe_single_excitation (other)
fmt_str = '{:d}({:s}) --{:s}--> {:d}({:s})'
return fmt_str.format (src, src_ds, e_spin, dest, dest_ds)
src, dest, e_spin, src_ds, dest_ds, lroots_s = self.describe_single_excitation (other)
fmt_str = '{:d}({:s}) --{:s}--> {:d}({:s}) ({:d} lroots)'
return fmt_str.format (src, src_ds, e_spin, dest, dest_ds, lroots_s)

def compute_single_excitation_lroots (self, ref):
if isinstance (ref, (list, tuple)):
lroots = np.array ([self.compute_single_excitation_lroots (r) for r in ref])
return np.amax (lroots)
assert (self.is_single_excitation_of (ref))
src, dest, e_spin = self.describe_single_excitation (ref)[:3]
if e_spin == 'a':
nelec, nhole = ref.neleca, ref.nholea
else:
nelec, nhole = ref.nelecb, ref.nholeb
return min (nelec[src], nhole[dest])
return self.describe_single_excitation (ref)[5]

def is_spin_shuffle_of (self, other):
if np.any (self.nelec != other.nelec): return False
Expand Down

0 comments on commit 6d13c64

Please sign in to comment.