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/mcscf/mc1step.py CHANGED
@@ -188,8 +188,8 @@ def gen_g_hop(casscf, mo, u, casdm1, casdm2, eris):
188
188
  if ncore > 0:
189
189
  # Due to x1_rs [4(pq|sr) + 4(pq|rs) - 2(pr|sq) - 2(ps|rq)] for r>s p>q,
190
190
  # == -x1_sr [4(pq|sr) + 4(pq|rs) - 2(pr|sq) - 2(ps|rq)] for r>s p>q,
191
- # x2[:,:ncore] += H * x1[:,:ncore] => (becuase x1=-x1.T) =>
192
- # x2[:,:ncore] += -H' * x1[:ncore] => (becuase x2-x2.T) =>
191
+ # x2[:,:ncore] += H * x1[:,:ncore] => (because x1=-x1.T) =>
192
+ # x2[:,:ncore] += -H' * x1[:ncore] => (because x2-x2.T) =>
193
193
  # x2[:ncore] += H' * x1[:ncore]
194
194
  va, vc = casscf.update_jk_in_ah(mo, x1, casdm1, eris)
195
195
  x2[ncore:nocc] += va
@@ -282,7 +282,7 @@ def rotate_orb_cc(casscf, mo, fcivec, fcasdm1, fcasdm2, eris, x0_guess=None,
282
282
  break
283
283
 
284
284
  elif (ikf >= max(casscf.kf_interval, -numpy.log(norm_dr+1e-7)) or
285
- # Insert keyframe if the keyframe and the esitimated grad
285
+ # Insert keyframe if the keyframe and the estimated grad
286
286
  # are very different
287
287
  norm_gorb < norm_gkf/casscf.kf_trust_region):
288
288
  ikf = 0
@@ -341,6 +341,9 @@ def kernel(casscf, mo_coeff, tol=1e-7, conv_tol_grad=None,
341
341
  if callback is None:
342
342
  callback = casscf.callback
343
343
 
344
+ if ci0 is None:
345
+ ci0 = casscf.ci
346
+
344
347
  mo = mo_coeff
345
348
  nmo = mo_coeff.shape[1]
346
349
  ncore = casscf.ncore
@@ -464,7 +467,7 @@ def kernel(casscf, mo_coeff, tol=1e-7, conv_tol_grad=None,
464
467
  (max_offdiag_u < casscf.small_rot_tol or casscf.small_rot_tol == 0)):
465
468
  conv = True
466
469
 
467
- if dump_chk:
470
+ if dump_chk and casscf.chkfile:
468
471
  casscf.dump_chk(locals())
469
472
 
470
473
  if callable(callback):
@@ -496,7 +499,7 @@ def kernel(casscf, mo_coeff, tol=1e-7, conv_tol_grad=None,
496
499
  'call to mc.cas_natorb_() is required')
497
500
  mo_energy = None
498
501
 
499
- if dump_chk:
502
+ if dump_chk and casscf.chkfile:
500
503
  casscf.dump_chk(locals())
501
504
 
502
505
  log.timer('1-step CASSCF', *cput0)
@@ -583,8 +586,8 @@ def max_stepsize_scheduler(casscf, envs):
583
586
  # To extend CASSCF for certain CAS space solver, it can be done by assign an
584
587
  # object or a module to CASSCF.fcisolver. The fcisolver object or module
585
588
  # should at least have three member functions "kernel" (wfn for given
586
- # hamiltonain), "make_rdm12" (1- and 2-pdm), "absorb_h1e" (effective
587
- # 2e-hamiltonain) in 1-step CASSCF solver, and two member functions "kernel"
589
+ # hamiltonian), "make_rdm12" (1- and 2-pdm), "absorb_h1e" (effective
590
+ # 2e-hamiltonian) in 1-step CASSCF solver, and two member functions "kernel"
588
591
  # and "make_rdm12" in 2-step CASSCF solver
589
592
  class CASSCF(casci.CASBase):
590
593
  __doc__ = casci.CASBase.__doc__ + '''
@@ -652,7 +655,7 @@ class CASSCF(casci.CASBase):
652
655
  callback function takes one dict as the argument which is
653
656
  generated by the builtin function :func:`locals`, so that the
654
657
  callback function can access all local variables in the current
655
- envrionment.
658
+ environment.
656
659
  scale_restoration : float
657
660
  When a step of orbital rotation moves out of trust region, the
658
661
  orbital optimization will be restored to previous state and the
@@ -758,8 +761,6 @@ class CASSCF(casci.CASBase):
758
761
  def __init__(self, mf_or_mol, ncas=0, nelecas=0, ncore=None, frozen=None):
759
762
  casci.CASBase.__init__(self, mf_or_mol, ncas, nelecas, ncore)
760
763
  self.frozen = frozen
761
-
762
- self.callback = None
763
764
  self.chkfile = self._scf.chkfile
764
765
 
765
766
  self.fcisolver.max_cycle = getattr(__config__,
@@ -777,6 +778,9 @@ class CASSCF(casci.CASBase):
777
778
  self.converged = False
778
779
  self._max_stepsize = None
779
780
 
781
+ __getstate__, __setstate__ = lib.generate_pickle_methods(
782
+ excludes=('chkfile', 'callback'))
783
+
780
784
  def dump_flags(self, verbose=None):
781
785
  log = logger.new_logger(self, verbose)
782
786
  log.info('')
@@ -853,6 +857,9 @@ To enable the solvent model for CASSCF, the following code needs to be called
853
857
  self.mo_coeff = mo_coeff
854
858
  if callback is None: callback = self.callback
855
859
 
860
+ if ci0 is None:
861
+ ci0 = self.ci
862
+
856
863
  self.check_sanity()
857
864
  self.dump_flags()
858
865
 
@@ -966,7 +973,7 @@ To enable the solvent model for CASSCF, the following code needs to be called
966
973
  rotate_orb_cc = rotate_orb_cc
967
974
 
968
975
  def update_ao2mo(self, mo):
969
- raise DeprecationWarning('update_ao2mo was obseleted since pyscf v1.0. '
976
+ raise DeprecationWarning('update_ao2mo was obsoleted since pyscf v1.0. '
970
977
  'Use .ao2mo method instead')
971
978
 
972
979
  def ao2mo(self, mo_coeff=None):
@@ -1171,38 +1178,55 @@ To enable the solvent model for CASSCF, the following code needs to be called
1171
1178
  paaa = lib.transpose(buf.reshape(ncas*ncas,-1), out=out)
1172
1179
  return paaa.reshape(nmo,ncas,ncas,ncas)
1173
1180
 
1174
- def dump_chk(self, envs):
1175
- if not self.chkfile:
1176
- return self
1181
+ def dump_chk(self, envs_or_file):
1182
+ '''Serialize the MCSCF object and save it to the specified chkfile.
1177
1183
 
1178
- if getattr(self.fcisolver, 'nevpt_intermediate', None):
1179
- civec = None
1180
- elif self.chk_ci:
1181
- civec = envs['fcivec']
1184
+ Args:
1185
+ envs_or_file:
1186
+ If this argument is a file path, the serialized MCSCF object is
1187
+ saved to the file specified by this argument.
1188
+ If this attribute is a dict (created by locals()), the necessary
1189
+ variables are saved to the file specified by the attribute .chkfile.
1190
+ '''
1191
+ if isinstance(envs_or_file, str):
1192
+ envs = None
1193
+ chk_file = envs_or_file
1182
1194
  else:
1183
- civec = None
1195
+ envs = envs_or_file
1196
+ chk_file = self.chkfile
1197
+ if not chk_file:
1198
+ return self
1199
+
1200
+ e_tot = mo_coeff = mo_occ = mo_energy = e_cas = civec = casdm1 = None
1184
1201
  ncore = self.ncore
1185
1202
  nocc = ncore + self.ncas
1186
- if 'mo' in envs:
1187
- mo_coeff = envs['mo']
1188
- else:
1189
- mo_coeff = envs['mo_coeff']
1190
- mo_occ = numpy.zeros(mo_coeff.shape[1])
1191
- mo_occ[:ncore] = 2
1192
- if self.natorb:
1193
- occ = self._eig(-envs['casdm1'], ncore, nocc)[0]
1194
- mo_occ[ncore:nocc] = -occ
1195
- else:
1196
- mo_occ[ncore:nocc] = envs['casdm1'].diagonal()
1197
- # Note: mo_energy in active space =/= F_{ii} (F is general Fock)
1198
- if 'mo_energy' in envs:
1199
- mo_energy = envs['mo_energy']
1200
- else:
1201
- mo_energy = 'None'
1202
- chkfile.dump_mcscf(self, self.chkfile, 'mcscf', envs['e_tot'],
1203
+
1204
+ if envs is not None:
1205
+ if self.chk_ci:
1206
+ civec = envs.get('fcivec', None)
1207
+
1208
+ e_tot = envs['e_tot']
1209
+ e_cas = envs['e_cas']
1210
+ casdm1 = envs['casdm1']
1211
+ if 'mo' in envs:
1212
+ mo_coeff = envs['mo']
1213
+ else:
1214
+ mo_coeff = envs['mo_coeff']
1215
+ mo_occ = numpy.zeros(mo_coeff.shape[1])
1216
+ mo_occ[:ncore] = 2
1217
+ if self.natorb:
1218
+ occ = self._eig(-casdm1, ncore, nocc)[0]
1219
+ mo_occ[ncore:nocc] = -occ
1220
+ else:
1221
+ mo_occ[ncore:nocc] = casdm1.diagonal()
1222
+ # Note: mo_energy in active space =/= F_{ii} (F is general Fock)
1223
+ if 'mo_energy' in envs:
1224
+ mo_energy = envs['mo_energy']
1225
+
1226
+ chkfile.dump_mcscf(self, chk_file, 'mcscf', e_tot,
1203
1227
  mo_coeff, ncore, self.ncas, mo_occ,
1204
- mo_energy, envs['e_cas'], civec, envs['casdm1'],
1205
- overwrite_mol=False)
1228
+ mo_energy, e_cas, civec, casdm1,
1229
+ overwrite_mol=(envs is None))
1206
1230
  return self
1207
1231
 
1208
1232
  def update_from_chk(self, chkfile=None):
@@ -366,8 +366,8 @@ def gen_g_hop(casscf, mo, ci0, eris, verbose=None):
366
366
  # part4, part5, part6
367
367
  # Due to x1_rs [4(pq|sr) + 4(pq|rs) - 2(pr|sq) - 2(ps|rq)] for r>s p>q,
368
368
  # == -x1_sr [4(pq|sr) + 4(pq|rs) - 2(pr|sq) - 2(ps|rq)] for r>s p>q,
369
- # x2[:,:ncore] += H * x1[:,:ncore] => (becuase x1=-x1.T) =>
370
- # x2[:,:ncore] += -H' * x1[:ncore] => (becuase x2-x2.T) =>
369
+ # x2[:,:ncore] += H * x1[:,:ncore] => (because x1=-x1.T) =>
370
+ # x2[:,:ncore] += -H' * x1[:ncore] => (because x2-x2.T) =>
371
371
  # x2[:ncore] += H' * x1[:ncore]
372
372
  va, vc = casscf.update_jk_in_ah(mo, x1, casdm1, eris)
373
373
  x2[ncore:nocc] += va
@@ -501,7 +501,7 @@ def update_orb_ci(casscf, mo, ci0, eris, x0_guess=None,
501
501
  break
502
502
 
503
503
  elif ((ikf >= max(casscf.kf_interval, casscf.kf_interval-numpy.log(norm_dr+1e-7)) or
504
- # Insert keyframe if the keyframe and the esitimated grad are too different
504
+ # Insert keyframe if the keyframe and the estimated grad are too different
505
505
  norm_gall < norm_gkf/casscf.kf_trust_region)):
506
506
  ikf = 0
507
507
  u, ci_kf = extract_rotation(casscf, dr, u, ci_kf)
@@ -705,7 +705,7 @@ class CASSCF(mc1step.CASSCF):
705
705
  callback function takes one dict as the argument which is
706
706
  generated by the builtin function :func:`locals`, so that the
707
707
  callback function can access all local variables in the current
708
- envrionment.
708
+ environment.
709
709
 
710
710
  Saved results
711
711
 
@@ -852,7 +852,7 @@ class CASSCF(mc1step.CASSCF):
852
852
  return e_tot, e_cas, fcivec
853
853
 
854
854
  def update_ao2mo(self, mo):
855
- raise DeprecationWarning('update_ao2mo was obseleted since pyscf v1.0. '
855
+ raise DeprecationWarning('update_ao2mo was obsoleted since pyscf v1.0. '
856
856
  'Use .ao2mo method instead')
857
857
 
858
858
 
pyscf/mcscf/ucasci.py CHANGED
@@ -54,7 +54,7 @@ def extract_orbs(mo_coeff, ncas, nelecas, ncore):
54
54
  return mo_core, mo_cas, mo_vir
55
55
 
56
56
  def h1e_for_cas(casci, mo_coeff=None, ncas=None, ncore=None):
57
- '''CAS sapce one-electron hamiltonian for UHF-CASCI or UHF-CASSCF
57
+ '''CAS space one-electron hamiltonian for UHF-CASCI or UHF-CASSCF
58
58
 
59
59
  Args:
60
60
  casci : a U-CASSCF/U-CASCI object or UHF object
pyscf/mcscf/umc1step.py CHANGED
@@ -27,6 +27,7 @@ from functools import reduce
27
27
  import numpy
28
28
  import pyscf.gto
29
29
  import pyscf.scf
30
+ from pyscf import lib
30
31
  from pyscf.lib import logger
31
32
  from pyscf.mcscf import ucasci
32
33
  from pyscf.mcscf.mc1step import expmat, rotate_orb_cc, max_stepsize_scheduler, as_scanner
@@ -399,6 +400,9 @@ class UCASSCF(ucasci.UCASBase):
399
400
  self.converged = False
400
401
  self._max_stepsize = None
401
402
 
403
+ __getstate__, __setstate__ = lib.generate_pickle_methods(
404
+ excludes=('chkfile', 'callback'))
405
+
402
406
  def dump_flags(self, verbose=None):
403
407
  log = logger.new_logger(self, verbose)
404
408
  log.info('')
@@ -732,39 +736,54 @@ class UCASSCF(ucasci.UCASBase):
732
736
  ci1 += xs[i] * v[i,0]
733
737
  return ci1, g
734
738
 
735
- def dump_chk(self, envs):
736
- if not self.chkfile:
737
- return self
739
+ def dump_chk(self, envs_or_file):
740
+ '''Serialize the MCSCF object and save it to the specified chkfile.
738
741
 
739
- if self.chk_ci:
740
- civec = envs['fcivec']
742
+ Args:
743
+ envs_or_file:
744
+ If this argument is a file path, the serialized MCSCF object is
745
+ saved to the file specified by this argument.
746
+ If this attribute is a dict (created by locals()), the necessary
747
+ variables are saved to the file specified by the attribute .chkfile.
748
+ '''
749
+ if isinstance(envs_or_file, str):
750
+ envs = None
751
+ chk_file = envs_or_file
741
752
  else:
742
- civec = None
753
+ envs = envs_or_file
754
+ chk_file = self.chkfile
755
+ if not chk_file:
756
+ return self
757
+
758
+ e_tot = mo_coeff = mo_occ = mo_energy = e_cas = civec = casdm1 = None
743
759
  ncore = self.ncore
744
760
  ncas = self.ncas
745
761
  nocca = ncore[0] + ncas
746
762
  noccb = ncore[1] + ncas
747
- if 'mo' in envs:
748
- mo_coeff = envs['mo']
749
- else:
750
- mo_coeff = envs['mo']
751
- mo_occ = numpy.zeros((2,envs['mo'][0].shape[1]))
752
- mo_occ[0,:ncore[0]] = 1
753
- mo_occ[1,:ncore[1]] = 1
754
- if self.natorb:
755
- occa, ucas = self._eig(-envs['casdm1'][0], ncore[0], nocca)
756
- occb, ucas = self._eig(-envs['casdm1'][1], ncore[1], noccb)
757
- mo_occ[0,ncore[0]:nocca] = -occa
758
- mo_occ[1,ncore[1]:noccb] = -occb
759
- else:
760
- mo_occ[0,ncore[0]:nocca] = envs['casdm1'][0].diagonal()
761
- mo_occ[1,ncore[1]:noccb] = envs['casdm1'][1].diagonal()
762
- mo_energy = 'None'
763
763
 
764
- chkfile.dump_mcscf(self, self.chkfile, 'mcscf', envs['e_tot'],
764
+ if envs is not None:
765
+ if self.chk_ci:
766
+ civec = envs['fcivec']
767
+ if 'mo' in envs:
768
+ mo_coeff = envs['mo']
769
+ else:
770
+ mo_coeff = envs['mo_coeff']
771
+ mo_occ = numpy.zeros((2,envs['mo'][0].shape[1]))
772
+ mo_occ[0,:ncore[0]] = 1
773
+ mo_occ[1,:ncore[1]] = 1
774
+ if self.natorb:
775
+ occa, ucas = self._eig(-casdm1[0], ncore[0], nocca)
776
+ occb, ucas = self._eig(-casdm1[1], ncore[1], noccb)
777
+ mo_occ[0,ncore[0]:nocca] = -occa
778
+ mo_occ[1,ncore[1]:noccb] = -occb
779
+ else:
780
+ mo_occ[0,ncore[0]:nocca] = casdm1[0].diagonal()
781
+ mo_occ[1,ncore[1]:noccb] = casdm1[1].diagonal()
782
+
783
+ chkfile.dump_mcscf(self, self.chkfile, 'mcscf', e_tot,
765
784
  mo_coeff, ncore, ncas, mo_occ,
766
- mo_energy, envs['e_cas'], civec, envs['casdm1'],
767
- overwrite_mol=False)
785
+ mo_energy, e_cas, civec, casdm1,
786
+ overwrite_mol=(envs is None))
768
787
  return self
769
788
 
770
789
  def rotate_mo(self, mo, u, log=None):
pyscf/md/integrators.py CHANGED
@@ -128,7 +128,7 @@ class _Integrator(lib.StreamObject):
128
128
  method : lib.GradScanner, rhf.GradientsBase instance, or
129
129
  has nuc_grad_method method.
130
130
  Method by which to compute the energy gradients and energies
131
- in order to propogate the equations of motion. Realistically,
131
+ in order to propagate the equations of motion. Realistically,
132
132
  it can be any callable object such that it returns the energy
133
133
  and potential energy gradient when given a mol.
134
134
 
@@ -179,8 +179,8 @@ class _Integrator(lib.StreamObject):
179
179
  Time of the last step during the simulation.
180
180
 
181
181
  callback : function(envs_dict) => None
182
- Callback function takes one dict as the arugment which is
183
- generaged by the builtin function :func:`locals`, so that the
182
+ Callback function takes one dict as the argument which is
183
+ generated by the builtin function :func:`locals`, so that the
184
184
  callback function can access all local variables in the current
185
185
  environment.
186
186
  '''
pyscf/mp/mp2.py CHANGED
@@ -54,7 +54,7 @@ def kernel(mp, mo_energy=None, mo_coeff=None, eris=None, with_t2=WITH_T2, verbos
54
54
  emp2_ss = emp2_os = 0
55
55
  for i in range(nocc):
56
56
  if isinstance(eris.ovov, numpy.ndarray) and eris.ovov.ndim == 4:
57
- # When mf._eri is a custom integrals wiht the shape (n,n,n,n), the
57
+ # When mf._eri is a custom integrals with the shape (n,n,n,n), the
58
58
  # ovov integrals might be in a 4-index tensor.
59
59
  gi = eris.ovov[i]
60
60
  else:
@@ -160,7 +160,7 @@ def make_rdm1(mp, t2=None, eris=None, ao_repr=False, with_frozen=True):
160
160
 
161
161
  Kwargs:
162
162
  ao_repr : boolean
163
- Whether to transfrom 1-particle density matrix to AO
163
+ Whether to transform 1-particle density matrix to AO
164
164
  representation.
165
165
  '''
166
166
  from pyscf.cc import ccsd_rdm
@@ -248,7 +248,8 @@ def make_fno(mp, thresh=1e-6, pct_occ=None, nvir_act=None, t2=None):
248
248
  else:
249
249
  cumsum = numpy.cumsum(n/numpy.sum(n))
250
250
  logger.debug(mp, 'Sum(pct_occ): %s', cumsum)
251
- nvir_keep = numpy.count_nonzero(cumsum<pct_occ)
251
+ nvir_keep = numpy.count_nonzero(
252
+ [c <= pct_occ or numpy.isclose(c, pct_occ) for c in cumsum])
252
253
  else:
253
254
  nvir_keep = min(nvir, nvir_act)
254
255
 
@@ -383,7 +384,7 @@ def get_frozen_mask(mp):
383
384
  '''Get boolean mask for the restricted reference orbitals.
384
385
 
385
386
  In the returned boolean (mask) array of frozen orbital indices, the
386
- element is False if it corresonds to the frozen orbital.
387
+ element is False if it corresponds to the frozen orbital.
387
388
  '''
388
389
  moidx = numpy.ones(mp.mo_occ.size, dtype=bool)
389
390
  if mp._nmo is not None:
@@ -478,7 +479,7 @@ class MP2(lib.StreamObject):
478
479
  For non-canonical MP2, DIIS space size in MP2
479
480
  iterations. Default is 6.
480
481
  level_shift : float
481
- A shift on virtual orbital energies to stablize the MP2 iterations.
482
+ A shift on virtual orbital energies to stabilize the MP2 iterations.
482
483
  frozen : int or list
483
484
  If integer is given, the inner-most orbitals are excluded from MP2
484
485
  amplitudes. Given the orbital indices (0-based) in a list, both
pyscf/mp/ump2.py CHANGED
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
 
16
16
  '''
17
- UMP2 with spatial integals
17
+ UMP2 with spatial integrals
18
18
  '''
19
19
 
20
20
 
@@ -63,7 +63,7 @@ def kernel(mp, mo_energy=None, mo_coeff=None, eris=None, with_t2=WITH_T2, verbos
63
63
  emp2_ss = emp2_os = 0.0
64
64
  for i in range(nocca):
65
65
  if isinstance(eris.ovov, numpy.ndarray) and eris.ovov.ndim == 4:
66
- # When mf._eri is a custom integrals wiht the shape (n,n,n,n), the
66
+ # When mf._eri is a custom integrals with the shape (n,n,n,n), the
67
67
  # ovov integrals might be in a 4-index tensor.
68
68
  eris_ovov = eris.ovov[i]
69
69
  else:
@@ -77,7 +77,7 @@ def kernel(mp, mo_energy=None, mo_coeff=None, eris=None, with_t2=WITH_T2, verbos
77
77
  t2aa[i] = t2i - t2i.transpose(0,2,1)
78
78
 
79
79
  if isinstance(eris.ovOV, numpy.ndarray) and eris.ovOV.ndim == 4:
80
- # When mf._eri is a custom integrals wiht the shape (n,n,n,n), the
80
+ # When mf._eri is a custom integrals with the shape (n,n,n,n), the
81
81
  # ovov integrals might be in a 4-index tensor.
82
82
  eris_ovov = eris.ovOV[i]
83
83
  else:
@@ -90,7 +90,7 @@ def kernel(mp, mo_energy=None, mo_coeff=None, eris=None, with_t2=WITH_T2, verbos
90
90
 
91
91
  for i in range(noccb):
92
92
  if isinstance(eris.OVOV, numpy.ndarray) and eris.OVOV.ndim == 4:
93
- # When mf._eri is a custom integrals wiht the shape (n,n,n,n), the
93
+ # When mf._eri is a custom integrals with the shape (n,n,n,n), the
94
94
  # ovov integrals might be in a 4-index tensor.
95
95
  eris_ovov = eris.OVOV[i]
96
96
  else:
@@ -217,7 +217,7 @@ def get_frozen_mask(mp):
217
217
  '''Get boolean mask for the unrestricted reference orbitals.
218
218
 
219
219
  In the returned boolean (mask) array of frozen orbital indices, the
220
- element is False if it corresonds to the frozen orbital.
220
+ element is False if it corresponds to the frozen orbital.
221
221
  '''
222
222
  moidxa = numpy.ones(mp.mo_occ[0].size, dtype=bool)
223
223
  moidxb = numpy.ones(mp.mo_occ[1].size, dtype=bool)
@@ -323,7 +323,8 @@ def make_fno(mp, thresh=1e-6, pct_occ=None, nvir_act=None, t2=None, eris=None):
323
323
  else:
324
324
  cumsum = numpy.cumsum(n/numpy.sum(n))
325
325
  logger.debug(mp, 'Sum(pct_occ): %s', cumsum)
326
- nvir_keep = numpy.count_nonzero(cumsum<pct_occ)
326
+ nvir_keep = numpy.count_nonzero(
327
+ [c <= pct_occ or numpy.isclose(c, pct_occ) for c in cumsum])
327
328
  else:
328
329
  nvir_keep = min(nvir, nvir_act[s])
329
330
 
pyscf/pbc/adc/kadc_rhf.py CHANGED
@@ -44,7 +44,7 @@ from pyscf.lib.parameters import LOOSE_ZERO_TOL, LARGE_DENOM # noqa
44
44
  import h5py
45
45
  import tempfile
46
46
 
47
- # Note : All interals are in Chemist's notation except for vvvv
47
+ # Note : All integrals are in Chemist's notation except for vvvv
48
48
  # Eg.of momentum conservation :
49
49
  # Chemist's oovv(ijab) : ki - kj + ka - kb
50
50
  # Amplitudes t2(ijab) : ki + kj - ka - kba
@@ -45,7 +45,7 @@ import h5py
45
45
  import tempfile
46
46
 
47
47
 
48
- # Note : All interals are in Chemist's notation except for vvvv
48
+ # Note : All integrals are in Chemist's notation except for vvvv
49
49
  # Eg.of momentum conservation :
50
50
  # Chemist's oovv(ijab) : ki - kj + ka - kb
51
51
  # Amplitudes t2(ijab) : ki + kj - ka - kba
@@ -281,7 +281,7 @@ def compute_amplitudes(myadc, eris):
281
281
  cput0 = log.timer_debug1("Completed t2_2 amplitude calculation", *cput0)
282
282
 
283
283
  if (myadc.method == "adc(3)" and myadc.approx_trans_moments is False):
284
- raise NotImplementedError('3rd order singles amplitues not implemented')
284
+ raise NotImplementedError('3rd order singles amplitudes not implemented')
285
285
 
286
286
  t1 = (t1_2, t1_3)
287
287
  t2 = (t2_1, t2_2)
pyscf/pbc/ao2mo/eris.py CHANGED
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  '''
20
- This ao2mo module is kept for backward compatiblity. It's recommended to use
20
+ This ao2mo module is kept for backward compatibility. It's recommended to use
21
21
  pyscf.pbc.df module to get 2e MO integrals
22
22
  '''
23
23
 
pyscf/pbc/cc/kccsd_rhf.py CHANGED
@@ -242,10 +242,10 @@ def _get_epq(pindices,qindices,fac=[1.0,1.0],large_num=LARGE_DENOM):
242
242
 
243
243
  Args:
244
244
  pindices (5-list of object):
245
- A list of p0, p1, kp, orbital values, and non-zero indicess for the first
245
+ A list of p0, p1, kp, orbital values, and non-zero indices for the first
246
246
  denominator indices.
247
247
  qindices (5-list of object):
248
- A list of q0, q1, kq, orbital values, and non-zero indicess for the second
248
+ A list of q0, q1, kq, orbital values, and non-zero indices for the second
249
249
  denominator element.
250
250
  fac (3-list of float):
251
251
  Factors to multiply the first and second denominator elements.
@@ -255,7 +255,7 @@ def _get_epq(pindices,qindices,fac=[1.0,1.0],large_num=LARGE_DENOM):
255
255
  def get_idx(x0,x1,kx,n0_p):
256
256
  return np.logical_and(n0_p[kx] >= x0, n0_p[kx] < x1)
257
257
 
258
- assert (all([len(x) == 5 for x in [pindices,qindices]]))
258
+ assert (all(len(x) == 5 for x in [pindices,qindices]))
259
259
  p0,p1,kp,mo_e_p,nonzero_p = pindices
260
260
  q0,q1,kq,mo_e_q,nonzero_q = qindices
261
261
  fac_p, fac_q = fac
@@ -117,7 +117,7 @@ def kernel(mycc, eris, t1=None, t2=None, max_memory=2000, verbose=logger.INFO):
117
117
  def get_w(ki, kj, kk, ka, kb, kc, a0, a1, b0, b1, c0, c1):
118
118
  '''Wijkabc intermediate as described in Scuseria paper before Pijkabc acts
119
119
 
120
- Uses tranposed eris for fast data access.'''
120
+ Uses transposed eris for fast data access.'''
121
121
  km = kconserv[kc, kk, kb]
122
122
  kf = kconserv[kk, kc, kj]
123
123
  out = einsum('cfjk,abif->abcijk', t2T[kc,kf,kj,c0:c1,:,:,:], eris_vvop[ka,kb,ki,a0:a1,b0:b1,:,nocc:])
@@ -579,7 +579,7 @@ def _get_epqr(pindices,qindices,rindices,fac=[1.0,1.0,1.0],large_num=LARGE_DENOM
579
579
  def get_idx(x0,x1,kx,n0_p):
580
580
  return np.logical_and(n0_p[kx] >= x0, n0_p[kx] < x1)
581
581
 
582
- assert (all([len(x) == 5 for x in [pindices,qindices]]))
582
+ assert (all(len(x) == 5 for x in [pindices,qindices]))
583
583
  p0,p1,kp,mo_e_p,nonzero_p = pindices
584
584
  q0,q1,kq,mo_e_q,nonzero_q = qindices
585
585
  r0,r1,kr,mo_e_r,nonzero_r = rindices
pyscf/pbc/ci/kcis_rhf.py CHANGED
@@ -126,7 +126,7 @@ def kernel(cis, nroots=1, eris=None, kptlist=None, **kargs):
126
126
  return evals, evecs
127
127
 
128
128
  def cis_matvec_singlet(cis, vector, kshift, eris=None):
129
- """Compute matrix-vector product of the Hamiltonion matrix and a CIS c
129
+ """Compute matrix-vector product of the Hamiltonian matrix and a CIS c
130
130
  oefficient vector, in the space of single excitation.
131
131
 
132
132
  Arguments:
@@ -143,7 +143,7 @@ def cis_matvec_singlet(cis, vector, kshift, eris=None):
143
143
  electron repulsion integrals (default: {None})
144
144
 
145
145
  Returns:
146
- 1D array -- matrix-vector product of the Hamiltonion matrix and the
146
+ 1D array -- matrix-vector product of the Hamiltonian matrix and the
147
147
  input vector.
148
148
  """
149
149
  if eris is None:
pyscf/pbc/df/aft.py CHANGED
@@ -180,7 +180,7 @@ def _int_nuc_vloc(mydf, nuccell, kpts, intor='int3c2e', aosym='s2', comp=1):
180
180
  raise DeprecationWarning
181
181
 
182
182
  def get_pp(mydf, kpts=None):
183
- '''Get the periodic pseudotential nuc-el AO matrix, with G=0 removed.
183
+ '''Get the periodic pseudopotential nuc-el AO matrix, with G=0 removed.
184
184
 
185
185
  Kwargs:
186
186
  mesh: custom mesh grids. By default mesh is determined by the
@@ -703,7 +703,7 @@ class AFTDF(lib.StreamObject, AFTDFMixin):
703
703
  cell = self.cell
704
704
  if cell.dimension == 2 and cell.low_dim_ft_type != 'inf_vacuum':
705
705
  raise RuntimeError('ERIs of PBC-2D systems are not positive '
706
- 'definite. Current API only supports postive '
706
+ 'definite. Current API only supports positive '
707
707
  'definite ERIs.')
708
708
 
709
709
  if blksize is None:
pyscf/pbc/df/aft_ao2mo.py CHANGED
@@ -222,7 +222,7 @@ def general(mydf, mo_coeffs, kpts=None,
222
222
 
223
223
  def get_ao_pairs_G(mydf, kpts=numpy.zeros((2,3)), q=None, shls_slice=None,
224
224
  compact=getattr(__config__, 'pbc_df_ao_pairs_compact', False)):
225
- '''Calculate forward Fourier tranform (G|ij) of all AO pairs.
225
+ '''Calculate forward Fourier transform (G|ij) of all AO pairs.
226
226
 
227
227
  Returns:
228
228
  ao_pairs_G : 2D complex array