pyscf 2.5.0__py3-none-macosx_11_0_arm64.whl → 2.6.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 (238) hide show
  1. pyscf/__init__.py +1 -1
  2. pyscf/ao2mo/outcore.py +6 -6
  3. pyscf/cc/__init__.py +1 -7
  4. pyscf/cc/ccsd.py +9 -0
  5. pyscf/cc/ccsd_t.py +1 -1
  6. pyscf/cc/ccsd_t_slow.py +1 -1
  7. pyscf/cc/dfccsd.py +2 -0
  8. pyscf/cc/gccsd.py +2 -0
  9. pyscf/cc/qcisd_t_slow.py +1 -1
  10. pyscf/cc/uccsd.py +2 -0
  11. pyscf/ci/cisd.py +2 -0
  12. pyscf/df/addons.py +1 -1
  13. pyscf/df/df.py +2 -4
  14. pyscf/df/df_jk.py +9 -9
  15. pyscf/df/grad/casdm2_util.py +1 -1
  16. pyscf/df/grad/casscf.py +2 -0
  17. pyscf/df/grad/rhf.py +9 -9
  18. pyscf/df/grad/rks.py +6 -9
  19. pyscf/df/grad/sacasscf.py +2 -0
  20. pyscf/df/grad/uhf.py +4 -3
  21. pyscf/df/grad/uks.py +5 -5
  22. pyscf/df/hessian/rhf.py +9 -6
  23. pyscf/df/hessian/rks.py +2 -6
  24. pyscf/df/hessian/uhf.py +3 -3
  25. pyscf/df/hessian/uks.py +2 -2
  26. pyscf/df/incore.py +6 -5
  27. pyscf/df/outcore.py +16 -2
  28. pyscf/dft/LebedevGrid.py +5047 -0
  29. pyscf/dft/__init__.py +1 -0
  30. pyscf/dft/dft_parser.py +24 -0
  31. pyscf/dft/dks.py +10 -1
  32. pyscf/dft/gen_grid.py +3 -44
  33. pyscf/dft/gks.py +2 -3
  34. pyscf/dft/gks_symm.py +3 -0
  35. pyscf/dft/libxc.py +14 -3
  36. pyscf/dft/numint.py +5 -4
  37. pyscf/dft/rks.py +39 -13
  38. pyscf/dft/rks_symm.py +6 -1
  39. pyscf/dft/roks.py +1 -8
  40. pyscf/dft/uks.py +2 -8
  41. pyscf/dft/uks_symm.py +3 -0
  42. pyscf/dft/xc_deriv.py +4 -3
  43. pyscf/dft/xcfun.py +9 -0
  44. pyscf/fci/addons.py +17 -14
  45. pyscf/fci/direct_nosym.py +45 -56
  46. pyscf/fci/direct_spin0.py +4 -2
  47. pyscf/fci/direct_spin1.py +9 -5
  48. pyscf/grad/__init__.py +1 -1
  49. pyscf/grad/casci.py +2 -0
  50. pyscf/grad/casscf.py +2 -0
  51. pyscf/grad/ccsd.py +2 -0
  52. pyscf/grad/cisd.py +2 -0
  53. pyscf/grad/dhf.py +2 -0
  54. pyscf/grad/dispersion.py +34 -27
  55. pyscf/grad/mp2.py +2 -0
  56. pyscf/grad/rhf.py +8 -6
  57. pyscf/grad/rks.py +3 -11
  58. pyscf/grad/tdrhf.py +2 -0
  59. pyscf/grad/uhf.py +0 -3
  60. pyscf/grad/uks.py +2 -6
  61. pyscf/gto/mole.py +33 -29
  62. pyscf/gto/moleintor.py +1 -0
  63. pyscf/gw/rpa.py +235 -94
  64. pyscf/gw/urpa.py +135 -127
  65. pyscf/hessian/__init__.py +1 -1
  66. pyscf/hessian/dispersion.py +40 -30
  67. pyscf/hessian/rhf.py +11 -9
  68. pyscf/hessian/rks.py +1 -5
  69. pyscf/hessian/uhf.py +2 -4
  70. pyscf/hessian/uks.py +1 -4
  71. pyscf/lib/CMakeLists.txt +46 -1
  72. pyscf/lib/dft/CMakeLists.txt +9 -5
  73. pyscf/lib/dft/grid_collocate.c +655 -0
  74. pyscf/lib/dft/grid_common.c +660 -0
  75. pyscf/lib/dft/grid_common.h +109 -0
  76. pyscf/lib/dft/grid_integrate.c +1358 -0
  77. pyscf/lib/dft/libxc_itrf.c +252 -38
  78. pyscf/lib/dft/multigrid.c +744 -0
  79. pyscf/lib/dft/multigrid.h +72 -0
  80. pyscf/lib/dft/utils.c +71 -0
  81. pyscf/lib/dft/utils.h +27 -0
  82. pyscf/lib/diis.py +2 -0
  83. pyscf/lib/libagf2.dylib +0 -0
  84. pyscf/lib/libao2mo.dylib +0 -0
  85. pyscf/lib/libcc.dylib +0 -0
  86. pyscf/lib/libcgto.dylib +0 -0
  87. pyscf/lib/libcvhf.dylib +0 -0
  88. pyscf/lib/libdft.dylib +0 -0
  89. pyscf/lib/libfci.dylib +0 -0
  90. pyscf/lib/libmcscf.dylib +0 -0
  91. pyscf/lib/libnp_helper.dylib +0 -0
  92. pyscf/lib/libpbc.dylib +0 -0
  93. pyscf/lib/libri.dylib +0 -0
  94. pyscf/lib/libxc_itrf.dylib +0 -0
  95. pyscf/lib/libxcfun_itrf.dylib +0 -0
  96. pyscf/lib/mcscf/fci_string.c +1 -6
  97. pyscf/lib/misc.py +87 -9
  98. pyscf/lib/np_helper/np_helper.h +7 -0
  99. pyscf/lib/numpy_helper.py +9 -2
  100. pyscf/lib/pbc/CMakeLists.txt +11 -1
  101. pyscf/lib/pbc/cell.c +280 -0
  102. pyscf/lib/pbc/cell.h +29 -0
  103. pyscf/lib/pbc/fft.c +147 -0
  104. pyscf/lib/pbc/fft.h +26 -0
  105. pyscf/lib/pbc/fill_ints.c +3 -3
  106. pyscf/lib/pbc/fill_ints.h +29 -0
  107. pyscf/lib/pbc/fill_ints_screened.c +1012 -0
  108. pyscf/lib/pbc/hf_grad.c +95 -0
  109. pyscf/lib/pbc/neighbor_list.c +206 -0
  110. pyscf/lib/pbc/neighbor_list.h +41 -0
  111. pyscf/lib/pbc/optimizer.c +37 -1
  112. pyscf/lib/pbc/optimizer.h +3 -3
  113. pyscf/lib/pbc/pp.c +448 -0
  114. pyscf/lib/solvent/CMakeLists.txt +38 -0
  115. pyscf/mcscf/__init__.py +9 -23
  116. pyscf/mcscf/casci.py +3 -1
  117. pyscf/mcscf/casci_symm.py +3 -1
  118. pyscf/mcscf/mc1step.py +8 -6
  119. pyscf/mcscf/newton_casscf_symm.py +1 -1
  120. pyscf/mcscf/ucasci.py +1 -1
  121. pyscf/mcscf/umc1step.py +1 -1
  122. pyscf/mp/__init__.py +1 -1
  123. pyscf/mp/dfgmp2.py +2 -2
  124. pyscf/mp/dfmp2.py +2 -2
  125. pyscf/mp/dfmp2_native.py +2 -0
  126. pyscf/mp/dfump2_native.py +2 -0
  127. pyscf/mp/gmp2.py +4 -2
  128. pyscf/mp/mp2.py +44 -12
  129. pyscf/mp/ump2.py +50 -19
  130. pyscf/pbc/cc/kccsd.py +2 -0
  131. pyscf/pbc/cc/kccsd_rhf.py +2 -0
  132. pyscf/pbc/cc/kccsd_uhf.py +2 -0
  133. pyscf/pbc/df/aft.py +1 -1
  134. pyscf/pbc/df/aft_jk.py +1 -1
  135. pyscf/pbc/df/df.py +5 -0
  136. pyscf/pbc/df/df_jk.py +4 -7
  137. pyscf/pbc/df/fft.py +5 -0
  138. pyscf/pbc/df/incore.py +244 -0
  139. pyscf/pbc/df/mdf.py +3 -0
  140. pyscf/pbc/df/mdf_jk.py +0 -3
  141. pyscf/pbc/dft/gen_grid.py +4 -0
  142. pyscf/pbc/dft/gks.py +4 -2
  143. pyscf/pbc/dft/kgks.py +13 -4
  144. pyscf/pbc/dft/krks.py +15 -25
  145. pyscf/pbc/dft/krks_ksymm.py +5 -5
  146. pyscf/pbc/dft/kroks.py +9 -19
  147. pyscf/pbc/dft/kuks.py +14 -24
  148. pyscf/pbc/dft/kuks_ksymm.py +5 -5
  149. pyscf/pbc/dft/multigrid/__init__.py +57 -0
  150. pyscf/pbc/dft/{multigrid.py → multigrid/multigrid.py} +86 -93
  151. pyscf/pbc/dft/multigrid/multigrid_pair.py +1405 -0
  152. pyscf/pbc/dft/multigrid/pp.py +290 -0
  153. pyscf/pbc/dft/multigrid/utils.py +70 -0
  154. pyscf/pbc/dft/numint.py +4 -0
  155. pyscf/pbc/dft/rks.py +8 -7
  156. pyscf/pbc/dft/roks.py +2 -0
  157. pyscf/pbc/dft/uks.py +6 -4
  158. pyscf/pbc/grad/__init__.py +5 -2
  159. pyscf/pbc/grad/krhf.py +7 -1
  160. pyscf/pbc/grad/rhf.py +167 -0
  161. pyscf/pbc/grad/rks.py +24 -0
  162. pyscf/pbc/grad/uhf.py +92 -0
  163. pyscf/pbc/grad/uks.py +24 -0
  164. pyscf/pbc/gto/__init__.py +1 -0
  165. pyscf/pbc/gto/_pbcintor.py +14 -7
  166. pyscf/pbc/gto/cell.py +218 -20
  167. pyscf/pbc/gto/ewald_methods.py +293 -0
  168. pyscf/pbc/gto/neighborlist.py +199 -0
  169. pyscf/pbc/gto/pseudo/pp_int.py +350 -17
  170. pyscf/pbc/mp/kmp2.py +2 -0
  171. pyscf/pbc/scf/addons.py +11 -5
  172. pyscf/pbc/scf/ghf.py +2 -0
  173. pyscf/pbc/scf/hf.py +29 -18
  174. pyscf/pbc/scf/kghf.py +2 -0
  175. pyscf/pbc/scf/khf.py +8 -5
  176. pyscf/pbc/scf/khf_ksymm.py +4 -2
  177. pyscf/pbc/scf/krohf.py +1 -0
  178. pyscf/pbc/scf/kuhf.py +5 -2
  179. pyscf/pbc/scf/kuhf_ksymm.py +4 -2
  180. pyscf/pbc/scf/rohf.py +1 -0
  181. pyscf/pbc/scf/rsjk.py +2 -0
  182. pyscf/pbc/scf/uhf.py +7 -3
  183. pyscf/pbc/symm/geom.py +1 -1
  184. pyscf/pbc/symm/pyscf_spglib.py +1 -1
  185. pyscf/pbc/symm/symmetry.py +1 -1
  186. pyscf/pbc/tools/pbc.py +51 -8
  187. pyscf/qmmm/itrf.py +12 -0
  188. pyscf/scf/__init__.py +1 -0
  189. pyscf/scf/_response_functions.py +3 -3
  190. pyscf/scf/addons.py +12 -6
  191. pyscf/scf/atom_hf.py +15 -2
  192. pyscf/scf/atom_hf_pp.py +154 -0
  193. pyscf/scf/dhf.py +5 -7
  194. pyscf/scf/diis.py +4 -8
  195. pyscf/scf/dispersion.py +136 -39
  196. pyscf/scf/ghf.py +3 -7
  197. pyscf/scf/ghf_symm.py +1 -2
  198. pyscf/scf/hf.py +40 -31
  199. pyscf/scf/hf_symm.py +2 -4
  200. pyscf/scf/rohf.py +1 -3
  201. pyscf/scf/uhf.py +7 -8
  202. pyscf/scf/uhf_symm.py +1 -2
  203. pyscf/sgx/sgx.py +5 -0
  204. pyscf/solvent/__init__.py +26 -2
  205. pyscf/solvent/_attach_solvent.py +49 -3
  206. pyscf/solvent/_ddcosmo_tdscf_grad.py +1 -1
  207. pyscf/solvent/ddcosmo.py +5 -4
  208. pyscf/solvent/ddpcm.py +1 -0
  209. pyscf/solvent/grad/__init__.py +17 -0
  210. pyscf/solvent/grad/pcm.py +384 -0
  211. pyscf/solvent/grad/smd.py +176 -0
  212. pyscf/solvent/grad/smd_experiment.py +216 -0
  213. pyscf/solvent/hessian/__init__.py +0 -0
  214. pyscf/solvent/hessian/pcm.py +230 -0
  215. pyscf/solvent/hessian/smd.py +171 -0
  216. pyscf/solvent/hessian/smd_experiment.py +208 -0
  217. pyscf/solvent/pcm.py +137 -56
  218. pyscf/solvent/smd.py +433 -0
  219. pyscf/solvent/smd_experiment.py +273 -0
  220. pyscf/soscf/newton_ah.py +3 -0
  221. pyscf/symm/geom.py +3 -7
  222. pyscf/tdscf/common_slow.py +1 -4
  223. pyscf/tdscf/dhf.py +1 -1
  224. pyscf/tdscf/ghf.py +1 -1
  225. pyscf/tdscf/rhf.py +8 -1
  226. pyscf/tdscf/uhf.py +5 -1
  227. pyscf/tools/chgcar.py +1 -5
  228. pyscf/x2c/sfx2c1e.py +7 -2
  229. pyscf/x2c/tdscf.py +1 -1
  230. pyscf/x2c/x2c.py +8 -0
  231. pyscf-2.6.0.dist-info/METADATA +140 -0
  232. {pyscf-2.5.0.dist-info → pyscf-2.6.0.dist-info}/NOTICE +4 -0
  233. {pyscf-2.5.0.dist-info → pyscf-2.6.0.dist-info}/RECORD +237 -195
  234. {pyscf-2.5.0.dist-info → pyscf-2.6.0.dist-info}/WHEEL +1 -1
  235. pyscf-2.5.0.dist-info/METADATA +0 -81
  236. /pyscf/solvent/{ddcosmo_grad.py → grad/ddcosmo_grad.py} +0 -0
  237. {pyscf-2.5.0.dist-info → pyscf-2.6.0.dist-info}/LICENSE +0 -0
  238. {pyscf-2.5.0.dist-info → pyscf-2.6.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.5.0'
38
+ __version__ = '2.6.0'
39
39
 
40
40
  import os
41
41
  import sys
pyscf/ao2mo/outcore.py CHANGED
@@ -486,16 +486,16 @@ def _load_from_h5g(h5group, row0, row1, out=None):
486
486
  out = numpy.ndarray((row1-row0, ncol), dat.dtype, buffer=out)
487
487
  col1 = 0
488
488
  for key in range(nkeys):
489
- dat = h5group[str(key)][row0:row1]
490
- col0, col1 = col1, col1 + dat.shape[1]
491
- out[:,col0:col1] = dat
489
+ col0, col1 = col1, col1 + h5group[str(key)].shape[1]
490
+ h5group[str(key)].read_direct(out, dest_sel=numpy.s_[:,col0:col1],
491
+ source_sel=numpy.s_[row0:row1])
492
492
  else: # multiple components
493
493
  out = numpy.ndarray((dat.shape[0], row1-row0, ncol), dat.dtype, buffer=out)
494
494
  col1 = 0
495
495
  for key in range(nkeys):
496
- dat = h5group[str(key)][:,row0:row1]
497
- col0, col1 = col1, col1 + dat.shape[2]
498
- out[:,:,col0:col1] = dat
496
+ col0, col1 = col1, col1 + h5group[str(key)].shape[2]
497
+ h5group[str(key)].read_direct(out, dest_sel=numpy.s_[:,:,col0:col1],
498
+ source_sel=numpy.s_[:,row0:row1])
499
499
  return out
500
500
 
501
501
  def _transpose_to_h5g(h5group, key, dat, blksize, chunks=None):
pyscf/cc/__init__.py CHANGED
@@ -194,15 +194,9 @@ def FNOCCSD(mf, thresh=1e-6, pct_occ=None, nvir_act=None, frozen=None):
194
194
  Number of virtual NOs to keep. Default is None. If present, overrides `thresh` and `pct_occ`.
195
195
  """
196
196
  import numpy
197
- if frozen is None:
198
- frozenocc = 0
199
- else:
200
- assert(isinstance(frozen, (int,numpy.int64)))
201
- frozenocc = frozen
202
197
  from pyscf import mp
203
- pt = mp.MP2(mf).set(verbose=0).run()
198
+ pt = mp.MP2(mf, frozen=frozen).set(verbose=0).run()
204
199
  frozen, no_coeff = pt.make_fno(thresh=thresh, pct_occ=pct_occ, nvir_act=nvir_act)
205
- frozen = numpy.hstack([numpy.arange(frozenocc),frozen])
206
200
  if len(frozen) == 0: frozen = None
207
201
  pt_no = mp.MP2(mf, frozen=frozen, mo_coeff=no_coeff).set(verbose=0).run()
208
202
  mycc = CCSD(mf, frozen=frozen, mo_coeff=no_coeff)
pyscf/cc/ccsd.py CHANGED
@@ -1240,6 +1240,15 @@ class CCSDBase(lib.StreamObject):
1240
1240
  def nuc_grad_method(self):
1241
1241
  raise NotImplementedError
1242
1242
 
1243
+ # to_gpu can be reused only when __init__ still takes mf
1244
+ def to_gpu(self):
1245
+ mf = self.base.to_gpu()
1246
+ from importlib import import_module
1247
+ mod = import_module(self.__module__.replace('pyscf', 'gpu4pyscf'))
1248
+ cls = getattr(mod, self.__class__.__name__)
1249
+ obj = cls(mf)
1250
+ return obj
1251
+
1243
1252
  class CCSD(CCSDBase):
1244
1253
  __doc__ = CCSDBase.__doc__
1245
1254
 
pyscf/cc/ccsd_t.py CHANGED
@@ -176,7 +176,7 @@ def _sort_eri(mycc, eris, nocc, nvir, vvop, log):
176
176
 
177
177
  def _sort_t2_vooo_(mycc, orbsym, t1, t2, eris):
178
178
  assert (t2.flags.c_contiguous)
179
- vooo = numpy.asarray(eris.ovoo).transpose(1,0,3,2).conj().copy()
179
+ vooo = numpy.asarray(eris.ovoo).transpose(1,0,2,3).conj().copy()
180
180
  nocc, nvir = t1.shape
181
181
  if mycc.mol.symmetry:
182
182
  orbsym = numpy.asarray(orbsym, dtype=numpy.int32)
pyscf/cc/ccsd_t_slow.py CHANGED
@@ -45,7 +45,7 @@ def kernel(mycc, eris, t1=None, t2=None, verbose=logger.NOTE):
45
45
  eijk = lib.direct_sum('i,j,k->ijk', e_occ, e_occ, e_occ)
46
46
 
47
47
  eris_vvov = eris.get_ovvv().conj().transpose(1,3,0,2)
48
- eris_vooo = numpy.asarray(eris.ovoo).conj().transpose(1,0,3,2)
48
+ eris_vooo = numpy.asarray(eris.ovoo).conj().transpose(1,0,2,3)
49
49
  eris_vvoo = numpy.asarray(eris.ovov).conj().transpose(1,3,0,2)
50
50
  fvo = eris.fock[nocc:,:nocc]
51
51
  def get_w(a, b, c):
pyscf/cc/dfccsd.py CHANGED
@@ -48,6 +48,8 @@ class RCCSD(ccsd.CCSD):
48
48
  assert (not self.direct)
49
49
  return ccsd.CCSD._add_vvvv(self, t1, t2, eris, out, with_ovvv, t2sym)
50
50
 
51
+ to_gpu = lib.to_gpu
52
+
51
53
 
52
54
  def _contract_vvvv_t2(mycc, mol, vvL, t2, out=None, verbose=None):
53
55
  '''Ht2 = numpy.einsum('ijcd,acdb->ijab', t2, vvvv)
pyscf/cc/gccsd.py CHANGED
@@ -289,6 +289,8 @@ class GCCSD(ccsd.CCSDBase):
289
289
  orbspin = orbspin[self.get_frozen_mask()]
290
290
  return spin2spatial(tx, orbspin)
291
291
 
292
+ to_gpu = lib.to_gpu
293
+
292
294
  CCSD = GCCSD
293
295
 
294
296
 
pyscf/cc/qcisd_t_slow.py CHANGED
@@ -47,7 +47,7 @@ def kernel(mycc, eris, t1=None, t2=None, verbose=logger.NOTE):
47
47
  eijk = lib.direct_sum('i,j,k->ijk', e_occ, e_occ, e_occ)
48
48
 
49
49
  eris_vvov = eris.get_ovvv().conj().transpose(1,3,0,2)
50
- eris_vooo = numpy.asarray(eris.ovoo).conj().transpose(1,0,3,2)
50
+ eris_vooo = numpy.asarray(eris.ovoo).conj().transpose(1,0,2,3)
51
51
  eris_vvoo = numpy.asarray(eris.ovov).conj().transpose(1,3,0,2)
52
52
  fvo = eris.fock[nocc:,:nocc]
53
53
  def get_w(a, b, c):
pyscf/cc/uccsd.py CHANGED
@@ -758,6 +758,8 @@ class UCCSD(ccsd.CCSDBase):
758
758
  def amplitudes_from_rccsd(self, t1, t2):
759
759
  return amplitudes_from_rccsd(t1, t2)
760
760
 
761
+ to_gpu = lib.to_gpu
762
+
761
763
  CCSD = UCCSD
762
764
 
763
765
 
pyscf/ci/cisd.py CHANGED
@@ -1131,6 +1131,8 @@ class CISD(lib.StreamObject):
1131
1131
  from pyscf.grad import cisd
1132
1132
  return cisd.Gradients(self)
1133
1133
 
1134
+ to_gpu = lib.to_gpu
1135
+
1134
1136
  class RCISD(CISD):
1135
1137
  pass
1136
1138
 
pyscf/df/addons.py CHANGED
@@ -152,7 +152,7 @@ def make_auxbasis(mol, mp2fit=False):
152
152
  _basis.update(mol.basis)
153
153
  del (_basis['default'])
154
154
  else:
155
- _basis = mol._basis
155
+ _basis = mol._basis or {}
156
156
 
157
157
  auxbasis = {}
158
158
  for k in _basis:
pyscf/df/df.py CHANGED
@@ -284,7 +284,7 @@ class DF(lib.StreamObject):
284
284
  else:
285
285
  rsh_df = self._rsh_df[key] = self.copy().reset()
286
286
  if hasattr(self, '_dataname'):
287
- rsh_df._dataname = f'{self._dataname}/lr/{key}'
287
+ rsh_df._dataname = f'{self._dataname}-lr/{key}'
288
288
  logger.info(self, 'Create RSH-DF object %s for omega=%s', rsh_df, omega)
289
289
 
290
290
  mol = self.mol
@@ -308,9 +308,7 @@ class DF(lib.StreamObject):
308
308
  if auxmol_omega is not None:
309
309
  auxmol.omega = auxmol_omega
310
310
 
311
- def to_gpu(self):
312
- from gpu4pyscf.df.df import DF as DF
313
- return lib.to_gpu(self.__class__.reset(self.view(DF)))
311
+ to_gpu = lib.to_gpu
314
312
 
315
313
  GDF = DF
316
314
 
pyscf/df/df_jk.py CHANGED
@@ -228,8 +228,7 @@ class _DFHF:
228
228
 
229
229
  def to_gpu(self):
230
230
  obj = self.undo_df().to_gpu().density_fit()
231
- obj.__dict__.update(self.__dict__)
232
- return lib.to_gpu(obj)
231
+ return lib.to_gpu(self, obj)
233
232
 
234
233
 
235
234
  def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
@@ -261,8 +260,9 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
261
260
 
262
261
  if not with_k:
263
262
  for eri1 in dfobj.loop():
264
- rho = numpy.einsum('ix,px->ip', dmtril, eri1)
265
- vj += numpy.einsum('ip,px->ix', rho, eri1)
263
+ # uses numpy.matmul
264
+ vj += (dmtril @ eri1.T) @ eri1
265
+
266
266
 
267
267
  elif getattr(dm, 'mo_coeff', None) is not None:
268
268
  #TODO: test whether dm.mo_coeff matching dm
@@ -291,9 +291,8 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
291
291
  naux, nao_pair = eri1.shape
292
292
  assert (nao_pair == nao*(nao+1)//2)
293
293
  if with_j:
294
- rho = numpy.einsum('ix,px->ip', dmtril, eri1)
295
- vj += numpy.einsum('ip,px->ix', rho, eri1)
296
-
294
+ # uses numpy.matmul
295
+ vj += (dmtril @ eri1.T) @ eri1
297
296
  for k in range(nset):
298
297
  nocc = orbo[k].shape[1]
299
298
  if nocc > 0:
@@ -319,8 +318,9 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
319
318
  for eri1 in dfobj.loop(blksize):
320
319
  naux, nao_pair = eri1.shape
321
320
  if with_j:
322
- rho = numpy.einsum('ix,px->ip', dmtril, eri1)
323
- vj += numpy.einsum('ip,px->ix', rho, eri1)
321
+ # uses numpy.matmul
322
+ vj += (dmtril @ eri1.T) @ eri1
323
+
324
324
 
325
325
  for k in range(nset):
326
326
  buf1 = buf[0,:naux]
@@ -476,7 +476,7 @@ def grad_elec_dferi (mc_grad, mo_cas=None, ci=None, dfcasdm2=None, casdm2=None,
476
476
 
477
477
  aoslices = mol.aoslice_by_atom ()
478
478
  dE = np.array ([dE[:,p0:p1].sum (axis=1) for p0, p1 in aoslices[:,2:]]).transpose (1,0,2)
479
- return np.ascontiguousarray (dE)
479
+ return np.ascontiguousarray (dE)[:,atmlst,:]
480
480
 
481
481
  if __name__ == '__main__':
482
482
  from pyscf.tools import molden
pyscf/df/grad/casscf.py CHANGED
@@ -224,6 +224,8 @@ class Gradients(casci_grad.Gradients):
224
224
 
225
225
  as_scanner = as_scanner
226
226
 
227
+ to_gpu = lib.to_gpu
228
+
227
229
  Grad = Gradients
228
230
 
229
231
  #from pyscf import mcscf
pyscf/df/grad/rhf.py CHANGED
@@ -38,8 +38,9 @@ from functools import reduce
38
38
  from itertools import product
39
39
  from pyscf.ao2mo import _ao2mo
40
40
  from pyscf.df import df_jk
41
+ from pyscf.df.incore import LINEAR_DEP_THR
41
42
 
42
- LINEAR_DEP_THRESHOLD = 1e-9
43
+ LINEAR_DEP_THRESHOLD = LINEAR_DEP_THR
43
44
 
44
45
  def get_jk(mf_grad, mol=None, dm=None, hermi=0, with_j=True, with_k=True,
45
46
  decompose_j2c='CD', lindep=LINEAR_DEP_THRESHOLD):
@@ -482,12 +483,15 @@ class Gradients(rhf_grad.Gradients):
482
483
  _keys = {'with_df', 'auxbasis_response'}
483
484
 
484
485
  def __init__(self, mf):
485
- assert isinstance(mf, df.df_jk._DFHF)
486
- # Whether to include the response of DF auxiliary basis when computing
487
- # nuclear gradients of J/K matrices
488
- self.auxbasis_response = True
489
486
  rhf_grad.Gradients.__init__(self, mf)
490
487
 
488
+ # Whether to include the response of DF auxiliary basis when computing
489
+ # nuclear gradients of J/K matrices
490
+ auxbasis_response = True
491
+
492
+ def check_sanity(self):
493
+ assert isinstance(self.base, df.df_jk._DFHF)
494
+
491
495
  def get_jk(self, mol=None, dm=None, hermi=0, with_j=True, with_k=True,
492
496
  omega=None):
493
497
  if omega is None:
@@ -521,8 +525,4 @@ class Gradients(rhf_grad.Gradients):
521
525
  else:
522
526
  return 0
523
527
 
524
- def to_gpu(self):
525
- from gpu4pyscf.df.grad.rhf import Gradients
526
- return lib.to_gpu(self.view(Gradients))
527
-
528
528
  Grad = Gradients
pyscf/df/grad/rks.py CHANGED
@@ -46,7 +46,7 @@ def get_veff(ks_grad, mol=None, dm=None):
46
46
  exc, vxc = rks_grad.get_vxc_full_response(
47
47
  ni, mol, grids, mf.xc, dm,
48
48
  max_memory=max_memory, verbose=ks_grad.verbose)
49
- if mf.nlc or ni.libxc.is_nlc(mf.xc):
49
+ if mf.do_nlc():
50
50
  if ni.libxc.is_nlc(mf.xc):
51
51
  xc = mf.xc
52
52
  else:
@@ -61,7 +61,7 @@ def get_veff(ks_grad, mol=None, dm=None):
61
61
  exc, vxc = rks_grad.get_vxc(
62
62
  ni, mol, grids, mf.xc, dm,
63
63
  max_memory=max_memory, verbose=ks_grad.verbose)
64
- if mf.nlc or ni.libxc.is_nlc(mf.xc):
64
+ if mf.do_nlc():
65
65
  if ni.libxc.is_nlc(mf.xc):
66
66
  xc = mf.xc
67
67
  else:
@@ -107,11 +107,12 @@ class Gradients(rks_grad.Gradients):
107
107
  _keys = {'with_df', 'auxbasis_response'}
108
108
 
109
109
  def __init__(self, mf):
110
- # Whether to include the response of DF auxiliary basis when computing
111
- # nuclear gradients of J/K matrices
112
- self.auxbasis_response = True
113
110
  rks_grad.Gradients.__init__(self, mf)
114
111
 
112
+ # Whether to include the response of DF auxiliary basis when computing
113
+ # nuclear gradients of J/K matrices
114
+ auxbasis_response = True
115
+
115
116
  get_jk = df_rhf_grad.Gradients.get_jk
116
117
  get_j = df_rhf_grad.Gradients.get_j
117
118
  get_k = df_rhf_grad.Gradients.get_k
@@ -123,8 +124,4 @@ class Gradients(rks_grad.Gradients):
123
124
  e1 += envs['vhf'].aux[atom_id]
124
125
  return e1
125
126
 
126
- def to_gpu(self):
127
- from gpu4pyscf.df.grad.rks import Gradients
128
- return lib.to_gpu(self.view(Gradients))
129
-
130
127
  Grad = Gradients
pyscf/df/grad/sacasscf.py CHANGED
@@ -370,3 +370,5 @@ class Gradients (sacasscf_grad.Gradients):
370
370
  def get_LdotJnuc (self, Lvec, **kwargs):
371
371
  with lib.temporary_env (sacasscf_grad, Lci_dot_dgci_dx=Lci_dot_dgci_dx, Lorb_dot_dgorb_dx=Lorb_dot_dgorb_dx):
372
372
  return sacasscf_grad.Gradients.get_LdotJnuc (self, Lvec, **kwargs)
373
+
374
+ to_gpu = lib.to_gpu
pyscf/df/grad/uhf.py CHANGED
@@ -35,11 +35,12 @@ class Gradients(uhf_grad.Gradients):
35
35
  _keys = {'with_df', 'auxbasis_response'}
36
36
 
37
37
  def __init__(self, mf):
38
- # Whether to include the response of DF auxiliary basis when computing
39
- # nuclear gradients of J/K matrices
40
- self.auxbasis_response = True
41
38
  uhf_grad.Gradients.__init__(self, mf)
42
39
 
40
+ # Whether to include the response of DF auxiliary basis when computing
41
+ # nuclear gradients of J/K matrices
42
+ auxbasis_response = True
43
+
43
44
  get_jk = df_rhf_grad.Gradients.get_jk
44
45
  get_j = df_rhf_grad.Gradients.get_j
45
46
  get_k = df_rhf_grad.Gradients.get_k
pyscf/df/grad/uks.py CHANGED
@@ -48,7 +48,7 @@ def get_veff(ks_grad, mol=None, dm=None):
48
48
  exc, vxc = uks_grad.get_vxc_full_response(
49
49
  ni, mol, grids, mf.xc, dm,
50
50
  max_memory=max_memory, verbose=ks_grad.verbose)
51
- if mf.nlc or ni.libxc.is_nlc(mf.xc):
51
+ if mf.do_nlc():
52
52
  if ni.libxc.is_nlc(mf.xc):
53
53
  xc = mf.xc
54
54
  else:
@@ -63,7 +63,7 @@ def get_veff(ks_grad, mol=None, dm=None):
63
63
  exc, vxc = uks_grad.get_vxc(
64
64
  ni, mol, grids, mf.xc, dm,
65
65
  max_memory=max_memory, verbose=ks_grad.verbose)
66
- if mf.nlc or ni.libxc.is_nlc(mf.xc):
66
+ if mf.do_nlc():
67
67
  if ni.libxc.is_nlc(mf.xc):
68
68
  xc = mf.xc
69
69
  else:
@@ -108,11 +108,11 @@ class Gradients(uks_grad.Gradients):
108
108
  _keys = {'with_df', 'auxbasis_response'}
109
109
 
110
110
  def __init__(self, mf):
111
- # Whether to include the response of DF auxiliary basis when computing
112
- # nuclear gradients of J/K matrices
113
- self.auxbasis_response = True
114
111
  uks_grad.Gradients.__init__(self, mf)
115
112
 
113
+ # Whether to include the response of DF auxiliary basis when computing
114
+ # nuclear gradients of J/K matrices
115
+ auxbasis_response = True
116
116
  get_jk = df_rhf_grad.Gradients.get_jk
117
117
  get_j = df_rhf_grad.Gradients.get_j
118
118
  get_k = df_rhf_grad.Gradients.get_k
pyscf/df/hessian/rhf.py CHANGED
@@ -43,6 +43,13 @@ from pyscf.hessian import rhf as rhf_hess
43
43
  from pyscf.df.grad.rhf import (_int3c_wrapper, _gen_metric_solver,
44
44
  LINEAR_DEP_THRESHOLD)
45
45
 
46
+ def _pinv(a, lindep=LINEAR_DEP_THRESHOLD):
47
+ '''Similar to pinv (v1.7.0) with atol=lindep and rtol=0'''
48
+ w, v = scipy.linalg.eigh(a)
49
+ mask = w > lindep
50
+ v1 = v[:, mask]
51
+ return lib.dot(v1/w[mask], v1.conj().T)
52
+
46
53
  def partial_hess_elec(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
47
54
  atmlst=None, max_memory=4000, verbose=None):
48
55
  e1, ej, ek = _partial_hess_ejk(hessobj, mo_energy, mo_coeff, mo_occ,
@@ -174,7 +181,7 @@ def _partial_hess_ejk(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
174
181
  get_int3c_ipip2 = _int3c_wrapper(mol, auxmol, 'int3c2e_ipip2', 's1')
175
182
  rhok0_P__ = lib.einsum('plj,li->pij', rhok0_Pl_, mocc_2)
176
183
  rho2c_0 = lib.einsum('pij,qji->pq', rhok0_P__, rhok0_P__)
177
- int2c_inv = numpy.linalg.pinv(int2c, rcond=LINEAR_DEP_THRESHOLD)
184
+ int2c_inv = _pinv(int2c, lindep=LINEAR_DEP_THRESHOLD)
178
185
  int2c_ipip1 = auxmol.intor('int2c2e_ipip1', aosym='s1')
179
186
  int2c_ip_ip = lib.einsum('xpq,qr,ysr->xyps', int2c_ip1, int2c_inv, int2c_ip1)
180
187
  int2c_ip_ip -= auxmol.intor('int2c2e_ip1ip2', aosym='s1').reshape(3,3,naux,naux)
@@ -475,16 +482,12 @@ def _load_dim0(dat, p0, p1):
475
482
  class Hessian(rhf_hess.Hessian):
476
483
  '''Non-relativistic restricted Hartree-Fock hessian'''
477
484
  def __init__(self, mf):
478
- self.auxbasis_response = 1
479
485
  rhf_hess.Hessian.__init__(self, mf)
480
486
 
487
+ auxbasis_response = 1
481
488
  partial_hess_elec = partial_hess_elec
482
489
  make_h1 = make_h1
483
490
 
484
- def to_gpu(self):
485
- from gpu4pyscf.df.hessian.rhf import Hessian
486
- return lib.to_gpu(self.view(Hessian))
487
-
488
491
  #TODO: Insert into DF class
489
492
 
490
493
 
pyscf/df/hessian/rks.py CHANGED
@@ -42,7 +42,7 @@ def partial_hess_elec(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
42
42
  mol = hessobj.mol
43
43
  mf = hessobj.base
44
44
  ni = mf._numint
45
- if mf.nlc or ni.libxc.is_nlc(mf.xc):
45
+ if mf.do_nlc():
46
46
  raise NotImplementedError('RKS Hessian for NLC functional')
47
47
 
48
48
  if mo_energy is None: mo_energy = mf.mo_energy
@@ -121,16 +121,12 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None):
121
121
  class Hessian(rks_hess.Hessian):
122
122
  '''Non-relativistic RKS hessian'''
123
123
  def __init__(self, mf):
124
- self.auxbasis_response = 1
125
124
  rks_hess.Hessian.__init__(self, mf)
126
125
 
126
+ auxbasis_response = 1
127
127
  partial_hess_elec = partial_hess_elec
128
128
  make_h1 = make_h1
129
129
 
130
- def to_gpu(self):
131
- from gpu4pyscf.df.hessian.rks import Hessian
132
- return lib.to_gpu(self.view(Hessian))
133
-
134
130
 
135
131
  if __name__ == '__main__':
136
132
  from pyscf import gto
pyscf/df/hessian/uhf.py CHANGED
@@ -35,7 +35,7 @@ from pyscf.lib import logger
35
35
  from pyscf import ao2mo
36
36
  from pyscf.hessian import rhf as rhf_hess
37
37
  from pyscf.hessian import uhf as uhf_hess
38
- from pyscf.df.hessian.rhf import _load_dim0
38
+ from pyscf.df.hessian.rhf import _load_dim0, _pinv
39
39
  from pyscf.df.grad.rhf import (_int3c_wrapper, _gen_metric_solver,
40
40
  LINEAR_DEP_THRESHOLD)
41
41
 
@@ -197,7 +197,7 @@ def _partial_hess_ejk(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
197
197
  rhok0b_P__ = lib.einsum('plj,li->pij', rhok0b_Pl_, moccb)
198
198
  rho2c_0 = lib.einsum('pij,qij->pq', rhok0a_P__, rhok0a_P__)
199
199
  rho2c_0 += lib.einsum('pij,qij->pq', rhok0b_P__, rhok0b_P__)
200
- int2c_inv = numpy.linalg.pinv(int2c, rcond=LINEAR_DEP_THRESHOLD)
200
+ int2c_inv = _pinv(int2c, lindep=LINEAR_DEP_THRESHOLD)
201
201
  int2c_ipip1 = auxmol.intor('int2c2e_ipip1', aosym='s1')
202
202
  int2c_ip_ip = lib.einsum('xpq,qr,ysr->xyps', int2c_ip1, int2c_inv, int2c_ip1)
203
203
  int2c_ip_ip -= auxmol.intor('int2c2e_ip1ip2', aosym='s1').reshape(3,3,naux,naux)
@@ -526,9 +526,9 @@ def _gen_jk(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None,
526
526
  class Hessian(uhf_hess.Hessian):
527
527
  '''Non-relativistic UHF hessian'''
528
528
  def __init__(self, mf):
529
- self.auxbasis_response = 1
530
529
  uhf_hess.Hessian.__init__(self, mf)
531
530
 
531
+ auxbasis_response = 1
532
532
  partial_hess_elec = partial_hess_elec
533
533
  make_h1 = make_h1
534
534
 
pyscf/df/hessian/uks.py CHANGED
@@ -42,7 +42,7 @@ def partial_hess_elec(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
42
42
  mol = hessobj.mol
43
43
  mf = hessobj.base
44
44
  ni = mf._numint
45
- if mf.nlc or ni.libxc.is_nlc(mf.xc):
45
+ if mf.do_nlc():
46
46
  raise NotImplementedError('RKS Hessian for NLC functional')
47
47
 
48
48
  if mo_energy is None: mo_energy = mf.mo_energy
@@ -134,9 +134,9 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None):
134
134
  class Hessian(uks_hess.Hessian):
135
135
  '''Non-relativistic RKS hessian'''
136
136
  def __init__(self, mf):
137
- self.auxbasis_response = 1
138
137
  uks_hess.Hessian.__init__(self, mf)
139
138
 
139
+ auxbasis_response = 1
140
140
  partial_hess_elec = partial_hess_elec
141
141
  make_h1 = make_h1
142
142
 
pyscf/df/incore.py CHANGED
@@ -28,7 +28,7 @@ from pyscf import __config__
28
28
 
29
29
 
30
30
  MAX_MEMORY = getattr(__config__, 'df_outcore_max_memory', 2000) # 2GB
31
- LINEAR_DEP_THR = getattr(__config__, 'df_df_DF_lindep', 1e-12)
31
+ LINEAR_DEP_THR = getattr(__config__, 'df_df_DF_lindep', 1e-9)
32
32
 
33
33
 
34
34
  # This function is aliased for backward compatibility.
@@ -179,10 +179,11 @@ def cholesky_eri(mol, auxbasis='weigend+etb', auxmol=None,
179
179
  p0, p1 = p1, p1 + nrow
180
180
  if decompose_j2c == 'cd':
181
181
  if ints.flags.c_contiguous:
182
- ints = lib.transpose(ints, out=bufs2).T
183
- bufs1, bufs2 = bufs2, bufs1
184
- dat = scipy.linalg.solve_triangular(low, ints, lower=True,
185
- overwrite_b=True, check_finite=False)
182
+ trsm, = scipy.linalg.get_blas_funcs(('trsm',), (low, ints))
183
+ dat = trsm(1.0, low, ints.T, lower=True, trans_a = 1, side = 1, overwrite_b=True).T
184
+ else:
185
+ dat = scipy.linalg.solve_triangular(low, ints, lower=True,
186
+ overwrite_b=True, check_finite=False)
186
187
  if dat.flags.f_contiguous:
187
188
  dat = lib.transpose(dat.T, out=bufs2)
188
189
  cderi[:,p0:p1] = dat
pyscf/df/outcore.py CHANGED
@@ -93,6 +93,11 @@ def cholesky_eri(mol, erifile, auxbasis='weigend+etb', dataname='j3c', tmpdir=No
93
93
  ti0 = log.timer('step 2 [%d/%d], [%d:%d], row = %d'%
94
94
  (istep+1, totstep, row0, row1, nrow), *ti0)
95
95
 
96
+ # A bug in NFS / HDF5 may cause .close() not to
97
+ # flush properly, hanging the calculation. Flush manually
98
+ fswap.flush()
99
+ feri.flush()
100
+
96
101
  fswap.close()
97
102
  feri.close()
98
103
  log.timer('cholesky_eri', *time0)
@@ -163,6 +168,7 @@ def cholesky_eri_b(mol, erifile, auxbasis='weigend+etb', dataname='j3c',
163
168
  # cintopt = gto.moleintor.make_cintopt(atm, bas, env, int3c)
164
169
  cintopt = gto.moleintor.make_cintopt(atm, bas, env, int3c)
165
170
  bufs1 = numpy.empty((comp*max([x[2] for x in shranges]),naoaux))
171
+ bufs2 = numpy.empty_like(bufs1)
166
172
 
167
173
  def transform(b):
168
174
  if b.ndim == 3 and b.flags.f_contiguous:
@@ -173,11 +179,16 @@ def cholesky_eri_b(mol, erifile, auxbasis='weigend+etb', dataname='j3c',
173
179
  return lib.dot(low, b)
174
180
 
175
181
  if b.flags.c_contiguous:
176
- b = lib.transpose(b).T
177
- return scipy.linalg.solve_triangular(low, b, lower=True,
182
+ trsm, = scipy.linalg.get_blas_funcs(('trsm',), (low, b))
183
+ return trsm(1.0, low, b.T, lower=True, trans_a = 1, side = 1,
184
+ overwrite_b=True).T
185
+ else:
186
+ return scipy.linalg.solve_triangular(low, b, lower=True,
178
187
  overwrite_b=True, check_finite=False)
179
188
 
180
189
  def process(sh_range):
190
+ nonlocal bufs1, bufs2
191
+ bufs2, bufs1 = bufs1, bufs2
181
192
  bstart, bend, nrow = sh_range
182
193
  shls_slice = (bstart, bend, 0, mol.nbas, mol.nbas, mol.nbas+auxmol.nbas)
183
194
  ints = gto.moleintor.getints3c(int3c, atm, bas, env, shls_slice, comp,
@@ -189,6 +200,7 @@ def cholesky_eri_b(mol, erifile, auxbasis='weigend+etb', dataname='j3c',
189
200
  return dat
190
201
 
191
202
  feri = _create_h5file(erifile, dataname)
203
+
192
204
  for istep, dat in enumerate(lib.map_with_prefetch(process, shranges)):
193
205
  sh_range = shranges[istep]
194
206
  label = '%s/%d'%(dataname,istep)
@@ -204,6 +216,8 @@ def cholesky_eri_b(mol, erifile, auxbasis='weigend+etb', dataname='j3c',
204
216
  istep+1, len(shranges), *sh_range)
205
217
  time1 = log.timer('gen CD eri [%d/%d]' % (istep+1,len(shranges)), *time1)
206
218
  bufs1 = None
219
+ bufs2 = None
220
+ feri.flush()
207
221
  feri.close()
208
222
  return erifile
209
223