ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
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 AtomBasisView &rows, const AtomBasisView &cols, T *existed_matrix)
 AtomPair (const int &atom_i, const int &atom_j, const ModuleBase::Vector3< int > &R_index, const AtomBasisView &rows, const AtomBasisView &cols, T *existed_matrix)
 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_Orbitals * get_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
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)
T & get_value (const int R_index, const int &i) const
 Get value at position i in the matrix values[R_index]. Thread-safe version: explicitly pass R_index.
T & get_value (const int R_index, const int &row, const int &col) const
 Get value at position (row, col) in the matrix values[R_index]. Thread-safe version: explicitly pass R_index.
std::tuple< std::vector< int >, T * > get_matrix_values (int ir) const
 get values of this->values[ir] for a whole matrix
T * get_pointer (int ir) 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 (const int R_index, std::complex< T > *hk, const int ld_hk, const std::complex< T > &kphase, const int hk_type=0) const
 Add this->value[R_index] * kphase as a block matrix of hk. Thread-safe version: explicitly pass R_index.
void add_to_matrix (const int R_index, T *hk, const int ld_hk, const T &kphase, const int hk_type=0) const
 Add this->value[R_index] * kphase as a block matrix of hk. Thread-safe version: explicitly pass R_index. 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_from_matrix (const int R_index, const std::complex< T > *hk, const int ld_hk, const std::complex< T > &kphase, const int hk_type=0)
 Add data from hk to this->value[R_index]. Thread-safe version: explicitly pass R_index.
void add_from_matrix (const int R_index, const T *hk, const int ld_hk, const T &kphase, const int hk_type=0)
 Add data from hk to this->value[R_index]. Thread-safe version: explicitly pass R_index. for non-collinear spin case only.
void add_to_array (const int R_index, std::complex< T > *target_array, const std::complex< T > &kphase) const
 Add this->value[R_index] * kphase to an array. Thread-safe version: explicitly pass R_index. T = double or float.
void add_to_array (const int R_index, T *target_array, const T &kphase) const
 Add this->value[R_index] * kphase to an array. Thread-safe version: explicitly pass R_index. for non-collinear spin case only (T = std::complex<double> or complex<float>).
bool operator< (const AtomPair &other) const
AtomPair & operator= (const AtomPair &other)
AtomPair & operator= (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_Orbitals * paraV = nullptr
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/10]

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 caller graph for this function:

◆ AtomPair() [2/10]

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 )

◆ AtomPair() [3/10]

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 )

◆ AtomPair() [4/10]

template<typename T>
hamilt::AtomPair< T >::AtomPair ( const int & atom_i,
const int & atom_j,
const AtomBasisView & rows,
const AtomBasisView & cols,
T * existed_matrix )
Here is the call graph for this function:

◆ AtomPair() [5/10]

template<typename T>
hamilt::AtomPair< T >::AtomPair ( const int & atom_i,
const int & atom_j,
const ModuleBase::Vector3< int > & R_index,
const AtomBasisView & rows,
const AtomBasisView & cols,
T * existed_matrix )
Here is the call graph for this function:

◆ AtomPair() [6/10]

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() [7/10]

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() [8/10]

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

◆ AtomPair() [9/10]

template<typename T>
hamilt::AtomPair< T >::AtomPair ( AtomPair< T > && other)
noexcept
Here is the call graph for this function:

◆ AtomPair() [10/10]

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/4]

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

Add data from hk to this->value[R_index]. Thread-safe version: explicitly pass R_index.

Parameters
R_indexIndex of the R vector in this->values
hkPointer to the source matrix.
ld_hkLeading dimension of the source matrix.
kphaseComplex scalar to be multiplied with the source matrix.
hk_typeThe type of matrix layout (default: 0).
Here is the call graph for this function:

◆ add_from_matrix() [2/4]

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

Add data from hk to this->value[R_index]. Thread-safe version: explicitly pass R_index. for non-collinear spin case only.

Parameters
R_indexIndex of the R vector in this->values
hkPointer to the source matrix.
ld_hkLeading dimension of the source matrix.
kphaseScalar to be multiplied with the source matrix.
hk_typeThe type of matrix layout (default: 0).
Here is the call graph for this function:

◆ add_from_matrix() [3/4]

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() [4/4]

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 ( const int R_index,
std::complex< T > * target_array,
const std::complex< T > & kphase ) const

Add this->value[R_index] * kphase to an array. Thread-safe version: explicitly pass R_index. T = double or float.

Parameters
R_indexIndex of the R vector in this->values
target_arrayPointer to the target array.
kphaseScalar to be multiplied with the block matrix.
Here is the caller graph for this function:

◆ add_to_array() [2/2]

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

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

Parameters
R_indexIndex of the R vector in this->values
target_arrayPointer to the target array.
kphaseScalar to be multiplied with the block matrix.

◆ add_to_matrix() [1/2]

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

Add this->value[R_index] * kphase as a block matrix of hk. Thread-safe version: explicitly pass R_index.

For row major dense matrix (hk_type == 0): value[R_index][i*col_size+j] -> hk[(row_ap+i) * ld_hk + col_ap + j] For column major dense matrix (hk_type == 1): value[R_index][i*col_size+j] -> hk[row_ap + i + (col_ap+j) * ld_hk]

Parameters
R_indexIndex of the R vector in this->values
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 ( const int R_index,
T * hk,
const int ld_hk,
const T & kphase,
const int hk_type = 0 ) const

Add this->value[R_index] * kphase as a block matrix of hk. Thread-safe version: explicitly pass R_index. for non-collinear spin case only.

Parameters
R_indexIndex of the R vector in this->values
hkPointer to the target matrix.
ld_hkLeading dimension of the target matrix.
kphaseScalar to be multiplied with the block matrix.
hk_typeThe type of matrix layout (default: 0).
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 call graph for this function:
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 )
Here is the call graph for this function:

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

◆ find_matrix() [4/4]

template<typename T>
const BaseMatrix< T > * hamilt::AtomPair< T >::find_matrix ( const ModuleBase::Vector3< int > & R_in) const
Here is the call graph for this function:

◆ 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

◆ get_atom_j()

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

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

◆ get_matrix_values()

template<typename T>
std::tuple< std::vector< int >, T * > hamilt::AtomPair< T >::get_matrix_values ( int ir) 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) const

get pointer of value from a submatrix

Parameters
irindex of this->values
Here is the caller graph for this function:

◆ get_R_index()

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 R_index,
const int & i ) const

Get value at position i in the matrix values[R_index]. Thread-safe version: explicitly pass R_index.

Parameters
R_indexIndex of the R vector in this->values
iPosition in the flattened matrix (row * col_size + col)
Returns
T& Reference to the value
Here is the caller graph for this function:

◆ get_value() [2/2]

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

Get value at position (row, col) in the matrix values[R_index]. Thread-safe version: explicitly pass R_index.

Parameters
R_indexIndex of the R vector in this->values
rowRow index
colColumn index
Returns
T& Reference to the value

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

◆ operator=() [1/2]

template<typename T>
AtomPair< T > & hamilt::AtomPair< T >::operator= ( AtomPair< T > && other)
noexcept
Here is the call graph for this function:

◆ operator=() [2/2]

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

◆ 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

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