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/gto/mole.py CHANGED
@@ -319,7 +319,7 @@ def format_atom(atoms, origin=0, axes=None,
319
319
  coordinates to AU, rotate and shift the molecule.
320
320
  If the :attr:`~Mole.atom` is a string, it takes ";" and "\\n"
321
321
  for the mark to separate atoms; "," and arbitrary length of blank space
322
- to spearate the individual terms for an atom. Blank line will be ignored.
322
+ to separate the individual terms for an atom. Blank line will be ignored.
323
323
 
324
324
  Args:
325
325
  atoms : list or str
@@ -459,7 +459,7 @@ def format_basis(basis_tab, sort_basis=True):
459
459
  if len(_basis) == 0:
460
460
  raise BasisNotFoundError('Basis not found for %s' % symb)
461
461
 
462
- # Sort basis accroding to angular momentum. This is important for method
462
+ # Sort basis according to angular momentum. This is important for method
463
463
  # decontract_basis, which assumes that basis functions with the same
464
464
  # angular momentum are grouped together. Related to issue #1620 #1770
465
465
  if sort_basis:
@@ -497,7 +497,7 @@ def _generate_basis_converter():
497
497
  _basis = load(raw_basis, _std_symbol_without_ghost(symb))
498
498
  elif (any(isinstance(x, str) for x in raw_basis)
499
499
  # The first element is the basis of internal format
500
- or not isinstance(raw_basis[0][0], int)):
500
+ or not isinstance(raw_basis[0][0], (numpy.integer, int))):
501
501
  stdsymb = _std_symbol_without_ghost(symb)
502
502
  _basis = []
503
503
  for rawb in raw_basis:
@@ -572,7 +572,7 @@ def to_uncontracted_cartesian_basis(mol):
572
572
  '''
573
573
  return decontract_basis(mol, to_cart=True)
574
574
 
575
- def decontract_basis(mol, atoms=None, to_cart=False):
575
+ def decontract_basis(mol, atoms=None, to_cart=False, aggregate=False):
576
576
  '''Decontract the basis of a Mole or a Cell. Returns a Mole (Cell) object
577
577
  with the uncontracted basis environment and a list of coefficients that
578
578
  transform the uncontracted basis to the original basis. Each element in
@@ -584,6 +584,9 @@ def decontract_basis(mol, atoms=None, to_cart=False):
584
584
  are decontracted
585
585
  to_cart: bool
586
586
  Decontract basis and transfer to Cartesian basis
587
+ aggregate: bool
588
+ Whether to aggregate the transformation coefficients into a giant
589
+ transformation matrix
587
590
 
588
591
  Examples:
589
592
 
@@ -602,17 +605,27 @@ def decontract_basis(mol, atoms=None, to_cart=False):
602
605
  bas_exps = mol.bas_exps()
603
606
  def _to_full_contraction(mol, bas_idx):
604
607
  es = numpy.hstack([bas_exps[i] for i in bas_idx])
605
- cs = scipy.linalg.block_diag(*[mol._libcint_ctr_coeff(ib) for ib in bas_idx])
606
-
607
- es, e_idx, rev_idx = numpy.unique(es.round(9), True, True)
608
- cs_new = numpy.zeros((es.size, cs.shape[1]))
609
- for i, j in enumerate(rev_idx):
610
- cs_new[j] += cs[i]
611
- return es[::-1], cs_new[::-1]
608
+ _, e_idx, rev_idx = numpy.unique(es.round(9), True, True)
609
+ if aggregate:
610
+ cs = scipy.linalg.block_diag(
611
+ *[mol._libcint_ctr_coeff(i) for i in bas_idx])
612
+ if len(es) != len(e_idx):
613
+ cs_new = numpy.zeros((e_idx.size, cs.shape[1]))
614
+ for i, j in enumerate(rev_idx):
615
+ cs_new[j] += cs[i]
616
+ es = es[e_idx][::-1]
617
+ cs = cs_new[::-1]
618
+ yield es, cs
619
+ else:
620
+ if len(es) != len(e_idx):
621
+ raise RuntimeError('Duplicated pGTOs across shells')
622
+ for i in bas_idx:
623
+ yield bas_exps[i], mol._libcint_ctr_coeff(i)
612
624
 
613
625
  _bas = []
614
- _env = mol._env.copy()
626
+ env = [mol._env.copy()]
615
627
  contr_coeff = []
628
+ pexp = env[0].size
616
629
 
617
630
  lmax = mol._bas[:,ANG_OF].max()
618
631
  if mol.cart:
@@ -648,7 +661,7 @@ def decontract_basis(mol, atoms=None, to_cart=False):
648
661
  continue
649
662
 
650
663
  lmax = mol._bas[ib0:ib1,ANG_OF].max()
651
- pexp = mol._bas[ib0,PTR_EXP]
664
+
652
665
  for l in range(lmax+1):
653
666
  bas_idx = ib0 + numpy.where(mol._bas[ib0:ib1,ANG_OF] == l)[0]
654
667
  if len(bas_idx) == 0:
@@ -656,30 +669,27 @@ def decontract_basis(mol, atoms=None, to_cart=False):
656
669
  if bas_idx[0] + len(bas_idx) != bas_idx[-1] + 1:
657
670
  raise NotImplementedError('Discontinuous bases of same angular momentum')
658
671
 
659
- mol_exps, b_coeff = _to_full_contraction(mol, bas_idx)
660
- nprim, nc = b_coeff.shape
661
- bs = numpy.zeros((nprim, BAS_SLOTS), dtype=numpy.int32)
662
- bs[:,ATOM_OF] = ia
663
- bs[:,ANG_OF ] = l
664
- bs[:,NCTR_OF] = bs[:,NPRIM_OF] = 1
665
- norm = gto_norm(l, mol_exps)
666
- if atoms is None:
672
+ for mol_exps, b_coeff in _to_full_contraction(mol, bas_idx):
673
+ nprim, nc = b_coeff.shape
674
+ bs = numpy.zeros((nprim, BAS_SLOTS), dtype=numpy.int32)
675
+ bs[:,ATOM_OF] = ia
676
+ bs[:,ANG_OF ] = l
677
+ bs[:,NCTR_OF] = bs[:,NPRIM_OF] = 1
667
678
  bs[:,PTR_EXP] = pexp + numpy.arange(nprim)
668
679
  bs[:,PTR_COEFF] = pexp + numpy.arange(nprim, nprim*2)
669
- _env[pexp:pexp+nprim] = mol_exps
670
- _env[pexp+nprim:pexp+nprim*2] = norm
680
+ norm = gto_norm(l, mol_exps)
681
+ env.append(mol_exps)
682
+ env.append(norm)
671
683
  pexp += nprim * 2
672
- else:
673
- bs[:,PTR_EXP] = _env.size + numpy.arange(nprim)
674
- bs[:,PTR_COEFF] = _env.size + numpy.arange(nprim, nprim*2)
675
- _env = np.hstack([_env, mol_exps, norm])
676
- _bas.append(bs)
684
+ _bas.append(bs)
677
685
 
678
- c = numpy.einsum('pi,p,xm->pxim', b_coeff, 1./norm, c2s[l])
679
- contr_coeff.append(c.reshape(nprim * c2s[l].shape[0], -1))
686
+ c = numpy.einsum('pi,p,xm->pxim', b_coeff, 1./norm, c2s[l])
687
+ contr_coeff.append(c.reshape(nprim * c2s[l].shape[0], -1))
680
688
 
681
689
  pmol._bas = numpy.asarray(numpy.vstack(_bas), dtype=numpy.int32)
682
- pmol._env = _env
690
+ pmol._env = numpy.hstack(env)
691
+ if aggregate:
692
+ contr_coeff = scipy.linalg.block_diag(*contr_coeff)
683
693
  return pmol, contr_coeff
684
694
 
685
695
  def format_ecp(ecp_tab):
@@ -1244,12 +1254,12 @@ def unpack(moldic):
1244
1254
  def dumps(mol):
1245
1255
  '''Serialize Mole object to a JSON formatted str.
1246
1256
  '''
1247
- exclude_keys = {'output', 'stdout', '_keys',
1248
- # Constructing in function loads
1249
- 'symm_orb', 'irrep_id', 'irrep_name'}
1257
+ exclude_keys = {'output', 'stdout', '_keys', '_ctx_lock',
1258
+ # Constructing in function loads
1259
+ 'symm_orb', 'irrep_id', 'irrep_name'}
1250
1260
  # FIXME: nparray and kpts for cell objects may need to be excluded
1251
1261
  nparray_keys = {'_atm', '_bas', '_env', '_ecpbas',
1252
- '_symm_orig', '_symm_axes'}
1262
+ '_symm_orig', '_symm_axes'}
1253
1263
 
1254
1264
  moldic = dict(mol.__dict__)
1255
1265
  for k in exclude_keys:
@@ -1961,7 +1971,7 @@ def same_mol(mol1, mol2, tol=1e-5, cmp_basis=True, ignore_chiral=False):
1961
1971
  is_same_mol = same_mol
1962
1972
 
1963
1973
  def chiral_mol(mol1, mol2=None):
1964
- '''Detect whether the given molelcule is chiral molecule or two molecules
1974
+ '''Detect whether the given molecule is chiral molecule or two molecules
1965
1975
  are chiral isomers.
1966
1976
  '''
1967
1977
  if mol2 is None:
@@ -2197,7 +2207,7 @@ class MoleBase(lib.StreamObject):
2197
2207
  subgroup
2198
2208
 
2199
2209
  atom : list or str
2200
- To define molecluar structure. The internal format is
2210
+ To define molecular structure. The internal format is
2201
2211
 
2202
2212
  | atom = [[atom1, (x, y, z)],
2203
2213
  | [atom2, (x, y, z)],
@@ -2457,7 +2467,7 @@ class MoleBase(lib.StreamObject):
2457
2467
  atom=None, basis=None, unit=None, nucmod=None, ecp=None, pseudo=None,
2458
2468
  charge=None, spin=0, symmetry=None, symmetry_subgroup=None,
2459
2469
  cart=None, magmom=None):
2460
- '''Setup moleclue and initialize some control parameters. Whenever you
2470
+ '''Setup molecule and initialize some control parameters. Whenever you
2461
2471
  change the value of the attributes of :class:`Mole`, you need call
2462
2472
  this function to refresh the internal data of Mole.
2463
2473
 
@@ -2473,7 +2483,7 @@ class MoleBase(lib.StreamObject):
2473
2483
  max_memory : int, float
2474
2484
  Allowd memory in MB. If given, overwrite :attr:`Mole.max_memory`
2475
2485
  atom : list or str
2476
- To define molecluar structure.
2486
+ To define molecular structure.
2477
2487
  basis : dict or str
2478
2488
  To define basis set.
2479
2489
  nucmod : dict or str
@@ -2750,7 +2760,7 @@ class MoleBase(lib.StreamObject):
2750
2760
  ' X Y Z unit Magmom\n')
2751
2761
  for ia,atom in enumerate(self._atom):
2752
2762
  coorda = tuple([x * param.BOHR for x in atom[1]])
2753
- coordb = tuple([x for x in atom[1]])
2763
+ coordb = tuple(atom[1])
2754
2764
  magmom = self.magmom[ia]
2755
2765
  self.stdout.write('[INPUT]%3d %-4s %16.12f %16.12f %16.12f AA '
2756
2766
  '%16.12f %16.12f %16.12f Bohr %4.1f\n'
@@ -3070,7 +3080,7 @@ class MoleBase(lib.StreamObject):
3070
3080
  logger.info(mol, 'New geometry')
3071
3081
  for ia, atom in enumerate(mol._atom):
3072
3082
  coorda = tuple([x * param.BOHR for x in atom[1]])
3073
- coordb = tuple([x for x in atom[1]])
3083
+ coordb = tuple(atom[1])
3074
3084
  coords = coorda + coordb
3075
3085
  logger.info(mol, ' %3d %-4s %16.12f %16.12f %16.12f AA '
3076
3086
  '%16.12f %16.12f %16.12f Bohr\n',
@@ -3431,6 +3441,11 @@ class MoleBase(lib.StreamObject):
3431
3441
  | 1 : hermitian
3432
3442
  | 2 : anti-hermitian
3433
3443
 
3444
+ shls_slice : 4-element, 6-element or 8-element tuple
3445
+ Label the start-stop shells for each index in the integral.
3446
+ For example, the 8-element tuple for the 2-electron integral
3447
+ tensor (ij|kl) = intor('int2e') are specified as
3448
+ (ish_start, ish_end, jsh_start, jsh_end, ksh_start, ksh_end, lsh_start, lsh_end)
3434
3449
  grids : ndarray
3435
3450
  Coordinates of grids for the int1e_grids integrals
3436
3451
 
@@ -3748,7 +3763,7 @@ class Mole(MoleBase):
3748
3763
  def ao2mo(self, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
3749
3764
  **kwargs):
3750
3765
  '''Integral transformation for arbitrary orbitals and arbitrary
3751
- integrals. See more detalied documentation in func:`ao2mo.kernel`.
3766
+ integrals. See more detailed documentation in func:`ao2mo.kernel`.
3752
3767
 
3753
3768
  Args:
3754
3769
  mo_coeffs (an np array or a list of arrays) : A matrix of orbital
@@ -3800,7 +3815,7 @@ class Mole(MoleBase):
3800
3815
  return ao2mo.kernel(self, mo_coeffs, erifile, dataname, intor, **kwargs)
3801
3816
 
3802
3817
  def to_cell(self, a, dimension=3):
3803
- '''Put a molecule in a cell with periodic boundary condictions
3818
+ '''Put a molecule in a cell with periodic boundary conditions
3804
3819
 
3805
3820
  Args:
3806
3821
  a : (3,3) ndarray
@@ -4054,7 +4069,7 @@ def fakemol_for_charges(coords, expnt=1e16):
4054
4069
  # approximate point charge with gaussian distribution exp(-1e16*r^2)
4055
4070
  fakebas[:,PTR_EXP] = ptr
4056
4071
  fakebas[:,PTR_COEFF] = ptr+1
4057
- fakeenv.append([expnt, 1/(2*numpy.sqrt(numpy.pi)*gaussian_int(2,expnt))])
4072
+ fakeenv.append([expnt, 1 / (2*numpy.sqrt(numpy.pi)*gaussian_int(2,expnt))])
4058
4073
  ptr += 2
4059
4074
  else:
4060
4075
  assert expnt.size == nbas
@@ -4071,6 +4086,46 @@ def fakemol_for_charges(coords, expnt=1e16):
4071
4086
  fakemol._built = True
4072
4087
  return fakemol
4073
4088
 
4089
+ def fakemol_for_cgtf_charge(coord, expnt=1e16, contr_coeff=1):
4090
+ '''Constructs a "fake" Mole object that has a Gaussian charge
4091
+ distribution at the specified coordinate (coord). The charge
4092
+ can be given as a linear combination of Gaussians with
4093
+ exponents expnt and contraction coefficients contr_coeff.
4094
+ '''
4095
+ assert coord.shape[0] == 1
4096
+ expnt = numpy.asarray(expnt).ravel()
4097
+ contr_coeff = numpy.asarray(contr_coeff).ravel()
4098
+
4099
+ fakeatm = numpy.zeros((1,ATM_SLOTS), dtype=numpy.int32)
4100
+ fakebas = numpy.zeros((1,BAS_SLOTS), dtype=numpy.int32)
4101
+ fakeenv = [0] * PTR_ENV_START
4102
+ ptr = PTR_ENV_START
4103
+ fakeatm[:,PTR_COORD] = numpy.arange(ptr, ptr+3, 3)
4104
+ fakeenv.append(coord.ravel())
4105
+ ptr += 3
4106
+ fakebas[:,ATOM_OF] = 0#numpy.arange(nbas)
4107
+ fakebas[:,NPRIM_OF] = contr_coeff.size
4108
+ fakebas[:,NCTR_OF] = 1
4109
+ if expnt.size == 1:
4110
+ expnt = expnt[0]
4111
+ fakebas[:,PTR_EXP] = ptr
4112
+ fakebas[:,PTR_COEFF] = ptr+1
4113
+ fakeenv.append([expnt, 1 / (2*numpy.sqrt(numpy.pi)*gaussian_int(2,expnt))])
4114
+ ptr += 2
4115
+ else:
4116
+ assert expnt.size == contr_coeff.size
4117
+ fakebas[:,PTR_EXP] = ptr
4118
+ fakebas[:,PTR_COEFF] = ptr + contr_coeff.size
4119
+ coeff = contr_coeff / (2 * numpy.sqrt(numpy.pi) * gaussian_int(2, expnt))
4120
+ fakeenv.append(numpy.vstack((expnt, coeff)).ravel())
4121
+
4122
+ fakemol = Mole()
4123
+ fakemol._atm = fakeatm
4124
+ fakemol._bas = fakebas
4125
+ fakemol._env = numpy.hstack(fakeenv)
4126
+ fakemol._built = True
4127
+ return fakemol
4128
+
4074
4129
  def classify_ecp_pseudo(mol, ecp, pp):
4075
4130
  '''
4076
4131
  Check whether ecp keywords are presented in pp and whether pp keywords are
pyscf/gw/gw_ac.py CHANGED
@@ -20,7 +20,7 @@
20
20
  Spin-restricted G0W0 approximation with analytic continuation
21
21
  This implementation has N^4 scaling, and is faster than GW-CD (N^4)
22
22
  and analytic GW (N^6) methods.
23
- GW-AC is recommended for valence states only, and is inaccuarate for core states.
23
+ GW-AC is recommended for valence states only, and is inaccurate for core states.
24
24
 
25
25
  Method:
26
26
  See T. Zhu and G.K.-L. Chan, arxiv:2007.03148 (2020) for details
@@ -230,7 +230,7 @@ def _get_scaled_legendre_roots(nw):
230
230
 
231
231
  def _get_clenshaw_curtis_roots(nw):
232
232
  """
233
- Clenshaw-Curtis qaudrature on [0,inf)
233
+ Clenshaw-Curtis quadrature on [0,inf)
234
234
  Ref: J. Chem. Phys. 132, 234114 (2010)
235
235
  Returns:
236
236
  freqs : 1D ndarray
pyscf/gw/gw_cd.py CHANGED
@@ -192,7 +192,7 @@ def get_rho_response_R(gw, omega, Lpq):
192
192
 
193
193
  def get_sigmaR_diag(gw, omega, orbp, ef, Lpq):
194
194
  '''
195
- Compute self-energy for poles inside coutour
195
+ Compute self-energy for poles inside contour
196
196
  (more and more expensive away from Fermi surface)
197
197
  '''
198
198
  mo_energy = gw._scf.mo_energy
@@ -234,7 +234,7 @@ def _get_scaled_legendre_roots(nw):
234
234
 
235
235
  def _get_clenshaw_curtis_roots(nw):
236
236
  """
237
- Clenshaw-Curtis qaudrature on [0,inf)
237
+ Clenshaw-Curtis quadrature on [0,inf)
238
238
  Ref: J. Chem. Phys. 132, 234114 (2010)
239
239
  Returns:
240
240
  freqs : 1D ndarray
pyscf/gw/rpa.py CHANGED
@@ -21,7 +21,7 @@ Spin-restricted random phase approximation (direct RPA/dRPA in chemistry)
21
21
  with N^4 scaling
22
22
 
23
23
  Method:
24
- Main routines are based on GW-AC method descirbed in:
24
+ Main routines are based on GW-AC method described in:
25
25
  T. Zhu and G.K.-L. Chan, J. Chem. Theory. Comput. 17, 727-741 (2021)
26
26
  X. Ren et al., New J. Phys. 14, 053020 (2012)
27
27
  """
@@ -172,7 +172,7 @@ def _get_scaled_legendre_roots(nw, x0=0.5):
172
172
 
173
173
  def _get_clenshaw_curtis_roots(nw):
174
174
  """
175
- Clenshaw-Curtis qaudrature on [0,inf)
175
+ Clenshaw-Curtis quadrature on [0,inf)
176
176
  Ref: J. Chem. Phys. 132, 234114 (2010)
177
177
 
178
178
  Returns:
pyscf/gw/ugw_ac.py CHANGED
@@ -21,7 +21,7 @@ Spin-unrestricted G0W0 approximation with analytic continuation
21
21
 
22
22
  This implementation has N^4 scaling, and is faster than GW-CD (N^4)
23
23
  and analytic GW (N^6) methods.
24
- GW-AC is recommended for valence states only, and is inaccuarate for core states.
24
+ GW-AC is recommended for valence states only, and is inaccurate for core states.
25
25
 
26
26
  Method:
27
27
  See T. Zhu and G.K.-L. Chan, arxiv:2007.03148 (2020) for details
@@ -277,7 +277,7 @@ def _get_scaled_legendre_roots(nw):
277
277
 
278
278
  def _get_clenshaw_curtis_roots(nw):
279
279
  """
280
- Clenshaw-Curtis qaudrature on [0,inf)
280
+ Clenshaw-Curtis quadrature on [0,inf)
281
281
  Ref: J. Chem. Phys. 132, 234114 (2010)
282
282
  Returns:
283
283
  freqs : 1D ndarray
pyscf/gw/urpa.py CHANGED
@@ -21,7 +21,7 @@ Spin-unrestricted random phase approximation (direct RPA/dRPA in chemistry)
21
21
  with N^4 scaling
22
22
 
23
23
  Method:
24
- Main routines are based on GW-AC method descirbed in:
24
+ Main routines are based on GW-AC method described in:
25
25
  T. Zhu and G.K.-L. Chan, J. Chem. Theory. Comput. 17, 727-741 (2021)
26
26
  X. Ren et al., New J. Phys. 14, 053020 (2012)
27
27
  """
pyscf/hessian/rhf.py CHANGED
@@ -53,20 +53,13 @@ def hess_elec(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
53
53
  max_memory, log)
54
54
 
55
55
  if h1ao is None:
56
- h1ao = hessobj.make_h1(mo_coeff, mo_occ, hessobj.chkfile, atmlst, log)
56
+ h1ao = hessobj.make_h1(mo_coeff, mo_occ, None, atmlst, log)
57
57
  t1 = log.timer_debug1('making H1', *time0)
58
58
  if mo1 is None or mo_e1 is None:
59
59
  mo1, mo_e1 = hessobj.solve_mo1(mo_energy, mo_coeff, mo_occ, h1ao,
60
60
  None, atmlst, max_memory, log)
61
61
  t1 = log.timer_debug1('solving MO1', *t1)
62
62
 
63
- if isinstance(h1ao, str):
64
- h1ao = lib.chkfile.load(h1ao, 'scf_f1ao')
65
- h1ao = {int(k): h1ao[k] for k in h1ao}
66
- if isinstance(mo1, str):
67
- mo1 = lib.chkfile.load(mo1, 'scf_mo1')
68
- mo1 = {int(k): mo1[k] for k in mo1}
69
-
70
63
  nao, nmo = mo_coeff.shape
71
64
  mocc = mo_coeff[:,mo_occ>0]
72
65
  s1a = -mol.intor('int1e_ipovlp', comp=3)
@@ -136,9 +129,12 @@ def _partial_hess_ejk(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
136
129
  ip1ip2_opt = _make_vhfopt(mol, dm0, 'ip1ip2', 'int2e_ip1ip2')
137
130
  ipvip1_opt = _make_vhfopt(mol, dm0, 'ipvip1', 'int2e_ipvip1ipvip2')
138
131
  aoslices = mol.aoslice_by_atom()
139
- e1 = numpy.zeros((mol.natm,mol.natm,3,3))
140
- ej = numpy.zeros((mol.natm,mol.natm,3,3))
141
- ek = numpy.zeros((mol.natm,mol.natm,3,3))
132
+
133
+ natm = len(atmlst)
134
+ e1 = numpy.zeros((natm, natm, 3, 3))
135
+ ej = numpy.zeros((natm, natm, 3, 3))
136
+ ek = numpy.zeros((natm, natm, 3, 3))
137
+
142
138
  for i0, ia in enumerate(atmlst):
143
139
  shl0, shl1, p0, p1 = aoslices[ia]
144
140
  shls_slice = (shl0, shl1) + (0, mol.nbas)*3
@@ -159,24 +155,24 @@ def _partial_hess_ejk(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None,
159
155
  vk1 = vk1.reshape(3,3,nao,nao)
160
156
  t1 = log.timer_debug1('contracting int2e_ipvip1 for atom %d'%ia, *t1)
161
157
 
162
- ej[i0,i0] += numpy.einsum('xypq,pq->xy', vj1_diag[:,:,p0:p1], dm0[p0:p1])*2
163
- ek[i0,i0] += numpy.einsum('xypq,pq->xy', vk1_diag[:,:,p0:p1], dm0[p0:p1])
164
- e1[i0,i0] -= numpy.einsum('xypq,pq->xy', s1aa[:,:,p0:p1], dme0[p0:p1])*2
158
+ ej[i0, i0] += numpy.einsum('xypq,pq->xy', vj1_diag[:,:,p0:p1], dm0[p0:p1])*2
159
+ ek[i0, i0] += numpy.einsum('xypq,pq->xy', vk1_diag[:,:,p0:p1], dm0[p0:p1])
160
+ e1[i0, i0] -= numpy.einsum('xypq,pq->xy', s1aa[:,:,p0:p1], dme0[p0:p1])*2
165
161
 
166
162
  for j0, ja in enumerate(atmlst[:i0+1]):
167
163
  q0, q1 = aoslices[ja][2:]
168
164
  # *2 for +c.c.
169
- ej[i0,j0] += numpy.einsum('xypq,pq->xy', vj1[:,:,q0:q1], dm0[q0:q1])*4
170
- ek[i0,j0] += numpy.einsum('xypq,pq->xy', vk1[:,:,q0:q1], dm0[q0:q1])
171
- e1[i0,j0] -= numpy.einsum('xypq,pq->xy', s1ab[:,:,p0:p1,q0:q1], dme0[p0:p1,q0:q1])*2
165
+ ej[i0, j0] += numpy.einsum('xypq,pq->xy', vj1[:,:,q0:q1], dm0[q0:q1])*4
166
+ ek[i0, j0] += numpy.einsum('xypq,pq->xy', vk1[:,:,q0:q1], dm0[q0:q1])
167
+ e1[i0, j0] -= numpy.einsum('xypq,pq->xy', s1ab[:,:,p0:p1,q0:q1], dme0[p0:p1,q0:q1])*2
172
168
 
173
169
  h1ao = hcore_deriv(ia, ja)
174
- e1[i0,j0] += numpy.einsum('xypq,pq->xy', h1ao, dm0)
170
+ e1[i0, j0] += numpy.einsum('xypq,pq->xy', h1ao, dm0)
175
171
 
176
172
  for j0 in range(i0):
177
- e1[j0,i0] = e1[i0,j0].T
178
- ej[j0,i0] = ej[i0,j0].T
179
- ek[j0,i0] = ek[i0,j0].T
173
+ e1[j0, i0] = e1[i0, j0].T
174
+ ej[j0, i0] = ej[i0, j0].T
175
+ ek[j0, i0] = ek[i0, j0].T
180
176
 
181
177
  log.timer('RHF partial hessian', *time0)
182
178
  return e1, ej, ek
@@ -237,16 +233,8 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None):
237
233
  vhf[:,p0:p1] += vj2 - vk2*.5
238
234
  h1 = vhf + vhf.transpose(0,2,1)
239
235
  h1 += hcore_deriv(ia)
240
-
241
- if chkfile is None:
242
- h1ao[ia] = h1
243
- else:
244
- key = 'scf_f1ao/%d' % ia
245
- lib.chkfile.save(chkfile, key, h1)
246
- if chkfile is None:
247
- return h1ao
248
- else:
249
- return chkfile
236
+ h1ao[ia] = h1
237
+ return h1ao
250
238
 
251
239
  def get_hcore(mol):
252
240
  '''Part of the second derivatives of core Hamiltonian'''
@@ -295,7 +283,7 @@ def _get_jk(mol, intor, comp, aosym, script_dms,
295
283
  lib.hermi_triu(vs[k], hermi=hermi, inplace=True)
296
284
  return vs
297
285
 
298
- def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1ao_or_chkfile,
286
+ def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1ao,
299
287
  fx=None, atmlst=None, max_memory=4000, verbose=None,
300
288
  max_cycle=50, level_shift=0):
301
289
  '''Solve the first order equation
@@ -335,12 +323,7 @@ def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1ao_or_chkfile,
335
323
  s1ao[:,p0:p1] += s1a[:,p0:p1]
336
324
  s1ao[:,:,p0:p1] += s1a[:,p0:p1].transpose(0,2,1)
337
325
  s1vo.append(_ao2mo(s1ao))
338
- if isinstance(h1ao_or_chkfile, str):
339
- key = 'scf_f1ao/%d' % ia
340
- h1ao = lib.chkfile.load(h1ao_or_chkfile, key)
341
- else:
342
- h1ao = h1ao_or_chkfile[ia]
343
- h1vo.append(_ao2mo(h1ao))
326
+ h1vo.append(_ao2mo(h1ao[ia]))
344
327
 
345
328
  h1vo = numpy.vstack(h1vo)
346
329
  s1vo = numpy.vstack(s1vo)
@@ -352,18 +335,10 @@ def solve_mo1(mf, mo_energy, mo_coeff, mo_occ, h1ao_or_chkfile,
352
335
 
353
336
  for k in range(ia1-ia0):
354
337
  ia = atmlst[k+ia0]
355
- if isinstance(h1ao_or_chkfile, str):
356
- key = 'scf_mo1/%d' % ia
357
- lib.chkfile.save(h1ao_or_chkfile, key, mo1[k])
358
- else:
359
- mo1s[ia] = mo1[k]
338
+ mo1s[ia] = mo1[k]
360
339
  e1s[ia] = e1[k].reshape(3,nocc,nocc)
361
340
  mo1 = e1 = None
362
-
363
- if isinstance(h1ao_or_chkfile, str):
364
- return h1ao_or_chkfile, e1s
365
- else:
366
- return mo1s, e1s
341
+ return mo1s, e1s
367
342
 
368
343
  def gen_vind(mf, mo_coeff, mo_occ):
369
344
  nao, nmo = mo_coeff.shape
@@ -428,8 +403,7 @@ def gen_hop(hobj, mo_energy=None, mo_coeff=None, mo_occ=None, verbose=None):
428
403
  max_memory, log)
429
404
  de2 += hobj.hess_nuc()
430
405
 
431
- # Compute H1 integrals and store in hobj.chkfile
432
- hobj.make_h1(mo_coeff, mo_occ, hobj.chkfile, atmlst, log)
406
+ h1ao_cache = hobj.make_h1(mo_coeff, mo_occ, None, atmlst, log)
433
407
 
434
408
  aoslices = mol.aoslice_by_atom()
435
409
  s1a = -mol.intor('int1e_ipovlp', comp=3)
@@ -442,8 +416,7 @@ def gen_hop(hobj, mo_energy=None, mo_coeff=None, mo_occ=None, verbose=None):
442
416
  s1ao = 0
443
417
  for ia in range(natm):
444
418
  shl0, shl1, p0, p1 = aoslices[ia]
445
- h1ao_i = lib.chkfile.load(hobj.chkfile, 'scf_f1ao/%d' % ia)
446
- h1ao += numpy.einsum('x,xij->ij', x[ia], h1ao_i)
419
+ h1ao += numpy.einsum('x,xij->ij', x[ia], h1ao_cache[ia])
447
420
  s1ao_i = numpy.zeros((3,nao,nao))
448
421
  s1ao_i[:,p0:p1] += s1a[:,p0:p1]
449
422
  s1ao_i[:,:,p0:p1] += s1a[:,p0:p1].transpose(0,2,1)
@@ -460,8 +433,7 @@ def gen_hop(hobj, mo_energy=None, mo_coeff=None, mo_occ=None, verbose=None):
460
433
 
461
434
  for ja in range(natm):
462
435
  q0, q1 = aoslices[ja][2:]
463
- h1ao = lib.chkfile.load(hobj.chkfile, 'scf_f1ao/%s'%ja)
464
- hx[ja] += numpy.einsum('xpq,pq->x', h1ao, dm1) * 4
436
+ hx[ja] += numpy.einsum('xpq,pq->x', h1ao_cache[ja], dm1) * 4
465
437
  hx[ja] -= numpy.einsum('xpq,pq->x', s1a[:,q0:q1], dme1[q0:q1]) * 2
466
438
  hx[ja] -= numpy.einsum('xpq,qp->x', s1a[:,q0:q1], dme1[:,q0:q1]) * 2
467
439
  return hx.ravel()
@@ -481,16 +453,15 @@ class HessianBase(lib.StreamObject):
481
453
  level_shift = 0
482
454
 
483
455
  _keys = {
484
- 'mol', 'base', 'chkfile', 'atmlst', 'de', 'max_cycle', 'level_shift'
456
+ 'mol', 'base', 'atmlst', 'de', 'max_cycle', 'level_shift'
485
457
  }
486
458
 
487
459
  def __init__(self, scf_method):
488
460
  self.verbose = scf_method.verbose
489
461
  self.stdout = scf_method.stdout
490
462
  self.mol = scf_method.mol
491
- self.chkfile = scf_method.chkfile
492
- self.max_memory = self.mol.max_memory
493
463
  self.base = scf_method
464
+ self.max_memory = self.mol.max_memory
494
465
  self.atmlst = range(self.mol.natm)
495
466
  self.de = numpy.zeros((0,0,3,3)) # (A,B,dR_A,dR_B)
496
467
 
@@ -572,9 +543,9 @@ class HessianBase(lib.StreamObject):
572
543
  return hcore + hcore.conj().transpose(0,1,3,2)
573
544
  return get_hcore
574
545
 
575
- def solve_mo1(self, mo_energy, mo_coeff, mo_occ, h1ao_or_chkfile,
546
+ def solve_mo1(self, mo_energy, mo_coeff, mo_occ, h1ao,
576
547
  fx=None, atmlst=None, max_memory=4000, verbose=None):
577
- return solve_mo1(self.base, mo_energy, mo_coeff, mo_occ, h1ao_or_chkfile,
548
+ return solve_mo1(self.base, mo_energy, mo_coeff, mo_occ, h1ao,
578
549
  fx, atmlst, max_memory, verbose,
579
550
  max_cycle=self.max_cycle, level_shift=self.level_shift)
580
551
 
@@ -619,72 +590,3 @@ class Hessian(HessianBase):
619
590
  from pyscf import scf
620
591
  scf.hf.RHF.Hessian = lib.class_as_method(Hessian)
621
592
  scf.rohf.ROHF.Hessian = lib.invalid_method('Hessian')
622
-
623
-
624
- if __name__ == '__main__':
625
- from pyscf import scf
626
-
627
- mol = gto.Mole()
628
- mol.verbose = 0
629
- mol.output = None
630
- mol.atom = [
631
- [1 , (1. , 0. , 0.000)],
632
- [1 , (0. , 1. , 0.000)],
633
- [1 , (0. , -1.517 , 1.177)],
634
- [1 , (0. , 1.517 , 1.177)] ]
635
- mol.basis = '631g'
636
- mol.unit = 'B'
637
- mol.build()
638
- mf = scf.RHF(mol)
639
- mf.conv_tol = 1e-14
640
- mf.scf()
641
- n3 = mol.natm * 3
642
- hobj = mf.Hessian()
643
- e2 = hobj.kernel().transpose(0,2,1,3).reshape(n3,n3)
644
- print(lib.fp(e2) - -0.50693144355876429)
645
- #from hessian import rhf_o0
646
- #e2ref = rhf_o0.Hessian(mf).kernel().transpose(0,2,1,3).reshape(n3,n3)
647
- #print numpy.linalg.norm(e2-e2ref)
648
- #print numpy.allclose(e2,e2ref)
649
-
650
- def grad_full(ia, inc):
651
- coord = mol.atom_coord(ia).copy()
652
- ptr = mol._atm[ia,gto.PTR_COORD]
653
- de = []
654
- for i in range(3):
655
- mol._env[ptr+i] = coord[i] + inc
656
- mf = scf.RHF(mol).run(conv_tol=1e-14)
657
- e1a = mf.nuc_grad_method().kernel()
658
- mol._env[ptr+i] = coord[i] - inc
659
- mf = scf.RHF(mol).run(conv_tol=1e-14)
660
- e1b = mf.nuc_grad_method().kernel()
661
- mol._env[ptr+i] = coord[i]
662
- de.append((e1a-e1b)/(2*inc))
663
- return de
664
- e2ref = [grad_full(ia, .5e-4) for ia in range(mol.natm)]
665
- e2ref = numpy.asarray(e2ref).reshape(n3,n3)
666
- print(numpy.linalg.norm(e2-e2ref))
667
- print(abs(e2-e2ref).max())
668
- print(numpy.allclose(e2,e2ref,atol=1e-6))
669
-
670
- # \partial^2 E / \partial R \partial R'
671
- e2 = hobj.partial_hess_elec(mf.mo_energy, mf.mo_coeff, mf.mo_occ)
672
- e2 += hobj.hess_nuc(mol)
673
- e2 = e2.transpose(0,2,1,3).reshape(n3,n3)
674
- def grad_partial_R(ia, inc):
675
- coord = mol.atom_coord(ia).copy()
676
- ptr = mol._atm[ia,gto.PTR_COORD]
677
- de = []
678
- for i in range(3):
679
- mol._env[ptr+i] = coord[i] + inc
680
- e1a = mf.nuc_grad_method().kernel()
681
- mol._env[ptr+i] = coord[i] - inc
682
- e1b = mf.nuc_grad_method().kernel()
683
- mol._env[ptr+i] = coord[i]
684
- de.append((e1a-e1b)/(2*inc))
685
- return de
686
- e2ref = [grad_partial_R(ia, .5e-4) for ia in range(mol.natm)]
687
- e2ref = numpy.asarray(e2ref).reshape(n3,n3)
688
- print(numpy.linalg.norm(e2-e2ref))
689
- print(abs(e2-e2ref).max())
690
- print(numpy.allclose(e2,e2ref,atol=1e-8))
pyscf/hessian/rks.py CHANGED
@@ -161,12 +161,7 @@ def make_h1(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None, verbose=None):
161
161
  h1ao[ia] += veff + veff.transpose(0,2,1)
162
162
  h1ao[ia] += hcore_deriv(ia)
163
163
 
164
- if chkfile is None:
165
- return h1ao
166
- else:
167
- for ia in atmlst:
168
- lib.chkfile.save(chkfile, 'scf_f1ao/%d'%ia, h1ao[ia])
169
- return chkfile
164
+ return h1ao
170
165
 
171
166
  XX, XY, XZ = 4, 5, 6
172
167
  YX, YY, YZ = 5, 7, 8