SIRIUS 7.5.0
Electronic structure library and applications
stress.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2019 Anton Kozhevnikov, Thomas Schulthess
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without modification, are permitted provided that
5// the following conditions are met:
6//
7// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
8// following disclaimer.
9// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
10// and the following disclaimer in the documentation and/or other materials provided with the distribution.
11//
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
13// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
15// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
16// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
18// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20/** \file stress.hpp
21 *
22 * \brief Contains definition of sirius::Stress tensor class.
23 */
24
25#ifndef __STRESS_HPP__
26#define __STRESS_HPP__
27
29
30namespace sirius {
31
32/// Stress tensor.
33/** The following referenceces were particularly useful in the derivation of the stress tensor components:
34 * - Hutter, D. M. A. J. (2012). Ab Initio Molecular Dynamics (pp. 1–580).
35 * - Marx, D., & Hutter, J. (2000). Ab initio molecular dynamics: Theory and implementation.
36 * Modern Methods and Algorithms of Quantum Chemistry.
37 * - Knuth, F., Carbogno, C., Atalla, V., & Blum, V. (2015). All-electron formalism for total energy strain
38 * derivatives and stress tensor components for numeric atom-centered orbitals. Computer Physics Communications.
39 * - Willand, A., Kvashnin, Y. O., Genovese, L., Vázquez-Mayagoitia, Á., Deb, A. K., Sadeghi, A., et al. (2013).
40 * Norm-conserving pseudopotentials with chemical accuracy compared to all-electron calculations.
41 * The Journal of Chemical Physics, 138(10), 104109. http://doi.org/10.1103/PhysRevB.50.4327
42 * - Corso, A. D., & Resta, R. (1994). Density-functional theory of macroscopic stress: Gradient-corrected
43 * calculations for crystalline Se. Physical Review B.
44 *
45 * Stress tensor describes a reaction of crystall to a strain:
46 * \f[
47 * \sigma_{\mu \nu} = \frac{1}{\Omega} \frac{\partial E}{\partial \varepsilon_{\mu \nu}}
48 * \f]
49 * where \f$ \varepsilon_{\mu \nu} \f$ is a symmetric strain tensor which describes the infinitesimal
50 * deformation of a crystal:
51 * \f[
52 * r_{\mu} \rightarrow \sum_{\nu} (\delta_{\mu \nu} + \varepsilon_{\mu \nu}) r_{\nu}
53 * \f]
54 * The following expressions are helpful:
55 * - strain derivative of a general position vector component:
56 * \f[
57 * \frac{\partial r_{\tau}}{\partial \varepsilon_{\mu \nu}} = \delta_{\tau \mu} r_{\nu}
58 * \f]
59 * - strain derivative of the lengths of a general position vector:
60 * \f[
61 * \frac{\partial |{\bf r}|}{\partial \varepsilon_{\mu \nu}} = \sum_{\tau} \frac{\partial |{\bf r}|}{\partial
62 * r_{\tau}} \frac{\partial r_{\tau}}{\partial \varepsilon_{\mu \nu}} = \sum_{\tau} \frac{ r_{\tau}}{|{\bf r}|}
63 * \delta_{\tau \mu} r_{\nu} = \frac{r_{\mu} r_{\nu}}{|{\bf r}|}
64 * \f]
65 * - strain derivative of the unit cell volume:
66 * \f[
67 * \frac{\partial \Omega}{\partial \varepsilon_{\mu \nu}} = \delta_{\mu \nu} \Omega
68 * \f]
69 * - strain derivative of the inverse square root of the unit cell volume:
70 * \f[
71 * \frac{\partial}{\partial \varepsilon_{\mu \nu}} \frac{1}{\sqrt{\Omega}} = -\frac{1}{2}\frac{1}{\sqrt{\Omega}}
72 * \delta_{\mu \nu}
73 * \f]
74 * - strain derivative of a reciprocal vector:
75 * \f[
76 * \frac{\partial G_{\tau}}{\partial \varepsilon_{\mu \nu}} = -\delta_{\tau \nu} G_{\mu}
77 * \f]
78 * - strain derivative of the length of a reciprocal vector:
79 * \f[
80 * \frac{\partial |{\bf G}|}{\partial \varepsilon_{\mu \nu}} = \sum_{\tau} \frac{\partial |{\bf G}|}{\partial
81 * G_{\tau}} \frac{\partial G_{\tau}}{\partial \varepsilon_{\mu \nu}} = -\frac{1}{|{\bf G}|}G_{\nu}G_{\mu}
82 * \f]
83 * In the derivation of the stress tensor contributions it is important to know which variables are
84 * invariant under lattice distortion. This are:
85 * - scalar product of the real-space (in the Bravais lattice frame) and reciprocal
86 * (in the reciprocal lattice frame) vectors
87 * - normalized plane-wave coefficients of the wave-functions
88 * \f[
89 * \psi({\bf G}) = \frac{1}{\sqrt{\Omega}} \int e^{-i {\bf G}{\bf r}} \psi({\bf r}) d{\bf r}
90 * \f]
91 * - unnormalized plane-wave coefficients of the charge density
92 * \f[
93 * \tilde \rho({\bf G}) = \int e^{-i {\bf G}{\bf r}} \sum_{j} |\psi_j({\bf r})|^{2} d{\bf r}
94 * \f]
95 */
96class Stress
97{
98 private:
100
101 Density const& density_;
102
103 Potential& potential_;
104
105 K_point_set& kset_;
106
107 r3::matrix<double> stress_kin_;
108
109 r3::matrix<double> stress_har_;
110
111 r3::matrix<double> stress_ewald_;
112
113 r3::matrix<double> stress_vloc_;
114
115 r3::matrix<double> stress_nonloc_;
116
117 r3::matrix<double> stress_us_;
118
119 r3::matrix<double> stress_xc_;
120
121 r3::matrix<double> stress_core_;
122
123 r3::matrix<double> stress_hubbard_;
124
125 r3::matrix<double> stress_total_;
126
127 /// Non-local contribution to stress.
128 /** Energy contribution from the non-local part of pseudopotential:
129 * \f[
130 * E^{nl} = \sum_{i{\bf k}} \sum_{\alpha}\sum_{\xi \xi'}P_{\xi}^{\alpha,i{\bf k}}
131 * D_{\xi\xi'}^{\alpha}P_{\xi'}^{\alpha,i{\bf k}*}
132 * \f]
133 * where
134 * \f[
135 * P_{\xi}^{\alpha,i{\bf k}} = \langle \psi_{i{\bf k}} | \beta_{\xi}^{\alpha} \rangle =
136 * \frac{1}{\Omega} \sum_{\bf G} \langle \psi_{i{\bf k}} | {\bf G+k} \rangle
137 * \langle {\bf G+k} | \beta_{\xi}^{\alpha} \rangle =
138 * \sum_{\bf G} \psi_i^{*}({\bf G+k}) \beta_{\xi}^{\alpha}({\bf G+k})
139 * \f]
140 * where
141 * \f[
142 * \beta_{\xi}^{\alpha}({\bf G+k}) = \frac{1}{\sqrt{\Omega}} \int e^{-i({\bf G+k}){\bf r}}
143 * \beta_{\xi}^{\alpha}({\bf r}) d{\bf r} = \frac{4\pi}{\sqrt{\Omega}} e^{-i{\bf (G+k) r_{\alpha}}}(-i)^{\ell}
144 * R_{\ell m}(\theta_{G+k}, \phi_{G+k}) \int \beta_{\ell}(r) j_{\ell}(|{\bf G+k}|r) r^2 dr
145 * \f]
146 * Contribution to stress tensor:
147 * \f[
148 * \sigma_{\mu \nu}^{nl} = \frac{1}{\Omega} \frac{\partial E^{nl}}{\partial \varepsilon_{\mu \nu}} =
149 * \frac{1}{\Omega} \sum_{i{\bf k}} \sum_{\xi \xi'}
150 * \Bigg( \frac{\partial P_{\xi}^{\alpha,i{\bf k}}}{\partial \varepsilon_{\mu \nu}}
151 * D_{\xi\xi'}^{\alpha}P_{\xi'}^{\alpha,i{\bf k}*} + P_{\xi}^{\alpha,i{\bf k}}
152 * D_{\xi\xi'}^{\alpha} \frac{\partial P_{\xi'}^{\alpha,i{\bf k}*}}{\partial \varepsilon_{\mu \nu}} \Bigg)
153 * \f]
154 * We need to compute strain derivatives of \f$ P_{\xi}^{\alpha,i{\bf k}} \f$:
155 * \f[
156 * \frac{\partial}{\partial
157 * \varepsilon_{\mu \nu}} P_{\xi}^{\alpha,i{\bf k}} = \sum_{\bf G} \psi_i^{*}({\bf G+k}) \frac{\partial}{\partial
158 * \varepsilon_{\mu \nu}} \beta_{\xi}^{\alpha}({\bf G+k})
159 * \f]
160 * First way to take strain derivative of beta-projectors (here and below \f$ {\bf G+k} = {\bf q} \f$):
161 * \f[
162 * \frac{\partial}{\partial \varepsilon_{\mu \nu}}
163 * \beta_{\xi}^{\alpha}({\bf q}) =
164 * -\frac{4\pi}{2\sqrt{\Omega}} \delta_{\mu \nu} e^{-i{\bf q r_{\alpha}}}(-i)^{\ell}
165 * R_{\ell m}(\theta_q, \phi_q) \int \beta_{\ell}(r) j_{\ell}(q r) r^2 dr + \\
166 * \frac{4\pi}{\sqrt{\Omega}} e^{-i{\bf q r_{\alpha}}}(-i)^{\ell}
167 * \frac{\partial R_{\ell m}(\theta_q, \phi_q)}{\partial \varepsilon_{\mu \nu}}
168 * \int \beta_{\ell}(r) j_{\ell}(q r) r^2 dr + \\
169 * \frac{4\pi}{\sqrt{\Omega}} e^{-i{\bf q r_{\alpha}}}(-i)^{\ell} R_{\ell m}(\theta_q, \phi_q)
170 * \int \beta_{\ell}(r) \frac{\partial j_{\ell}(q r)}{\partial \varepsilon_{\mu \nu}} r^2 dr = \\
171 * \frac{4\pi}{\sqrt{\Omega}} e^{-i{\bf q r_{\alpha}}}(-i)^{\ell}
172 * \Bigg[ \int \beta_{\ell}(r) j_{\ell}(q r) r^2 dr
173 * \Big(\frac{\partial R_{\ell m}(\theta_q, \phi_q)}{\partial \varepsilon_{\mu \nu}} -
174 * \frac{1}{2} R_{\ell m}(\theta_q, \phi_q) \delta_{\mu \nu}\Big) + R_{\ell m}(\theta_q, \phi_q)
175 * \int \beta_{\ell}(r) \frac{\partial j_{\ell}(q r)}{\partial \varepsilon_{\mu \nu}} r^2 dr \Bigg]
176 * \f]
177 *
178 * Strain derivative of the real spherical harmonics:
179 * \f[
180 * \frac{\partial R_{\ell m}(\theta, \phi)}{\partial \varepsilon_{\mu \nu}} =
181 * \sum_{\tau} \frac{\partial R_{\ell m}(\theta, \phi)}{\partial q_{\tau}} \frac{\partial q_{\tau}}{\partial
182 * \varepsilon_{\mu \nu}} = -q_{\mu} \frac{\partial R_{\ell m}(\theta, \phi)}{\partial q_{\nu}}
183 * \f]
184 * For the derivatives of spherical harmonics over Cartesian components of vector please refer to
185 * the sht::dRlm_dr function.
186 *
187 * Strain derivative of spherical Bessel function integral:
188 * \f[
189 * \int \beta_{\ell}(r) \frac{\partial j_{\ell}(qr) }{\partial \varepsilon_{\mu \nu}} r^2 dr =
190 * \int \beta_{\ell}(r) \frac{\partial j_{\ell}(qr) }{\partial q} \frac{-q_{\mu} q_{\nu}}{q} r^2 dr
191 * \f]
192 * The second way to compute strain derivative of beta-projectors is trough Gaunt coefficients:
193 * \f[
194 * \frac{\partial}{\partial \varepsilon_{\mu \nu}} \beta_{\xi}^{\alpha}({\bf q}) =
195 * -\frac{1}{2\sqrt{\Omega}} \delta_{\mu \nu} \int e^{-i{\bf q r}} \beta_{\xi}^{\alpha}({\bf r}) d{\bf r} +
196 * \frac{1}{\sqrt{\Omega}} \int i r_{\nu} q_{\mu} e^{-i{\bf q r}} \beta_{\xi}^{\alpha}({\bf r}) d{\bf r}
197 * \f]
198 * (second term comes from the strain derivative of \f$ e^{-i{\bf q r}} \f$). Remembering that \f$ {\bf r} \f$ is
199 * proportional to p-like real spherical harmonics, we can rewrite the second part of beta-projector derivative as:
200 * \f[
201 * \frac{1}{\sqrt{\Omega}} \int i r_{\nu} q_{\mu} e^{-i{\bf q r}} \beta_{\xi}^{\alpha}({\bf r}) d{\bf r} =
202 * \frac{1}{\sqrt{\Omega}} i q_{\mu} \int r \bar R_{1 \nu}(\theta, \phi) 4\pi \sum_{\ell_3 m_3} (-i)^{\ell_3}
203 * R_{\ell_3 m_3}(\theta_q, \phi_q) R_{\ell_3 m_3}(\theta, \phi) j_{\ell_3}(q r) \beta_{\ell_2}^{\alpha}(r)
204 * R_{\ell_2 m_2}(\theta, \phi) d{\bf r} = \\
205 * \frac{4 \pi}{\sqrt{\Omega}} i q_{\mu} \sum_{\ell_3 m_3} (-i)^{\ell_3} R_{\ell_3 m_3}(\theta_q, \phi_q)
206 * \langle \bar R_{1\nu} | R_{\ell_3 m_3} | R_{\ell_2 m_2} \rangle
207 * \int j_{\ell_3}(q r) \beta_{\ell_2}^{\alpha}(r) r^3 dr
208 * \f]
209 * where
210 * \f[
211 * \bar R_{1 x}(\theta, \phi) = -2 \sqrt{\frac{\pi}{3}} R_{11}(\theta, \phi) = \sin(\theta) \cos(\phi) \\
212 * \bar R_{1 y}(\theta, \phi) = -2 \sqrt{\frac{\pi}{3}} R_{1-1}(\theta,\phi) = \sin(\theta) \sin(\phi) \\
213 * \bar R_{1 z}(\theta, \phi) = 2 \sqrt{\frac{\pi}{3}} R_{10}(\theta, \phi) = \cos(\theta)
214 * \f]
215 *
216 * \tparam T One of float, double, complex<float> or complex<double> types for generic or Gamma point case.
217 */
218 template <typename T, typename F>
220
221 public:
222 Stress(Simulation_context& ctx__, Density& density__, Potential& potential__, K_point_set& kset__)
223 : ctx_(ctx__)
224 , density_(density__)
225 , potential_(potential__)
226 , kset_(kset__)
227 {
228 }
229
230 /// Local potential contribution to stress.
231 /** Energy contribution from the local part of pseudopotential:
232 * \f[
233 * E^{loc} = \int \rho({\bf r}) V^{loc}({\bf r}) d{\bf r} =
234 * \frac{1}{\Omega} \sum_{\bf G} \langle \rho | {\bf G} \rangle \langle {\bf G}| V^{loc} \rangle =
235 * \frac{1}{\Omega} \sum_{\bf G} \tilde \rho^{*}({\bf G}) \tilde
236 * V^{loc}({\bf G})
237 * \f]
238 * where
239 * \f[
240 * \tilde \rho({\bf G}) = \langle {\bf G} | \rho \rangle = \int e^{-i{\bf Gr}}\rho({\bf r}) d {\bf r}
241 * \f]
242 * and
243 * \f[
244 * \tilde V^{loc}({\bf G}) = \langle {\bf G} | V^{loc} \rangle =
245 * \int e^{-i{\bf Gr}}V^{loc}({\bf r}) d {\bf r}
246 * \f]
247 * Using the expression for \f$ \tilde V^{loc}({\bf G}) \f$, the local contribution to the total energy
248 * is rewritten as
249 * \f[
250 * E^{loc} = \frac{1}{\Omega} \sum_{\bf G} \tilde \rho^{*}({\bf G})
251 * \sum_{\alpha} e^{-{\bf G\tau}_{\alpha}} 4 \pi \int V_{\alpha}^{loc}(r)\frac{\sin(Gr)}{Gr} r^2 dr =
252 * \frac{4\pi}{\Omega}\sum_{\bf G}\tilde \rho^{*}({\bf G})\sum_{\alpha} e^{-{\bf G\tau}_{\alpha}}
253 * \Bigg( \int \Big(V_{\alpha}(r) r + Z_{\alpha}^p {\rm erf}(r) \Big)
254 * \frac{\sin(Gr)}{G} dr - Z_{\alpha}^p \frac{e^{-\frac{G^2}{4}}}{G^2} \Bigg)
255 * \f]
256 * (see \link sirius::Potential::generate_local_potential \endlink for details).
257 *
258 * Contribution to stress tensor:
259 * \f[
260 * \sigma_{\mu \nu}^{loc} = \frac{1}{\Omega} \frac{\partial E^{loc}}{\partial \varepsilon_{\mu \nu}} =
261 * \frac{1}{\Omega} \frac{-1}{\Omega} \delta_{\mu \nu} \sum_{\bf G}\tilde \rho^{*}({\bf G}) \tilde
262 * V^{loc}({\bf G}) + \frac{4\pi}{\Omega^2} \sum_{\bf G}\tilde \rho^{*}({\bf G}) \sum_{\alpha} e^{-{\bf
263 * G\tau}_{\alpha}} \Bigg( \int \Big(V_{\alpha}(r) r + Z_{\alpha}^p {\rm erf}(r) \Big)
264 * \Big( \frac{r \cos (G r)}{G}-\frac{\sin (G r)}{G^2} \Big) \Big( -\frac{G_{\mu}G_{\nu}}{G} \Big) dr -
265 * Z_{\alpha}^p \Big(-\frac{e^{-\frac{G^2}{4}}}{2 G}-\frac{2 e^{-\frac{G^2}{4}}}{G^3} \Big)
266 * \Big( -\frac{G_{\mu}G_{\nu}}{G} \Big) \Bigg) = \\
267 * -\delta_{\mu \nu} \sum_{\bf G}\rho^{*}({\bf G}) V^{loc}({\bf G}) + \sum_{\bf G} \rho^{*}({\bf G}) \Delta
268 * V^{loc}({\bf G}) G_{\mu}G_{\nu}
269 * \f]
270 * where \f$ \Delta V^{loc}({\bf G}) \f$ is built from the following radial integrals:
271 * \f[
272 * \int \Big(V_{\alpha}(r) r + Z_{\alpha}^p {\rm erf}(r) \Big)
273 * \Big( \frac{\sin (G r)}{G^3} - \frac{r\cos (G r)}{G^2}\Big) dr -
274 * Z_{\alpha}^p \Big( \frac{e^{-\frac{G^2}{4}}}{2 G^2} + \frac{2 e^{-\frac{G^2}{4}}}{G^4}\Big)
275 * \f]
276 */
278
279 inline r3::matrix<double> stress_vloc() const
280 {
281 return stress_vloc_;
282 }
283
284 /// Hartree energy contribution to stress.
285 /** Hartree energy:
286 * \f[
287 * E^{H} = \frac{1}{2} \int_{\Omega} \rho({\bf r}) V^{H}({\bf r}) d{\bf r} =
288 * \frac{1}{2} \frac{1}{\Omega} \sum_{\bf G} \langle \rho | {\bf G} \rangle \langle {\bf G}| V^{H} \rangle =
289 * \frac{2 \pi}{\Omega} \sum_{\bf G} \frac{|\tilde \rho({\bf G})|^2}{G^2}
290 * \f]
291 * where
292 * \f[
293 * \langle {\bf G} | \rho \rangle = \int e^{-i{\bf Gr}}\rho({\bf r}) d {\bf r} = \tilde \rho({\bf G})
294 * \f]
295 * and
296 * \f[
297 * \langle {\bf G} | V^{H} \rangle = \int e^{-i{\bf Gr}}V^{H}({\bf r}) d {\bf r} = \frac{4\pi}{G^2} \tilde
298 * \rho({\bf G}) \f]
299 *
300 * Hartree energy contribution to stress tensor:
301 * \f[
302 * \sigma_{\mu \nu}^{H} = \frac{1}{\Omega} \frac{\partial E^{H}}{\partial \varepsilon_{\mu \nu}} =
303 * \frac{1}{\Omega} 2\pi \Big( \big( \frac{\partial}{\partial \varepsilon_{\mu \nu}} \frac{1}{\Omega} \big)
304 * \sum_{{\bf G}} \frac{|\tilde \rho({\bf G})|^2}{G^2} +
305 * \frac{1}{\Omega} \sum_{{\bf G}} |\tilde \rho({\bf G})|^2 \frac{\partial}{\partial \varepsilon_{\mu \nu}}
306 * \frac{1}{G^2} \Big) = \\ \frac{1}{\Omega} 2\pi \Big( -\frac{1}{\Omega} \delta_{\mu \nu} \sum_{{\bf G}}
307 * \frac{|\tilde \rho({\bf G})|^2}{G^2} +
308 * \frac{1}{\Omega} \sum_{\bf G} |\tilde \rho({\bf G})|^2 \sum_{\tau} \frac{-2 G_{\tau}}{G^4} \frac{\partial
309 * G_{\tau}}{\partial \varepsilon_{\mu \nu}} \Big) = \\ 2\pi \sum_{\bf G} \frac{|\rho({\bf G})|^2}{G^2} \Big(
310 * -\delta_{\mu \nu} + \frac{2}{G^2} G_{\nu} G_{\mu} \Big)
311 * \f]
312 */
314
315 inline r3::matrix<double> stress_har() const
316 {
317 return stress_har_;
318 }
319
320 /// Ewald energy contribution to stress.
321 /** Ewald energy:
322 * \f[
323 * E^{ion-ion} = \frac{1}{2} \sideset{}{'} \sum_{\alpha \beta {\bf T}} Z_{\alpha} Z_{\beta}
324 * \frac{{\rm erfc}(\sqrt{\lambda} |{\bf r}_{\alpha} - {\bf r}_{\beta} + {\bf T}|)}{|{\bf r}_{\alpha} - {\bf
325 * r}_{\beta} + {\bf T}|} + \frac{2 \pi}{\Omega} \sum_{{\bf G}} \frac{e^{-\frac{G^2}{4 \lambda}}}{G^2} \Big|
326 * \sum_{\alpha} Z_{\alpha} e^{-i{\bf r}_{\alpha}{\bf G}} \Big|^2 - \sum_{\alpha} Z_{\alpha}^2
327 * \sqrt{\frac{\lambda}{\pi}} - \frac{2\pi}{\Omega}\frac{N_{el}^2}{4 \lambda}
328 * \f]
329 * (check \link sirius::DFT_ground_state::ewald_energy \endlink for details).\n
330 * Contribution to stress tensor:
331 * \f[ \sigma_{\mu \nu}^{ion-ion} = \frac{1}{\Omega} \frac{\partial
332 * E^{ion-ion}}{\partial \varepsilon_{\mu \nu}}
333 * \f]
334 * Derivative of the first part:
335 * \f[
336 * \frac{1}{\Omega}\frac{\partial}{\partial \varepsilon_{\mu \nu}} \frac{1}{2} \sideset{}{'}
337 * \sum_{\alpha \beta {\bf T}} Z_{\alpha} Z_{\beta} \frac{{\rm erfc}(\sqrt{\lambda} |{\bf r}_{\alpha} - {\bf
338 * r}_{\beta} + {\bf T}|)}{|{\bf r}_{\alpha} - {\bf r}_{\beta} + {\bf T}|} = \frac{1}{2\Omega} \sideset{}{'}
339 * \sum_{\alpha \beta {\bf T}} Z_{\alpha} Z_{\beta} \Big( -2e^{-\lambda |{\bf r'}|^2} \sqrt{\frac{\lambda}{\pi}}
340 * \frac{1}{|{\bf r'}|^2} - {\rm erfc}(\sqrt{\lambda} |{\bf r'}|) \frac{1}{|{\bf r'}|^3} \Big) r'_{\mu} r'_{\nu}
341 * \f]
342 * where \f$ {\bf r'} = {\bf r}_{\alpha} - {\bf r}_{\beta} + {\bf T} \f$.
343 *
344 * Derivative of the second part:
345 * \f[
346 * \frac{1}{\Omega}\frac{\partial}{\partial \varepsilon_{\mu \nu}} \frac{2\pi}{\Omega} \sum_{{\bf G}}
347 * \frac{e^{-\frac{G^2}{4 \lambda}}}{G^2} \Big| \sum_{\alpha} Z_{\alpha} e^{-i{\bf r}_{\alpha}{\bf G}} \Big|^2 =
348 * -\frac{2\pi}{\Omega^2} \delta_{\mu \nu} \sum_{{\bf G}} \frac{e^{-\frac{G^2}{4 \lambda}}}{G^2} \Big|
349 * \sum_{\alpha} Z_{\alpha} e^{-i{\bf r}_{\alpha}{\bf G}} \Big|^2 +
350 * \frac{2\pi}{\Omega^2} \sum_{\bf G} G_{\mu} G_{\nu} \frac{e^{-\frac{G^2}{4 \lambda}}}{G^2} 2
351 * \frac{\frac{G^2}{4\lambda} + 1}{G^2} \Big| \sum_{\alpha} Z_{\alpha} e^{-i{\bf r}_{\alpha}{\bf G}} \Big|^2
352 * \f]
353 *
354 * Derivative of the fourth part:
355 * \f[
356 * -\frac{1}{\Omega}\frac{\partial}{\partial \varepsilon_{\mu \nu}} \frac{2\pi}{\Omega}\frac{N_{el}^2}{4 \lambda}
357 * = \frac{2\pi}{\Omega^2}\frac{N_{el}^2}{4 \lambda} \delta_{\mu \nu}
358 * \f]
359 */
361
362 inline r3::matrix<double> stress_ewald() const
363 {
364 return stress_ewald_;
365 }
366
367 /// Kinetic energy contribution to stress.
368 /** Kinetic energy:
369 * \f[
370 * E^{kin} = \sum_{{\bf k}} w_{\bf k} \sum_j f_j \frac{1}{2} |{\bf G+k}|^2 |\psi_j({\bf G + k})|^2
371 * \f]
372 * Contribution to the stress tensor
373 * \f[
374 * \sigma_{\mu \nu}^{kin} = \frac{1}{\Omega} \frac{\partial E^{kin}}{\partial \varepsilon_{\mu \nu}} =
375 * \frac{1}{\Omega} \sum_{{\bf k}} w_{\bf k} \sum_j f_j \frac{1}{2} 2 |{\bf G+k}| \Big( -\frac{1}{|{\bf G+k}|}
376 * (G+k)_{\mu} (G+k)_{\nu} \Big) |\psi_j({\bf G + k})|^2 =\\
377 * -\frac{1}{\Omega} \sum_{{\bf k}} w_{\bf k} (G+k)_{\mu} (G+k)_{\nu} \sum_j f_j |\psi_j({\bf G + k})|^2
378 * \f]
379 */
380 template <typename T>
381 void calc_stress_kin_aux();
382
383 r3::matrix<double> calc_stress_kin();
384
385 inline r3::matrix<double> stress_kin() const
386 {
387 return stress_kin_;
388 }
389
390 r3::matrix<double> calc_stress_nonloc();
391
392 inline r3::matrix<double> stress_nonloc() const
393 {
394 return stress_nonloc_;
395 }
396
397 /// Contribution to the stress tensor from the augmentation operator.
398 /** Total energy in ultrasoft pseudopotential contains this term:
399 * \f[
400 * \int V^{eff}({\bf r})\rho^{aug}({\bf r})d{\bf r} =
401 * \sum_{\alpha} \sum_{\xi \xi'} n_{\xi \xi'}^{\alpha} \int V^{eff}({\bf r}) Q_{\xi \xi'}^{\alpha}({\bf r})
402 * d{\bf r}
403 * \f]
404 * The derivatives of beta-projectors (hidden in the desnity matrix expression) are taken into account
405 * in \link sirius::Stress::calc_stress_nonloc \endlink. Here we need to compute the remaining contribution
406 * from the
407 * \f$ Q_{\xi \xi'}({\bf r}) \f$ itself. We are interested in the integral:
408 * \f[
409 * \int V^{eff}({\bf r}) Q_{\xi \xi'}^{\alpha}({\bf r}) d{\bf r} =
410 * \sum_{\bf G} V^{eff}({\bf G}) \tilde Q_{\xi \xi'}^{\alpha}({\bf G})
411 * \f]
412 * where
413 * \f[
414 * \tilde Q_{\xi \xi'}^{\alpha}({\bf G}) = \int e^{-i{\bf Gr}} Q_{\xi \xi'}^{\alpha}({\bf r}) d{\bf r} =
415 * 4\pi \sum_{\ell m} (-i)^{\ell} R_{\ell m}(\hat{\bf G}) \langle R_{\ell_{\xi} m_{\xi}} | R_{\ell m} |
416 * R_{\ell_{\xi'} m_{\xi'}} \rangle \int Q_{\ell_{\xi} \ell_{\xi'}}^{\ell}(r) j_{\ell}(Gr) r^2 dr
417 * \f]
418 * Strain derivative of \f$ \tilde Q_{\xi \xi'}^{\alpha}({\bf G}) \f$ is:
419 * \f[
420 * \frac{\partial}{\partial \varepsilon_{\mu \nu}} \tilde Q_{\xi \xi'}^{\alpha}({\bf G}) =
421 * 4\pi \sum_{\ell m} (-i)^{\ell} \langle R_{\ell_{\xi} m_{\xi}} |
422 * R_{\ell m} | R_{\ell_{\xi'} m_{\xi'}} \rangle
423 * \Big( \frac{\partial R_{\ell m}(\hat{\bf G})}{\partial \varepsilon_{\mu \nu}}
424 * \int Q_{\ell_{\xi} \ell_{\xi'}}^{\ell}(r) j_{\ell}(Gr) r^2 dr + R_{\ell m}(\hat{\bf G})
425 * \int Q_{\ell_{\xi} \ell_{\xi'}}^{\ell}(r)
426 * \frac{\partial j_{\ell}(Gr)}{\partial \varepsilon_{\mu \nu}} r^2 dr \Big)
427 * \f]
428 * For strain derivatives of spherical harmonics and Bessel functions see
429 * \link sirius::Stress::calc_stress_nonloc \endlink. We can pull the common multiplier \f$ -G_{\mu} / G \f$
430 * from both terms and arrive to the following expression:
431 * \f[
432 * \frac{\partial}{\partial \varepsilon_{\mu \nu}} \tilde Q_{\xi \xi'}^{\alpha}({\bf G}) =
433 * -\frac{G_{\mu}}{G} 4\pi \sum_{\ell m} (-i)^{\ell} \langle R_{\ell_{\xi} m_{\xi}} | R_{\ell m} |
434 * R_{\ell_{\xi'} m_{\xi'}} \rangle \Big( \big(\nabla_{G} R_{\ell m}(\hat{\bf G})\big)_{\nu} \int Q_{\ell_{\xi}
435 * \ell_{\xi'}}^{\ell}(r) j_{\ell}(Gr) r^2 dr + R_{\ell m}(\hat{\bf G}) \int Q_{\ell_{\xi} \ell_{\xi'}}^{\ell}(r)
436 * \frac{\partial j_{\ell}(Gr)}{\partial G} G_{\nu} r^2 dr \Big)
437 * \f]
438 */
440
441 inline auto stress_us() const
442 {
443 return stress_us_;
444 }
445
446 inline auto stress_us_nl() const
447 {
448 return stress_nonloc_ + stress_us_;
449 }
450
451 /// XC contribution to stress.
452 /** XC contribution has the following expression:
453 * \f[
454 * \frac{\partial E_{xc}}{\partial \varepsilon_{\mu \nu}} = \delta_{\mu \nu} \int \Big( \epsilon_{xc}({\bf r}) -
455 * v_{xc}({\bf r}) \Big) \rho({\bf r})d{\bf r} - \int \frac{\partial \epsilon_{xc} \big( \rho({\bf r}), \nabla
456 * \rho({\bf r})\big) }{\nabla_{\mu} \rho({\bf r})} \nabla_{\nu}\rho({\bf r}) d{\bf r}
457 * \f]
458 */
460
461 inline auto stress_xc() const
462 {
463 return stress_xc_;
464 }
465
466 /// Non-linear core correction to stress tensor.
468
469 inline auto stress_core() const
470 {
471 return stress_core_;
472 }
473
474 r3::matrix<double> calc_stress_hubbard();
475
476 inline auto stress_hubbard() const
477 {
478 return stress_hubbard_;
479 }
480
481 r3::matrix<double> calc_stress_total();
482
483 inline auto stress_total() const
484 {
485 return stress_total_;
486 }
487
488 void print_info(std::ostream& out__, int verbosity__) const;
489};
490
491} // namespace sirius
492
493#endif
Generate charge density and magnetization from occupied spinor wave-functions.
Definition: density.hpp:214
Set of k-points.
Definition: k_point_set.hpp:41
Generate effective potential from charge density and magnetization.
Definition: potential.hpp:46
Simulation context is a set of parameters and objects describing a single simulation.
Stress tensor.
Definition: stress.hpp:97
r3::matrix< double > calc_stress_xc()
XC contribution to stress.
Definition: stress.cpp:284
r3::matrix< double > calc_stress_ewald()
Ewald energy contribution to stress.
Definition: stress.cpp:490
r3::matrix< double > calc_stress_us()
Contribution to the stress tensor from the augmentation operator.
Definition: stress.cpp:371
r3::matrix< double > calc_stress_vloc()
Local potential contribution to stress.
Definition: stress.cpp:706
r3::matrix< double > calc_stress_har()
Hartree energy contribution to stress.
Definition: stress.cpp:613
void calc_stress_kin_aux()
Kinetic energy contribution to stress.
Definition: stress.cpp:649
void calc_stress_nonloc_aux()
Non-local contribution to stress.
Definition: stress.cpp:37
r3::matrix< double > calc_stress_core()
Non-linear core correction to stress tensor.
Definition: stress.cpp:217
Namespace of the SIRIUS library.
Definition: sirius.f90:5
Contains declaration and partial implementation of sirius::Potential class.