SIRIUS 7.5.0
Electronic structure library and applications
dft_ground_state.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2018 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 dft_ground_state.hpp
21 *
22 * \brief Contains definition and partial implementation of sirius::DFT_ground_state class.
23 */
24
25#ifndef __DFT_GROUND_STATE_HPP__
26#define __DFT_GROUND_STATE_HPP__
27
29#include "core/json.hpp"
30#include "hubbard/hubbard.hpp"
31#include "geometry/stress.hpp"
32#include "geometry/force.hpp"
33#include "energy.hpp"
34
35using json = nlohmann::json;
36
37namespace sirius {
38
39/// The whole DFT ground state implementation.
40/** The DFT cycle consists of four basic steps: solution of the Kohn-Sham equations, summation of the occupied states
41 * in order to get a system's charge density and magnetization, mixing and finally gneneration of the effective
42 * potential and effective magnetic field. \image html dft_cycle.png "DFT self-consistency cycle"
43 */
45{
46 private:
47 /// Context of simulation.
49
50 /// Set of k-points that are used to generate density.
52
53 /// Alias of the unit cell.
55
56 /// Instance of the Potential class.
58
59 /// Instance of the Density class.
61
62 /// Lattice stress.
64
65 /// Atomic forces.
67
68 /// k-point independent part of the Hamiltonian.
69 std::shared_ptr<Hamiltonian0<double>> H0_; // hard-code double for now
70
71 /// Store Ewald energy which is computed once and which doesn't change during the run.
72 double ewald_energy_{0};
73
74 /// Correction to total energy from the SCF density minimisation.
76
77 public:
78 /// Constructor.
80 : ctx_(kset__.ctx())
81 , kset_(kset__)
82 , unit_cell_(ctx_.unit_cell())
84 , density_(ctx_)
85 , stress_(ctx_, density_, potential_, kset__)
86 , forces_(ctx_, density_, potential_, kset__)
87
88 {
89 if (!ctx_.full_potential()) {
91 }
92 }
94 {
95 int n = ctx_.num_loc_op_applied();
96 kset_.comm().allreduce(&n, 1);
97 if (ctx_.verbosity() >= 2) {
98 RTE_OUT(ctx_.out()) << "local op. applied: " << n << std::endl;
99 }
100 double d = ctx_.evp_work_count();
101 kset_.comm().allreduce(&d, 1);
102 if (ctx_.verbosity() >= 2) {
103 RTE_OUT(ctx_.out()) << "evp. work count: " << d << std::endl;
104 }
105 n = ctx_.num_itsol_steps();
106 kset_.comm().allreduce(&n, 1);
107 if (ctx_.verbosity() >= 2) {
108 RTE_OUT(ctx_.out()) << "numbef of iterative solver steps: " << n << std::endl;
109 }
110 }
111
112 /// Return reference to a simulation context.
113 inline Simulation_context const& ctx() const
114 {
115 return ctx_;
116 }
117
118 inline Hamiltonian0<double>& get_H0() const
119 {
120 return *H0_;
121 }
122
123 inline Density& density()
124 {
125 return density_;
126 }
127
128 inline Potential& potential()
129 {
130 return potential_;
131 }
132
133 inline K_point_set& k_point_set()
134 {
135 return kset_;
136 }
137
138 inline Force& forces()
139 {
140 return forces_;
141 }
142
143 inline Stress& stress()
144 {
145 return stress_;
146 }
147
148 inline double ewald_energy() const
149 {
150 return ewald_energy_;
151 }
152
153 inline double scf_correction_energy() const
154 {
156 }
157
158 void create_H0();
159
160 double total_energy() const;
161
162 /// Generate initial density, potential and a subspace of wave-functions.
163 void initial_state();
164
165 /// Update the parameters after the change of lattice vectors or atomic positions.
166 void update();
167
168 /// Run the SCF ground state calculation and find a total energy minimum.
169 json find(double density_tol, double energy_tol, double initial_tolerance, int num_dft_iter, bool write_state);
170
171 /// Print the basic information (total energy, charges, moments, etc.).
172 void print_info(std::ostream& out__) const;
173
174 double energy_kin_sum_pw() const;
175
176 json serialize();
177
178 /// A quick check of self-constent density in case of pseudopotential.
180};
181
182} // namespace sirius
183
184#endif // __DFT_GROUND_STATE_HPP__
185
186/** \page dft Spin-polarized DFT
187 * \section s1dft Preliminary notes
188 *
189 * \note Here and below sybol \f$ {\boldsymbol \sigma} \f$ is reserved for the vector of Pauli matrices. Spin
190 * components are labeled with \f$ \alpha \f$ or \f$ \beta \f$.
191 *
192 * Wave-function of spin-1/2 particle is a two-component spinor:
193 * \f[
194 * {\bf \Psi}({\bf r}) = \left( \begin{array}{c} \psi^{\uparrow}({\bf r}) \\
195 * \psi^{\downarrow}({\bf r})
196 * \end{array}
197 * \right)
198 * \f]
199 * Operator of spin:
200 * \f[
201 * {\bf \hat S}=\frac{\hbar}{2}{\boldsymbol \sigma},
202 * \f]
203 * Pauli matrices:
204 * \f[
205 * \sigma_x=\left( \begin{array}{cc}
206 * 0 & 1 \\
207 * 1 & 0 \\ \end{array} \right) \,
208 * \sigma_y=\left( \begin{array}{cc}
209 * 0 & -i \\
210 * i & 0 \\ \end{array} \right) \,
211 * \sigma_z=\left( \begin{array}{cc}
212 * 1 & 0 \\
213 * 0 & -1 \\ \end{array} \right)
214 * \f]
215 *
216 * Spin moment of an electron in quantum state \f$ | \Psi \rangle \f$:
217 * \f[
218 * {\bf S}=\langle \Psi | {\bf \hat S} | \Psi \rangle = \frac{\hbar}{2} \langle \Psi | {\boldsymbol \sigma} | \Psi
219 * \rangle
220 * \f]
221 *
222 * Spin magnetic moment of electron:
223 * \f[
224 * {\bf \mu}_e=\gamma_e {\bf S},
225 * \f]
226 * where \f$ \gamma_e \f$ is the gyromagnetic ratio for the electron.
227 * \f[
228 * \gamma_e=-\frac{g_e \mu_B}{\hbar} \;\;\; \mu_B=\frac{e\hbar}{2m_ec}
229 * \f]
230 * Here \f$ g_e \f$ is a g-factor for electron which is ~2, and \f$ \mu_B \f$ - Bohr magneton (defined as positive
231 * constant). Finally, magnetic moment of electron: \f[
232 * {\bf \mu}_e=-{\bf \mu}_B \langle \Psi | {\boldsymbol \sigma} | \Psi \rangle
233 * \f]
234 * Potential energy of magnetic dipole in magnetic field:
235 * \f[
236 * U=-{\bf B}{\bf \mu}={\bf \mu}_B {\bf B} \langle \Psi | {\boldsymbol \sigma} | \Psi \rangle
237 * \f]
238 *
239 * \section s2dft Density and magnetization
240 * In magnetic calculations we have charge density \f$ \rho({\bf r}) \f$ (scalar function) and magnetization density
241 * \f$ {\bf m}({\bf r}) \f$ (vector function). Density is defined as:
242 * \f[
243 * \rho({\bf r}) = \sum_{j}^{occ} \Psi_{j}^{*}({\bf r}){\bf I} \Psi_{j}({\bf r}) =
244 * \sum_{j}^{occ} \psi_{j}^{\uparrow *}({\bf r}) \psi_{j}^{\uparrow}({\bf r}) +
245 * \psi_{j}^{\downarrow *}({\bf r}) \psi_{j}^{\downarrow}({\bf r})
246 * \f]
247 * Magnetization is defined as:
248 * \f[
249 * {\bf m}({\bf r}) = \sum_{j}^{occ} \Psi_{j}^{*}({\bf r}) {\boldsymbol \sigma} \Psi_{j}({\bf r})
250 * \f]
251 * \f[
252 * m_x({\bf r}) = \sum_{j}^{occ} \psi_{j}^{\uparrow *}({\bf r}) \psi_{j}^{\downarrow}({\bf r}) +
253 * \psi_{j}^{\downarrow *}({\bf r}) \psi_{j}^{\uparrow}({\bf r})
254 * \f]
255 * \f[
256 * m_y({\bf r}) = \sum_{j}^{occ} -i \psi_{j}^{\uparrow *}({\bf r}) \psi_{j}^{\downarrow}({\bf r}) +
257 * i \psi_{j}^{\downarrow *}({\bf r}) \psi_{j}^{\uparrow}({\bf r})
258 * \f]
259 * \f[
260 * m_z({\bf r}) = \sum_{j}^{occ} \psi_{j}^{\uparrow *}({\bf r}) \psi_{j}^{\uparrow}({\bf r}) -
261 * \psi_{j}^{\downarrow *}({\bf r}) \psi_{j}^{\downarrow}({\bf r})
262 * \f]
263 * Density and magnetization can be grouped into a \f$ 2 \times 2 \f$ density matrix, which is defined as:
264 * \f[
265 * {\boldsymbol \rho}({\bf r}) = \frac{1}{2} \Big( {\bf I}\rho({\bf r}) + {\boldsymbol \sigma} {\bf m}({\bf
266 * r})\Big) =
267 * \frac{1}{2} \left( \begin{array}{cc} \rho({\bf r}) + m_z({\bf r}) & m_x({\bf r}) - i m_y({\bf r}) \\
268 * m_x({\bf r}) + i m_y({\bf r}) & \rho({\bf r}) - m_z({\bf r}) \end{array}
269 * \right) = \sum_{j}^{occ} \left( \begin{array}{cc} \psi_{j}^{\uparrow *}({\bf r}) \psi_{j}^{\uparrow}({\bf r}) &
270 * \psi_{j}^{\downarrow *}({\bf r}) \psi_{j}^{\uparrow}({\bf r}) \\
271 * \psi_{j}^{\uparrow *}({\bf r}) \psi_{j}^{\downarrow}({\bf r}) &
272 * \psi_{j}^{\downarrow *}({\bf r}) \psi_{j}^{\downarrow}({\bf r})
273 * \end{array} \right) \f] or simply \f[ \rho_{\alpha \beta}({\bf r}) = \sum_{j}^{occ} \psi_{j}^{\beta *}({\bf
274 * r})\psi_{j}^{\alpha}({\bf r}) \f] Pay attention to the order of spin indices in the \f$ 2 \times 2 \f$ density
275 * matrix. External potential \f$ v^{ext}({\bf r}) \f$ and external magnetic field \f$ {\bf B}^{ext}({\bf r}) \f$ can
276 * also be grouped into a \f$ 2 \times 2 \f$ matrix:
277 * \f[
278 * V_{\alpha\beta}^{ext}({\bf r})=\Big({\bf I}v^{ext}({\bf r})+\mu_{B}{\boldsymbol \sigma}{\bf B}^{ext}({\bf r})
279 * \Big) =
280 * \left( \begin{array}{cc} v^{ext}({\bf r})+\mu_{B}B_z^{ext}({\bf r}) & \mu_{B} \Big( B_x^{ext}({\bf
281 * r})-iB_y^{exp}({\bf r}) \Big) \\ \mu_{B} \Big( B_x^{ext}({\bf r})+iB_y^{ext}({\bf r}) \Big) & v^{ext}({\bf
282 * r})-\mu_{B}B_z^{ext}({\bf r}) \end{array} \right) \f] Let's check that potential energy in external fields can be
283 * written in the following way: \f[ E^{ext}=\int Tr \Big( {\boldsymbol \rho}({\bf r}) {\bf V}^{ext}({\bf r}) \Big)
284 * d{\bf r} = \sum_{\alpha\beta} \int \rho_{\alpha\beta}({\bf r})V_{\beta\alpha}^{ext}({\bf r}) d{\bf r} \f] (below \f$
285 * {\bf r} \f$, \f$ ext \f$ and \f$ \int d{\bf r} \f$ are dropped for simplicity) \f[ \begin{eqnarray}
286 * \rho_{11}V_{11} &= \frac{1}{2}(\rho+m_z)(v+\mu_{B}B_z) = \frac{1}{2}(\rho v +\mu_{B} \rho B_z + m_z v +
287 * \mu_{B}m_zB_z) \\
288 * \rho_{22}V_{22} &= \frac{1}{2}(\rho-m_z)(v-\mu_{B}B_z) = \frac{1}{2}(\rho v -\mu_{B} \rho B_z - m_z v +
289 * \mu_{B}m_zB_z) \\
290 * \rho_{12}V_{21} &= \frac{1}{2}(m_x-im_y)\Big( \mu_{B}( B_x+iB_y) \Big) =
291 * \frac{\mu_B}{2}(m_xB_x+im_xB_y-im_yB_x+m_yB_y) \\ \rho_{21}V_{12} &= \frac{1}{2}(m_x+im_y)\Big( \mu_{B}( B_x-iB_y)
292 * \Big) = \frac{\mu_B}{2}(m_xB_x-im_xB_y+im_yB_x+m_yB_y) \end{eqnarray} \f] The sum of this four terms will give
293 * exactly \f$ \int \rho({\bf r}) v^{ext}({\bf r}) + \mu_{B}{\bf m}({\bf r})
294 * {\bf B}^{ext}({\bf r}) d{\bf r}\f$
295 *
296 * \section s3dft Total energy variation
297 *
298 * To derive Kohn-Sham equations we need to write total energy functional of density matrix \f$ \rho_{\alpha\beta}({\bf
299 * r}) \f$: \f[ E^{tot}[\rho_{\alpha\beta}] = E^{kin}[\rho_{\alpha\beta}] + E^{H}[\rho_{\alpha\beta}] +
300 * E^{ext}[\rho_{\alpha\beta}] + E^{XC}[\rho_{\alpha\beta}] \f] Kinetic energy of non-interacting electrons is written
301 * in the following way: \f[ E^{kin}[\rho_{\alpha\beta}] \equiv E^{kin}[\Psi[\rho_{\alpha\beta}]] =
302 * -\frac{1}{2} \sum_{i}^{occ}\sum_{\alpha} \int \psi_{i}^{\alpha*}({\bf r}) \nabla^{2} \psi_{i}^{\alpha}({\bf
303 * r})d^3{\bf r} \f] Hartree energy: \f[ E^{H}[\rho_{\alpha\beta}]= \frac{1}{2} \iint \frac{\rho({\bf r})\rho({\bf
304 * r'})}{|{\bf r}-{\bf r'}|} d{\bf r} d{\bf r'} = \frac{1}{2} \iint \sum_{\alpha\beta}\delta_{\alpha\beta}
305 * \frac{\rho_{\alpha\beta}({\bf r}) \rho({\bf r'})}{|{\bf r}-{\bf r'}|} d{\bf r} d{\bf r'} \f] where \f$ \rho({\bf r})
306 * = Tr \rho_{\alpha\beta}({\bf r}) \f$.
307 *
308 * Exchange-correlation energy:
309 * \f[
310 * E^{XC}[\rho_{\alpha\beta}({\bf r})] \equiv E^{XC}[\rho({\bf r}),|{\bf m}({\bf r})|] =
311 * \int \rho({\bf r}) \eta_{XC}(\rho({\bf r}), m({\bf r})) d{\bf r} =
312 * \int \rho({\bf r}) \eta_{XC}(\rho^{\uparrow}({\bf r}), \rho_{\downarrow}({\bf r})) d{\bf r}
313 * \f]
314 * Now we can write the total energy variation over auxiliary orbitals with constrain of orbital normalization:
315 * \f[
316 * \frac{\delta \Big( E^{tot}+\varepsilon_i \big( 1-\sum_{\alpha} \int \psi^{\alpha*}_{i}({\bf r})
317 * \psi^{\alpha}_{i}({\bf r})d{\bf r} \big) \Big)} {\delta \psi_{i}^{\gamma*}({\bf r})} = 0
318 * \f]
319 * We will use the following chain rule:
320 * \f[
321 * \frac{\delta F[\rho_{\alpha\beta}]}{\delta \psi_{i}^{\gamma *}({\bf r})} =
322 * \sum_{\alpha' \beta'} \frac{\delta F[\rho_{\alpha\beta}]}{\delta \rho_{\alpha'\beta'}({\bf r})}
323 * \frac{\delta \rho_{\alpha'\beta'}({\bf r})}{\delta \psi_{i}^{\gamma *}({\bf r})} =
324 * \sum_{\alpha'\beta'}\frac{\delta F[\rho_{\alpha\beta}]}{\delta \rho_{\alpha'\beta'}({\bf r})}
325 * \psi_{i}^{\alpha'}({\bf r}) \delta_{\beta'\gamma} =
326 * \sum_{\alpha'}\frac{\delta F[\rho_{\alpha\beta}]}{\delta \rho_{\alpha'\gamma}({\bf r})}\psi_{i}^{\alpha'}({\bf
327 * r}) \f] Variation of the normalization integral: \f[ \frac{\delta \sum_{\alpha} \int \psi_{i}^{\alpha*}({\bf r})
328 * \psi_{i}^{\alpha}({\bf r}) d {\bf r} }{\delta \psi_{i}^{\gamma *}({\bf r})} = \psi_{i}^{\gamma}({\bf r}) \f]
329 * Variation of the kinetic energy functional:
330 * \f[
331 * \frac{\delta E^{kin}}{\delta \psi_{i}^{\gamma*}({\bf r})} = -\frac{1}{2} \sum_{\alpha} \nabla^{2}
332 * \psi_{i}^{\alpha}({\bf r}) \delta_{\alpha\gamma} = -\frac{1}{2}\nabla^{2}\psi_{i}^{\gamma}({\bf r}) \f] Variation of
333 * the Hartree energy functional: \f[ \frac{\delta E^{H}[\rho_{\alpha\beta}]}{\delta \psi_{i}^{\gamma *}({\bf r})} =
334 * \sum_{\alpha'} \sum_{\alpha\beta} \delta_{\alpha\beta} \frac{1}{2} \int \frac{ \rho({\bf r'})}{|{\bf r}-{\bf r'}|}
335 * d{\bf r'} \delta_{\alpha\alpha'}\delta_{\beta\gamma} \psi_{i}^{\alpha'}({\bf r}) = v^{H}({\bf r})
336 * \psi_{i}^{\gamma}({\bf r}) \f] Variation of the external energy functional: \f[ \frac{\delta
337 * E^{ext}[\rho_{\alpha\beta}]}{\delta \psi_{i}^{\gamma*}({\bf r}) } = \sum_{\alpha'} \sum_{\alpha\beta}
338 * V_{\beta\alpha}^{ext}({\bf r}) \delta_{\alpha\alpha'} \delta_{\beta\gamma} \psi_{i}^{\alpha'}({\bf r})= \sum_{\alpha}
339 * V_{\gamma\alpha}^{ext}({\bf r}) \psi_{i}^{\alpha}({\bf r}) \f]
340 *
341 * Variation of the exchange-correlation functional:
342 * \f[
343 * \frac{\delta E^{XC}[\rho_{\alpha\beta}]}{ \delta \psi_{i}^{\gamma*}({\bf r}) } =
344 * \frac{\delta E^{XC}[\rho_{\alpha\beta}]}{ \delta \rho({\bf r})} \frac{\delta \rho({\bf r})}{\delta
345 * \psi_{i}^{\gamma*}({\bf r})} + \frac{\delta E^{XC}[\rho_{\alpha\beta}]}{ \delta m({\bf r})} \sum_{p=x,y,z}
346 * \frac{\delta m({\bf r})}{ \delta m_p({\bf r})}
347 * \frac{\delta m_p({\bf r})}{\delta \psi_{i}^{\gamma*}({\bf r})}
348 * \f]
349 * where \f$ m({\bf r}) = |{\bf m}({\bf r})|\f$ is the length of magnetization vector.
350 *
351 * First term:
352 * \f[
353 * \frac{\delta E^{XC}[\rho_{\alpha\beta}]}{ \delta \rho({\bf r})} \frac{\delta \rho({\bf r})}{\delta
354 * \psi_{i}^{\gamma*}({\bf r})} = v^{XC}({\bf r}) \psi_{i}^{\gamma}({\bf r})
355 * \f]
356 * Second term:
357 * \f[
358 * \frac{\delta E^{XC}[\rho_{\alpha\beta}]}{ \delta m({\bf r})} \sum_{p=x,y,z} \frac{\delta m({\bf r})}{ \delta
359 * m_p({\bf r})} \frac{\delta m_p({\bf r})}{\delta \psi_{i}^{\gamma*}({\bf r})} = B^{XC}({\bf r}) \hat {\bf m}
360 * \sum_{\beta} {\boldsymbol \sigma}_{\gamma \beta} \psi_{i}^{\beta}({\bf r}) \f] where \f$ B^{XC}({\bf r}) =
361 * \frac{\delta E^{XC}[\rho_{\alpha\beta}]}{ \delta m({\bf r})} \f$, \f$ \hat {\bf m}({\bf r}) = \frac{\delta m({\bf
362 * r})}{ \delta {\bf m}({\bf r})} \f$ is the unit vector, parallel to \f$ {\bf m}({\bf r}) \f$ and \f$ {\bf m}({\bf r})
363 * = \sum_{i} \sum_{\alpha \beta} \psi_{i}^{\alpha*}({\bf r}) {\boldsymbol \sigma}_{\alpha \beta} \psi_i^{\beta}({\bf
364 * r}) \f$
365 *
366 * Similarly to external potential, exchange-correlation potential can be grouped into \f$ 2 \times 2 \f$ matrix::
367 * \f[
368 * \frac{\delta E^{XC}[\rho_{\alpha\beta}]}{\delta \rho_{\alpha'\beta'}({\bf r})} \equiv V^{XC}_{\beta'\alpha'}({\bf
369 * r}) = \Big( {\bf I}v^{XC}({\bf r}) + {\bf B}^{XC}({\bf r}) {\boldsymbol \sigma} \Big)_{\beta'\alpha'} \f] where
370 * \f${\bf B}^{XC}({\bf r}) = \hat {\bf m}({\bf r})B^{XC}({\bf r}) \f$ -- exchange-correlation magnetic field, parallel
371 * to \f$ {\bf m}({\bf r}) \f$ at each point in space. We can now collect \f$ v^{H}({\bf r}) \f$, \f$
372 * V_{\alpha\beta}^{ext}({\bf r}) \f$ and \f$V_{\alpha\beta}^{XC}({\bf r}) \f$ to one effective potential: \f[
373 * V^{eff}_{\alpha\beta}({\bf r}) = v^{H}({\bf r})\delta_{\alpha\beta} + V_{\alpha\beta}^{ext}({\bf r}) +
374 * V_{\alpha\beta}^{XC}({\bf r}) =
375 * \Big({\bf I}\big(v^{H}({\bf r})+v^{ext}({\bf r})+v^{XC}({\bf r})\big) +
376 * {\boldsymbol \sigma}\big( \mu_{B}{\bf B}^{ext}({\bf r}) + {\bf B}^{XC}({\bf r})\big)\Big)_{\alpha\beta}
377 * \f]
378 * and finally, we arrive to the following Kohn-Sham equation for each component \f$ \gamma \f$ of spinor
379 * wave-functions: \f[
380 * -\frac{1}{2}\nabla^{2}\psi_{i}^{\gamma}({\bf r}) + \sum_{\alpha} V_{\gamma\alpha}^{eff}({\bf r})
381 * \psi_{i}^{\alpha}({\bf r}) = \varepsilon_i \psi_{i}^{\gamma}({\bf r}) \f] or in matrix form \f[
382 * \left( \begin{array}{cc} -\frac{1}{2}\nabla^2+V^{eff}_{\uparrow \uparrow} & V^{eff}_{\uparrow \downarrow} \\
383 * V^{eff}_{\downarrow \uparrow} & -\frac{1}{2}\nabla^2+V^{eff}_{\downarrow \downarrow} \end{array}\right)
384 * \left(\begin{array}{c} \psi_{i}^{\uparrow}({\bf r}) \\ \psi_{i}^{\downarrow} ({\bf r}) \end{array} \right) =
385 * \varepsilon_i \left(\begin{array}{c} \psi_{i}^{\uparrow}({\bf r}) \\ \psi_{i}^{\downarrow}({\bf r}) \end{array}
386 * \right) \f]
387 *
388 * \section s4dft Second-variational approach
389 *
390 * Suppose that we know first \f$ N_{fv} \f$ solutions of the following equation (so-called first variational
391 * equation): \f[ \Big(-\frac{1}{2}\nabla^2+v^{H}({\bf r})+v^{ext}({\bf r})+v^{XC}({\bf r}) \Big)\phi_{i}({\bf r}) =
392 * \epsilon_i \phi_{i}({\bf r}) \f] We can write expansion of the components of spinor wave-functions \f$
393 * \psi^{\alpha}_j({\bf r}) \f$ in terms of first-variational states \f$ \phi_i({\bf r}) \f$: \f[ \psi_{j}^{\alpha}({\bf
394 * r}) = \sum_{i}^{N_{fv}}C_{ij}^{\alpha}\phi_{i}({\bf r}) \f] Next, we switch to matrix equation: \f[
395 * \langle \Psi_{j'}| \hat H | \Psi_{j} \rangle = \varepsilon_j \delta_{j'j} \\
396 * \sum_{\alpha \alpha'} \sum_{ii'} C_{i'j'}^{\alpha'*} C_{ij}^{\alpha} \langle \phi_{i'} | \hat H_{\alpha' \alpha} |
397 * \phi_{i} \rangle = \sum_{\alpha \alpha'} \sum_{ii'} C_{i'j'}^{\alpha'*} C_{ij}^{\alpha} H_{\alpha'i', \alpha i} =
398 * \varepsilon_j \delta_{j'j} \f]
399 *
400 * We can combine indices \f$ \{i,\alpha\} \f$ into one 'flat' index \f$ \nu \f$. If we also assume that the number of
401 * spinor wave-functions is equal to \f$ 2 N_{fv} \f$ then we arrive to the well-known eigen decomposition:
402 * \f[
403 * \sum_{\nu'\nu} C_{\nu' j'}^{*} H_{\nu'\nu} C_{\nu j} = \varepsilon_j \delta_{j'j}
404 * \f]
405 *
406 * The expression for second-variational Hamiltonian is simple:
407 * \f[
408 * \langle \phi_{i'}|\hat H_{\alpha'\alpha} |\phi_{i} \rangle =
409 * \langle \phi_{i'} | \Big(-\frac{1}{2}\nabla^2 + v^{H}({\bf r}) + v^{ext}({\bf r}) + v^{XC}({\bf r}) \Big)
410 * \delta_{\alpha\alpha'}|\phi_{i}\rangle +
411 * \langle \phi_{i'} | {\boldsymbol \sigma}_{\alpha\alpha'} \Big( \mu_{B}{\bf B}^{ext}({\bf r})+
412 * {\bf B}^{XC}({\bf r})\Big) | \phi_{i}\rangle =\\
413 * \epsilon_{i}\delta_{i'i}\delta_{\alpha\alpha'} + {\boldsymbol \sigma}_{\alpha\alpha'} \langle \phi_{i'} |
414 * \Big( \mu_{B}{\bf B}^{ext}({\bf r}) +
415 * {\bf B}^{XC}({\bf r})\Big) | \phi_{i}\rangle
416 * \f]
417 */
namespace for Niels Lohmann
The whole DFT ground state implementation.
Potential potential_
Instance of the Potential class.
double scf_correction_energy_
Correction to total energy from the SCF density minimisation.
void initial_state()
Generate initial density, potential and a subspace of wave-functions.
void print_info(std::ostream &out__) const
Print the basic information (total energy, charges, moments, etc.).
Force forces_
Atomic forces.
Density density_
Instance of the Density class.
Simulation_context & ctx_
Context of simulation.
K_point_set & kset_
Set of k-points that are used to generate density.
double ewald_energy_
Store Ewald energy which is computed once and which doesn't change during the run.
json find(double density_tol, double energy_tol, double initial_tolerance, int num_dft_iter, bool write_state)
Run the SCF ground state calculation and find a total energy minimum.
Simulation_context const & ctx() const
Return reference to a simulation context.
std::shared_ptr< Hamiltonian0< double > > H0_
k-point independent part of the Hamiltonian.
void update()
Update the parameters after the change of lattice vectors or atomic positions.
Unit_cell & unit_cell_
Alias of the unit cell.
DFT_ground_state(K_point_set &kset__)
Constructor.
Stress stress_
Lattice stress.
json check_scf_density()
A quick check of self-constent density in case of pseudopotential.
Generate charge density and magnetization from occupied spinor wave-functions.
Definition: density.hpp:214
Compute atomic forces.
Definition: force.hpp:44
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.
auto const & gvec() const
Return const reference to Gvec object.
std::ostream & out() const
Return output stream.
int num_loc_op_applied(int n=0) const
Keep track of the total number of wave-functions to which the local operator was applied.
Stress tensor.
Definition: stress.hpp:97
Representation of a unit cell.
Definition: unit_cell.hpp:43
Total energy terms.
Contains definition of sirius::Force class.
Contains declaration and partial implementation of sirius::Hubbard class.
Interface to nlohmann::json library and helper functions.
Contains declaration and partial implementation of sirius::K_point_set class.
Namespace of the SIRIUS library.
Definition: sirius.f90:5
double ewald_energy(const Simulation_context &ctx, const fft::Gvec &gvec, const Unit_cell &unit_cell)
Compute the ion-ion electrostatic energy using Ewald method.
Definition: energy.cpp:30
Contains definition of sirius::Stress tensor class.