Skip to content

Commit def0d1c

Browse files
sunqmbabbush
authored andcommitted
scale ccsd t2 amplitudes for issue #43 (#44)
* Update psycf interface * Efficient integral transformation function * Fixed n_orbitals * Extending MolecularData to hold pyscf objects * Bugfix for index convention of eri and 2-pdm * Renamed _molecular_data module and MolecularData class * Removing the DEBUG flag * Updated installation requirements and tests * Updated Author lists * More sanity checks in pyscf_molecular_data * Fix error in PySCFMolecularData.__init__ * Temporarily removed dependence to pyscf in requirements.txt * Name convention of test files. * Updated Author list * A pyscf-1.4.3 compatibility issue * Added travis (for issue #28) * Fix import error (issue #40) * Fix ccsd amps for OpenFermion issue #451 * typo in PR #42 * scale ccsd t2 amplitudes by 0.5 (issue #43) * Update ccsd amps tests
1 parent 0e467e8 commit def0d1c

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

openfermionpyscf/_pyscf_molecular_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def ccsd_double_amps(self):
279279
t2 = spatial2spin(ccsd.t2)
280280
no, nv = t2.shape[1:3]
281281
nmo = no + nv
282-
self._ccsd_single_amps = numpy.zeros((nmo, nmo, nmo, nmo))
283-
self._ccsd_single_amps[no:,:no,no:,:no] = t2.transpose(2,0,3,1)
282+
self._ccsd_double_amps = numpy.zeros((nmo, nmo, nmo, nmo))
283+
self._ccsd_double_amps[no:,:no,no:,:no] = .5 * t2.transpose(2,0,3,1)
284284

285285
return self._ccsd_double_amps

openfermionpyscf/tests/_pyscf_molecular_data_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,26 @@ def test_accessing_rdm():
6868
numpy.einsum('pqrs,pqrs', h2, rdm2) * .5 + e_core)
6969
numpy.testing.assert_almost_equal(e_tot, -1.1516827321, 9)
7070

71+
def test_ccsd_amps():
72+
mo = molecule.canonical_orbitals
73+
h2 = molecule.two_body_integrals
74+
mf = molecule._pyscf_data['scf']
75+
7176
ccsd_t1 = molecule.ccsd_single_amps
7277
ccsd_t2 = molecule.ccsd_double_amps
7378

79+
nmo = mo.shape[1]
80+
g_fock = numpy.zeros((nmo*2,nmo*2))
81+
g_fock[::2,::2] = g_fock[1::2,1::2] = mo.T.dot(mf.get_fock()).dot(mo)
82+
g_h2 = numpy.zeros((nmo*2,nmo*2,nmo*2,nmo*2))
83+
g_h2[ ::2, ::2, ::2, ::2] = h2
84+
g_h2[1::2,1::2, ::2, ::2] = h2
85+
g_h2[ ::2, ::2,1::2,1::2] = h2
86+
g_h2[1::2,1::2,1::2,1::2] = h2
87+
g_h2 = g_h2 - g_h2.transpose(0,3,2,1)
7488

89+
e_corr_ref = molecule._pyscf_data['ccsd'].e_corr
90+
e_corr = (numpy.einsum('ij,ji->', g_fock, ccsd_t1)
91+
+ .5 * numpy.einsum('ijkl,jilk->', g_h2, ccsd_t2)
92+
+ .5 * numpy.einsum('ijkl,ji,lk->', g_h2, ccsd_t1, ccsd_t1))
93+
numpy.testing.assert_almost_equal(e_corr_ref, e_corr, 9)

0 commit comments

Comments
 (0)