25#ifndef __BETA_PROJECTORS_HPP__
26#define __BETA_PROJECTORS_HPP__
40 PROFILE(
"sirius::Beta_projectors::generate_pw_coefs_t");
41 if (!this->num_beta_t()) {
45 auto& uc = this->ctx_.unit_cell();
47 std::vector<int> offset_t(uc.num_atom_types());
48 std::generate(offset_t.begin(), offset_t.end(),
49 [n = 0, iat = 0, &uc] ()
mutable
52 n += uc.atom_type(iat++).mt_basis_size();
56 auto& comm = this->
gkvec_.comm();
58 auto& beta_radial_integrals = *this->ctx_.ri().beta_;
60 std::vector<std::complex<double>> z(uc.lmax() + 1);
61 for (
int l = 0; l <= uc.lmax(); l++) {
62 z[l] = std::pow(std::complex<double>(0, -1), l) *
fourpi / std::sqrt(uc.omega());
66 #pragma omp parallel for
67 for (
int igkloc = 0; igkloc < this->num_gkvec_loc(); igkloc++) {
71 std::vector<double> gkvec_rlm(
sf::lmmax(uc.lmax()));
73 for (
int iat = 0; iat < uc.num_atom_types(); iat++) {
74 auto& atom_type = uc.atom_type(iat);
76 auto ri_val = beta_radial_integrals.values(iat, vs[0]);
77 for (
int xi = 0; xi < atom_type.mt_basis_size(); xi++) {
78 int l = atom_type.indexb(xi).am.l();
79 int lm = atom_type.indexb(xi).lm;
80 int idxrf = atom_type.indexb(xi).idxrf;
82 this->
pw_coeffs_t_(igkloc, offset_t[atom_type.id()] + xi, 0) =
83 static_cast<std::complex<T>
>(z[l] * gkvec_rlm[
lm] * ri_val(idxrf));
88 if (env::print_checksum()) {
91 if (comm.
rank() == 0) {
92 print_checksum(
"beta_pw_coeffs_t", c1, std::cout);
101 PROFILE(
"sirius::Beta_projectors");
104 if (!this->num_beta_t()) {
108 if (this->ctx_.processing_unit() == sddk::device_t::GPU) {
109 this->reallocate_pw_coeffs_t_on_gpu_ =
false;
114 for (
int iat = 0; iat < ctx__.unit_cell().num_atom_types(); iat++) {
115 nbeta += ctx__.unit_cell().atom_type(iat).num_atoms() * ctx__.unit_cell().atom_type(iat).mt_basis_size();
121 sddk::matrix<std::complex<T>>(this->num_gkvec_loc(), nbeta);
122 for (
int ichunk = 0; ichunk < this->num_chunks(); ++ichunk) {
124 sddk::matrix<std::complex<T>>(&this->
beta_pw_all_atoms_(0, this->beta_chunks_[ichunk].offset_),
125 this->num_gkvec_loc(), this->beta_chunks_[ichunk].num_beta_);
127 this->beta_chunks_[ichunk], ctx__, gkvec__);
Contains declaration and implementation of sirius::Beta_projectors_base class.
Base class for beta-projectors, gradient of beta-projectors and strain derivatives of beta-projectors...
fft::Gvec const & gkvec_
List of G+k vectors.
sddk::matrix< std::complex< T > > pw_coeffs_a_
Set of beta PW coefficients for a chunk of atoms.
sddk::mdarray< std::complex< T >, 3 > pw_coeffs_t_
Phase-factor independent coefficients of |beta> functions for atom types.
sddk::matrix< std::complex< T > > beta_pw_all_atoms_
Set of beta PW coefficients for all atoms.
Stores <G+k | beta> expansion.
void generate_pw_coefs_t()
Generate plane-wave coefficients for beta-projectors of atom types.
Simulation context is a set of parameters and objects describing a single simulation.
A set of G-vectors for FFTs and G+k basis functions.
void allreduce(T *buffer__, int count__) const
Perform the in-place (the output buffer is used as the input buffer) all-to-all reduction.
int rank() const
Rank of MPI process inside communicator.
mdarray< T, N > & allocate(memory_t memory__)
Allocate memory for array.
T checksum(size_t idx0__, size_t size__) const
Compute checksum.
auto spherical_coordinates(vector< double > vc)
Transform Cartesian coordinates [x,y,z] to spherical coordinates [r,theta,phi].
int lmmax(int lmax)
Maximum number of combinations for a given .
int lm(int l, int m)
Get composite lm index by angular index l and azimuthal index m.
void spherical_harmonics(int lmax, double theta, double phi, std::complex< double > *ylm)
Optimized implementation of complex spherical harmonics.
Namespace of the SIRIUS library.