SIRIUS 7.5.0
Electronic structure library and applications
generate_pw_coeffs.cpp
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 generate_pw_coefs.cpp
21 *
22 * \brief Generate plane-wave coefficients of the potential for the LAPW Hamiltonian.
23 */
24
25#include "potential.hpp"
26
27namespace sirius {
28
30{
31 PROFILE("sirius::Potential::generate_pw_coefs");
32
33 double sq_alpha_half = 0.5 * std::pow(speed_of_light, -2);
34
35 int gv_count = ctx_.gvec_fft().count();
36
37 auto& fft = ctx_.spfft<double>();
38
39 /* temporaty output buffer */
40 sddk::mdarray<std::complex<double>, 1> fpw_fft(gv_count);
41
42 switch (ctx_.valence_relativity()) {
43 case relativity_t::iora: {
44 fft::spfft_input<double>(fft, [&](int ir) -> double
45 {
46 double M = 1 - sq_alpha_half * effective_potential().rg().value(ir);
47 return ctx_.theta(ir) / std::pow(M, 2);
48 });
49 fft.forward(SPFFT_PU_HOST, reinterpret_cast<double*>(&fpw_fft[0]), SPFFT_FULL_SCALING);
50 ctx_.gvec_fft().gather_pw_global(&fpw_fft[0], &rm2_inv_pw_[0]);
51 }
52 case relativity_t::zora: {
53 fft::spfft_input<double>(fft, [&](int ir)
54 {
55 double M = 1 - sq_alpha_half * effective_potential().rg().value(ir);
56 return ctx_.theta(ir) / M;
57 });
58 fft.forward(SPFFT_PU_HOST, reinterpret_cast<double*>(&fpw_fft[0]), SPFFT_FULL_SCALING);
59 ctx_.gvec_fft().gather_pw_global(&fpw_fft[0], &rm_inv_pw_[0]);
60 }
61 default: {
62 fft::spfft_input<double>(fft, [&](int ir)
63 {
64 return effective_potential().rg().value(ir) * ctx_.theta(ir);
65 });
66 fft.forward(SPFFT_PU_HOST, reinterpret_cast<double*>(&fpw_fft[0]), SPFFT_FULL_SCALING);
67 ctx_.gvec_fft().gather_pw_global(&fpw_fft[0], &veff_pw_[0]);
68 }
69 }
70
71 /* for full diagonalization we also need Beff(G) */
72 if (!ctx_.cfg().control().use_second_variation()) {
73 throw std::runtime_error("not implemented");
74 }
75}
76
77
78} // sirius
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
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
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
void generate_pw_coefs()
Generate plane-wave coefficients of the potential in the interstitial region.
auto const & gvec_fft() const
Return const reference to Gvec_fft object.
double theta(int ir__) const
Return the value of the step function for the grid point ir.
void valence_relativity(std::string name__)
Set valence relativity for the LAPW method.
Multidimensional array with the column-major (Fortran) order.
Definition: memory.hpp:660
Namespace of the SIRIUS library.
Definition: sirius.f90:5
const double speed_of_light
NIST value for the inverse fine structure (http://physics.nist.gov/cuu/Constants/index....
Definition: constants.hpp:33
Contains declaration and partial implementation of sirius::Potential class.