1#!/usr/bin/env python 2 3''' 4In the pure DFT (LDA, GGA) calculations, Coulomb matrix of density fitting 5method by default is computed on the fly (without caching the 3-index integral 6tensor on disk). For small systems, this is slightly slower than precomputing 7the 3-index integral tensor. On-the-fly Coulomb builder can be disabled by 8explicitly constructing and caching the 3-index tensor. 9''' 10 11import time 12from pyscf import gto, dft 13 14mol = gto.Mole() 15mol.atom = ''' 16O 1.081302 1.129735 1.195158 17O -.967942 1.693585 .543683 18N 2.060859 1.075277 -1.315237 19C .249391 1.494424 .336070 20C .760991 1.733681 -1.081882 21H 2.396597 1.201189 -2.305828 22H 2.790965 1.427758 -.669398 23H 1.985133 .067145 -1.148141 24H .883860 2.805965 -1.234913 25H .041439 1.369111 -1.813528 26''' 27mol.basis = 'ccpvdz' 28mol.build() 29 30# 31# Default treatment for Coulomb matrix is IO free. 32# 33t0 = time.time() 34mf = dft.RKS(mol).density_fit() 35mf.kernel() 36print('CPU time', time.time() - t0) 37print(mf.with_df._cderi is None) 38 39# 40# Explicitly build and cache the 3-index tensor is slightly faster for small 41# systems. Since 3-index tensor is cached on disk, IO overhead may not be 42# ignored for large systems. Especially on multi-core machines, the IO free 43# treatment above can be more efficient. 44# 45t0 = time.time() 46mf = dft.RKS(mol).density_fit() 47mf.with_df.build() 48mf.kernel() 49print('CPU time', time.time() - t0) 50print(mf.with_df._cderi is None) # ._cderi will not be created 51