pyscf 2.6.2__py3-none-macosx_11_0_arm64.whl → 2.7.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 (244) 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/outcore.py +6 -4
  20. pyscf/cc/__init__.py +21 -3
  21. pyscf/cc/bccd.py +0 -46
  22. pyscf/cc/ccsd.py +16 -8
  23. pyscf/cc/uccsd.py +1 -1
  24. pyscf/data/elements.py +1 -1
  25. pyscf/df/__init__.py +2 -1
  26. pyscf/df/addons.py +79 -51
  27. pyscf/df/autoaux.py +191 -0
  28. pyscf/df/df.py +5 -1
  29. pyscf/df/grad/casscf.py +0 -41
  30. pyscf/df/hessian/rhf.py +2 -10
  31. pyscf/df/hessian/rks.py +1 -7
  32. pyscf/df/hessian/uhf.py +3 -13
  33. pyscf/df/hessian/uks.py +1 -8
  34. pyscf/df/incore.py +17 -5
  35. pyscf/dft/dks.py +1 -1
  36. pyscf/dft/libxc.py +65 -639
  37. pyscf/dft/numint.py +7 -3
  38. pyscf/dft/radi.py +39 -5
  39. pyscf/dft/rks.py +1 -1
  40. pyscf/dft/xc_deriv.py +1 -1
  41. pyscf/dft/xcfun.py +53 -2
  42. pyscf/eph/eph_fd.py +1 -1
  43. pyscf/eph/rhf.py +6 -36
  44. pyscf/eph/rks.py +0 -4
  45. pyscf/eph/uhf.py +1 -7
  46. pyscf/eph/uks.py +1 -7
  47. pyscf/fci/addons.py +117 -2
  48. pyscf/fci/cistring.py +1 -1
  49. pyscf/fci/direct_nosym.py +3 -3
  50. pyscf/fci/direct_spin0_symm.py +22 -43
  51. pyscf/fci/direct_spin1.py +65 -9
  52. pyscf/fci/direct_spin1_symm.py +49 -14
  53. pyscf/fci/direct_uhf.py +4 -4
  54. pyscf/fci/selected_ci_symm.py +1 -1
  55. pyscf/grad/lagrange.py +11 -3
  56. pyscf/grad/mp2.py +1 -1
  57. pyscf/grad/sacasscf.py +1 -1
  58. pyscf/grad/tdrks.py +1 -1
  59. pyscf/gto/basis/__init__.py +7 -0
  60. pyscf/gto/basis/bse.py +68 -15
  61. pyscf/gto/basis/parse_cp2k_pp.py +1 -1
  62. pyscf/gto/basis/parse_nwchem.py +1 -1
  63. pyscf/gto/basis/parse_nwchem_ecp.py +2 -1
  64. pyscf/gto/basis/sap_grasp_large.dat +2438 -0
  65. pyscf/gto/basis/sap_grasp_small.dat +1434 -0
  66. pyscf/gto/mole.py +99 -44
  67. pyscf/gw/gw_ac.py +2 -2
  68. pyscf/gw/gw_cd.py +2 -2
  69. pyscf/gw/rpa.py +2 -2
  70. pyscf/gw/ugw_ac.py +2 -2
  71. pyscf/gw/urpa.py +1 -1
  72. pyscf/hessian/rhf.py +30 -128
  73. pyscf/hessian/rks.py +1 -6
  74. pyscf/hessian/uhf.py +28 -138
  75. pyscf/hessian/uks.py +1 -8
  76. pyscf/lib/ao2mo/nr_ao2mo.c +1 -1
  77. pyscf/lib/ao2mo/nrr_ao2mo.c +1 -1
  78. pyscf/lib/ao2mo/r_ao2mo.c +1 -1
  79. pyscf/lib/cc/ccsd_pack.c +1 -1
  80. pyscf/lib/cc/ccsd_t.c +6 -6
  81. pyscf/lib/cc/uccsd_t.c +4 -4
  82. pyscf/lib/deps/include/XCFun/XCFunExport.h +1 -0
  83. pyscf/lib/dft/grid_common.c +1 -1
  84. pyscf/lib/dft/libxc_itrf.c +4 -1
  85. pyscf/lib/dft/xcfun_itrf.c +1 -1
  86. pyscf/lib/diis.py +1 -1
  87. pyscf/lib/exceptions.py +3 -0
  88. pyscf/lib/gto/fill_grids_int2c.c +11 -9
  89. pyscf/lib/gto/fill_int2e.c +7 -5
  90. pyscf/lib/gto/fill_r_4c.c +1 -1
  91. pyscf/lib/gto/ft_ao.c +1 -1
  92. pyscf/lib/gto/ft_ao.h +1 -1
  93. pyscf/lib/gto/gto.h +2 -2
  94. pyscf/lib/gto/nr_ecp.c +3 -2
  95. pyscf/lib/libagf2.dylib +0 -0
  96. pyscf/lib/libao2mo.dylib +0 -0
  97. pyscf/lib/libcc.dylib +0 -0
  98. pyscf/lib/libcgto.dylib +0 -0
  99. pyscf/lib/libcvhf.dylib +0 -0
  100. pyscf/lib/libdft.dylib +0 -0
  101. pyscf/lib/libfci.dylib +0 -0
  102. pyscf/lib/libmcscf.dylib +0 -0
  103. pyscf/lib/libnp_helper.dylib +0 -0
  104. pyscf/lib/libpbc.dylib +0 -0
  105. pyscf/lib/libri.dylib +0 -0
  106. pyscf/lib/libxc_itrf.dylib +0 -0
  107. pyscf/lib/libxcfun_itrf.dylib +0 -0
  108. pyscf/lib/linalg_helper.py +112 -192
  109. pyscf/lib/mcscf/fci_contract.c +2 -2
  110. pyscf/lib/misc.py +47 -14
  111. pyscf/lib/numpy_helper.py +1 -1
  112. pyscf/lib/pbc/nr_ecp.c +10 -3
  113. pyscf/lib/pbc/pbc.h +1 -1
  114. pyscf/lib/vhf/nr_sgx_direct.c +8 -6
  115. pyscf/lib/vhf/optimizer.c +2 -2
  116. pyscf/lo/iao.py +1 -1
  117. pyscf/lo/ibo.py +3 -3
  118. pyscf/lo/pipek_jacobi.py +1 -1
  119. pyscf/mcscf/__init__.py +2 -2
  120. pyscf/mcscf/addons.py +3 -3
  121. pyscf/mcscf/apc.py +2 -2
  122. pyscf/mcscf/casci.py +8 -6
  123. pyscf/mcscf/chkfile.py +70 -41
  124. pyscf/mcscf/dmet_cas.py +2 -2
  125. pyscf/mcscf/mc1step.py +62 -38
  126. pyscf/mcscf/newton_casscf.py +5 -5
  127. pyscf/mcscf/ucasci.py +1 -1
  128. pyscf/mcscf/umc1step.py +44 -25
  129. pyscf/md/integrators.py +3 -3
  130. pyscf/mp/mp2.py +6 -5
  131. pyscf/mp/ump2.py +7 -6
  132. pyscf/pbc/adc/kadc_rhf.py +1 -1
  133. pyscf/pbc/adc/kadc_rhf_amplitudes.py +2 -2
  134. pyscf/pbc/ao2mo/eris.py +1 -1
  135. pyscf/pbc/cc/kccsd_rhf.py +3 -3
  136. pyscf/pbc/cc/kccsd_t_rhf.py +2 -2
  137. pyscf/pbc/ci/kcis_rhf.py +2 -2
  138. pyscf/pbc/df/aft.py +2 -2
  139. pyscf/pbc/df/aft_ao2mo.py +1 -1
  140. pyscf/pbc/df/df.py +84 -11
  141. pyscf/pbc/df/df_jk.py +2 -1
  142. pyscf/pbc/df/fft.py +6 -2
  143. pyscf/pbc/df/fft_ao2mo.py +4 -0
  144. pyscf/pbc/df/fft_jk.py +11 -3
  145. pyscf/pbc/df/ft_ao.py +4 -3
  146. pyscf/pbc/df/gdf_builder.py +5 -4
  147. pyscf/pbc/df/incore.py +1 -1
  148. pyscf/pbc/df/mdf.py +6 -3
  149. pyscf/pbc/df/rsdf.py +2 -2
  150. pyscf/pbc/df/rsdf_builder.py +11 -6
  151. pyscf/pbc/df/rsdf_helper.py +1 -1
  152. pyscf/pbc/dft/cdft.py +5 -5
  153. pyscf/pbc/dft/multigrid/multigrid.py +19 -26
  154. pyscf/pbc/dft/multigrid/multigrid_pair.py +1 -1
  155. pyscf/pbc/dft/multigrid/pp.py +1 -1
  156. pyscf/pbc/dft/numint.py +30 -21
  157. pyscf/pbc/eph/eph_fd.py +1 -1
  158. pyscf/pbc/geomopt/geometric_solver.py +1 -1
  159. pyscf/pbc/gto/cell.py +37 -19
  160. pyscf/pbc/gto/ecp.py +12 -12
  161. pyscf/pbc/gto/eval_gto.py +2 -2
  162. pyscf/pbc/gto/pseudo/pp.py +1 -1
  163. pyscf/pbc/gw/krgw_ac.py +4 -4
  164. pyscf/pbc/gw/krgw_cd.py +4 -4
  165. pyscf/pbc/gw/kugw_ac.py +3 -3
  166. pyscf/pbc/lib/kpts_helper.py +4 -3
  167. pyscf/pbc/lib/linalg_helper.py +1 -1
  168. pyscf/pbc/mp/kmp2.py +1 -1
  169. pyscf/pbc/mpitools/mpi.py +1 -1
  170. pyscf/pbc/scf/addons.py +15 -11
  171. pyscf/pbc/scf/cphf.py +1 -1
  172. pyscf/pbc/scf/ghf.py +1 -1
  173. pyscf/pbc/scf/hf.py +21 -24
  174. pyscf/pbc/scf/kghf.py +33 -29
  175. pyscf/pbc/scf/khf.py +71 -26
  176. pyscf/pbc/scf/krohf.py +5 -7
  177. pyscf/pbc/scf/kuhf.py +53 -22
  178. pyscf/pbc/scf/rsjk.py +13 -9
  179. pyscf/pbc/scf/scfint.py +1 -1
  180. pyscf/pbc/scf/stability.py +1 -1
  181. pyscf/pbc/scf/uhf.py +3 -1
  182. pyscf/pbc/symm/symmetry.py +2 -2
  183. pyscf/pbc/tdscf/kproxy.py +1 -1
  184. pyscf/pbc/tdscf/kproxy_supercell.py +2 -2
  185. pyscf/pbc/tdscf/krhf.py +215 -133
  186. pyscf/pbc/tdscf/krhf_slow_supercell.py +1 -1
  187. pyscf/pbc/tdscf/krks.py +1 -45
  188. pyscf/pbc/tdscf/kuhf.py +58 -105
  189. pyscf/pbc/tdscf/kuks.py +0 -56
  190. pyscf/pbc/tdscf/proxy.py +1 -1
  191. pyscf/pbc/tdscf/rhf.py +111 -3
  192. pyscf/pbc/tdscf/rks.py +2 -1
  193. pyscf/pbc/tdscf/uhf.py +203 -1
  194. pyscf/pbc/tdscf/uks.py +2 -1
  195. pyscf/pbc/tools/k2gamma.py +7 -4
  196. pyscf/pbc/tools/pbc.py +63 -56
  197. pyscf/pbc/tools/pyscf_ase.py +0 -1
  198. pyscf/pbc/tools/pywannier90.py +1 -1
  199. pyscf/qmmm/mm_mole.py +1 -1
  200. pyscf/scf/_response_functions.py +2 -2
  201. pyscf/scf/_vhf.py +14 -10
  202. pyscf/scf/addons.py +29 -15
  203. pyscf/scf/cphf.py +14 -52
  204. pyscf/scf/dhf.py +39 -10
  205. pyscf/scf/dispersion.py +9 -8
  206. pyscf/scf/ghf.py +25 -13
  207. pyscf/scf/ghf_symm.py +2 -2
  208. pyscf/scf/hf.py +245 -29
  209. pyscf/scf/rohf.py +37 -5
  210. pyscf/scf/stability.py +142 -112
  211. pyscf/scf/ucphf.py +21 -16
  212. pyscf/scf/uhf.py +95 -58
  213. pyscf/sgx/sgx.py +1 -1
  214. pyscf/sgx/sgx_jk.py +4 -4
  215. pyscf/solvent/_ddcosmo_tdscf_grad.py +1 -1
  216. pyscf/solvent/ddcosmo.py +1 -1
  217. pyscf/solvent/pol_embed.py +1 -1
  218. pyscf/soscf/ciah.py +1 -1
  219. pyscf/soscf/newton_ah.py +1 -1
  220. pyscf/symm/__init__.py +1 -1
  221. pyscf/symm/addons.py +5 -5
  222. pyscf/tdscf/_lr_eig.py +505 -0
  223. pyscf/tdscf/common_slow.py +1 -1
  224. pyscf/tdscf/dhf.py +41 -37
  225. pyscf/tdscf/dks.py +0 -4
  226. pyscf/tdscf/ghf.py +91 -71
  227. pyscf/tdscf/gks.py +16 -16
  228. pyscf/tdscf/proxy.py +2 -2
  229. pyscf/tdscf/rhf.py +143 -96
  230. pyscf/tdscf/rks.py +15 -14
  231. pyscf/tdscf/uhf.py +117 -70
  232. pyscf/tdscf/uks.py +17 -18
  233. pyscf/tools/fcidump.py +3 -0
  234. pyscf/x2c/sfx2c1e.py +1 -1
  235. pyscf/x2c/tdscf.py +4 -4
  236. pyscf/x2c/x2c.py +15 -11
  237. {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/METADATA +24 -24
  238. {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/NOTICE +3 -1
  239. {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/RECORD +242 -240
  240. {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/WHEEL +1 -1
  241. pyscf/dft/gen_libxc_param.py +0 -35
  242. pyscf/dft/gen_xcfun_param.py +0 -209
  243. {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/LICENSE +0 -0
  244. {pyscf-2.6.2.dist-info → pyscf-2.7.0.dist-info}/top_level.txt +0 -0
pyscf/pbc/tdscf/uhf.py CHANGED
@@ -16,14 +16,212 @@
16
16
  # Author: Qiming Sun <osirpt.sun@gmail.com>
17
17
  #
18
18
 
19
+ import numpy as np
19
20
  from pyscf import lib
20
21
  from pyscf.tdscf import uhf
21
22
  from pyscf.pbc.tdscf import rhf as td_rhf
22
23
  from pyscf.pbc.tdscf.rhf import TDBase
23
24
 
24
25
 
26
+ def get_ab(mf):
27
+ r'''A and B matrices for TDDFT response function.
28
+
29
+ A[i,a,j,b] = \delta_{ab}\delta_{ij}(E_a - E_i) + (ia||bj)
30
+ B[i,a,j,b] = (ia||jb)
31
+
32
+ Spin symmetry is considered in the returned A, B lists. List A has three
33
+ items: (A_aaaa, A_aabb, A_bbbb). A_bbaa = A_aabb.transpose(2,3,0,1).
34
+ B has three items: (B_aaaa, B_aabb, B_bbbb).
35
+ B_bbaa = B_aabb.transpose(2,3,0,1).
36
+ '''
37
+ cell = mf.cell
38
+ nao = cell.nao_nr()
39
+ mo_energy = scf.addons.mo_energy_with_exxdiv_none(mf)
40
+ mo = np.asarray(mf.mo_coeff)
41
+ mo_occ = np.asarray(mf.mo_occ)
42
+ kpt = mf.kpt
43
+
44
+ occidx_a = np.where(mo_occ[0]==1)[0]
45
+ viridx_a = np.where(mo_occ[0]==0)[0]
46
+ occidx_b = np.where(mo_occ[1]==1)[0]
47
+ viridx_b = np.where(mo_occ[1]==0)[0]
48
+ orbo_a = mo[0][:,occidx_a]
49
+ orbv_a = mo[0][:,viridx_a]
50
+ orbo_b = mo[1][:,occidx_b]
51
+ orbv_b = mo[1][:,viridx_b]
52
+ nocc_a = orbo_a.shape[1]
53
+ nvir_a = orbv_a.shape[1]
54
+ nocc_b = orbo_b.shape[1]
55
+ nvir_b = orbv_b.shape[1]
56
+ mo_a = np.hstack((orbo_a,orbv_a))
57
+ mo_b = np.hstack((orbo_b,orbv_b))
58
+ nmo_a = nocc_a + nvir_a
59
+ nmo_b = nocc_b + nvir_b
60
+
61
+ e_ia_a = (mo_energy[0][viridx_a,None] - mo_energy[0][occidx_a]).T
62
+ e_ia_b = (mo_energy[1][viridx_b,None] - mo_energy[1][occidx_b]).T
63
+ a_aa = np.diag(e_ia_a.ravel()).reshape(nocc_a,nvir_a,nocc_a,nvir_a)
64
+ a_bb = np.diag(e_ia_b.ravel()).reshape(nocc_b,nvir_b,nocc_b,nvir_b)
65
+ a_ab = np.zeros((nocc_a,nvir_a,nocc_b,nvir_b))
66
+ b_aa = np.zeros_like(a_aa)
67
+ b_ab = np.zeros_like(a_ab)
68
+ b_bb = np.zeros_like(a_bb)
69
+ a = (a_aa, a_ab, a_bb)
70
+ b = (b_aa, b_ab, b_bb)
71
+
72
+ def add_hf_(a, b, hyb=1):
73
+ eri_aa = mf.with_df.ao2mo([orbo_a,mo_a,mo_a,mo_a], kpt, compact=False)
74
+ eri_ab = mf.with_df.ao2mo([orbo_a,mo_a,mo_b,mo_b], kpt, compact=False)
75
+ eri_bb = mf.with_df.ao2mo([orbo_b,mo_b,mo_b,mo_b], kpt, compact=False)
76
+ eri_aa = eri_aa.reshape(nocc_a,nmo_a,nmo_a,nmo_a)
77
+ eri_ab = eri_ab.reshape(nocc_a,nmo_a,nmo_b,nmo_b)
78
+ eri_bb = eri_bb.reshape(nocc_b,nmo_b,nmo_b,nmo_b)
79
+ a_aa, a_ab, a_bb = a
80
+ b_aa, b_ab, b_bb = b
81
+
82
+ a_aa += np.einsum('iabj->iajb', eri_aa[:nocc_a,nocc_a:,nocc_a:,:nocc_a])
83
+ a_aa -= np.einsum('ijba->iajb', eri_aa[:nocc_a,:nocc_a,nocc_a:,nocc_a:]) * hyb
84
+ b_aa += np.einsum('iajb->iajb', eri_aa[:nocc_a,nocc_a:,:nocc_a,nocc_a:])
85
+ b_aa -= np.einsum('jaib->iajb', eri_aa[:nocc_a,nocc_a:,:nocc_a,nocc_a:]) * hyb
86
+
87
+ a_bb += np.einsum('iabj->iajb', eri_bb[:nocc_b,nocc_b:,nocc_b:,:nocc_b])
88
+ a_bb -= np.einsum('ijba->iajb', eri_bb[:nocc_b,:nocc_b,nocc_b:,nocc_b:]) * hyb
89
+ b_bb += np.einsum('iajb->iajb', eri_bb[:nocc_b,nocc_b:,:nocc_b,nocc_b:])
90
+ b_bb -= np.einsum('jaib->iajb', eri_bb[:nocc_b,nocc_b:,:nocc_b,nocc_b:]) * hyb
91
+
92
+ a_ab += np.einsum('iabj->iajb', eri_ab[:nocc_a,nocc_a:,nocc_b:,:nocc_b])
93
+ b_ab += np.einsum('iajb->iajb', eri_ab[:nocc_a,nocc_a:,:nocc_b,nocc_b:])
94
+
95
+ if isinstance(mf, scf.hf.KohnShamDFT):
96
+ ni = mf._numint
97
+ omega, alpha, hyb = ni.rsh_and_hybrid_coeff(mf.xc, cell.spin)
98
+
99
+ add_hf_(a, b, hyb)
100
+ if omega != 0: # For RSH
101
+ raise NotImplementedError
102
+
103
+ xctype = ni._xc_type(mf.xc)
104
+ dm0 = mf.make_rdm1(mo, mo_occ)
105
+ make_rho = ni._gen_rho_evaluator(cell, dm0, hermi=1, with_lapl=False)[0]
106
+ mem_now = lib.current_memory()[0]
107
+ max_memory = max(2000, mf.max_memory*.8-mem_now)
108
+
109
+ if xctype == 'LDA':
110
+ ao_deriv = 0
111
+ for ao, _, mask, weight, coords \
112
+ in ni.block_loop(cell, mf.grids, nao, ao_deriv, kpt, None, max_memory):
113
+ rho0a = make_rho(0, ao, mask, xctype)
114
+ rho0b = make_rho(1, ao, mask, xctype)
115
+ rho = (rho0a, rho0b)
116
+ fxc = ni.eval_xc_eff(mf.xc, rho, deriv=2, xctype=xctype)[2]
117
+ wfxc = fxc[:,0,:,0] * weight
118
+
119
+ rho_o_a = lib.einsum('rp,pi->ri', ao, orbo_a)
120
+ rho_v_a = lib.einsum('rp,pi->ri', ao, orbv_a)
121
+ rho_o_b = lib.einsum('rp,pi->ri', ao, orbo_b)
122
+ rho_v_b = lib.einsum('rp,pi->ri', ao, orbv_b)
123
+ rho_ov_a = np.einsum('ri,ra->ria', rho_o_a, rho_v_a)
124
+ rho_ov_b = np.einsum('ri,ra->ria', rho_o_b, rho_v_b)
125
+ rho_vo_a = rho_ov_a.conj()
126
+ rho_vo_b = rho_ov_b.conj()
127
+ w_ov_aa = np.einsum('ria,r->ria', rho_ov_a, wfxc[0,0])
128
+ w_ov_ab = np.einsum('ria,r->ria', rho_ov_a, wfxc[0,1])
129
+ w_ov_bb = np.einsum('ria,r->ria', rho_ov_b, wfxc[1,1])
130
+
131
+ a_aa += lib.einsum('ria,rjb->iajb', w_ov_aa, rho_vo_a)
132
+ b_aa += lib.einsum('ria,rjb->iajb', w_ov_aa, rho_ov_a)
133
+
134
+ a_ab += lib.einsum('ria,rjb->iajb', w_ov_ab, rho_vo_b)
135
+ b_ab += lib.einsum('ria,rjb->iajb', w_ov_ab, rho_ov_b)
136
+
137
+ a_bb += lib.einsum('ria,rjb->iajb', w_ov_bb, rho_vo_b)
138
+ b_bb += lib.einsum('ria,rjb->iajb', w_ov_bb, rho_ov_b)
139
+
140
+ elif xctype == 'GGA':
141
+ ao_deriv = 1
142
+ for ao, _, mask, weight, coords \
143
+ in ni.block_loop(cell, mf.grids, nao, ao_deriv, kpt, None, max_memory):
144
+ rho0a = make_rho(0, ao, mask, xctype)
145
+ rho0b = make_rho(1, ao, mask, xctype)
146
+ rho = (rho0a, rho0b)
147
+ fxc = ni.eval_xc_eff(mf.xc, rho, deriv=2, xctype=xctype)[2]
148
+ wfxc = fxc * weight
149
+ rho_o_a = lib.einsum('xrp,pi->xri', ao, orbo_a)
150
+ rho_v_a = lib.einsum('xrp,pi->xri', ao, orbv_a)
151
+ rho_o_b = lib.einsum('xrp,pi->xri', ao, orbo_b)
152
+ rho_v_b = lib.einsum('xrp,pi->xri', ao, orbv_b)
153
+ rho_ov_a = np.einsum('xri,ra->xria', rho_o_a, rho_v_a[0])
154
+ rho_ov_b = np.einsum('xri,ra->xria', rho_o_b, rho_v_b[0])
155
+ rho_ov_a[1:4] += np.einsum('ri,xra->xria', rho_o_a[0], rho_v_a[1:4])
156
+ rho_ov_b[1:4] += np.einsum('ri,xra->xria', rho_o_b[0], rho_v_b[1:4])
157
+ rho_vo_a = rho_ov_a.conj()
158
+ rho_vo_b = rho_ov_b.conj()
159
+ w_ov_aa = np.einsum('xyr,xria->yria', wfxc[0,:,0], rho_ov_a)
160
+ w_ov_ab = np.einsum('xyr,xria->yria', wfxc[0,:,1], rho_ov_a)
161
+ w_ov_bb = np.einsum('xyr,xria->yria', wfxc[1,:,1], rho_ov_b)
162
+
163
+ a_aa += lib.einsum('xria,xrjb->iajb', w_ov_aa, rho_vo_a)
164
+ b_aa += lib.einsum('xria,xrjb->iajb', w_ov_aa, rho_ov_a)
165
+
166
+ a_ab += lib.einsum('xria,xrjb->iajb', w_ov_ab, rho_vo_b)
167
+ b_ab += lib.einsum('xria,xrjb->iajb', w_ov_ab, rho_ov_b)
168
+
169
+ a_bb += lib.einsum('xria,xrjb->iajb', w_ov_bb, rho_vo_b)
170
+ b_bb += lib.einsum('xria,xrjb->iajb', w_ov_bb, rho_ov_b)
171
+
172
+ elif xctype == 'HF':
173
+ pass
174
+
175
+ elif xctype == 'NLC':
176
+ raise NotImplementedError('NLC')
177
+
178
+ elif xctype == 'MGGA':
179
+ ao_deriv = 1
180
+ for ao, _, mask, weight, coords \
181
+ in ni.block_loop(cell, mf.grids, nao, ao_deriv, kpt, None, max_memory):
182
+ rho0a = make_rho(0, ao, mask, xctype)
183
+ rho0b = make_rho(1, ao, mask, xctype)
184
+ rho = (rho0a, rho0b)
185
+ fxc = ni.eval_xc_eff(mf.xc, rho, deriv=2, xctype=xctype)[2]
186
+ wfxc = fxc * weight
187
+ rho_oa = lib.einsum('xrp,pi->xri', ao, orbo_a)
188
+ rho_ob = lib.einsum('xrp,pi->xri', ao, orbo_b)
189
+ rho_va = lib.einsum('xrp,pi->xri', ao, orbv_a)
190
+ rho_vb = lib.einsum('xrp,pi->xri', ao, orbv_b)
191
+ rho_ov_a = np.einsum('xri,ra->xria', rho_oa, rho_va[0])
192
+ rho_ov_b = np.einsum('xri,ra->xria', rho_ob, rho_vb[0])
193
+ rho_ov_a[1:4] += np.einsum('ri,xra->xria', rho_oa[0], rho_va[1:4])
194
+ rho_ov_b[1:4] += np.einsum('ri,xra->xria', rho_ob[0], rho_vb[1:4])
195
+ tau_ov_a = np.einsum('xri,xra->ria', rho_oa[1:4], rho_va[1:4]) * .5
196
+ tau_ov_b = np.einsum('xri,xra->ria', rho_ob[1:4], rho_vb[1:4]) * .5
197
+ rho_ov_a = np.vstack([rho_ov_a, tau_ov_a[np.newaxis]])
198
+ rho_ov_b = np.vstack([rho_ov_b, tau_ov_b[np.newaxis]])
199
+ rho_vo_a = rho_ov_a.conj()
200
+ rho_vo_b = rho_ov_b.conj()
201
+ w_ov_aa = np.einsum('xyr,xria->yria', wfxc[0,:,0], rho_ov_a)
202
+ w_ov_ab = np.einsum('xyr,xria->yria', wfxc[0,:,1], rho_ov_a)
203
+ w_ov_bb = np.einsum('xyr,xria->yria', wfxc[1,:,1], rho_ov_b)
204
+
205
+ a_aa += lib.einsum('xria,xrjb->iajb', w_ov_aa, rho_vo_a)
206
+ b_aa += lib.einsum('xria,xrjb->iajb', w_ov_aa, rho_ov_a)
207
+
208
+ a_ab += lib.einsum('xria,xrjb->iajb', w_ov_ab, rho_vo_b)
209
+ b_ab += lib.einsum('xria,xrjb->iajb', w_ov_ab, rho_ov_b)
210
+
211
+ a_bb += lib.einsum('xria,xrjb->iajb', w_ov_bb, rho_vo_b)
212
+ b_bb += lib.einsum('xria,xrjb->iajb', w_ov_bb, rho_ov_b)
213
+
214
+ else:
215
+ add_hf_(a, b)
216
+
217
+ return a, b
218
+
25
219
  class TDA(TDBase):
26
220
 
221
+ def get_ab(self, mf=None):
222
+ if mf is None: mf = self._scf
223
+ return get_ab(mf)
224
+
27
225
  singlet = None
28
226
 
29
227
  init_guess = uhf.TDA.init_guess
@@ -34,7 +232,11 @@ class TDA(TDBase):
34
232
  CIS = TDA
35
233
 
36
234
 
37
- class TDHF(TDA):
235
+ class TDHF(TDBase):
236
+
237
+ def get_ab(self, mf=None):
238
+ if mf is None: mf = self._scf
239
+ return get_ab(mf)
38
240
 
39
241
  singlet = None
40
242
 
pyscf/pbc/tdscf/uks.py CHANGED
@@ -25,7 +25,8 @@ from pyscf.pbc.tdscf.uhf import TDHF as TDDFT
25
25
  RPA = TDUKS = TDDFT
26
26
 
27
27
 
28
- class CasidaTDDFT(TDA):
28
+ class CasidaTDDFT(TDDFT):
29
+ init_guess = TDA.init_guess
29
30
  _gen_vind = uks.TDDFTNoHybrid.gen_vind
30
31
  gen_vind = TDA.gen_vind
31
32
  kernel = uks.TDDFTNoHybrid.kernel
@@ -257,15 +257,18 @@ def k2gamma(kmf, kmesh=None):
257
257
  return mf
258
258
 
259
259
 
260
- def to_supercell_ao_integrals(cell, kpts, ao_ints):
260
+ def to_supercell_ao_integrals(cell, kpts, ao_ints, kmesh=None, force_real=True):
261
261
  '''Transform from the unitcell k-point AO integrals to the supercell
262
262
  gamma-point AO integrals.
263
263
  '''
264
- scell, phase = get_phase(cell, kpts)
264
+ scell, phase = get_phase(cell, kpts, kmesh=kmesh)
265
265
  NR, Nk = phase.shape
266
266
  nao = cell.nao
267
267
  scell_ints = np.einsum('Rk,kij,Sk->RiSj', phase, ao_ints, phase.conj())
268
- return scell_ints.reshape(NR*nao,NR*nao).real
268
+ if force_real:
269
+ return scell_ints.reshape(NR*nao,NR*nao).real
270
+ else:
271
+ return scell_ints.reshape(NR*nao,NR*nao)
269
272
 
270
273
 
271
274
  def to_supercell_mo_integrals(kmf, mo_ints):
@@ -321,7 +324,7 @@ if __name__ == '__main__':
321
324
  mf = k2gamma(kmf, kmesh)
322
325
  c_g_ao = mf.mo_coeff
323
326
 
324
- # The following is to check whether the MO is correctly coverted:
327
+ # The following is to check whether the MO is correctly converted:
325
328
 
326
329
  print("Supercell gamma MO in AO basis from conversion:")
327
330
  scell = tools.super_cell(cell, kmesh)
pyscf/pbc/tools/pbc.py CHANGED
@@ -16,6 +16,7 @@
16
16
  import warnings
17
17
  import ctypes
18
18
  import numpy as np
19
+ import scipy
19
20
  import scipy.linalg
20
21
  from pyscf import lib
21
22
  from pyscf.lib import logger
@@ -23,39 +24,55 @@ from pyscf.gto import ATM_SLOTS, BAS_SLOTS, ATOM_OF, PTR_COORD
23
24
  from pyscf.pbc.lib.kpts_helper import get_kconserv, get_kconserv3 # noqa
24
25
  from pyscf import __config__
25
26
 
26
- FFT_ENGINE = getattr(__config__, 'pbc_tools_pbc_fft_engine', 'BLAS')
27
+ FFT_ENGINE = getattr(__config__, 'pbc_tools_pbc_fft_engine', 'NUMPY+BLAS')
27
28
 
28
29
  def _fftn_blas(f, mesh):
29
- Gx = np.fft.fftfreq(mesh[0])
30
- Gy = np.fft.fftfreq(mesh[1])
31
- Gz = np.fft.fftfreq(mesh[2])
32
- expRGx = np.exp(np.einsum('x,k->xk', -2j*np.pi*np.arange(mesh[0]), Gx))
33
- expRGy = np.exp(np.einsum('x,k->xk', -2j*np.pi*np.arange(mesh[1]), Gy))
34
- expRGz = np.exp(np.einsum('x,k->xk', -2j*np.pi*np.arange(mesh[2]), Gz))
35
- out = np.empty(f.shape, dtype=np.complex128)
36
- buf = np.empty(mesh, dtype=np.complex128)
37
- for i, fi in enumerate(f):
38
- buf[:] = fi.reshape(mesh)
39
- g = lib.dot(buf.reshape(mesh[0],-1).T, expRGx, c=out[i].reshape(-1,mesh[0]))
40
- g = lib.dot(g.reshape(mesh[1],-1).T, expRGy, c=buf.reshape(-1,mesh[1]))
41
- g = lib.dot(g.reshape(mesh[2],-1).T, expRGz, c=out[i].reshape(-1,mesh[2]))
42
- return out.reshape(-1, *mesh)
30
+ assert f.ndim == 4
31
+ mx, my, mz = mesh
32
+ expRGx = np.exp(-2j*np.pi*np.arange(mx)[:,None] * np.fft.fftfreq(mx))
33
+ expRGy = np.exp(-2j*np.pi*np.arange(my)[:,None] * np.fft.fftfreq(my))
34
+ expRGz = np.exp(-2j*np.pi*np.arange(mz)[:,None] * np.fft.fftfreq(mz))
35
+ blksize = max(int(1e5 / (mx * my * mz)), 8) * 4
36
+ n = f.shape[0]
37
+ out = np.empty((n, mx*my*mz), dtype=np.complex128)
38
+ buf = np.empty((blksize, mx*my*mz), dtype=np.complex128)
39
+ for i0, i1 in lib.prange(0, n, blksize):
40
+ ni = i1 - i0
41
+ buf1 = buf[:ni]
42
+ out1 = out[i0:i1]
43
+ g = lib.transpose(f[i0:i1].reshape(ni,-1), out=buf1.reshape(-1,ni))
44
+ g = lib.dot(g.reshape(mx,-1).T, expRGx, c=out1.reshape(-1,mx))
45
+ g = lib.dot(g.reshape(my,-1).T, expRGy, c=buf1.reshape(-1,my))
46
+ g = lib.dot(g.reshape(mz,-1).T, expRGz, c=out1.reshape(-1,mz))
47
+ return out.reshape(n, *mesh)
43
48
 
44
49
  def _ifftn_blas(g, mesh):
45
- Gx = np.fft.fftfreq(mesh[0])
46
- Gy = np.fft.fftfreq(mesh[1])
47
- Gz = np.fft.fftfreq(mesh[2])
48
- expRGx = np.exp(np.einsum('x,k->xk', 2j*np.pi*np.arange(mesh[0]), Gx))
49
- expRGy = np.exp(np.einsum('x,k->xk', 2j*np.pi*np.arange(mesh[1]), Gy))
50
- expRGz = np.exp(np.einsum('x,k->xk', 2j*np.pi*np.arange(mesh[2]), Gz))
51
- out = np.empty(g.shape, dtype=np.complex128)
52
- buf = np.empty(mesh, dtype=np.complex128)
53
- for i, gi in enumerate(g):
54
- buf[:] = gi.reshape(mesh)
55
- f = lib.dot(buf.reshape(mesh[0],-1).T, expRGx, 1./mesh[0], c=out[i].reshape(-1,mesh[0]))
56
- f = lib.dot(f.reshape(mesh[1],-1).T, expRGy, 1./mesh[1], c=buf.reshape(-1,mesh[1]))
57
- f = lib.dot(f.reshape(mesh[2],-1).T, expRGz, 1./mesh[2], c=out[i].reshape(-1,mesh[2]))
58
- return out.reshape(-1, *mesh)
50
+ assert g.ndim == 4
51
+ mx, my, mz = mesh
52
+ expRGx = np.exp(2j*np.pi*np.fft.fftfreq(mx)[:,None] * np.arange(mx))
53
+ expRGy = np.exp(2j*np.pi*np.fft.fftfreq(my)[:,None] * np.arange(my))
54
+ expRGz = np.exp(2j*np.pi*np.fft.fftfreq(mz)[:,None] * np.arange(mz))
55
+ blksize = max(int(1e5 / (mx * my * mz)), 8) * 4
56
+ n = g.shape[0]
57
+ out = np.empty((n, mx*my*mz), dtype=np.complex128)
58
+ buf = np.empty((blksize, mx*my*mz), dtype=np.complex128)
59
+ for i0, i1 in lib.prange(0, n, blksize):
60
+ ni = i1 - i0
61
+ buf1 = buf[:ni]
62
+ out1 = out[i0:i1]
63
+ f = lib.transpose(g[i0:i1].reshape(ni,-1), out=buf1.reshape(-1,ni))
64
+ f = lib.dot(f.reshape(mx,-1).T, expRGx, 1./mx, c=out1.reshape(-1,mx))
65
+ f = lib.dot(f.reshape(my,-1).T, expRGy, 1./my, c=buf1.reshape(-1,my))
66
+ f = lib.dot(f.reshape(mz,-1).T, expRGz, 1./mz, c=out1.reshape(-1,mz))
67
+ return out.reshape(n, *mesh)
68
+
69
+ nproc = lib.num_threads()
70
+
71
+ def _fftn_wrapper(a): # noqa
72
+ return scipy.fft.fftn(a, axes=(1,2,3), workers=nproc)
73
+
74
+ def _ifftn_wrapper(a): # noqa
75
+ return scipy.fft.ifftn(a, axes=(1,2,3), workers=nproc)
59
76
 
60
77
  if FFT_ENGINE == 'FFTW':
61
78
  try:
@@ -88,60 +105,50 @@ if FFT_ENGINE == 'FFTW':
88
105
  ctypes.c_int(rank))
89
106
  return out
90
107
 
91
- def _fftn_wrapper(a):
108
+ def _fftn_wrapper(a): # noqa
92
109
  mesh = a.shape[1:]
93
110
  return _complex_fftn_fftw(a, mesh, 'fft')
94
- def _ifftn_wrapper(a):
111
+ def _ifftn_wrapper(a): # noqa
95
112
  mesh = a.shape[1:]
96
113
  return _complex_fftn_fftw(a, mesh, 'ifft')
97
114
 
98
115
  elif FFT_ENGINE == 'PYFFTW':
99
- # pyfftw is slower than np.fft in most cases
116
+ # Note: pyfftw is likely slower than scipy.fft in multi-threading environments
100
117
  try:
101
118
  import pyfftw
119
+ pyfftw.config.PLANNER_EFFORT = 'FFTW_MEASURE'
102
120
  pyfftw.interfaces.cache.enable()
103
- nproc = lib.num_threads()
104
- def _fftn_wrapper(a):
121
+ def _fftn_wrapper(a): # noqa
105
122
  return pyfftw.interfaces.numpy_fft.fftn(a, axes=(1,2,3), threads=nproc)
106
- def _ifftn_wrapper(a):
123
+ def _ifftn_wrapper(a): # noqa
107
124
  return pyfftw.interfaces.numpy_fft.ifftn(a, axes=(1,2,3), threads=nproc)
108
125
  except ImportError:
109
- def _fftn_wrapper(a):
110
- return np.fft.fftn(a, axes=(1,2,3))
111
- def _ifftn_wrapper(a):
112
- return np.fft.ifftn(a, axes=(1,2,3))
113
-
114
- elif FFT_ENGINE == 'NUMPY':
115
- def _fftn_wrapper(a):
116
- return np.fft.fftn(a, axes=(1,2,3))
117
- def _ifftn_wrapper(a):
118
- return np.fft.ifftn(a, axes=(1,2,3))
126
+ print('PyFFTW not installed. SciPy fft module will be used.')
119
127
 
120
128
  elif FFT_ENGINE == 'NUMPY+BLAS':
121
129
  _EXCLUDE = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79,
122
130
  83, 89, 97,101,103,107,109,113,127,131,137,139,149,151,157,163,
123
131
  167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,
124
132
  257,263,269,271,277,281,283,293]
125
- _EXCLUDE = set(_EXCLUDE + [n*2 for n in _EXCLUDE] + [n*3 for n in _EXCLUDE])
126
- def _fftn_wrapper(a):
133
+ _EXCLUDE = set(_EXCLUDE + [n*2 for n in _EXCLUDE[:30]] + [n*3 for n in _EXCLUDE[:20]])
134
+ def _fftn_wrapper(a): # noqa
127
135
  mesh = a.shape[1:]
128
136
  if mesh[0] in _EXCLUDE and mesh[1] in _EXCLUDE and mesh[2] in _EXCLUDE:
129
137
  return _fftn_blas(a, mesh)
130
138
  else:
131
- return np.fft.fftn(a, axes=(1,2,3))
132
- def _ifftn_wrapper(a):
139
+ return scipy.fft.fftn(a, axes=(1,2,3), workers=nproc)
140
+ def _ifftn_wrapper(a): # noqa
133
141
  mesh = a.shape[1:]
134
142
  if mesh[0] in _EXCLUDE and mesh[1] in _EXCLUDE and mesh[2] in _EXCLUDE:
135
143
  return _ifftn_blas(a, mesh)
136
144
  else:
137
- return np.fft.ifftn(a, axes=(1,2,3))
145
+ return scipy.fft.ifftn(a, axes=(1,2,3), workers=nproc)
138
146
 
139
- #?elif: # 'FFTW+BLAS'
140
- else: # 'BLAS'
141
- def _fftn_wrapper(a):
147
+ elif FFT_ENGINE == 'BLAS':
148
+ def _fftn_wrapper(a): # noqa
142
149
  mesh = a.shape[1:]
143
150
  return _fftn_blas(a, mesh)
144
- def _ifftn_wrapper(a):
151
+ def _ifftn_wrapper(a): # noqa
145
152
  mesh = a.shape[1:]
146
153
  return _ifftn_blas(a, mesh)
147
154
 
@@ -384,7 +391,7 @@ def get_coulG(cell, k=np.zeros(3), exx=False, mf=None, mesh=None, Gv=None,
384
391
  weights = 1 + Gp*Rc * scipy.special.j1(Gp*Rc) * scipy.special.k0(Gx*Rc)
385
392
  weights -= Gx*Rc * scipy.special.j0(Gp*Rc) * scipy.special.k1(Gx*Rc)
386
393
  coulG = 4*np.pi/absG2 * weights
387
- # TODO: numerical integation
394
+ # TODO: numerical integration
388
395
  # coulG[Gx==0] = -4*np.pi * (dr * r * scipy.special.j0(Gp*r) * np.log(r)).sum()
389
396
  if len(G0_idx) > 0:
390
397
  coulG[G0_idx] = -np.pi*Rc**2 * (2*np.log(Rc) - 1)
@@ -685,7 +692,7 @@ def _build_supcell_(supcell, cell, Ls):
685
692
  _env = np.append(cell._env, coords.ravel())
686
693
  _atm = np.repeat(cell._atm[None,:,:], nimgs, axis=0)
687
694
  _atm = _atm.reshape(-1, ATM_SLOTS)
688
- # Point to the corrdinates appended to _env
695
+ # Point to the coordinates appended to _env
689
696
  _atm[:,PTR_COORD] = cell._env.size + np.arange(nimgs * cell.natm) * 3
690
697
 
691
698
  _bas = np.repeat(cell._bas[None,:,:], nimgs, axis=0)
@@ -24,7 +24,6 @@ ASE package interface
24
24
  import numpy as np
25
25
  from ase.calculators.calculator import Calculator
26
26
  import ase.dft.kpoints
27
- from ase.lattice import bulk
28
27
 
29
28
  def pyscf_to_ase_atoms(cell):
30
29
  '''
@@ -325,7 +325,7 @@ def get_wigner_seitz_supercell(w90, ws_search_size=[2,2,2], ws_distance_tol=1e-6
325
325
  '''
326
326
  Return a grid that contains all the lattice within the Wigner-Seitz supercell
327
327
 
328
- Ref: the hamiltonian_wigner_seitz(count_pts) in wannier90/src/hamittonian.F90
328
+ Ref: the hamiltonian_wigner_seitz(count_pts) in wannier90/src/hamiltonian.F90
329
329
  '''
330
330
 
331
331
  real_metric = w90.real_lattice_loc.T.dot(w90.real_lattice_loc)
pyscf/qmmm/mm_mole.py CHANGED
@@ -97,7 +97,7 @@ def create_mm_mol(atoms_or_coords, charges=None, radii=None, unit='Angstrom'):
97
97
  charges : 1D array
98
98
  The charges of MM atoms.
99
99
  radii : 1D array
100
- The Gaussian charge distribuction radii of MM atoms.
100
+ The Gaussian charge distribution radii of MM atoms.
101
101
  unit : string
102
102
  The unit of the input. Default is 'Angstrom'.
103
103
  '''
@@ -47,7 +47,7 @@ def _gen_rhf_response(mf, mo_coeff=None, mo_occ=None,
47
47
  ni.libxc.test_deriv_order(mf.xc, 2, raise_error=True)
48
48
  if mf.do_nlc():
49
49
  logger.warn(mf, 'NLC functional found in DFT object. Its second '
50
- 'deriviative is not available. Its contribution is '
50
+ 'derivative is not available. Its contribution is '
51
51
  'not included in the response function.')
52
52
  omega, alpha, hyb = ni.rsh_and_hybrid_coeff(mf.xc, mol.spin)
53
53
  hybrid = ni.libxc.is_hybrid_xc(mf.xc)
@@ -157,7 +157,7 @@ def _gen_uhf_response(mf, mo_coeff=None, mo_occ=None,
157
157
  ni.libxc.test_deriv_order(mf.xc, 2, raise_error=True)
158
158
  if mf.do_nlc():
159
159
  logger.warn(mf, 'NLC functional found in DFT object. Its second '
160
- 'deriviative is not available. Its contribution is '
160
+ 'derivative is not available. Its contribution is '
161
161
  'not included in the response function.')
162
162
  omega, alpha, hyb = ni.rsh_and_hybrid_coeff(mf.xc, mol.spin)
163
163
  hybrid = ni.libxc.is_hybrid_xc(mf.xc)
pyscf/scf/_vhf.py CHANGED
@@ -79,10 +79,10 @@ class VHFOpt:
79
79
 
80
80
  @property
81
81
  def direct_scf_tol(self):
82
- return self._this.contents.direct_scf_cutoff
82
+ return self._this.contents.direct_scf_tol
83
83
  @direct_scf_tol.setter
84
84
  def direct_scf_tol(self, v):
85
- self._this.contents.direct_scf_cutoff = v
85
+ self._this.contents.direct_scf_tol = v
86
86
 
87
87
  @property
88
88
  def prescreen(self):
@@ -162,7 +162,7 @@ class _VHFOpt:
162
162
  self.mol = mol
163
163
  self._this = cvhfopt = _CVHFOpt()
164
164
  cvhfopt.nbas = mol.nbas
165
- cvhfopt.direct_scf_cutoff = direct_scf_tol
165
+ cvhfopt.direct_scf_tol = direct_scf_tol
166
166
  cvhfopt.fprescreen = _fpointer(prescreen)
167
167
  cvhfopt.r_vkscreen = _fpointer('CVHFr_vknoscreen')
168
168
  self._q_cond = None
@@ -207,10 +207,10 @@ class _VHFOpt:
207
207
 
208
208
  @property
209
209
  def direct_scf_tol(self):
210
- return self._this.direct_scf_cutoff
210
+ return self._this.direct_scf_tol
211
211
  @direct_scf_tol.setter
212
212
  def direct_scf_tol(self, v):
213
- self._this.direct_scf_cutoff = v
213
+ self._this.direct_scf_tol = v
214
214
 
215
215
  @property
216
216
  def prescreen(self):
@@ -265,9 +265,9 @@ class _VHFOpt:
265
265
 
266
266
  class SGXOpt(_VHFOpt):
267
267
  def __init__(self, mol, intor=None, prescreen='CVHFnoscreen',
268
- qcondname=None, dmcondname=None, direct_scf_cutoff=1e-14):
268
+ qcondname=None, dmcondname=None, direct_scf_tol=1e-14):
269
269
  _VHFOpt.__init__(self, mol, intor, prescreen, qcondname, dmcondname,
270
- direct_scf_cutoff)
270
+ direct_scf_tol)
271
271
  self.ngrids = None
272
272
 
273
273
  def set_dm(self, dm, atm, bas, env):
@@ -287,18 +287,22 @@ class SGXOpt(_VHFOpt):
287
287
  if self._dmcondname != 'SGXnr_dm_cond':
288
288
  raise ValueError('SGXOpt only supports SGXnr_dm_cond')
289
289
  fdmcond = getattr(libcvhf, self._dmcondname)
290
- dm_cond = numpy.empty((mol.nbas, self.ngrids))
290
+ if self.ngrids is None:
291
+ ngrids = int(env[gto.NGRIDS])
292
+ else:
293
+ ngrids = self.ngrids
294
+ dm_cond = numpy.empty((mol.nbas, ngrids))
291
295
  fdmcond(dm_cond.ctypes, dm.ctypes, ctypes.c_int(n_dm),
292
296
  ao_loc.ctypes, mol._atm.ctypes, ctypes.c_int(mol.natm),
293
297
  mol._bas.ctypes, ctypes.c_int(mol.nbas), mol._env.ctypes,
294
- ctypes.c_int(self.ngrids))
298
+ ctypes.c_int(ngrids))
295
299
  self.dm_cond = dm_cond
296
300
 
297
301
 
298
302
  class _CVHFOpt(ctypes.Structure):
299
303
  _fields_ = [('nbas', ctypes.c_int),
300
304
  ('ngrids', ctypes.c_int),
301
- ('direct_scf_cutoff', ctypes.c_double),
305
+ ('direct_scf_tol', ctypes.c_double),
302
306
  ('q_cond', ctypes.c_void_p),
303
307
  ('dm_cond', ctypes.c_void_p),
304
308
  ('fprescreen', ctypes.c_void_p),