pyscf 2.6.2__py3-none-macosx_11_0_arm64.whl → 2.8.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 (360) hide show
  1. pyscf/__init__.py +2 -2
  2. pyscf/adc/__init__.py +3 -8
  3. pyscf/adc/dfadc.py +22 -6
  4. pyscf/adc/radc.py +106 -15
  5. pyscf/adc/radc_amplitudes.py +7 -1
  6. pyscf/adc/radc_ao2mo.py +4 -2
  7. pyscf/adc/radc_ea.py +524 -8
  8. pyscf/adc/radc_ip.py +492 -60
  9. pyscf/adc/radc_ip_cvs.py +4 -2
  10. pyscf/adc/uadc.py +116 -27
  11. pyscf/adc/uadc_amplitudes.py +215 -20
  12. pyscf/adc/uadc_ao2mo.py +30 -9
  13. pyscf/adc/uadc_ea.py +34 -44
  14. pyscf/adc/uadc_ip.py +9 -4
  15. pyscf/adc/uadc_ip_cvs.py +4 -1
  16. pyscf/agf2/__init__.py +2 -2
  17. pyscf/agf2/aux_space.py +1 -1
  18. pyscf/agf2/chkfile.py +1 -1
  19. pyscf/ao2mo/__init__.py +13 -2
  20. pyscf/ao2mo/_ao2mo.py +10 -1
  21. pyscf/ao2mo/incore.py +3 -0
  22. pyscf/ao2mo/nrr_outcore.py +2 -2
  23. pyscf/ao2mo/outcore.py +9 -7
  24. pyscf/ao2mo/r_outcore.py +2 -2
  25. pyscf/cc/__init__.py +21 -3
  26. pyscf/cc/bccd.py +0 -46
  27. pyscf/cc/ccsd.py +29 -13
  28. pyscf/cc/ccsd_rdm.py +6 -1
  29. pyscf/cc/gccsd.py +2 -2
  30. pyscf/cc/uccsd.py +7 -7
  31. pyscf/cc/uccsd_rdm.py +2 -2
  32. pyscf/data/elements.py +1 -1
  33. pyscf/df/__init__.py +2 -1
  34. pyscf/df/addons.py +79 -51
  35. pyscf/df/autoaux.py +195 -0
  36. pyscf/df/df.py +5 -1
  37. pyscf/df/df_jk.py +27 -25
  38. pyscf/df/grad/casscf.py +0 -41
  39. pyscf/df/grad/rhf.py +31 -1
  40. pyscf/df/hessian/rhf.py +2 -10
  41. pyscf/df/hessian/rks.py +1 -7
  42. pyscf/df/hessian/uhf.py +3 -13
  43. pyscf/df/hessian/uks.py +1 -8
  44. pyscf/df/incore.py +18 -6
  45. pyscf/df/outcore.py +6 -6
  46. pyscf/dft/dks.py +1 -1
  47. pyscf/dft/gks.py +25 -21
  48. pyscf/dft/libxc.py +91 -645
  49. pyscf/dft/numint.py +40 -19
  50. pyscf/dft/radi.py +48 -7
  51. pyscf/dft/rks.py +29 -25
  52. pyscf/dft/roks.py +7 -1
  53. pyscf/dft/uks.py +34 -25
  54. pyscf/dft/xc_deriv.py +1 -1
  55. pyscf/dft/xcfun.py +53 -2
  56. pyscf/eph/eph_fd.py +1 -1
  57. pyscf/eph/rhf.py +6 -36
  58. pyscf/eph/rks.py +0 -4
  59. pyscf/eph/uhf.py +1 -7
  60. pyscf/eph/uks.py +1 -7
  61. pyscf/fci/addons.py +117 -2
  62. pyscf/fci/cistring.py +1 -1
  63. pyscf/fci/direct_nosym.py +3 -3
  64. pyscf/fci/direct_spin0_symm.py +22 -43
  65. pyscf/fci/direct_spin1.py +65 -10
  66. pyscf/fci/direct_spin1_symm.py +49 -14
  67. pyscf/fci/direct_uhf.py +4 -4
  68. pyscf/fci/selected_ci_symm.py +1 -1
  69. pyscf/grad/ccsd.py +3 -7
  70. pyscf/grad/ccsd_slow.py +2 -3
  71. pyscf/grad/lagrange.py +11 -3
  72. pyscf/grad/mp2.py +13 -4
  73. pyscf/grad/sacasscf.py +1 -1
  74. pyscf/grad/tdrks.py +1 -1
  75. pyscf/grad/uccsd.py +3 -7
  76. pyscf/grad/ump2.py +2 -4
  77. pyscf/gto/basis/__init__.py +17 -4
  78. pyscf/gto/basis/bse.py +68 -15
  79. pyscf/gto/basis/def2-mtzvp.dat +4719 -0
  80. pyscf/gto/basis/def2-mtzvpp.dat +4739 -0
  81. pyscf/gto/basis/dyall-basis/__init__.py +0 -0
  82. pyscf/gto/basis/dyall-basis/dyall_2zp.py +6492 -0
  83. pyscf/gto/basis/dyall-basis/dyall_3zp.py +8343 -0
  84. pyscf/gto/basis/dyall-basis/dyall_4zp.py +10055 -0
  85. pyscf/gto/basis/dyall-basis/dyall_aae2z.py +1818 -0
  86. pyscf/gto/basis/dyall-basis/dyall_aae3z.py +2521 -0
  87. pyscf/gto/basis/dyall-basis/dyall_aae4z.py +3351 -0
  88. pyscf/gto/basis/dyall-basis/dyall_acv2z.py +1790 -0
  89. pyscf/gto/basis/dyall-basis/dyall_acv3z.py +2417 -0
  90. pyscf/gto/basis/dyall-basis/dyall_acv4z.py +3085 -0
  91. pyscf/gto/basis/dyall-basis/dyall_ae2z.py +6619 -0
  92. pyscf/gto/basis/dyall-basis/dyall_ae3z.py +9027 -0
  93. pyscf/gto/basis/dyall-basis/dyall_ae4z.py +11839 -0
  94. pyscf/gto/basis/dyall-basis/dyall_av2z.py +1742 -0
  95. pyscf/gto/basis/dyall-basis/dyall_av3z.py +2318 -0
  96. pyscf/gto/basis/dyall-basis/dyall_av4z.py +2905 -0
  97. pyscf/gto/basis/dyall-basis/dyall_cv2z.py +6558 -0
  98. pyscf/gto/basis/dyall-basis/dyall_cv3z.py +8767 -0
  99. pyscf/gto/basis/dyall-basis/dyall_cv4z.py +11098 -0
  100. pyscf/gto/basis/dyall-basis/dyall_v2z.py +6472 -0
  101. pyscf/gto/basis/dyall-basis/dyall_v3z.py +8539 -0
  102. pyscf/gto/basis/dyall-basis/dyall_v4z.py +10658 -0
  103. pyscf/gto/basis/ma-def2-qzvp.dat +5959 -0
  104. pyscf/gto/basis/ma-def2-qzvpp.dat +6195 -0
  105. pyscf/gto/basis/ma-def2-svp.dat +3504 -0
  106. pyscf/gto/basis/ma-def2-svpp.dat +3504 -0
  107. pyscf/gto/basis/ma-def2-tzvp.dat +4347 -0
  108. pyscf/gto/basis/ma-def2-tzvpp.dat +4549 -0
  109. pyscf/gto/basis/parse_cp2k.py +8 -7
  110. pyscf/gto/basis/parse_cp2k_pp.py +1 -1
  111. pyscf/gto/basis/parse_nwchem.py +26 -11
  112. pyscf/gto/basis/parse_nwchem_ecp.py +2 -1
  113. pyscf/gto/basis/sap_grasp_large.dat +2438 -0
  114. pyscf/gto/basis/sap_grasp_small.dat +1434 -0
  115. pyscf/gto/eval_gto.py +1 -1
  116. pyscf/gto/ft_ao.py +6 -6
  117. pyscf/gto/mole.py +123 -71
  118. pyscf/gto/moleintor.py +1 -1
  119. pyscf/gw/gw_ac.py +2 -2
  120. pyscf/gw/gw_cd.py +2 -2
  121. pyscf/gw/rpa.py +135 -246
  122. pyscf/gw/ugw_ac.py +2 -2
  123. pyscf/gw/urpa.py +80 -131
  124. pyscf/hessian/rhf.py +30 -128
  125. pyscf/hessian/rks.py +1 -6
  126. pyscf/hessian/uhf.py +28 -138
  127. pyscf/hessian/uks.py +1 -8
  128. pyscf/lib/CMakeLists.txt +6 -2
  129. pyscf/lib/ao2mo/nr_ao2mo.c +1 -1
  130. pyscf/lib/ao2mo/nrr_ao2mo.c +1 -1
  131. pyscf/lib/ao2mo/r_ao2mo.c +1 -1
  132. pyscf/lib/cc/ccsd_pack.c +1 -1
  133. pyscf/lib/cc/ccsd_t.c +6 -6
  134. pyscf/lib/cc/uccsd_t.c +4 -4
  135. pyscf/lib/config.h +0 -1
  136. pyscf/lib/config.h.in +0 -1
  137. pyscf/lib/deps/include/XCFun/XCFunExport.h +1 -0
  138. pyscf/lib/deps/include/xc.h +28 -18
  139. pyscf/lib/deps/include/xc_funcs.h +50 -2
  140. pyscf/lib/deps/include/xc_version.h +3 -3
  141. pyscf/lib/deps/lib/libcint.6.dylib +0 -0
  142. pyscf/lib/deps/lib/{libxc.12.dylib → libxc.15.dylib} +0 -0
  143. pyscf/lib/deps/lib/libxcfun.2.dylib +0 -0
  144. pyscf/lib/dft/grid_common.c +1 -1
  145. pyscf/lib/dft/libxc_itrf.c +10 -7
  146. pyscf/lib/dft/nr_numint_sparse.c +3 -3
  147. pyscf/lib/dft/xcfun_itrf.c +1 -1
  148. pyscf/lib/diis.py +2 -2
  149. pyscf/lib/exceptions.py +6 -0
  150. pyscf/lib/gto/fill_grids_int2c.c +11 -9
  151. pyscf/lib/gto/fill_int2e.c +7 -5
  152. pyscf/lib/gto/fill_r_4c.c +1 -1
  153. pyscf/lib/gto/ft_ao.c +1 -1
  154. pyscf/lib/gto/ft_ao.h +1 -1
  155. pyscf/lib/gto/gto.h +2 -2
  156. pyscf/lib/gto/nr_ecp.c +3 -2
  157. pyscf/lib/libagf2.dylib +0 -0
  158. pyscf/lib/libao2mo.dylib +0 -0
  159. pyscf/lib/libcc.dylib +0 -0
  160. pyscf/lib/libcgto.dylib +0 -0
  161. pyscf/lib/libcvhf.dylib +0 -0
  162. pyscf/lib/libdft.dylib +0 -0
  163. pyscf/lib/libfci.dylib +0 -0
  164. pyscf/lib/libmcscf.dylib +0 -0
  165. pyscf/lib/libmp.dylib +0 -0
  166. pyscf/lib/libnp_helper.dylib +0 -0
  167. pyscf/lib/libpbc.dylib +0 -0
  168. pyscf/lib/libri.dylib +0 -0
  169. pyscf/lib/libxc_itrf.dylib +0 -0
  170. pyscf/lib/libxcfun_itrf.dylib +0 -0
  171. pyscf/lib/linalg_helper.py +117 -198
  172. pyscf/lib/logger.py +2 -1
  173. pyscf/lib/mcscf/fci_contract.c +10 -3
  174. pyscf/lib/misc.py +63 -22
  175. pyscf/lib/mp/CMakeLists.txt +22 -0
  176. pyscf/lib/mp/mp2.c +518 -0
  177. pyscf/lib/mp/mp2.h +44 -0
  178. pyscf/lib/np_helper/CMakeLists.txt +1 -1
  179. pyscf/lib/np_helper/imatcopy.c +360 -0
  180. pyscf/lib/np_helper/np_helper.c +94 -0
  181. pyscf/lib/np_helper/np_helper.h +26 -0
  182. pyscf/lib/numpy_helper.py +195 -11
  183. pyscf/lib/pbc/nr_direct.c +2 -7
  184. pyscf/lib/pbc/nr_ecp.c +10 -3
  185. pyscf/lib/pbc/pbc.h +1 -1
  186. pyscf/lib/vhf/fblas.h +3 -0
  187. pyscf/lib/vhf/nr_sgx_direct.c +8 -6
  188. pyscf/lib/vhf/nr_sr_vhf.c +8 -12
  189. pyscf/lib/vhf/optimizer.c +2 -2
  190. pyscf/lib/vhf/rkb_screen.c +139 -0
  191. pyscf/lo/iao.py +1 -1
  192. pyscf/lo/ibo.py +3 -3
  193. pyscf/lo/pipek_jacobi.py +1 -1
  194. pyscf/mcscf/__init__.py +2 -2
  195. pyscf/mcscf/addons.py +3 -3
  196. pyscf/mcscf/apc.py +2 -2
  197. pyscf/mcscf/casci.py +13 -7
  198. pyscf/mcscf/chkfile.py +69 -41
  199. pyscf/mcscf/dmet_cas.py +2 -2
  200. pyscf/mcscf/mc1step.py +72 -44
  201. pyscf/mcscf/newton_casscf.py +5 -5
  202. pyscf/mcscf/ucasci.py +1 -1
  203. pyscf/mcscf/umc1step.py +49 -28
  204. pyscf/md/integrators.py +3 -3
  205. pyscf/mp/__init__.py +1 -0
  206. pyscf/mp/dfmp2.py +498 -59
  207. pyscf/mp/dfmp2_native.py +11 -1
  208. pyscf/mp/dfmp2_slow.py +133 -0
  209. pyscf/mp/dfump2.py +672 -0
  210. pyscf/mp/dfump2_native.py +9 -0
  211. pyscf/mp/dfump2_slow.py +161 -0
  212. pyscf/mp/gmp2.py +6 -47
  213. pyscf/mp/mp2.py +25 -10
  214. pyscf/mp/ump2.py +30 -24
  215. pyscf/pbc/adc/kadc_rhf.py +1 -1
  216. pyscf/pbc/adc/kadc_rhf_amplitudes.py +2 -2
  217. pyscf/pbc/ao2mo/eris.py +1 -1
  218. pyscf/pbc/cc/kccsd_rhf.py +3 -3
  219. pyscf/pbc/cc/kccsd_t_rhf.py +2 -2
  220. pyscf/pbc/ci/kcis_rhf.py +2 -2
  221. pyscf/pbc/df/aft.py +8 -9
  222. pyscf/pbc/df/aft_ao2mo.py +1 -1
  223. pyscf/pbc/df/df.py +85 -12
  224. pyscf/pbc/df/df_jk.py +6 -2
  225. pyscf/pbc/df/fft.py +9 -5
  226. pyscf/pbc/df/fft_ao2mo.py +4 -0
  227. pyscf/pbc/df/fft_jk.py +18 -10
  228. pyscf/pbc/df/ft_ao.py +4 -3
  229. pyscf/pbc/df/gdf_builder.py +5 -4
  230. pyscf/pbc/df/incore.py +2 -2
  231. pyscf/pbc/df/mdf.py +6 -3
  232. pyscf/pbc/df/mdf_jk.py +2 -1
  233. pyscf/pbc/df/outcore.py +10 -10
  234. pyscf/pbc/df/rsdf.py +2 -2
  235. pyscf/pbc/df/rsdf_builder.py +13 -8
  236. pyscf/pbc/df/rsdf_helper.py +6 -6
  237. pyscf/pbc/df/rsdf_jk.py +2 -1
  238. pyscf/pbc/dft/cdft.py +5 -5
  239. pyscf/pbc/dft/gen_grid.py +3 -2
  240. pyscf/pbc/dft/gks.py +14 -3
  241. pyscf/pbc/dft/kgks.py +15 -4
  242. pyscf/pbc/dft/krks.py +28 -10
  243. pyscf/pbc/dft/krks_ksymm.py +21 -9
  244. pyscf/pbc/dft/krkspu.py +1 -30
  245. pyscf/pbc/dft/krkspu_ksymm.py +0 -30
  246. pyscf/pbc/dft/kuks.py +30 -13
  247. pyscf/pbc/dft/kuks_ksymm.py +22 -10
  248. pyscf/pbc/dft/kukspu.py +0 -27
  249. pyscf/pbc/dft/kukspu_ksymm.py +0 -30
  250. pyscf/pbc/dft/multigrid/multigrid.py +36 -33
  251. pyscf/pbc/dft/multigrid/multigrid_pair.py +7 -2
  252. pyscf/pbc/dft/multigrid/pp.py +1 -1
  253. pyscf/pbc/dft/numint.py +56 -31
  254. pyscf/pbc/dft/rks.py +16 -24
  255. pyscf/pbc/dft/uks.py +21 -4
  256. pyscf/pbc/eph/eph_fd.py +1 -1
  257. pyscf/pbc/geomopt/geometric_solver.py +1 -1
  258. pyscf/pbc/gto/_pbcintor.py +1 -0
  259. pyscf/pbc/gto/cell.py +194 -23
  260. pyscf/pbc/gto/ecp.py +12 -12
  261. pyscf/pbc/gto/eval_gto.py +3 -3
  262. pyscf/pbc/gto/neighborlist.py +4 -1
  263. pyscf/pbc/gto/pseudo/pp.py +1 -1
  264. pyscf/pbc/gw/krgw_ac.py +4 -4
  265. pyscf/pbc/gw/krgw_cd.py +4 -4
  266. pyscf/pbc/gw/kugw_ac.py +3 -3
  267. pyscf/pbc/lib/kpts_helper.py +4 -3
  268. pyscf/pbc/lib/linalg_helper.py +1 -1
  269. pyscf/pbc/mp/kmp2.py +1 -1
  270. pyscf/pbc/mpitools/mpi.py +1 -1
  271. pyscf/pbc/scf/_response_functions.py +141 -34
  272. pyscf/pbc/scf/addons.py +15 -11
  273. pyscf/pbc/scf/cphf.py +1 -1
  274. pyscf/pbc/scf/ghf.py +1 -1
  275. pyscf/pbc/scf/hf.py +21 -32
  276. pyscf/pbc/scf/kghf.py +33 -29
  277. pyscf/pbc/scf/khf.py +103 -29
  278. pyscf/pbc/scf/khf_ksymm.py +15 -1
  279. pyscf/pbc/scf/krohf.py +5 -7
  280. pyscf/pbc/scf/kuhf.py +54 -23
  281. pyscf/pbc/scf/kuhf_ksymm.py +1 -1
  282. pyscf/pbc/scf/rsjk.py +14 -10
  283. pyscf/pbc/scf/scfint.py +1 -1
  284. pyscf/pbc/scf/stability.py +27 -15
  285. pyscf/pbc/scf/uhf.py +3 -1
  286. pyscf/pbc/symm/symmetry.py +2 -2
  287. pyscf/pbc/tdscf/krhf.py +238 -154
  288. pyscf/pbc/tdscf/krks.py +1 -45
  289. pyscf/pbc/tdscf/kuhf.py +319 -171
  290. pyscf/pbc/tdscf/kuks.py +0 -56
  291. pyscf/pbc/tdscf/rhf.py +116 -3
  292. pyscf/pbc/tdscf/rks.py +2 -1
  293. pyscf/pbc/tdscf/uhf.py +214 -1
  294. pyscf/pbc/tdscf/uks.py +2 -1
  295. pyscf/pbc/tools/k2gamma.py +20 -6
  296. pyscf/pbc/tools/lattice.py +3 -3
  297. pyscf/pbc/tools/pbc.py +111 -91
  298. pyscf/pbc/tools/pyscf_ase.py +0 -1
  299. pyscf/pbc/tools/pywannier90.py +1 -1
  300. pyscf/qmmm/mm_mole.py +1 -1
  301. pyscf/scf/_response_functions.py +87 -46
  302. pyscf/scf/_vhf.py +15 -10
  303. pyscf/scf/addons.py +29 -15
  304. pyscf/scf/cphf.py +14 -52
  305. pyscf/scf/dhf.py +121 -38
  306. pyscf/scf/dispersion.py +10 -9
  307. pyscf/scf/ghf.py +25 -13
  308. pyscf/scf/ghf_symm.py +2 -2
  309. pyscf/scf/hf.py +262 -30
  310. pyscf/scf/rohf.py +37 -5
  311. pyscf/scf/stability.py +142 -112
  312. pyscf/scf/ucphf.py +21 -16
  313. pyscf/scf/uhf.py +104 -61
  314. pyscf/sgx/sgx.py +1 -1
  315. pyscf/sgx/sgx_jk.py +4 -4
  316. pyscf/solvent/__init__.py +2 -2
  317. pyscf/solvent/_attach_solvent.py +2 -0
  318. pyscf/solvent/_ddcosmo_tdscf_grad.py +1 -1
  319. pyscf/solvent/cosmors.py +366 -0
  320. pyscf/solvent/ddcosmo.py +1 -1
  321. pyscf/solvent/pcm.py +4 -4
  322. pyscf/solvent/pol_embed.py +1 -1
  323. pyscf/solvent/smd.py +5 -3
  324. pyscf/soscf/ciah.py +3 -11
  325. pyscf/soscf/newton_ah.py +5 -2
  326. pyscf/symm/__init__.py +1 -1
  327. pyscf/symm/addons.py +5 -5
  328. pyscf/symm/geom.py +1 -5
  329. pyscf/tdscf/_lr_eig.py +1002 -0
  330. pyscf/tdscf/dhf.py +84 -87
  331. pyscf/tdscf/dks.py +0 -4
  332. pyscf/tdscf/ghf.py +139 -127
  333. pyscf/tdscf/gks.py +27 -25
  334. pyscf/tdscf/rhf.py +194 -147
  335. pyscf/tdscf/rks.py +26 -22
  336. pyscf/tdscf/uhf.py +166 -118
  337. pyscf/tdscf/uks.py +32 -31
  338. pyscf/tools/fcidump.py +3 -0
  339. pyscf/tools/qcschema.py +265 -0
  340. pyscf/x2c/sfx2c1e.py +1 -1
  341. pyscf/x2c/tdscf.py +41 -41
  342. pyscf/x2c/x2c.py +15 -11
  343. {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/METADATA +39 -36
  344. {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/NOTICE +14 -1
  345. {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/RECORD +348 -316
  346. {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/WHEEL +1 -1
  347. pyscf/dft/gen_libxc_param.py +0 -35
  348. pyscf/dft/gen_xcfun_param.py +0 -209
  349. pyscf/pbc/tdscf/kproxy.py +0 -189
  350. pyscf/pbc/tdscf/kproxy_supercell.py +0 -664
  351. pyscf/pbc/tdscf/krhf_slow.py +0 -300
  352. pyscf/pbc/tdscf/krhf_slow_gamma.py +0 -175
  353. pyscf/pbc/tdscf/krhf_slow_supercell.py +0 -250
  354. pyscf/pbc/tdscf/proxy.py +0 -39
  355. pyscf/pbc/tdscf/rhf_slow.py +0 -35
  356. pyscf/tdscf/common_slow.py +0 -799
  357. pyscf/tdscf/proxy.py +0 -258
  358. pyscf/tdscf/rhf_slow.py +0 -181
  359. {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/LICENSE +0 -0
  360. {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/top_level.txt +0 -0
@@ -64,34 +64,64 @@ def _gen_rhf_response(mf, mo_coeff=None, mo_occ=None,
64
64
  if hermi == 2:
65
65
  v1 = numpy.zeros_like(dm1)
66
66
  else:
67
+ assert kshift == 0
67
68
  v1 = ni.nr_rks_fxc(cell, mf.grids, mf.xc, dm0, dm1, 0, hermi,
68
69
  rho0, vxc, fxc, kpts, max_memory=max_memory)
69
70
  if hybrid:
70
- if hermi != 2:
71
+ if omega == 0:
72
+ vj, vk = _get_jk(mf, cell, dm1, hermi, kpts, kshift)
73
+ vk *= hyb
74
+ elif alpha == 0: # LR=0, only SR exchange
75
+ vj = _get_j(mf, cell, dm1, hermi, kpts, kshift)
76
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=-omega)
77
+ vk *= hyb
78
+ elif hyb == 0: # SR=0, only LR exchange
79
+ vj = _get_j(mf, cell, dm1, hermi, kpts, kshift)
80
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega)
81
+ vk *= alpha
82
+ else: # SR and LR exchange with different ratios
71
83
  vj, vk = _get_jk(mf, cell, dm1, hermi, kpts, kshift)
72
- v1 += vj - .5 * hyb * vk
84
+ vk *= hyb
85
+ vk += _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega) * (alpha-hyb)
86
+ if hermi != 2:
87
+ v1 += vj - .5 * vk
73
88
  else:
74
- v1 -= .5 * hyb * _get_k(mf, cell, dm1, hermi, kpts, kshift)
89
+ v1 += -.5 * vk
75
90
  elif hermi != 2:
76
91
  v1 += _get_j(mf, cell, dm1, hermi, kpts, kshift)
77
92
  return v1
78
93
 
79
94
  elif singlet:
95
+ fxc *= .5
80
96
  def vind(dm1, kshift=0):
81
97
  if hermi == 2:
82
98
  v1 = numpy.zeros_like(dm1)
83
99
  else:
100
+ assert kshift == 0
84
101
  # nr_rks_fxc_st requires alpha of dm1
85
102
  v1 = numint.nr_rks_fxc_st(ni, cell, mf.grids, mf.xc, dm0, dm1, 0,
86
103
  True, rho0, vxc, fxc, kpts,
87
104
  max_memory=max_memory)
88
- v1 *= .5
89
105
  if hybrid:
90
- if hermi != 2:
106
+ if omega == 0:
91
107
  vj, vk = _get_jk(mf, cell, dm1, hermi, kpts, kshift)
92
- v1 += vj - .5 * hyb * vk
108
+ vk *= hyb
109
+ elif alpha == 0: # LR=0, only SR exchange
110
+ vj = _get_j(mf, cell, dm1, hermi, kpts, kshift)
111
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=-omega)
112
+ vk *= hyb
113
+ elif hyb == 0: # SR=0, only LR exchange
114
+ vj = _get_j(mf, cell, dm1, hermi, kpts, kshift)
115
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega)
116
+ vk *= alpha
117
+ else: # SR and LR exchange with different ratios
118
+ vj, vk = _get_jk(mf, cell, dm1, hermi, kpts, kshift)
119
+ vk *= hyb
120
+ vk += _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega) * (alpha-hyb)
121
+ if hermi != 2:
122
+ v1 += vj - .5 * vk
93
123
  else:
94
- v1 -= .5 * hyb * _get_k(mf, cell, dm1, hermi, kpts, kshift)
124
+ v1 += -.5 * vk
95
125
  elif hermi != 2:
96
126
  v1 += _get_j(mf, cell, dm1, hermi, kpts, kshift)
97
127
  return v1
@@ -100,13 +130,23 @@ def _gen_rhf_response(mf, mo_coeff=None, mo_occ=None,
100
130
  if hermi == 2:
101
131
  v1 = numpy.zeros_like(dm1)
102
132
  else:
133
+ assert kshift == 0
103
134
  # nr_rks_fxc_st requires alpha of dm1
104
135
  v1 = numint.nr_rks_fxc_st(ni, cell, mf.grids, mf.xc, dm0, dm1, 0,
105
136
  False, rho0, vxc, fxc, kpts,
106
137
  max_memory=max_memory)
107
138
  v1 *= .5
108
139
  if hybrid:
109
- v1 += -.5 * hyb * _get_k(mf, cell, dm1, hermi, kpts, kshift)
140
+ if omega == 0:
141
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift) * hyb
142
+ elif alpha == 0: # LR=0, only SR exchange
143
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=-omega) * hyb
144
+ elif hyb == 0: # SR=0, only LR exchange
145
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega) * alpha
146
+ else: # SR and LR exchange with different ratios
147
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift) * hyb
148
+ vk += _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega) * (alpha-hyb)
149
+ v1 += -.5 * vk
110
150
  return v1
111
151
 
112
152
  else: # HF
@@ -154,6 +194,7 @@ def _gen_uhf_response(mf, mo_coeff=None, mo_occ=None,
154
194
  if hermi == 2:
155
195
  v1 = numpy.zeros_like(dm1)
156
196
  else:
197
+ assert kshift == 0
157
198
  v1 = ni.nr_uks_fxc(cell, mf.grids, mf.xc, dm0, dm1, 0, hermi,
158
199
  rho0, vxc, fxc, kpts, max_memory=max_memory)
159
200
  if not hybrid:
@@ -161,11 +202,25 @@ def _gen_uhf_response(mf, mo_coeff=None, mo_occ=None,
161
202
  vj = _get_j(mf, cell, dm1, hermi, kpts, kshift)
162
203
  v1 += vj[0] + vj[1]
163
204
  else:
164
- if with_j:
205
+ if omega == 0:
206
+ vj, vk = _get_jk(mf, cell, dm1, hermi, kpts, kshift)
207
+ vk *= hyb
208
+ elif alpha == 0: # LR=0, only SR exchange
209
+ vj = _get_j(mf, cell, dm1, hermi, kpts, kshift)
210
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=-omega)
211
+ vk *= hyb
212
+ elif hyb == 0: # SR=0, only LR exchange
213
+ vj = _get_j(mf, cell, dm1, hermi, kpts, kshift)
214
+ vk = _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega)
215
+ vk *= alpha
216
+ else: # SR and LR exchange with different ratios
165
217
  vj, vk = _get_jk(mf, cell, dm1, hermi, kpts, kshift)
166
- v1 += vj[0] + vj[1] - vk * hyb
218
+ vk *= hyb
219
+ vk += _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=omega) * (alpha-hyb)
220
+ if with_j:
221
+ v1 += vj[0] + vj[1] - vk
167
222
  else:
168
- v1 -= hyb * _get_k(mf, cell, dm1, hermi, kpts, kshift)
223
+ v1 -= vk
169
224
  return v1
170
225
 
171
226
  elif with_j:
@@ -187,7 +242,8 @@ def _gen_ghf_response(mf, mo_coeff=None, mo_occ=None,
187
242
  '''
188
243
  raise NotImplementedError
189
244
 
190
- def _get_jk_kshift(mf, dm_kpts, hermi, kpts, kshift, with_j=True, with_k=True):
245
+ def _get_jk_kshift(mf, dm_kpts, hermi, kpts, kshift, with_j=True, with_k=True,
246
+ omega=None):
191
247
  from pyscf.pbc.df.df_jk import get_j_kpts_kshift, get_k_kpts_kshift
192
248
  vj = vk = None
193
249
  if with_j:
@@ -196,19 +252,23 @@ def _get_jk_kshift(mf, dm_kpts, hermi, kpts, kshift, with_j=True, with_k=True):
196
252
  vk = get_k_kpts_kshift(mf.with_df, dm_kpts, kshift, hermi=hermi, kpts=kpts,
197
253
  exxdiv=mf.exxdiv)
198
254
  return vj, vk
199
- def _get_jk(mf, cell, dm1, hermi, kpts, kshift, with_j=True, with_k=True):
255
+ def _get_jk(mf, cell, dm1, hermi, kpts, kshift, with_j=True, with_k=True, omega=None):
200
256
  from pyscf.pbc import df
201
257
  if kshift == 0:
202
- return mf.get_jk(cell, dm1, hermi=hermi, kpts=kpts, with_j=with_j, with_k=with_k)
258
+ return mf.get_jk(cell, dm1, hermi=hermi, kpts=kpts,
259
+ with_j=with_j, with_k=with_k, omega=omega)
260
+ elif omega is not None and omega != 0:
261
+ raise NotImplementedError
203
262
  elif mf.rsjk is not None or not isinstance(mf.with_df, df.df.DF):
204
263
  lib.logger.error(mf, 'Non-zero kshift is only supported by GDF/RSDF.')
205
264
  raise NotImplementedError
206
265
  else:
207
- return _get_jk_kshift(mf, dm1, hermi, kpts, kshift, with_j=with_j, with_k=with_k)
208
- def _get_j(mf, cell, dm1, hermi, kpts, kshift):
209
- return _get_jk(mf, cell, dm1, hermi, kpts, kshift, True, False)[0]
210
- def _get_k(mf, cell, dm1, hermi, kpts, kshift):
211
- return _get_jk(mf, cell, dm1, hermi, kpts, kshift, False, True)[1]
266
+ return _get_jk_kshift(mf, dm1, hermi, kpts, kshift,
267
+ with_j=with_j, with_k=with_k, omega=omega)
268
+ def _get_j(mf, cell, dm1, hermi, kpts, kshift, omega=None):
269
+ return _get_jk(mf, cell, dm1, hermi, kpts, kshift, True, False, omega)[0]
270
+ def _get_k(mf, cell, dm1, hermi, kpts, kshift, omega=None):
271
+ return _get_jk(mf, cell, dm1, hermi, kpts, kshift, False, True, omega)[1]
212
272
 
213
273
 
214
274
  khf.KRHF.gen_response = _gen_rhf_response
@@ -233,8 +293,6 @@ def _gen_rhf_response_gam(mf, mo_coeff=None, mo_occ=None,
233
293
 
234
294
  omega, alpha, hyb = ni.rsh_and_hybrid_coeff(mf.xc, spin=cell.spin)
235
295
  hybrid = ni.libxc.is_hybrid_xc(mf.xc)
236
- if omega != 0: # For range separated Coulomb
237
- raise NotImplementedError
238
296
 
239
297
  if not hybrid and isinstance(mf.with_df, multigrid.MultiGridFFTDF):
240
298
  dm0 = mf.make_rdm1(mo_coeff, mo_occ)
@@ -261,16 +319,31 @@ def _gen_rhf_response_gam(mf, mo_coeff=None, mo_occ=None,
261
319
  v1 = ni.nr_rks_fxc(cell, mf.grids, mf.xc, dm0, dm1, 0, hermi,
262
320
  rho0, vxc, fxc, kpt, max_memory=max_memory)
263
321
  if hybrid:
322
+ if omega == 0:
323
+ vj, vk = mf.get_jk(cell, dm1, hermi, kpt=kpt)
324
+ vk *= hyb
325
+ elif alpha == 0: # LR=0, only SR exchange
326
+ vj = mf.get_j(cell, dm1, hermi, kpt=kpt)
327
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=-omega)
328
+ vk *= hyb
329
+ elif hyb == 0: # SR=0, only LR exchange
330
+ vj = mf.get_j(cell, dm1, hermi, kpt=kpt)
331
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega)
332
+ vk *= alpha
333
+ else: # SR and LR exchange with different ratios
334
+ vj, vk = mf.get_jk(cell, dm1, hermi, kpt=kpt)
335
+ vk *= hyb
336
+ vk += mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega) * (alpha-hyb)
264
337
  if hermi != 2:
265
- vj, vk = mf.get_jk(cell, dm1, hermi=hermi, kpt=kpt)
266
- v1 += vj - .5 * hyb * vk
338
+ v1 += vj - .5 * vk
267
339
  else:
268
- v1 -= .5 * hyb * mf.get_k(cell, dm1, hermi=hermi, kpt=kpt)
340
+ v1 += -.5 * vk
269
341
  elif hermi != 2:
270
342
  v1 += mf.get_j(cell, dm1, hermi=hermi, kpt=kpt)
271
343
  return v1
272
344
 
273
345
  elif singlet:
346
+ fxc *= .5
274
347
  def vind(dm1):
275
348
  if hermi == 2:
276
349
  v1 = numpy.zeros_like(dm1)
@@ -279,13 +352,26 @@ def _gen_rhf_response_gam(mf, mo_coeff=None, mo_occ=None,
279
352
  v1 = numint.nr_rks_fxc_st(ni, cell, mf.grids, mf.xc, dm0, dm1, 0,
280
353
  True, rho0, vxc, fxc, kpt,
281
354
  max_memory=max_memory)
282
- v1 *= .5
283
355
  if hybrid:
356
+ if omega == 0:
357
+ vj, vk = mf.get_jk(cell, dm1, hermi, kpt=kpt)
358
+ vk *= hyb
359
+ elif alpha == 0: # LR=0, only SR exchange
360
+ vj = mf.get_j(cell, dm1, hermi, kpt=kpt)
361
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=-omega)
362
+ vk *= hyb
363
+ elif hyb == 0: # SR=0, only LR exchange
364
+ vj = mf.get_j(cell, dm1, hermi, kpt=kpt)
365
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega)
366
+ vk *= alpha
367
+ else: # SR and LR exchange with different ratios
368
+ vj, vk = mf.get_jk(cell, dm1, hermi, kpt=kpt)
369
+ vk *= hyb
370
+ vk += mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega) * (alpha-hyb)
284
371
  if hermi != 2:
285
- vj, vk = mf.get_jk(cell, dm1, hermi=hermi, kpt=kpt)
286
- v1 += vj - .5 * hyb * vk
372
+ v1 += vj - .5 * vk
287
373
  else:
288
- v1 -= .5 * hyb * mf.get_k(cell, dm1, hermi=hermi, kpt=kpt)
374
+ v1 += -.5 * vk
289
375
  elif hermi != 2:
290
376
  v1 += mf.get_j(cell, dm1, hermi=hermi, kpt=kpt)
291
377
  return v1
@@ -300,7 +386,16 @@ def _gen_rhf_response_gam(mf, mo_coeff=None, mo_occ=None,
300
386
  max_memory=max_memory)
301
387
  v1 *= .5
302
388
  if hybrid:
303
- v1 += -.5 * hyb * mf.get_k(cell, dm1, hermi=hermi, kpt=kpt)
389
+ if omega == 0:
390
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt) * hyb
391
+ elif alpha == 0: # LR=0, only SR exchange
392
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=-omega) * hyb
393
+ elif hyb == 0: # SR=0, only LR exchange
394
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega) * alpha
395
+ else: # SR and LR exchange with different ratios
396
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt) * hyb
397
+ vk += mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega) * (alpha-hyb)
398
+ v1 += -.5 * vk
304
399
  return v1
305
400
 
306
401
  else: # HF
@@ -329,8 +424,6 @@ def _gen_uhf_response_gam(mf, mo_coeff=None, mo_occ=None,
329
424
 
330
425
  omega, alpha, hyb = ni.rsh_and_hybrid_coeff(mf.xc, spin=cell.spin)
331
426
  hybrid = ni.libxc.is_hybrid_xc(mf.xc)
332
- if omega != 0: # For range separated Coulomb
333
- raise NotImplementedError
334
427
 
335
428
  if not hybrid and isinstance(mf.with_df, multigrid.MultiGridFFTDF):
336
429
  dm0 = mf.make_rdm1(mo_coeff, mo_occ)
@@ -355,11 +448,25 @@ def _gen_uhf_response_gam(mf, mo_coeff=None, mo_occ=None,
355
448
  vj = mf.get_j(cell, dm1, hermi=hermi, kpt=kpt)
356
449
  v1 += vj[0] + vj[1]
357
450
  else:
451
+ if omega == 0:
452
+ vj, vk = mf.get_jk(cell, dm1, hermi, kpt=kpt)
453
+ vk *= hyb
454
+ elif alpha == 0: # LR=0, only SR exchange
455
+ vj = mf.get_j(cell, dm1, hermi, kpt=kpt)
456
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=-omega)
457
+ vk *= hyb
458
+ elif hyb == 0: # SR=0, only LR exchange
459
+ vj = mf.get_j(cell, dm1, hermi, kpt=kpt)
460
+ vk = mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega)
461
+ vk *= alpha
462
+ else: # SR and LR exchange with different ratios
463
+ vj, vk = mf.get_jk(cell, dm1, hermi, kpt=kpt)
464
+ vk *= hyb
465
+ vk += mf.get_k(cell, dm1, hermi, kpt=kpt, omega=omega) * (alpha-hyb)
358
466
  if with_j:
359
- vj, vk = mf.get_jk(cell, dm1, hermi=hermi, kpt=kpt)
360
- v1 += vj[0] + vj[1] - vk * hyb
467
+ v1 += vj[0] + vj[1] - vk
361
468
  else:
362
- v1 -= hyb * mf.get_k(cell, dm1, hermi=hermi, kpt=kpt)
469
+ v1 -= vk
363
470
  return v1
364
471
 
365
472
  elif with_j:
pyscf/pbc/scf/addons.py CHANGED
@@ -91,13 +91,17 @@ class _SmearingKSCF(mol_addons._SmearingSCF):
91
91
 
92
92
  This is a k-point version of scf.hf.SCF.get_occ
93
93
  '''
94
+ from pyscf.pbc import scf
94
95
  if (self.sigma == 0) or (not self.sigma) or (not self.smearing_method):
95
96
  mo_occ_kpts = super().get_occ(mo_energy_kpts, mo_coeff_kpts)
96
97
  return mo_occ_kpts
97
98
 
98
99
  is_uhf = self.istype('KUHF')
99
100
  is_rhf = self.istype('KRHF')
100
- is_rohf = self.istype('KROHF')
101
+ if isinstance(self, scf.krohf.KROHF):
102
+ # ROHF leads to two Fock matrices. It's not clear how to define the
103
+ # Roothaan effective Fock matrix from the two.
104
+ raise NotImplementedError('Smearing-ROHF')
101
105
 
102
106
  sigma = self.sigma
103
107
  if self.smearing_method.lower() == 'fermi':
@@ -112,9 +116,7 @@ class _SmearingKSCF(mol_addons._SmearingSCF):
112
116
  else:
113
117
  nkpts = len(kpts)
114
118
 
115
- if self.fix_spin and (is_uhf or is_rohf): # spin separated fermi level
116
- if is_rohf: # treat rohf as uhf
117
- mo_energy_kpts = (mo_energy_kpts, mo_energy_kpts)
119
+ if self.fix_spin and is_uhf: # spin separated fermi level
118
120
  mo_es = [numpy.hstack(mo_energy_kpts[0]),
119
121
  numpy.hstack(mo_energy_kpts[1])]
120
122
  nocc = self.nelec
@@ -150,8 +152,6 @@ class _SmearingKSCF(mol_addons._SmearingSCF):
150
152
  mo_occ_kpts =(_partition_occ(mo_occs[0], mo_energy_kpts[0]),
151
153
  _partition_occ(mo_occs[1], mo_energy_kpts[1]))
152
154
  tools.print_mo_energy_occ_kpts(self, mo_energy_kpts, mo_occ_kpts, True)
153
- if is_rohf:
154
- mo_occ_kpts = numpy.array(mo_occ_kpts, dtype=numpy.float64).sum(axis=0)
155
155
  else:
156
156
  nocc = nelectron = self.mol.tot_electrons(nkpts)
157
157
  if is_uhf:
@@ -488,15 +488,19 @@ def convert_to_kscf(mf, out=None):
488
488
  }
489
489
  mf = mol_addons._object_without_soscf(mf, known_cls, False)
490
490
  if mf.mo_energy is not None:
491
- if mf.istype('UHF'):
492
- mf.mo_occ = mf.mo_occ[:,numpy.newaxis]
493
- mf.mo_coeff = mf.mo_coeff[:,numpy.newaxis]
494
- mf.mo_energy = mf.mo_energy[:,numpy.newaxis]
491
+ if isinstance(mf, scf.kuhf.KUHF):
492
+ mf.mo_occ = mf.mo_occ[:, numpy.newaxis]
493
+ mf.mo_coeff = mf.mo_coeff[:, numpy.newaxis]
494
+ mf.mo_energy = mf.mo_energy[:, numpy.newaxis]
495
495
  else:
496
496
  mf.mo_occ = mf.mo_occ[numpy.newaxis]
497
497
  mf.mo_coeff = mf.mo_coeff[numpy.newaxis]
498
498
  mf.mo_energy = mf.mo_energy[numpy.newaxis]
499
499
 
500
+ if hasattr(mf, '_numint'):
501
+ kpts = getattr(mf.kpts, 'kpts', mf.kpts)
502
+ mf._numint = dft.numint.KNumInt(kpts)
503
+
500
504
  if out is None:
501
505
  return mf
502
506
 
@@ -522,7 +526,7 @@ def mo_energy_with_exxdiv_none(mf, mo_coeff=None):
522
526
  fockao = mf.get_fock(vhf=vhf, dm=dm)
523
527
 
524
528
  def _get_moe1(C, fao):
525
- return lib.einsum('pi,pq,qi->i', C.conj(), fao, C)
529
+ return lib.einsum('pi,pq,qi->i', C.conj(), fao, C).real
526
530
  def _get_moek(kC, kfao):
527
531
  return [_get_moe1(C, fao) for C,fao in zip(kC, kfao)]
528
532
 
pyscf/pbc/scf/cphf.py CHANGED
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  '''
20
- Restricted coupled pertubed Hartree-Fock solver
20
+ Restricted coupled perturbed Hartree-Fock solver
21
21
  Modified from pyscf.scf.cphf
22
22
  '''
23
23
 
pyscf/pbc/scf/ghf.py CHANGED
@@ -117,7 +117,7 @@ class GHF(pbchf.SCF):
117
117
  _finalize = mol_ghf.GHF._finalize
118
118
  analyze = lib.invalid_method('analyze')
119
119
  mulliken_pop = lib.invalid_method('mulliken_pop')
120
- mulliken_meta = lib.invalid_method('mulliken_meta')
120
+ mulliken_meta = mol_ghf.GHF.mulliken_meta
121
121
  spin_square = mol_ghf.GHF.spin_square
122
122
  stability = mol_ghf.GHF.stability
123
123
 
pyscf/pbc/scf/hf.py CHANGED
@@ -35,7 +35,6 @@ from pyscf.lib import logger
35
35
  from pyscf.data import nist
36
36
  from pyscf.pbc import gto
37
37
  from pyscf.pbc import tools
38
- from pyscf.pbc.gto import ecp
39
38
  from pyscf.pbc.gto.pseudo import get_pp
40
39
  from pyscf.pbc.scf import addons
41
40
  from pyscf.pbc import df
@@ -83,6 +82,7 @@ def get_hcore(cell, kpt=np.zeros(3)):
83
82
  else:
84
83
  hcore += get_nuc(cell, kpt)
85
84
  if len(cell._ecpbas) > 0:
85
+ from pyscf.pbc.gto import ecp
86
86
  hcore += ecp.ecp_int(cell, kpt)
87
87
  return hcore
88
88
 
@@ -246,7 +246,7 @@ def dip_moment(cell, dm, unit='Debye', verbose=logger.NOTE,
246
246
  # With the optimal origin of the unti cell, the net dipole in the unit
247
247
  # cell should be strictly zero. However, the integral grids are often not
248
248
  # enough to produce the zero dipole. Errors are caused by the sub-optimal
249
- # origin and the numerial integration.
249
+ # origin and the numerical integration.
250
250
  if origin is None:
251
251
  origin = _search_dipole_gauge_origin(cell, grids, rho, log)
252
252
 
@@ -540,40 +540,16 @@ class SCF(mol_hf.SCF):
540
540
 
541
541
  @property
542
542
  def kpts(self):
543
- if 'kpts' in self.__dict__:
544
- # To handle the attribute kpt loaded from chkfile
545
- self.kpts = self.__dict__.pop('kpts')
546
543
  return self.with_df.kpts
547
- @kpts.setter
548
- def kpts(self, x):
549
- self.with_df.kpts = np.reshape(x, (-1,3))
550
- if self.rsjk:
551
- self.rsjk.kpts = self.with_df.kpts
552
544
 
553
545
  def build(self, cell=None):
554
546
  # To handle the attribute kpt or kpts loaded from chkfile
555
- if 'kpts' in self.__dict__:
556
- self.kpts = self.__dict__.pop('kpts')
557
- elif 'kpt' in self.__dict__:
547
+ if 'kpt' in self.__dict__:
558
548
  self.kpt = self.__dict__.pop('kpt')
559
549
 
560
- # "vcut_ws" precomputing is triggered by pbc.tools.pbc.get_coulG
561
- #if self.exxdiv == 'vcut_ws':
562
- # if self.exx_built is False:
563
- # self.precompute_exx()
564
- # logger.info(self, 'WS alpha = %s', self.exx_alpha)
565
-
566
- kpts = self.kpts
567
550
  if self.rsjk:
568
551
  if not np.all(self.rsjk.kpts == self.kpt):
569
- self.rsjk = self.rsjk.__class__(cell, kpts)
570
-
571
- # for GDF and MDF
572
- with_df = self.with_df
573
- if len(kpts) > 1 and getattr(with_df, '_j_only', False):
574
- logger.warn(self, 'df.j_only cannot be used with k-point HF')
575
- with_df._j_only = False
576
- with_df.reset()
552
+ self.rsjk = self.rsjk.__class__(cell, self.kpt)
577
553
 
578
554
  if self.verbose >= logger.WARN:
579
555
  self.check_sanity()
@@ -638,6 +614,7 @@ class SCF(mol_hf.SCF):
638
614
  else:
639
615
  nuc = self.with_df.get_nuc(kpt)
640
616
  if len(cell._ecpbas) > 0:
617
+ from pyscf.pbc.gto import ecp
641
618
  nuc += ecp.ecp_int(cell, kpt)
642
619
  return nuc + cell.pbc_intor('int1e_kin', 1, 1, kpt)
643
620
 
@@ -680,7 +657,7 @@ class SCF(mol_hf.SCF):
680
657
 
681
658
  if with_k and self.exxdiv == 'ewald':
682
659
  from pyscf.pbc.df.df_jk import _ewald_exxdiv_for_G0
683
- # G=0 is not inculded in the ._eri integrals
660
+ # G=0 is not included in the ._eri integrals
684
661
  _ewald_exxdiv_for_G0(self.cell, kpt, dm.reshape(-1,nao,nao),
685
662
  vk.reshape(-1,nao,nao))
686
663
  elif self.rsjk:
@@ -786,9 +763,21 @@ class SCF(mol_hf.SCF):
786
763
  def from_chk(self, chk=None, project=None, kpt=None):
787
764
  return self.init_guess_by_chkfile(chk, project, kpt)
788
765
 
789
- def dump_chk(self, envs):
790
- if self.chkfile:
791
- mol_hf.SCF.dump_chk(self, envs)
766
+ def dump_chk(self, envs_or_file):
767
+ '''Serialize the SCF object and save it to the specified chkfile.
768
+
769
+ Args:
770
+ envs_or_file:
771
+ If this argument is a file path, the serialized SCF object is
772
+ saved to the file specified by this argument.
773
+ If this attribute is a dict (created by locals()), the necessary
774
+ variables are saved to the file specified by the attribute mf.chkfile.
775
+ '''
776
+ mol_hf.SCF.dump_chk(self, envs_or_file)
777
+ if isinstance(envs_or_file, str):
778
+ with lib.H5FileWrap(envs_or_file, 'a') as fh5:
779
+ fh5['scf/kpt'] = self.kpt
780
+ elif self.chkfile:
792
781
  with lib.H5FileWrap(self.chkfile, 'a') as fh5:
793
782
  fh5['scf/kpt'] = self.kpt
794
783
  return self
pyscf/pbc/scf/kghf.py CHANGED
@@ -136,38 +136,41 @@ def get_occ(mf, mo_energy_kpts=None, mo_coeff_kpts=None):
136
136
 
137
137
  return mo_occ_kpts
138
138
 
139
- def mulliken_meta(cell, dm_ao_kpts, verbose=logger.DEBUG,
139
+ def _make_rdm1_meta(cell, dm_ao_kpts, kpts, pre_orth_method, s):
140
+ from pyscf.lo import orth
141
+ from pyscf.pbc.tools import k2gamma
142
+
143
+ kmesh = k2gamma.kpts_to_kmesh(cell, kpts-kpts[0])
144
+ nkpts, nso = dm_ao_kpts.shape[:2]
145
+ nao = nso // 2
146
+ scell, phase = k2gamma.get_phase(cell, kpts, kmesh)
147
+ s_sc = k2gamma.to_supercell_ao_integrals(cell, kpts, s, kmesh=kmesh, force_real=False)
148
+ orth_coeff = orth.orth_ao(scell, 'meta_lowdin', pre_orth_method, s=s_sc)[:,:nao] # cell 0 only
149
+ c_inv = np.dot(orth_coeff.T.conj(), s_sc)
150
+ c_inv = lib.einsum('aRp,Rk->kap', c_inv.reshape(nao,nkpts,nao), phase)
151
+ dm_aa = lib.einsum('kap,kpq,kbq->ab', c_inv, dm_ao_kpts[:,:nao,:nao], c_inv.conj())
152
+ dm_bb = lib.einsum('kap,kpq,kbq->ab', c_inv, dm_ao_kpts[:,nao:,nao:], c_inv.conj())
153
+
154
+ return (dm_aa, dm_bb)
155
+
156
+ def mulliken_meta(cell, dm_ao_kpts, kpts, verbose=logger.DEBUG,
140
157
  pre_orth_method=PRE_ORTH_METHOD, s=None):
141
158
  '''A modified Mulliken population analysis, based on meta-Lowdin AOs.
142
-
143
- Note this function only computes the Mulliken population for the gamma
144
- point density matrix.
159
+ The results are equivalent to the corresponding supercell calculation.
145
160
  '''
146
- from pyscf.lo import orth
147
- if s is None:
148
- s = khf.get_ovlp(cell)
149
161
  log = logger.new_logger(cell, verbose)
150
- log.note('Analyze output for *gamma point*.')
151
- log.info(' To include the contributions from k-points, transform to a '
152
- 'supercell then run the population analysis on the supercell\n'
153
- ' from pyscf.pbc.tools import k2gamma\n'
154
- ' k2gamma.k2gamma(mf).mulliken_meta()')
155
- log.note("KGHF mulliken_meta")
156
- dm_ao_gamma = dm_ao_kpts[0,:,:]
157
- nso = dm_ao_gamma.shape[-1]
158
- nao = nso // 2
159
162
 
160
- dm_ao_gamma_aa = dm_ao_gamma[:nao,:nao]
161
- dm_ao_gamma_bb = dm_ao_gamma[nao:,nao:]
162
- s_gamma = s[0,:,:].real
163
- s_gamma_aa = s_gamma[:nao,:nao]
164
- orth_coeff = orth.orth_ao(cell, 'meta_lowdin', pre_orth_method, s=s_gamma_aa)
165
- c_inv = np.dot(orth_coeff.T, s_gamma_aa)
166
- dm_aa = reduce(np.dot, (c_inv, dm_ao_gamma_aa, c_inv.T.conj()))
167
- dm_bb = reduce(np.dot, (c_inv, dm_ao_gamma_bb, c_inv.T.conj()))
163
+ if s is None:
164
+ s = khf.get_ovlp(None, cell=cell, kpts=kpts)
165
+ if s is not None:
166
+ if s[0].shape == dm_ao_kpts[0].shape: # s in SO
167
+ nao = dm_ao_kpts[0].shape[0]//2
168
+ s = lib.asarray(s[:,:nao,:nao], order='C') # keep only one spin sector
169
+
170
+ dm_aa, dm_bb = _make_rdm1_meta(cell, dm_ao_kpts, kpts, pre_orth_method, s)
168
171
 
169
172
  log.note(' ** Mulliken pop alpha/beta on meta-lowdin orthogonal AOs **')
170
- return mol_uhf.mulliken_pop(cell, (dm_aa,dm_bb), np.eye(orth_coeff.shape[0]), log)
173
+ return mol_uhf.mulliken_pop(cell, (dm_aa,dm_bb), np.eye(dm_aa.shape[0]), log)
171
174
 
172
175
  def _cast_mol_init_guess(fn):
173
176
  def fn_init_guess(mf, cell=None, kpts=None):
@@ -259,12 +262,13 @@ class KGHF(khf.KSCF):
259
262
  raise NotImplementedError
260
263
 
261
264
  @lib.with_doc(mulliken_meta.__doc__)
262
- def mulliken_meta(self, cell=None, dm=None, verbose=logger.DEBUG,
265
+ def mulliken_meta(self, cell=None, dm=None, kpts=None, verbose=logger.DEBUG,
263
266
  pre_orth_method=PRE_ORTH_METHOD, s=None):
264
267
  if cell is None: cell = self.cell
265
268
  if dm is None: dm = self.make_rdm1()
266
- if s is None: s = self.get_ovlp(cell)
267
- return mulliken_meta(cell, dm, s=s, verbose=verbose,
269
+ if kpts is None: kpts = self.kpts
270
+ if s is None: s = khf.get_ovlp(self, cell, kpts)
271
+ return mulliken_meta(cell, dm, kpts, s=s, verbose=verbose,
268
272
  pre_orth_method=pre_orth_method)
269
273
 
270
274
  def mulliken_pop(self):
@@ -303,7 +307,7 @@ if __name__ == '__main__':
303
307
  mf = KGHF(cell, kpts=kpts)
304
308
  mf.kernel()
305
309
 
306
- # x2c1e decoractor to KGHF class.
310
+ # x2c1e decorator to KGHF class.
307
311
  #mf = KGHF(cell, kpts=kpts).x2c1e()
308
312
  # or
309
313
  #mf = KGHF(cell, kpts=kpts).sfx2c1e()