ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Typedefs | Functions
LR_Util Namespace Reference

Typedefs

using TC = std::array< int, 3 >
 
using TAC = std::pair< int, TC >
 
template<typename T >
using TLRIX = std::map< int, std::map< TAC, std::vector< T > > >
 

Functions

int cal_nocc (int nelec)
 =================PHYSICS====================
 
std::pair< ModuleBase::matrix, std::vector< std::pair< int, int > > > set_ix_map_diagonal (bool mode, int nc, int nv)
 set the index map: ix to (ic, iv) and vice versa by diagonal traverse the c-v pairs leftdown -> rightup for mode 0, rightup -> leftdown for mode 1
 
template<>
void matsym< double > (const double *in, const int n, const Parallel_2D &pmat, double *out)
 =================ALGORITHM====================
 
template<>
void matsym< double > (double *inout, const int n, const Parallel_2D &pmat)
 
template<>
void matsym< std::complex< double > > (const std::complex< double > *in, const int n, const Parallel_2D &pmat, std::complex< double > *out)
 
template<>
void matsym< std::complex< double > > (std::complex< double > *inout, const int n, const Parallel_2D &pmat)
 
void setup_2d_division (Parallel_2D &pv, int nb, int gr, int gc)
 =================2D-block Parallel===============
 
void setup_2d_division (Parallel_2D &pv, int nb, int gr, int gc, const int &blacs_ctxt_in)
 
void diag_lapack (const int &n, double *mat, double *eig)
 diagonalize a hermitian matrix
 
void diag_lapack (const int &n, std::complex< double > *mat, double *eig)
 
void diag_lapack_nh (const int &n, double *mat, std::complex< double > *eig)
 diagonalize a general matrix
 
void diag_lapack_nh (const int &n, std::complex< double > *mat, std::complex< double > *eig)
 
std::string tolower (const std::string &str)
 =================string option====================
 
std::string toupper (const std::string &str)
 
template<typename TCell >
int cal_nelec (const TCell &ucell)
 =====================PHYSICS====================
 
template<typename T >
void _deallocate_2order_nested_ptr (T **p2, size_t size)
 =================ALGORITHM====================
 
template<typename T >
void _allocate_2order_nested_ptr (T **&p2, size_t size1, size_t size2)
 new 2d pointer

 
template<typename T >
ct::Tensor newTensor (const ct::TensorShape &shape)
 
template<typename T >
void matsym (const T *in, const int n, T *out)
 
template<typename T >
void matsym (T *inout, const int n)
 calculate (A+A^T)/2 (in-place version)
 
template<typename T >
void matsym (const T *in, const int n, const Parallel_2D &pmat, T *out)
 
template<typename T >
void matsym (T *inout, const int n, const Parallel_2D &pmat)
 
template<typename T , typename Device >
psi::Psi< T, Device > k1_to_bfirst_wrapper (const psi::Psi< T, Device > &psi_kfirst, int nk_in, int nbasis_in)
 psi(nk=1, nbands=nb, nk * nbasis) -> psi(nb, nk, nbasis) without memory copy
 
template<typename T , typename Device >
psi::Psi< T, Device > bfirst_to_k1_wrapper (const psi::Psi< T, Device > &psi_bfirst)
 psi(nb, nk, nbasis) -> psi(nk=1, nbands=nb, nk * nbasis) without memory copy
 
template<typename T >
void gather_2d_to_full (const Parallel_2D &pv, const T *submat, T *fullmat, bool col_first, int global_nrow, int global_ncol)
 gather 2d matrix to full matrix the defination of row and col is consistent with setup_2d_division
 
template<typename T , typename... Args>
std::unique_ptr< Tmake_unique (Args &&... args)
 
double get_conj (const double &x)
 
std::complex< double > get_conj (const std::complex< double > &x)
 
template<typename T >
psi::Psi< Tget_psi_spin (const psi::Psi< T > &psi_in, const int &is, const int &nk)
 get the Psi wrapper of the selected spin from the Psi object
 
void get_DMR_real_imag_part (const elecstate::DensityMatrix< std::complex< double >, std::complex< double > > &DMR, elecstate::DensityMatrix< std::complex< double >, double > &DMR_real, const int &nat, const char &type)
 
void set_HR_real_imag_part (const hamilt::HContainer< double > &HR_real, hamilt::HContainer< std::complex< double > > &HR, const int &nat, const char &type)
 
template<typename TR >
void print_HR (const hamilt::HContainer< TR > &HR, const int &nat, const std::string &label, const double &threshold=1e-10)
 
template<typename TK , typename TR >
void print_DMR (const elecstate::DensityMatrix< TK, TR > &DMR, const int &nat, const std::string &label, const double &threshold=1e-10)
 
template<typename T , typename TR >
void initialize_HR (hamilt::HContainer< TR > &hR, const UnitCell &ucell, const Grid_Driver &gd, const std::vector< double > &orb_cutoff)
 
template<typename T , typename TR >
void initialize_DMR (elecstate::DensityMatrix< T, TR > &dm, const Parallel_Orbitals &pmat, const UnitCell &ucell, const Grid_Driver &gd, const std::vector< double > &orb_cutoff)
 
template<typename TR1 , typename TR2 >
TR1 dot_R_matrix (const hamilt::HContainer< TR1 > &h1, const hamilt::HContainer< TR2 > &h2, const int &nat)
 $\sum_{uvR} H1_{uv}(R) H2_{uv}(R)$
 
template<typename T >
constexpr T filter (const T &v, const double &threshold=1e-10)
 
template<typename T >
int read_value (std::ifstream &ifs, T *ptr, const int &size)
 
template<typename T , typename... Args>
int read_value (std::ifstream &ifs, T *ptr, const int &size, Args &&... args)
 
template<typename T , typename... Args>
int read_value (const std::string &file, T *ptr, const int &size, Args &&... args)
 
template<typename T >
int write_value (std::ofstream &ofs, const T *ptr, const int &size)
 
template<typename T , typename... Args>
int write_value (std::ofstream &ofs, const T *ptr, const int &size, Args &&... args)
 
template<typename T , typename... Args>
int write_value (const std::string &file, const int &prec, const T *ptr, const int &size, Args &&... args)
 
template<typename T >
int print_value (const T *ptr, const int &size)
 
template<typename T , typename... Args>
int print_value (const T *ptr, const int &size, Args &&... args)
 
template<typename T >
void print_psi_bandfirst (const psi::Psi< T > &psi, const std::string &label, const int &ib, const double &threshold=1e-10)
 
template<typename T >
void write_psi_bandfirst (const psi::Psi< T > &psi, const std::string &filename, const int &rank, const double &threshold=1e-10, const int &precision=8)
 
template<typename T >
void write_psi_bandfirst (const T *psi, const int &nband, const int &nk, const int &nbasis, const std::string &filename, const int &rank, const double &threshold=1e-10, const int &precision=8)
 
template<typename T >
psi::Psi< Tread_psi_bandfirst (const std::string &filename, const int &rank)
 
template<typename T >
void print_psi_kfirst (const psi::Psi< T > &psi, const std::string &label, const double &threshold=1e-10)
 
template<typename T >
void print_tensor (const container::Tensor &t, const std::string &label, const Parallel_2D *pmat, const double &threshold=1e-10)
 
template<typename T >
void print_grid_nonzero (T *rho, const int &nrxx, const int &nnz, const std::string &label, const double &threshold=1e-5)
 
template<typename T >
void print_CsX (const TLRIX< T > &CsX, const int nvirt, const std::string &label, const double &threshold=1e-10)
 
template<typename T >
void grad (const T *rhor, ModuleBase::Vector3< T > *gradrho, const ModulePW::PW_Basis &rho_basis, const double &tpiba)
 
template<typename T >
void grad (const std::vector< T > &rhor, std::vector< ModuleBase::Vector3< T > > &gradrho, const ModulePW::PW_Basis &rho_basis, const double &tpiba)
 
template<typename T >
void lapl (const T *rhor, T *lapn, const ModulePW::PW_Basis &rho_basis, const double &tpiba2)
 
template<typename T >
void lapl (const std::vector< T > &rhor, std::vector< T > &lapn, const ModulePW::PW_Basis &rho_basis, const double &tpiba2)
 

Typedef Documentation

◆ TAC

using LR_Util::TAC = typedef std::pair<int, TC>

◆ TC

using LR_Util::TC = typedef std::array<int, 3>

◆ TLRIX

template<typename T >
using LR_Util::TLRIX = typedef std::map<int, std::map<TAC, std::vector<T> >>

Function Documentation

◆ _allocate_2order_nested_ptr()

template<typename T >
void LR_Util::_allocate_2order_nested_ptr ( T **&  p2,
size_t  size1,
size_t  size2 
)

new 2d pointer

new 2d pointer

Template Parameters
T
Parameters
size1
size2
Here is the caller graph for this function:

◆ _deallocate_2order_nested_ptr()

template<typename T >
void LR_Util::_deallocate_2order_nested_ptr ( T **  p2,
size_t  size 
)

=================ALGORITHM====================

delete 2d pointer

delete 2d pointer

Template Parameters
T
Parameters
p2
size
Here is the caller graph for this function:

◆ bfirst_to_k1_wrapper()

template<typename T , typename Device >
psi::Psi< T, Device > LR_Util::bfirst_to_k1_wrapper ( const psi::Psi< T, Device > &  psi_bfirst)

psi(nb, nk, nbasis) -> psi(nk=1, nbands=nb, nk * nbasis) without memory copy

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

◆ cal_nelec()

template<typename TCell >
int LR_Util::cal_nelec ( const TCell &  ucell)

=====================PHYSICS====================

=================PHYSICS====================

calculate the number of electrons

Template Parameters
TCell
Parameters
ucell
Here is the caller graph for this function:

◆ cal_nocc()

int LR_Util::cal_nocc ( int  nelec)

=================PHYSICS====================

calculate the number of occupied orbitals

Parameters
nelec
Here is the caller graph for this function:

◆ diag_lapack() [1/2]

void LR_Util::diag_lapack ( const int &  n,
double *  mat,
double *  eig 
)

diagonalize a hermitian matrix

=================diago-lapack====================

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

◆ diag_lapack() [2/2]

void LR_Util::diag_lapack ( const int &  n,
std::complex< double > *  mat,
double *  eig 
)
Here is the call graph for this function:

◆ diag_lapack_nh() [1/2]

void LR_Util::diag_lapack_nh ( const int &  n,
double *  mat,
std::complex< double > *  eig 
)

diagonalize a general matrix

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

◆ diag_lapack_nh() [2/2]

void LR_Util::diag_lapack_nh ( const int &  n,
std::complex< double > *  mat,
std::complex< double > *  eig 
)
Here is the call graph for this function:

◆ dot_R_matrix()

template<typename TR1 , typename TR2 >
TR1 LR_Util::dot_R_matrix ( const hamilt::HContainer< TR1 > &  h1,
const hamilt::HContainer< TR2 > &  h2,
const int &  nat 
)

$\sum_{uvR} H1_{uv}(R) H2_{uv}(R)$

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

◆ filter()

template<typename T >
constexpr T LR_Util::filter ( const T v,
const double &  threshold = 1e-10 
)
constexpr
Here is the caller graph for this function:

◆ gather_2d_to_full()

template<typename T >
void LR_Util::gather_2d_to_full ( const Parallel_2D pv,
const T submat,
T fullmat,
bool  col_first,
int  global_nrow,
int  global_ncol 
)

gather 2d matrix to full matrix the defination of row and col is consistent with setup_2d_division

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

◆ get_conj() [1/2]

double LR_Util::get_conj ( const double &  x)
inline
Here is the caller graph for this function:

◆ get_conj() [2/2]

std::complex< double > LR_Util::get_conj ( const std::complex< double > &  x)
inline

◆ get_DMR_real_imag_part()

void LR_Util::get_DMR_real_imag_part ( const elecstate::DensityMatrix< std::complex< double >, std::complex< double > > &  DMR,
elecstate::DensityMatrix< std::complex< double >, double > &  DMR_real,
const int &  nat,
const char &  type 
)
Here is the caller graph for this function:

◆ get_psi_spin()

template<typename T >
psi::Psi< T > LR_Util::get_psi_spin ( const psi::Psi< T > &  psi_in,
const int &  is,
const int &  nk 
)

get the Psi wrapper of the selected spin from the Psi object

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

◆ grad() [1/2]

template<typename T >
void LR_Util::grad ( const std::vector< T > &  rhor,
std::vector< ModuleBase::Vector3< T > > &  gradrho,
const ModulePW::PW_Basis rho_basis,
const double &  tpiba 
)
Here is the call graph for this function:

◆ grad() [2/2]

template<typename T >
void LR_Util::grad ( const T rhor,
ModuleBase::Vector3< T > *  gradrho,
const ModulePW::PW_Basis rho_basis,
const double &  tpiba 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize_DMR()

template<typename T , typename TR >
void LR_Util::initialize_DMR ( elecstate::DensityMatrix< T, TR > &  dm,
const Parallel_Orbitals pmat,
const UnitCell ucell,
const Grid_Driver gd,
const std::vector< double > &  orb_cutoff 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize_HR()

template<typename T , typename TR >
void LR_Util::initialize_HR ( hamilt::HContainer< TR > &  hR,
const UnitCell ucell,
const Grid_Driver gd,
const std::vector< double > &  orb_cutoff 
)
Here is the call graph for this function:

◆ k1_to_bfirst_wrapper()

template<typename T , typename Device >
psi::Psi< T, Device > LR_Util::k1_to_bfirst_wrapper ( const psi::Psi< T, Device > &  psi_kfirst,
int  nk_in,
int  nbasis_in 
)

psi(nk=1, nbands=nb, nk * nbasis) -> psi(nb, nk, nbasis) without memory copy

===================Psi wrapper================= psi(nk=1, nbands=nb, nk * nbasis) -> psi(nb, nk, nbasis) without memory copy

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

◆ lapl() [1/2]

template<typename T >
void LR_Util::lapl ( const std::vector< T > &  rhor,
std::vector< T > &  lapn,
const ModulePW::PW_Basis rho_basis,
const double &  tpiba2 
)
Here is the call graph for this function:

◆ lapl() [2/2]

template<typename T >
void LR_Util::lapl ( const T rhor,
T lapn,
const ModulePW::PW_Basis rho_basis,
const double &  tpiba2 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_unique()

template<typename T , typename... Args>
std::unique_ptr< T > LR_Util::make_unique ( Args &&...  args)

=================ALGORITHM==================== for lack of make_unique in c++11

◆ matsym() [1/4]

template<typename T >
void LR_Util::matsym ( const T in,
const int  n,
const Parallel_2D pmat,
T out 
)

◆ matsym() [2/4]

template<typename T >
void LR_Util::matsym ( const T in,
const int  n,
T out 
)

================ BLAS ====================== calculate (A+A^T)/2

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

◆ matsym() [3/4]

template<typename T >
void LR_Util::matsym ( T inout,
const int  n 
)

calculate (A+A^T)/2 (in-place version)

Here is the call graph for this function:

◆ matsym() [4/4]

template<typename T >
void LR_Util::matsym ( T inout,
const int  n,
const Parallel_2D pmat 
)

◆ matsym< double >() [1/2]

template<>
void LR_Util::matsym< double > ( const double *  in,
const int  n,
const Parallel_2D pmat,
double *  out 
)

=================ALGORITHM====================

Here is the call graph for this function:

◆ matsym< double >() [2/2]

template<>
void LR_Util::matsym< double > ( double *  inout,
const int  n,
const Parallel_2D pmat 
)
Here is the call graph for this function:

◆ matsym< std::complex< double > >() [1/2]

template<>
void LR_Util::matsym< std::complex< double > > ( const std::complex< double > *  in,
const int  n,
const Parallel_2D pmat,
std::complex< double > *  out 
)
Here is the call graph for this function:

◆ matsym< std::complex< double > >() [2/2]

template<>
void LR_Util::matsym< std::complex< double > > ( std::complex< double > *  inout,
const int  n,
const Parallel_2D pmat 
)
Here is the call graph for this function:

◆ newTensor()

template<typename T >
ct::Tensor LR_Util::newTensor ( const ct::TensorShape shape)

◆ print_CsX()

template<typename T >
void LR_Util::print_CsX ( const TLRIX< T > &  CsX,
const int  nvirt,
const std::string &  label,
const double &  threshold = 1e-10 
)
Here is the call graph for this function:

◆ print_DMR()

template<typename TK , typename TR >
void LR_Util::print_DMR ( const elecstate::DensityMatrix< TK, TR > &  DMR,
const int &  nat,
const std::string &  label,
const double &  threshold = 1e-10 
)
Here is the call graph for this function:

◆ print_grid_nonzero()

template<typename T >
void LR_Util::print_grid_nonzero ( T rho,
const int &  nrxx,
const int &  nnz,
const std::string &  label,
const double &  threshold = 1e-5 
)

◆ print_HR()

template<typename TR >
void LR_Util::print_HR ( const hamilt::HContainer< TR > &  HR,
const int &  nat,
const std::string &  label,
const double &  threshold = 1e-10 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_psi_bandfirst()

template<typename T >
void LR_Util::print_psi_bandfirst ( const psi::Psi< T > &  psi,
const std::string &  label,
const int &  ib,
const double &  threshold = 1e-10 
)
Here is the call graph for this function:

◆ print_psi_kfirst()

template<typename T >
void LR_Util::print_psi_kfirst ( const psi::Psi< T > &  psi,
const std::string &  label,
const double &  threshold = 1e-10 
)
Here is the call graph for this function:

◆ print_tensor()

template<typename T >
void LR_Util::print_tensor ( const container::Tensor t,
const std::string &  label,
const Parallel_2D pmat,
const double &  threshold = 1e-10 
)
Here is the call graph for this function:

◆ print_value() [1/2]

template<typename T >
int LR_Util::print_value ( const T ptr,
const int &  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_value() [2/2]

template<typename T , typename... Args>
int LR_Util::print_value ( const T ptr,
const int &  size,
Args &&...  args 
)
Here is the call graph for this function:

◆ read_psi_bandfirst()

template<typename T >
psi::Psi< T > LR_Util::read_psi_bandfirst ( const std::string &  filename,
const int &  rank 
)
Here is the call graph for this function:

◆ read_value() [1/3]

template<typename T , typename... Args>
int LR_Util::read_value ( const std::string &  file,
T ptr,
const int &  size,
Args &&...  args 
)
Here is the call graph for this function:

◆ read_value() [2/3]

template<typename T >
int LR_Util::read_value ( std::ifstream &  ifs,
T ptr,
const int &  size 
)
Here is the caller graph for this function:

◆ read_value() [3/3]

template<typename T , typename... Args>
int LR_Util::read_value ( std::ifstream &  ifs,
T ptr,
const int &  size,
Args &&...  args 
)
Here is the call graph for this function:

◆ set_HR_real_imag_part()

void LR_Util::set_HR_real_imag_part ( const hamilt::HContainer< double > &  HR_real,
hamilt::HContainer< std::complex< double > > &  HR,
const int &  nat,
const char &  type 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_ix_map_diagonal()

std::pair< ModuleBase::matrix, std::vector< std::pair< int, int > > > LR_Util::set_ix_map_diagonal ( bool  mode,
int  nc,
int  nv 
)

set the index map: ix to (ic, iv) and vice versa by diagonal traverse the c-v pairs leftdown -> rightup for mode 0, rightup -> leftdown for mode 1

Parameters
mode0: homo-1 -> lumo first; 1: homo -> lumo+1 first
ncnumber of occupied bands
nvnumber of virtual bands
Returns
[iciv2ix, ix2iciv]
Here is the caller graph for this function:

◆ setup_2d_division() [1/2]

void LR_Util::setup_2d_division ( Parallel_2D pv,
int  nb,
int  gr,
int  gc 
)

=================2D-block Parallel===============

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

◆ setup_2d_division() [2/2]

void LR_Util::setup_2d_division ( Parallel_2D pv,
int  nb,
int  gr,
int  gc,
const int &  blacs_ctxt_in 
)
Here is the call graph for this function:

◆ tolower()

std::string LR_Util::tolower ( const std::string &  str)

=================string option====================

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

◆ toupper()

std::string LR_Util::toupper ( const std::string &  str)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_psi_bandfirst() [1/2]

template<typename T >
void LR_Util::write_psi_bandfirst ( const psi::Psi< T > &  psi,
const std::string &  filename,
const int &  rank,
const double &  threshold = 1e-10,
const int &  precision = 8 
)
Here is the call graph for this function:

◆ write_psi_bandfirst() [2/2]

template<typename T >
void LR_Util::write_psi_bandfirst ( const T psi,
const int &  nband,
const int &  nk,
const int &  nbasis,
const std::string &  filename,
const int &  rank,
const double &  threshold = 1e-10,
const int &  precision = 8 
)
Here is the call graph for this function:

◆ write_value() [1/3]

template<typename T , typename... Args>
int LR_Util::write_value ( const std::string &  file,
const int &  prec,
const T ptr,
const int &  size,
Args &&...  args 
)
Here is the call graph for this function:

◆ write_value() [2/3]

template<typename T >
int LR_Util::write_value ( std::ofstream &  ofs,
const T ptr,
const int &  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_value() [3/3]

template<typename T , typename... Args>
int LR_Util::write_value ( std::ofstream &  ofs,
const T ptr,
const int &  size,
Args &&...  args 
)
Here is the call graph for this function: