25#ifndef __NON_LOCAL_FUNCTOR_HPP__
26#define __NON_LOCAL_FUNCTOR_HPP__
37template<
typename T,
typename F>
41 PROFILE(
"sirius::add_k_point_contribution_nonlocal");
43 auto& uc = ctx__.unit_cell();
45 if (uc.max_mt_basis_size() == 0) {
49 auto& bp = kp__.beta_projectors();
51 double main_two_factor{-2};
54 auto bp_gen = bp.make_generator(mt);
55 auto beta_coeffs = bp_gen.prepare();
57 auto bp_base_gen = bp_base__.make_generator(mt);
58 auto beta_coeffs_base = bp_base_gen.prepare();
60 for (
int icnk = 0; icnk < bp_base__.num_chunks(); icnk++) {
63 bp_gen.generate(beta_coeffs, icnk);
68 for (
int ispn = 0; ispn < ctx__.
num_spins(); ispn++) {
72 beta_phi_chunks[ispn] = inner_prod_beta<F>(ctx__.spla_context(), mt, ctx__.
host_memory_t(), sddk::is_device_memory(mt),
78 for (
int x = 0; x < bp_base__.num_comp(); x++) {
80 bp_base_gen.generate(beta_coeffs_base, icnk, x);
82 for (
int ispn = 0; ispn < ctx__.
num_spins(); ispn++) {
83 int spin_factor = (ispn == 0 ? 1 : -1);
88 auto bp_base_phi_chunk = inner_prod_beta<F>(
89 ctx__.spla_context(), mt, ctx__.
host_memory_t(), sddk::is_device_memory(mt), beta_coeffs_base,
96 #pragma omp parallel for
97 for (
int ia_chunk = 0; ia_chunk < beta_coeffs_base.beta_chunk_.num_atoms_; ia_chunk++) {
101 int iat = uc.atom(ia).type_id();
103 if (uc.atom(ia).type().spin_orbit_coupling()) {
104 RTE_THROW(
"stress and forces with SO coupling are not upported");
108 auto for_bnd = [&](
int ibf,
int jbf, std::complex<real_type<F>> dij, real_type<F> qij,
111 for (
int ibnd_loc = 0; ibnd_loc < nbnd_loc; ibnd_loc++) {
115 auto z2 = dij -
static_cast<real_type<F>
>(kp__.
band_energy(ibnd, ispn) * qij);
116 auto z1 = z2 *
std::conj(beta_phi_chunk(offs + jbf, ibnd)) * bp_base_phi_chunk(offs + ibf, ibnd);
118 auto scalar_part =
static_cast<real_type<F>
>(d1) * z1;
121 collect_res__(x, ia) += scalar_part.real();
125 for (
int ibf = 0; ibf < nbf; ibf++) {
126 int lm2 = uc.atom(ia).type().indexb(ibf).lm;
127 int idxrf2 = uc.atom(ia).type().indexb(ibf).idxrf;
128 for (
int jbf = 0; jbf < nbf; jbf++) {
129 int lm1 = uc.atom(ia).type().indexb(jbf).lm;
130 int idxrf1 = uc.atom(ia).type().indexb(jbf).idxrf;
134 if (uc.atom(ia).type().augment()) {
137 std::complex<real_type<F>> dij{0};
142 dij = uc.atom(ia).d_mtrx(ibf, jbf, 0);
144 dij += uc.atom(ia).type().d_mtrx_ion()(idxrf1, idxrf2);
151 dij = (uc.atom(ia).d_mtrx(ibf, jbf, 0) +
152 spin_factor * uc.atom(ia).d_mtrx(ibf, jbf, 1));
154 dij += uc.atom(ia).type().d_mtrx_ion()(idxrf1, idxrf2);
160 RTE_THROW(
"Error in non_local_functor, D_aug_mtrx. ");
166 for_bnd(ibf, jbf, dij, qij, beta_phi_chunks[ispn]);
171 dij = std::complex<real_type<F>>(uc.atom(ia).d_mtrx(ibf, jbf, 2),
172 spin_factor * uc.atom(ia).d_mtrx(ibf, jbf, 3));
174 for_bnd(ibf, jbf, dij, 0.0, beta_phi_chunks[ispn + spin_factor]);
Contains implementation of sirius::Augmentation_operator class.
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...
K-point related variables and methods.
double band_occupancy(int j__, int ispn__) const
Get band occupancy.
double band_energy(int j__, int ispn__) const
Get band energy.
double weight() const
Return weight of k-point.
int num_occupied_bands(int ispn__=-1) const
Get the number of occupied bands for each spin channel.
Simulation context is a set of parameters and objects describing a single simulation.
auto const & augmentation_op(int iat__) const
Returns a constant pointer to the augmentation operator of a given atom type.
auto processing_unit_memory_t() const
Return the memory type for processing unit.
auto host_memory_t() const
Type of the host memory for arrays used in linear algebra operations.
int num_spins() const
Number of spin components.
int num_mag_dims() const
Number of dimensions in the magnetization vector.
Multidimensional array with the column-major (Fortran) order.
value_type local_size(block_id block_id__) const
Return local size of the split index for a given block.
Index_t::global global_index(typename Index_t::local idxloc__, block_id block_id__) const
Return global index of an element by local index and block id.
Describe a range of bands.
Contains definition of sirius::K_point class.
Memory management functions and classes.
Namespace of the SIRIUS library.
void add_k_point_contribution_nonlocal(Simulation_context &ctx__, Beta_projectors_base< T > &bp_base__, K_point< T > &kp__, sddk::mdarray< real_type< F >, 2 > &collect_res__)
strong_type< int, struct __n_blocks_tag > n_blocks
Number of blocks to which the global index is split.
auto conj(double x__)
Return complex conjugate of a number. For a real value this is the number itself.
Contains declaration and partial implementation of sirius::Periodic_function class.
static const int ia
Global index of atom.
static const int nbf
Number of beta-projector functions for this atom.
static const int offset
Offset of beta-projectors in this chunk.