1#!/usr/bin/env python
2#
3# Author: Qiming Sun <osirpt.sun@gmail.com>
4#
5
6'''
7This example shows how to specify auxiliary basis for density fitting integrals.
8The format and input convention of auxbasis are the same to the AO basis.
9
10See also examples/gto/04-input_basis.py
11'''
12
13import tempfile
14from pyscf import gto, scf, df
15
16#
17# If auxbasis is not specified, default optimal auxiliary basis (if possible)
18# or even-tempered gaussian functions will be generated as auxbasis
19#
20mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis={'N1':'ccpvdz', 'N2':'tzp'})
21mf = scf.RHF(mol).density_fit()
22mf.kernel()
23print('Default auxbasis', mf.with_df.auxmol.basis)
24#
25# The default basis is generated in the function df.make_auxbasis.  It returns
26# a basis dict for the DF auxiliary basis. In the real calculations, you can
27# first generate the default basis then make modification.
28#
29auxbasis = df.make_auxbasis(mol)
30print(mf.with_df.auxmol.basis == auxbasis)
31auxbasis['N2'] = 'ccpvdz jkfit'
32mf = scf.RHF(mol).density_fit(auxbasis=auxbasis)
33mf.kernel()
34
35#
36# Input with key argument auxbasis='xxx' in .density_fit function
37# This auxbasis will be used for all elements in the system.
38#
39mol = gto.M(atom='N1 0 0 0; N2 0 0 1.2', basis='ccpvdz')
40mf = scf.RHF(mol).density_fit(auxbasis='weigend')
41mf.kernel()
42
43#
44# The DF basis can be assigned to with_df.auxbasis attribute.
45# Like the AO basis input, DF basis can be specified separately for each element.
46#
47mf = scf.RHF(mol).density_fit()
48mf.with_df.auxbasis = {'default': 'weigend', 'N2': 'ahlrichs'}
49mf.kernel()
50
51#
52# Combined basis set is also supported in DF basis input.
53#
54mf = scf.RHF(mol).density_fit()
55mf.with_df.auxbasis = ('weigend','sto3g')
56mf.kernel()
57
58#
59# Even-tempered Gaussian DF basis can be generated based on the AO basis.
60# In the following example, the exponents of auxbasis are
61#    alpha = a * 1.7^i   i = 0..N
62# where a and N are determined by the smallest and largest exponets of AO basis.
63#
64mf = scf.RHF(mol).density_fit()
65mf.with_df.auxbasis = df.aug_etb(mol, beta=1.7)
66mf.kernel()
67
68