25#ifndef __PERIODIC_FUNCTION_HPP__
26#define __PERIODIC_FUNCTION_HPP__
30#include "spheric_function_set.hpp"
84 ,
rg_component_(ctx__.spfft<real_type<T>>(), ctx__.gvec_fft_sptr(), rg_ptr__)
97 ,
rg_component_(ctx__.spfft<real_type<T>>(), ctx__.gvec_fft_sptr(), rg_ptr__)
98 ,
mt_component_(
"MT component of Periodic_function", ctx__.unit_cell(), lmax__, spl_atoms__, mt_ptr__)
113 PROFILE(
"sirius::Periodic_function::add");
115 this->rg_component_ += g__.
rg();
117 if (
ctx_.full_potential()) {
118 this->mt_component_ += g__.
mt();
125 PROFILE(
"sirius::Periodic_function::add");
127 this->rg_component_ *= alpha__;
129 if (
ctx_.full_potential()) {
130 for (
int ialoc = 0; ialoc <
unit_cell_.spl_num_atoms().local_size(); ialoc++) {
131 this->f_mt_local_(ialoc) *= alpha__;
139 inline std::tuple<T, T, std::vector<T>>
142 PROFILE(
"sirius::Periodic_function::integrate");
146 if (!
ctx_.full_potential()) {
148 for (
int irloc = 0; irloc < this->
rg().spfft().local_slice_size(); irloc++) {
149 it_val += this->
rg().value(irloc);
153 for (
int irloc = 0; irloc < this->
rg().spfft().local_slice_size(); irloc++) {
154 it_val += this->
rg().value(irloc) *
ctx_.
theta(irloc);
161 std::vector<T> mt_val;
162 if (
ctx_.full_potential()) {
175 return std::make_tuple(total, it_val, mt_val);
179 void hdf5_write(std::string file_name__, std::string path__)
const
181 auto v = this->
rg().gather_f_pw();
183 HDF5_tree fout(file_name__, hdf5_access_t::read_write);
184 fout[path__].
write(
"f_pw",
reinterpret_cast<T*
>(v.data()),
static_cast<int>(v.size() * 2));
185 if (
ctx_.full_potential()) {
187 fout[path__].
write(
"f_mt_" + std::to_string(ia),
mt_component_[ia].at(sddk::memory_t::host),
196 HDF5_tree h5f(file_name__, hdf5_access_t::read_only);
200 h5f[path__].read(
"f_pw",
reinterpret_cast<T*
>(v.data()),
static_cast<int>(v.size() * 2));
212 for (
int igloc = 0; igloc <
gvec_.
count(); igloc++) {
213 this->
rg().f_pw_local(igloc) = v[igmap[igloc]];
216 if (
ctx_.full_potential()) {
218 h5f[path__].read(
"f_mt_" + std::to_string(ia),
mt_component_[ia].at(sddk::memory_t::host),
224 T value_rg(r3::vector<T>
const& vc)
const
227 for (
int igloc = 0; igloc <
gvec_.
count(); igloc++) {
229 p += std::real(this->
rg().f_pw_local(igloc) * std::exp(std::complex<T>(0.0, dot(vc, vgc))));
235 T value(r3::vector<T>
const& vc)
240 if (
unit_cell_.is_point_in_mt(vc, ja, jr, dr, tp)) {
243 std::vector<T> rlm(frlm.angular_domain_size());
246 for (
int lm = 0;
lm < frlm.angular_domain_size();
lm++) {
249 p += rlm[
lm] * (frlm(
lm, jr) + d * dr);
257 inline auto const& ctx()
const
269 auto const&
rg()
const
281 auto const&
mt()
const
288inline T inner(Periodic_function<T>
const& f__, Periodic_function<T>
const& g__)
290 PROFILE(
"sirius::inner");
291 if (f__.ctx().full_potential()) {
293 [&](
int ir) { return f__.ctx().theta(ir); });
294 f__.ctx().comm_fft().allreduce(&result, 1);
295 result += inner(f__.mt(), g__.mt());
298 return inner(f__.rg(), g__.rg());
306 copy(src__.
rg(), dest__.rg);
307 if (src__.ctx().full_potential()) {
308 copy(src__.
mt(), dest__.mt);
316 copy(src__.rg, dest__.
rg());
317 if (dest__.ctx().full_potential()) {
318 copy(src__.mt, dest__.
mt());
Atom_type const & type() const
Return const reference to corresponding atom type object.
Interface to the HDF5 library.
void write(const std::string &name, T const *data, std::vector< int > const &dims)
Write a multidimensional array.
Representation of the periodical function on the muffin-tin geometry.
Smooth_periodic_function< T > rg_component_
Regular space grid component of the periodic function.
auto const & mt() const
Return const reference to spherical functions component.
Simulation_context const & ctx_
Simulation contex.
auto & mt()
Return reference to spherical functions component.
auto & rg()
Return reference to regular space grid component.
std::tuple< T, T, std::vector< T > > integrate() const
Return total integral, interstitial contribution and muffin-tin contributions.
Spheric_function_set< T, atom_index_t > mt_component_
Muffin-tin part of the periodic function.
Periodic_function< T > & operator+=(Periodic_function< T > const &g__)
Add the function.
void zero()
Zero the function.
Unit_cell const & unit_cell_
Alias to unit cell.
fft::Gvec const & gvec_
Alias to G-vectors.
Periodic_function(Simulation_context const &ctx__, std::function< lmax_t(int)> lmax__, splindex_block< atom_index_t > const *spl_atoms__=nullptr, smooth_periodic_function_ptr_t< T > const *rg_ptr__=nullptr, spheric_function_set_ptr_t< T > const *mt_ptr__=nullptr)
Constructor for interstitial and muffin-tin parts (FP-LAPW case).
auto const & rg() const
Return const reference to regular space grid component.
void hdf5_write(std::string file_name__, std::string path__) const
Periodic_function(Simulation_context const &ctx__, smooth_periodic_function_ptr_t< T > const *rg_ptr__=nullptr)
Constructor for real-space FFT grid only (PP-PW case).
T dx(const int i) const
Return .
Simulation context is a set of parameters and objects describing a single simulation.
double theta(int ir__) const
Return the value of the step function for the grid point ir.
mpi::Communicator const & comm() const
Total communicator of the simulation.
Representation of a smooth (Fourier-transformable) periodic function.
Representation of a unit cell.
double omega() const
Unit cell volume.
Atom const & atom(int id__) const
Return const atom instance by id.
int num_atoms() const
Number of atoms in the unit cell.
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.
int offset() const
Offset (in the global index) of G-vectors for a fine-grained distribution for a current MPI rank.
int count() const
Number of G-vectors for a fine-grained distribution for the current MPI rank.
int index_by_gvec(r3::vector< int > const &G__) const
Return a global G-vector index in the range [0, num_gvec) by the G-vector.
r3::vector< double > gvec_cart(int ig__) const
Return G vector in Cartesian coordinates.
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.
Simple implementation of 3d vector.
size_t spfft_grid_size(T const &spfft__)
Total size of the SpFFT transformation grid.
int lmax(int lmmax__)
Get maximum orbital quantum number by the maximum lm index.
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.
std::enable_if_t< std::is_same< T, real_type< F > >::value, void > inner(::spla::Context &spla_ctx__, sddk::memory_t mem__, spin_range spins__, W const &wf_i__, band_range br_i__, Wave_functions< T > const &wf_j__, band_range br_j__, la::dmatrix< F > &result__, int irow0__, int jcol0__)
Compute inner product between the two sets of wave-functions.
Namespace of the SIRIUS library.
T inner_local(Smooth_periodic_function< T > const &f__, Smooth_periodic_function< T > const &g__, F &&theta__)
Compute local contribution to inner product <f|g>
const double y00
First spherical harmonic .
Contains definition and implementation of Simulation_context class.
Contains declaration and implementation of sirius::Smooth_periodic_function and sirius::Smooth_period...
Contains declaration and implementation of sirius::Spheric_function and sirius::Spheric_function_grad...
Describe external pointers to periodic function.