Skip to content

Commit 0e467e8

Browse files
sunqmbabbush
authored andcommitted
OpenFermion issue #451 (#42)
* 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
1 parent 2093129 commit 0e467e8

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

openfermionpyscf/_pyscf_molecular_data.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from functools import reduce
1717
from pyscf import ao2mo
1818
from pyscf import scf
19+
from pyscf.cc.addons import spatial2spin
1920
from openfermion.hamiltonians import MolecularData
2021

2122

@@ -249,36 +250,36 @@ def fci_two_rdm(self):
249250

250251
@property
251252
def ccsd_single_amps(self):
252-
r"""A 2-dimension array t[a,i] for RCCSD single excitation amplitudes
253+
r"""A 2-dimension array t[a,i] for CCSD single excitation amplitudes
253254
where a is virtual index and i is occupied index.
254255
"""
255256
if self._ccsd_single_amps is None:
256257
ccsd = self._pyscf_data.get('ccsd', None)
257258
if ccsd is None:
258259
return None
259260

260-
mf = self._pyscf_data.get('scf', None)
261-
if isinstance(mf, (scf.rohf.ROHF, scf.uhf.UHF)):
262-
#raise ValueError('UCCSD t1 amplitudes not available.')
263-
return None
261+
t1 = spatial2spin(ccsd.t1)
262+
no, nv = t1.shape
263+
nmo = no + nv
264+
self._ccsd_single_amps = numpy.zeros((nmo, nmo))
265+
self._ccsd_single_amps[no:,:no] = t1.T
264266

265-
self._ccsd_single_amps = ccsd.t1.T
266267
return self._ccsd_single_amps
267268

268269
@property
269270
def ccsd_double_amps(self):
270-
r"""A 4-dimension array t[a,b,i,j] for RCCSD double excitation amplitudes
271+
r"""A 4-dimension array t[a,i,b,j] for CCSD double excitation amplitudes
271272
where a, b are virtual indices and i, j are occupied indices.
272273
"""
273274
if self._ccsd_double_amps is None:
274275
ccsd = self._pyscf_data.get('ccsd', None)
275276
if ccsd is None:
276277
return None
277278

278-
mf = self._pyscf_data.get('scf', None)
279-
if isinstance(mf, (scf.rohf.ROHF, scf.uhf.UHF)):
280-
#raise ValueError('UCCSD t2 amplitudes not available.')
281-
return None
279+
t2 = spatial2spin(ccsd.t2)
280+
no, nv = t2.shape[1:3]
281+
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)
282284

283-
self._ccsd_double_amps = ccsd.t2.transpose(2, 3, 0, 1)
284285
return self._ccsd_double_amps

0 commit comments

Comments
 (0)