Skip to content

Commit

Permalink
Hessian_CC in newton_casscf (issue pyscf#731)
Browse files Browse the repository at this point in the history
Hessian-vector product should have zero overlap w/ keyframe CI
vector at all times. Remove factors of 2 which spoiled this.
  • Loading branch information
MatthewRHermes committed Sep 15, 2023
1 parent 4c0998d commit 1babe6f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pyscf/fci/rdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def make_rdm1_spin1(fname, cibra, ciket, norb, nelec, link_index=None):
link_indexa, link_indexb = link_index
na,nlinka = link_indexa.shape[:2]
nb,nlinkb = link_indexb.shape[:2]
assert (cibra.size == na*nb)
assert (ciket.size == na*nb)
assert (cibra.size == na*nb), '{} {} {}'.format (cibra.size, na, nb)
assert (ciket.size == na*nb), '{} {} {}'.format (ciket.size, na, nb)
rdm1 = numpy.empty((norb,norb))
fn = getattr(librdm, fname)
fn(rdm1.ctypes.data_as(ctypes.c_void_p),
Expand Down
8 changes: 5 additions & 3 deletions pyscf/mcscf/newton_casscf.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ def g_update(u, fcivec):
# h_diag[ncore:nocc,ncore:nocc] -= v_diag[:,ncore:nocc]*2
h_diag = casscf.pack_uniq_var(h_diag)

hci_diag = [hd - ec - gc*c*4 for hd, ec, gc, c in zip (_Hdiag (h1cas_0, eri_cas), eci0, gci, ci0)]
# Fix intermediate normalization? - MRH 2023/09/15
hci_diag = [hd - ec - gc*c*2 for hd, ec, gc, c in zip (_Hdiag (h1cas_0, eri_cas), eci0, gci, ci0)]
hci_diag = [h * w for h, w in zip (hci_diag, weights)]
hdiag_all = numpy.hstack((h_diag*2, _pack_ci (hci_diag)*2))

Expand All @@ -308,9 +309,10 @@ def h_op(x):
ci1 = _unpack_ci (x[ngorb:])

# H_cc
# Fix intermediate normalization? - MRH 2023/09/15
hci1 = [hc1 - c1 * ec0 for hc1, c1, ec0 in zip (_Hci (h1cas_0, eri_cas, ci1), ci1, eci0)]
hci1 = [hc1 - 2*(hc0 - c0*ec0)*c0.dot(c1) for hc1, hc0, c0, ec0, c1 in zip (hci1, hci0, ci0, eci0, ci1)]
hci1 = [hc1 - 2*c0*(hc0 - c0*ec0).dot(c1) for hc1, hc0, c0, ec0, c1 in zip (hci1, hci0, ci0, eci0, ci1)]
hci1 = [hc1 - (hc0 - c0*ec0)*c0.dot(c1) for hc1, hc0, c0, ec0, c1 in zip (hci1, hci0, ci0, eci0, ci1)]
hci1 = [hc1 - c0*(hc0 - c0*ec0).dot(c1) for hc1, hc0, c0, ec0, c1 in zip (hci1, hci0, ci0, eci0, ci1)]

# H_co
rc = x1[:,:ncore]
Expand Down

0 comments on commit 1babe6f

Please sign in to comment.