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/scf/rohf.py
CHANGED
|
@@ -47,6 +47,13 @@ def init_guess_by_atom(mol):
|
|
|
47
47
|
dm = lib.tag_array(dm, mo_coeff=dm.mo_coeff, mo_occ=dm.mo_occ)
|
|
48
48
|
return dm
|
|
49
49
|
|
|
50
|
+
def init_guess_by_sap(mol, sap_basis, **kwargs):
|
|
51
|
+
dm = hf.init_guess_by_sap(mol, sap_basis, **kwargs)
|
|
52
|
+
dm = numpy.array((dm*.5, dm*.5))
|
|
53
|
+
if hasattr(dm, 'mo_coeff'):
|
|
54
|
+
dm = lib.tag_array(dm, mo_coeff=dm.mo_coeff, mo_occ=dm.mo_occ)
|
|
55
|
+
return dm
|
|
56
|
+
|
|
50
57
|
init_guess_by_huckel = uhf.init_guess_by_huckel
|
|
51
58
|
init_guess_by_mod_huckel = uhf.init_guess_by_mod_huckel
|
|
52
59
|
|
|
@@ -270,7 +277,7 @@ def energy_elec(mf, dm=None, h1e=None, vhf=None):
|
|
|
270
277
|
get_veff = uhf.get_veff
|
|
271
278
|
|
|
272
279
|
def analyze(mf, verbose=logger.DEBUG, with_meta_lowdin=WITH_META_LOWDIN,
|
|
273
|
-
**kwargs):
|
|
280
|
+
origin=None, **kwargs):
|
|
274
281
|
'''Analyze the given SCF object: print orbital energies, occupancies;
|
|
275
282
|
print orbital coefficients; Mulliken population analysis
|
|
276
283
|
'''
|
|
@@ -312,7 +319,7 @@ def analyze(mf, verbose=logger.DEBUG, with_meta_lowdin=WITH_META_LOWDIN,
|
|
|
312
319
|
pop_and_charge = mf.mulliken_meta(mf.mol, dm, s=ovlp_ao, verbose=log)
|
|
313
320
|
else:
|
|
314
321
|
pop_and_charge = mf.mulliken_pop(mf.mol, dm, s=ovlp_ao, verbose=log)
|
|
315
|
-
dip = mf.dip_moment(mf.mol, dm, verbose=log)
|
|
322
|
+
dip = mf.dip_moment(mf.mol, dm, origin=origin, verbose=log)
|
|
316
323
|
return pop_and_charge, dip
|
|
317
324
|
|
|
318
325
|
mulliken_pop = hf.mulliken_pop
|
|
@@ -381,7 +388,7 @@ class ROHF(hf.RHF):
|
|
|
381
388
|
|
|
382
389
|
def init_guess_by_atom(self, mol=None):
|
|
383
390
|
if mol is None: mol = self.mol
|
|
384
|
-
logger.info(self, 'Initial guess from the
|
|
391
|
+
logger.info(self, 'Initial guess from the superposition of atomic densities.')
|
|
385
392
|
return init_guess_by_atom(mol)
|
|
386
393
|
|
|
387
394
|
def init_guess_by_huckel(self, mol=None):
|
|
@@ -404,6 +411,30 @@ employing the updated GWH rule from doi:10.1021/ja00480a005.''')
|
|
|
404
411
|
mo_occ = self.get_occ(mo_energy, mo_coeff)
|
|
405
412
|
return self.make_rdm1(mo_coeff, mo_occ)
|
|
406
413
|
|
|
414
|
+
def init_guess_by_sap(self, mol=None, **kwargs):
|
|
415
|
+
from pyscf.gto.basis import load
|
|
416
|
+
if mol is None: mol = self.mol
|
|
417
|
+
sap_basis = self.sap_basis
|
|
418
|
+
logger.info(self, '''Initial guess from superposition of atomic potentials (doi:10.1021/acs.jctc.8b01089)
|
|
419
|
+
This is the Gaussian fit version as described in doi:10.1063/5.0004046.''')
|
|
420
|
+
if isinstance(sap_basis, str):
|
|
421
|
+
atoms = [coord[0] for coord in mol._atom]
|
|
422
|
+
sapbas = {}
|
|
423
|
+
for atom in set(atoms):
|
|
424
|
+
single_element_bs = load(sap_basis, atom)
|
|
425
|
+
if isinstance(single_element_bs, dict):
|
|
426
|
+
sapbas[atom] = numpy.asarray(single_element_bs[atom][0][1:], dtype=float)
|
|
427
|
+
else:
|
|
428
|
+
sapbas[atom] = numpy.asarray(single_element_bs[0][1:], dtype=float)
|
|
429
|
+
logger.note(self, f'Found SAP basis {sap_basis.split("/")[-1]}')
|
|
430
|
+
elif isinstance(sap_basis, dict):
|
|
431
|
+
sapbas = {}
|
|
432
|
+
for key in sap_basis:
|
|
433
|
+
sapbas[key] = numpy.asarray(sap_basis[key][0][1:], dtype=float)
|
|
434
|
+
else:
|
|
435
|
+
logger.error(self, 'sap_basis is of an unexpected datatype.')
|
|
436
|
+
return init_guess_by_sap(mol, sap_basis=sapbas, **kwargs)
|
|
437
|
+
|
|
407
438
|
def init_guess_by_chkfile(self, chkfile=None, project=None):
|
|
408
439
|
if chkfile is None: chkfile = self.chkfile
|
|
409
440
|
return init_guess_by_chkfile(self.mol, chkfile, project=project)
|
|
@@ -480,7 +511,8 @@ employing the updated GWH rule from doi:10.1021/ja00480a005.''')
|
|
|
480
511
|
internal=getattr(__config__, 'scf_stability_internal', True),
|
|
481
512
|
external=getattr(__config__, 'scf_stability_external', False),
|
|
482
513
|
verbose=None,
|
|
483
|
-
return_status=False
|
|
514
|
+
return_status=False,
|
|
515
|
+
**kwargs):
|
|
484
516
|
'''
|
|
485
517
|
ROHF/ROKS stability analysis.
|
|
486
518
|
|
|
@@ -506,7 +538,7 @@ employing the updated GWH rule from doi:10.1021/ja00480a005.''')
|
|
|
506
538
|
and the second corresponds to the external stability.
|
|
507
539
|
'''
|
|
508
540
|
from pyscf.scf.stability import rohf_stability
|
|
509
|
-
return rohf_stability(self, internal, external, verbose, return_status)
|
|
541
|
+
return rohf_stability(self, internal, external, verbose, return_status, **kwargs)
|
|
510
542
|
|
|
511
543
|
def nuc_grad_method(self):
|
|
512
544
|
from pyscf.grad import rohf
|
pyscf/scf/stability.py
CHANGED
|
@@ -33,8 +33,13 @@ from pyscf.lib import logger
|
|
|
33
33
|
from pyscf.scf import hf, hf_symm, uhf_symm
|
|
34
34
|
from pyscf.scf import _response_functions # noqa
|
|
35
35
|
from pyscf.soscf import newton_ah
|
|
36
|
+
from pyscf import __config__
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
STAB_NROOTS = getattr(__config__, 'stab_nroots', 3)
|
|
39
|
+
STAB_TOL = getattr(__config__, 'stab_tol', 1e-4)
|
|
40
|
+
|
|
41
|
+
def rhf_stability(mf, internal=True, external=False, verbose=None, return_status=False,
|
|
42
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
38
43
|
'''
|
|
39
44
|
Stability analysis for RHF/RKS method.
|
|
40
45
|
|
|
@@ -49,6 +54,10 @@ def rhf_stability(mf, internal=True, external=False, verbose=None, return_status
|
|
|
49
54
|
stability analysis.
|
|
50
55
|
return_status: bool
|
|
51
56
|
Whether to return `stable_i` and `stable_e`
|
|
57
|
+
nroots : int
|
|
58
|
+
Number of roots solved by Davidson solver
|
|
59
|
+
tol : float
|
|
60
|
+
Convergence threshold for Davidson solver
|
|
52
61
|
|
|
53
62
|
Returns:
|
|
54
63
|
If return_status is False (default), the return value includes
|
|
@@ -62,21 +71,18 @@ def rhf_stability(mf, internal=True, external=False, verbose=None, return_status
|
|
|
62
71
|
and the second corresponds to the external stability.
|
|
63
72
|
'''
|
|
64
73
|
mo_i = mo_e = None
|
|
74
|
+
stable_i = stable_e = None
|
|
75
|
+
if internal:
|
|
76
|
+
mo_i, stable_i = rhf_internal(mf, verbose=verbose, return_status=True, nroots=nroots, tol=tol)
|
|
77
|
+
if external:
|
|
78
|
+
mo_e, stable_e = rhf_external(mf, verbose=verbose, return_status=True, nroots=nroots, tol=tol)
|
|
65
79
|
if return_status:
|
|
66
|
-
stable_i = stable_e = None
|
|
67
|
-
if internal:
|
|
68
|
-
mo_i, stable_i = rhf_internal(mf, verbose=verbose, return_status=True)
|
|
69
|
-
if external:
|
|
70
|
-
mo_e, stable_e = rhf_external(mf, verbose=verbose, return_status=True)
|
|
71
80
|
return mo_i, mo_e, stable_i, stable_e
|
|
72
81
|
else:
|
|
73
|
-
if internal:
|
|
74
|
-
mo_i = rhf_internal(mf, verbose=verbose)
|
|
75
|
-
if external:
|
|
76
|
-
mo_e = rhf_external(mf, verbose=verbose)
|
|
77
82
|
return mo_i, mo_e
|
|
78
83
|
|
|
79
|
-
def uhf_stability(mf, internal=True, external=False, verbose=None, return_status=False
|
|
84
|
+
def uhf_stability(mf, internal=True, external=False, verbose=None, return_status=False,
|
|
85
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
80
86
|
'''
|
|
81
87
|
Stability analysis for UHF/UKS method.
|
|
82
88
|
|
|
@@ -91,6 +97,10 @@ def uhf_stability(mf, internal=True, external=False, verbose=None, return_status
|
|
|
91
97
|
stability analysis.
|
|
92
98
|
return_status: bool
|
|
93
99
|
Whether to return `stable_i` and `stable_e`
|
|
100
|
+
nroots : int
|
|
101
|
+
Number of roots solved by Davidson solver
|
|
102
|
+
tol : float
|
|
103
|
+
Convergence threshold for Davidson solver
|
|
94
104
|
|
|
95
105
|
Returns:
|
|
96
106
|
If return_status is False (default), the return value includes
|
|
@@ -104,21 +114,18 @@ def uhf_stability(mf, internal=True, external=False, verbose=None, return_status
|
|
|
104
114
|
and the second corresponds to the external stability.
|
|
105
115
|
'''
|
|
106
116
|
mo_i = mo_e = None
|
|
117
|
+
stable_i = stable_e = None
|
|
118
|
+
if internal:
|
|
119
|
+
mo_i, stable_i = uhf_internal(mf, verbose=verbose, return_status=True, nroots=nroots, tol=tol)
|
|
120
|
+
if external:
|
|
121
|
+
mo_e, stable_e = uhf_external(mf, verbose=verbose, return_status=True, nroots=nroots, tol=tol)
|
|
107
122
|
if return_status:
|
|
108
|
-
stable_i = stable_e = None
|
|
109
|
-
if internal:
|
|
110
|
-
mo_i, stable_i = uhf_internal(mf, verbose=verbose, return_status=True)
|
|
111
|
-
if external:
|
|
112
|
-
mo_e, stable_e = uhf_external(mf, verbose=verbose, return_status=True)
|
|
113
123
|
return mo_i, mo_e, stable_i, stable_e
|
|
114
124
|
else:
|
|
115
|
-
if internal:
|
|
116
|
-
mo_i = uhf_internal(mf, verbose=verbose)
|
|
117
|
-
if external:
|
|
118
|
-
mo_e = uhf_external(mf, verbose=verbose)
|
|
119
125
|
return mo_i, mo_e
|
|
120
126
|
|
|
121
|
-
def rohf_stability(mf, internal=True, external=False, verbose=None, return_status=False
|
|
127
|
+
def rohf_stability(mf, internal=True, external=False, verbose=None, return_status=False,
|
|
128
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
122
129
|
'''
|
|
123
130
|
Stability analysis for ROHF/ROKS method.
|
|
124
131
|
|
|
@@ -132,6 +139,10 @@ def rohf_stability(mf, internal=True, external=False, verbose=None, return_statu
|
|
|
132
139
|
External stability. It is not available in current version.
|
|
133
140
|
return_status: bool
|
|
134
141
|
Whether to return `stable_i` and `stable_e`
|
|
142
|
+
nroots : int
|
|
143
|
+
Number of roots solved by Davidson solver
|
|
144
|
+
tol : float
|
|
145
|
+
Convergence threshold for Davidson solver
|
|
135
146
|
|
|
136
147
|
Returns:
|
|
137
148
|
If return_status is False (default), the return value includes
|
|
@@ -145,21 +156,25 @@ def rohf_stability(mf, internal=True, external=False, verbose=None, return_statu
|
|
|
145
156
|
and the second corresponds to the external stability.
|
|
146
157
|
'''
|
|
147
158
|
mo_i = mo_e = None
|
|
159
|
+
stable_i = stable_e = None
|
|
160
|
+
if internal:
|
|
161
|
+
mo_i, stable_i = rohf_internal(mf, verbose=verbose, return_status=True, nroots=nroots, tol=tol)
|
|
162
|
+
if external:
|
|
163
|
+
mo_e, stable_e = rohf_external(mf, verbose=verbose, return_status=True, nroots=nroots, tol=tol)
|
|
148
164
|
if return_status:
|
|
149
|
-
stable_i = stable_e = None
|
|
150
|
-
if internal:
|
|
151
|
-
mo_i, stable_i = rohf_internal(mf, verbose=verbose, return_status=True)
|
|
152
|
-
if external:
|
|
153
|
-
mo_e, stable_e = rohf_external(mf, verbose=verbose, return_status=True)
|
|
154
165
|
return mo_i, mo_e, stable_i, stable_e
|
|
155
166
|
else:
|
|
156
|
-
if internal:
|
|
157
|
-
mo_i = rohf_internal(mf, verbose=verbose)
|
|
158
|
-
if external:
|
|
159
|
-
mo_e = rohf_external(mf, verbose=verbose)
|
|
160
167
|
return mo_i, mo_e
|
|
161
168
|
|
|
162
|
-
def
|
|
169
|
+
def dump_status(log, stable, method_class, stab_type):
|
|
170
|
+
if not stable:
|
|
171
|
+
log.note(method_class + f' wavefunction has an {stab_type} instability')
|
|
172
|
+
else:
|
|
173
|
+
log.note(method_class + f' wavefunction is stable in the {stab_type} '
|
|
174
|
+
'stability analysis')
|
|
175
|
+
|
|
176
|
+
def ghf_stability(mf, verbose=None, return_status=False,
|
|
177
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
163
178
|
'''
|
|
164
179
|
Stability analysis for GHF/GKS method.
|
|
165
180
|
|
|
@@ -169,6 +184,10 @@ def ghf_stability(mf, verbose=None, return_status=False):
|
|
|
169
184
|
Kwargs:
|
|
170
185
|
return_status: bool
|
|
171
186
|
Whether to return `stable_i` and `stable_e`
|
|
187
|
+
nroots : int
|
|
188
|
+
Number of roots solved by Davidson solver
|
|
189
|
+
tol : float
|
|
190
|
+
Convergence threshold for Davidson solver
|
|
172
191
|
|
|
173
192
|
Returns:
|
|
174
193
|
If return_status is False (default), the return value includes
|
|
@@ -193,21 +212,23 @@ def ghf_stability(mf, verbose=None, return_status=False):
|
|
|
193
212
|
x0[g!=0] = 1. / hdiag[g!=0]
|
|
194
213
|
if not with_symmetry: # allow to break point group symmetry
|
|
195
214
|
x0[numpy.argmin(hdiag)] = 1
|
|
196
|
-
e, v = lib.davidson(hessian_x, x0, precond, tol=
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
'stability analysis')
|
|
215
|
+
e, v = lib.davidson(hessian_x, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
216
|
+
log.info('ghf_stability: lowest eigs of H = %s', e)
|
|
217
|
+
if nroots != 1:
|
|
218
|
+
e, v = e[0], v[0]
|
|
219
|
+
stable = not (e < -1e-5)
|
|
220
|
+
dump_status(log, stable, f'{mf.__class__}', 'internal')
|
|
221
|
+
if stable:
|
|
204
222
|
mo = mf.mo_coeff
|
|
223
|
+
else:
|
|
224
|
+
mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
|
|
205
225
|
if return_status:
|
|
206
226
|
return mo, stable
|
|
207
227
|
else:
|
|
208
228
|
return mo
|
|
209
229
|
|
|
210
|
-
def dhf_stability(mf, verbose=None, return_status=False
|
|
230
|
+
def dhf_stability(mf, verbose=None, return_status=False,
|
|
231
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
211
232
|
'''
|
|
212
233
|
Stability analysis for DHF/DKS method.
|
|
213
234
|
|
|
@@ -217,6 +238,10 @@ def dhf_stability(mf, verbose=None, return_status=False):
|
|
|
217
238
|
Kwargs:
|
|
218
239
|
return_status: bool
|
|
219
240
|
Whether to return `stable_i` and `stable_e`
|
|
241
|
+
nroots : int
|
|
242
|
+
Number of roots solved by Davidson solver
|
|
243
|
+
tol : float
|
|
244
|
+
Convergence threshold for Davidson solver
|
|
220
245
|
|
|
221
246
|
Returns:
|
|
222
247
|
If return_status is False (default), the return value includes
|
|
@@ -239,26 +264,27 @@ def dhf_stability(mf, verbose=None, return_status=False):
|
|
|
239
264
|
x0 = numpy.zeros_like(g)
|
|
240
265
|
x0[g!=0] = 1. / hdiag[g!=0]
|
|
241
266
|
x0[numpy.argmin(hdiag)] = 1
|
|
242
|
-
e, v = lib.davidson(hessian_x, x0, precond, tol=
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
'stability analysis')
|
|
267
|
+
e, v = lib.davidson(hessian_x, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
268
|
+
log.info('dhf_stability: lowest eigs of H = %s', e)
|
|
269
|
+
if nroots != 1:
|
|
270
|
+
e, v = e[0], v[0]
|
|
271
|
+
stable = not (e < -1e-5)
|
|
272
|
+
dump_status(log, stable, f'{mf.__class__}', 'internal')
|
|
273
|
+
if stable:
|
|
250
274
|
mo = mf.mo_coeff
|
|
275
|
+
else:
|
|
276
|
+
mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
|
|
251
277
|
if return_status:
|
|
252
278
|
return mo, stable
|
|
253
279
|
else:
|
|
254
280
|
return mo
|
|
255
281
|
|
|
256
|
-
def rhf_internal(mf, with_symmetry=True, verbose=None, return_status=False
|
|
282
|
+
def rhf_internal(mf, with_symmetry=True, verbose=None, return_status=False,
|
|
283
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
257
284
|
log = logger.new_logger(mf, verbose)
|
|
258
285
|
g, hop, hdiag = newton_ah.gen_g_hop_rhf(mf, mf.mo_coeff, mf.mo_occ,
|
|
259
286
|
with_symmetry=with_symmetry)
|
|
260
287
|
hdiag *= 2
|
|
261
|
-
stable = True
|
|
262
288
|
def precond(dx, e, x0):
|
|
263
289
|
hdiagd = hdiag - e
|
|
264
290
|
hdiagd[abs(hdiagd)<1e-8] = 1e-8
|
|
@@ -266,7 +292,7 @@ def rhf_internal(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
266
292
|
# The results of hop(x) corresponds to a displacement that reduces
|
|
267
293
|
# gradients g. It is the vir-occ block of the matrix vector product
|
|
268
294
|
# (Hessian*x). The occ-vir block equals to x2.T.conj(). The overall
|
|
269
|
-
# Hessian for internal
|
|
295
|
+
# Hessian for internal rotation is x2 + x2.T.conj(). This is
|
|
270
296
|
# the reason we apply (.real * 2) below
|
|
271
297
|
def hessian_x(x):
|
|
272
298
|
return hop(x).real * 2
|
|
@@ -275,15 +301,16 @@ def rhf_internal(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
275
301
|
x0[g!=0] = 1. / hdiag[g!=0]
|
|
276
302
|
if not with_symmetry: # allow to break point group symmetry
|
|
277
303
|
x0[numpy.argmin(hdiag)] = 1
|
|
278
|
-
e, v = lib.davidson(hessian_x, x0, precond, tol=
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
'stability analysis')
|
|
304
|
+
e, v = lib.davidson(hessian_x, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
305
|
+
log.info('rhf_internal: lowest eigs of H = %s', e)
|
|
306
|
+
if nroots != 1:
|
|
307
|
+
e, v = e[0], v[0]
|
|
308
|
+
stable = not (e < -1e-5)
|
|
309
|
+
dump_status(log, stable, f'{mf.__class__}', 'internal')
|
|
310
|
+
if stable:
|
|
286
311
|
mo = mf.mo_coeff
|
|
312
|
+
else:
|
|
313
|
+
mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
|
|
287
314
|
if return_status:
|
|
288
315
|
return mo, stable
|
|
289
316
|
else:
|
|
@@ -360,10 +387,10 @@ def _gen_hop_rhf_external(mf, with_symmetry=True, verbose=None):
|
|
|
360
387
|
return hop_real2complex, hdiag, hop_rhf2uhf, hdiag
|
|
361
388
|
|
|
362
389
|
|
|
363
|
-
def rhf_external(mf, with_symmetry=True, verbose=None, return_status=False
|
|
390
|
+
def rhf_external(mf, with_symmetry=True, verbose=None, return_status=False,
|
|
391
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
364
392
|
log = logger.new_logger(mf, verbose)
|
|
365
393
|
hop1, hdiag1, hop2, hdiag2 = _gen_hop_rhf_external(mf, with_symmetry)
|
|
366
|
-
stable = True
|
|
367
394
|
|
|
368
395
|
def precond(dx, e, x0):
|
|
369
396
|
hdiagd = hdiag1 - e
|
|
@@ -373,12 +400,12 @@ def rhf_external(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
373
400
|
x0[hdiag1>1e-5] = 1. / hdiag1[hdiag1>1e-5]
|
|
374
401
|
if not with_symmetry: # allow to break point group symmetry
|
|
375
402
|
x0[numpy.argmin(hdiag1)] = 1
|
|
376
|
-
e1, v1 = lib.davidson(hop1, x0, precond, tol=
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
403
|
+
e1, v1 = lib.davidson(hop1, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
404
|
+
log.info('rhf_real2complex: lowest eigs of H = %s', e1)
|
|
405
|
+
if nroots != 1:
|
|
406
|
+
e1, v1 = e1[0], v1[0]
|
|
407
|
+
stable1 = not (e1 < -1e-5)
|
|
408
|
+
dump_status(log, stable1, f'{mf.__class__}', 'real -> complex')
|
|
382
409
|
|
|
383
410
|
def precond(dx, e, x0):
|
|
384
411
|
hdiagd = hdiag2 - e
|
|
@@ -386,26 +413,27 @@ def rhf_external(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
386
413
|
return dx/hdiagd
|
|
387
414
|
x0 = numpy.zeros_like(hdiag2)
|
|
388
415
|
x0[hdiag2>1e-5] = 1. / hdiag2[hdiag2>1e-5]
|
|
389
|
-
e3, v3 = lib.davidson(hop2, x0, precond, tol=
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
'UHF/UKS stability analysis')
|
|
416
|
+
e3, v3 = lib.davidson(hop2, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
417
|
+
log.info('rhf_external: lowest eigs of H = %s', e3)
|
|
418
|
+
if nroots != 1:
|
|
419
|
+
e3, v3 = e3[0], v3[0]
|
|
420
|
+
stable = not (e3 < -1e-5)
|
|
421
|
+
dump_status(log, stable, f'{mf.__class__}', 'RHF/RKS -> UHF/UKS')
|
|
422
|
+
if stable:
|
|
397
423
|
mo = (mf.mo_coeff, mf.mo_coeff)
|
|
424
|
+
else:
|
|
425
|
+
mo = (_rotate_mo(mf.mo_coeff, mf.mo_occ, v3), mf.mo_coeff)
|
|
398
426
|
if return_status:
|
|
399
427
|
return mo, stable
|
|
400
428
|
else:
|
|
401
429
|
return mo
|
|
402
430
|
|
|
403
|
-
def rohf_internal(mf, with_symmetry=True, verbose=None, return_status=False
|
|
431
|
+
def rohf_internal(mf, with_symmetry=True, verbose=None, return_status=False,
|
|
432
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
404
433
|
log = logger.new_logger(mf, verbose)
|
|
405
434
|
g, hop, hdiag = newton_ah.gen_g_hop_rohf(mf, mf.mo_coeff, mf.mo_occ,
|
|
406
435
|
with_symmetry=with_symmetry)
|
|
407
436
|
hdiag *= 2
|
|
408
|
-
stable = True
|
|
409
437
|
def precond(dx, e, x0):
|
|
410
438
|
hdiagd = hdiag - e
|
|
411
439
|
hdiagd[abs(hdiagd)<1e-8] = 1e-8
|
|
@@ -417,29 +445,31 @@ def rohf_internal(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
417
445
|
x0[g!=0] = 1. / hdiag[g!=0]
|
|
418
446
|
if not with_symmetry: # allow to break point group symmetry
|
|
419
447
|
x0[numpy.argmin(hdiag)] = 1
|
|
420
|
-
e, v = lib.davidson(hessian_x, x0, precond, tol=
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
'stability analysis')
|
|
448
|
+
e, v = lib.davidson(hessian_x, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
449
|
+
log.info('rohf_internal: lowest eigs of H = %s', e)
|
|
450
|
+
if nroots != 1:
|
|
451
|
+
e, v = e[0], v[0]
|
|
452
|
+
stable = not (e < -1e-5)
|
|
453
|
+
dump_status(log, stable, f'{mf.__class__}', 'internal')
|
|
454
|
+
if stable:
|
|
428
455
|
mo = mf.mo_coeff
|
|
456
|
+
else:
|
|
457
|
+
mo = _rotate_mo(mf.mo_coeff, mf.mo_occ, v)
|
|
429
458
|
if return_status:
|
|
430
459
|
return mo, stable
|
|
431
460
|
else:
|
|
432
461
|
return mo
|
|
433
462
|
|
|
434
|
-
def rohf_external(mf, with_symmetry=True, verbose=None, return_status=False
|
|
463
|
+
def rohf_external(mf, with_symmetry=True, verbose=None, return_status=False,
|
|
464
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
435
465
|
raise NotImplementedError
|
|
436
466
|
|
|
437
|
-
def uhf_internal(mf, with_symmetry=True, verbose=None, return_status=False
|
|
467
|
+
def uhf_internal(mf, with_symmetry=True, verbose=None, return_status=False,
|
|
468
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
438
469
|
log = logger.new_logger(mf, verbose)
|
|
439
470
|
g, hop, hdiag = newton_ah.gen_g_hop_uhf(mf, mf.mo_coeff, mf.mo_occ,
|
|
440
471
|
with_symmetry=with_symmetry)
|
|
441
472
|
hdiag *= 2
|
|
442
|
-
stable = True
|
|
443
473
|
def precond(dx, e, x0):
|
|
444
474
|
hdiagd = hdiag - e
|
|
445
475
|
hdiagd[abs(hdiagd)<1e-8] = 1e-8
|
|
@@ -451,18 +481,19 @@ def uhf_internal(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
451
481
|
x0[g!=0] = 1. / hdiag[g!=0]
|
|
452
482
|
if not with_symmetry: # allow to break point group symmetry
|
|
453
483
|
x0[numpy.argmin(hdiag)] = 1
|
|
454
|
-
e, v = lib.davidson(hessian_x, x0, precond, tol=
|
|
455
|
-
|
|
456
|
-
|
|
484
|
+
e, v = lib.davidson(hessian_x, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
485
|
+
log.info('uhf_internal: lowest eigs of H = %s', e)
|
|
486
|
+
if nroots != 1:
|
|
487
|
+
e, v = e[0], v[0]
|
|
488
|
+
stable = not (e < -1e-5)
|
|
489
|
+
dump_status(log, stable, f'{mf.__class__}', 'internal')
|
|
490
|
+
if stable:
|
|
491
|
+
mo = mf.mo_coeff
|
|
492
|
+
else:
|
|
457
493
|
nocca = numpy.count_nonzero(mf.mo_occ[0]> 0)
|
|
458
494
|
nvira = numpy.count_nonzero(mf.mo_occ[0]==0)
|
|
459
495
|
mo = (_rotate_mo(mf.mo_coeff[0], mf.mo_occ[0], v[:nocca*nvira]),
|
|
460
496
|
_rotate_mo(mf.mo_coeff[1], mf.mo_occ[1], v[nocca*nvira:]))
|
|
461
|
-
stable = False
|
|
462
|
-
else:
|
|
463
|
-
log.note(f'{mf.__class__} wavefunction is stable in the internal '
|
|
464
|
-
'stability analysis')
|
|
465
|
-
mo = mf.mo_coeff
|
|
466
497
|
if return_status:
|
|
467
498
|
return mo, stable
|
|
468
499
|
else:
|
|
@@ -569,10 +600,10 @@ def _gen_hop_uhf_external(mf, with_symmetry=True, verbose=None):
|
|
|
569
600
|
return hop_real2complex, hdiag1, hop_uhf2ghf, hdiag2
|
|
570
601
|
|
|
571
602
|
|
|
572
|
-
def uhf_external(mf, with_symmetry=True, verbose=None, return_status=False
|
|
603
|
+
def uhf_external(mf, with_symmetry=True, verbose=None, return_status=False,
|
|
604
|
+
nroots=STAB_NROOTS, tol=STAB_TOL):
|
|
573
605
|
log = logger.new_logger(mf, verbose)
|
|
574
606
|
hop1, hdiag1, hop2, hdiag2 = _gen_hop_uhf_external(mf, with_symmetry)
|
|
575
|
-
stable = True
|
|
576
607
|
|
|
577
608
|
def precond(dx, e, x0):
|
|
578
609
|
hdiagd = hdiag1 - e
|
|
@@ -582,12 +613,12 @@ def uhf_external(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
582
613
|
x0[hdiag1>1e-5] = 1. / hdiag1[hdiag1>1e-5]
|
|
583
614
|
if not with_symmetry: # allow to break point group symmetry
|
|
584
615
|
x0[numpy.argmin(hdiag1)] = 1
|
|
585
|
-
e1, v = lib.davidson(hop1, x0, precond, tol=
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
616
|
+
e1, v = lib.davidson(hop1, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
617
|
+
log.info('uhf_real2complex: lowest eigs of H = %s', e1)
|
|
618
|
+
if nroots != 1:
|
|
619
|
+
e1, v = e1[0], v[0]
|
|
620
|
+
stable1 = not (e1 < -1e-5)
|
|
621
|
+
dump_status(log, stable1, f'{mf.__class__}', 'real -> complex')
|
|
591
622
|
|
|
592
623
|
def precond(dx, e, x0):
|
|
593
624
|
hdiagd = hdiag2 - e
|
|
@@ -597,11 +628,14 @@ def uhf_external(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
597
628
|
x0[hdiag2>1e-5] = 1. / hdiag2[hdiag2>1e-5]
|
|
598
629
|
if not with_symmetry: # allow to break point group symmetry
|
|
599
630
|
x0[numpy.argmin(hdiag2)] = 1
|
|
600
|
-
e3, v = lib.davidson(hop2, x0, precond, tol=
|
|
601
|
-
log.
|
|
631
|
+
e3, v = lib.davidson(hop2, x0, precond, tol=tol, verbose=log, nroots=nroots)
|
|
632
|
+
log.info('uhf_external: lowest eigs of H = %s', e3)
|
|
633
|
+
if nroots != 1:
|
|
634
|
+
e3, v = e3[0], v[0]
|
|
635
|
+
stable = not (e3 < -1e-5)
|
|
636
|
+
dump_status(log, stable, f'{mf.__class__}', 'UHF/UKS -> GHF/GKS')
|
|
602
637
|
mo = scipy.linalg.block_diag(*mf.mo_coeff)
|
|
603
|
-
if
|
|
604
|
-
log.note(f'{mf.__class__} wavefunction has an UHF/UKS -> GHF/GKS instability.')
|
|
638
|
+
if not stable:
|
|
605
639
|
occidxa = numpy.where(mf.mo_occ[0]> 0)[0]
|
|
606
640
|
viridxa = numpy.where(mf.mo_occ[0]==0)[0]
|
|
607
641
|
occidxb = numpy.where(mf.mo_occ[1]> 0)[0]
|
|
@@ -618,10 +652,6 @@ def uhf_external(mf, with_symmetry=True, verbose=None, return_status=False):
|
|
|
618
652
|
mo = numpy.dot(mo, u)
|
|
619
653
|
mo = numpy.hstack([mo[:,:nocca], mo[:,nmo:nmo+noccb],
|
|
620
654
|
mo[:,nocca:nmo], mo[:,nmo+noccb:]])
|
|
621
|
-
stable = False
|
|
622
|
-
else:
|
|
623
|
-
log.note(f'{mf.__class__} wavefunction is stable in the UHF/UKS -> '
|
|
624
|
-
'GHF/GKS stability analysis')
|
|
625
655
|
if return_status:
|
|
626
656
|
return mo, stable
|
|
627
657
|
else:
|
pyscf/scf/ucphf.py
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
#
|
|
18
18
|
|
|
19
19
|
'''
|
|
20
|
-
Unrestricted coupled
|
|
20
|
+
Unrestricted coupled perturbed Hartree-Fock solver
|
|
21
21
|
'''
|
|
22
22
|
|
|
23
23
|
|
|
@@ -67,25 +67,26 @@ def solve_nos1(fvind, mo_energy, mo_occ, h1,
|
|
|
67
67
|
mo1base = numpy.hstack((h1[0].reshape(-1,nvira*nocca),
|
|
68
68
|
h1[1].reshape(-1,nvirb*noccb)))
|
|
69
69
|
mo1base *= -e_ai
|
|
70
|
+
nov = e_ai.size
|
|
70
71
|
|
|
71
72
|
def vind_vo(mo1):
|
|
72
|
-
|
|
73
|
-
v = fvind(mo1).reshape(
|
|
73
|
+
nd = mo1.shape[0]
|
|
74
|
+
v = fvind(mo1).reshape(nd, nov)
|
|
74
75
|
if level_shift != 0:
|
|
75
76
|
v -= mo1 * level_shift
|
|
76
77
|
v *= e_ai
|
|
77
|
-
return v.
|
|
78
|
-
mo1 = lib.krylov(vind_vo, mo1base.
|
|
78
|
+
return v.reshape(-1, nov)
|
|
79
|
+
mo1 = lib.krylov(vind_vo, mo1base.reshape(-1, nov),
|
|
79
80
|
tol=tol, max_cycle=max_cycle, hermi=hermi, verbose=log)
|
|
80
81
|
log.timer('krylov solver in CPHF', *t0)
|
|
81
82
|
|
|
83
|
+
mo1 = mo1.reshape(mo1base.shape)
|
|
84
|
+
mo1_a = mo1[:,:nvira*nocca].reshape(-1,nvira,nocca)
|
|
85
|
+
mo1_b = mo1[:,nvira*nocca:].reshape(-1,nvirb,noccb)
|
|
82
86
|
if isinstance(h1[0], numpy.ndarray) and h1[0].ndim == 2:
|
|
83
|
-
mo1 = (
|
|
84
|
-
mo1[nocca*nvira:].reshape(nvirb,noccb))
|
|
87
|
+
mo1 = (mo1_a[0], mo1_b[0])
|
|
85
88
|
else:
|
|
86
|
-
|
|
87
|
-
mo1_a = mo1[:,:nvira*nocca].reshape(-1,nvira,nocca)
|
|
88
|
-
mo1_b = mo1[:,nvira*nocca:].reshape(-1,nvirb,noccb)
|
|
89
|
+
assert h1[0].ndim == 3
|
|
89
90
|
mo1 = (mo1_a, mo1_b)
|
|
90
91
|
return mo1, None
|
|
91
92
|
|
|
@@ -128,20 +129,22 @@ def solve_withs1(fvind, mo_energy, mo_occ, h1, s1,
|
|
|
128
129
|
mo1base_a[:,occidxa] = -s1_a[:,occidxa] * .5
|
|
129
130
|
mo1base_b[:,occidxb] = -s1_b[:,occidxb] * .5
|
|
130
131
|
mo1base = numpy.hstack((mo1base_a.reshape(nset,-1), mo1base_b.reshape(nset,-1)))
|
|
132
|
+
nov = nocca * nmoa + noccb * nmob
|
|
131
133
|
|
|
132
134
|
def vind_vo(mo1):
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
nd = mo1.shape[0]
|
|
136
|
+
mo1 = mo1.reshape(nd, nov)
|
|
137
|
+
v = fvind(mo1).reshape(nd, nov)
|
|
135
138
|
if level_shift != 0:
|
|
136
139
|
v -= mo1 * level_shift
|
|
137
|
-
v1a = v[:,:nmoa*nocca].reshape(
|
|
138
|
-
v1b = v[:,nmoa*nocca:].reshape(
|
|
140
|
+
v1a = v[:,:nmoa*nocca].reshape(nd,nmoa,nocca)
|
|
141
|
+
v1b = v[:,nmoa*nocca:].reshape(nd,nmob,noccb)
|
|
139
142
|
v1a[:,viridxa] *= eai_a
|
|
140
143
|
v1b[:,viridxb] *= eai_b
|
|
141
144
|
v1a[:,occidxa] = 0
|
|
142
145
|
v1b[:,occidxb] = 0
|
|
143
|
-
return v.
|
|
144
|
-
mo1 = lib.krylov(vind_vo, mo1base.
|
|
146
|
+
return v.reshape(nd, nov)
|
|
147
|
+
mo1 = lib.krylov(vind_vo, mo1base.reshape(-1, nov),
|
|
145
148
|
tol=tol, max_cycle=max_cycle, hermi=hermi, verbose=log)
|
|
146
149
|
mo1 = mo1.reshape(mo1base.shape)
|
|
147
150
|
mo1_a = mo1[:,:nmoa*nocca].reshape(nset,nmoa,nocca)
|
|
@@ -164,4 +167,6 @@ def solve_withs1(fvind, mo_energy, mo_occ, h1, s1,
|
|
|
164
167
|
if isinstance(h1[0], numpy.ndarray) and h1[0].ndim == 2:
|
|
165
168
|
mo1_a, mo1_b = mo1_a[0], mo1_b[0]
|
|
166
169
|
mo_e1_a, mo_e1_b = mo_e1_a[0], mo_e1_b[0]
|
|
170
|
+
else:
|
|
171
|
+
assert h1[0].ndim == 3
|
|
167
172
|
return (mo1_a, mo1_b), (mo_e1_a, mo_e1_b)
|