Debian Codegraph @

doc/tutorialsexercises/energetics/rpa_tut/rpa_tut.rst

raw
1 .. _rpa_tut:
2
3 ====================================
4 Calculating RPA correlation energies
5 ====================================
6
7 The Random Phase Approximation (RPA) can be used to derive a non-local
8 expression for the ground state correlation energy. The calculation requires
9 a large number of unoccupied bands and is significantly heavier than
10 standard DFT calculation using semi-local exchange-correlation functionals.
11 However, when combined with exact exchange the method has been shown to give
12 a good description of van der Waals interactions and a decent description of
13 covalent bonds (slightly worse than PBE).
14
15 For more details on the theory and implementation we refer to :ref:`rpa`.
16 Below we give examples on how to calculate the RPA atomization energy of
17 `N_2` and the correlation energy of graphene an a Cu(111) surface. Note
18 that some of the calculations in this tutorial will need a lot of CPU time
19 and is essentially not possible without a supercomputer.
20
21
22 Example 1: Atomization energy of N2
23 ===================================
24
25 The atomization energy of `N_2` is overestimated by typical GGA functionals,
26 and the RPA functional seems to do a bit better. This is not a general trend
27 for small molecules, however, typically the HF-RPA approach yields too small
28 atomization energies when evaluated at the GGA equilibrium geometry. See for
29 example Furche [#Furche]_ for a table of atomization energies for small
30 molecules calculated with the RPA functional.
31
32
33 Ground state calculation
34 --------------------------
35
36 First we set up a ground state calculation with lots of unoccupied bands.
37 This is done with the script:
38
39 .. literalinclude:: gs_N2.py
40
41 which takes on the order of 3-4 CPU hours. The script generates N.gpw and
42 N2.gpw which are the input to the RPA calculation. The PBE and
43 non self-consistent Hartree-Fock energy is also calculated and written to the
44 file PBE_HF.dat. Be aware that using symmetries (i. e. not using ``symmetry='off'``
45 in the calculator) may cause problems if you want to calculate non self-consistent
46 HF energies for atoms and molecules.
47
48 Converging the frequency integration
49 -------------------------------------
50
51 We will start by making a single RPA calculation with extremely fine frequency sampling. The following script returns the integrand at 2000 frequency points from 0 to 1000 eV from a cutoff of 50 eV.
52
53 .. literalinclude:: frequency.py
54
55 The correlation energy is obtained as the integral of this function divided
56 by `2\pi` and yields -6.62 eV. The frequency sampling is dense enough
57 so that this value can be regarded as "exact" (but not converged with
58 respect to cutoff energy, of course). We can now test the Gauss-Legendre
59 integration method with different number of points using the same script but
60 now specifying the Gauss-Legendre parameters instead of a frequency list::
61
62 rpa = RPACorrelation(calc,
63 nfrequencies=16,
64 frequency_max=800.0,
65 frequency_scale=2.0)
66
67 This is the default parameters for Gauss-legendre integration. The
68 nfrequencies keyword specifies the number of points, the frequency_max
69 keyword sets the value of the highest frequency (but the integration is
70 always an approximation for the infinite integral) and the frequency_scale
71 keyword determines how dense the frequencies are sampled close to
72 `\omega=0`. The integrals for different number of Gauss-Legendre
73 points is shown below as well as the integrand evaluated at the fine
74 equidistant frequency grid.
75
76 .. image:: E_w.png
77 :height: 400 px
78
79 .. image:: con_freq.png
80 :height: 400 px
81
82 It is seen that using the default value of 16 frequency points gives a
83 result which is very well converged (to 0.1 meV). Below we will simply use
84 the default values although we could perhaps use 8 points instead of 16,
85 which would half the total CPU time for the calculations. In this particular
86 case the result is not very sensitive to the frequency scale, but if the
87 there is a non-vanishing density of states near the Fermi level, there may
88 be much more structure in the integrand near `\omega=0` and it is
89 important to sample this region well. It should of course be remembered that
90 these values are not converged with respect to the number of unoccupied
91 bands and plane waves.
92
93
94 Extrapolating to infinite number of bands
95 -----------------------------------------
96
97 To calculate the atomization energy we need to obtain the correlation energy
98 as a function of cutoff energy and extrapolate to infinity as explained in
99 :ref:`rpa` [#Harl]_. This is accomplished with the script:
100
101 .. literalinclude:: rpa_N2.py
102
103 which calculates the correlation part of the atomization energy with the
104 bands and plane waved corresponding to the list of cutoff energies. Note that
105 the default value of frequencies (16 Gauss-Legendre points) is used. The
106 script takes on the order of two CPU hours, but can be efficiently
107 parallelized over kpoints, spin and bands. If memory becomes and issue, it
108 may be an advantage to specify parallelize over **G**-vectors, which is
109 done by specifying ``nblocks=N``. The result is written to
110 rpa_N2.dat and can be visualized with the script:
111
112 .. literalinclude:: extrapolate.py
113 :end-before: assert
114
115 The figure is shown below
116
117 .. image:: extrapolate.png
118 :height: 400 px
119
120 Note that the extrapolate function can also be used to visualize the result
121 by setting plot=True. The power law scaling is seen to be very good at the
122 last three points and the extrapolated results is obtained using linear
123 regression on the last three points (reg=3). We find an extrapolated value
124 of -4.91 eV for the correlation part of the atomization energy. The results
125 are summarized below (all values in eV)
126
127 .. csv-table::
128 :file: N2-data.csv
129
130 It should be noted that in general, the accuracy of RPA is comparable to (or
131 worse) that of PBE calculations and N2 is just a special case where RPA
132 performs better than PBE. The major advantage of RPA is the non-locality,
133 which results in a good description of van der Waals forces. The true power
134 of RPA thus only comes into play for systems where dispersive interactions
135 dominate.
136
137
138 .. _c2cu rpa:
139
140 Example 2: Adsorption of graphene on metal surfaces
141 ===================================================
142
143 As an example where dispersive interactions are known to play a prominent
144 role, we consider the case of graphene adsorbed on a Cu(111) surface
145 [#Olsen]_ and [#Olsen0]_.
146
147 .. literalinclude:: c2cu.py
148
149 Note that besides diagonalizing the full Hamiltonian for each distance, the
150 script calculates the EXX energy at the self-consistent PBE orbitals and
151 writes the result to a file. It should also be noted that the k-point grid
152 is centered at the Gamma point, which makes the *q*-point reduction in the
153 RPA calculation much more efficient. In general, RPA and EXX is more
154 sensitive to Fermi smearing than semi-local functionals and we have set the
155 smearing to 0.01 eV. Due to the long range nature of the van der Waals
156 interactions, a lot of vacuum have been included above the slab. The
157 calculation should be parallelized over spin and irreducible *k*-points.
158
159 The RPA calculations are rather time consuming (~50 CPU hours per distance
160 point), but can be parallelized very efficiently over bands, k-points
161 (default) and frequencies (needs to be specified). Here we have changed the
162 frequency scale from the default value of 2.0 to 2.5 to increase the density
163 of frequency points near the origin. We also specify that the Gamma point
164 (in *q*) should not be included since the optical limit becomes unstable for
165 systems with high degeneracy near the Fermi level. The restart file contains
166 the contributions from different *q*-points, which is read if a calculation
167 needs to be restarted.
168
169 In principle, the calculations should be performed for a range of cutoff
170 energies and extrapolated to infinity as in the example above. However,
171 energy differences between systems with similar electronic structure
172 converges much faster than absolute correlation energies and a reasonably
173 converged potential energy surface can be obtained using a fixed cutoff of
174 200 eV for this system.
175
176 The result is shown in the figure below along with LDA, PBE and vdW-DF
177 results.
178
179 .. image:: c2cu.png
180 :height: 600 px
181
182 LDA predicts adsorption at 2 Å from the metal slab, but do
183 not include van der Waals attraction. The van der Waals functional shows a
184 significant amount of dispersive interactions far from the slab and predicts
185 a physisorbed minimum 3.75 Å from the slab. RPA captures both covalent and
186 dispersive interactions and the resulting potential energy surface is a
187 delicate balance between the two types of interactions.
188
189
190 .. [#Furche] F. Furche,
191 *Phys. Rev. B* **64**, 195120 (2001)
192
193 .. [#Harl] J. Harl and G. Kresse,
194 *Phys. Rev. B* **77**, 045136 (2008)
195
196 .. [#Olsen] T. Olsen, J. Yan, J. J. Mortensen and K. S. Thygesen,
197 *Phys. Rev. Lett* **107**, 156401 (2011)
198
199 .. [#Olsen0] T. Olsen and K. S. Thygesen,
200 *Phys. Rev. B* **87**, 075111 (2013)