Skip to content

Commit

Permalink
Merge branch 'dev' into lassis_excitation_2step
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewRHermes committed Dec 9, 2024
2 parents 3ba5734 + 18b0932 commit 84d6491
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions my_pyscf/lassi/excitations.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,11 @@ def truncrot_ham_pq (self, ham_pq, u, vh):
p = np.prod (lroots)
nstates = ham_pq.shape[1]
h_pr = ham_pq[:p,:].reshape (lroots[1],lroots[0],nstates)
h_pr = np.dot (uh, np.dot (vh, h_pr)).reshape (nroots*nroots,nstates)
h_pr = np.dot (uh, np.dot (vh, h_pr)).reshape (u.shape[1]*v.shape[1],nstates)
ham_pq = np.append (h_pr, ham_pq[p:,:], axis=0)
nstates = ham_pq.shape[0]
h_rp = ham_pq[:,:p].reshape (nstates,lroots[1],lroots[0])
h_rp = lib.einsum ('rij,ia,jb->rab', h_rp, u, v).reshape (nstates,nroots*nroots)
h_rp = lib.einsum ('rij,ia,jb->rab', h_rp, u, v).reshape (nstates,u.shape[1]*v.shape[1])
ham_pq = np.append (h_rp, ham_pq[:,p:], axis=1)
return ham_pq

Expand Down
25 changes: 23 additions & 2 deletions my_pyscf/lassi/min_2frag_tps.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,35 @@ def quadratic_step (ham_pq, ci1, si_p, si_q):
kappa_u[nroots:,:nroots] = x[:nelu].reshape (
lroots[1]-nroots, nroots)
kappa_u -= kappa_u.T
u = linalg.expm (kappa_u)[:,:nroots]
u = linalg.expm (-kappa_u/2)[:,:nroots]
kappa_v = np.zeros ((lroots[0],lroots[0]), dtype=x.dtype)
kappa_v[nroots:,:nroots] = x[:nelv].reshape (
lroots[0]-nroots, nroots)
kappa_v -= kappa_v.T
vh = linalg.expm (kappa_v)[:,:nroots].conj ().T
vh = linalg.expm (-kappa_v/2)[:,:nroots].conj ().T
return u, vh

def idx_down_ham_pq (ham_pq, lroots, nroots):
p = np.prod (lroots)
q = ham_pq.shape[0] - p
h_pr = ham_pq[:p,:].reshape (lroots[1],lroots[0],p+q)
h_pr = h_pr[:nroots,:nroots,:].reshape (nroots*nroots,p+q)
ham_pq = np.append (h_pr, ham_pq[p:,:], axis=0)
h_rp = ham_pq[:,:p].reshape (nroots*nroots+q,lroots[1],lroots[0])
h_rp = h_rp[:,:nroots,:nroots].reshape (nroots*nroots+q,nroots*nroots)
ham_pq = np.append (h_rp, ham_pq[:,p:], axis=1)
return ham_pq

def subspace_eig (ham_pq, lroots, nroots):
p = np.prod (lroots)
q = ham_pq.shape[0] - p
p0 = nroots*nroots
evals, evecs = linalg.eigh (idx_down_ham_pq (ham_pq, lroots, nroots))
si_p = np.zeros ((lroots[1],lroots[0],p0+q), dtype=evecs.dtype)
si_p[:nroots,:nroots,:] = evecs[:p0,:].reshape (nroots,nroots,p0+q)
si = np.append (si_p.reshape (p,p0+q), evecs[p0:,:], axis=0)
return evals, si




Expand Down

0 comments on commit 84d6491

Please sign in to comment.