1#!/usr/bin/env python
2
3from pyscf import gto
4from pyscf import dft
5
6'''
7Tune DFT grids
8
9By default, the DFT integration grids use
10* Bragg radius for atom
11* Treutler-Ahlrichs radial grids
12* Becke partition for grid weights
13* NWChem pruning scheme
14* mesh grids
15  ===================================
16  Elements  radial part  angular part
17  --------  -----------  ------------
18  H, He         50           302
19  Li - Ne       75           302
20  Na - Ar       80           434
21  K  - Kr       90           434
22  Rb - Xe       95           434
23  Cs - Rn      100           434
24  ===================================
25
26See pyscf/dft/gen_grid.py  "class Grids" for more details.
27'''
28
29mol = gto.M(
30    verbose = 0,
31    atom = '''
32    o    0    0.       0.
33    h    0    -0.757   0.587
34    h    0    0.757    0.587''',
35    basis = '6-31g')
36method = dft.RKS(mol)
37print('Default DFT(LDA).  E = %.12f' % method.kernel())
38
39# See pyscf/dft/radi.py for more radial grid schemes
40#grids.radi_method = dft.gauss_chebeshev
41#grids.radi_method = dft.delley
42method = dft.RKS(mol)
43method.grids.radi_method = dft.mura_knowles
44print('Changed radial grids for DFT.  E = %.12f' % method.kernel())
45
46
47# See pyscf/dft/gen_grid.py for detail of the grid weight scheme
48#method.grids.becke_scheme = dft.original_becke
49# Stratmann-Scuseria weight scheme
50method = dft.RKS(mol)
51method.grids.becke_scheme = dft.stratmann
52print('Changed grid partition funciton.  E = %.12f' % method.kernel())
53
54# Grids level 0 - 9.  Big number indicates dense grids. Default is 3
55method = dft.RKS(mol)
56method.grids.level = 4
57print('Dense grids.  E = %.12f' % method.kernel())
58
59# Specify mesh grid for certain atom
60method = dft.RKS(mol)
61method.grids.atom_grid = {'O': (100, 770)}
62print('Dense grids for O atom.  E = %.12f' % method.kernel())
63
64# Specify mesh grid for all atoms
65method = dft.RKS(mol)
66method.grids.atom_grid = (100, 770)
67print('Dense grids for all atoms.  E = %.12f' % method.kernel())
68
69
70# Disable pruning grids near core region
71#grids.prune = dft.sg1_prune
72method = dft.RKS(mol)
73method.grids.prune = None
74print('Changed grid partition funciton.  E = %.12f' % method.kernel())
75