SIRIUS 7.5.0
Electronic structure library and applications
potential.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2021 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 potential.hpp
21 *
22 * \brief Contains declaration and partial implementation of sirius::Potential class.
23 */
24
25#ifndef __POTENTIAL_HPP__
26#define __POTENTIAL_HPP__
27
28#include "density/density.hpp"
29#include "hubbard/hubbard.hpp"
30#include "xc_functional.hpp"
31
32namespace sirius {
33
34void check_xc_potential(Density const& rho__);
35
36double xc_mt(Radial_grid<double> const& rgrid__, SHT const& sht__, std::vector<XC_functional> const& xc_func__,
37 int num_mag_dims__, std::vector<Flm const*> rho__, std::vector<Flm*> vxc__, Flm* exc__);
38
39double density_residual_hartree_energy(Density const& rho1__, Density const& rho2__);
40
41/// Generate effective potential from charge density and magnetization.
42/** \note At some point we need to update the atomic potential with the new MT potential. This is simple if the
43 effective potential is a global function. Otherwise we need to pass the effective potential between MPI ranks.
44 This is also simple, but requires some time. It is also easier to mix the global functions. */
45class Potential : public Field4D
46{
47 private:
48 /// Alias to unit cell.
50
51 /// Communicator of the simulation.
53
54 /// Hartree potential.
55 std::unique_ptr<Periodic_function<double>> hartree_potential_;
56
57 /// XC potential.
58 std::unique_ptr<Periodic_function<double>> xc_potential_;
59
60 /// XC energy per unit particle.
61 std::unique_ptr<Periodic_function<double>> xc_energy_density_;
62
63 /// Local part of pseudopotential.
64 std::unique_ptr<Smooth_periodic_function<double>> local_potential_;
65
66 /// Derivative \f$ \partial \epsilon^{XC} / \partial \sigma_{\alpha} \f$.
67 /** \f$ \epsilon^{XC} \f$ is the exchange-correlation energy per unit volume and \f$ \sigma \f$ is one of
68 * \f$ \nabla \rho_{\uparrow} \nabla \rho_{\uparrow} \f$, \f$ \nabla \rho_{\uparrow} \nabla \rho_{\downarrow}\f$
69 * or \f$ \nabla \rho_{\downarrow} \nabla \rho_{\downarrow} \f$. This quantity is required to compute the GGA
70 * contribution to the XC stress tensor.
71 */
72 std::array<std::unique_ptr<Smooth_periodic_function<double>>, 3> vsigma_;
73
74 /// Used to compute SCF correction to forces.
75 /** This function is set by PW code and is not computed here. */
76 std::unique_ptr<Smooth_periodic_function<double>> dveff_;
77
78 /// Moments of the spherical Bessel functions.
80
81 sddk::mdarray<double, 3> sbessel_mt_;
82
83 sddk::mdarray<double, 2> gamma_factors_R_;
84
85 std::unique_ptr<SHT> sht_;
86
87 int pseudo_density_order_{9};
88
89 std::vector<std::complex<double>> zil_;
90
91 std::vector<std::complex<double>> zilm_;
92
93 std::vector<int> l_by_lm_;
94
96
97 double energy_vha_{0};
98
99 /// Electronic part of Hartree potential.
100 /** Used to compute electron-nuclear contribution to the total energy */
102
103 std::vector<XC_functional> xc_func_;
104
105 /// Plane-wave coefficients of the effective potential weighted by the unit step-function.
107
108 /// Plane-wave coefficients of the inverse relativistic mass weighted by the unit step-function.
110
111 /// Plane-wave coefficients of the squared inverse relativistic mass weighted by the unit step-function.
113
114 /// Hartree contribution to total energy from PAW atoms.
116
117 /// All-electron and pseudopotential parts of PAW potential.
118 std::unique_ptr<PAW_field4D<double>> paw_potential_;
119
120 /// Exchange-correlation energy density of PAW atoms pseudodensity.
121 std::unique_ptr<Spheric_function_set<double, paw_atom_index_t>> paw_ps_exc_;
122
123 /// Exchange-correlation energy density of PAW atoms all-electron density.
124 std::unique_ptr<Spheric_function_set<double, paw_atom_index_t>> paw_ae_exc_;
125
126 /// Contribution to D-operator matrix from the PAW atoms.
127 std::vector<sddk::mdarray<double, 3>> paw_dij_;
128
130
131 /// Hubbard potential correction operator.
132 std::unique_ptr<Hubbard> U_;
133
134 /// Hubbard potential correction matrix.
136
137 /// Add extra charge to the density.
138 /** This is used to verify the variational derivative of Exc w.r.t. density rho */
140
141 /// Add extra charge to the density.
142 /** This is used to verify the variational derivative of Exc w.r.t. magnetisation mag */
144
145 void init_PAW();
146
147 /// Calculate PAW potential for a given atom.
148 /** \return Hartree energy contribution. */
149 double calc_PAW_local_potential(typename atom_index_t::global ia__, std::vector<Flm const*> ae_density,
150 std::vector<Flm const*> ps_density);
151
152 void calc_PAW_local_Dij(typename atom_index_t::global ia__, sddk::mdarray<double, 3>& paw_dij__);
153
154 double calc_PAW_hartree_potential(Atom& atom, Flm const& full_density, Flm& full_potential);
155
156 double calc_PAW_one_elec_energy(Atom const& atom__, sddk::mdarray<double, 2> const& density_matrix__,
157 sddk::mdarray<double, 3> const& paw_dij__) const;
158
159 /// Compute MT part of the potential and MT multipole moments
160 auto poisson_vmt(Periodic_function<double> const& rho__) const
161 {
162 PROFILE("sirius::Potential::poisson_vmt");
163
164 sddk::mdarray<std::complex<double>, 2> qmt(ctx_.lmmax_rho(), unit_cell_.num_atoms());
165 qmt.zero();
166
167 for (auto it : unit_cell_.spl_num_atoms()) {
168 auto ia = it.i;
169
170 auto qmt_re = poisson_vmt<false>(unit_cell_.atom(ia), rho__.mt()[ia],
172
173 SHT::convert(ctx_.lmax_rho(), &qmt_re[0], &qmt(0, ia));
174 }
175
176 ctx_.comm().allreduce(&qmt(0, 0), (int)qmt.size());
177 return qmt;
178 }
179
180 /// Add contribution from the pseudocharge to the plane-wave expansion
181 void poisson_add_pseudo_pw(sddk::mdarray<std::complex<double>, 2>& qmt__,
182 sddk::mdarray<std::complex<double>, 2>& qit__, std::complex<double>* rho_pw__);
183
184 /// Generate local part of pseudo potential.
185 /** Total local potential is a lattice sum:
186 * \f[
187 * V({\bf r}) = \sum_{{\bf T},\alpha} V_{\alpha}({\bf r} - {\bf T} - {\bf \tau}_{\alpha})
188 * \f]
189 * We want to compute it's plane-wave expansion coefficients:
190 * \f[
191 * V({\bf G}) = \frac{1}{V} \int e^{-i{\bf Gr}} V({\bf r}) d{\bf r} =
192 * \frac{1}{V} \sum_{{\bf T},\alpha} \int e^{-i{\bf Gr}}V_{\alpha}({\bf r} - {\bf T} -
193 * {\bf \tau}_{\alpha})d{\bf r}
194 * \f]
195 * Standard change of variables:
196 * \f$ {\bf r}' = {\bf r} - {\bf T} - {\bf \tau}_{\alpha},\; {\bf r} = {\bf r}' + {\bf T} + {\bf \tau}_{\alpha} \f$
197 * leads to:
198 * \f[
199 * V({\bf G}) = \frac{1}{V} \sum_{{\bf T},\alpha} \int e^{-i{\bf G}({\bf r}' + {\bf T} +
200 * {\bf \tau}_{\alpha})}V_{\alpha}({\bf r}')d{\bf r'} =
201 * \frac{N}{V} \sum_{\alpha} \int e^{-i{\bf G}({\bf r}' + {\bf \tau}_{\alpha})}V_{\alpha}({\bf r}')d{\bf r'} =
202 * \frac{1}{\Omega} \sum_{\alpha} e^{-i {\bf G} {\bf \tau}_{\alpha} }
203 * \int e^{-i{\bf G}{\bf r}}V_{\alpha}({\bf r})d{\bf r}
204 * \f]
205 * Using the well-known expansion of a plane wave in terms of spherical Bessel functions:
206 * \f[
207 * e^{i{\bf G}{\bf r}}=4\pi \sum_{\ell m} i^\ell j_{\ell}(Gr)Y_{\ell m}^{*}({\bf \hat G})Y_{\ell m}({\bf \hat r})
208 * \f]
209 * and remembering that for \f$ \ell = 0 \f$ (potential is sphericla) \f$ j_{0}(x) = \sin(x) / x \f$ we have:
210 * \f[
211 * V_{\alpha}({\bf G}) = \int V_{\alpha}(r) 4\pi \frac{\sin(Gr)}{Gr} Y^{*}_{00} Y_{00}
212 * r^2 \sin(\theta) dr d \phi d\theta = 4\pi \int V_{\alpha}(r) \frac{\sin(Gr)}{Gr} r^2 dr
213 * \f]
214 * The tricky part comes next: \f$ V_{\alpha}({\bf r}) \f$ is a long-range potential -- it decays slowly as
215 * \f$ -Z_{\alpha}^{p}/r \f$ and the straightforward integration with sperical Bessel function is numerically
216 * unstable. For \f$ {\bf G} = 0 \f$ an extra term \f$ Z_{\alpha}^p/r \f$, corresponding to the potential of
217 * pseudo-ion, is added to and removed from the local part of the atomic pseudopotential
218 * \f$ V_{\alpha}({\bf r}) \f$:
219 * \f[
220 * V_{\alpha}({\bf G} = 0) = \int V_{\alpha}({\bf r})d{\bf r} \Rightarrow
221 * 4\pi \int \Big( V_{\alpha}(r) + \frac{Z_{\alpha}^p}{r} \Big) r^2 dr -
222 * 4\pi \int \Big( \frac{Z_{\alpha}^p}{r} \Big) r^2 dr
223 * \f]
224 * Second term corresponds to the average electrostatic potential of ions and it is ignored
225 * (like the \f$ {\bf G} = 0 \f$ term in the Hartree potential of electrons).
226 * For \f$ G \ne 0 \f$ the following trick is done: \f$ Z_{\alpha}^p {\rm erf}(r) / r \f$ is added to and
227 * removed from \f$ V_{\alpha}(r) \f$. The idea is to make potential decay quickly and then take the extra
228 * contribution analytically. We have:
229 * \f[
230 * V_{\alpha}({\bf G}) = 4\pi \int \Big(V_{\alpha}(r) + Z_{\alpha}^p \frac{{\rm erf}(r)} {r} -
231 * Z_{\alpha}^p \frac{{\rm erf}(r)}{r}\Big) \frac{\sin(Gr)}{Gr} r^2 dr
232 * \f]
233 * Analytical contribution from the error function is computed using the 1D Fourier transform in complex plane:
234 * \f[
235 * \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty} {\rm erf}(t) e^{i\omega t} dt =
236 * \frac{i e^{-\frac{\omega ^2}{4}} \sqrt{\frac{2}{\pi }}}{\omega }
237 * \f]
238 * from which we immediately get
239 * \f[
240 * \int_{0}^{\infty} \frac{{\rm erf}(r)}{r} \frac{\sin(Gr)}{Gr} r^2 dr = \frac{e^{-\frac{G^2}{4}}}{G^2}
241 * \f]
242 * The final expression for the local potential radial integrals for \f$ G \ne 0 \f$ take the following form:
243 * \f[
244 * 4\pi \int \Big(V_{\alpha}(r) r + Z_{\alpha}^p {\rm erf}(r) \Big) \frac{\sin(Gr)}{G} dr -
245 * Z_{\alpha}^p \frac{e^{-\frac{G^2}{4}}}{G^2}
246 * \f]
247 */
249 {
250 PROFILE("sirius::Potential::generate_local_potential");
251
252 /* get lenghts of all G shells */
253 auto q = ctx_.gvec().shells_len();
254 /* get form-factors for all G shells */
255 auto const ff = ctx_.ri().vloc_->values(q, ctx_.comm());
256 /* make Vloc(G) */
257 auto v = make_periodic_function<index_domain_t::local>(ctx_.unit_cell(), ctx_.gvec(),
258 ctx_.phase_factors_t(), ff);
259
260 std::copy(v.begin(), v.end(), &local_potential_->f_pw_local(0));
261
262 local_potential_->fft_transform(1);
263
264 if (env::print_checksum()) {
265 auto cs = local_potential_->checksum_pw();
266 auto cs1 = local_potential_->checksum_rg();
267 print_checksum("local_potential_pw", cs, ctx_.out());
268 print_checksum("local_potential_rg", cs1, ctx_.out());
269 }
270 }
271
272 /// Generate XC potential in the muffin-tins.
273 void xc_mt(Density const& density__);
274
275 /// Generate non-magnetic XC potential on the regular real-space grid.
276 template <bool add_pseudo_core__>
277 void xc_rg_nonmagnetic(Density const& density__);
278
279 /// Generate magnetic XC potential on the regular real-space grid.
280 template <bool add_pseudo_core__>
281 void xc_rg_magnetic(Density const& density__);
282
283 public:
284 /// Constructor
286
287 /// Recompute some variables that depend on atomic positions or the muffin-tin radius.
288 void update();
289
290 /// Solve Poisson equation for a single atom.
291 template <bool free_atom, typename T>
292 inline std::vector<T>
295 {
296 const bool use_r_prefact{false};
297
298 int lmmax_rho = rho_mt__.angular_domain_size();
299 int lmmax_pot = vha_mt__.angular_domain_size();
300 if ((int)l_by_lm_.size() < lmmax_rho) {
301 std::stringstream s;
302 s << "wrong size of l_by_lm array for atom of " << atom__.type().symbol() << std::endl
303 << " lmmax_rho: " << lmmax_rho << std::endl
304 << " l_by_lm.size: " << l_by_lm_.size();
305 RTE_THROW(s);
306 }
307 std::vector<T> qmt(lmmax_rho, 0);
308
309 double R = atom__.mt_radius();
310 int nmtp = atom__.num_mt_points();
311
312 #pragma omp parallel
313 {
314 std::vector<T> g1;
315 std::vector<T> g2;
316
317 #pragma omp for
318 for (int lm = 0; lm < lmmax_rho; lm++) {
319 int l = l_by_lm_[lm];
320
321 auto rholm = rho_mt__.component(lm);
322
323 if (use_r_prefact) {
324 /* save multipole moment */
325 qmt[lm] = rholm.integrate(g1, l + 2);
326 } else {
327 for (int ir = 0; ir < nmtp; ir++) {
328 double r = atom__.radial_grid(ir);
329 rholm(ir) *= std::pow(r, l + 2);
330 }
331 qmt[lm] = rholm.interpolate().integrate(g1, 0);
332 }
333
334 if (lm < lmmax_pot) {
335
336 if (use_r_prefact) {
337 rholm.integrate(g2, 1 - l);
338 } else {
339 rholm = rho_mt__.component(lm);
340 for (int ir = 0; ir < nmtp; ir++) {
341 double r = atom__.radial_grid(ir);
342 rholm(ir) *= std::pow(r, 1 - l);
343 }
344 rholm.interpolate().integrate(g2, 0);
345 }
346
347 double fact = fourpi / double(2 * l + 1);
348
349 for (int ir = 0; ir < nmtp; ir++) {
350 double r = atom__.radial_grid(ir);
351
352 if (free_atom) {
353 vha_mt__(lm, ir) = g1[ir] / std::pow(r, l + 1) + (g2.back() - g2[ir]) * std::pow(r, l);
354 } else {
355 double d1 = 1.0 / std::pow(R, 2 * l + 1);
356 vha_mt__(lm, ir) = (1.0 - std::pow(r / R, 2 * l + 1)) * g1[ir] / std::pow(r, l + 1) +
357 (g2.back() - g2[ir]) * std::pow(r, l) - (g1.back() - g1[ir]) * std::pow(r, l) * d1;
358 }
359 vha_mt__(lm, ir) *= fact;
360 }
361 }
362 }
363 }
364 if (!free_atom) {
365 /* contribution from nuclear potential -z*(1/r - 1/R) */
366 for (int ir = 0; ir < nmtp; ir++) {
367#ifdef __VHA_AUX
368 double r = atom__.radial_grid(ir);
369 vha_mt__(0, ir) += atom__.zn() * (1 / R - 1 / r) / y00;
370#else
371 vha_mt__(0, ir) += atom__.zn() / R / y00;
372#endif
373 }
374 }
375 /* nuclear multipole moment */
376 qmt[0] -= atom__.zn() * y00;
377
378 return qmt;
379 }
380
381 /// Poisson solver.
382 /** Detailed explanation is available in:
383 * - Weinert, M. (1981). Solution of Poisson's equation: beyond Ewald-type methods.
384 * Journal of Mathematical Physics, 22(11), 2433–2439. doi:10.1063/1.524800
385 * - Classical Electrodynamics Third Edition by J. D. Jackson.
386 *
387 * Solution of Poisson's equation for the muffin-tin geometry is carried out in several steps:
388 * - True multipole moments \f$ q_{\ell m}^{\alpha} \f$ of the muffin-tin charge density are computed.
389 * - Pseudocharge density is introduced. Pseudocharge density coincides with the true charge density
390 * in the interstitial region and it's multipole moments inside muffin-tin spheres coincide with the
391 * true multipole moments.
392 * - Poisson's equation for the pseudocharge density is solved in the plane-wave domain. It gives the
393 * correct interstitial potential and correct muffin-tin boundary values.
394 * - Finally, muffin-tin part of potential is found by solving Poisson's equation in spherical coordinates
395 * with Dirichlet boundary conditions.
396 *
397 * We start by computing true multipole moments of the charge density inside the muffin-tin spheres:
398 * \f[
399 * q_{\ell m}^{\alpha} = \int Y_{\ell m}^{*}(\hat {\bf r}) r^{\ell} \rho({\bf r}) d {\bf r} =
400 * \int \rho_{\ell m}^{\alpha}(r) r^{\ell + 2} dr
401 * \f]
402 * and for the nucleus with charge density \f$ \rho(r, \theta, \phi) = -\frac{Z \delta(r)}{4 \pi r^2} \f$:
403 * \f[
404 * q_{00}^{\alpha} = \int Y_{0 0} \frac{-Z_{\alpha} \delta(r)}{4 \pi r^2} r^2 \sin \theta dr d\phi d\theta =
405 * -Z_{\alpha} Y_{00}
406 * \f]
407 *
408 * Now we need to get the multipole moments of the interstitial charge density \f$ \rho^{I}({\bf r}) \f$ inside
409 * muffin-tin spheres. We need this in order to estimate the amount of pseudocharge to be added to
410 * \f$ \rho^{I}({\bf r}) \f$ to get the pseudocharge multipole moments equal to the true multipole moments.
411 * We want to compute
412 * \f[
413 * q_{\ell m}^{I,\alpha} = \int Y_{\ell m}^{*}(\hat {\bf r}) r^{\ell} \rho^{I}({\bf r}) d {\bf r}
414 * \f]
415 * where
416 * \f[
417 * \rho^{I}({\bf r}) = \sum_{\bf G}e^{i{\bf Gr}} \rho({\bf G})
418 * \f]
419 *
420 * Recall the spherical plane wave expansion:
421 * \f[
422 * e^{i{\bf G r}}=4\pi e^{i{\bf G r}_{\alpha}} \sum_{\ell m} i^\ell
423 * j_{\ell}(G|{\bf r}-{\bf r}_{\alpha}|)
424 * Y_{\ell m}^{*}({\bf \hat G}) Y_{\ell m}(\widehat{{\bf r}-{\bf r}_{\alpha}})
425 * \f]
426 * Multipole moments of each plane-wave are computed as:
427 * \f[
428 * q_{\ell m}^{\alpha}({\bf G}) = 4 \pi e^{i{\bf G r}_{\alpha}} Y_{\ell m}^{*}({\bf \hat G}) i^{\ell}
429 * \int_{0}^{R} j_{\ell}(Gr) r^{\ell + 2} dr = 4 \pi e^{i{\bf G r}_{\alpha}} Y_{\ell m}^{*}({\bf \hat G}) i^{\ell}
430 * \left\{\begin{array}{ll} \frac{R^{\ell + 2} j_{\ell + 1}(GR)}{G} & G \ne 0 \\
431 * \frac{R^3}{3} \delta_{\ell 0} & G = 0 \end{array} \right.
432 * \f]
433 *
434 * Final expression for the muffin-tin multipole moments of the interstitial charge density:
435 * \f[
436 * q_{\ell m}^{I,\alpha} = \sum_{\bf G}\rho({\bf G}) q_{\ell m}^{\alpha}({\bf G})
437 * \f]
438 *
439 * Now we are going to modify interstitial charge density inside the muffin-tin region in order to
440 * get the true multipole moments. We will add a pseudodensity of the form:
441 * \f[
442 * P({\bf r}) = \sum_{\ell m} p_{\ell m}^{\alpha} Y_{\ell m}(\hat {\bf r}) r^{\ell} \left(1-\frac{r^2}{R^2}\right)^n
443 * \f]
444 * Radial functions of the pseudodensity are chosen in a special way. First, they produce a confined and
445 * smooth functions inside muffin-tins and second (most important) plane-wave coefficients of the
446 * pseudodensity can be computed analytically. Let's find the relation between \f$ p_{\ell m}^{\alpha} \f$
447 * coefficients and true and interstitial multipole moments first. We are searching for the pseudodensity which restores
448 * the true multipole moments:
449 * \f[
450 * \int Y_{\ell m}^{*}(\hat {\bf r}) r^{\ell} \Big(\rho^{I}({\bf r}) + P({\bf r})\Big) d {\bf r} = q_{\ell m}^{\alpha}
451 * \f]
452 * Then
453 * \f[
454 * p_{\ell m}^{\alpha} = \frac{q_{\ell m}^{\alpha} - q_{\ell m}^{I,\alpha}}
455 * {\int r^{2 \ell + 2} \left(1-\frac{r^2}{R^2}\right)^n dr} =
456 * (q_{\ell m}^{\alpha} - q_{\ell m}^{I,\alpha}) \frac{2 \Gamma(5/2 + \ell + n)}{R^{2\ell + 3}\Gamma(3/2 + \ell) \Gamma(n + 1)}
457 * \f]
458 *
459 * Now let's find the plane-wave coefficients of \f$ P({\bf r}) \f$ inside each muffin-tin:
460 * \f[
461 * P^{\alpha}({\bf G}) = \frac{4\pi e^{-i{\bf G r}_{\alpha}}}{\Omega} \sum_{\ell m} (-i)^{\ell} Y_{\ell m}({\bf \hat G})
462 * p_{\ell m}^{\alpha} \int_{0}^{R} j_{\ell}(G r) r^{\ell} \left(1-\frac{r^2}{R^2}\right)^n r^2 dr
463 * \f]
464 *
465 * Integral of the spherical Bessel function with the radial pseudodensity component is taken analytically:
466 * \f[
467 * \int_{0}^{R} j_{\ell}(G r) r^{\ell} \left(1-\frac{r^2}{R^2}\right)^n r^2 dr =
468 * 2^n R^{\ell + 3} (GR)^{-n - 1} \Gamma(n + 1) j_{n + \ell + 1}(GR)
469 * \f]
470 *
471 * The final expression for the pseudodensity plane-wave component is:
472 * \f[
473 * P^{\alpha}({\bf G}) = \frac{4\pi e^{-i{\bf G r}_{\alpha}}}{\Omega} \sum_{\ell m} (-i)^{\ell} Y_{\ell m}({\bf \hat G})
474 * (q_{\ell m}^{\alpha} - q_{\ell m}^{I,\alpha}) \Big( \frac{2}{GR} \Big)^{n+1}
475 * \frac{ \Gamma(5/2 + n + \ell) } {R^{\ell} \Gamma(3/2+\ell)} j_{n + \ell + 1}(GR)
476 * \f]
477 *
478 * For \f$ G=0 \f$ only \f$ \ell = 0 \f$ contribution survives:
479 * \f[
480 * P^{\alpha}({\bf G}=0) = \frac{4\pi}{\Omega} Y_{00} (q_{00}^{\alpha} - q_{00}^{I,\alpha})
481 * \f]
482 *
483 * We can now sum the contributions from all muffin-tin spheres and obtain a modified charge density,
484 * which is equal to the exact charge density in the interstitial region and which has correct multipole
485 * moments inside muffin-tin spheres:
486 * \f[
487 * \tilde \rho({\bf G}) = \rho({\bf G}) + \sum_{\alpha} P^{\alpha}({\bf G})
488 * \f]
489 * This density is used to solve the Poisson's equation in the plane-wave domain:
490 * \f[
491 * V_{H}({\bf G}) = \frac{4 \pi \tilde \rho({\bf G})}{G^2}
492 * \f]
493 * The potential is correct in the interstitial region and also on the muffin-tin surface. We will use
494 * it to find the boundary conditions for the potential inside the muffin-tins. Using spherical
495 * plane-wave expansion we get:
496 * \f[
497 * V^{\alpha}_{\ell m}(R) = \sum_{\bf G} V_{H}({\bf G})
498 * 4\pi e^{i{\bf G r}_{\alpha}} i^\ell
499 * j_{\ell}^{\alpha}(GR) Y_{\ell m}^{*}({\bf \hat G})
500 * \f]
501 *
502 * As soon as the muffin-tin boundary conditions for the potential are known, we can find the potential
503 * inside spheres using Dirichlet Green's function:
504 * \f[
505 * V({\bf x}) = \int \rho({\bf x'})G_D({\bf x},{\bf x'}) d{\bf x'} - \frac{1}{4 \pi} \int_{S} V({\bf x'})
506 * \frac{\partial G_D}{\partial n'} d{\bf S'}
507 * \f]
508 * where Dirichlet Green's function for the sphere is defined as:
509 * \f[
510 * G_D({\bf x},{\bf x'}) = 4\pi \sum_{\ell m} \frac{Y_{\ell m}^{*}({\bf \hat x'})
511 * Y_{\ell m}(\hat {\bf x})}{2\ell + 1}
512 * \frac{r_{<}^{\ell}}{r_{>}^{\ell+1}}\Biggl(1 - \Big( \frac{r_{>}}{R} \Big)^{2\ell + 1} \Biggr)
513 * \f]
514 * and it's normal derivative at the surface is equal to:
515 * \f[
516 * \frac{\partial G_D}{\partial n'} = -\frac{4 \pi}{R^2} \sum_{\ell m} \Big( \frac{r}{R} \Big)^{\ell}
517 * Y_{\ell m}^{*}({\bf \hat x'}) Y_{\ell m}(\hat {\bf x})
518 * \f]
519 */
520 void poisson(Periodic_function<double> const& rho);
521
522 /// Generate XC potential and energy density
523 /** In case of spin-unpolarized GGA the XC potential has the following expression:
524 * \f[
525 * V_{XC}({\bf r}) = \frac{\partial}{\partial \rho} \varepsilon_{xc}(\rho, \nabla \rho) -
526 * \nabla \frac{\partial}{\partial (\nabla \rho)} \varepsilon_{xc}(\rho, \nabla \rho) =
527 * \frac{\partial}{\partial \rho} \varepsilon_{xc}(\rho, \nabla \rho) -
528 * \sum_{\alpha} \frac{\partial}{\partial r_{\alpha}}
529 * \frac{\partial \varepsilon_{xc}(\rho, \nabla \rho) }{\partial g_{\alpha}}
530 * \f]
531 * where \f$ {\bf g}({\bf r}) = \nabla \rho({\bf r}) \f$.
532 *
533 * LibXC packs the gradient information into the so-called \a sigma array:
534 * \f[
535 * \sigma = \nabla \rho \nabla \rho = \sum_{\alpha} g_{\alpha}^2({\bf r})
536 * \f]
537 * The derivative of \f$ \sigma \f$ with respect to the gradient of density is simply
538 * \f[
539 * \frac{\partial \sigma}{\partial g_{\alpha}} = 2 g_{\alpha}
540 * \f]
541 *
542 * Changing variables in \f$ V_{XC} \f$ expression gives:
543 * \f{eqnarray*}{
544 * V_{XC}({\bf r}) &=& \frac{\partial}{\partial \rho} \varepsilon_{xc}(\rho, \sigma) -
545 * \nabla \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma}
546 * \frac{\partial \sigma}{ \partial (\nabla \rho)} \\
547 * &=& \frac{\partial}{\partial \rho} \varepsilon_{xc}(\rho, \sigma) -
548 * 2 \nabla \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma} \nabla \rho -
549 * 2 \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma} \nabla^2 \rho
550 * \f}
551 * Alternative expression can be derived for the XC potential if we leave the gradient:
552 * \f[
553 * V_{XC}({\bf r}) = \frac{\partial}{\partial \rho} \varepsilon_{xc}(\rho, \sigma) -
554 * \sum_{\alpha} \frac{\partial}{\partial r_{\alpha}}
555 * \Big( \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma} 2 g_{\alpha} \Big) =
556 * \frac{\partial}{\partial \rho} \varepsilon_{xc}(\rho, \sigma) - 2 \nabla \Big(
557 * \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma} {\bf g}({\bf r}) \Big)
558 * \f]
559 * The following sequence of functions must be computed:
560 * - density on the real space grid
561 * - gradient of density (in spectral representation)
562 * - gradient of density on the real space grid
563 * - laplacian of density (in spectral representation)
564 * - laplacian of density on the real space grid
565 * - \a sigma array
566 * - a call to Libxc must be performed \a sigma derivatives must be obtained
567 * - \f$ \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma} \f$ in spectral representation
568 * - gradient of \f$ \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma} \f$ in spectral representation
569 * - gradient of \f$ \frac{\partial \varepsilon_{xc}(\rho, \sigma)}{\partial \sigma} \f$ on the real space grid
570 *
571 * Expression for spin-polarized potential has a bit more complicated form:
572 * \f{eqnarray*}
573 * V_{XC}^{\gamma} &=& \frac{\partial \varepsilon_{xc}}{\partial \rho_{\gamma}} - \nabla
574 * \Big( 2 \frac{\partial \varepsilon_{xc}}{\partial \sigma_{\gamma \gamma}} \nabla \rho_{\gamma} +
575 * \frac{\partial \varepsilon_{xc}}{\partial \sigma_{\gamma \delta}} \nabla \rho_{\delta} \Big) \\
576 * &=& \frac{\partial \varepsilon_{xc}}{\partial \rho_{\gamma}}
577 * -2 \nabla \frac{\partial \varepsilon_{xc}}{\partial \sigma_{\gamma \gamma}} \nabla \rho_{\gamma}
578 * -2 \frac{\partial \varepsilon_{xc}}{\partial \sigma_{\gamma \gamma}} \nabla^2 \rho_{\gamma}
579 * - \nabla \frac{\partial \varepsilon_{xc}}{\partial \sigma_{\gamma \delta}} \nabla \rho_{\delta}
580 * - \frac{\partial \varepsilon_{xc}}{\partial \sigma_{\gamma \delta}} \nabla^2 \rho_{\delta}
581 * \f}
582 * In magnetic case the "up" and "dn" density and potential decomposition is used. Using the fact that the
583 * effective magnetic field is parallel to magnetization at each point in space, we can write the coupling
584 * of density and magnetization with XC potential and XC magentic field as:
585 * \f[
586 * V_{xc}({\bf r}) \rho({\bf r}) + {\bf B}_{xc}({\bf r}){\bf m}({\bf r}) =
587 * V_{xc}({\bf r}) \rho({\bf r}) + {\rm B}_{xc}({\bf r}) {\rm m}({\bf r}) =
588 * V^{\uparrow}({\bf r})\rho^{\uparrow}({\bf r}) + V^{\downarrow}({\bf r})\rho^{\downarrow}({\bf r})
589 * \f]
590 * where
591 * \f{eqnarray*}{
592 * \rho^{\uparrow}({\bf r}) &=& \frac{1}{2}\Big( \rho({\bf r}) + {\rm m}({\bf r}) \Big) \\
593 * \rho^{\downarrow}({\bf r}) &=& \frac{1}{2}\Big( \rho({\bf r}) - {\rm m}({\bf r}) \Big)
594 * \f}
595 * and
596 * \f{eqnarray*}{
597 * V^{\uparrow}({\bf r}) &=& V_{xc}({\bf r}) + {\rm B}_{xc}({\bf r}) \\
598 * V^{\downarrow}({\bf r}) &=& V_{xc}({\bf r}) - {\rm B}_{xc}({\bf r})
599 * \f}
600 */
601 template <bool add_pseudo_core__ = false>
602 void xc(Density const& rho__);
603
604 /// Generate effective potential and magnetic field from charge density and magnetization.
605 void generate(Density const& density__, bool use_sym__, bool transform_to_rg__);
606
607 void save(std::string name__);
608
609 void load(std::string name__);
610
611 void update_atomic_potential();
612
613 template <sddk::device_t pu>
614 void add_mt_contribution_to_pw();
615
616 /// Generate plane-wave coefficients of the potential in the interstitial region.
617 void generate_pw_coefs();
618
619 /// Calculate D operator from potential and augmentation charge.
620 /** The following real symmetric matrix is computed:
621 * \f[
622 * D_{\xi \xi'}^{\alpha} = \int V({\bf r}) Q_{\xi \xi'}^{\alpha}({\bf r}) d{\bf r}
623 * \f]
624 * In the plane-wave domain this integrals transform into sum over Fourier components:
625 * \f[
626 * D_{\xi \xi'}^{\alpha} = \sum_{\bf G} \langle V |{\bf G}\rangle \langle{\bf G}|Q_{\xi \xi'}^{\alpha} \rangle =
627 * \sum_{\bf G} V^{*}({\bf G}) e^{-i{\bf r}_{\alpha}{\bf G}} Q_{\xi \xi'}^{A}({\bf G}) =
628 * \sum_{\bf G} Q_{\xi \xi'}^{A}({\bf G}) \tilde V_{\alpha}^{*}({\bf G})
629 * \f]
630 * where \f$ \alpha \f$ is the atom, \f$ A \f$ is the atom type and
631 * \f[
632 * \tilde V_{\alpha}({\bf G}) = e^{i{\bf r}_{\alpha}{\bf G}} V({\bf G})
633 * \f]
634 * Both \f$ V({\bf r}) \f$ and \f$ Q({\bf r}) \f$ functions are real and the following condition is fulfilled:
635 * \f[
636 * \tilde V_{\alpha}({\bf G}) = \tilde V_{\alpha}^{*}(-{\bf G})
637 * \f]
638 * \f[
639 * Q_{\xi \xi'}({\bf G}) = Q_{\xi \xi'}^{*}(-{\bf G})
640 * \f]
641 * In the sum over plane-wave coefficients the \f$ {\bf G} \f$ and \f$ -{\bf G} \f$ contributions will give:
642 * \f[
643 * Q_{\xi \xi'}^{A}({\bf G}) \tilde V_{\alpha}^{*}({\bf G}) + Q_{\xi \xi'}^{A}(-{\bf G}) \tilde V_{\alpha}^{*}(-{\bf G}) =
644 * 2 \Re \Big( Q_{\xi \xi'}^{A}({\bf G}) \Big) \Re \Big( \tilde V_{\alpha}({\bf G}) \Big) +
645 * 2 \Im \Big( Q_{\xi \xi'}^{A}({\bf G}) \Big) \Im \Big( \tilde V_{\alpha}({\bf G}) \Big)
646 * \f]
647 * This allows the use of a <b>dgemm</b> instead of a <b>zgemm</b> when \f$ D_{\xi \xi'}^{\alpha} \f$ matrix
648 * is calculated for all atoms of the same type.
649 */
651
652 void generate_PAW_effective_potential(Density const& density);
653
654 double PAW_xc_total_energy(Density const& density__) const
655 {
656 if (!unit_cell_.num_paw_atoms()) {
657 return 0;
658 }
659 /* compute contribution from the core */
660 double ecore{0};
661 #pragma omp parallel for reduction(+:ecore)
662 for (auto it : unit_cell_.spl_num_paw_atoms()) {
663 auto ia = unit_cell_.paw_atom_index(it.i);
664
665 auto& atom = unit_cell_.atom(ia);
666
667 auto& atom_type = atom.type();
668
669 auto& ps_core = atom_type.ps_core_charge_density();
670 auto& ae_core = atom_type.paw_ae_core_charge_density();
671
672 Spline<double> s(atom_type.radial_grid());
673 auto y00inv = 1.0 / y00;
674 for (int ir = 0; ir < atom_type.num_mt_points(); ir++) {
675 s(ir) = y00inv * ((*paw_ae_exc_)[ia](0, ir) * ae_core[ir] - (*paw_ps_exc_)[ia](0, ir) * ps_core[ir]) *
676 std::pow(atom_type.radial_grid(ir), 2);
677 }
678 ecore += s.interpolate().integrate(0);
679 }
680 comm_.allreduce(&ecore, 1);
681
682 return inner(*paw_ae_exc_, density__.paw_density().ae_component(0)) -
683 inner(*paw_ps_exc_, density__.paw_density().ps_component(0)) + ecore;
684 }
685
686 double PAW_total_energy(Density const& density__) const
687 {
688 return paw_hartree_total_energy_ + PAW_xc_total_energy(density__);
689 }
690
691 double PAW_one_elec_energy(Density const& density__) const
692 {
693 double e{0};
694 #pragma omp parallel for reduction(+:e)
695 for (auto it : unit_cell_.spl_num_paw_atoms()) {
696 auto ia = unit_cell_.paw_atom_index(it.i);
697 auto dm = density__.density_matrix_aux(atom_index_t::global(ia));
698 e += calc_PAW_one_elec_energy(unit_cell_.atom(ia), dm, paw_dij_[it.i]);
699 }
700 comm_.allreduce(&e, 1);
701 return e;
702 }
703
704 void check_potential_continuity_at_mt();
705
706 auto& effective_potential()
707 {
708 return this->scalar();
709 }
710
711 auto const& effective_potential() const
712 {
713 return this->scalar();
714 }
715
716 auto& local_potential()
717 {
718 return *local_potential_;
719 }
720
721 auto const& local_potential() const
722 {
723 return *local_potential_;
724 }
725
726 auto& dveff()
727 {
728 return *dveff_;
729 }
730
731 auto const& effective_potential_mt(atom_index_t::local ialoc) const
732 {
733 auto ia = unit_cell_.spl_num_atoms().global_index(ialoc);
734 return this->scalar().mt()[ia];
735 }
736
737 auto& effective_magnetic_field(int i)
738 {
739 return this->vector(i);
740 }
741
742 auto& effective_magnetic_field(int i) const
743 {
744 return this->vector(i);
745 }
746
747 auto& hartree_potential()
748 {
749 return *hartree_potential_;
750 }
751
752 auto const& hartree_potential_mt(atom_index_t::local ialoc) const
753 {
754 auto ia = unit_cell_.spl_num_atoms().global_index(ialoc);
755 return hartree_potential_->mt()[ia];
756 }
757
758 auto& xc_potential()
759 {
760 return *xc_potential_;
761 }
762
763 auto const& xc_potential() const
764 {
765 return *xc_potential_;
766 }
767
768 auto& xc_energy_density()
769 {
770 return *xc_energy_density_;
771 }
772
773 auto const& xc_energy_density() const
774 {
775 return *xc_energy_density_;
776 }
777
778 inline auto vh_el(int ia) const
779 {
780 return vh_el_(ia);
781 }
782
783 auto energy_vha() const
784 {
785 return energy_vha_;
786 }
787
788 auto const& veff_pw(int ig__) const
789 {
790 return veff_pw_(ig__);
791 }
792
793 void set_veff_pw(std::complex<double> const* veff_pw__)
794 {
795 std::copy(veff_pw__, veff_pw__ + ctx_.gvec().num_gvec(), veff_pw_.at(sddk::memory_t::host));
796 }
797
798 auto const& rm_inv_pw(int ig__) const
799 {
800 return rm_inv_pw_(ig__);
801 }
802
803 void set_rm_inv_pw(std::complex<double> const* rm_inv_pw__)
804 {
805 std::copy(rm_inv_pw__, rm_inv_pw__ + ctx_.gvec().num_gvec(), rm_inv_pw_.at(sddk::memory_t::host));
806 }
807
808 auto const& rm2_inv_pw(int ig__) const
809 {
810 return rm2_inv_pw_(ig__);
811 }
812
813 inline void set_rm2_inv_pw(std::complex<double> const* rm2_inv_pw__)
814 {
815 std::copy(rm2_inv_pw__, rm2_inv_pw__ + ctx_.gvec().num_gvec(), rm2_inv_pw_.at(sddk::memory_t::host));
816 }
817
818 /// Integral of \f$ \rho({\bf r}) V^{XC}({\bf r}) \f$.
819 auto energy_vxc(Density const& density__) const
820 {
821 return inner(density__.rho(), xc_potential());
822 }
823
824 /// Integral of \f$ \rho_{c}({\bf r}) V^{XC}({\bf r}) \f$.
825 auto energy_vxc_core(Density const& density__) const
826 {
827 return inner(density__.rho_pseudo_core(), xc_potential().rg());
828 }
829
830 /// Integral of \f$ \rho({\bf r}) \epsilon^{XC}({\bf r}) \f$.
831 auto energy_exc(Density const& density__) const
832 {
833 double exc = (1 + add_delta_rho_xc_) * inner(density__.rho(), xc_energy_density());
834 if (!ctx_.full_potential()) {
835 exc += (1 + add_delta_rho_xc_) * inner(density__.rho_pseudo_core(), xc_energy_density().rg());
836 }
837 return exc;
838 }
839
840 bool is_gradient_correction() const;
841
842 auto& vsigma(int idx__)
843 {
844 RTE_ASSERT(idx__ >= 0 && idx__ < 3);
845 return (*vsigma_[idx__].get());
846 }
847
848 inline void add_delta_rho_xc(double d__)
849 {
850 add_delta_rho_xc_ = d__;
851 }
852
853 inline void add_delta_mag_xc(double d__)
854 {
855 add_delta_mag_xc_ = d__;
856 }
857
858 auto& U() const
859 {
860 return *U_;
861 }
862
863 auto& hubbard_potential()
864 {
865 return hubbard_potential_;
866 }
867
868 auto const& hubbard_potential() const
869 {
870 return hubbard_potential_;
871 }
872};
873
874}; // namespace sirius
875
876#endif // __POTENTIAL_HPP__
Data and methods specific to the actual atom in the unit cell.
Definition: atom.hpp:37
Atom_type const & type() const
Return const reference to corresponding atom type object.
Definition: atom.hpp:318
Generate charge density and magnetization from occupied spinor wave-functions.
Definition: density.hpp:214
auto const & rho() const
Return const reference to charge density (scalar functions).
Definition: density.hpp:416
Four-component function consisting of scalar and vector parts.
Definition: field4d.hpp:40
auto & scalar()
Return scalar part of the field.
Definition: field4d.hpp:74
auto & vector(int i)
Return component of the vector part of the field.
Definition: field4d.hpp:86
Describes Hubbard orbital occupancy or potential correction matrices.
Representation of the periodical function on the muffin-tin geometry.
auto & mt()
Return reference to spherical functions component.
Generate effective potential from charge density and magnetization.
Definition: potential.hpp:46
void generate(Density const &density__, bool use_sym__, bool transform_to_rg__)
Generate effective potential and magnetic field from charge density and magnetization.
Definition: potential.cpp:241
std::unique_ptr< Smooth_periodic_function< double > > dveff_
Used to compute SCF correction to forces.
Definition: potential.hpp:76
std::unique_ptr< Smooth_periodic_function< double > > local_potential_
Local part of pseudopotential.
Definition: potential.hpp:64
sddk::mdarray< std::complex< double >, 1 > rm_inv_pw_
Plane-wave coefficients of the inverse relativistic mass weighted by the unit step-function.
Definition: potential.hpp:109
void xc_rg_magnetic(Density const &density__)
Generate magnetic XC potential on the regular real-space grid.
Definition: xc.cpp:247
auto energy_vxc_core(Density const &density__) const
Integral of .
Definition: potential.hpp:825
auto energy_vxc(Density const &density__) const
Integral of .
Definition: potential.hpp:819
mpi::Communicator const & comm_
Communicator of the simulation.
Definition: potential.hpp:52
std::unique_ptr< Periodic_function< double > > xc_energy_density_
XC energy per unit particle.
Definition: potential.hpp:61
void poisson(Periodic_function< double > const &rho)
Poisson solver.
Definition: poisson.cpp:158
double add_delta_mag_xc_
Add extra charge to the density.
Definition: potential.hpp:143
Hubbard_matrix hubbard_potential_
Hubbard potential correction matrix.
Definition: potential.hpp:135
std::unique_ptr< Periodic_function< double > > hartree_potential_
Hartree potential.
Definition: potential.hpp:55
double paw_hartree_total_energy_
Hartree contribution to total energy from PAW atoms.
Definition: potential.hpp:115
double calc_PAW_local_potential(typename atom_index_t::global ia__, std::vector< Flm const * > ae_density, std::vector< Flm const * > ps_density)
Calculate PAW potential for a given atom.
sddk::mdarray< std::complex< double >, 1 > rm2_inv_pw_
Plane-wave coefficients of the squared inverse relativistic mass weighted by the unit step-function.
Definition: potential.hpp:112
std::unique_ptr< Spheric_function_set< double, paw_atom_index_t > > paw_ae_exc_
Exchange-correlation energy density of PAW atoms all-electron density.
Definition: potential.hpp:124
std::unique_ptr< PAW_field4D< double > > paw_potential_
All-electron and pseudopotential parts of PAW potential.
Definition: potential.hpp:118
void xc_mt(Density const &density__)
Generate XC potential in the muffin-tins.
Definition: xc_mt.cpp:314
Potential(Simulation_context &ctx__)
Constructor.
Definition: potential.cpp:33
void xc(Density const &rho__)
Generate XC potential and energy density.
Definition: xc.cpp:435
std::unique_ptr< Periodic_function< double > > xc_potential_
XC potential.
Definition: potential.hpp:58
std::vector< T > poisson_vmt(Atom const &atom__, Spheric_function< function_domain_t::spectral, T > const &rho_mt__, Spheric_function< function_domain_t::spectral, T > &vha_mt__) const
Solve Poisson equation for a single atom.
Definition: potential.hpp:293
std::unique_ptr< Hubbard > U_
Hubbard potential correction operator.
Definition: potential.hpp:132
auto energy_exc(Density const &density__) const
Integral of .
Definition: potential.hpp:831
std::unique_ptr< Spheric_function_set< double, paw_atom_index_t > > paw_ps_exc_
Exchange-correlation energy density of PAW atoms pseudodensity.
Definition: potential.hpp:121
Unit_cell & unit_cell_
Alias to unit cell.
Definition: potential.hpp:49
std::vector< sddk::mdarray< double, 3 > > paw_dij_
Contribution to D-operator matrix from the PAW atoms.
Definition: potential.hpp:127
void generate_local_potential()
Generate local part of pseudo potential.
Definition: potential.hpp:248
void update()
Recompute some variables that depend on atomic positions or the muffin-tin radius.
Definition: potential.cpp:152
std::array< std::unique_ptr< Smooth_periodic_function< double > >, 3 > vsigma_
Derivative .
Definition: potential.hpp:72
sddk::mdarray< double, 1 > vh_el_
Electronic part of Hartree potential.
Definition: potential.hpp:101
void generate_D_operator_matrix()
Calculate D operator from potential and augmentation charge.
void xc_rg_nonmagnetic(Density const &density__)
Generate non-magnetic XC potential on the regular real-space grid.
Definition: xc.cpp:36
sddk::mdarray< std::complex< double >, 1 > veff_pw_
Plane-wave coefficients of the effective potential weighted by the unit step-function.
Definition: potential.hpp:106
auto poisson_vmt(Periodic_function< double > const &rho__) const
Compute MT part of the potential and MT multipole moments.
Definition: potential.hpp:160
sddk::mdarray< double, 3 > sbessel_mom_
Moments of the spherical Bessel functions.
Definition: potential.hpp:79
void generate_pw_coefs()
Generate plane-wave coefficients of the potential in the interstitial region.
double add_delta_rho_xc_
Add extra charge to the density.
Definition: potential.hpp:139
void poisson_add_pseudo_pw(sddk::mdarray< std::complex< double >, 2 > &qmt__, sddk::mdarray< std::complex< double >, 2 > &qit__, std::complex< double > *rho_pw__)
Add contribution from the pseudocharge to the plane-wave expansion.
Definition: poisson.cpp:49
static void convert(int lmax__, double const *f_rlm__, std::complex< double > *f_ylm__)
Convert form Rlm to Ylm representation.
Definition: sht.hpp:264
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.
mpi::Communicator const & comm() const
Total communicator of the simulation.
Function in spherical harmonics or spherical coordinates representation.
Representation of a unit cell.
Definition: unit_cell.hpp:43
Atom const & atom(int id__) const
Return const atom instance by id.
Definition: unit_cell.hpp:344
int num_paw_atoms() const
Return number of atoms with PAW pseudopotential.
Definition: unit_cell.hpp:161
auto const & spl_num_paw_atoms() const
Get split index of PAW atoms.
Definition: unit_cell.hpp:172
int num_atoms() const
Number of atoms in the unit cell.
Definition: unit_cell.hpp:338
auto paw_atom_index(paw_atom_index_t::global ipaw__) const
Return global index of atom by the index in the list of PAW atoms.
Definition: unit_cell.hpp:183
MPI communicator wrapper.
void allreduce(T *buffer__, int count__) const
Perform the in-place (the output buffer is used as the input buffer) all-to-all reduction.
void zero(memory_t mem__, size_t idx0__, size_t n__)
Zero n elements starting from idx0.
Definition: memory.hpp:1316
size_t size() const
Return total size (number of elements) of the array.
Definition: memory.hpp:1207
Contains definition and partial implementation of sirius::Density class.
Contains declaration and partial implementation of sirius::Hubbard class.
void copy(T *target__, T const *source__, size_t n__)
Copy memory inside a device.
Definition: acc.hpp:320
int lm(int l, int m)
Get composite lm index by angular index l and azimuthal index m.
Definition: specfunc.hpp:50
std::enable_if_t< std::is_same< T, real_type< F > >::value, void > inner(::spla::Context &spla_ctx__, sddk::memory_t mem__, spin_range spins__, W const &wf_i__, band_range br_i__, Wave_functions< T > const &wf_j__, band_range br_j__, la::dmatrix< F > &result__, int irow0__, int jcol0__)
Compute inner product between the two sets of wave-functions.
Namespace of the SIRIUS library.
Definition: sirius.f90:5
const double y00
First spherical harmonic .
Definition: constants.hpp:51
const double fourpi
Definition: constants.hpp:48
Contains implementation of sirius::XC_functional class.