ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
hamilt::AtomPair< T > Class Template Reference

#include <atom_pair.h>

Collaboration diagram for hamilt::AtomPair< T >:

Public Member Functions

 AtomPair (const int &atom_i_, const int &atom_j_, const Parallel_Orbitals *paraV_, T *existed_matrix=nullptr)
 
 AtomPair (const int &atom_i_, const int &atom_j_, const int &rx, const int &ry, const int &rz, const Parallel_Orbitals *paraV_, T *existed_array=nullptr)
 
 AtomPair (const int &atom_i_, const int &atom_j_, const ModuleBase::Vector3< int > &R_index, const Parallel_Orbitals *paraV_, T *existed_array=nullptr)
 
 AtomPair (const int &atom_i, const int &atom_j, const int *row_atom_begin, const int *col_atom_begin, const int &natom, T *existed_matrix=nullptr)
 
 AtomPair (const int &atom_i, const int &atom_j, const int &rx, const int &ry, const int &rz, const int *row_atom_begin, const int *col_atom_begin, const int &natom, T *existed_matrix=nullptr)
 
 AtomPair (const AtomPair< T > &other, T *data_pointer=nullptr)
 
 AtomPair (AtomPair &&other) noexcept
 
 AtomPair (const int &atom_i_, const int &atom_j_)
 
 ~AtomPair ()
 
void allocate (T *data_array=nullptr, bool if_zero=false)
 allocate memory for all the BaseMatrix
 
void set_zero ()
 set values in every BaseMatrix to zero
 
int get_begin_row () const
 get begin index of this AtomPair
 
int get_begin_col () const
 
int get_col_size () const
 get col_size for this AtomPair
 
int get_row_size () const
 get row_size for this AtomPair
 
int get_atom_i () const
 get atom_i and atom_j for this AtomPair
 
int get_atom_j () const
 
void set_size (const int &col_size_in, const int &row_size_in)
 set col_size and row_size
 
int get_size () const
 get size = col_size * row_size
 
const Parallel_Orbitalsget_paraV () const
 get Parallel_Orbitals pointer of this AtomPair for checking 2d-block parallel
 
void set_paraV (const Parallel_Orbitals *paraV_in)
 set Parallel_Orbitals pointer of this AtomPair for checking 2d-block parallel
 
bool identify (const AtomPair< T > &other) const
 use atom_i and atom_j to identify the atom-pair
 
bool identify (const int &atom_i_, const int &atom_j_) const
 
BaseMatrix< T > & get_HR_values (int rx_in, int ry_in, int rz_in)
 get target BaseMatrix of target cell for const AtomPair, it will return a const BaseMatrix<T> object, and if not found, it will throw a error message for non-const AtomPair, it will return a BaseMatrix<T> object, and if not found, it will insert a new one and return it
 
const BaseMatrix< T > & get_HR_values (int rx_in, int ry_in, int rz_in) const
 
BaseMatrix< T > & get_HR_values (const int &index) const
 get target BaseMatrix of index of this->values it will return a BaseMatrix<T> object, and if not found, it will throw a error message
 
ModuleBase::Vector3< int > get_R_index (const int &index) const
 
ModuleBase::Vector3< int > get_R_index () const
 
int find_R (const int &rx_in, const int &ry_in, const int &rz_in) const
 
int find_R (const ModuleBase::Vector3< int > &R_in) const
 
const BaseMatrix< T > * find_matrix (const int &rx_in, const int &ry_in, const int &rz_in) const
 
BaseMatrix< T > * find_matrix (const int &rx_in, const int &ry_in, const int &rz_in)
 
const BaseMatrix< T > * find_matrix (const ModuleBase::Vector3< int > &R_in) const
 
BaseMatrix< T > * find_matrix (const ModuleBase::Vector3< int > &R_in)
 
Tget_value (const int &i) const
 
Tget_value (const int &row, const int &col) const
 
std::tuple< std::vector< int >, T * > get_matrix_values (int ir=-1) const
 get values of this->values[ir] for a whole matrix
 
Tget_pointer (int ir=-1) const
 get pointer of value from a submatrix
 
void convert_add (const BaseMatrix< T > &target, int rx_in, int ry_in, int rz_in)
 
void merge (const AtomPair< T > &other, bool skip_R=false)
 merge another AtomPair to this AtomPair
 
void merge_to_gamma ()
 merge all values in this AtomPair to one BaseMatrix with R-index (0, 0, 0) in this case, H_gamma = sum_{R} H_R will be saved in this->values[0]
 
void add_to_matrix (std::complex< T > *hk, const int ld_hk, const std::complex< T > &kphase, const int hk_type=0) const
 Add this->value[current_R] * kphase as a block matrix of hk.
 
void add_to_matrix (T *hk, const int ld_hk, const T &kphase, const int hk_type=0) const
 Add this->value[current_R] * kphase as a block matrix of hk. for non-collinear spin case only.
 
void add_from_matrix (const std::complex< T > *hk, const int ld_hk, const std::complex< T > &kphase, const int hk_type=0)
 
void add_from_matrix (const T *hk, const int ld_hk, const T &kphase, const int hk_type=0)
 
void add_to_array (std::complex< T > *target_array, const std::complex< T > &kphase) const
 Add this->value[current_R] * kphase to an array. T = double or float.
 
void add_to_array (T *target_array, const T &kphase) const
 Add this->value[current_R] * kphase to an array. for non-collinear spin case only (T = std::complex<double> or complex<float>)
 
bool operator< (const AtomPair &other) const
 
AtomPairoperator= (const AtomPair &other)
 
AtomPairoperator= (AtomPair &&other) noexcept
 
size_t get_R_size () const
 
size_t get_memory_size () const
 get total memory size of AtomPair
 

Private Attributes

std::vector< ModuleBase::Vector3< int > > R_index
 
std::vector< BaseMatrix< T > > values
 
const Parallel_OrbitalsparaV = nullptr
 
int current_R = 0
 
int atom_i = -1
 
int atom_j = -1
 
int row_ap = -1
 
int col_ap = -1
 
int row_size = 0
 
int col_size = 0
 

Detailed Description

template<typename T>
class hamilt::AtomPair< T >

Class: AtomPair

the simplest way to use this class is:
{
    AtomPair<T> atom_pair(atom_i, atom_j);
    atom_pair.set_size(row_size, col_size);
    const int rx = 0, ry = 0, rz = 0;
    auto tmp_matrix = atom_pair.get_HR_values(rx, ry, rz);
  1. save array to tmp_matrix std::vector<T> local_matrix_ij = ...; tmp_matrix.add_array(local_matrix_ij.data());
  2. get pointer of tmp_matrix and save array to it T* tmp_matrix_pointer = tmp_matrix.get_pointer(); for(int orb_i = 0;orb_i

Constructor & Destructor Documentation

◆ AtomPair() [1/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( const int &  atom_i_,
const int &  atom_j_,
const Parallel_Orbitals paraV_,
T existed_matrix = nullptr 
)
Here is the call graph for this function:

◆ AtomPair() [2/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( const int &  atom_i_,
const int &  atom_j_,
const int &  rx,
const int &  ry,
const int &  rz,
const Parallel_Orbitals paraV_,
T existed_array = nullptr 
)
Here is the call graph for this function:

◆ AtomPair() [3/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( const int &  atom_i_,
const int &  atom_j_,
const ModuleBase::Vector3< int > &  R_index,
const Parallel_Orbitals paraV_,
T existed_array = nullptr 
)
Here is the call graph for this function:

◆ AtomPair() [4/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( const int &  atom_i,
const int &  atom_j,
const int *  row_atom_begin,
const int *  col_atom_begin,
const int &  natom,
T existed_matrix = nullptr 
)

◆ AtomPair() [5/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( const int &  atom_i,
const int &  atom_j,
const int &  rx,
const int &  ry,
const int &  rz,
const int *  row_atom_begin,
const int *  col_atom_begin,
const int &  natom,
T existed_matrix = nullptr 
)

◆ AtomPair() [6/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( const AtomPair< T > &  other,
T data_pointer = nullptr 
)
Here is the call graph for this function:

◆ AtomPair() [7/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( AtomPair< T > &&  other)
noexcept

◆ AtomPair() [8/8]

template<typename T >
hamilt::AtomPair< T >::AtomPair ( const int &  atom_i_,
const int &  atom_j_ 
)

◆ ~AtomPair()

template<typename T >
hamilt::AtomPair< T >::~AtomPair ( )

Member Function Documentation

◆ add_from_matrix() [1/2]

template<typename T >
void hamilt::AtomPair< T >::add_from_matrix ( const std::complex< T > *  hk,
const int  ld_hk,
const std::complex< T > &  kphase,
const int  hk_type = 0 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_from_matrix() [2/2]

template<typename T >
void hamilt::AtomPair< T >::add_from_matrix ( const T hk,
const int  ld_hk,
const T kphase,
const int  hk_type = 0 
)
Here is the call graph for this function:

◆ add_to_array() [1/2]

template<typename T >
void hamilt::AtomPair< T >::add_to_array ( std::complex< T > *  target_array,
const std::complex< T > &  kphase 
) const

Add this->value[current_R] * kphase to an array. T = double or float.

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

◆ add_to_array() [2/2]

template<typename T >
void hamilt::AtomPair< T >::add_to_array ( T target_array,
const T kphase 
) const

Add this->value[current_R] * kphase to an array. for non-collinear spin case only (T = std::complex<double> or complex<float>)

Here is the call graph for this function:

◆ add_to_matrix() [1/2]

template<typename T >
void hamilt::AtomPair< T >::add_to_matrix ( std::complex< T > *  hk,
const int  ld_hk,
const std::complex< T > &  kphase,
const int  hk_type = 0 
) const

Add this->value[current_R] * kphase as a block matrix of hk.

For row major dense matrix (hk_type == 0): value[current_R][i*col_size+j] -> hk[(row_ap+i) * ld_hk + col_ap + j] For column major dense matrix (hk_type == 1): value[current_R][i*col_size+j] -> hk[row_ap + i + (col_ap+j) * ld_hk] For sparse matrix (hk_type == 2): not implemented yet

Parameters
hkPointer to the target matrix.
ld_hkLeading dimension of the target matrix.
kphaseComplex scalar to be multiplied with the block matrix.
hk_typeThe type of matrix layout (default: 0).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_to_matrix() [2/2]

template<typename T >
void hamilt::AtomPair< T >::add_to_matrix ( T hk,
const int  ld_hk,
const T kphase,
const int  hk_type = 0 
) const

Add this->value[current_R] * kphase as a block matrix of hk. for non-collinear spin case only.

Here is the call graph for this function:

◆ allocate()

template<typename T >
void hamilt::AtomPair< T >::allocate ( T data_array = nullptr,
bool  if_zero = false 
)

allocate memory for all the BaseMatrix

Here is the caller graph for this function:

◆ convert_add()

template<typename T >
void hamilt::AtomPair< T >::convert_add ( const BaseMatrix< T > &  target,
int  rx_in,
int  ry_in,
int  rz_in 
)
Here is the call graph for this function:

◆ find_matrix() [1/4]

template<typename T >
BaseMatrix< T > * hamilt::AtomPair< T >::find_matrix ( const int &  rx_in,
const int &  ry_in,
const int &  rz_in 
)

◆ find_matrix() [2/4]

template<typename T >
const BaseMatrix< T > * hamilt::AtomPair< T >::find_matrix ( const int &  rx_in,
const int &  ry_in,
const int &  rz_in 
) const
Here is the caller graph for this function:

◆ find_matrix() [3/4]

template<typename T >
BaseMatrix< T > * hamilt::AtomPair< T >::find_matrix ( const ModuleBase::Vector3< int > &  R_in)

◆ find_matrix() [4/4]

template<typename T >
const BaseMatrix< T > * hamilt::AtomPair< T >::find_matrix ( const ModuleBase::Vector3< int > &  R_in) const

◆ find_R() [1/2]

template<typename T >
int hamilt::AtomPair< T >::find_R ( const int &  rx_in,
const int &  ry_in,
const int &  rz_in 
) const
Here is the caller graph for this function:

◆ find_R() [2/2]

template<typename T >
int hamilt::AtomPair< T >::find_R ( const ModuleBase::Vector3< int > &  R_in) const

◆ get_atom_i()

template<typename T >
int hamilt::AtomPair< T >::get_atom_i ( ) const

get atom_i and atom_j for this AtomPair

Here is the caller graph for this function:

◆ get_atom_j()

template<typename T >
int hamilt::AtomPair< T >::get_atom_j ( ) const
Here is the caller graph for this function:

◆ get_begin_col()

template<typename T >
int hamilt::AtomPair< T >::get_begin_col ( ) const
inline
Here is the caller graph for this function:

◆ get_begin_row()

template<typename T >
int hamilt::AtomPair< T >::get_begin_row ( ) const
inline

get begin index of this AtomPair

Here is the caller graph for this function:

◆ get_col_size()

template<typename T >
int hamilt::AtomPair< T >::get_col_size ( ) const

get col_size for this AtomPair

Here is the caller graph for this function:

◆ get_HR_values() [1/3]

template<typename T >
BaseMatrix< T > & hamilt::AtomPair< T >::get_HR_values ( const int &  index) const

get target BaseMatrix of index of this->values it will return a BaseMatrix<T> object, and if not found, it will throw a error message

Parameters
indexindex of this->values
Returns
BaseMatrix<T>&

◆ get_HR_values() [2/3]

template<typename T >
BaseMatrix< T > & hamilt::AtomPair< T >::get_HR_values ( int  rx_in,
int  ry_in,
int  rz_in 
)

get target BaseMatrix of target cell for const AtomPair, it will return a const BaseMatrix<T> object, and if not found, it will throw a error message for non-const AtomPair, it will return a BaseMatrix<T> object, and if not found, it will insert a new one and return it

Parameters
rx_inx coordinate of cell
ry_iny coordinate of cell
rz_inz coordinate of cell
Returns
BaseMatrix<T>&
Here is the caller graph for this function:

◆ get_HR_values() [3/3]

template<typename T >
const BaseMatrix< T > & hamilt::AtomPair< T >::get_HR_values ( int  rx_in,
int  ry_in,
int  rz_in 
) const

◆ get_matrix_values()

template<typename T >
std::tuple< std::vector< int >, T * > hamilt::AtomPair< T >::get_matrix_values ( int  ir = -1) const

get values of this->values[ir] for a whole matrix

Parameters
irindex of this->values
Returns
std::tuple<std::vector<int>, T*> std::vector<int>(4) contains (row_begin_index, row_size, col_begin_index, col_size) T* is pointer of values[ir].value_begin, legal index is [0, row_size*col_size)
Here is the caller graph for this function:

◆ get_memory_size()

template<typename T >
size_t hamilt::AtomPair< T >::get_memory_size ( ) const

get total memory size of AtomPair

◆ get_paraV()

template<typename T >
const Parallel_Orbitals * hamilt::AtomPair< T >::get_paraV ( ) const

get Parallel_Orbitals pointer of this AtomPair for checking 2d-block parallel

Returns
const Parallel_Orbitals*
Here is the caller graph for this function:

◆ get_pointer()

template<typename T >
T * hamilt::AtomPair< T >::get_pointer ( int  ir = -1) const

get pointer of value from a submatrix

Here is the caller graph for this function:

◆ get_R_index() [1/2]

template<typename T >
ModuleBase::Vector3< int > hamilt::AtomPair< T >::get_R_index ( ) const

◆ get_R_index() [2/2]

template<typename T >
ModuleBase::Vector3< int > hamilt::AtomPair< T >::get_R_index ( const int &  index) const
Here is the caller graph for this function:

◆ get_R_size()

template<typename T >
size_t hamilt::AtomPair< T >::get_R_size ( ) const
inline
Here is the caller graph for this function:

◆ get_row_size()

template<typename T >
int hamilt::AtomPair< T >::get_row_size ( ) const

get row_size for this AtomPair

Here is the caller graph for this function:

◆ get_size()

template<typename T >
int hamilt::AtomPair< T >::get_size ( ) const
inline

get size = col_size * row_size

Returns
int
Here is the caller graph for this function:

◆ get_value() [1/2]

template<typename T >
T & hamilt::AtomPair< T >::get_value ( const int &  i) const
Here is the caller graph for this function:

◆ get_value() [2/2]

template<typename T >
T & hamilt::AtomPair< T >::get_value ( const int &  row,
const int &  col 
) const

◆ identify() [1/2]

template<typename T >
bool hamilt::AtomPair< T >::identify ( const AtomPair< T > &  other) const

use atom_i and atom_j to identify the atom-pair

Here is the caller graph for this function:

◆ identify() [2/2]

template<typename T >
bool hamilt::AtomPair< T >::identify ( const int &  atom_i_,
const int &  atom_j_ 
) const

◆ merge()

template<typename T >
void hamilt::AtomPair< T >::merge ( const AtomPair< T > &  other,
bool  skip_R = false 
)

merge another AtomPair to this AtomPair

Parameters
otherAnother AtomPair
Here is the call graph for this function:

◆ merge_to_gamma()

template<typename T >
void hamilt::AtomPair< T >::merge_to_gamma ( )

merge all values in this AtomPair to one BaseMatrix with R-index (0, 0, 0) in this case, H_gamma = sum_{R} H_R will be saved in this->values[0]

Here is the call graph for this function:

◆ operator<()

template<typename T >
bool hamilt::AtomPair< T >::operator< ( const AtomPair< T > &  other) const

◆ operator=() [1/2]

template<typename T >
AtomPair< T > & hamilt::AtomPair< T >::operator= ( AtomPair< T > &&  other)
noexcept

◆ operator=() [2/2]

template<typename T >
AtomPair< T > & hamilt::AtomPair< T >::operator= ( const AtomPair< T > &  other)

◆ set_paraV()

template<typename T >
void hamilt::AtomPair< T >::set_paraV ( const Parallel_Orbitals paraV_in)
inline

set Parallel_Orbitals pointer of this AtomPair for checking 2d-block parallel

◆ set_size()

template<typename T >
void hamilt::AtomPair< T >::set_size ( const int &  col_size_in,
const int &  row_size_in 
)

set col_size and row_size

Here is the caller graph for this function:

◆ set_zero()

template<typename T >
void hamilt::AtomPair< T >::set_zero ( )

set values in every BaseMatrix to zero

Member Data Documentation

◆ atom_i

template<typename T >
int hamilt::AtomPair< T >::atom_i = -1
private

◆ atom_j

template<typename T >
int hamilt::AtomPair< T >::atom_j = -1
private

◆ col_ap

template<typename T >
int hamilt::AtomPair< T >::col_ap = -1
private

◆ col_size

template<typename T >
int hamilt::AtomPair< T >::col_size = 0
private

◆ current_R

template<typename T >
int hamilt::AtomPair< T >::current_R = 0
mutableprivate

◆ paraV

template<typename T >
const Parallel_Orbitals* hamilt::AtomPair< T >::paraV = nullptr
private

◆ R_index

template<typename T >
std::vector<ModuleBase::Vector3<int> > hamilt::AtomPair< T >::R_index
private

◆ row_ap

template<typename T >
int hamilt::AtomPair< T >::row_ap = -1
private

◆ row_size

template<typename T >
int hamilt::AtomPair< T >::row_size = 0
private

◆ values

template<typename T >
std::vector<BaseMatrix<T> > hamilt::AtomPair< T >::values
private

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