pyscf 2.7.0__py3-none-macosx_11_0_arm64.whl → 2.9.0__py3-none-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. pyscf/__init__.py +1 -1
  2. pyscf/ao2mo/__init__.py +13 -2
  3. pyscf/ao2mo/_ao2mo.py +10 -1
  4. pyscf/ao2mo/incore.py +3 -0
  5. pyscf/ao2mo/nrr_outcore.py +2 -2
  6. pyscf/ao2mo/outcore.py +3 -3
  7. pyscf/ao2mo/r_outcore.py +2 -2
  8. pyscf/cc/__init__.py +2 -3
  9. pyscf/cc/ccsd.py +13 -5
  10. pyscf/cc/ccsd_rdm.py +6 -1
  11. pyscf/cc/dfccsd.py +3 -3
  12. pyscf/cc/dfuccsd.py +310 -0
  13. pyscf/cc/gccsd.py +2 -2
  14. pyscf/cc/rccsd.py +5 -1
  15. pyscf/cc/uccsd.py +36 -27
  16. pyscf/cc/uccsd_rdm.py +2 -2
  17. pyscf/df/addons.py +8 -3
  18. pyscf/df/autoaux.py +4 -0
  19. pyscf/df/df_jk.py +56 -25
  20. pyscf/df/grad/rhf.py +31 -1
  21. pyscf/df/hessian/uhf.py +2 -2
  22. pyscf/df/incore.py +2 -2
  23. pyscf/df/outcore.py +6 -6
  24. pyscf/dft/gks.py +25 -21
  25. pyscf/dft/libxc.py +31 -11
  26. pyscf/dft/numint.py +33 -16
  27. pyscf/dft/radi.py +9 -2
  28. pyscf/dft/rks.py +28 -24
  29. pyscf/dft/roks.py +7 -1
  30. pyscf/dft/uks.py +34 -25
  31. pyscf/fci/direct_spin1.py +0 -1
  32. pyscf/fci/fci_dhf_slow.py +15 -1
  33. pyscf/grad/ccsd.py +3 -7
  34. pyscf/grad/ccsd_slow.py +2 -3
  35. pyscf/grad/mp2.py +12 -3
  36. pyscf/grad/sacasscf.py +2 -0
  37. pyscf/grad/uccsd.py +3 -7
  38. pyscf/grad/ump2.py +2 -4
  39. pyscf/gto/basis/__init__.py +32 -5
  40. pyscf/gto/basis/def2-mtzvp.dat +4719 -0
  41. pyscf/gto/basis/def2-mtzvpp.dat +4739 -0
  42. pyscf/gto/basis/dyall-basis/__init__.py +0 -0
  43. pyscf/gto/basis/dyall-basis/dyall_2zp.py +6492 -0
  44. pyscf/gto/basis/dyall-basis/dyall_3zp.py +8343 -0
  45. pyscf/gto/basis/dyall-basis/dyall_4zp.py +10055 -0
  46. pyscf/gto/basis/dyall-basis/dyall_aae2z.py +1818 -0
  47. pyscf/gto/basis/dyall-basis/dyall_aae3z.py +2521 -0
  48. pyscf/gto/basis/dyall-basis/dyall_aae4z.py +3351 -0
  49. pyscf/gto/basis/dyall-basis/dyall_acv2z.py +1790 -0
  50. pyscf/gto/basis/dyall-basis/dyall_acv3z.py +2417 -0
  51. pyscf/gto/basis/dyall-basis/dyall_acv4z.py +3085 -0
  52. pyscf/gto/basis/dyall-basis/dyall_ae2z.py +6619 -0
  53. pyscf/gto/basis/dyall-basis/dyall_ae3z.py +9027 -0
  54. pyscf/gto/basis/dyall-basis/dyall_ae4z.py +11839 -0
  55. pyscf/gto/basis/dyall-basis/dyall_av2z.py +1742 -0
  56. pyscf/gto/basis/dyall-basis/dyall_av3z.py +2318 -0
  57. pyscf/gto/basis/dyall-basis/dyall_av4z.py +2905 -0
  58. pyscf/gto/basis/dyall-basis/dyall_cv2z.py +6558 -0
  59. pyscf/gto/basis/dyall-basis/dyall_cv3z.py +8767 -0
  60. pyscf/gto/basis/dyall-basis/dyall_cv4z.py +11098 -0
  61. pyscf/gto/basis/dyall-basis/dyall_v2z.py +6472 -0
  62. pyscf/gto/basis/dyall-basis/dyall_v3z.py +8539 -0
  63. pyscf/gto/basis/dyall-basis/dyall_v4z.py +10658 -0
  64. pyscf/gto/basis/ma-def2-qzvp.dat +5959 -0
  65. pyscf/gto/basis/ma-def2-qzvpp.dat +6195 -0
  66. pyscf/gto/basis/ma-def2-svp.dat +3504 -0
  67. pyscf/gto/basis/ma-def2-svpp.dat +3504 -0
  68. pyscf/gto/basis/ma-def2-tzvp.dat +4347 -0
  69. pyscf/gto/basis/ma-def2-tzvpp.dat +4549 -0
  70. pyscf/gto/basis/parse_cp2k.py +8 -7
  71. pyscf/gto/basis/parse_nwchem.py +25 -10
  72. pyscf/gto/eval_gto.py +1 -1
  73. pyscf/gto/ft_ao.py +6 -6
  74. pyscf/gto/mole.py +32 -35
  75. pyscf/gto/moleintor.py +26 -1
  76. pyscf/gw/rpa.py +133 -244
  77. pyscf/gw/urpa.py +84 -131
  78. pyscf/hessian/uks.py +1 -1
  79. pyscf/lib/CMakeLists.txt +8 -4
  80. pyscf/lib/config.h +0 -1
  81. pyscf/lib/config.h.in +0 -1
  82. pyscf/lib/deps/include/xc.h +28 -18
  83. pyscf/lib/deps/include/xc_funcs.h +50 -2
  84. pyscf/lib/deps/include/xc_version.h +3 -3
  85. pyscf/lib/deps/lib/libcint.6.dylib +0 -0
  86. pyscf/lib/deps/lib/{libxc.12.dylib → libxc.15.dylib} +0 -0
  87. pyscf/lib/deps/lib/libxcfun.2.dylib +0 -0
  88. pyscf/lib/dft/libxc_itrf.c +25 -21
  89. pyscf/lib/dft/nr_numint_sparse.c +3 -3
  90. pyscf/lib/diis.py +1 -1
  91. pyscf/lib/exceptions.py +3 -0
  92. pyscf/lib/libagf2.dylib +0 -0
  93. pyscf/lib/libao2mo.dylib +0 -0
  94. pyscf/lib/libcc.dylib +0 -0
  95. pyscf/lib/libcgto.dylib +0 -0
  96. pyscf/lib/libcvhf.dylib +0 -0
  97. pyscf/lib/libdft.dylib +0 -0
  98. pyscf/lib/libfci.dylib +0 -0
  99. pyscf/lib/libmcscf.dylib +0 -0
  100. pyscf/lib/libmp.dylib +0 -0
  101. pyscf/lib/libnp_helper.dylib +0 -0
  102. pyscf/lib/libpbc.dylib +0 -0
  103. pyscf/lib/libri.dylib +0 -0
  104. pyscf/lib/libxc_itrf.dylib +0 -0
  105. pyscf/lib/libxcfun_itrf.dylib +0 -0
  106. pyscf/lib/linalg_helper.py +5 -6
  107. pyscf/lib/logger.py +2 -1
  108. pyscf/lib/mcscf/fci_contract.c +8 -1
  109. pyscf/lib/misc.py +16 -8
  110. pyscf/lib/mp/CMakeLists.txt +22 -0
  111. pyscf/lib/mp/mp2.c +518 -0
  112. pyscf/lib/mp/mp2.h +44 -0
  113. pyscf/lib/np_helper/CMakeLists.txt +1 -1
  114. pyscf/lib/np_helper/imatcopy.c +360 -0
  115. pyscf/lib/np_helper/np_helper.c +94 -0
  116. pyscf/lib/np_helper/np_helper.h +26 -0
  117. pyscf/lib/numpy_helper.py +194 -10
  118. pyscf/lib/pbc/nr_direct.c +2 -7
  119. pyscf/lib/vhf/fblas.h +3 -0
  120. pyscf/lib/vhf/nr_sr_vhf.c +8 -12
  121. pyscf/lib/vhf/rkb_screen.c +139 -0
  122. pyscf/mcscf/__init__.py +1 -1
  123. pyscf/mcscf/casci.py +7 -3
  124. pyscf/mcscf/chkfile.py +2 -3
  125. pyscf/mcscf/mc1step.py +12 -8
  126. pyscf/mcscf/newton_casscf.py +1 -1
  127. pyscf/mcscf/umc1step.py +5 -3
  128. pyscf/mp/__init__.py +2 -2
  129. pyscf/mp/dfmp2.py +498 -59
  130. pyscf/mp/dfmp2_native.py +11 -1
  131. pyscf/mp/dfmp2_slow.py +133 -0
  132. pyscf/mp/dfump2.py +672 -0
  133. pyscf/mp/dfump2_native.py +9 -0
  134. pyscf/mp/dfump2_slow.py +161 -0
  135. pyscf/mp/gmp2.py +6 -47
  136. pyscf/mp/mp2.py +19 -5
  137. pyscf/mp/ump2.py +23 -18
  138. pyscf/mrpt/nevpt2.py +11 -0
  139. pyscf/pbc/df/aft.py +9 -7
  140. pyscf/pbc/df/df.py +5 -6
  141. pyscf/pbc/df/df_jk.py +12 -6
  142. pyscf/pbc/df/fft.py +3 -3
  143. pyscf/pbc/df/fft_jk.py +7 -7
  144. pyscf/pbc/df/incore.py +1 -1
  145. pyscf/pbc/df/mdf_jk.py +2 -1
  146. pyscf/pbc/df/outcore.py +10 -10
  147. pyscf/pbc/df/rsdf.py +1 -0
  148. pyscf/pbc/df/rsdf_builder.py +3 -3
  149. pyscf/pbc/df/rsdf_helper.py +5 -5
  150. pyscf/pbc/df/rsdf_jk.py +2 -1
  151. pyscf/pbc/dft/gen_grid.py +3 -2
  152. pyscf/pbc/dft/gks.py +14 -3
  153. pyscf/pbc/dft/kgks.py +15 -4
  154. pyscf/pbc/dft/krks.py +28 -10
  155. pyscf/pbc/dft/krks_ksymm.py +21 -9
  156. pyscf/pbc/dft/krkspu.py +1 -30
  157. pyscf/pbc/dft/krkspu_ksymm.py +0 -30
  158. pyscf/pbc/dft/kuks.py +30 -13
  159. pyscf/pbc/dft/kuks_ksymm.py +22 -10
  160. pyscf/pbc/dft/kukspu.py +0 -27
  161. pyscf/pbc/dft/kukspu_ksymm.py +0 -30
  162. pyscf/pbc/dft/multigrid/multigrid.py +17 -7
  163. pyscf/pbc/dft/multigrid/multigrid_pair.py +6 -1
  164. pyscf/pbc/dft/numint.py +26 -10
  165. pyscf/pbc/dft/rks.py +20 -26
  166. pyscf/pbc/dft/uks.py +21 -4
  167. pyscf/pbc/gto/_pbcintor.py +1 -0
  168. pyscf/pbc/gto/cell.py +170 -5
  169. pyscf/pbc/gto/eval_gto.py +1 -1
  170. pyscf/pbc/gto/neighborlist.py +4 -1
  171. pyscf/pbc/mpitools/mpi.py +0 -1
  172. pyscf/pbc/scf/_response_functions.py +141 -34
  173. pyscf/pbc/scf/hf.py +13 -10
  174. pyscf/pbc/scf/khf.py +32 -3
  175. pyscf/pbc/scf/khf_ksymm.py +15 -1
  176. pyscf/pbc/scf/kuhf.py +1 -1
  177. pyscf/pbc/scf/kuhf_ksymm.py +1 -1
  178. pyscf/pbc/scf/rsjk.py +1 -1
  179. pyscf/pbc/scf/stability.py +26 -14
  180. pyscf/pbc/tdscf/krhf.py +58 -56
  181. pyscf/pbc/tdscf/kuhf.py +273 -78
  182. pyscf/pbc/tdscf/rhf.py +17 -12
  183. pyscf/pbc/tdscf/uhf.py +46 -35
  184. pyscf/pbc/tools/k2gamma.py +15 -3
  185. pyscf/pbc/tools/lattice.py +3 -3
  186. pyscf/pbc/tools/pbc.py +48 -35
  187. pyscf/pbc/x2c/sfx2c1e.py +5 -0
  188. pyscf/scf/_response_functions.py +85 -44
  189. pyscf/scf/_vhf.py +1 -0
  190. pyscf/scf/addons.py +21 -2
  191. pyscf/scf/dhf.py +82 -28
  192. pyscf/scf/dispersion.py +1 -1
  193. pyscf/scf/hf.py +19 -3
  194. pyscf/scf/uhf.py +9 -3
  195. pyscf/solvent/__init__.py +2 -2
  196. pyscf/solvent/_attach_solvent.py +2 -0
  197. pyscf/solvent/cosmors.py +378 -0
  198. pyscf/solvent/grad/pcm.py +75 -19
  199. pyscf/solvent/hessian/pcm.py +957 -108
  200. pyscf/solvent/hessian/smd.py +7 -43
  201. pyscf/solvent/pcm.py +4 -4
  202. pyscf/solvent/smd.py +5 -3
  203. pyscf/soscf/ciah.py +2 -10
  204. pyscf/soscf/newton_ah.py +4 -1
  205. pyscf/symm/geom.py +58 -13
  206. pyscf/tdscf/_lr_eig.py +561 -57
  207. pyscf/tdscf/dhf.py +58 -65
  208. pyscf/tdscf/ghf.py +63 -71
  209. pyscf/tdscf/gks.py +12 -10
  210. pyscf/tdscf/rhf.py +68 -68
  211. pyscf/tdscf/rks.py +12 -9
  212. pyscf/tdscf/uhf.py +59 -58
  213. pyscf/tdscf/uks.py +15 -13
  214. pyscf/tools/fcidump.py +36 -9
  215. pyscf/tools/finite_diff.py +175 -0
  216. pyscf/tools/qcschema.py +265 -0
  217. pyscf/x2c/tdscf.py +37 -37
  218. pyscf/x2c/x2c.py +101 -34
  219. {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/METADATA +30 -26
  220. {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/RECORD +224 -192
  221. {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/WHEEL +2 -1
  222. {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info/licenses}/NOTICE +13 -0
  223. pyscf/pbc/tdscf/kproxy.py +0 -189
  224. pyscf/pbc/tdscf/kproxy_supercell.py +0 -664
  225. pyscf/pbc/tdscf/krhf_slow.py +0 -300
  226. pyscf/pbc/tdscf/krhf_slow_gamma.py +0 -175
  227. pyscf/pbc/tdscf/krhf_slow_supercell.py +0 -250
  228. pyscf/pbc/tdscf/proxy.py +0 -39
  229. pyscf/pbc/tdscf/rhf_slow.py +0 -35
  230. pyscf/tdscf/common_slow.py +0 -799
  231. pyscf/tdscf/proxy.py +0 -258
  232. pyscf/tdscf/rhf_slow.py +0 -181
  233. {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info/licenses}/LICENSE +0 -0
  234. {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/top_level.txt +0 -0
pyscf/__init__.py CHANGED
@@ -35,7 +35,7 @@ to try out the package::
35
35
 
36
36
  '''
37
37
 
38
- __version__ = '2.7.0'
38
+ __version__ = '2.9.0'
39
39
 
40
40
  import os
41
41
  import sys
pyscf/ao2mo/__init__.py CHANGED
@@ -31,6 +31,7 @@ Simple usage::
31
31
  import tempfile
32
32
  import numpy
33
33
  import h5py
34
+ from pyscf import gto
34
35
  from pyscf.ao2mo import incore
35
36
  from pyscf.ao2mo import outcore
36
37
  from pyscf.ao2mo import r_outcore
@@ -143,7 +144,7 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e',
143
144
  '''
144
145
  if isinstance(eri_or_mol, numpy.ndarray):
145
146
  return incore.full(eri_or_mol, mo_coeff, *args, **kwargs)
146
- else:
147
+ elif isinstance(eri_or_mol, gto.MoleBase):
147
148
  if '_spinor' in intor:
148
149
  mod = r_outcore
149
150
  else:
@@ -157,6 +158,11 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e',
157
158
  *args, **kwargs)
158
159
  else:
159
160
  return mod.full_iofree(eri_or_mol, mo_coeff, intor, *args, **kwargs)
161
+ else:
162
+ raise RuntimeError('ERI is not available. If this is generated by mf._eri, '
163
+ 'the integral tensor is too big to store in memory. '
164
+ 'You should either increase mol.max_memory, or set '
165
+ 'mol.incore_anyway. See issue #2473.')
160
166
 
161
167
  def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
162
168
  *args, **kwargs):
@@ -293,7 +299,7 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e
293
299
  '''
294
300
  if isinstance(eri_or_mol, numpy.ndarray):
295
301
  return incore.general(eri_or_mol, mo_coeffs, *args, **kwargs)
296
- else:
302
+ elif isinstance(eri_or_mol, gto.MoleBase):
297
303
  if '_spinor' in intor:
298
304
  mod = r_outcore
299
305
  else:
@@ -307,6 +313,11 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e
307
313
  *args, **kwargs)
308
314
  else:
309
315
  return mod.general_iofree(eri_or_mol, mo_coeffs, intor, *args, **kwargs)
316
+ else:
317
+ raise RuntimeError('ERI is not available. If this is generated by mf._eri, '
318
+ 'the integral tensor is too big to store in memory. '
319
+ 'You should either increase mol.max_memory, or set '
320
+ 'mol.incore_anyway. See issue #2473.')
310
321
 
311
322
  def kernel(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
312
323
  *args, **kwargs):
pyscf/ao2mo/_ao2mo.py CHANGED
@@ -73,7 +73,7 @@ def nr_e1fill(intor, sh_range, atm, bas, env,
73
73
  natm = ctypes.c_int(c_atm.shape[0])
74
74
  nbas = ctypes.c_int(c_bas.shape[0])
75
75
  ao_loc = make_loc(bas, intor)
76
- nao = ao_loc[-1]
76
+ nao = int(ao_loc[-1])
77
77
 
78
78
  klsh0, klsh1, nkl = sh_range
79
79
 
@@ -137,6 +137,9 @@ def nr_e1(eri, mo_coeff, orbs_slice, aosym='s1', mosym='s1', out=None):
137
137
  if out.size == 0:
138
138
  return out
139
139
 
140
+ if eri.dtype != numpy.double:
141
+ raise TypeError('_ao2mo.nr_e1 is for double precision only')
142
+
140
143
  fdrv = getattr(libao2mo, 'AO2MOnr_e2_drv')
141
144
  pao_loc = ctypes.POINTER(ctypes.c_void_p)()
142
145
  c_nbas = ctypes.c_int(0)
@@ -184,6 +187,9 @@ def nr_e2(eri, mo_coeff, orbs_slice, aosym='s1', mosym='s1', out=None,
184
187
  if out.size == 0:
185
188
  return out
186
189
 
190
+ if eri.dtype != numpy.double:
191
+ raise TypeError('_ao2mo.nr_e2 is for double precision only')
192
+
187
193
  if ao_loc is None:
188
194
  pao_loc = ctypes.POINTER(ctypes.c_void_p)()
189
195
  c_nbas = ctypes.c_int(0)
@@ -283,6 +289,9 @@ def r_e2(eri, mo_coeff, orbs_slice, tao, ao_loc, aosym='s1', out=None):
283
289
  if out.size == 0:
284
290
  return out
285
291
 
292
+ if eri.dtype != numpy.complex128:
293
+ raise TypeError('_ao2mo.r_e2 is for complex double precision only')
294
+
286
295
  tao = numpy.asarray(tao, dtype=numpy.int32)
287
296
  if ao_loc is None:
288
297
  c_ao_loc = ctypes.POINTER(ctypes.c_void_p)()
pyscf/ao2mo/incore.py CHANGED
@@ -202,6 +202,9 @@ def half_e1(eri_ao, mo_coeffs, compact=True):
202
202
  if nij_pair == 0:
203
203
  return eri1
204
204
 
205
+ if eri_ao.dtype != numpy.double:
206
+ raise TypeError('ao2mo.incore.half_e1 is for double precision only')
207
+
205
208
  if eri_ao.size == nao_pair**2: # 4-fold symmetry
206
209
  # half_e1 first transforms the indices which are contiguous in memory
207
210
  # transpose the 4-fold integrals to make ij the contiguous indices
@@ -380,9 +380,9 @@ def _count_naopair(mol, nao):
380
380
  ao_loc = mol.ao_loc_2c()
381
381
  nao_pair = 0
382
382
  for i in range(mol.nbas):
383
- di = ao_loc[i+1] - ao_loc[i]
383
+ di = int(ao_loc[i+1] - ao_loc[i])
384
384
  for j in range(i+1):
385
- dj = ao_loc[j+1] - ao_loc[j]
385
+ dj = int(ao_loc[j+1] - ao_loc[j])
386
386
  nao_pair += di * dj
387
387
  return nao_pair
388
388
 
pyscf/ao2mo/outcore.py CHANGED
@@ -710,8 +710,8 @@ def guess_shell_ranges(mol, aosym, max_iobuf, max_aobuf=None, ao_loc=None,
710
710
  compress_diag=True):
711
711
  if ao_loc is None: ao_loc = mol.ao_loc_nr()
712
712
  max_iobuf = max(1, max_iobuf)
713
-
714
- dims = ao_loc[1:] - ao_loc[:-1]
713
+ ao_loc_long = ao_loc.astype(numpy.int64)
714
+ dims = ao_loc_long[1:] - ao_loc_long[:-1]
715
715
  dijs = (dims.reshape(-1,1) * dims)
716
716
  nbas = dijs.shape[0]
717
717
 
@@ -773,7 +773,7 @@ def balance_partition(ao_loc, blksize, start_id=0, stop_id=None):
773
773
  displs = [i+start_id for i in displs]
774
774
  tasks = []
775
775
  for i0, i1 in zip(displs[:-1],displs[1:]):
776
- tasks.append((i0, i1, ao_loc[i1]-ao_loc[i0]))
776
+ tasks.append((i0, i1, int(ao_loc[i1]-ao_loc[i0])))
777
777
  return tasks
778
778
 
779
779
  del (MAX_MEMORY)
pyscf/ao2mo/r_outcore.py CHANGED
@@ -302,9 +302,9 @@ def _count_naopair(mol, nao):
302
302
  ao_loc = mol.ao_loc_2c()
303
303
  nao_pair = 0
304
304
  for i in range(mol.nbas):
305
- di = ao_loc[i+1] - ao_loc[i]
305
+ di = int(ao_loc[i+1] - ao_loc[i])
306
306
  for j in range(i+1):
307
- dj = ao_loc[j+1] - ao_loc[j]
307
+ dj = int(ao_loc[j+1] - ao_loc[j])
308
308
  nao_pair += di * dj
309
309
  return nao_pair
310
310
 
pyscf/cc/__init__.py CHANGED
@@ -120,15 +120,14 @@ RCCSD.__doc__ = ccsd.CCSD.__doc__
120
120
 
121
121
  def UCCSD(mf, frozen=None, mo_coeff=None, mo_occ=None):
122
122
  from pyscf.df.df_jk import _DFHF
123
+ from pyscf.cc import dfuccsd
123
124
 
124
125
  mf = mf.remove_soscf()
125
126
  if not mf.istype('UHF'):
126
127
  mf = mf.to_uhf()
127
128
 
128
129
  if isinstance(mf, _DFHF) and mf.with_df:
129
- # TODO: DF-UCCSD with memory-efficient particle-particle ladder,
130
- # similar to dfccsd.RCCSD
131
- return uccsd.UCCSD(mf, frozen, mo_coeff, mo_occ)
130
+ return dfuccsd.UCCSD(mf, frozen, mo_coeff, mo_occ)
132
131
  else:
133
132
  return uccsd.UCCSD(mf, frozen, mo_coeff, mo_occ)
134
133
  UCCSD.__doc__ = uccsd.UCCSD.__doc__
pyscf/cc/ccsd.py CHANGED
@@ -76,10 +76,16 @@ def kernel(mycc, eris=None, t1=None, t2=None, max_cycle=50, tol=1e-8,
76
76
  normt = numpy.linalg.norm(tmpvec)
77
77
  tmpvec = None
78
78
  if mycc.iterative_damping < 1.0:
79
- alpha = mycc.iterative_damping
80
- t1new = (1-alpha) * t1 + alpha * t1new
81
- t2new *= alpha
82
- t2new += (1-alpha) * t2
79
+ alpha = numpy.asarray(mycc.iterative_damping)
80
+ if isinstance(t1, tuple): # e.g. UCCSD
81
+ t1new = tuple((1-alpha) * numpy.asarray(t1_part) + alpha * numpy.asarray(t1new_part)
82
+ for t1_part, t1new_part in zip(t1, t1new))
83
+ t2new = tuple((1-alpha) * numpy.asarray(t2_part) + alpha * numpy.asarray(t2new_part)
84
+ for t2_part, t2new_part in zip(t2, t2new))
85
+ else:
86
+ t1new = (1-alpha) * numpy.asarray(t1) + alpha * numpy.asarray(t1new)
87
+ t2new *= alpha
88
+ t2new += (1-alpha) * numpy.asarray(t2)
83
89
  t1, t2 = t1new, t2new
84
90
  t1new = t2new = None
85
91
  t1, t2 = mycc.run_diis(t1, t2, istep, normt, eccsd-eold, adiis)
@@ -611,6 +617,8 @@ def _contract_s1vvvv_t2(mycc, mol, vvvv, t2, out=None, verbose=None):
611
617
  # vvvv == None means AO-direct CCSD. It should redirect to
612
618
  # _contract_s4vvvv_t2(mycc, mol, vvvv, t2, out, verbose)
613
619
  assert (vvvv is not None)
620
+ if t2.size == 0:
621
+ return numpy.zeros_like(t2)
614
622
 
615
623
  time0 = logger.process_clock(), logger.perf_counter()
616
624
  log = logger.new_logger(mycc, verbose)
@@ -934,7 +942,7 @@ class CCSDBase(lib.StreamObject):
934
942
  'async_io', 'incore_complete', 'cc2', 'callback',
935
943
  'mol', 'verbose', 'stdout', 'frozen', 'level_shift',
936
944
  'mo_coeff', 'mo_occ', 'cycles', 'converged_lambda', 'emp2', 'e_hf',
937
- 'e_corr', 't1', 't2', 'l1', 'l2', 'chkfile',
945
+ 'converged', 'e_corr', 't1', 't2', 'l1', 'l2', 'chkfile',
938
946
  }
939
947
 
940
948
  def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
pyscf/cc/ccsd_rdm.py CHANGED
@@ -377,8 +377,13 @@ def _make_rdm2(mycc, d1, d2, with_dm1=True, with_frozen=True, ao_repr=False):
377
377
 
378
378
 
379
379
  def _rdm2_mo2ao(dm2, mo):
380
+ '''
381
+ Back transform the two-particle density matrices to AO representation, where
382
+ the dm2 is defined in accordance with the chemist's ERI notation:
383
+ E = einsum('pqrs,pqrs', eri, rdm2)
384
+ '''
380
385
  mo_C = mo.conj()
381
- return lib.einsum('ijkl,pi,qj,rk,sl->pqrs', dm2, mo, mo_C, mo, mo_C)
386
+ return lib.einsum('ijkl,pi,qj,rk,sl->pqrs', dm2, mo_C, mo, mo_C, mo)
382
387
 
383
388
 
384
389
  if __name__ == '__main__':
pyscf/cc/dfccsd.py CHANGED
@@ -51,7 +51,7 @@ class RCCSD(ccsd.CCSD):
51
51
  to_gpu = lib.to_gpu
52
52
 
53
53
 
54
- def _contract_vvvv_t2(mycc, mol, vvL, t2, out=None, verbose=None):
54
+ def _contract_vvvv_t2(mycc, mol, vvL, VVL, t2, out=None, verbose=None):
55
55
  '''Ht2 = numpy.einsum('ijcd,acdb->ijab', t2, vvvv)
56
56
 
57
57
  Args:
@@ -103,7 +103,7 @@ def _contract_vvvv_t2(mycc, mol, vvL, t2, out=None, verbose=None):
103
103
  ijL = vvL0[tril2sq[i0:i1,j0:j1] - off0].reshape(-1,naux)
104
104
  eri = numpy.ndarray(((i1-i0)*(j1-j0),nvir_pair), buffer=eribuf)
105
105
  for p0, p1 in lib.prange(0, nvir_pair, vvblk):
106
- vvL1 = _cp(vvL[p0:p1])
106
+ vvL1 = _cp(VVL[p0:p1])
107
107
  eri[:,p0:p1] = lib.ddot(ijL, vvL1.T)
108
108
  vvL1 = None
109
109
 
@@ -120,7 +120,7 @@ def _contract_vvvv_t2(mycc, mol, vvL, t2, out=None, verbose=None):
120
120
  class _ChemistsERIs(ccsd._ChemistsERIs):
121
121
  def _contract_vvvv_t2(self, mycc, t2, direct=False, out=None, verbose=None):
122
122
  assert (not direct)
123
- return _contract_vvvv_t2(mycc, self.mol, self.vvL, t2, out, verbose)
123
+ return _contract_vvvv_t2(mycc, self.mol, self.vvL, self.vvL, t2, out, verbose)
124
124
 
125
125
  def _make_df_eris(cc, mo_coeff=None):
126
126
  assert cc._scf.istype('RHF')
pyscf/cc/dfuccsd.py ADDED
@@ -0,0 +1,310 @@
1
+ #!/usr/bin/env python
2
+ # Copyright 2014-2025 The PySCF Developers. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ import numpy as np
18
+ from pyscf import lib
19
+ from pyscf.lib import logger
20
+ from pyscf import df
21
+ from pyscf.cc import uccsd
22
+ from pyscf.cc import ccsd
23
+ from pyscf.cc import dfccsd
24
+ from pyscf import __config__
25
+
26
+ MEMORYMIN = getattr(__config__, 'cc_ccsd_memorymin', 2000)
27
+
28
+ class UCCSD(uccsd.UCCSD):
29
+ _keys = {'with_df'}
30
+
31
+ def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
32
+ uccsd.UCCSD.__init__(self, mf, frozen, mo_coeff, mo_occ)
33
+ if getattr(mf, 'with_df', None):
34
+ self.with_df = mf.with_df
35
+ else:
36
+ self.with_df = df.DF(mf.mol)
37
+ self.with_df.auxbasis = df.make_auxbasis(mf.mol, mp2fit=True)
38
+
39
+ def reset(self, mol=None):
40
+ self.with_df.reset(mol)
41
+ return uccsd.UCCSD.reset(self, mol)
42
+
43
+ def ao2mo(self, mo_coeff=None):
44
+ return _make_df_eris(self, mo_coeff)
45
+
46
+ def _add_vvvv(self, t1, t2, eris, out=None, with_ovvv=False, t2sym=None):
47
+ assert (not self.direct)
48
+ return uccsd.UCCSD._add_vvvv(self, t1, t2, eris, out, with_ovvv, t2sym)
49
+
50
+ def _add_vvVV(self, t1, t2, eris, out=None):
51
+ assert (not self.direct)
52
+ return uccsd.UCCSD._add_vvVV(self, t1, t2, eris, out)
53
+
54
+ to_gpu = lib.to_gpu
55
+
56
+ class _ChemistsERIs(uccsd._ChemistsERIs):
57
+ def _contract_vvvv_t2(self, mycc, t2, direct=False, out=None, verbose=None):
58
+ assert (not direct)
59
+ return dfccsd._contract_vvvv_t2(mycc, self.mol, self.vvL, self.vvL, t2, out, verbose)
60
+ def _contract_VVVV_t2(self, mycc, t2, direct=False, out=None, verbose=None):
61
+ assert (not direct)
62
+ return dfccsd._contract_vvvv_t2(mycc, self.mol, self.VVL, self.VVL, t2, out, verbose)
63
+ def _contract_vvVV_t2(self, mycc, t2, direct=False, out=None, verbose=None):
64
+ assert (not direct)
65
+ return dfccsd._contract_vvvv_t2(mycc, self.mol, self.vvL, self.VVL, t2, out, verbose)
66
+
67
+ def _cp(a):
68
+ return np.asarray(a, order='C')
69
+
70
+ def _make_df_eris(mycc, mo_coeff=None):
71
+ assert mycc._scf.istype('UHF')
72
+ cput0 = (logger.process_clock(), logger.perf_counter())
73
+ log = logger.Logger(mycc.stdout, mycc.verbose)
74
+ eris = _ChemistsERIs()
75
+ eris._common_init_(mycc, mo_coeff)
76
+
77
+ moa, mob = eris.mo_coeff
78
+ nocca, noccb = eris.nocc
79
+ nao = moa.shape[0]
80
+ nmoa = moa.shape[1]
81
+ nmob = mob.shape[1]
82
+ nvira = nmoa - nocca
83
+ nvirb = nmob - noccb
84
+ nvira_pair = nvira * (nvira + 1) // 2
85
+ nvirb_pair = nvirb * (nvirb + 1) // 2
86
+ with_df = mycc.with_df
87
+ naux = eris.naux = with_df.get_naoaux()
88
+
89
+ # --- Three-center integrals
90
+ # (L|aa)
91
+ Loo = np.empty((naux, nocca, nocca))
92
+ Lov = np.empty((naux, nocca, nvira))
93
+ Lvo = np.empty((naux, nvira, nocca))
94
+ # (L|bb)
95
+ LOO = np.empty((naux, noccb, noccb))
96
+ LOV = np.empty((naux, noccb, nvirb))
97
+ LVO = np.empty((naux, nvirb, noccb))
98
+
99
+ # --- Four-center integrals
100
+ eris.feri = lib.H5TmpFile()
101
+ # (aa|aa)
102
+ eris.oooo = eris.feri.create_dataset('oooo', (nocca,nocca,nocca,nocca), 'f8')
103
+ eris.oovv = eris.feri.create_dataset('oovv', (nocca,nocca,nvira,nvira), 'f8', chunks=(nocca,nocca,1,nvira))
104
+ eris.ovoo = eris.feri.create_dataset('ovoo', (nocca,nvira,nocca,nocca), 'f8', chunks=(nocca,1,nocca,nocca))
105
+ eris.ovvo = eris.feri.create_dataset('ovvo', (nocca,nvira,nvira,nocca), 'f8', chunks=(nocca,1,nvira,nocca))
106
+ eris.ovov = eris.feri.create_dataset('ovov', (nocca,nvira,nocca,nvira), 'f8', chunks=(nocca,1,nocca,nvira))
107
+ # (bb|bb)
108
+ eris.OOOO = eris.feri.create_dataset('OOOO', (noccb,noccb,noccb,noccb), 'f8')
109
+ eris.OOVV = eris.feri.create_dataset('OOVV', (noccb,noccb,nvirb,nvirb), 'f8', chunks=(noccb,noccb,1,nvirb))
110
+ eris.OVOO = eris.feri.create_dataset('OVOO', (noccb,nvirb,noccb,noccb), 'f8', chunks=(noccb,1,noccb,noccb))
111
+ eris.OVVO = eris.feri.create_dataset('OVVO', (noccb,nvirb,nvirb,noccb), 'f8', chunks=(noccb,1,nvirb,noccb))
112
+ eris.OVOV = eris.feri.create_dataset('OVOV', (noccb,nvirb,noccb,nvirb), 'f8', chunks=(noccb,1,noccb,nvirb))
113
+ # (aa|bb)
114
+ eris.ooOO = eris.feri.create_dataset('ooOO', (nocca,nocca,noccb,noccb), 'f8')
115
+ eris.ooVV = eris.feri.create_dataset('ooVV', (nocca,nocca,nvirb,nvirb), 'f8', chunks=(nocca,nocca,1,nvirb))
116
+ eris.ovOO = eris.feri.create_dataset('ovOO', (nocca,nvira,noccb,noccb), 'f8', chunks=(nocca,1,noccb,noccb))
117
+ eris.ovVO = eris.feri.create_dataset('ovVO', (nocca,nvira,nvirb,noccb), 'f8', chunks=(nocca,1,nvirb,noccb))
118
+ eris.ovOV = eris.feri.create_dataset('ovOV', (nocca,nvira,noccb,nvirb), 'f8', chunks=(nocca,1,noccb,nvirb))
119
+ # (bb|aa)
120
+ eris.OOvv = eris.feri.create_dataset('OOvv', (noccb,noccb,nvira,nvira), 'f8', chunks=(noccb,noccb,1,nvira))
121
+ eris.OVoo = eris.feri.create_dataset('OVoo', (noccb,nvirb,nocca,nocca), 'f8', chunks=(noccb,1,nocca,nocca))
122
+ eris.OVvo = eris.feri.create_dataset('OVvo', (noccb,nvirb,nvira,nocca), 'f8', chunks=(noccb,1,nvira,nocca))
123
+
124
+ # nrow ~ 4e9/8/blockdim to ensure hdf5 chunk < 4GB
125
+ chunks = (min(nvira_pair, int(4e8 / with_df.blockdim)), min(naux, with_df.blockdim))
126
+ eris.vvL = eris.feri.create_dataset('vvL', (nvira_pair,naux), 'f8', chunks=chunks)
127
+ chunks = (min(nvirb_pair, int(4e8 / with_df.blockdim)), min(naux, with_df.blockdim))
128
+ eris.VVL = eris.feri.create_dataset('VVL', (nvirb_pair,naux), 'f8', chunks=chunks)
129
+
130
+ # Transform three-center integrals to MO basis
131
+ p1 = 0
132
+ for eri1 in with_df.loop():
133
+ eri1 = lib.unpack_tril(eri1).reshape(-1, nao, nao)
134
+ # (L|aa)
135
+ Lpq = lib.einsum('Lab,ap,bq->Lpq', eri1, moa, moa)
136
+ p0, p1 = p1, p1 + Lpq.shape[0]
137
+ blk = np.s_[p0:p1]
138
+ Loo[blk] = Lpq[:, :nocca, :nocca]
139
+ Lov[blk] = Lpq[:, :nocca, nocca:]
140
+ Lvo[blk] = Lpq[:, nocca:, :nocca]
141
+ eris.vvL[:, p0:p1] = lib.pack_tril(Lpq[:, nocca:, nocca:]).T
142
+ # (L|bb)
143
+ Lpq = None
144
+ Lpq = lib.einsum('Lab,ap,bq->Lpq', eri1, mob, mob)
145
+ LOO[blk] = Lpq[:, :noccb, :noccb]
146
+ LOV[blk] = Lpq[:, :noccb, noccb:]
147
+ LVO[blk] = Lpq[:, noccb:, :noccb]
148
+ eris.VVL[:, p0:p1] = lib.pack_tril(Lpq[:, noccb:, noccb:]).T
149
+ Lpq = None
150
+
151
+ Loo = Loo.reshape(naux, nocca * nocca)
152
+ Lov = Lov.reshape(naux, nocca * nvira)
153
+ Lvo = Lvo.reshape(naux, nocca * nvira)
154
+ LOO = LOO.reshape(naux, noccb * noccb)
155
+ LOV = LOV.reshape(naux, noccb * nvirb)
156
+ LVO = LVO.reshape(naux, noccb * nvirb)
157
+
158
+ eris.oooo[:] = lib.ddot(Loo.T, Loo).reshape(nocca,nocca,nocca,nocca)
159
+ eris.ovoo[:] = lib.ddot(Lov.T, Loo).reshape(nocca,nvira,nocca,nocca)
160
+ eris.ovvo[:] = lib.ddot(Lov.T, Lvo).reshape(nocca,nvira,nvira,nocca)
161
+ eris.ovov[:] = lib.ddot(Lov.T, Lov).reshape(nocca,nvira,nocca,nvira)
162
+
163
+ eris.OVoo[:] = lib.ddot(LOV.T, Loo).reshape(noccb,nvirb,nocca,nocca)
164
+ eris.OVvo[:] = lib.ddot(LOV.T, Lvo).reshape(noccb,nvirb,nvira,nocca)
165
+
166
+ Lvo = None
167
+
168
+ eris.OOOO[:] = lib.ddot(LOO.T, LOO).reshape(noccb,noccb,noccb,noccb)
169
+ eris.OVOO[:] = lib.ddot(LOV.T, LOO).reshape(noccb,nvirb,noccb,noccb)
170
+ eris.OVVO[:] = lib.ddot(LOV.T, LVO).reshape(noccb,nvirb,nvirb,noccb)
171
+ eris.OVOV[:] = lib.ddot(LOV.T, LOV).reshape(noccb,nvirb,noccb,nvirb)
172
+
173
+ eris.ooOO[:] = lib.ddot(Loo.T, LOO).reshape(nocca,nocca,noccb,noccb)
174
+ eris.ovOO[:] = lib.ddot(Lov.T, LOO).reshape(nocca,nvira,noccb,noccb)
175
+ eris.ovVO[:] = lib.ddot(Lov.T, LVO).reshape(nocca,nvira,nvirb,noccb)
176
+ eris.ovOV[:] = lib.ddot(Lov.T, LOV).reshape(nocca,nvira,noccb,nvirb)
177
+
178
+ LVO = None
179
+
180
+ mem_now = lib.current_memory()[0]
181
+ max_memory = max(0, mycc.max_memory - mem_now)
182
+
183
+ # eris.oovv
184
+ blksize = max(ccsd.BLKMIN, int((max_memory*.9e6/8-nocca**2*nvira_pair)/(nocca**2+naux)))
185
+ oovv_tril = np.empty((nocca * nocca, nvira_pair))
186
+ for p0, p1 in lib.prange(0, nvira_pair, blksize):
187
+ oovv_tril[:, p0:p1] = lib.ddot(Loo.T, _cp(eris.vvL[p0:p1]).T)
188
+ eris.oovv[:] = lib.unpack_tril(oovv_tril).reshape(nocca, nocca, nvira, nvira)
189
+ oovv_tril = None
190
+
191
+ # eris.ooVV
192
+ blksize = max(ccsd.BLKMIN, int((max_memory*.9e6/8-nocca**2*nvirb_pair)/(nocca**2+naux)))
193
+ oovv_tril = np.empty((nocca * nocca, nvirb_pair))
194
+ for p0, p1 in lib.prange(0, nvirb_pair, blksize):
195
+ oovv_tril[:, p0:p1] = lib.ddot(Loo.T, _cp(eris.VVL[p0:p1]).T)
196
+ eris.ooVV[:] = lib.unpack_tril(oovv_tril).reshape(nocca, nocca, nvirb, nvirb)
197
+ oovv_tril = Loo = None
198
+
199
+ mem_now = lib.current_memory()[0]
200
+ max_memory = max(0, mycc.max_memory - mem_now)
201
+
202
+ # eris.OOvv
203
+ blksize = max(ccsd.BLKMIN, int((max_memory*.9e6/8-noccb**2*nvira_pair)/(noccb**2+naux)))
204
+ oovv_tril = np.empty((noccb * noccb, nvira_pair))
205
+ for p0, p1 in lib.prange(0, nvira_pair, blksize):
206
+ oovv_tril[:, p0:p1] = lib.ddot(LOO.T, _cp(eris.vvL[p0:p1]).T)
207
+ eris.OOvv[:] = lib.unpack_tril(oovv_tril).reshape(noccb, noccb, nvira, nvira)
208
+ oovv_tril = None
209
+
210
+ # eris.OOVV
211
+ blksize = max(ccsd.BLKMIN, int((max_memory*.9e6/8-noccb**2*nvirb_pair)/(noccb**2+naux)))
212
+ oovv_tril = np.empty((noccb * noccb, nvirb_pair))
213
+ for p0, p1 in lib.prange(0, nvirb_pair, blksize):
214
+ oovv_tril[:, p0:p1] = lib.ddot(LOO.T, _cp(eris.VVL[p0:p1]).T)
215
+ eris.OOVV[:] = lib.unpack_tril(oovv_tril).reshape(noccb, noccb, nvirb, nvirb)
216
+ oovv_tril = LOO = None
217
+
218
+ mem_now = lib.current_memory()[0]
219
+ max_memory = max(0, mycc.max_memory - mem_now)
220
+
221
+ Lov = Lov.reshape(naux, nocca, nvira)
222
+ LOV = LOV.reshape(naux, noccb, nvirb)
223
+
224
+ # eris.ovvv
225
+ vblk = max(nocca, int((max_memory*.15e6/8)/(nocca*nvira_pair)))
226
+ vvblk = int(min(nvira_pair, 4e8/nocca, max(4, (max_memory*.8e6/8)/(vblk*nocca+naux))))
227
+ eris.ovvv = eris.feri.create_dataset('ovvv', (nocca, nvira, nvira_pair), 'f8', chunks=(nocca, 1, vvblk))
228
+ for q0, q1 in lib.prange(0, nvira_pair, vvblk):
229
+ vvL = _cp(eris.vvL[q0:q1])
230
+ for p0, p1 in lib.prange(0, nvira, vblk):
231
+ tmpLov = Lov[:, :, p0:p1].reshape(naux, -1)
232
+ eris.ovvv[:, p0:p1, q0:q1] = lib.ddot(tmpLov.T, vvL.T).reshape(nocca, p1 - p0, q1 - q0)
233
+ vvL = None
234
+
235
+ # eris.ovVV
236
+ vblk = max(nocca, int((max_memory*.15e6/8)/(nocca*nvirb_pair)))
237
+ vvblk = int(min(nvirb_pair, 4e8/nocca, max(4, (max_memory*.8e6/8)/(vblk*nocca+naux))))
238
+ eris.ovVV = eris.feri.create_dataset('ovVV', (nocca, nvira, nvirb_pair), 'f8', chunks=(nocca, 1, vvblk))
239
+ for q0, q1 in lib.prange(0, nvirb_pair, vvblk):
240
+ vvL = _cp(eris.VVL[q0:q1])
241
+ for p0, p1 in lib.prange(0, nvira, vblk):
242
+ tmpLov = Lov[:, :, p0:p1].reshape(naux, -1)
243
+ eris.ovVV[:, p0:p1, q0:q1] = lib.ddot(tmpLov.T, vvL.T).reshape(nocca, p1 - p0, q1 - q0)
244
+ vvL = None
245
+ Lov = None
246
+
247
+ mem_now = lib.current_memory()[0]
248
+ max_memory = max(0, mycc.max_memory - mem_now)
249
+
250
+ # eris.OVvv
251
+ vblk = max(noccb, int((max_memory*.15e6/8)/(noccb*nvira_pair)))
252
+ vvblk = int(min(nvira_pair, 4e8/noccb, max(4, (max_memory*.8e6/8)/(vblk*noccb+naux))))
253
+ eris.OVvv = eris.feri.create_dataset('OVvv', (noccb, nvirb, nvira_pair), 'f8', chunks=(noccb, 1, vvblk))
254
+ for q0, q1 in lib.prange(0, nvira_pair, vvblk):
255
+ vvL = _cp(eris.vvL[q0:q1])
256
+ for p0, p1 in lib.prange(0, nvirb, vblk):
257
+ tmpLov = LOV[:, :, p0:p1].reshape(naux, -1)
258
+ eris.OVvv[:, p0:p1, q0:q1] = lib.ddot(tmpLov.T, vvL.T).reshape(noccb, p1 - p0, q1 - q0)
259
+ vvL = None
260
+
261
+ # eris.OVVV
262
+ vblk = max(noccb, int((max_memory*.15e6/8)/(noccb*nvirb_pair)))
263
+ vvblk = int(min(nvirb_pair, 4e8/noccb, max(4, (max_memory*.8e6/8)/(vblk*noccb+naux))))
264
+ eris.OVVV = eris.feri.create_dataset('OVVV', (noccb, nvirb, nvirb_pair), 'f8', chunks=(noccb, 1, vvblk))
265
+ for q0, q1 in lib.prange(0, nvirb_pair, vvblk):
266
+ vvL = _cp(eris.VVL[q0:q1])
267
+ for p0, p1 in lib.prange(0, nvirb, vblk):
268
+ tmpLov = LOV[:, :, p0:p1].reshape(naux, -1)
269
+ eris.OVVV[:, p0:p1, q0:q1] = lib.ddot(tmpLov.T, vvL.T).reshape(noccb, p1 - p0, q1 - q0)
270
+ vvL = None
271
+ LOV = None
272
+
273
+ log.timer('DF-UCCSD integral transformation', *cput0)
274
+ return eris
275
+
276
+ if __name__ == '__main__':
277
+ from pyscf import gto
278
+ from pyscf import scf
279
+
280
+ mol = gto.Mole()
281
+ mol.atom = [
282
+ [8 , (0. , 0. , 0.)],
283
+ [1 , (0. , -0.757 , 0.587)],
284
+ [1 , (0. , 0.757 , 0.587)]]
285
+
286
+ mol.basis = 'cc-pvdz'
287
+ mol.build()
288
+ mf = scf.UHF(mol).density_fit('weigend').run()
289
+ mycc = UCCSD(mf).run()
290
+ print(mycc.e_corr - -0.2133709727796199)
291
+
292
+ print("IP energies... (right eigenvector)")
293
+ e,v = mycc.ipccsd(nroots=8)
294
+ print(e)
295
+ print(e[0] - 0.4336428577342009)
296
+ print(e[2] - 0.5188000951518845)
297
+ print(e[4] - 0.6785158684375829)
298
+
299
+ print("EA energies... (right eigenvector)")
300
+ e,v = mycc.eaccsd(nroots=8)
301
+ print(e)
302
+ print(e[0] - 0.1673013569134136)
303
+ print(e[2] - 0.2399984284491973)
304
+ print(e[4] - 0.5096018470162480)
305
+
306
+ e, v = mycc.eeccsd(nroots=4)
307
+ print(e[0] - 0.2757563806054133)
308
+ print(e[1] - 0.2757563806171079)
309
+ print(e[2] - 0.2757563806183815)
310
+ print(e[3] - 0.3006896721085447)
pyscf/cc/gccsd.py CHANGED
@@ -128,8 +128,8 @@ class GCCSD(ccsd.CCSDBase):
128
128
  eijab = lib.direct_sum('ia,jb->ijab', eia, eia)
129
129
  t1 = eris.fock[:nocc,nocc:] / eia
130
130
  eris_oovv = np.array(eris.oovv)
131
- t2 = eris_oovv / eijab
132
- self.emp2 = 0.25*einsum('ijab,ijab', t2, eris_oovv.conj()).real
131
+ t2 = eris_oovv.conj() / eijab
132
+ self.emp2 = 0.25*einsum('ijab,ijab', t2, eris_oovv).real
133
133
  logger.info(self, 'Init t2, MP2 energy = %.15g', self.emp2)
134
134
  return self.emp2, t1, t2
135
135
 
pyscf/cc/rccsd.py CHANGED
@@ -247,7 +247,11 @@ def _make_eris_incore(mycc, mo_coeff=None, ao2mofn=None):
247
247
  eri1 = ao2mofn(eris.mo_coeff).reshape([nmo]*4)
248
248
  else:
249
249
  eri1 = ao2mo.incore.full(mycc._scf._eri, eris.mo_coeff)
250
- eri1 = ao2mo.restore(1, eri1, nmo)
250
+ if mycc._scf._eri.size == nmo**4:
251
+ # The N^4-sized full integral tensor.
252
+ eri1 = eri1.reshape([nmo]*4)
253
+ else:
254
+ eri1 = ao2mo.restore(1, eri1, nmo)
251
255
  eris.oooo = eri1[:nocc,:nocc,:nocc,:nocc].copy()
252
256
  eris.ovoo = eri1[:nocc,nocc:,:nocc,:nocc].copy()
253
257
  eris.ovov = eri1[:nocc,nocc:,:nocc,nocc:].copy()