pyscf 2.7.0__py3-none-macosx_11_0_arm64.whl → 2.9.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 +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 +3 -3
- pyscf/ao2mo/r_outcore.py +2 -2
- pyscf/cc/__init__.py +2 -3
- pyscf/cc/ccsd.py +13 -5
- pyscf/cc/ccsd_rdm.py +6 -1
- pyscf/cc/dfccsd.py +3 -3
- pyscf/cc/dfuccsd.py +310 -0
- pyscf/cc/gccsd.py +2 -2
- pyscf/cc/rccsd.py +5 -1
- pyscf/cc/uccsd.py +36 -27
- pyscf/cc/uccsd_rdm.py +2 -2
- pyscf/df/addons.py +8 -3
- pyscf/df/autoaux.py +4 -0
- pyscf/df/df_jk.py +56 -25
- pyscf/df/grad/rhf.py +31 -1
- pyscf/df/hessian/uhf.py +2 -2
- pyscf/df/incore.py +2 -2
- pyscf/df/outcore.py +6 -6
- pyscf/dft/gks.py +25 -21
- pyscf/dft/libxc.py +31 -11
- pyscf/dft/numint.py +33 -16
- pyscf/dft/radi.py +9 -2
- pyscf/dft/rks.py +28 -24
- pyscf/dft/roks.py +7 -1
- pyscf/dft/uks.py +34 -25
- pyscf/fci/direct_spin1.py +0 -1
- pyscf/fci/fci_dhf_slow.py +15 -1
- pyscf/grad/ccsd.py +3 -7
- pyscf/grad/ccsd_slow.py +2 -3
- pyscf/grad/mp2.py +12 -3
- pyscf/grad/sacasscf.py +2 -0
- pyscf/grad/uccsd.py +3 -7
- pyscf/grad/ump2.py +2 -4
- pyscf/gto/basis/__init__.py +32 -5
- 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_nwchem.py +25 -10
- pyscf/gto/eval_gto.py +1 -1
- pyscf/gto/ft_ao.py +6 -6
- pyscf/gto/mole.py +32 -35
- pyscf/gto/moleintor.py +26 -1
- pyscf/gw/rpa.py +133 -244
- pyscf/gw/urpa.py +84 -131
- pyscf/hessian/uks.py +1 -1
- pyscf/lib/CMakeLists.txt +8 -4
- pyscf/lib/config.h +0 -1
- pyscf/lib/config.h.in +0 -1
- 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/libxc_itrf.c +25 -21
- pyscf/lib/dft/nr_numint_sparse.c +3 -3
- pyscf/lib/diis.py +1 -1
- pyscf/lib/exceptions.py +3 -0
- 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 +5 -6
- pyscf/lib/logger.py +2 -1
- pyscf/lib/mcscf/fci_contract.c +8 -1
- pyscf/lib/misc.py +16 -8
- 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 +194 -10
- pyscf/lib/pbc/nr_direct.c +2 -7
- pyscf/lib/vhf/fblas.h +3 -0
- pyscf/lib/vhf/nr_sr_vhf.c +8 -12
- pyscf/lib/vhf/rkb_screen.c +139 -0
- pyscf/mcscf/__init__.py +1 -1
- pyscf/mcscf/casci.py +7 -3
- pyscf/mcscf/chkfile.py +2 -3
- pyscf/mcscf/mc1step.py +12 -8
- pyscf/mcscf/newton_casscf.py +1 -1
- pyscf/mcscf/umc1step.py +5 -3
- pyscf/mp/__init__.py +2 -2
- 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 +19 -5
- pyscf/mp/ump2.py +23 -18
- pyscf/mrpt/nevpt2.py +11 -0
- pyscf/pbc/df/aft.py +9 -7
- pyscf/pbc/df/df.py +5 -6
- pyscf/pbc/df/df_jk.py +12 -6
- pyscf/pbc/df/fft.py +3 -3
- pyscf/pbc/df/fft_jk.py +7 -7
- pyscf/pbc/df/incore.py +1 -1
- pyscf/pbc/df/mdf_jk.py +2 -1
- pyscf/pbc/df/outcore.py +10 -10
- pyscf/pbc/df/rsdf.py +1 -0
- pyscf/pbc/df/rsdf_builder.py +3 -3
- pyscf/pbc/df/rsdf_helper.py +5 -5
- pyscf/pbc/df/rsdf_jk.py +2 -1
- 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 +17 -7
- pyscf/pbc/dft/multigrid/multigrid_pair.py +6 -1
- pyscf/pbc/dft/numint.py +26 -10
- pyscf/pbc/dft/rks.py +20 -26
- pyscf/pbc/dft/uks.py +21 -4
- pyscf/pbc/gto/_pbcintor.py +1 -0
- pyscf/pbc/gto/cell.py +170 -5
- pyscf/pbc/gto/eval_gto.py +1 -1
- pyscf/pbc/gto/neighborlist.py +4 -1
- pyscf/pbc/mpitools/mpi.py +0 -1
- pyscf/pbc/scf/_response_functions.py +141 -34
- pyscf/pbc/scf/hf.py +13 -10
- pyscf/pbc/scf/khf.py +32 -3
- pyscf/pbc/scf/khf_ksymm.py +15 -1
- pyscf/pbc/scf/kuhf.py +1 -1
- pyscf/pbc/scf/kuhf_ksymm.py +1 -1
- pyscf/pbc/scf/rsjk.py +1 -1
- pyscf/pbc/scf/stability.py +26 -14
- pyscf/pbc/tdscf/krhf.py +58 -56
- pyscf/pbc/tdscf/kuhf.py +273 -78
- pyscf/pbc/tdscf/rhf.py +17 -12
- pyscf/pbc/tdscf/uhf.py +46 -35
- pyscf/pbc/tools/k2gamma.py +15 -3
- pyscf/pbc/tools/lattice.py +3 -3
- pyscf/pbc/tools/pbc.py +48 -35
- pyscf/pbc/x2c/sfx2c1e.py +5 -0
- pyscf/scf/_response_functions.py +85 -44
- pyscf/scf/_vhf.py +1 -0
- pyscf/scf/addons.py +21 -2
- pyscf/scf/dhf.py +82 -28
- pyscf/scf/dispersion.py +1 -1
- pyscf/scf/hf.py +19 -3
- pyscf/scf/uhf.py +9 -3
- pyscf/solvent/__init__.py +2 -2
- pyscf/solvent/_attach_solvent.py +2 -0
- pyscf/solvent/cosmors.py +378 -0
- pyscf/solvent/grad/pcm.py +75 -19
- pyscf/solvent/hessian/pcm.py +957 -108
- pyscf/solvent/hessian/smd.py +7 -43
- pyscf/solvent/pcm.py +4 -4
- pyscf/solvent/smd.py +5 -3
- pyscf/soscf/ciah.py +2 -10
- pyscf/soscf/newton_ah.py +4 -1
- pyscf/symm/geom.py +58 -13
- pyscf/tdscf/_lr_eig.py +561 -57
- pyscf/tdscf/dhf.py +58 -65
- pyscf/tdscf/ghf.py +63 -71
- pyscf/tdscf/gks.py +12 -10
- pyscf/tdscf/rhf.py +68 -68
- pyscf/tdscf/rks.py +12 -9
- pyscf/tdscf/uhf.py +59 -58
- pyscf/tdscf/uks.py +15 -13
- pyscf/tools/fcidump.py +36 -9
- pyscf/tools/finite_diff.py +175 -0
- pyscf/tools/qcschema.py +265 -0
- pyscf/x2c/tdscf.py +37 -37
- pyscf/x2c/x2c.py +101 -34
- {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/METADATA +30 -26
- {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/RECORD +224 -192
- {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/WHEEL +2 -1
- {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info/licenses}/NOTICE +13 -0
- 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.7.0.dist-info → pyscf-2.9.0.dist-info/licenses}/LICENSE +0 -0
- {pyscf-2.7.0.dist-info → pyscf-2.9.0.dist-info}/top_level.txt +0 -0
pyscf/cc/uccsd.py
CHANGED
|
@@ -236,8 +236,8 @@ def update_amps(cc, t1, t2, eris):
|
|
|
236
236
|
u1a -= np.einsum('imea,me->ia', t2aa, Fova)
|
|
237
237
|
u1a += np.einsum('iMaE,ME->ia', t2ab, Fovb)
|
|
238
238
|
u1b += fovb.conj()
|
|
239
|
-
u1b += np.einsum('ie,ae->ia',t1b,Fvvb)
|
|
240
|
-
u1b -= np.einsum('ma,mi->ia',t1b,Foob)
|
|
239
|
+
u1b += np.einsum('ie,ae->ia', t1b, Fvvb)
|
|
240
|
+
u1b -= np.einsum('ma,mi->ia', t1b, Foob)
|
|
241
241
|
u1b -= np.einsum('imea,me->ia', t2bb, Fovb)
|
|
242
242
|
u1b += np.einsum('mIeA,me->IA', t2ab, Fova)
|
|
243
243
|
|
|
@@ -246,8 +246,8 @@ def update_amps(cc, t1, t2, eris):
|
|
|
246
246
|
wovvo -= eris_oovv.transpose(0,2,3,1)
|
|
247
247
|
wovvo += eris_ovvo.transpose(0,2,1,3)
|
|
248
248
|
oovv = eris_oovv - eris_ovvo.transpose(0,3,2,1)
|
|
249
|
-
u1a-= np.einsum('nf,niaf->ia', t1a,
|
|
250
|
-
tmp1aa = lib.einsum('ie,mjbe->mbij', t1a,
|
|
249
|
+
u1a-= np.einsum('nf,niaf->ia', t1a, oovv)
|
|
250
|
+
tmp1aa = lib.einsum('ie,mjbe->mbij', t1a, oovv)
|
|
251
251
|
u2aa += 2*lib.einsum('ma,mbij->ijab', t1a, tmp1aa)
|
|
252
252
|
eris_ovvo = eris_oovv = oovv = tmp1aa = None
|
|
253
253
|
|
|
@@ -256,8 +256,8 @@ def update_amps(cc, t1, t2, eris):
|
|
|
256
256
|
wOVVO -= eris_OOVV.transpose(0,2,3,1)
|
|
257
257
|
wOVVO += eris_OVVO.transpose(0,2,1,3)
|
|
258
258
|
OOVV = eris_OOVV - eris_OVVO.transpose(0,3,2,1)
|
|
259
|
-
u1b-= np.einsum('nf,niaf->ia', t1b,
|
|
260
|
-
tmp1bb = lib.einsum('ie,mjbe->mbij', t1b,
|
|
259
|
+
u1b-= np.einsum('nf,niaf->ia', t1b, OOVV)
|
|
260
|
+
tmp1bb = lib.einsum('ie,mjbe->mbij', t1b, OOVV)
|
|
261
261
|
u2bb += 2*lib.einsum('ma,mbij->ijab', t1b, tmp1bb)
|
|
262
262
|
eris_OVVO = eris_OOVV = OOVV = None
|
|
263
263
|
|
|
@@ -356,16 +356,16 @@ def energy(cc, t1=None, t2=None, eris=None):
|
|
|
356
356
|
fovb = eris.fockb[:noccb,noccb:]
|
|
357
357
|
e = np.einsum('ia,ia', fova, t1a)
|
|
358
358
|
e += np.einsum('ia,ia', fovb, t1b)
|
|
359
|
-
e += 0.25*np.einsum('ijab,iajb',t2aa,eris_ovov)
|
|
360
|
-
e -= 0.25*np.einsum('ijab,ibja',t2aa,eris_ovov)
|
|
361
|
-
e += 0.25*np.einsum('ijab,iajb',t2bb,eris_OVOV)
|
|
362
|
-
e -= 0.25*np.einsum('ijab,ibja',t2bb,eris_OVOV)
|
|
363
|
-
e += np.einsum('iJaB,iaJB',t2ab,eris_ovOV)
|
|
364
|
-
e += 0.5*
|
|
365
|
-
e -= 0.5*
|
|
366
|
-
e += 0.5*
|
|
367
|
-
e -= 0.5*
|
|
368
|
-
e +=
|
|
359
|
+
e += 0.25*np.einsum('ijab,iajb',t2aa, eris_ovov)
|
|
360
|
+
e -= 0.25*np.einsum('ijab,ibja',t2aa, eris_ovov)
|
|
361
|
+
e += 0.25*np.einsum('ijab,iajb',t2bb, eris_OVOV)
|
|
362
|
+
e -= 0.25*np.einsum('ijab,ibja',t2bb, eris_OVOV)
|
|
363
|
+
e += np.einsum('iJaB,iaJB',t2ab, eris_ovOV)
|
|
364
|
+
e += 0.5*lib.einsum('ia,jb,iajb',t1a, t1a, eris_ovov)
|
|
365
|
+
e -= 0.5*lib.einsum('ia,jb,ibja',t1a, t1a, eris_ovov)
|
|
366
|
+
e += 0.5*lib.einsum('ia,jb,iajb',t1b, t1b, eris_OVOV)
|
|
367
|
+
e -= 0.5*lib.einsum('ia,jb,ibja',t1b, t1b, eris_OVOV)
|
|
368
|
+
e += lib.einsum('ia,jb,iajb',t1a, t1b, eris_ovOV)
|
|
369
369
|
if abs(e.imag) > 1e-4:
|
|
370
370
|
logger.warn(cc, 'Non-zero imaginary part found in UCCSD energy %s', e)
|
|
371
371
|
return e.real
|
|
@@ -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
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)
|
|
@@ -687,11 +687,10 @@ class UCCSD(ccsd.CCSDBase):
|
|
|
687
687
|
return _make_eris_incore(self, mo_coeff)
|
|
688
688
|
|
|
689
689
|
elif getattr(self._scf, 'with_df', None):
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
# 'DF-CCSD calculations')
|
|
690
|
+
logger.warn(self, 'UCCSD detected DF being used in the HF object. '
|
|
691
|
+
'MO integrals are computed based on the DF 3-index tensors.\n'
|
|
692
|
+
'It\'s recommended to use dfuccsd.UCCSD for the '
|
|
693
|
+
'DF-UCCSD calculations')
|
|
695
694
|
return _make_df_eris_outcore(self, mo_coeff)
|
|
696
695
|
else:
|
|
697
696
|
return _make_eris_outcore(self, mo_coeff)
|
|
@@ -732,6 +731,16 @@ class UCCSD(ccsd.CCSDBase):
|
|
|
732
731
|
from pyscf.cc import eom_uccsd
|
|
733
732
|
return eom_uccsd.EOMEE(self)
|
|
734
733
|
|
|
734
|
+
def density_fit(self, auxbasis=None, with_df=None):
|
|
735
|
+
from pyscf.cc import dfuccsd
|
|
736
|
+
mycc = dfuccsd.UCCSD(self._scf, self.frozen, self.mo_coeff, self.mo_occ)
|
|
737
|
+
if with_df is not None:
|
|
738
|
+
mycc.with_df = with_df
|
|
739
|
+
if mycc.with_df.auxbasis != auxbasis:
|
|
740
|
+
mycc.with_df = mycc.with_df.copy()
|
|
741
|
+
mycc.with_df.auxbasis = auxbasis
|
|
742
|
+
return mycc
|
|
743
|
+
|
|
735
744
|
def nuc_grad_method(self):
|
|
736
745
|
from pyscf.grad import uccsd
|
|
737
746
|
return uccsd.Gradients(self)
|
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/df/addons.py
CHANGED
|
@@ -52,8 +52,10 @@ DEFAULT_AUXBASIS = {
|
|
|
52
52
|
'def2svp' : ('def2-svp-jkfit' , 'def2-svp-ri' ),
|
|
53
53
|
'def2svpd' : ('def2-svp-jkfit' , 'def2-svpd-ri' ),
|
|
54
54
|
'def2tzvp' : ('def2-tzvp-jkfit' , 'def2-tzvp-ri' ),
|
|
55
|
+
'def2mtzvp' : ('def2-tzvp-jkfit' , 'def2-tzvp-ri' ),
|
|
55
56
|
'def2tzvpd' : ('def2-tzvp-jkfit' , 'def2-tzvpd-ri' ),
|
|
56
57
|
'def2tzvpp' : ('def2-tzvpp-jkfit' , 'def2-tzvpp-ri' ),
|
|
58
|
+
'def2mtzvpp' : ('def2-tzvpp-jkfit' , 'def2-tzvpp-ri' ),
|
|
57
59
|
'def2tzvppd' : ('def2-tzvpp-jkfit' , 'def2-tzvppd-ri' ),
|
|
58
60
|
'def2qzvp' : ('def2-qzvp-jkfit' , 'def2-qzvp-ri' ),
|
|
59
61
|
'def2qzvpd' : ('def2-qzvp-jkfit' , None ),
|
|
@@ -151,8 +153,8 @@ def aug_etb_for_dfbasis(mol, dfbasis=DFBASIS, beta=ETB_BETA,
|
|
|
151
153
|
if etb:
|
|
152
154
|
newbasis[symb] = gto.expand_etbs(etb)
|
|
153
155
|
for l, n, emin, beta in etb:
|
|
154
|
-
logger.info(mol, 'l = %d, exps = %s * %g^n
|
|
155
|
-
l, emin, beta, n-1)
|
|
156
|
+
logger.info(mol, 'ETB for %s: l = %d, exps = %s * %g^n , n = 0..%d',
|
|
157
|
+
symb, l, emin, beta, n-1)
|
|
156
158
|
else:
|
|
157
159
|
raise RuntimeError(f'Failed to generate even-tempered auxbasis for {symb}')
|
|
158
160
|
|
|
@@ -174,6 +176,9 @@ def make_auxbasis(mol, mp2fit=False):
|
|
|
174
176
|
_basis = {a: default_basis for a in uniq_atoms}
|
|
175
177
|
_basis.update(mol.basis)
|
|
176
178
|
del (_basis['default'])
|
|
179
|
+
elif (isinstance(mol.basis, dict) and
|
|
180
|
+
all([isinstance(basis, str) for basis in mol.basis.values()])):
|
|
181
|
+
_basis = {a: mol.basis[a] for a in uniq_atoms}
|
|
177
182
|
else:
|
|
178
183
|
_basis = mol._basis or {}
|
|
179
184
|
|
|
@@ -191,7 +196,7 @@ def make_auxbasis(mol, mp2fit=False):
|
|
|
191
196
|
if auxb is not None:
|
|
192
197
|
try:
|
|
193
198
|
# Test if basis auxb for element k is available
|
|
194
|
-
gto.basis.load(auxb, k)
|
|
199
|
+
gto.basis.load(auxb, elements._std_symbol_without_ghost(k))
|
|
195
200
|
except BasisNotFoundError:
|
|
196
201
|
pass
|
|
197
202
|
else:
|
pyscf/df/autoaux.py
CHANGED
|
@@ -24,6 +24,7 @@ Ref:
|
|
|
24
24
|
from math import factorial
|
|
25
25
|
import numpy as np
|
|
26
26
|
from pyscf import gto
|
|
27
|
+
from pyscf.lib import logger
|
|
27
28
|
|
|
28
29
|
F_LAUX = np.array([20 , 7.0, 4.0, 4.0, 3.5, 2.5, 2.0, 2.0])
|
|
29
30
|
BETA_BIG = np.array([1.8, 2.0, 2.2, 2.2, 2.2, 2.3, 3.0, 3.0])
|
|
@@ -136,6 +137,9 @@ def autoaux(mol):
|
|
|
136
137
|
Z = gto.charge(symb)
|
|
137
138
|
etb = _auto_aux_element(Z, mol._basis[symb])
|
|
138
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)
|
|
139
143
|
return gto.expand_etbs(etb)
|
|
140
144
|
raise RuntimeError(f'Failed to generate even-tempered auxbasis for {symb}')
|
|
141
145
|
|
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
|
|
@@ -255,6 +258,33 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
255
258
|
vj = 0
|
|
256
259
|
vk = numpy.zeros_like(dms)
|
|
257
260
|
|
|
261
|
+
if numpy.iscomplexobj(dms):
|
|
262
|
+
if with_j:
|
|
263
|
+
vj = numpy.zeros_like(dms)
|
|
264
|
+
max_memory = dfobj.max_memory - lib.current_memory()[0]
|
|
265
|
+
blksize = max(4, int(min(dfobj.blockdim, max_memory*.22e6/8/nao**2)))
|
|
266
|
+
buf = numpy.empty((blksize,nao,nao))
|
|
267
|
+
buf1 = numpy.empty((nao,blksize,nao))
|
|
268
|
+
for eri1 in dfobj.loop(blksize):
|
|
269
|
+
naux, nao_pair = eri1.shape
|
|
270
|
+
eri1 = lib.unpack_tril(eri1, out=buf)
|
|
271
|
+
if with_j:
|
|
272
|
+
tmp = numpy.einsum('pij,nji->pn', eri1, dms.real)
|
|
273
|
+
vj.real += numpy.einsum('pn,pij->nij', tmp, eri1)
|
|
274
|
+
tmp = numpy.einsum('pij,nji->pn', eri1, dms.imag)
|
|
275
|
+
vj.imag += numpy.einsum('pn,pij->nij', tmp, eri1)
|
|
276
|
+
buf2 = numpy.ndarray((nao,naux,nao), buffer=buf1)
|
|
277
|
+
for k in range(nset):
|
|
278
|
+
buf2[:] = lib.einsum('pij,jk->ipk', eri1, dms[k].real)
|
|
279
|
+
vk[k].real += lib.einsum('ipk,pkj->ij', buf2, eri1)
|
|
280
|
+
buf2[:] = lib.einsum('pij,jk->ipk', eri1, dms[k].imag)
|
|
281
|
+
vk[k].imag += lib.einsum('ipk,pkj->ij', buf2, eri1)
|
|
282
|
+
t1 = log.timer_debug1('jk', *t1)
|
|
283
|
+
if with_j: vj = vj.reshape(dm_shape)
|
|
284
|
+
if with_k: vk = vk.reshape(dm_shape)
|
|
285
|
+
logger.timer(dfobj, 'df vj and vk', *t0)
|
|
286
|
+
return vj, vk
|
|
287
|
+
|
|
258
288
|
if with_j:
|
|
259
289
|
idx = numpy.arange(nao)
|
|
260
290
|
dmtril = lib.pack_tril(dms + dms.conj().transpose(0,2,1))
|
|
@@ -263,8 +293,7 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
263
293
|
if not with_k:
|
|
264
294
|
for eri1 in dfobj.loop():
|
|
265
295
|
# uses numpy.matmul
|
|
266
|
-
vj += (
|
|
267
|
-
|
|
296
|
+
vj += dmtril.dot(eri1.T).dot(eri1)
|
|
268
297
|
|
|
269
298
|
elif getattr(dm, 'mo_coeff', None) is not None:
|
|
270
299
|
#TODO: test whether dm.mo_coeff matching dm
|
|
@@ -294,7 +323,8 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
294
323
|
assert (nao_pair == nao*(nao+1)//2)
|
|
295
324
|
if with_j:
|
|
296
325
|
# uses numpy.matmul
|
|
297
|
-
vj += (
|
|
326
|
+
vj += dmtril.dot(eri1.T).dot(eri1)
|
|
327
|
+
|
|
298
328
|
for k in range(nset):
|
|
299
329
|
nocc = orbo[k].shape[1]
|
|
300
330
|
if nocc > 0:
|
|
@@ -319,10 +349,10 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
319
349
|
buf = numpy.empty((2,blksize,nao,nao))
|
|
320
350
|
for eri1 in dfobj.loop(blksize):
|
|
321
351
|
naux, nao_pair = eri1.shape
|
|
352
|
+
assert (nao_pair == nao*(nao+1)//2)
|
|
322
353
|
if with_j:
|
|
323
354
|
# uses numpy.matmul
|
|
324
|
-
vj += (
|
|
325
|
-
|
|
355
|
+
vj += dmtril.dot(eri1.T).dot(eri1)
|
|
326
356
|
|
|
327
357
|
for k in range(nset):
|
|
328
358
|
buf1 = buf[0,:naux]
|
|
@@ -341,7 +371,7 @@ def get_jk(dfobj, dm, hermi=1, with_j=True, with_k=True, direct_scf_tol=1e-13):
|
|
|
341
371
|
logger.timer(dfobj, 'df vj and vk', *t0)
|
|
342
372
|
return vj, vk
|
|
343
373
|
|
|
344
|
-
def get_j(dfobj, dm, hermi=
|
|
374
|
+
def get_j(dfobj, dm, hermi=0, direct_scf_tol=1e-13):
|
|
345
375
|
from pyscf.scf import _vhf
|
|
346
376
|
from pyscf.scf import jk
|
|
347
377
|
from pyscf.df import addons
|
|
@@ -386,6 +416,7 @@ def get_j(dfobj, dm, hermi=1, direct_scf_tol=1e-13):
|
|
|
386
416
|
opt = dfobj._vjopt
|
|
387
417
|
fakemol = opt.fakemol
|
|
388
418
|
dm = numpy.asarray(dm, order='C')
|
|
419
|
+
assert dm.dtype == numpy.float64
|
|
389
420
|
dm_shape = dm.shape
|
|
390
421
|
nao = dm_shape[-1]
|
|
391
422
|
dm = dm.reshape(-1,nao,nao)
|
|
@@ -434,7 +465,7 @@ def get_j(dfobj, dm, hermi=1, direct_scf_tol=1e-13):
|
|
|
434
465
|
return numpy.asarray(vj).reshape(dm_shape)
|
|
435
466
|
|
|
436
467
|
|
|
437
|
-
def r_get_jk(dfobj, dms, hermi=
|
|
468
|
+
def r_get_jk(dfobj, dms, hermi=0, with_j=True, with_k=True):
|
|
438
469
|
'''Relativistic density fitting JK'''
|
|
439
470
|
t0 = (logger.process_clock(), logger.perf_counter())
|
|
440
471
|
mol = dfobj.mol
|
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
|
pyscf/df/hessian/uhf.py
CHANGED
|
@@ -465,9 +465,9 @@ def _gen_jk(hessobj, mo_coeff, mo_occ, chkfile=None, atmlst=None,
|
|
|
465
465
|
vj1_buf[i] += np.einsum('xp,pij->xij', wj1, coef3c)
|
|
466
466
|
if with_k:
|
|
467
467
|
rhok0_PlJ = lib.einsum('plj,Jj->plJ', rhok0a_Pl_[p0:p1], mocca)
|
|
468
|
-
vk1a_buf += lib.einsum('xijp,plj->xil', int3c_ip1, rhok0_PlJ
|
|
468
|
+
vk1a_buf += lib.einsum('xijp,plj->xil', int3c_ip1, rhok0_PlJ)
|
|
469
469
|
rhok0_PlJ = lib.einsum('plj,Jj->plJ', rhok0b_Pl_[p0:p1], moccb)
|
|
470
|
-
vk1b_buf += lib.einsum('xijp,plj->xil', int3c_ip1, rhok0_PlJ
|
|
470
|
+
vk1b_buf += lib.einsum('xijp,plj->xil', int3c_ip1, rhok0_PlJ)
|
|
471
471
|
int3c_ip1 = None
|
|
472
472
|
vj1_buf = ftmp['vj1_buf'] = vj1_buf
|
|
473
473
|
|
pyscf/df/incore.py
CHANGED
|
@@ -62,7 +62,7 @@ def aux_e2(mol, auxmol_or_auxbasis, intor='int3c2e', aosym='s1', comp=None, out=
|
|
|
62
62
|
mol.nbas, mol.nbas+auxmol.nbas)
|
|
63
63
|
else:
|
|
64
64
|
assert len(shls_slice) == 6
|
|
65
|
-
assert shls_slice[5]
|
|
65
|
+
assert shls_slice[5] <= auxmol.nbas
|
|
66
66
|
shls_slice = list(shls_slice)
|
|
67
67
|
shls_slice[4] += mol.nbas
|
|
68
68
|
shls_slice[5] += mol.nbas
|
|
@@ -155,7 +155,7 @@ def cholesky_eri(mol, auxbasis='weigend+etb', auxmol=None,
|
|
|
155
155
|
atm, bas, env = gto.mole.conc_env(mol._atm, mol._bas, mol._env,
|
|
156
156
|
auxmol._atm, auxmol._bas, auxmol._env)
|
|
157
157
|
ao_loc = gto.moleintor.make_loc(bas, int3c)
|
|
158
|
-
nao = ao_loc[mol.nbas]
|
|
158
|
+
nao = int(ao_loc[mol.nbas])
|
|
159
159
|
|
|
160
160
|
if aosym == 's1':
|
|
161
161
|
nao_pair = nao * nao
|
pyscf/df/outcore.py
CHANGED
|
@@ -146,8 +146,8 @@ def cholesky_eri_b(mol, erifile, auxbasis='weigend+etb', dataname='j3c',
|
|
|
146
146
|
atm, bas, env = gto.mole.conc_env(mol._atm, mol._bas, mol._env,
|
|
147
147
|
auxmol._atm, auxmol._bas, auxmol._env)
|
|
148
148
|
ao_loc = gto.moleintor.make_loc(bas, int3c)
|
|
149
|
-
nao = ao_loc[mol.nbas]
|
|
150
|
-
naoaux = ao_loc[-1] - nao
|
|
149
|
+
nao = int(ao_loc[mol.nbas])
|
|
150
|
+
naoaux = int(ao_loc[-1] - nao)
|
|
151
151
|
if aosym == 's1':
|
|
152
152
|
nao_pair = nao * nao
|
|
153
153
|
buflen = min(max(int(max_memory*.24e6/8/naoaux/comp), 1), nao_pair)
|
|
@@ -289,12 +289,12 @@ def general(mol, mo_coeffs, erifile, auxbasis='weigend+etb', dataname='eri_mo',
|
|
|
289
289
|
|
|
290
290
|
def _guess_shell_ranges(mol, buflen, aosym, start=0, stop=None):
|
|
291
291
|
from pyscf.ao2mo.outcore import balance_partition
|
|
292
|
-
|
|
292
|
+
ao_loc_long = mol.ao_loc_nr().astype(numpy.int64)
|
|
293
293
|
if 's2' in aosym:
|
|
294
|
-
return balance_partition(
|
|
294
|
+
return balance_partition(ao_loc_long*(ao_loc_long+1)//2, buflen, start, stop)
|
|
295
295
|
else:
|
|
296
|
-
nao =
|
|
297
|
-
return balance_partition(
|
|
296
|
+
nao = ao_loc_long[-1]
|
|
297
|
+
return balance_partition(ao_loc_long*nao, buflen, start, stop)
|
|
298
298
|
|
|
299
299
|
def _create_h5file(erifile, dataname):
|
|
300
300
|
if isinstance(getattr(erifile, 'name', None), str):
|
pyscf/dft/gks.py
CHANGED
|
@@ -89,36 +89,40 @@ def get_veff(ks, mol=None, dm=None, dm_last=0, vhf_last=0, hermi=1):
|
|
|
89
89
|
logger.debug(ks, 'nelec with nlc grids = %s', n)
|
|
90
90
|
t0 = logger.timer(ks, 'vxc', *t0)
|
|
91
91
|
|
|
92
|
+
incremental_jk = (ks._eri is None and ks.direct_scf and
|
|
93
|
+
getattr(vhf_last, 'vj', None) is not None)
|
|
94
|
+
if incremental_jk:
|
|
95
|
+
_dm = numpy.asarray(dm) - numpy.asarray(dm_last)
|
|
96
|
+
else:
|
|
97
|
+
_dm = dm
|
|
92
98
|
if not ni.libxc.is_hybrid_xc(ks.xc):
|
|
93
99
|
vk = None
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
ddm = numpy.asarray(dm) - numpy.asarray(dm_last)
|
|
97
|
-
vj = ks.get_j(mol, ddm, hermi)
|
|
100
|
+
vj = ks.get_j(mol, _dm, hermi)
|
|
101
|
+
if incremental_jk:
|
|
98
102
|
vj += vhf_last.vj
|
|
99
|
-
else:
|
|
100
|
-
vj = ks.get_j(mol, dm, hermi)
|
|
101
103
|
vxc += vj
|
|
102
104
|
else:
|
|
103
105
|
omega, alpha, hyb = ni.rsh_and_hybrid_coeff(ks.xc, spin=mol.spin)
|
|
104
|
-
if
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
if omega == 0:
|
|
107
|
+
vj, vk = ks.get_jk(mol, _dm, hermi)
|
|
108
|
+
vk *= hyb
|
|
109
|
+
elif alpha == 0: # LR=0, only SR exchange
|
|
110
|
+
vj = ks.get_j(mol, _dm, hermi)
|
|
111
|
+
vk = ks.get_k(mol, _dm, hermi, omega=-omega)
|
|
108
112
|
vk *= hyb
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
elif hyb == 0: # SR=0, only LR exchange
|
|
114
|
+
vj = ks.get_j(mol, _dm, hermi)
|
|
115
|
+
vk = ks.get_k(mol, _dm, hermi, omega=omega)
|
|
116
|
+
vk *= alpha
|
|
117
|
+
else: # SR and LR exchange with different ratios
|
|
118
|
+
vj, vk = ks.get_jk(mol, _dm, hermi)
|
|
119
|
+
vk *= hyb
|
|
120
|
+
vklr = ks.get_k(mol, _dm, hermi, omega=omega)
|
|
121
|
+
vklr *= (alpha - hyb)
|
|
122
|
+
vk += vklr
|
|
123
|
+
if incremental_jk:
|
|
113
124
|
vj += vhf_last.vj
|
|
114
125
|
vk += vhf_last.vk
|
|
115
|
-
else:
|
|
116
|
-
vj, vk = ks.get_jk(mol, dm, hermi)
|
|
117
|
-
vk *= hyb
|
|
118
|
-
if omega != 0:
|
|
119
|
-
vklr = ks.get_k(mol, dm, hermi, omega=omega)
|
|
120
|
-
vklr *= (alpha - hyb)
|
|
121
|
-
vk += vklr
|
|
122
126
|
vxc += vj - vk
|
|
123
127
|
|
|
124
128
|
if ground_state:
|
pyscf/dft/libxc.py
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
'''
|
|
21
21
|
XC functional, the interface to libxc
|
|
22
|
-
(
|
|
22
|
+
(https://libxc.gitlab.io)
|
|
23
23
|
'''
|
|
24
24
|
|
|
25
25
|
import sys
|
|
@@ -410,9 +410,14 @@ def rsh_coeff(xc_code):
|
|
|
410
410
|
if 'SR_HF' in xc_code or 'LR_HF' in xc_code or 'RSH(' in xc_code:
|
|
411
411
|
check_omega = False
|
|
412
412
|
|
|
413
|
-
hyb, fn_facs = parse_xc(xc_code)
|
|
414
|
-
|
|
415
|
-
|
|
413
|
+
(hyb, alpha, omega), fn_facs = parse_xc(xc_code)
|
|
414
|
+
if omega == 0:
|
|
415
|
+
# SR and LR Coulomb share the same coefficients
|
|
416
|
+
# Note: this change breaks compatibility with pyscf-2.7
|
|
417
|
+
assert hyb == alpha
|
|
418
|
+
beta = 0.
|
|
419
|
+
else:
|
|
420
|
+
beta = hyb - alpha
|
|
416
421
|
rsh_pars = [omega, alpha, beta]
|
|
417
422
|
rsh_tmp = (ctypes.c_double*3)()
|
|
418
423
|
for xid, fac in fn_facs:
|
|
@@ -639,8 +644,6 @@ def parse_xc(description):
|
|
|
639
644
|
# dftd3 cannot be used in a custom xc description
|
|
640
645
|
assert '-d3' not in token
|
|
641
646
|
parse_token(token, 'compound XC', search_xc_alias=True)
|
|
642
|
-
if hyb[2] == 0: # No omega is assigned. LR_HF is 0 for normal Coulomb operator
|
|
643
|
-
hyb[1] = 0
|
|
644
647
|
return tuple(hyb), tuple(remove_dup(fn_facs))
|
|
645
648
|
|
|
646
649
|
_NAME_WITH_DASH = {'SR-HF' : 'SR_HF',
|
|
@@ -770,7 +773,7 @@ def eval_xc(xc_code, rho, spin=0, relativity=0, deriv=1, omega=None, verbose=Non
|
|
|
770
773
|
| vtau[:,2] = (u, d)
|
|
771
774
|
|
|
772
775
|
* fxc for restricted case:
|
|
773
|
-
(v2rho2, v2rhosigma, v2sigma2, v2lapl2,
|
|
776
|
+
(v2rho2, v2rhosigma, v2sigma2, v2lapl2, v2tau2, v2rholapl, v2rhotau, v2lapltau, v2sigmalapl, v2sigmatau)
|
|
774
777
|
|
|
775
778
|
* fxc for unrestricted case:
|
|
776
779
|
| v2rho2[:,3] = (u_u, u_d, d_d)
|
|
@@ -1186,16 +1189,33 @@ def define_xc_(ni, description, xctype='LDA', hyb=0, rsh=(0,0,0)):
|
|
|
1186
1189
|
outlen = lib.comb(xlen+deriv, deriv)
|
|
1187
1190
|
exc, vxc, fxc, kxc = libxc_out[:4]
|
|
1188
1191
|
out = [exc]
|
|
1189
|
-
if
|
|
1192
|
+
if deriv > 0:
|
|
1193
|
+
assert vxc is not None
|
|
1190
1194
|
out.extend([x for x in vxc if x is not None])
|
|
1191
|
-
if
|
|
1192
|
-
|
|
1193
|
-
|
|
1195
|
+
if deriv > 1:
|
|
1196
|
+
assert fxc is not None
|
|
1197
|
+
if xctype == 'GGA':
|
|
1198
|
+
assert len(fxc) == 3, 'fxc for GGA should be arranged as (v2rho2, v2rhosigma, v2sigma2)'
|
|
1199
|
+
elif xctype == 'MGGA':
|
|
1200
|
+
if len(fxc) == 10:
|
|
1201
|
+
fxc = [fxc[i] for i in [0, 1, 2, 6, 4, 9]]
|
|
1202
|
+
else:
|
|
1203
|
+
assert len(fxc) == 6, (
|
|
1204
|
+
'fxc for MGGA should be arranged as\n'
|
|
1205
|
+
'(v2rho2, v2rhosigma, v2sigma2, v2tau2, v2rhotau, v2sigmatau)\nor\n'
|
|
1206
|
+
'(v2rho2, v2rhosigma, v2sigma2, v2lapl2, v2tau2, '
|
|
1207
|
+
'v2rholapl, v2rhotau, v2lapltau, v2sigmalapl, v2sigmatau)')
|
|
1208
|
+
assert all(x is not None for x in fxc)
|
|
1209
|
+
out.extend(fxc)
|
|
1210
|
+
if deriv > 2:
|
|
1211
|
+
assert kxc is not None
|
|
1194
1212
|
out.extend([x for x in kxc if x is not None])
|
|
1213
|
+
|
|
1195
1214
|
if spin == 1:
|
|
1196
1215
|
# Returns of eval_xc are structured as [grid_id,deriv_component]
|
|
1197
1216
|
# for each term in libxc_out. Change the shape to [deriv_comp, grid_id]
|
|
1198
1217
|
out = [x.T for x in out]
|
|
1218
|
+
|
|
1199
1219
|
out = numpy.vstack(out)[:outlen]
|
|
1200
1220
|
assert len(out) == outlen
|
|
1201
1221
|
idx = _libxc_to_xcfun_indices(xctype, spin, deriv)
|