ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
ModulePW::PW_Basis_Sup Class Reference

Special pw_basis class for sup girds, which is constrcuted in order to be consistent with the smooth grids in terms of sticks. Easy for conversion between smooth and sup grids in reciprocal space. More...

#include <pw_basis_sup.h>

Inheritance diagram for ModulePW::PW_Basis_Sup:
Collaboration diagram for ModulePW::PW_Basis_Sup:

Public Member Functions

 PW_Basis_Sup ()
 PW_Basis_Sup (std::string device_, std::string precision_)
 ~PW_Basis_Sup ()
void setuptransform (const ModulePW::PW_Basis *pw_rho)
Public Member Functions inherited from ModulePW::PW_Basis
 PW_Basis ()
 PW_Basis (std::string device_, std::string precision_)
virtual ~PW_Basis ()
void initmpi (const int poolnproc_in, const int poolrank_in, MPI_Comm pool_world_in)
virtual void initgrids (const double lat0_in, const ModuleBase::Matrix3 latvec_in, const double gridecut)
virtual void initgrids (const double lat0_in, const ModuleBase::Matrix3 latvec_in, const int nx_in, int ny_in, int nz_in)
void initparameters (const bool gamma_only_in, const double pwecut_in, const int distribution_type_in=1, const bool xprime_in=true)
void setfullpw (const bool inpt_full_pw=false, const int inpt_full_pw_dim=0)
void setuptransform ()
void collect_local_pw ()
void collect_uniqgg ()
template<typename FPTYPE>
void real2recip (const FPTYPE *in, std::complex< FPTYPE > *out, const bool add=false, const FPTYPE factor=1.0) const
 Transform real-valued real-space data to reciprocal-space (gamma-only or non-gamma).
template<typename FPTYPE>
void real2recip (const std::complex< FPTYPE > *in, std::complex< FPTYPE > *out, const bool add=false, const FPTYPE factor=1.0) const
 Transform real-space data to reciprocal-space plane-wave coefficients (complex input).
template<typename FPTYPE>
void recip2real (const std::complex< FPTYPE > *in, FPTYPE *out, const bool add=false, const FPTYPE factor=1.0) const
 Transform reciprocal-space to real-valued real-space (gamma-only or non-gamma).
template<typename FPTYPE>
void recip2real (const std::complex< FPTYPE > *in, std::complex< FPTYPE > *out, const bool add=false, const FPTYPE factor=1.0) const
 Transform reciprocal-space plane-wave coefficients to real-space data (complex output).
template<typename FPTYPE>
void real2recip_gpu (const FPTYPE *in, std::complex< FPTYPE > *out, const bool add=false, const FPTYPE factor=1.0) const
template<typename FPTYPE>
void real2recip_gpu (const std::complex< FPTYPE > *in, std::complex< FPTYPE > *out, const bool add=false, const FPTYPE factor=1.0) const
template<typename FPTYPE>
void recip2real_gpu (const std::complex< FPTYPE > *in, FPTYPE *out, const bool add=false, const FPTYPE factor=1.0) const
template<typename FPTYPE>
void recip2real_gpu (const std::complex< FPTYPE > *in, std::complex< FPTYPE > *out, const bool add=false, const FPTYPE factor=1.0) const
template<typename TK, typename TR, typename Device, typename std::enable_if<!std::is_same< TK, typename GetTypeReal< TK >::type >::value &&(std::is_same< TR, typename GetTypeReal< TK >::type >::value||std::is_same< TR, TK >::value) &&std::is_same< Device, base_device::DEVICE_CPU >::value, int >::type = 0>
void recip_to_real (TK *in, TR *out, const bool add=false, const typename GetTypeReal< TK >::type factor=1.0) const
 Converts data from reciprocal space to real space on Cpu.
template<typename TK, typename TR, typename Device, typename std::enable_if<!std::is_same< TK, typename GetTypeReal< TK >::type >::value &&(std::is_same< TR, typename GetTypeReal< TK >::type >::value||std::is_same< TR, TK >::value) &&std::is_same< Device, base_device::DEVICE_GPU >::value, int >::type = 0>
void recip_to_real (TK *in, TR *out, const bool add=false, const typename GetTypeReal< TK >::type factor=1.0) const
 Converts data from reciprocal space (Fourier space) to real space.
template<typename TR, typename TK, typename Device, typename std::enable_if<!std::is_same< TK, typename GetTypeReal< TK >::type >::value &&(std::is_same< TR, typename GetTypeReal< TK >::type >::value||std::is_same< TR, TK >::value) &&std::is_same< Device, base_device::DEVICE_CPU >::value, int >::type = 0>
void real_to_recip (TR *in, TK *out, const bool add=false, const typename GetTypeReal< TK >::type factor=1.0) const
 Converts data from real space to reciprocal space (Fourier space).
template<typename TR, typename TK, typename Device, typename std::enable_if<!std::is_same< TK, typename GetTypeReal< TK >::type >::value &&(std::is_same< TR, typename GetTypeReal< TK >::type >::value||std::is_same< TR, TK >::value) &&std::is_same< Device, base_device::DEVICE_GPU >::value, int >::type = 0>
void real_to_recip (TR *in, TK *out, const bool add=false, const typename GetTypeReal< TK >::type factor=1.0) const
void getfftixy2is (int *fftixy2is) const
void set_device (std::string device_)
void set_precision (std::string precision_)
std::string get_device () const
std::string get_precision () const
template<typename T>
void real2recip (const T *in, std::complex< T > *out, const bool, const T) const
template<typename T>
void recip2real (const std::complex< T > *in, std::complex< T > *out, const bool, const T) const

Protected Member Functions

void distribute_g (const ModulePW::PW_Basis *pw_rho)
void distribution_method3 (const ModulePW::PW_Basis *pw_rho)
void divide_sticks_3 (const int *st_length2D, const int *st_i, const int *st_j, const int *st_length, const int *fftixy2ip_s, const int &nx_s, const int &ny_s)
void get_ig2isz_is2fftixy (int *st_bottom2D, int *st_length2D, const ModulePW::PW_Basis *pw_rho)
Protected Member Functions inherited from ModulePW::PW_Basis
void distribute_g ()
 distribute plane waves to different cores
virtual void distribute_r ()
 distribute real-space grids to different processors
void getstartgr ()
void distribution_method1 ()
void divide_sticks_1 (int *st_i, int *st_j, int *st_length)
 (3-1) Distribute sticks to cores according to the number of plane waves.
void distribution_method2 ()
void divide_sticks_2 ()
 (2) Devide the sticks to each core according to the number of sticks Sticks are in the order of ixy increasing.
void count_pw_st (int *st_length2D, int *st_bottom2D)
 (1) We count the total number of planewaves (tot_npw) and sticks (this->nstot) here.
void get_ig2isz_is2fftixy (int *st_bottom, int *st_length)
 (5) Construct ig2isz, and is2fftixy.
void collect_st (int *st_length2D, int *st_bottom2D, int *st_i, int *st_j, int *st_length)
 (2) Collect the x, y indexs, length of the sticks.
void get_istot2ixy (int *st_i, int *st_j)
 (3-2) Rearrange sticks in the order of the ip of core increasing, in each core, sticks are sorted in the order of ixy increasing.
void create_maps (int *st_length2D)
 (3) Create the maps from ixy to ip, istot, and from istot to ixy, and construt npw_per simultaneously.
template<typename T>
void gatherp_scatters (std::complex< T > *in, std::complex< T > *out) const
 gather planes and scatter sticks
template<typename T>
void gathers_scatterp (std::complex< T > *in, std::complex< T > *out) const
 gather sticks and scatter planes

Additional Inherited Members

Public Types inherited from ModulePW::PW_Basis
using resmem_int_op = base_device::memory::resize_memory_op<int, base_device::DEVICE_GPU>
using delmem_int_op = base_device::memory::delete_memory_op<int, base_device::DEVICE_GPU>
using syncmem_int_h2d_op = base_device::memory::synchronize_memory_op<int, base_device::DEVICE_GPU, base_device::DEVICE_CPU>
Public Attributes inherited from ModulePW::PW_Basis
std::string classname
MPI_Comm pool_world =MPI_COMM_NULL
int * ig2isz =nullptr
int * ig2ixyz_gpu = nullptr
int * istot2ixy =nullptr
int * is2fftixy =nullptr
int * d_is2fftixy = nullptr
int * fftixy2ip =nullptr
int nst =0
int * nst_per =nullptr
int nstnz =0
int nstot =0
int npw =0
int * npw_per =nullptr
int npwtot =0
int nrxx =0
int * startz =nullptr
int * numz =nullptr
int * numg =nullptr
int * numr =nullptr
int * startg =nullptr
int * startr =nullptr
int startz_current =0
int nplane =0
ModuleBase::Vector3< double > * gdirect =nullptr
ModuleBase::Vector3< double > * gcar =nullptr
double * gg =nullptr
int ig_gge0 =-1
int ngg =0
int * ig2igg =nullptr
double * gg_uniq =nullptr
bool gamma_only = false
 only half g are used.
bool full_pw = false
double ggecut = 0.0
 Energy cut off for g^2/2 = ecutwfc(Ry)*lat0^2/4pi^2, unit in 1/lat0^2.
double gridecut_lat = 0.0
 Energy cut off for all fft grids = ecutrho(Ry)*lat0^2/4pi^2, unit in 1/lat0^2.
double lat0 = 1
 unit length for lattice, unit in bohr
double tpiba = 1
 2pi/lat0
double tpiba2 = 1
 4pi^2/lat0^2
ModuleBase::Matrix3 latvec
 Unitcell lattice vectors, unit in lat0.
ModuleBase::Matrix3 G
 reciprocal lattice vector, unit in 1/lat0
ModuleBase::Matrix3 GT
 traspose of G
ModuleBase::Matrix3 GGT
 GGT = G*GT.
double omega = 1.0
 volume of the cell
int distribution_type = 1
 distribution method
int full_pw_dim = 0
int poolnproc = 1
int poolrank = 0
int fftnx =0
int fftny =0
int fftnz =0
int fftnxyz =0
int fftnxy =0
int nx =0
int ny =0
int nz =0
int nxyz =0
int nxy =0
int liy =0
int riy =0
int lix =0
int rix =0
bool xprime = true
int ng_xeq0 = 0
int nmaxgr = 0
ModuleBase::FFT_Bundle fft_bundle
Protected Attributes inherited from ModulePW::PW_Basis
int * startnsz_per =nullptr
std::string device = "cpu"
 cpu or gpu
std::string precision = "double"
 single, double, mixing
bool double_data_ = true
 if has double data
bool float_data_ = false
 if has float data

Detailed Description

Special pw_basis class for sup girds, which is constrcuted in order to be consistent with the smooth grids in terms of sticks. Easy for conversion between smooth and sup grids in reciprocal space.

Author
liuyu on 2023-10-12

Math: plane waves: <r|g>=1/sqrt(V) * exp(igr) f(r) = 1/sqrt(V) * \sum_g{c(g)*exp(igr)} c(g) = \int f(r)*exp(-igr) dr

USAGE: Similar to PW_Basis, but we need to set up the smooth grids first.

Constructor & Destructor Documentation

◆ PW_Basis_Sup() [1/2]

ModulePW::PW_Basis_Sup::PW_Basis_Sup ( )
inline
Here is the caller graph for this function:

◆ PW_Basis_Sup() [2/2]

ModulePW::PW_Basis_Sup::PW_Basis_Sup ( std::string device_,
std::string precision_ )
inline
Here is the call graph for this function:

◆ ~PW_Basis_Sup()

ModulePW::PW_Basis_Sup::~PW_Basis_Sup ( )

Member Function Documentation

◆ distribute_g()

void ModulePW::PW_Basis_Sup::distribute_g ( const ModulePW::PW_Basis * pw_rho)
protected

distribute plane waves to different cores Known: G, GT, GGT, fftnx, fftny, nz, poolnproc, poolrank, ggecut output: ig2isz[ig], istot2ixy[is], is2fftixy[is], fftixy2ip[ixy], gg[ig], gcar[ig], gdirect[ig], nst, nstot

Here is the call graph for this function:

◆ distribution_method3()

void ModulePW::PW_Basis_Sup::distribution_method3 ( const ModulePW::PW_Basis * pw_rho)
protected

Distribute planewaves in reciprocal space to cores. Firstly, divide the sphere in reciprocal space into sticks, which are vertical to x-y plane. Secondly, distribute these sticks to cores.

Example | -— ixy increasing ---> | -— ixy increasing ---> |... index of sticks 0, 1, 2, ..., nst_per[0]-1, nst_per[0], ..., nst_per[1]-1, ... |___________________________|______________________________|___ ip 0 1 ... npw approximate equal to npw approximate equal to...

Note: This method are ONLY used for dense grids in uspp, and it is not suitable for other cases. The smooth grids is constructed by distribution_method1(). Then, in order to conserve the consistence of planewaves between dense and smooth grids, we divide sticks corresponding to smooth girds first, and then the left ones are divided to ensure the approximate equality of planewaves on each core.

Known: smooth grids Known: G, GT, GGT, fftny, fftnx, nz, poolnproc, poolrank, ggecut output: ig2isz[ig], istot2ixy[is], is2fftixy[is], fftixy2ip[ixy], startnsz_per[ip], nst_per[ip], nst

Here is the call graph for this function:
Here is the caller graph for this function:

◆ divide_sticks_3()

void ModulePW::PW_Basis_Sup::divide_sticks_3 ( const int * st_length2D,
const int * st_i,
const int * st_j,
const int * st_length,
const int * fftixy2ip_s,
const int & nx_s,
const int & ny_s )
protected

(3-1) Distribute sticks to cores. The smooth grids is constructed by distribution_method1(). Then, in order to conserve the consistence of planewaves between dense and smooth grids, we divide sticks corresponding to smooth girds first. We have rearranged sticks in the order of length decreasing, so that we will distribute the longest in the lefted stick preferentially here. For each stick, we find the core that contains the least planewaves firstly, and distribute the stick to it, then update npw_per, this->fftixy2ip, and this->startnsz_per. known: fftixy2ip[ixy], fftnxy, fftny, nx, ny of smooth grids known: tot_npw, this->nstot, st_i, st_j, st_length output: npw_per, nst_per, this->fftixy2ip, this->startnsz_per

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ig2isz_is2fftixy()

void ModulePW::PW_Basis_Sup::get_ig2isz_is2fftixy ( int * st_bottom2D,
int * st_length2D,
const ModulePW::PW_Basis * pw_rho )
protected

(5) Construct ig2isz, and is2fftixy. is2fftixy contains the x-coordinate and y-coordinate of sticks on current core. ig2isz contains the z-coordinate of planewaves on current core. We will scan all the sticks and find the planewaves on them, then store the information into ig2isz and is2fftixy. known: smooth grids known: this->nstot, st_bottom2D, st_length2D output: ig2isz, is2fftixy

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setuptransform()

void ModulePW::PW_Basis_Sup::setuptransform ( const ModulePW::PW_Basis * pw_rho)

distribute plane wave basis and real-space grids to different processors set up maps for fft and create arrays for MPI_Alltoall set up ffts

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: