pyscf 2.6.2__py3-none-macosx_11_0_arm64.whl → 2.8.0__py3-none-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyscf/__init__.py +2 -2
- pyscf/adc/__init__.py +3 -8
- pyscf/adc/dfadc.py +22 -6
- pyscf/adc/radc.py +106 -15
- pyscf/adc/radc_amplitudes.py +7 -1
- pyscf/adc/radc_ao2mo.py +4 -2
- pyscf/adc/radc_ea.py +524 -8
- pyscf/adc/radc_ip.py +492 -60
- pyscf/adc/radc_ip_cvs.py +4 -2
- pyscf/adc/uadc.py +116 -27
- pyscf/adc/uadc_amplitudes.py +215 -20
- pyscf/adc/uadc_ao2mo.py +30 -9
- pyscf/adc/uadc_ea.py +34 -44
- pyscf/adc/uadc_ip.py +9 -4
- pyscf/adc/uadc_ip_cvs.py +4 -1
- pyscf/agf2/__init__.py +2 -2
- pyscf/agf2/aux_space.py +1 -1
- pyscf/agf2/chkfile.py +1 -1
- pyscf/ao2mo/__init__.py +13 -2
- pyscf/ao2mo/_ao2mo.py +10 -1
- pyscf/ao2mo/incore.py +3 -0
- pyscf/ao2mo/nrr_outcore.py +2 -2
- pyscf/ao2mo/outcore.py +9 -7
- pyscf/ao2mo/r_outcore.py +2 -2
- pyscf/cc/__init__.py +21 -3
- pyscf/cc/bccd.py +0 -46
- pyscf/cc/ccsd.py +29 -13
- pyscf/cc/ccsd_rdm.py +6 -1
- pyscf/cc/gccsd.py +2 -2
- pyscf/cc/uccsd.py +7 -7
- pyscf/cc/uccsd_rdm.py +2 -2
- pyscf/data/elements.py +1 -1
- pyscf/df/__init__.py +2 -1
- pyscf/df/addons.py +79 -51
- pyscf/df/autoaux.py +195 -0
- pyscf/df/df.py +5 -1
- pyscf/df/df_jk.py +27 -25
- pyscf/df/grad/casscf.py +0 -41
- pyscf/df/grad/rhf.py +31 -1
- pyscf/df/hessian/rhf.py +2 -10
- pyscf/df/hessian/rks.py +1 -7
- pyscf/df/hessian/uhf.py +3 -13
- pyscf/df/hessian/uks.py +1 -8
- pyscf/df/incore.py +18 -6
- pyscf/df/outcore.py +6 -6
- pyscf/dft/dks.py +1 -1
- pyscf/dft/gks.py +25 -21
- pyscf/dft/libxc.py +91 -645
- pyscf/dft/numint.py +40 -19
- pyscf/dft/radi.py +48 -7
- pyscf/dft/rks.py +29 -25
- pyscf/dft/roks.py +7 -1
- pyscf/dft/uks.py +34 -25
- pyscf/dft/xc_deriv.py +1 -1
- pyscf/dft/xcfun.py +53 -2
- pyscf/eph/eph_fd.py +1 -1
- pyscf/eph/rhf.py +6 -36
- pyscf/eph/rks.py +0 -4
- pyscf/eph/uhf.py +1 -7
- pyscf/eph/uks.py +1 -7
- pyscf/fci/addons.py +117 -2
- pyscf/fci/cistring.py +1 -1
- pyscf/fci/direct_nosym.py +3 -3
- pyscf/fci/direct_spin0_symm.py +22 -43
- pyscf/fci/direct_spin1.py +65 -10
- pyscf/fci/direct_spin1_symm.py +49 -14
- pyscf/fci/direct_uhf.py +4 -4
- pyscf/fci/selected_ci_symm.py +1 -1
- pyscf/grad/ccsd.py +3 -7
- pyscf/grad/ccsd_slow.py +2 -3
- pyscf/grad/lagrange.py +11 -3
- pyscf/grad/mp2.py +13 -4
- pyscf/grad/sacasscf.py +1 -1
- pyscf/grad/tdrks.py +1 -1
- pyscf/grad/uccsd.py +3 -7
- pyscf/grad/ump2.py +2 -4
- pyscf/gto/basis/__init__.py +17 -4
- pyscf/gto/basis/bse.py +68 -15
- pyscf/gto/basis/def2-mtzvp.dat +4719 -0
- pyscf/gto/basis/def2-mtzvpp.dat +4739 -0
- pyscf/gto/basis/dyall-basis/__init__.py +0 -0
- pyscf/gto/basis/dyall-basis/dyall_2zp.py +6492 -0
- pyscf/gto/basis/dyall-basis/dyall_3zp.py +8343 -0
- pyscf/gto/basis/dyall-basis/dyall_4zp.py +10055 -0
- pyscf/gto/basis/dyall-basis/dyall_aae2z.py +1818 -0
- pyscf/gto/basis/dyall-basis/dyall_aae3z.py +2521 -0
- pyscf/gto/basis/dyall-basis/dyall_aae4z.py +3351 -0
- pyscf/gto/basis/dyall-basis/dyall_acv2z.py +1790 -0
- pyscf/gto/basis/dyall-basis/dyall_acv3z.py +2417 -0
- pyscf/gto/basis/dyall-basis/dyall_acv4z.py +3085 -0
- pyscf/gto/basis/dyall-basis/dyall_ae2z.py +6619 -0
- pyscf/gto/basis/dyall-basis/dyall_ae3z.py +9027 -0
- pyscf/gto/basis/dyall-basis/dyall_ae4z.py +11839 -0
- pyscf/gto/basis/dyall-basis/dyall_av2z.py +1742 -0
- pyscf/gto/basis/dyall-basis/dyall_av3z.py +2318 -0
- pyscf/gto/basis/dyall-basis/dyall_av4z.py +2905 -0
- pyscf/gto/basis/dyall-basis/dyall_cv2z.py +6558 -0
- pyscf/gto/basis/dyall-basis/dyall_cv3z.py +8767 -0
- pyscf/gto/basis/dyall-basis/dyall_cv4z.py +11098 -0
- pyscf/gto/basis/dyall-basis/dyall_v2z.py +6472 -0
- pyscf/gto/basis/dyall-basis/dyall_v3z.py +8539 -0
- pyscf/gto/basis/dyall-basis/dyall_v4z.py +10658 -0
- pyscf/gto/basis/ma-def2-qzvp.dat +5959 -0
- pyscf/gto/basis/ma-def2-qzvpp.dat +6195 -0
- pyscf/gto/basis/ma-def2-svp.dat +3504 -0
- pyscf/gto/basis/ma-def2-svpp.dat +3504 -0
- pyscf/gto/basis/ma-def2-tzvp.dat +4347 -0
- pyscf/gto/basis/ma-def2-tzvpp.dat +4549 -0
- pyscf/gto/basis/parse_cp2k.py +8 -7
- pyscf/gto/basis/parse_cp2k_pp.py +1 -1
- pyscf/gto/basis/parse_nwchem.py +26 -11
- pyscf/gto/basis/parse_nwchem_ecp.py +2 -1
- pyscf/gto/basis/sap_grasp_large.dat +2438 -0
- pyscf/gto/basis/sap_grasp_small.dat +1434 -0
- pyscf/gto/eval_gto.py +1 -1
- pyscf/gto/ft_ao.py +6 -6
- pyscf/gto/mole.py +123 -71
- pyscf/gto/moleintor.py +1 -1
- pyscf/gw/gw_ac.py +2 -2
- pyscf/gw/gw_cd.py +2 -2
- pyscf/gw/rpa.py +135 -246
- pyscf/gw/ugw_ac.py +2 -2
- pyscf/gw/urpa.py +80 -131
- pyscf/hessian/rhf.py +30 -128
- pyscf/hessian/rks.py +1 -6
- pyscf/hessian/uhf.py +28 -138
- pyscf/hessian/uks.py +1 -8
- pyscf/lib/CMakeLists.txt +6 -2
- pyscf/lib/ao2mo/nr_ao2mo.c +1 -1
- pyscf/lib/ao2mo/nrr_ao2mo.c +1 -1
- pyscf/lib/ao2mo/r_ao2mo.c +1 -1
- pyscf/lib/cc/ccsd_pack.c +1 -1
- pyscf/lib/cc/ccsd_t.c +6 -6
- pyscf/lib/cc/uccsd_t.c +4 -4
- pyscf/lib/config.h +0 -1
- pyscf/lib/config.h.in +0 -1
- pyscf/lib/deps/include/XCFun/XCFunExport.h +1 -0
- pyscf/lib/deps/include/xc.h +28 -18
- pyscf/lib/deps/include/xc_funcs.h +50 -2
- pyscf/lib/deps/include/xc_version.h +3 -3
- pyscf/lib/deps/lib/libcint.6.dylib +0 -0
- pyscf/lib/deps/lib/{libxc.12.dylib → libxc.15.dylib} +0 -0
- pyscf/lib/deps/lib/libxcfun.2.dylib +0 -0
- pyscf/lib/dft/grid_common.c +1 -1
- pyscf/lib/dft/libxc_itrf.c +10 -7
- pyscf/lib/dft/nr_numint_sparse.c +3 -3
- pyscf/lib/dft/xcfun_itrf.c +1 -1
- pyscf/lib/diis.py +2 -2
- pyscf/lib/exceptions.py +6 -0
- pyscf/lib/gto/fill_grids_int2c.c +11 -9
- pyscf/lib/gto/fill_int2e.c +7 -5
- pyscf/lib/gto/fill_r_4c.c +1 -1
- pyscf/lib/gto/ft_ao.c +1 -1
- pyscf/lib/gto/ft_ao.h +1 -1
- pyscf/lib/gto/gto.h +2 -2
- pyscf/lib/gto/nr_ecp.c +3 -2
- pyscf/lib/libagf2.dylib +0 -0
- pyscf/lib/libao2mo.dylib +0 -0
- pyscf/lib/libcc.dylib +0 -0
- pyscf/lib/libcgto.dylib +0 -0
- pyscf/lib/libcvhf.dylib +0 -0
- pyscf/lib/libdft.dylib +0 -0
- pyscf/lib/libfci.dylib +0 -0
- pyscf/lib/libmcscf.dylib +0 -0
- pyscf/lib/libmp.dylib +0 -0
- pyscf/lib/libnp_helper.dylib +0 -0
- pyscf/lib/libpbc.dylib +0 -0
- pyscf/lib/libri.dylib +0 -0
- pyscf/lib/libxc_itrf.dylib +0 -0
- pyscf/lib/libxcfun_itrf.dylib +0 -0
- pyscf/lib/linalg_helper.py +117 -198
- pyscf/lib/logger.py +2 -1
- pyscf/lib/mcscf/fci_contract.c +10 -3
- pyscf/lib/misc.py +63 -22
- pyscf/lib/mp/CMakeLists.txt +22 -0
- pyscf/lib/mp/mp2.c +518 -0
- pyscf/lib/mp/mp2.h +44 -0
- pyscf/lib/np_helper/CMakeLists.txt +1 -1
- pyscf/lib/np_helper/imatcopy.c +360 -0
- pyscf/lib/np_helper/np_helper.c +94 -0
- pyscf/lib/np_helper/np_helper.h +26 -0
- pyscf/lib/numpy_helper.py +195 -11
- pyscf/lib/pbc/nr_direct.c +2 -7
- pyscf/lib/pbc/nr_ecp.c +10 -3
- pyscf/lib/pbc/pbc.h +1 -1
- pyscf/lib/vhf/fblas.h +3 -0
- pyscf/lib/vhf/nr_sgx_direct.c +8 -6
- pyscf/lib/vhf/nr_sr_vhf.c +8 -12
- pyscf/lib/vhf/optimizer.c +2 -2
- pyscf/lib/vhf/rkb_screen.c +139 -0
- pyscf/lo/iao.py +1 -1
- pyscf/lo/ibo.py +3 -3
- pyscf/lo/pipek_jacobi.py +1 -1
- pyscf/mcscf/__init__.py +2 -2
- pyscf/mcscf/addons.py +3 -3
- pyscf/mcscf/apc.py +2 -2
- pyscf/mcscf/casci.py +13 -7
- pyscf/mcscf/chkfile.py +69 -41
- pyscf/mcscf/dmet_cas.py +2 -2
- pyscf/mcscf/mc1step.py +72 -44
- pyscf/mcscf/newton_casscf.py +5 -5
- pyscf/mcscf/ucasci.py +1 -1
- pyscf/mcscf/umc1step.py +49 -28
- pyscf/md/integrators.py +3 -3
- pyscf/mp/__init__.py +1 -0
- pyscf/mp/dfmp2.py +498 -59
- pyscf/mp/dfmp2_native.py +11 -1
- pyscf/mp/dfmp2_slow.py +133 -0
- pyscf/mp/dfump2.py +672 -0
- pyscf/mp/dfump2_native.py +9 -0
- pyscf/mp/dfump2_slow.py +161 -0
- pyscf/mp/gmp2.py +6 -47
- pyscf/mp/mp2.py +25 -10
- pyscf/mp/ump2.py +30 -24
- pyscf/pbc/adc/kadc_rhf.py +1 -1
- pyscf/pbc/adc/kadc_rhf_amplitudes.py +2 -2
- pyscf/pbc/ao2mo/eris.py +1 -1
- pyscf/pbc/cc/kccsd_rhf.py +3 -3
- pyscf/pbc/cc/kccsd_t_rhf.py +2 -2
- pyscf/pbc/ci/kcis_rhf.py +2 -2
- pyscf/pbc/df/aft.py +8 -9
- pyscf/pbc/df/aft_ao2mo.py +1 -1
- pyscf/pbc/df/df.py +85 -12
- pyscf/pbc/df/df_jk.py +6 -2
- pyscf/pbc/df/fft.py +9 -5
- pyscf/pbc/df/fft_ao2mo.py +4 -0
- pyscf/pbc/df/fft_jk.py +18 -10
- pyscf/pbc/df/ft_ao.py +4 -3
- pyscf/pbc/df/gdf_builder.py +5 -4
- pyscf/pbc/df/incore.py +2 -2
- pyscf/pbc/df/mdf.py +6 -3
- pyscf/pbc/df/mdf_jk.py +2 -1
- pyscf/pbc/df/outcore.py +10 -10
- pyscf/pbc/df/rsdf.py +2 -2
- pyscf/pbc/df/rsdf_builder.py +13 -8
- pyscf/pbc/df/rsdf_helper.py +6 -6
- pyscf/pbc/df/rsdf_jk.py +2 -1
- pyscf/pbc/dft/cdft.py +5 -5
- pyscf/pbc/dft/gen_grid.py +3 -2
- pyscf/pbc/dft/gks.py +14 -3
- pyscf/pbc/dft/kgks.py +15 -4
- pyscf/pbc/dft/krks.py +28 -10
- pyscf/pbc/dft/krks_ksymm.py +21 -9
- pyscf/pbc/dft/krkspu.py +1 -30
- pyscf/pbc/dft/krkspu_ksymm.py +0 -30
- pyscf/pbc/dft/kuks.py +30 -13
- pyscf/pbc/dft/kuks_ksymm.py +22 -10
- pyscf/pbc/dft/kukspu.py +0 -27
- pyscf/pbc/dft/kukspu_ksymm.py +0 -30
- pyscf/pbc/dft/multigrid/multigrid.py +36 -33
- pyscf/pbc/dft/multigrid/multigrid_pair.py +7 -2
- pyscf/pbc/dft/multigrid/pp.py +1 -1
- pyscf/pbc/dft/numint.py +56 -31
- pyscf/pbc/dft/rks.py +16 -24
- pyscf/pbc/dft/uks.py +21 -4
- pyscf/pbc/eph/eph_fd.py +1 -1
- pyscf/pbc/geomopt/geometric_solver.py +1 -1
- pyscf/pbc/gto/_pbcintor.py +1 -0
- pyscf/pbc/gto/cell.py +194 -23
- pyscf/pbc/gto/ecp.py +12 -12
- pyscf/pbc/gto/eval_gto.py +3 -3
- pyscf/pbc/gto/neighborlist.py +4 -1
- pyscf/pbc/gto/pseudo/pp.py +1 -1
- pyscf/pbc/gw/krgw_ac.py +4 -4
- pyscf/pbc/gw/krgw_cd.py +4 -4
- pyscf/pbc/gw/kugw_ac.py +3 -3
- pyscf/pbc/lib/kpts_helper.py +4 -3
- pyscf/pbc/lib/linalg_helper.py +1 -1
- pyscf/pbc/mp/kmp2.py +1 -1
- pyscf/pbc/mpitools/mpi.py +1 -1
- pyscf/pbc/scf/_response_functions.py +141 -34
- pyscf/pbc/scf/addons.py +15 -11
- pyscf/pbc/scf/cphf.py +1 -1
- pyscf/pbc/scf/ghf.py +1 -1
- pyscf/pbc/scf/hf.py +21 -32
- pyscf/pbc/scf/kghf.py +33 -29
- pyscf/pbc/scf/khf.py +103 -29
- pyscf/pbc/scf/khf_ksymm.py +15 -1
- pyscf/pbc/scf/krohf.py +5 -7
- pyscf/pbc/scf/kuhf.py +54 -23
- pyscf/pbc/scf/kuhf_ksymm.py +1 -1
- pyscf/pbc/scf/rsjk.py +14 -10
- pyscf/pbc/scf/scfint.py +1 -1
- pyscf/pbc/scf/stability.py +27 -15
- pyscf/pbc/scf/uhf.py +3 -1
- pyscf/pbc/symm/symmetry.py +2 -2
- pyscf/pbc/tdscf/krhf.py +238 -154
- pyscf/pbc/tdscf/krks.py +1 -45
- pyscf/pbc/tdscf/kuhf.py +319 -171
- pyscf/pbc/tdscf/kuks.py +0 -56
- pyscf/pbc/tdscf/rhf.py +116 -3
- pyscf/pbc/tdscf/rks.py +2 -1
- pyscf/pbc/tdscf/uhf.py +214 -1
- pyscf/pbc/tdscf/uks.py +2 -1
- pyscf/pbc/tools/k2gamma.py +20 -6
- pyscf/pbc/tools/lattice.py +3 -3
- pyscf/pbc/tools/pbc.py +111 -91
- pyscf/pbc/tools/pyscf_ase.py +0 -1
- pyscf/pbc/tools/pywannier90.py +1 -1
- pyscf/qmmm/mm_mole.py +1 -1
- pyscf/scf/_response_functions.py +87 -46
- pyscf/scf/_vhf.py +15 -10
- pyscf/scf/addons.py +29 -15
- pyscf/scf/cphf.py +14 -52
- pyscf/scf/dhf.py +121 -38
- pyscf/scf/dispersion.py +10 -9
- pyscf/scf/ghf.py +25 -13
- pyscf/scf/ghf_symm.py +2 -2
- pyscf/scf/hf.py +262 -30
- pyscf/scf/rohf.py +37 -5
- pyscf/scf/stability.py +142 -112
- pyscf/scf/ucphf.py +21 -16
- pyscf/scf/uhf.py +104 -61
- pyscf/sgx/sgx.py +1 -1
- pyscf/sgx/sgx_jk.py +4 -4
- pyscf/solvent/__init__.py +2 -2
- pyscf/solvent/_attach_solvent.py +2 -0
- pyscf/solvent/_ddcosmo_tdscf_grad.py +1 -1
- pyscf/solvent/cosmors.py +366 -0
- pyscf/solvent/ddcosmo.py +1 -1
- pyscf/solvent/pcm.py +4 -4
- pyscf/solvent/pol_embed.py +1 -1
- pyscf/solvent/smd.py +5 -3
- pyscf/soscf/ciah.py +3 -11
- pyscf/soscf/newton_ah.py +5 -2
- pyscf/symm/__init__.py +1 -1
- pyscf/symm/addons.py +5 -5
- pyscf/symm/geom.py +1 -5
- pyscf/tdscf/_lr_eig.py +1002 -0
- pyscf/tdscf/dhf.py +84 -87
- pyscf/tdscf/dks.py +0 -4
- pyscf/tdscf/ghf.py +139 -127
- pyscf/tdscf/gks.py +27 -25
- pyscf/tdscf/rhf.py +194 -147
- pyscf/tdscf/rks.py +26 -22
- pyscf/tdscf/uhf.py +166 -118
- pyscf/tdscf/uks.py +32 -31
- pyscf/tools/fcidump.py +3 -0
- pyscf/tools/qcschema.py +265 -0
- pyscf/x2c/sfx2c1e.py +1 -1
- pyscf/x2c/tdscf.py +41 -41
- pyscf/x2c/x2c.py +15 -11
- {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/METADATA +39 -36
- {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/NOTICE +14 -1
- {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/RECORD +348 -316
- {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/WHEEL +1 -1
- pyscf/dft/gen_libxc_param.py +0 -35
- pyscf/dft/gen_xcfun_param.py +0 -209
- pyscf/pbc/tdscf/kproxy.py +0 -189
- pyscf/pbc/tdscf/kproxy_supercell.py +0 -664
- pyscf/pbc/tdscf/krhf_slow.py +0 -300
- pyscf/pbc/tdscf/krhf_slow_gamma.py +0 -175
- pyscf/pbc/tdscf/krhf_slow_supercell.py +0 -250
- pyscf/pbc/tdscf/proxy.py +0 -39
- pyscf/pbc/tdscf/rhf_slow.py +0 -35
- pyscf/tdscf/common_slow.py +0 -799
- pyscf/tdscf/proxy.py +0 -258
- pyscf/tdscf/rhf_slow.py +0 -181
- {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/LICENSE +0 -0
- {pyscf-2.6.2.dist-info → pyscf-2.8.0.dist-info}/top_level.txt +0 -0
pyscf/cc/uccsd.py
CHANGED
|
@@ -396,12 +396,12 @@ def vector_to_amplitudes(vector, nmo, nocc):
|
|
|
396
396
|
nvir = nvira + nvirb
|
|
397
397
|
nov = nocc * nvir
|
|
398
398
|
size = nov + nocc*(nocc-1)//2*nvir*(nvir-1)//2
|
|
399
|
-
|
|
399
|
+
sizea = nocca * nvira + nocca*(nocca-1)//2*nvira*(nvira-1)//2
|
|
400
|
+
sizeb = noccb * nvirb + noccb*(noccb-1)//2*nvirb*(nvirb-1)//2
|
|
401
|
+
if vector.size == size and sizea > 0 and sizeb > 0:
|
|
400
402
|
#return ccsd.vector_to_amplitudes_s4(vector, nmo, nocc)
|
|
401
|
-
raise RuntimeError('Input vector is GCCSD
|
|
403
|
+
raise RuntimeError('Input vector is GCCSD vector')
|
|
402
404
|
else:
|
|
403
|
-
sizea = nocca * nvira + nocca*(nocca-1)//2*nvira*(nvira-1)//2
|
|
404
|
-
sizeb = noccb * nvirb + noccb*(noccb-1)//2*nvirb*(nvirb-1)//2
|
|
405
405
|
sections = np.cumsum([sizea, sizeb])
|
|
406
406
|
veca, vecb, t2ab = np.split(vector, sections)
|
|
407
407
|
t1a, t2aa = ccsd.vector_to_amplitudes_s4(veca, nmoa, nocca)
|
|
@@ -574,9 +574,9 @@ class UCCSD(ccsd.CCSDBase):
|
|
|
574
574
|
eris_ovov = np.asarray(eris.ovov)
|
|
575
575
|
eris_OVOV = np.asarray(eris.OVOV)
|
|
576
576
|
eris_ovOV = np.asarray(eris.ovOV)
|
|
577
|
-
t2aa = eris_ovov.transpose(0,2,1,3) / lib.direct_sum('ia+jb->ijab', eia_a, eia_a)
|
|
578
|
-
t2ab = eris_ovOV.transpose(0,2,1,3) / lib.direct_sum('ia+jb->ijab', eia_a, eia_b)
|
|
579
|
-
t2bb = eris_OVOV.transpose(0,2,1,3) / lib.direct_sum('ia+jb->ijab', eia_b, eia_b)
|
|
577
|
+
t2aa = eris_ovov.transpose(0,2,1,3).conj() / lib.direct_sum('ia+jb->ijab', eia_a, eia_a)
|
|
578
|
+
t2ab = eris_ovOV.transpose(0,2,1,3).conj() / lib.direct_sum('ia+jb->ijab', eia_a, eia_b)
|
|
579
|
+
t2bb = eris_OVOV.transpose(0,2,1,3).conj() / lib.direct_sum('ia+jb->ijab', eia_b, eia_b)
|
|
580
580
|
t2aa = t2aa - t2aa.transpose(0,1,3,2)
|
|
581
581
|
t2bb = t2bb - t2bb.transpose(0,1,3,2)
|
|
582
582
|
e = np.einsum('iJaB,iaJB', t2ab, eris_ovOV)
|
pyscf/cc/uccsd_rdm.py
CHANGED
|
@@ -625,8 +625,8 @@ def _make_rdm2(mycc, d1, d2, with_dm1=True, with_frozen=True, ao_repr=False):
|
|
|
625
625
|
|
|
626
626
|
|
|
627
627
|
def _dm2ab_mo2ao(dm2, mo_a, mo_b):
|
|
628
|
-
return lib.einsum('ijkl,pi,qj,rk,sl->pqrs', dm2, mo_a
|
|
629
|
-
mo_b
|
|
628
|
+
return lib.einsum('ijkl,pi,qj,rk,sl->pqrs', dm2, mo_a.conj(), mo_a,
|
|
629
|
+
mo_b.conj(), mo_b)
|
|
630
630
|
|
|
631
631
|
|
|
632
632
|
if __name__ == '__main__':
|
pyscf/data/elements.py
CHANGED
|
@@ -827,7 +827,7 @@ NRSRHFS_CONFIGURATION = [
|
|
|
827
827
|
[14,36,40,28], #118 Og
|
|
828
828
|
]
|
|
829
829
|
|
|
830
|
-
# This is No. of shells, not the atomic
|
|
830
|
+
# This is No. of shells, not the atomic configurations
|
|
831
831
|
# core core+valence
|
|
832
832
|
# core+valence = lambda nuc, l: \
|
|
833
833
|
# int(numpy.ceil(pyscf.lib.parameters.ELEMENTS[nuc][2][l]/(4*l+2.)))
|
pyscf/df/__init__.py
CHANGED
|
@@ -34,7 +34,8 @@ Simple usage::
|
|
|
34
34
|
from . import incore
|
|
35
35
|
from . import outcore
|
|
36
36
|
from . import addons
|
|
37
|
-
from .addons import load, aug_etb,
|
|
37
|
+
from .addons import (load, aug_etb, autoaux, autoabs,
|
|
38
|
+
DEFAULT_AUXBASIS, make_auxbasis, make_auxmol)
|
|
38
39
|
from .df import DF, GDF, DF4C, GDF4C
|
|
39
40
|
|
|
40
41
|
from . import r_incore
|
pyscf/df/addons.py
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
# Author: Qiming Sun <osirpt.sun@gmail.com>
|
|
17
17
|
#
|
|
18
18
|
|
|
19
|
+
|
|
19
20
|
import sys
|
|
20
21
|
import numpy
|
|
21
22
|
from pyscf.lib import logger
|
|
@@ -23,12 +24,18 @@ from pyscf import gto
|
|
|
23
24
|
from pyscf import ao2mo
|
|
24
25
|
from pyscf.data import elements
|
|
25
26
|
from pyscf.lib.exceptions import BasisNotFoundError
|
|
27
|
+
from pyscf.df.autoaux import autoaux, autoabs
|
|
26
28
|
from pyscf import __config__
|
|
27
29
|
|
|
28
30
|
DFBASIS = getattr(__config__, 'df_addons_aug_etb_beta', 'weigend')
|
|
29
31
|
ETB_BETA = getattr(__config__, 'df_addons_aug_dfbasis', 2.0)
|
|
30
32
|
FIRST_ETB_ELEMENT = getattr(__config__, 'df_addons_aug_start_at', 36) # 'Rb'
|
|
31
33
|
|
|
34
|
+
# TODO: Switch to other default scheme for auxiliary basis generation.
|
|
35
|
+
# The auxiliary basis set generated by version 2.6 (and earlier) lacks compact
|
|
36
|
+
# functions. It may cause higher errors in ERI integrals.
|
|
37
|
+
USE_VERSION_26_AUXBASIS = True
|
|
38
|
+
|
|
32
39
|
# Obtained from http://www.psicode.org/psi4manual/master/basissets_byfamily.html
|
|
33
40
|
DEFAULT_AUXBASIS = {
|
|
34
41
|
# AO basis JK-fit MP2-fit
|
|
@@ -72,6 +79,58 @@ class load(ao2mo.load):
|
|
|
72
79
|
def __init__(self, eri, dataname='j3c'):
|
|
73
80
|
ao2mo.load.__init__(self, eri, dataname)
|
|
74
81
|
|
|
82
|
+
def _aug_etb_element(nuc_charge, basis, beta):
|
|
83
|
+
l_max = max(b[0] for b in basis)
|
|
84
|
+
emin_by_l = [1e99] * (l_max+1)
|
|
85
|
+
emax_by_l = [0] * (l_max+1)
|
|
86
|
+
for b in basis:
|
|
87
|
+
l = b[0]
|
|
88
|
+
if isinstance(b[1], int):
|
|
89
|
+
e_c = numpy.array(b[2:])
|
|
90
|
+
else:
|
|
91
|
+
e_c = numpy.array(b[1:])
|
|
92
|
+
es = e_c[:,0]
|
|
93
|
+
cs = e_c[:,1:]
|
|
94
|
+
es = es[abs(cs).max(axis=1) > 1e-3]
|
|
95
|
+
emax_by_l[l] = max(es.max(), emax_by_l[l])
|
|
96
|
+
emin_by_l[l] = min(es.min(), emin_by_l[l])
|
|
97
|
+
|
|
98
|
+
conf = elements.CONFIGURATION[nuc_charge]
|
|
99
|
+
# 1: H - Be, 2: B - Ca, 3: Sc - La, 4: Ce -
|
|
100
|
+
max_shells = 4 - conf.count(0)
|
|
101
|
+
|
|
102
|
+
if USE_VERSION_26_AUXBASIS:
|
|
103
|
+
# This is the method that version 2.6 (and earlier) generates auxiliary
|
|
104
|
+
# basis. It estimates the exponents ranges by geometric average.
|
|
105
|
+
# This method is not recommended because it tends to generate diffuse
|
|
106
|
+
# functions. Important compact functions might be improperly excluded.
|
|
107
|
+
l_max = min(l_max, max_shells)
|
|
108
|
+
l_max_aux = l_max * 2
|
|
109
|
+
l_max1 = l_max + 1
|
|
110
|
+
emin_by_l = numpy.array(emin_by_l[:l_max1])
|
|
111
|
+
emax_by_l = numpy.array(emax_by_l[:l_max1])
|
|
112
|
+
emax = (emax_by_l[:,None] * emax_by_l) ** .5 * 2
|
|
113
|
+
emin = (emin_by_l[:,None] * emin_by_l) ** .5 * 2
|
|
114
|
+
else:
|
|
115
|
+
# Using normal average, more auxiliary functions, especially compact
|
|
116
|
+
# functions, will be generated.
|
|
117
|
+
l_max_aux = min(l_max, max_shells) * 2
|
|
118
|
+
l_max1 = l_max + 1
|
|
119
|
+
emin_by_l = numpy.array(emin_by_l)
|
|
120
|
+
emax_by_l = numpy.array(emax_by_l)
|
|
121
|
+
emax = emax_by_l[:,None] + emax_by_l
|
|
122
|
+
emin = emin_by_l[:,None] + emin_by_l
|
|
123
|
+
|
|
124
|
+
liljsum = numpy.arange(l_max1)[:,None] + numpy.arange(l_max1)
|
|
125
|
+
emax_by_l = numpy.array([emax[liljsum==ll].max() for ll in range(l_max_aux+1)])
|
|
126
|
+
emin_by_l = numpy.array([emin[liljsum==ll].min() for ll in range(l_max_aux+1)])
|
|
127
|
+
|
|
128
|
+
ns = numpy.log((emax_by_l+emin_by_l)/emin_by_l) / numpy.log(beta)
|
|
129
|
+
etb = []
|
|
130
|
+
for l, n in enumerate(numpy.ceil(ns).astype(int)):
|
|
131
|
+
if n > 0:
|
|
132
|
+
etb.append((l, n, emin_by_l[l], beta))
|
|
133
|
+
return etb
|
|
75
134
|
|
|
76
135
|
def aug_etb_for_dfbasis(mol, dfbasis=DFBASIS, beta=ETB_BETA,
|
|
77
136
|
start_at=FIRST_ETB_ELEMENT):
|
|
@@ -86,50 +145,14 @@ def aug_etb_for_dfbasis(mol, dfbasis=DFBASIS, beta=ETB_BETA,
|
|
|
86
145
|
nuc_charge = gto.charge(symb)
|
|
87
146
|
if nuc_charge < nuc_start:
|
|
88
147
|
newbasis[symb] = dfbasis
|
|
89
|
-
#?elif symb in mol._ecp:
|
|
90
148
|
else:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
emin_by_l = [1e99] * 8
|
|
94
|
-
emax_by_l = [0] * 8
|
|
95
|
-
l_max = 0
|
|
96
|
-
for b in mol._basis[symb]:
|
|
97
|
-
l = b[0]
|
|
98
|
-
l_max = max(l_max, l)
|
|
99
|
-
if l >= max_shells+1:
|
|
100
|
-
continue
|
|
101
|
-
|
|
102
|
-
if isinstance(b[1], int):
|
|
103
|
-
e_c = numpy.array(b[2:])
|
|
104
|
-
else:
|
|
105
|
-
e_c = numpy.array(b[1:])
|
|
106
|
-
es = e_c[:,0]
|
|
107
|
-
cs = e_c[:,1:]
|
|
108
|
-
es = es[abs(cs).max(axis=1) > 1e-3]
|
|
109
|
-
emax_by_l[l] = max(es.max(), emax_by_l[l])
|
|
110
|
-
emin_by_l[l] = min(es.min(), emin_by_l[l])
|
|
111
|
-
|
|
112
|
-
l_max1 = l_max + 1
|
|
113
|
-
emin_by_l = numpy.array(emin_by_l[:l_max1])
|
|
114
|
-
emax_by_l = numpy.array(emax_by_l[:l_max1])
|
|
115
|
-
|
|
116
|
-
# Estimate the exponents ranges by geometric average
|
|
117
|
-
emax = numpy.sqrt(numpy.einsum('i,j->ij', emax_by_l, emax_by_l))
|
|
118
|
-
emin = numpy.sqrt(numpy.einsum('i,j->ij', emin_by_l, emin_by_l))
|
|
119
|
-
liljsum = numpy.arange(l_max1)[:,None] + numpy.arange(l_max1)
|
|
120
|
-
emax_by_l = [emax[liljsum==ll].max() for ll in range(l_max1*2-1)]
|
|
121
|
-
emin_by_l = [emin[liljsum==ll].min() for ll in range(l_max1*2-1)]
|
|
122
|
-
# Tune emin and emax
|
|
123
|
-
emin_by_l = numpy.array(emin_by_l) * 2 # *2 for alpha+alpha on same center
|
|
124
|
-
emax_by_l = numpy.array(emax_by_l) * 2 #/ (numpy.arange(l_max1*2-1)*.5+1)
|
|
125
|
-
|
|
126
|
-
ns = numpy.log((emax_by_l+emin_by_l)/emin_by_l) / numpy.log(beta)
|
|
127
|
-
etb = []
|
|
128
|
-
for l, n in enumerate(numpy.ceil(ns).astype(int)):
|
|
129
|
-
if n > 0:
|
|
130
|
-
etb.append((l, n, emin_by_l[l], beta))
|
|
149
|
+
basis = mol._basis[symb]
|
|
150
|
+
etb = _aug_etb_element(nuc_charge, basis, beta)
|
|
131
151
|
if etb:
|
|
132
152
|
newbasis[symb] = gto.expand_etbs(etb)
|
|
153
|
+
for l, n, emin, beta in etb:
|
|
154
|
+
logger.info(mol, 'ETB for %s: l = %d, exps = %s * %g^n , n = 0..%d',
|
|
155
|
+
symb, l, emin, beta, n-1)
|
|
133
156
|
else:
|
|
134
157
|
raise RuntimeError(f'Failed to generate even-tempered auxbasis for {symb}')
|
|
135
158
|
|
|
@@ -182,12 +205,13 @@ def make_auxbasis(mol, mp2fit=False):
|
|
|
182
205
|
auxbasis.update(auxdefault)
|
|
183
206
|
aux_etb = set(auxbasis) - set(auxdefault)
|
|
184
207
|
if aux_etb:
|
|
185
|
-
logger.
|
|
208
|
+
logger.warn(mol, 'Even tempered Gaussians are generated as '
|
|
186
209
|
'DF auxbasis for %s', ' '.join(aux_etb))
|
|
187
210
|
for k in aux_etb:
|
|
188
211
|
logger.debug(mol, ' ETB auxbasis for %s %s', k, auxbasis[k])
|
|
189
212
|
return auxbasis
|
|
190
213
|
|
|
214
|
+
# TODO: add auxbasis keyword etb and auto
|
|
191
215
|
def make_auxmol(mol, auxbasis=None):
|
|
192
216
|
'''Generate a fake Mole object which uses the density fitting auxbasis as
|
|
193
217
|
the basis sets. If auxbasis is not specified, the optimized auxiliary fitting
|
|
@@ -198,26 +222,30 @@ def make_auxmol(mol, auxbasis=None):
|
|
|
198
222
|
even-tempered Gaussian basis set will be generated.
|
|
199
223
|
|
|
200
224
|
See also the paper JCTC, 13, 554 about generating auxiliary fitting basis.
|
|
225
|
+
|
|
226
|
+
Kwargs:
|
|
227
|
+
auxbasis : str, list, tuple
|
|
228
|
+
Similar to the input of orbital basis in Mole object.
|
|
201
229
|
'''
|
|
202
230
|
pmol = mol.copy(deep=False)
|
|
203
231
|
|
|
204
232
|
if auxbasis is None:
|
|
205
233
|
auxbasis = make_auxbasis(mol)
|
|
206
|
-
elif isinstance(auxbasis, str) and '+etb' in auxbasis:
|
|
207
|
-
dfbasis = auxbasis[:-4]
|
|
208
|
-
auxbasis = aug_etb_for_dfbasis(mol, dfbasis)
|
|
209
234
|
pmol.basis = auxbasis
|
|
210
235
|
|
|
211
236
|
if isinstance(auxbasis, (str, list, tuple)):
|
|
212
237
|
uniq_atoms = {a[0] for a in mol._atom}
|
|
213
238
|
_basis = {a: auxbasis for a in uniq_atoms}
|
|
214
|
-
elif 'default' in auxbasis:
|
|
215
|
-
uniq_atoms = {a[0] for a in mol._atom}
|
|
216
|
-
_basis = {a: auxbasis['default'] for a in uniq_atoms}
|
|
217
|
-
_basis.update(auxbasis)
|
|
218
|
-
del (_basis['default'])
|
|
219
239
|
else:
|
|
220
|
-
|
|
240
|
+
assert isinstance(auxbasis, dict)
|
|
241
|
+
if 'default' in auxbasis:
|
|
242
|
+
uniq_atoms = {a[0] for a in mol._atom}
|
|
243
|
+
_basis = {a: auxbasis['default'] for a in uniq_atoms}
|
|
244
|
+
_basis.update(auxbasis)
|
|
245
|
+
del (_basis['default'])
|
|
246
|
+
else:
|
|
247
|
+
_basis = auxbasis
|
|
248
|
+
|
|
221
249
|
pmol._basis = pmol.format_basis(_basis)
|
|
222
250
|
|
|
223
251
|
# Note: To pass parameters like gauge origin, rsh-omega to auxmol,
|
pyscf/df/autoaux.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# Copyright 2024 The PySCF Developers. All Rights Reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
'''
|
|
18
|
+
The AutoAux algorithm by ORCA
|
|
19
|
+
|
|
20
|
+
Ref:
|
|
21
|
+
JCTC, 13 (2016), 554
|
|
22
|
+
'''
|
|
23
|
+
|
|
24
|
+
from math import factorial
|
|
25
|
+
import numpy as np
|
|
26
|
+
from pyscf import gto
|
|
27
|
+
from pyscf.lib import logger
|
|
28
|
+
|
|
29
|
+
F_LAUX = np.array([20 , 7.0, 4.0, 4.0, 3.5, 2.5, 2.0, 2.0])
|
|
30
|
+
BETA_BIG = np.array([1.8, 2.0, 2.2, 2.2, 2.2, 2.3, 3.0, 3.0])
|
|
31
|
+
BETA_SMALL = 1.8
|
|
32
|
+
|
|
33
|
+
def _primitive_emin_emax(basis):
|
|
34
|
+
l_max = max(b[0] for b in basis)
|
|
35
|
+
emin_by_l = [1e99] * (l_max+1)
|
|
36
|
+
emax_by_l = [0] * (l_max+1)
|
|
37
|
+
e_eff_by_l = [0] * (l_max+1)
|
|
38
|
+
|
|
39
|
+
for b in basis:
|
|
40
|
+
l = b[0]
|
|
41
|
+
if isinstance(b[1], int):
|
|
42
|
+
e_c = np.array(b[2:])
|
|
43
|
+
else:
|
|
44
|
+
e_c = np.array(b[1:])
|
|
45
|
+
es = e_c[:,0]
|
|
46
|
+
emax_by_l[l] = max(es.max(), emax_by_l[l])
|
|
47
|
+
emin_by_l[l] = min(es.min(), emin_by_l[l])
|
|
48
|
+
|
|
49
|
+
cs = e_c[:,1:]
|
|
50
|
+
cs = np.einsum('pi,p->pi', cs, gto.gto_norm(l, es)) # normalize GTOs
|
|
51
|
+
cs = gto.mole._nomalize_contracted_ao(l, es, cs) # prefactors in r_ints
|
|
52
|
+
ee = es[:,None] + es
|
|
53
|
+
r_ints = gto.gaussian_int(l*2+3, ee) # \int \chi^2 r dr
|
|
54
|
+
r_exp = np.einsum('pi,pq,qi->i', cs, r_ints, cs)
|
|
55
|
+
|
|
56
|
+
k = 2**(2*l+1) * factorial(l+1)**2 / factorial(2*l+2)
|
|
57
|
+
# Eq (9) in the paper, e_eff = 2 * k**2 / (np.pi * r_exp) is a typo.
|
|
58
|
+
# See also https://github.com/MolSSI-BSE/basis_set_exchange/issues/317
|
|
59
|
+
# For primitive functions, following expression leads to
|
|
60
|
+
# e_eff = exponent of the basis
|
|
61
|
+
e_eff = 2 * k**2 / (np.pi * r_exp**2)
|
|
62
|
+
# For primitive functions, e_eff may be slightly different to the
|
|
63
|
+
# exponent due to the rounding errors in gaussian_int function.
|
|
64
|
+
# When a particular shell has only one primitive function, one auxiliary
|
|
65
|
+
# function should be generated. This error can introduce an additional
|
|
66
|
+
# auxiliary function.
|
|
67
|
+
# Slightly reduce e_eff to remove the extra auxiliary functions.
|
|
68
|
+
e_eff -= 1e-8
|
|
69
|
+
e_eff_by_l[l] = max(e_eff.max(), e_eff_by_l[l])
|
|
70
|
+
return np.array(emax_by_l), np.array(emin_by_l), np.array(e_eff_by_l)
|
|
71
|
+
|
|
72
|
+
def _auto_aux_element(Z, basis, ecp_core=0):
|
|
73
|
+
a_max_by_l, a_min_by_l, a_eff_by_l = _primitive_emin_emax(basis)
|
|
74
|
+
a_min_prim = a_min_by_l[:,None] + a_min_by_l
|
|
75
|
+
a_max_prim = a_max_by_l[:,None] + a_max_by_l
|
|
76
|
+
a_max_aux = a_eff_by_l[:,None] + a_eff_by_l
|
|
77
|
+
|
|
78
|
+
l_max1 = a_max_by_l.size
|
|
79
|
+
l_max = l_max1 - 1
|
|
80
|
+
# TODO: handle ECP
|
|
81
|
+
if Z <= 2:
|
|
82
|
+
l_val = 0
|
|
83
|
+
elif Z <= 20:
|
|
84
|
+
l_val = 1
|
|
85
|
+
elif Z <= 56:
|
|
86
|
+
l_val = 2
|
|
87
|
+
else:
|
|
88
|
+
l_val = 3
|
|
89
|
+
l_inc = 1
|
|
90
|
+
if Z > 18:
|
|
91
|
+
l_inc = 2
|
|
92
|
+
l_max_aux = min(max(l_val*2, l_max+l_inc), l_max*2)
|
|
93
|
+
|
|
94
|
+
liljsum = np.arange(l_max1)[:,None] + np.arange(l_max1)
|
|
95
|
+
liljsub = abs(np.arange(l_max1)[:,None] - np.arange(l_max1))
|
|
96
|
+
a_min_by_l = [a_min_prim[(liljsub<=ll) & (ll<=liljsum)].min() for ll in range(l_max_aux+1)]
|
|
97
|
+
a_max_by_l = [a_max_prim[(liljsub<=ll) & (ll<=liljsum)].max() for ll in range(l_max_aux+1)]
|
|
98
|
+
a_aux_by_l = [a_max_aux [(liljsub<=ll) & (ll<=liljsum)].max() for ll in range(l_max_aux+1)]
|
|
99
|
+
|
|
100
|
+
a_max_adjust = [min(F_LAUX[l] * a_aux_by_l[l], a_max_by_l[l])
|
|
101
|
+
for l in range(l_val*2+1)]
|
|
102
|
+
a_max_adjust = a_max_adjust + a_aux_by_l[l_val*2+1 : l_max_aux+1]
|
|
103
|
+
|
|
104
|
+
emin = np.array(a_min_by_l)
|
|
105
|
+
emax = np.array(a_max_adjust)
|
|
106
|
+
|
|
107
|
+
ns_small = np.log(a_max_adjust[:l_val*2+1] / emin[:l_val*2+1]) / np.log(BETA_SMALL)
|
|
108
|
+
etb = []
|
|
109
|
+
# ns_small+1 to ensure the largest exponent in etb > emax
|
|
110
|
+
for l, n in enumerate(np.ceil(ns_small).astype(int) + 1):
|
|
111
|
+
if n > 0:
|
|
112
|
+
etb.append((l, n, emin[l], BETA_SMALL))
|
|
113
|
+
|
|
114
|
+
if l_max_aux > l_val*2:
|
|
115
|
+
ns_big = (np.log(emax[l_val*2+1:] / emin[l_val*2+1:])
|
|
116
|
+
/ np.log(BETA_BIG[l_val*2+1:l_max_aux+1]))
|
|
117
|
+
for l, n in enumerate(np.ceil(ns_big).astype(int) + 1):
|
|
118
|
+
if n > 0:
|
|
119
|
+
l = l + l_val*2+1
|
|
120
|
+
beta = BETA_BIG[l]
|
|
121
|
+
etb.append((l, n, emin[l], beta))
|
|
122
|
+
return etb
|
|
123
|
+
|
|
124
|
+
def autoaux(mol):
|
|
125
|
+
'''
|
|
126
|
+
Create an auxiliary basis set for the given orbital basis set using
|
|
127
|
+
the Auto-Aux algorithm.
|
|
128
|
+
|
|
129
|
+
See also: G. L. Stoychev, A. A. Auer, and F. Neese
|
|
130
|
+
Automatic Generation of Auxiliary Basis Sets
|
|
131
|
+
J. Chem. Theory Comput. 13, 554 (2017)
|
|
132
|
+
http://doi.org/10.1021/acs.jctc.6b01041
|
|
133
|
+
'''
|
|
134
|
+
from pyscf.gto.basis import bse
|
|
135
|
+
|
|
136
|
+
def expand(symb):
|
|
137
|
+
Z = gto.charge(symb)
|
|
138
|
+
etb = _auto_aux_element(Z, mol._basis[symb])
|
|
139
|
+
if etb:
|
|
140
|
+
for l, n, emin, beta in etb:
|
|
141
|
+
logger.info(mol, 'ETB for %s: l = %d, exps = %s * %g^n , n = 0..%d',
|
|
142
|
+
symb, l, emin, beta, n-1)
|
|
143
|
+
return gto.expand_etbs(etb)
|
|
144
|
+
raise RuntimeError(f'Failed to generate even-tempered auxbasis for {symb}')
|
|
145
|
+
|
|
146
|
+
uniq_atoms = {a[0] for a in mol._atom}
|
|
147
|
+
if bse.basis_set_exchange is None:
|
|
148
|
+
return {symb: expand(symb) for symb in uniq_atoms}
|
|
149
|
+
|
|
150
|
+
if isinstance(mol.basis, str):
|
|
151
|
+
try:
|
|
152
|
+
elements = [gto.charge(symb) for symb in uniq_atoms]
|
|
153
|
+
newbasis = bse.autoaux(mol.basis, elements)
|
|
154
|
+
except KeyError:
|
|
155
|
+
newbasis = {symb: expand(symb) for symb in uniq_atoms}
|
|
156
|
+
else:
|
|
157
|
+
newbasis = {}
|
|
158
|
+
for symb in uniq_atoms:
|
|
159
|
+
if symb in mol.basis and isinstance(mol.basis[symb], str):
|
|
160
|
+
try:
|
|
161
|
+
auxbs = bse.autoaux(mol.basis[symb], gto.charge(symb))
|
|
162
|
+
newbasis[symb] = next(iter(auxbs.values()))
|
|
163
|
+
except KeyError:
|
|
164
|
+
newbasis[symb] = expand(symb)
|
|
165
|
+
else:
|
|
166
|
+
newbasis[symb] = expand(symb)
|
|
167
|
+
return newbasis
|
|
168
|
+
|
|
169
|
+
def autoabs(mol):
|
|
170
|
+
'''
|
|
171
|
+
Create a Coulomb fitting basis set for the given orbital basis set.
|
|
172
|
+
See also:
|
|
173
|
+
R. Yang, A. P. Rendell, and M. J. Frisch
|
|
174
|
+
Automatically generated Coulomb fitting basis sets: Design and accuracy for systems containing H to Kr
|
|
175
|
+
J. Chem. Phys. 127, 074102 (2007)
|
|
176
|
+
http://doi.org/10.1063/1.2752807
|
|
177
|
+
'''
|
|
178
|
+
from pyscf.gto.basis import bse
|
|
179
|
+
if bse is None:
|
|
180
|
+
print('Package basis-set-exchange not available')
|
|
181
|
+
raise ImportError
|
|
182
|
+
|
|
183
|
+
uniq_atoms = {a[0] for a in mol._atom}
|
|
184
|
+
if isinstance(mol.basis, str):
|
|
185
|
+
elements = [gto.charge(symb) for symb in uniq_atoms]
|
|
186
|
+
newbasis = bse.autoabs(mol.basis, elements)
|
|
187
|
+
else:
|
|
188
|
+
newbasis = {}
|
|
189
|
+
for symb in uniq_atoms:
|
|
190
|
+
if symb in mol.basis and isinstance(mol.basis[symb], str):
|
|
191
|
+
auxbs = bse.autoabs(mol.basis[symb], gto.charge(symb))
|
|
192
|
+
newbasis[symb] = next(iter(auxbs.values()))
|
|
193
|
+
else:
|
|
194
|
+
raise NotImplementedError
|
|
195
|
+
return newbasis
|
pyscf/df/df.py
CHANGED
|
@@ -98,6 +98,10 @@ class DF(lib.StreamObject):
|
|
|
98
98
|
self._vjopt = None
|
|
99
99
|
self._rsh_df = {} # Range separated Coulomb DF objects
|
|
100
100
|
|
|
101
|
+
__getstate__, __setstate__ = lib.generate_pickle_methods(
|
|
102
|
+
excludes=('_cderi_to_save', '_cderi', '_vjopt', '_rsh_df'),
|
|
103
|
+
reset_state=True)
|
|
104
|
+
|
|
101
105
|
@property
|
|
102
106
|
def auxbasis(self):
|
|
103
107
|
return self._auxbasis
|
|
@@ -166,7 +170,7 @@ class DF(lib.StreamObject):
|
|
|
166
170
|
max_memory=max_memory, verbose=log)
|
|
167
171
|
else:
|
|
168
172
|
# Store DF tensor in blocks. This is to reduce the
|
|
169
|
-
#
|
|
173
|
+
# initialization overhead
|
|
170
174
|
outcore.cholesky_eri_b(mol, cderi, dataname=self._dataname,
|
|
171
175
|
int3c=int3c, int2c=int2c, auxmol=auxmol,
|
|
172
176
|
max_memory=max_memory, verbose=log)
|
pyscf/df/df_jk.py
CHANGED
|
@@ -132,28 +132,31 @@ class _DFHF:
|
|
|
132
132
|
|
|
133
133
|
def get_jk(self, mol=None, dm=None, hermi=1, with_j=True, with_k=True,
|
|
134
134
|
omega=None):
|
|
135
|
+
assert (with_j or with_k)
|
|
135
136
|
if dm is None: dm = self.make_rdm1()
|
|
136
137
|
if not self.with_df:
|
|
137
138
|
return super().get_jk(mol, dm, hermi, with_j, with_k, omega)
|
|
138
139
|
|
|
140
|
+
vj = vk = None
|
|
139
141
|
with_dfk = with_k and not self.only_dfj
|
|
140
|
-
if
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
142
|
+
if with_j or with_dfk:
|
|
143
|
+
if isinstance(self, scf.ghf.GHF):
|
|
144
|
+
def jkbuild(mol, dm, hermi, with_j, with_k, omega=None):
|
|
145
|
+
vj, vk = self.with_df.get_jk(dm.real, hermi, with_j, with_k,
|
|
146
|
+
self.direct_scf_tol, omega)
|
|
147
|
+
if dm.dtype == numpy.complex128:
|
|
148
|
+
vjI, vkI = self.with_df.get_jk(dm.imag, hermi, with_j, with_k,
|
|
149
|
+
self.direct_scf_tol, omega)
|
|
150
|
+
if with_j:
|
|
151
|
+
vj = vj + vjI * 1j
|
|
152
|
+
if with_k:
|
|
153
|
+
vk = vk + vkI * 1j
|
|
154
|
+
return vj, vk
|
|
155
|
+
vj, vk = scf.ghf.get_jk(mol, dm, hermi, with_j, with_dfk,
|
|
156
|
+
jkbuild, omega)
|
|
157
|
+
else:
|
|
158
|
+
vj, vk = self.with_df.get_jk(dm, hermi, with_j, with_dfk,
|
|
159
|
+
self.direct_scf_tol, omega)
|
|
157
160
|
if with_k and not with_dfk:
|
|
158
161
|
vk = super().get_jk(mol, dm, hermi, False, True, omega)[1]
|
|
159
162
|
return vj, vk
|
|
@@ -233,7 +236,7 @@ class _DFHF:
|
|
|
233
236
|
return lib.to_gpu(self, obj)
|
|
234
237
|
|
|
235
238
|
|
|
236
|
-
def get_jk(dfobj, dm, hermi=
|
|
239
|
+
def get_jk(dfobj, dm, hermi=0, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
237
240
|
assert (with_j or with_k)
|
|
238
241
|
if (not with_k and not dfobj.mol.incore_anyway and
|
|
239
242
|
# 3-center integral tensor is not initialized
|
|
@@ -263,8 +266,7 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
263
266
|
if not with_k:
|
|
264
267
|
for eri1 in dfobj.loop():
|
|
265
268
|
# uses numpy.matmul
|
|
266
|
-
vj += (
|
|
267
|
-
|
|
269
|
+
vj += dmtril.dot(eri1.T).dot(eri1)
|
|
268
270
|
|
|
269
271
|
elif getattr(dm, 'mo_coeff', None) is not None:
|
|
270
272
|
#TODO: test whether dm.mo_coeff matching dm
|
|
@@ -294,7 +296,8 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
294
296
|
assert (nao_pair == nao*(nao+1)//2)
|
|
295
297
|
if with_j:
|
|
296
298
|
# uses numpy.matmul
|
|
297
|
-
vj += (
|
|
299
|
+
vj += dmtril.dot(eri1.T).dot(eri1)
|
|
300
|
+
|
|
298
301
|
for k in range(nset):
|
|
299
302
|
nocc = orbo[k].shape[1]
|
|
300
303
|
if nocc > 0:
|
|
@@ -321,8 +324,7 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
321
324
|
naux, nao_pair = eri1.shape
|
|
322
325
|
if with_j:
|
|
323
326
|
# uses numpy.matmul
|
|
324
|
-
vj += (
|
|
325
|
-
|
|
327
|
+
vj += dmtril.dot(eri1.T).dot(eri1)
|
|
326
328
|
|
|
327
329
|
for k in range(nset):
|
|
328
330
|
buf1 = buf[0,:naux]
|
|
@@ -341,7 +343,7 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
341
343
|
logger.timer(dfobj, 'df vj and vk', *t0)
|
|
342
344
|
return vj, vk
|
|
343
345
|
|
|
344
|
-
def get_j(dfobj, dm, hermi=
|
|
346
|
+
def get_j(dfobj, dm, hermi=0, direct_scf_tol=1e-13):
|
|
345
347
|
from pyscf.scf import _vhf
|
|
346
348
|
from pyscf.scf import jk
|
|
347
349
|
from pyscf.df import addons
|
|
@@ -434,7 +436,7 @@ def get_j(dfobj, dm, hermi=1, direct_scf_tol=1e-13):
|
|
|
434
436
|
return numpy.asarray(vj).reshape(dm_shape)
|
|
435
437
|
|
|
436
438
|
|
|
437
|
-
def r_get_jk(dfobj, dms, hermi=
|
|
439
|
+
def r_get_jk(dfobj, dms, hermi=0, with_j=True, with_k=True):
|
|
438
440
|
'''Relativistic density fitting JK'''
|
|
439
441
|
t0 = (logger.process_clock(), logger.perf_counter())
|
|
440
442
|
mol = dfobj.mol
|
pyscf/df/grad/casscf.py
CHANGED
|
@@ -227,44 +227,3 @@ class Gradients(casci_grad.Gradients):
|
|
|
227
227
|
to_gpu = lib.to_gpu
|
|
228
228
|
|
|
229
229
|
Grad = Gradients
|
|
230
|
-
|
|
231
|
-
#from pyscf import mcscf
|
|
232
|
-
#mcscf.mc1step.CASSCF.Gradients = lib.class_as_method(Gradients)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if __name__ == '__main__':
|
|
236
|
-
from pyscf import scf
|
|
237
|
-
from pyscf import mcscf
|
|
238
|
-
from pyscf import df
|
|
239
|
-
#from pyscf.grad import numeric
|
|
240
|
-
|
|
241
|
-
mol = gto.Mole()
|
|
242
|
-
mol.atom = 'N 0 0 0; N 0 0 1.2; H 1 1 0; H 1 1 1.2'
|
|
243
|
-
mol.basis = '631g'
|
|
244
|
-
mol.build()
|
|
245
|
-
aux = df.aug_etb (mol)
|
|
246
|
-
mf = scf.RHF(mol).density_fit (auxbasis=aux).run()
|
|
247
|
-
mc = mcscf.CASSCF(mf, 4, 4).run()
|
|
248
|
-
mc.conv_tol = 1e-10
|
|
249
|
-
de = Gradients (mc).kernel()
|
|
250
|
-
#de_num = numeric.Gradients (mc).kernel ()
|
|
251
|
-
#print(lib.finger(de) - 0.019602220578635747)
|
|
252
|
-
#print(lib.finger(de) - lib.finger (de_num))
|
|
253
|
-
|
|
254
|
-
mol = gto.Mole()
|
|
255
|
-
mol.verbose = 0
|
|
256
|
-
mol.atom = 'N 0 0 0; N 0 0 1.2'
|
|
257
|
-
mol.basis = 'sto3g'
|
|
258
|
-
mol.build()
|
|
259
|
-
mf = scf.RHF(mol).density_fit (auxbasis=aux).run()
|
|
260
|
-
mc = mcscf.CASSCF(mf, 4, 4)
|
|
261
|
-
mc.conv_tol = 1e-10
|
|
262
|
-
mc.kernel ()
|
|
263
|
-
de = Gradients (mc).kernel()
|
|
264
|
-
|
|
265
|
-
mcs = mc.as_scanner()
|
|
266
|
-
mol.set_geom_('N 0 0 0; N 0 0 1.201')
|
|
267
|
-
e1 = mcs(mol)
|
|
268
|
-
mol.set_geom_('N 0 0 0; N 0 0 1.199')
|
|
269
|
-
e2 = mcs(mol)
|
|
270
|
-
print(de[1,2], (e1-e2)/0.002*lib.param.BOHR)
|
pyscf/df/grad/rhf.py
CHANGED
|
@@ -94,7 +94,10 @@ def get_jk(mf_grad, mol=None, dm=None, hermi=0, with_j=True, with_k=True,
|
|
|
94
94
|
dm_tril[:,idx] *= .5
|
|
95
95
|
|
|
96
96
|
# For k
|
|
97
|
-
|
|
97
|
+
if hermi == 1:
|
|
98
|
+
orbol, orbor = _decompose_rdm1 (mf_grad, mol, dm)
|
|
99
|
+
else:
|
|
100
|
+
orbol, orbor = _decompose_rdm1_svd (mf_grad, mol, dm)
|
|
98
101
|
nocc = [o.shape[-1] for o in orbor]
|
|
99
102
|
|
|
100
103
|
# Coulomb: (P|Q) D_Q = (P|uv) D_uv for D_Q ("rhoj")
|
|
@@ -320,6 +323,33 @@ def _int3c_wrapper(mol, auxmol, intor, aosym):
|
|
|
320
323
|
aosym=aosym, cintopt=opt)
|
|
321
324
|
return get_int3c
|
|
322
325
|
|
|
326
|
+
def _decompose_rdm1_svd (mf_grad, mol, dm):
|
|
327
|
+
'''Decompose dms as U.Vh using SVD
|
|
328
|
+
|
|
329
|
+
Args:
|
|
330
|
+
mf_grad : instance of :class:`Gradients`
|
|
331
|
+
mol : instance of :class:`gto.Mole`
|
|
332
|
+
dm : ndarray or sequence of ndarrays of shape (nao,nao)
|
|
333
|
+
Density matrices
|
|
334
|
+
|
|
335
|
+
Returns:
|
|
336
|
+
orbol : list of ndarrays of shape (nao,*)
|
|
337
|
+
Contains non-null eigenvectors of density matrix
|
|
338
|
+
orbor : list of ndarrays of shape (nao,*)
|
|
339
|
+
Contains orbol * eigenvalues (occupancies)
|
|
340
|
+
'''
|
|
341
|
+
nao = mol.nao
|
|
342
|
+
dms = numpy.asarray(dm).reshape (-1,nao,nao)
|
|
343
|
+
orbor = []
|
|
344
|
+
orbol = []
|
|
345
|
+
for dm in dms:
|
|
346
|
+
u, s, vh = numpy.linalg.svd (dm)
|
|
347
|
+
idx = numpy.abs (s)>1e-8
|
|
348
|
+
orbol.append (numpy.asfortranarray (u[:,idx]))
|
|
349
|
+
orbor.append (numpy.asfortranarray (lib.einsum('i,ip->pi', s[idx], vh[idx])))
|
|
350
|
+
|
|
351
|
+
return orbol, orbor
|
|
352
|
+
|
|
323
353
|
def _decompose_rdm1 (mf_grad, mol, dm):
|
|
324
354
|
'''Decompose dms as U.Vh, where
|
|
325
355
|
U = orbol = eigenvectors
|