25#ifndef __STEP_FUNCTION_HPP__
26#define __STEP_FUNCTION_HPP__
37 return std::pow(R__, 3) / 3.0;
39 return (std::sin(g__ * R__) - g__ * R__ * std::cos(g__ * R__)) / std::pow(g__, 3);
88 sddk::mdarray<std::complex<double>, 2>
const& phase_factors_t__,
89 fft::spfft_transform_type<double> spfft__)
91 auto v = make_periodic_function<index_domain_t::global>(uc__, gv__, phase_factors_t__,
92 [&](
int iat,
double g) {
102 for (
int ig = 0; ig < gv__.
num_gvec(); ig++) {
103 theta.pw[ig] = -v[ig];
107 std::vector<std::complex<double>> ftmp(gvec_fft__.
count());
108 gvec_fft__.scatter_pw_global(&theta.pw[0], &ftmp[0]);
109 spfft__.backward(
reinterpret_cast<double const*
>(ftmp.data()), SPFFT_PU_HOST);
110 double* theta_ptr = spfft__.local_slice_size() == 0 ? nullptr : &theta.rg[0];
114 s <<
"Error creating step function" << std::endl
115 <<
" local_slice_size() = " << spfft__.local_slice_size() << std::endl
116 <<
" gvec_fft__.count() = " << gvec_fft__.
count();
121 for (
int i = 0; i < spfft__.local_slice_size(); i++) {
127 if (std::abs(vit - uc__.volume_it()) > 1e-10) {
129 s <<
"step function gives a wrong volume for IT region" << std::endl
130 <<
" difference with exact value : " << std::abs(vit - uc__.volume_it());
131 if (gv__.comm().
rank() == 0) {
Representation of a unit cell.
double omega() const
Unit cell volume.
Atom_type & atom_type(int id__)
Return atom type instance by id.
Stores information about G-vector partitioning between MPI ranks for the FFT transformation.
int count(int rank__) const
Local number of G-vectors in the FFT distribution for a given rank.
A set of G-vectors for FFTs and G+k basis functions.
int num_gvec() const
Return the total number of G-vectors within the cutoff.
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.
int rank() const
Rank of MPI process inside communicator.
Generate plane-wave coefficients of the periodic function from the form-factors.
void spfft_output(spfft_transform_type< T > &spfft__, T *data__)
Output CPU data from the CPU buffer of SpFFT.
size_t spfft_grid_size(T const &spfft__)
Total size of the SpFFT transformation grid.
Namespace of the SIRIUS library.
auto init_step_function(Unit_cell const &uc__, fft::Gvec const &gv__, fft::Gvec_fft const &gvec_fft__, sddk::mdarray< std::complex< double >, 2 > const &phase_factors_t__, fft::spfft_transform_type< double > spfft__)
Unit step function is defined to be 1 in the interstitial and 0 inside muffin-tins.
double unit_step_function_form_factors(double R__, double g__)
Utility function to generate LAPW unit step function.
Representation of the unit step function.
sddk::mdarray< std::complex< double >, 1 > pw
Plane wave expansion coefficients of the step function (global array).
sddk::mdarray< double, 1 > rg
Step function on the real-space grid.