25#ifndef __RADIAL_INTEGRALS_HPP__
26#define __RADIAL_INTEGRALS_HPP__
66 qmax_ = qmax__ + std::max(10.0, qmax__ * 0.1);
75 inline std::pair<int, double>
iqdq(
double q__)
const
79 s <<
"q-point is out of range" << std::endl
80 <<
" q : " << q__ << std::endl
81 <<
" last point of the q-grid : " <<
grid_q_.
last() << std::endl;
83 s <<
"unit cell: " << uc;
86 std::pair<int, double> result;
90 result.second = q__ -
grid_q_[result.first];
95 template <
typename... Args>
96 inline double value(Args... args,
double q__)
const
99 return values_(args...)(idx.first, idx.second);
102 inline int nq()
const
107 inline double qmax()
const
115template <
bool jl_deriv>
131 std::function<
void(
int,
double,
double*,
int)> atomic_wfc_callback__)
139 nrf_max = std::max(nrf_max,
static_cast<int>(
indexr_(iat).size()));
157 auto idx =
iqdq(q__);
159 int nrf =
indexr_(atom_type.id()).size();
164 for (
int i = 0; i < nrf; i++) {
165 val(i) =
values_(i, iat__)(idx.first, idx.second);
175template <
bool jl_deriv>
179 std::function<void(
int,
double,
double*,
int,
int)> ri_callback_{
nullptr};
185 std::function<
void(
int,
double,
double*,
int,
int)> ri_callback__)
187 , ri_callback_(ri_callback__)
189 if (ri_callback_ ==
nullptr) {
203 int lmax = atom_type.indexr().lmax();
204 int nbrf = atom_type.mt_radial_basis_size();
208 if (ri_callback_ ==
nullptr) {
209 auto idx =
iqdq(q__);
211 for (
int l = 0; l <= 2 *
lmax; l++) {
212 for (
int i = 0; i < nbrf * (nbrf + 1) / 2; i++) {
213 val(i, l) =
values_(i, l, iat__)(idx.first, idx.second);
217 ri_callback_(iat__ + 1, q__, &val[0], nbrf * (nbrf + 1) / 2, 2 *
lmax + 1);
226 std::function<void(
int,
int,
double*,
double*)> ri_callback_{
nullptr};
231 std::function<
void(
int,
int,
double*,
double*)> ri_callback__)
233 , ri_callback_(ri_callback__)
235 if (ri_callback__ ==
nullptr) {
239 auto pcs = env::print_checksum();
248 print_checksum(
"Radial_integrals_rho_pseudo", cs, std::cout);
256 int nq =
static_cast<int>(q__.size());
262 #pragma omp parallel for
263 for (
int iqloc = 0; iqloc < splq.
local_size(); iqloc++) {
266 ri_callback_(iat + 1, 1, &q__[iq], &result(iq, iat));
268 result(iq, iat) = this->value<int>(iat, q__[iq]);
278template <
bool jl_deriv>
282 std::function<void(
int,
int,
double*,
double*)> ri_callback_{
nullptr};
287 std::function<
void(
int,
int,
double*,
double*)> ri_callback__)
289 , ri_callback_(ri_callback__)
291 if (ri_callback_ ==
nullptr) {
300 int nq =
static_cast<int>(q__.size());
306 #pragma omp parallel for
307 for (
int iqloc = 0; iqloc < splq.
local_size(); iqloc++) {
310 ri_callback_(iat + 1, 1, &q__[iq], &result(iq, iat));
312 result(iq, iat) = this->value<int>(iat, q__[iq]);
323template <
bool jl_deriv>
335 std::function<
void(
int,
double,
double*,
int)> ri_callback__)
352 auto idx =
iqdq(q__);
353 for (
int i = 0; i < atom_type.mt_radial_basis_size(); i++) {
354 val(i) =
values_(i, iat__)(idx.first, idx.second);
357 ri_callback_(iat__ + 1, q__, &val[0], atom_type.mt_radial_basis_size());
363template <
bool jl_deriv>
367 std::function<void(
int,
int,
double*,
double*)> ri_callback_{
nullptr};
372 std::function<
void(
int,
int,
double*,
double*)> ri_callback__)
374 , ri_callback_(ri_callback__)
376 if (ri_callback_ ==
nullptr) {
383 inline double value(
int iat__,
double q__)
const
388 auto idx =
iqdq(q__);
389 if (std::abs(q__) < 1e-12) {
398 auto q2 = std::pow(q__, 2);
400 return values_(iat__)(idx.first, idx.second) / q2 / q__ -
401 atom_type.zn() * std::exp(-q2 / 4) * (4 + q2) / 2 / q2 / q2;
403 return values_(iat__)(idx.first, idx.second) / q__ - atom_type.zn() * std::exp(-q2 / 4) / q2;
411 int nq =
static_cast<int>(q__.size());
417 #pragma omp parallel for
418 for (
int iqloc = 0; iqloc < splq.
local_size(); iqloc++) {
421 ri_callback_(iat + 1, 1, &q__[iq], &result(iq, iat));
423 result(iq, iat) = this->
value(iat, q__[iq]);
447 inline double value(
int iat__,
double q__)
const
449 auto idx =
iqdq(q__);
450 if (std::abs(q__) < 1e-12) {
453 return values_(iat__)(idx.first, idx.second) / q__;
std::vector< double > & local_potential(std::vector< double > vloc__)
Set the radial function of the local potential.
T last() const
Last point of the grid.
int num_points() const
Number of grid points.
Radial integrals of the atomic centered orbitals.
Radial_integrals_atomic_wf(Unit_cell const &unit_cell__, double qmax__, int np__, std::function< radial_functions_index const &(int)> indexr__, std::function< Spline< double > const &(int, int)> fl__, std::function< void(int, double, double *, int)> atomic_wfc_callback__)
Constructor.
sddk::mdarray< double, 1 > values(int iat__, double q__) const
Get all values for a given atom type and q-point.
std::function< radial_functions_index const &(int)> indexr_
Return radial basis index for a given atom type.
void generate(std::function< Spline< double > const &(int, int)> fl__)
Generate radial integrals.
Spline< double > const & values(int iwf__, int iat__) const
Retrieve a value for a given orbital of an atom type.
std::function< void(int, double, double *, int)> atomic_wfc_callback_
Callback function to compute radial integrals using the host code.
Radial integrals of the augmentation operator.
Base class for all kinds of radial integrals.
double value(Args... args, double q__) const
Return value of the radial integral with specific indices.
Radial_integrals_base(Unit_cell const &unit_cell__, double const qmax__, int const np__)
Constructor.
sddk::mdarray< Spline< double >, N > values_
Array with integrals.
Unit_cell const & unit_cell_
Unit cell.
double qmax_
Maximum length of the reciprocal wave-vector.
std::pair< int, double > iqdq(double q__) const
Get starting index iq and delta dq for the q-point on the linear grid.
splindex_block spl_q_
Split index of q-points.
Radial_grid< double > grid_q_
Linear grid of q-points on which the interpolation of radial integrals is done.
Radial integrals of beta projectors.
sddk::mdarray< double, 1 > values(int iat__, double q__) const
Get all values for a given atom type and q-point.
void generate()
Generate radial integrals on the q-grid.
std::function< void(int, double, double *, int)> ri_callback_
Callback function to compute radial integrals using the host code.
auto values(std::vector< double > &q__, mpi::Communicator const &comm__) const
Compute all values of the raial integrals.
double value(int iat__, double q__) const
Special implementation to recover the true radial integral value.
auto values(std::vector< double > &q__, mpi::Communicator const &comm__) const
Compute all values of the raial integrals.
double value(int iat__, double q__) const
Special implementation to recover the true radial integral value.
auto values(std::vector< double > &q__, mpi::Communicator const &comm__) const
Compute all values of the raial integrals.
Representation of a unit cell.
int lmax() const
Maximum orbital quantum number of radial functions between all atom types.
int num_atom_types() const
Number of atom types.
json serialize(bool cart_pos__=false) const
Write structure to JSON file.
Atom_type & atom_type(int id__)
Return atom type instance by id.
int max_mt_radial_basis_size() const
Maximum number of radial functions among all atom types.
MPI communicator wrapper.
void allgather(T *buffer__, int const *recvcounts__, int const *displs__) const
In-place MPI_Allgatherv.
int size() const
Size of the communicator (number of ranks).
int rank() const
Rank of MPI process inside communicator.
Radial basis function index.
Multidimensional array with the column-major (Fortran) order.
void zero(memory_t mem__, size_t idx0__, size_t n__)
Zero n elements starting from idx0.
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.
Get the environment variables.
int lmax(int lmmax__)
Get maximum orbital quantum number by the maximum lm index.
Namespace of the SIRIUS library.
strong_type< int, struct __n_blocks_tag > n_blocks
Number of blocks to which the global index is split.
Eror and warning handling during run-time execution.
Contains implementation of sirius::Spherical_Bessel_functions class.
Contains definition and partial implementation of sirius::Unit_cell class.