|
| ~HContainer () |
|
| HContainer () |
|
| HContainer (const HContainer< T > &HR_in, T *data_array=nullptr) |
| copy constructor when data_array is not nullptr, new HContainer will be wrapper for data_array data of HR_in will not be copied, please call add() after this constructor to copy data.
|
|
HContainer & | operator= (const HContainer< T > &HR_in)=delete |
|
| HContainer (HContainer< T > &&HR_in) noexcept |
|
HContainer & | operator= (HContainer< T > &&HR_in) noexcept |
|
| HContainer (int natom) |
|
| HContainer (const UnitCell &ucell_, const Parallel_Orbitals *paraV=nullptr) |
|
| HContainer (const Parallel_Orbitals *paraV, T *data_pointer=nullptr, const std::vector< int > *ijr_info=nullptr) |
| use 2d-block-recycle parallel case to initialize atom_pairs, mainly used now. pass a data pointer to HContainer, which means HContainer is a wrapper it will not allocate memory for atom_pairs this case will forbit inserting empty atom_pair
|
|
void | set_paraV (const Parallel_Orbitals *paraV_in) |
| set parallel orbital pointer to check parallel information
|
|
const Parallel_Orbitals * | get_paraV () const |
| get parallel orbital pointer to check parallel information
|
|
void | allocate (T *data_array=nullptr, bool if_zero=false) |
| allocate memory for all <IJR> matrix if data_array is not nullptr, use memory after data_array for each BaseMatrix; if BaseMatrix has memory allocated before, it will be freed first. if data_array is nullptr, allocate memory for each BaseMatrix
|
|
void | set_zero () |
| set values of all <IJR> matrix to zero
|
|
void | insert_pair (const AtomPair< T > &atom_ij) |
| a AtomPair object can be inserted into HContainer, two steps: 1, find AtomPair with atom index atom_i and atom_j 2.1, if found, add to exist AtomPair, 2.2, if not found, insert new one and sort.
|
|
AtomPair< T > * | find_pair (int i, int j) const |
| find AtomPair with atom index atom_i and atom_j This interface can be used to find AtomPair, if found, return pointer will be the exist one, if not found, return pointer will be nullptr.
|
|
BaseMatrix< T > * | find_matrix (int i, int j, int rx, int ry, int rz) |
| find BaseMatrix with atom index atom_i and atom_j and R index (rx, ry, rz) This interface can be used to find BaseMatrix in AtomPair, if found, return pointer will be the exist one, if not found, return pointer will be nullptr.
|
|
const BaseMatrix< T > * | find_matrix (int i, int j, int rx, int ry, int rz) const |
|
BaseMatrix< T > * | find_matrix (int i, int j, const ModuleBase::Vector3< int > &R_index) |
|
const BaseMatrix< T > * | find_matrix (int i, int j, const ModuleBase::Vector3< int > &R_index) const |
|
int | find_matrix_offset (int i, int j, int rx, int ry, int rz) const |
| find the offset of BaseMatrix with atom index atom_i and atom_j and R index (rx, ry, rz) if found, return this->find_matrix(i, j, rx, ry, rz)->get_pointer() - this->get_wrapper(); if not found, return -1
|
|
int | find_matrix_offset (int i, int j, const ModuleBase::Vector3< int > &R_index) const |
|
AtomPair< T > & | get_atom_pair (int i, int j) const |
| return a reference of AtomPair with index of atom I and J in atom_pairs
|
|
AtomPair< T > & | get_atom_pair (int index) const |
| return a reference of AtomPair with index in atom_pairs (R is not fixed) tmp_atom_pairs (R is fixed)
|
|
void | add (const HContainer< T > &other) |
| operator() for accessing value with indexes this interface is not implemented now, because it is too expensive to access data
|
|
bool | fix_R (int rx_in, int ry_in, int rz_in) const |
| save atom-pair pointers into this->tmp_atom_pairs for selected R index
|
|
void | unfix_R () const |
| set current_R to -1, which means R is not fixed clear this->tmp_atom_pairs
|
|
void | fix_gamma () |
| restrict R indexes of all atom-pair to 0, 0, 0 add BaseMatrix<T> with non-zero R index to this->atom_pairs[i].values[0] set gamma_only = true in this mode:
|
|
void | loop_R (const size_t &index, int &rx, int &ry, int &rz) const |
| interface for call a R loop for HContainer it can return a new R-index with (rx,ry,rz) for each loop if index==0, a new loop of R will be initialized
|
|
size_t | size_R_loop () const |
| calculate number of R index which has counted AtomPairs
|
|
int | find_R (const int &rx_in, const int &ry_in, const int &rz_in) const |
| find index of R in tmp_R_index, used when current_R is fixed
|
|
int | find_R (const ModuleBase::Vector3< int > &R_in) const |
|
size_t | size_atom_pairs () const |
| calculate number of AtomPairs for current R index
|
|
T * | data (int i, int j) const |
| get data pointer of AtomPair with index of I, J
|
|
T * | data (int i, int j, int *R) const |
| get data pointer of AtomPair with index of I, J, Rx, Ry, Rz
|
|
int | get_current_R () const |
| get current_R
|
|
bool | is_gamma_only () const |
| judge if gamma_only
|
|
size_t | get_memory_size () const |
| get total memory bites of HContainer
|
|
size_t | get_nnr () const |
| calculate total size of data in HContainer, named nnr inherited from history all AtomPairs and BaseMatrixs are counted
|
|
std::vector< int > | get_ijr_info () const |
| get infomation of IJR pairs in HContainer the return vector format is {size_I, I1, size_J, J1, size_R, R1x, R1y, R1z, ..., J2, ...}
|
|
void | insert_ijrs (const std::vector< int > *ijrs) |
| use infomation of IJ pairs to expand HContainer the input vector format is {size_IJ_pairs, I1, J1, size_R, R1x, R1y, R1z, ..., I2, J2, ...} HContainer has not been allocated after this function, user should call allocate(...) to allocate memory.
|
|
void | insert_ijrs (const std::vector< int > *ijrs, const UnitCell &ucell, const int npol=1) |
| use infomation of IJ pairs to expand HContainer the number of wavefunctions are stored in UnitCell. HContainer has not been allocated after this function, user should call allocate(...) to allocate memory.
|
|
T * | get_wrapper () const |
| return the wrapper_pointer
|
|
void | shape_synchron (const HContainer< T > &other) |
| synchronization of atom-pairs for read-in HContainer new <IJR> pair from read-in HContainer will be inserted into this->atom-pairs
|
|
const std::vector< std::vector< int > > & | get_sparse_ap () const |
| get sparse_ap
|
|
const std::vector< std::vector< int > > & | get_sparse_ap_index () const |
| get sparse_ap_index
|
|
int | get_nbasis () const |
| get number of basis in each H matrix
|
|
template<typename
T>
class hamilt::HContainer< T >
class HContainer
used to store a matrix for atom-pair local Hamiltonian with specific R-index
<Psi_{mu_I,0}|H|Psi_{nu_J,R}>
template T can be double or std::complex<double>
examples for using this class:
- initialize a HContainer a. use unitcell to initialize atom_pairs
Definition hcontainer.h:144
const Parallel_Orbitals * paraV
pointer of Parallel_Orbitals, which is used to get atom-pair information
Definition hcontainer.h:502
b. use insert_pair() to insert atom-pair
HR.insert_pair(atom_ij);
Definition atom_pair.h:42
void allocate(T *data_array=nullptr, bool if_zero=false)
allocate memory for all <IJR> matrix if data_array is not nullptr, use memory after data_array for ea...
Definition hcontainer.cpp:175
c. use Parallel_Orbital to initialize atom_pairs and HContainer
HCotainer<double> HR(
paraV);
@icode
std::vector< AtomPair< T > > atom_pairs
Definition hcontainer.h:473
void insert_pair(const AtomPair< T > &atom_ij)
a AtomPair object can be inserted into HContainer, two steps: 1, find AtomPair with atom index atom_i...
Definition hcontainer.cpp:624
AtomPair< T > * find_pair(int i, int j) const
find AtomPair with atom index atom_i and atom_j This interface can be used to find AtomPair,...
Definition hcontainer.cpp:219
// HR is a HContainer object AtomPair<double>* atom_ij = HR.find_pair(0, 1); // check if atom_ij is found if (atom_ij != nullptr) { // do something }
AtomPair< T > & get_atom_pair(int i, int j) const
return a reference of AtomPair with index of atom I and J in atom_pairs
Definition hcontainer.cpp:353
// HR is a HContainer object AtomPair<double>& atom_ij_1 = HR.get_atom_pair(0, 1); AtomPair<double>& atom_ij_2 = HR.get_atom_pair(1);//suppose 0,1 is the second atom-pair in atom_pairs 3. get
data pointer of target local matrix <Psi_{mu_I,R}|H|Psi_{nu_J,0}>
a. use
interface data() with atom_i and atom_j and R index
T * data(int i, int j) const
get data pointer of AtomPair with index of I, J
Definition hcontainer.cpp:592
// HR is a HContainer object // suppose atom_i = 0, atom_j = 1, int[3] target_R = {0, 0, 0} double* target_data = HR.data(0, 1, target_R); b.
fix_R and use
data() with atom_i and atom_j without R index
bool fix_R(int rx_in, int ry_in, int rz_in) const
save atom-pair pointers into this->tmp_atom_pairs for selected R index
Definition hcontainer.cpp:417
HR.fix_R(0, 0, 0); double* target_data = HR.data(0, 1); HR.unfix_R(); 4. use for-loop to do something with atom-pairs with specific R index
a. loop R-index first and then loop atom-pairs
// HR is a const HContainer object, which has been initialized int rx, ry, rz; // call size_R_loop() to get number of different R indexes, // be careful, it will cost some time to loop all atom-pairs to gather R indexes int size_for_loop_R = HR.size_R_loop(); for (int iR = 0; iR < size_for_loop_R ; iR++) { // call loop_R() to get R coordinates (rx, ry, rz) HR.loop_R(iR, rx, ry, rz); // call fix_R() to save atom-pairs with R index (rx, ry, rz) into tmp_atom_pairs HR.fix_R(rx, ry, rz); // loop fixed atom-pairs for (int i = 0; i < HR.size_atom_pairs(); i++) { // get pointer of target atom-pair double* data_pointer = HR.data(i); // or get reference of target atom-pair AtomPair<double>& atom_ijR = HR.get_atom_pair(i); // do something with atom_ijR or data_pointer ... } } // call unfix_R() to clear tmp_atom_pairs HR.unfix_R(); b. loop atom-pairs first and then loop R-index
// HR is a const HContainer object, which has been initialized // loop atom-pairs for (int i = 0; i < HR.size_atom_pairs(); i++) { // get reference of target atom-pair AtomPair<double>& atom_ij = HR.get_atom_pair(i); // loop R-index for (int iR = 0; iR < atom_ij.size_R(); iR++) { const ModuleBase::Vector3<int> r_index = atom_ij.get_R_index(iR); auto tmp_matrix = atom_ij.get_HR_values(r_index.x, r_index.y, r_index.z); // do something with tmp_matrix ... } }
bool gamma_only
Definition hcontainer.h:488
... HR.fix_gamma(); // HR is a const HContainer object, which has been initialized and fixed to gamma // loop atom-pairs directly without R index for (int i = 0; i < HR.size_atom_pairs(); i++) { // get data pointer of target atom-pair double* data_pointer = HR.get_pointer(i); // do something with data_pointer ... }