pyscf 2.7.0__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 +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/ccsd.py +13 -5
- pyscf/cc/ccsd_rdm.py +6 -1
- pyscf/cc/gccsd.py +2 -2
- pyscf/cc/uccsd.py +6 -6
- pyscf/cc/uccsd_rdm.py +2 -2
- pyscf/df/addons.py +2 -2
- pyscf/df/autoaux.py +4 -0
- pyscf/df/df_jk.py +27 -25
- pyscf/df/grad/rhf.py +31 -1
- pyscf/df/incore.py +1 -1
- pyscf/df/outcore.py +6 -6
- pyscf/dft/gks.py +25 -21
- pyscf/dft/libxc.py +30 -10
- 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/grad/ccsd.py +3 -7
- pyscf/grad/ccsd_slow.py +2 -3
- pyscf/grad/mp2.py +12 -3
- pyscf/grad/uccsd.py +3 -7
- pyscf/grad/ump2.py +2 -4
- pyscf/gto/basis/__init__.py +10 -4
- 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 +25 -28
- pyscf/gto/moleintor.py +1 -1
- pyscf/gw/rpa.py +133 -244
- pyscf/gw/urpa.py +79 -130
- pyscf/lib/CMakeLists.txt +6 -2
- 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 +6 -6
- 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/casci.py +5 -1
- pyscf/mcscf/chkfile.py +2 -3
- pyscf/mcscf/mc1step.py +10 -6
- pyscf/mcscf/umc1step.py +5 -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 +19 -5
- pyscf/mp/ump2.py +23 -18
- pyscf/pbc/df/aft.py +6 -7
- pyscf/pbc/df/df.py +1 -1
- pyscf/pbc/df/df_jk.py +4 -1
- 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_builder.py +2 -2
- 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 +16 -24
- pyscf/pbc/dft/uks.py +21 -4
- pyscf/pbc/gto/_pbcintor.py +1 -0
- pyscf/pbc/gto/cell.py +157 -4
- pyscf/pbc/gto/eval_gto.py +1 -1
- pyscf/pbc/gto/neighborlist.py +4 -1
- pyscf/pbc/scf/_response_functions.py +141 -34
- pyscf/pbc/scf/hf.py +0 -8
- 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 +13 -2
- pyscf/pbc/tools/lattice.py +3 -3
- pyscf/pbc/tools/pbc.py +48 -35
- pyscf/scf/_response_functions.py +85 -44
- pyscf/scf/_vhf.py +1 -0
- 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 +366 -0
- 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 +1 -5
- pyscf/tdscf/_lr_eig.py +554 -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/qcschema.py +265 -0
- pyscf/x2c/tdscf.py +37 -37
- {pyscf-2.7.0.dist-info → pyscf-2.8.0.dist-info}/METADATA +29 -26
- {pyscf-2.7.0.dist-info → pyscf-2.8.0.dist-info}/NOTICE +11 -0
- {pyscf-2.7.0.dist-info → pyscf-2.8.0.dist-info}/RECORD +203 -173
- {pyscf-2.7.0.dist-info → pyscf-2.8.0.dist-info}/WHEEL +1 -1
- 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.8.0.dist-info}/LICENSE +0 -0
- {pyscf-2.7.0.dist-info → pyscf-2.8.0.dist-info}/top_level.txt +0 -0
pyscf/__init__.py
CHANGED
pyscf/ao2mo/__init__.py
CHANGED
|
@@ -31,6 +31,7 @@ Simple usage::
|
|
|
31
31
|
import tempfile
|
|
32
32
|
import numpy
|
|
33
33
|
import h5py
|
|
34
|
+
from pyscf import gto
|
|
34
35
|
from pyscf.ao2mo import incore
|
|
35
36
|
from pyscf.ao2mo import outcore
|
|
36
37
|
from pyscf.ao2mo import r_outcore
|
|
@@ -143,7 +144,7 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e',
|
|
|
143
144
|
'''
|
|
144
145
|
if isinstance(eri_or_mol, numpy.ndarray):
|
|
145
146
|
return incore.full(eri_or_mol, mo_coeff, *args, **kwargs)
|
|
146
|
-
|
|
147
|
+
elif isinstance(eri_or_mol, gto.MoleBase):
|
|
147
148
|
if '_spinor' in intor:
|
|
148
149
|
mod = r_outcore
|
|
149
150
|
else:
|
|
@@ -157,6 +158,11 @@ def full(eri_or_mol, mo_coeff, erifile=None, dataname='eri_mo', intor='int2e',
|
|
|
157
158
|
*args, **kwargs)
|
|
158
159
|
else:
|
|
159
160
|
return mod.full_iofree(eri_or_mol, mo_coeff, intor, *args, **kwargs)
|
|
161
|
+
else:
|
|
162
|
+
raise RuntimeError('ERI is not available. If this is generated by mf._eri, '
|
|
163
|
+
'the integral tensor is too big to store in memory. '
|
|
164
|
+
'You should either increase mol.max_memory, or set '
|
|
165
|
+
'mol.incore_anyway. See issue #2473.')
|
|
160
166
|
|
|
161
167
|
def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
|
|
162
168
|
*args, **kwargs):
|
|
@@ -293,7 +299,7 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e
|
|
|
293
299
|
'''
|
|
294
300
|
if isinstance(eri_or_mol, numpy.ndarray):
|
|
295
301
|
return incore.general(eri_or_mol, mo_coeffs, *args, **kwargs)
|
|
296
|
-
|
|
302
|
+
elif isinstance(eri_or_mol, gto.MoleBase):
|
|
297
303
|
if '_spinor' in intor:
|
|
298
304
|
mod = r_outcore
|
|
299
305
|
else:
|
|
@@ -307,6 +313,11 @@ def general(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e
|
|
|
307
313
|
*args, **kwargs)
|
|
308
314
|
else:
|
|
309
315
|
return mod.general_iofree(eri_or_mol, mo_coeffs, intor, *args, **kwargs)
|
|
316
|
+
else:
|
|
317
|
+
raise RuntimeError('ERI is not available. If this is generated by mf._eri, '
|
|
318
|
+
'the integral tensor is too big to store in memory. '
|
|
319
|
+
'You should either increase mol.max_memory, or set '
|
|
320
|
+
'mol.incore_anyway. See issue #2473.')
|
|
310
321
|
|
|
311
322
|
def kernel(eri_or_mol, mo_coeffs, erifile=None, dataname='eri_mo', intor='int2e',
|
|
312
323
|
*args, **kwargs):
|
pyscf/ao2mo/_ao2mo.py
CHANGED
|
@@ -73,7 +73,7 @@ def nr_e1fill(intor, sh_range, atm, bas, env,
|
|
|
73
73
|
natm = ctypes.c_int(c_atm.shape[0])
|
|
74
74
|
nbas = ctypes.c_int(c_bas.shape[0])
|
|
75
75
|
ao_loc = make_loc(bas, intor)
|
|
76
|
-
nao = ao_loc[-1]
|
|
76
|
+
nao = int(ao_loc[-1])
|
|
77
77
|
|
|
78
78
|
klsh0, klsh1, nkl = sh_range
|
|
79
79
|
|
|
@@ -137,6 +137,9 @@ def nr_e1(eri, mo_coeff, orbs_slice, aosym='s1', mosym='s1', out=None):
|
|
|
137
137
|
if out.size == 0:
|
|
138
138
|
return out
|
|
139
139
|
|
|
140
|
+
if eri.dtype != numpy.double:
|
|
141
|
+
raise TypeError('_ao2mo.nr_e1 is for double precision only')
|
|
142
|
+
|
|
140
143
|
fdrv = getattr(libao2mo, 'AO2MOnr_e2_drv')
|
|
141
144
|
pao_loc = ctypes.POINTER(ctypes.c_void_p)()
|
|
142
145
|
c_nbas = ctypes.c_int(0)
|
|
@@ -184,6 +187,9 @@ def nr_e2(eri, mo_coeff, orbs_slice, aosym='s1', mosym='s1', out=None,
|
|
|
184
187
|
if out.size == 0:
|
|
185
188
|
return out
|
|
186
189
|
|
|
190
|
+
if eri.dtype != numpy.double:
|
|
191
|
+
raise TypeError('_ao2mo.nr_e2 is for double precision only')
|
|
192
|
+
|
|
187
193
|
if ao_loc is None:
|
|
188
194
|
pao_loc = ctypes.POINTER(ctypes.c_void_p)()
|
|
189
195
|
c_nbas = ctypes.c_int(0)
|
|
@@ -283,6 +289,9 @@ def r_e2(eri, mo_coeff, orbs_slice, tao, ao_loc, aosym='s1', out=None):
|
|
|
283
289
|
if out.size == 0:
|
|
284
290
|
return out
|
|
285
291
|
|
|
292
|
+
if eri.dtype != numpy.complex128:
|
|
293
|
+
raise TypeError('_ao2mo.r_e2 is for complex double precision only')
|
|
294
|
+
|
|
286
295
|
tao = numpy.asarray(tao, dtype=numpy.int32)
|
|
287
296
|
if ao_loc is None:
|
|
288
297
|
c_ao_loc = ctypes.POINTER(ctypes.c_void_p)()
|
pyscf/ao2mo/incore.py
CHANGED
|
@@ -202,6 +202,9 @@ def half_e1(eri_ao, mo_coeffs, compact=True):
|
|
|
202
202
|
if nij_pair == 0:
|
|
203
203
|
return eri1
|
|
204
204
|
|
|
205
|
+
if eri_ao.dtype != numpy.double:
|
|
206
|
+
raise TypeError('ao2mo.incore.half_e1 is for double precision only')
|
|
207
|
+
|
|
205
208
|
if eri_ao.size == nao_pair**2: # 4-fold symmetry
|
|
206
209
|
# half_e1 first transforms the indices which are contiguous in memory
|
|
207
210
|
# transpose the 4-fold integrals to make ij the contiguous indices
|
pyscf/ao2mo/nrr_outcore.py
CHANGED
|
@@ -380,9 +380,9 @@ def _count_naopair(mol, nao):
|
|
|
380
380
|
ao_loc = mol.ao_loc_2c()
|
|
381
381
|
nao_pair = 0
|
|
382
382
|
for i in range(mol.nbas):
|
|
383
|
-
di = ao_loc[i+1] - ao_loc[i]
|
|
383
|
+
di = int(ao_loc[i+1] - ao_loc[i])
|
|
384
384
|
for j in range(i+1):
|
|
385
|
-
dj = ao_loc[j+1] - ao_loc[j]
|
|
385
|
+
dj = int(ao_loc[j+1] - ao_loc[j])
|
|
386
386
|
nao_pair += di * dj
|
|
387
387
|
return nao_pair
|
|
388
388
|
|
pyscf/ao2mo/outcore.py
CHANGED
|
@@ -710,8 +710,8 @@ def guess_shell_ranges(mol, aosym, max_iobuf, max_aobuf=None, ao_loc=None,
|
|
|
710
710
|
compress_diag=True):
|
|
711
711
|
if ao_loc is None: ao_loc = mol.ao_loc_nr()
|
|
712
712
|
max_iobuf = max(1, max_iobuf)
|
|
713
|
-
|
|
714
|
-
dims =
|
|
713
|
+
ao_loc_long = ao_loc.astype(numpy.int64)
|
|
714
|
+
dims = ao_loc_long[1:] - ao_loc_long[:-1]
|
|
715
715
|
dijs = (dims.reshape(-1,1) * dims)
|
|
716
716
|
nbas = dijs.shape[0]
|
|
717
717
|
|
|
@@ -773,7 +773,7 @@ def balance_partition(ao_loc, blksize, start_id=0, stop_id=None):
|
|
|
773
773
|
displs = [i+start_id for i in displs]
|
|
774
774
|
tasks = []
|
|
775
775
|
for i0, i1 in zip(displs[:-1],displs[1:]):
|
|
776
|
-
tasks.append((i0, i1, ao_loc[i1]-ao_loc[i0]))
|
|
776
|
+
tasks.append((i0, i1, int(ao_loc[i1]-ao_loc[i0])))
|
|
777
777
|
return tasks
|
|
778
778
|
|
|
779
779
|
del (MAX_MEMORY)
|
pyscf/ao2mo/r_outcore.py
CHANGED
|
@@ -302,9 +302,9 @@ def _count_naopair(mol, nao):
|
|
|
302
302
|
ao_loc = mol.ao_loc_2c()
|
|
303
303
|
nao_pair = 0
|
|
304
304
|
for i in range(mol.nbas):
|
|
305
|
-
di = ao_loc[i+1] - ao_loc[i]
|
|
305
|
+
di = int(ao_loc[i+1] - ao_loc[i])
|
|
306
306
|
for j in range(i+1):
|
|
307
|
-
dj = ao_loc[j+1] - ao_loc[j]
|
|
307
|
+
dj = int(ao_loc[j+1] - ao_loc[j])
|
|
308
308
|
nao_pair += di * dj
|
|
309
309
|
return nao_pair
|
|
310
310
|
|
pyscf/cc/ccsd.py
CHANGED
|
@@ -76,10 +76,16 @@ def kernel(mycc, eris=None, t1=None, t2=None, max_cycle=50, tol=1e-8,
|
|
|
76
76
|
normt = numpy.linalg.norm(tmpvec)
|
|
77
77
|
tmpvec = None
|
|
78
78
|
if mycc.iterative_damping < 1.0:
|
|
79
|
-
alpha = mycc.iterative_damping
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
alpha = numpy.asarray(mycc.iterative_damping)
|
|
80
|
+
if isinstance(t1, tuple): # e.g. UCCSD
|
|
81
|
+
t1new = tuple((1-alpha) * numpy.asarray(t1_part) + alpha * numpy.asarray(t1new_part)
|
|
82
|
+
for t1_part, t1new_part in zip(t1, t1new))
|
|
83
|
+
t2new = tuple((1-alpha) * numpy.asarray(t2_part) + alpha * numpy.asarray(t2new_part)
|
|
84
|
+
for t2_part, t2new_part in zip(t2, t2new))
|
|
85
|
+
else:
|
|
86
|
+
t1new = (1-alpha) * numpy.asarray(t1) + alpha * numpy.asarray(t1new)
|
|
87
|
+
t2new *= alpha
|
|
88
|
+
t2new += (1-alpha) * numpy.asarray(t2)
|
|
83
89
|
t1, t2 = t1new, t2new
|
|
84
90
|
t1new = t2new = None
|
|
85
91
|
t1, t2 = mycc.run_diis(t1, t2, istep, normt, eccsd-eold, adiis)
|
|
@@ -611,6 +617,8 @@ def _contract_s1vvvv_t2(mycc, mol, vvvv, t2, out=None, verbose=None):
|
|
|
611
617
|
# vvvv == None means AO-direct CCSD. It should redirect to
|
|
612
618
|
# _contract_s4vvvv_t2(mycc, mol, vvvv, t2, out, verbose)
|
|
613
619
|
assert (vvvv is not None)
|
|
620
|
+
if t2.size == 0:
|
|
621
|
+
return numpy.zeros_like(t2)
|
|
614
622
|
|
|
615
623
|
time0 = logger.process_clock(), logger.perf_counter()
|
|
616
624
|
log = logger.new_logger(mycc, verbose)
|
|
@@ -934,7 +942,7 @@ class CCSDBase(lib.StreamObject):
|
|
|
934
942
|
'async_io', 'incore_complete', 'cc2', 'callback',
|
|
935
943
|
'mol', 'verbose', 'stdout', 'frozen', 'level_shift',
|
|
936
944
|
'mo_coeff', 'mo_occ', 'cycles', 'converged_lambda', 'emp2', 'e_hf',
|
|
937
|
-
'e_corr', 't1', 't2', 'l1', 'l2', 'chkfile',
|
|
945
|
+
'converged', 'e_corr', 't1', 't2', 'l1', 'l2', 'chkfile',
|
|
938
946
|
}
|
|
939
947
|
|
|
940
948
|
def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None):
|
pyscf/cc/ccsd_rdm.py
CHANGED
|
@@ -377,8 +377,13 @@ def _make_rdm2(mycc, d1, d2, with_dm1=True, with_frozen=True, ao_repr=False):
|
|
|
377
377
|
|
|
378
378
|
|
|
379
379
|
def _rdm2_mo2ao(dm2, mo):
|
|
380
|
+
'''
|
|
381
|
+
Back transform the two-particle density matrices to AO representation, where
|
|
382
|
+
the dm2 is defined in accordance with the chemist's ERI notation:
|
|
383
|
+
E = einsum('pqrs,pqrs', eri, rdm2)
|
|
384
|
+
'''
|
|
380
385
|
mo_C = mo.conj()
|
|
381
|
-
return lib.einsum('ijkl,pi,qj,rk,sl->pqrs', dm2, mo, mo_C, mo
|
|
386
|
+
return lib.einsum('ijkl,pi,qj,rk,sl->pqrs', dm2, mo_C, mo, mo_C, mo)
|
|
382
387
|
|
|
383
388
|
|
|
384
389
|
if __name__ == '__main__':
|
pyscf/cc/gccsd.py
CHANGED
|
@@ -128,8 +128,8 @@ class GCCSD(ccsd.CCSDBase):
|
|
|
128
128
|
eijab = lib.direct_sum('ia,jb->ijab', eia, eia)
|
|
129
129
|
t1 = eris.fock[:nocc,nocc:] / eia
|
|
130
130
|
eris_oovv = np.array(eris.oovv)
|
|
131
|
-
t2 = eris_oovv / eijab
|
|
132
|
-
self.emp2 = 0.25*einsum('ijab,ijab', t2, eris_oovv
|
|
131
|
+
t2 = eris_oovv.conj() / eijab
|
|
132
|
+
self.emp2 = 0.25*einsum('ijab,ijab', t2, eris_oovv).real
|
|
133
133
|
logger.info(self, 'Init t2, MP2 energy = %.15g', self.emp2)
|
|
134
134
|
return self.emp2, t1, t2
|
|
135
135
|
|
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
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/df/addons.py
CHANGED
|
@@ -151,8 +151,8 @@ def aug_etb_for_dfbasis(mol, dfbasis=DFBASIS, beta=ETB_BETA,
|
|
|
151
151
|
if etb:
|
|
152
152
|
newbasis[symb] = gto.expand_etbs(etb)
|
|
153
153
|
for l, n, emin, beta in etb:
|
|
154
|
-
logger.info(mol, 'l = %d, exps = %s * %g^n
|
|
155
|
-
l, emin, beta, n-1)
|
|
154
|
+
logger.info(mol, 'ETB for %s: l = %d, exps = %s * %g^n , n = 0..%d',
|
|
155
|
+
symb, l, emin, beta, n-1)
|
|
156
156
|
else:
|
|
157
157
|
raise RuntimeError(f'Failed to generate even-tempered auxbasis for {symb}')
|
|
158
158
|
|
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
|
|
@@ -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/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/incore.py
CHANGED
|
@@ -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
|
@@ -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)
|