ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
hsolver::DiagoCG< T, Device > Class Template Referencefinal

#include <diago_cg.h>

Collaboration diagram for hsolver::DiagoCG< T, Device >:

Public Types

using Func = std::function< void(const ct::Tensor &, ct::Tensor &)>
 

Public Member Functions

 DiagoCG (const std::string &basis_type, const std::string &calculation)
 
 DiagoCG (const std::string &basis_type, const std::string &calculation, const bool &need_subspace, const Func &subspace_func, const Real &pw_diag_thr, const int &pw_diag_nmax, const int &nproc_in_pool)
 
 ~DiagoCG ()
 
void diag (const Func &hpsi_func, const Func &spsi_func, ct::Tensor &psi, ct::Tensor &eigen, const std::vector< double > &ethr_band, const ct::Tensor &prec={})
 

Private Types

using Real = typename GetTypeReal< T >::type
 
using ct_Device = typename ct::PsiToContainer< Device >::type
 
using dot_real_op = ModuleBase::dot_real_op< T, Device >
 

Private Member Functions

void calc_grad (const ct::Tensor &prec, ct::Tensor &grad, ct::Tensor &hphi, ct::Tensor &sphi, ct::Tensor &pphi)
 
void orth_grad (const ct::Tensor &psi, const int &m, ct::Tensor &grad, ct::Tensor &scg, ct::Tensor &lagrange)
 
void calc_gamma_cg (const int &iter, const Real &cg_norm, const Real &theta, const ct::Tensor &prec, const ct::Tensor &scg, const ct::Tensor &grad, const ct::Tensor &phi_m, Real &gg_last, ct::Tensor &g0, ct::Tensor &cg)
 
bool update_psi (const ct::Tensor &pphi, const ct::Tensor &cg, const ct::Tensor &scg, const double &ethreshold, Real &cg_norm, Real &theta, Real &eigen, ct::Tensor &phi_m, ct::Tensor &sphi, ct::Tensor &hphi)
 
void schmit_orth (const int &m, const ct::Tensor &psi, const ct::Tensor &sphi, ct::Tensor &phi_m)
 
void diag_mock (const ct::Tensor &prec, ct::Tensor &psi, ct::Tensor &eigen, const std::vector< double > &ethr_band)
 
bool test_exit_cond (const int &ntry, const int &notconv) const
 

Private Attributes

Device * ctx_ = {}
 
int notconv_ = 0
 
int n_band_ = 0
 
int n_basis_ = 0
 col size for input psi matrix
 
int avg_iter_ = 0
 average iteration steps for cg diagonalization
 
Real pw_diag_thr_ = 1e-5
 threshold for cg diagonalization
 
int pw_diag_nmax_ = 0
 maximum iteration steps for cg diagonalization
 
int nproc_in_pool_ = 0
 number of processors in a node
 
std::string basis_type_ = {}
 basis_type of psi
 
std::string calculation_ = {}
 calculation type of ABACUS
 
bool need_subspace_ = false
 
std::function< void(const ct::Tensor &, ct::Tensor &)> hpsi_func_ = nullptr
 A function object that performs the hPsi calculation.
 
std::function< void(const ct::Tensor &, ct::Tensor &)> spsi_func_ = nullptr
 A function object that performs the sPsi calculation.
 
std::function< void(const ct::Tensor &, ct::Tensor &)> subspace_func_ = nullptr
 A function object that performs the subspace calculation.
 
const Tone_ = nullptr
 
const Tzero_ = nullptr
 
const Tneg_one_ = nullptr
 

Member Typedef Documentation

◆ ct_Device

template<typename T , typename Device = base_device::DEVICE_CPU>
using hsolver::DiagoCG< T, Device >::ct_Device = typename ct::PsiToContainer<Device>::type
private

◆ dot_real_op

template<typename T , typename Device = base_device::DEVICE_CPU>
using hsolver::DiagoCG< T, Device >::dot_real_op = ModuleBase::dot_real_op<T, Device>
private

◆ Func

template<typename T , typename Device = base_device::DEVICE_CPU>
using hsolver::DiagoCG< T, Device >::Func = std::function<void(const ct::Tensor&, ct::Tensor&)>

◆ Real

template<typename T , typename Device = base_device::DEVICE_CPU>
using hsolver::DiagoCG< T, Device >::Real = typename GetTypeReal<T>::type
private

Constructor & Destructor Documentation

◆ DiagoCG() [1/2]

template<typename T , typename Device >
hsolver::DiagoCG< T, Device >::DiagoCG ( const std::string &  basis_type,
const std::string &  calculation 
)

◆ DiagoCG() [2/2]

template<typename T , typename Device >
hsolver::DiagoCG< T, Device >::DiagoCG ( const std::string &  basis_type,
const std::string &  calculation,
const bool &  need_subspace,
const Func subspace_func,
const Real pw_diag_thr,
const int &  pw_diag_nmax,
const int &  nproc_in_pool 
)

◆ ~DiagoCG()

template<typename T , typename Device >
hsolver::DiagoCG< T, Device >::~DiagoCG ( )

Member Function Documentation

◆ calc_gamma_cg()

template<typename T , typename Device >
void DiagoCG::calc_gamma_cg ( const int &  iter,
const Real cg_norm,
const Real theta,
const ct::Tensor prec,
const ct::Tensor scg,
const ct::Tensor grad,
const ct::Tensor phi_m,
Real gg_last,
ct::Tensor g0,
ct::Tensor cg 
)
private
Here is the call graph for this function:

◆ calc_grad()

template<typename T , typename Device >
void DiagoCG::calc_grad ( const ct::Tensor prec,
ct::Tensor grad,
ct::Tensor hphi,
ct::Tensor sphi,
ct::Tensor pphi 
)
private
Here is the call graph for this function:

◆ diag()

template<typename T , typename Device >
void hsolver::DiagoCG< T, Device >::diag ( const Func hpsi_func,
const Func spsi_func,
ct::Tensor psi,
ct::Tensor eigen,
const std::vector< double > &  ethr_band,
const ct::Tensor prec = {} 
)

record the times of trying iterative diagonalization

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

◆ diag_mock()

template<typename T , typename Device >
void DiagoCG::diag_mock ( const ct::Tensor prec,
ct::Tensor psi,
ct::Tensor eigen,
const std::vector< double > &  ethr_band 
)
private

out : record for states of convergence

initialize variables

record for how many loops in cg convergence

Here is the call graph for this function:

◆ orth_grad()

template<typename T , typename Device >
void DiagoCG::orth_grad ( const ct::Tensor psi,
const int &  m,
ct::Tensor grad,
ct::Tensor scg,
ct::Tensor lagrange 
)
private
Here is the call graph for this function:

◆ schmit_orth()

template<typename T , typename Device >
void DiagoCG::schmit_orth ( const int &  m,
const ct::Tensor psi,
const ct::Tensor sphi,
ct::Tensor phi_m 
)
private
Here is the call graph for this function:

◆ test_exit_cond()

template<typename T , typename Device >
bool DiagoCG::test_exit_cond ( const int &  ntry,
const int &  notconv 
) const
private

◆ update_psi()

template<typename T , typename Device >
bool DiagoCG::update_psi ( const ct::Tensor pphi,
const ct::Tensor cg,
const ct::Tensor scg,
const double &  ethreshold,
Real cg_norm,
Real theta,
Real eigen,
ct::Tensor phi_m,
ct::Tensor sphi,
ct::Tensor hphi 
)
private
Here is the call graph for this function:

Member Data Documentation

◆ avg_iter_

template<typename T , typename Device = base_device::DEVICE_CPU>
int hsolver::DiagoCG< T, Device >::avg_iter_ = 0
private

average iteration steps for cg diagonalization

◆ basis_type_

template<typename T , typename Device = base_device::DEVICE_CPU>
std::string hsolver::DiagoCG< T, Device >::basis_type_ = {}
private

basis_type of psi

◆ calculation_

template<typename T , typename Device = base_device::DEVICE_CPU>
std::string hsolver::DiagoCG< T, Device >::calculation_ = {}
private

calculation type of ABACUS

◆ ctx_

template<typename T , typename Device = base_device::DEVICE_CPU>
Device* hsolver::DiagoCG< T, Device >::ctx_ = {}
private

◆ hpsi_func_

template<typename T , typename Device = base_device::DEVICE_CPU>
std::function<void(const ct::Tensor&, ct::Tensor&)> hsolver::DiagoCG< T, Device >::hpsi_func_ = nullptr
private

A function object that performs the hPsi calculation.

◆ n_band_

template<typename T , typename Device = base_device::DEVICE_CPU>
int hsolver::DiagoCG< T, Device >::n_band_ = 0
private

inside variables and vectors, used by inside functions. row size for input psi matrix

◆ n_basis_

template<typename T , typename Device = base_device::DEVICE_CPU>
int hsolver::DiagoCG< T, Device >::n_basis_ = 0
private

col size for input psi matrix

◆ need_subspace_

template<typename T , typename Device = base_device::DEVICE_CPU>
bool hsolver::DiagoCG< T, Device >::need_subspace_ = false
private

◆ neg_one_

template<typename T , typename Device = base_device::DEVICE_CPU>
const T * hsolver::DiagoCG< T, Device >::neg_one_ = nullptr
private

◆ notconv_

template<typename T , typename Device = base_device::DEVICE_CPU>
int hsolver::DiagoCG< T, Device >::notconv_ = 0
private

static variables, used for passing control variables record for how many bands not have convergence eigenvalues

◆ nproc_in_pool_

template<typename T , typename Device = base_device::DEVICE_CPU>
int hsolver::DiagoCG< T, Device >::nproc_in_pool_ = 0
private

number of processors in a node

◆ one_

template<typename T , typename Device = base_device::DEVICE_CPU>
const T* hsolver::DiagoCG< T, Device >::one_ = nullptr
private

◆ pw_diag_nmax_

template<typename T , typename Device = base_device::DEVICE_CPU>
int hsolver::DiagoCG< T, Device >::pw_diag_nmax_ = 0
private

maximum iteration steps for cg diagonalization

◆ pw_diag_thr_

template<typename T , typename Device = base_device::DEVICE_CPU>
Real hsolver::DiagoCG< T, Device >::pw_diag_thr_ = 1e-5
private

threshold for cg diagonalization

◆ spsi_func_

template<typename T , typename Device = base_device::DEVICE_CPU>
std::function<void(const ct::Tensor&, ct::Tensor&)> hsolver::DiagoCG< T, Device >::spsi_func_ = nullptr
private

A function object that performs the sPsi calculation.

◆ subspace_func_

template<typename T , typename Device = base_device::DEVICE_CPU>
std::function<void(const ct::Tensor&, ct::Tensor&)> hsolver::DiagoCG< T, Device >::subspace_func_ = nullptr
private

A function object that performs the subspace calculation.

◆ zero_

template<typename T , typename Device = base_device::DEVICE_CPU>
const T * hsolver::DiagoCG< T, Device >::zero_ = nullptr
private

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