ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
hsolver::DiagoCG< T, Device > Class Template Referencefinal

#include <diago_cg.h>

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

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 diag_comm_info &diag_comm, const Real &pw_diag_thr, const int &pw_diag_nmax)
 ~DiagoCG ()
double diag (const HSOperator< T, Device > &op, const int ld_psi, const int nband, const int dim, T *psi_in, Real *eigenvalue_in, const std::vector< double > &ethr_band, const Real *prec=nullptr)

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_once (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
void diag_subspace (const T *psi_in, T *psi_out, const int dim, const int nband, const bool S_orth)
 subspace rotation of the current nband vectors (packed, leading dimension dim)

Private Attributes

Device * ctx_ = {}
int notconv_ = 0
int n_band_ = 0
int n_basis_ = 0
 col size for input psi matrix
double avg_iter_ = 0
 average iteration steps for cg diagonalization
std::vector< int > iter_band
 std::vector for iter count of each band
Real pw_diag_thr_ = 1e-5
 threshold for cg diagonalization
int pw_diag_nmax_ = 0
 maximum iteration steps for cg diagonalization
const diag_comm_info diag_comm_
 communicator of the pool sharing the plane waves
std::string basis_type_ = {}
 basis_type of psi
std::string calculation_ = {}
 calculation type of ABACUS
bool need_subspace_ = false
const HSOperator< T, Device > * op_ = nullptr
 The H and S operator being diagonalized, set for the duration of diag().
const T * one_ = nullptr
const T * zero_ = nullptr
const T * neg_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

◆ 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 diag_comm_info & diag_comm,
const Real & pw_diag_thr,
const int & pw_diag_nmax )

◆ ~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:
Here is the caller 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:
Here is the caller graph for this function:

◆ diag()

template<typename T, typename Device>
double hsolver::DiagoCG< T, Device >::diag ( const HSOperator< T, Device > & op,
const int ld_psi,
const int nband,
const int dim,
T * psi_in,
Real * eigenvalue_in,
const std::vector< double > & ethr_band,
const Real * prec = nullptr )

record the times of trying iterative diagonalization

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

◆ diag_once()

template<typename T, typename Device>
void DiagoCG::diag_once ( 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:
Here is the caller graph for this function:

◆ diag_subspace()

template<typename T, typename Device>
void DiagoCG::diag_subspace ( const T * psi_in,
T * psi_out,
const int dim,
const int nband,
const bool S_orth )
private

subspace rotation of the current nband vectors (packed, leading dimension dim)

Here is the call graph for this function:
Here is the caller 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:
Here is the caller 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:
Here is the caller 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
Here is the caller graph for this function:

◆ 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:
Here is the caller graph for this function:

Member Data Documentation

◆ avg_iter_

template<typename T, typename Device = base_device::DEVICE_CPU>
double 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

◆ diag_comm_

template<typename T, typename Device = base_device::DEVICE_CPU>
const diag_comm_info hsolver::DiagoCG< T, Device >::diag_comm_
private

communicator of the pool sharing the plane waves

◆ iter_band

template<typename T, typename Device = base_device::DEVICE_CPU>
std::vector<int> hsolver::DiagoCG< T, Device >::iter_band
private

std::vector for iter count of each band

◆ 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

◆ one_

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

◆ op_

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

The H and S operator being diagonalized, set for the duration of diag().

◆ 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

◆ 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: