|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
DensityMatrix Class <TK,TR> = <double,double> for Gamma-only calculation <TK,TR> = <std::complex<double>,double> for multi-k calculation. More...
#include <density_matrix.h>
Public Member Functions | |
| ~DensityMatrix () | |
| Destructor of class DensityMatrix. | |
| DensityMatrix (const Parallel_Orbitals *pv, const int spin_mult, const std::vector< ModuleBase::Vector3< double > > &kvec_d, const int nk, const int nspin=0) | |
| Constructor of class DensityMatrix for multi-k calculation. | |
| DensityMatrix (const Parallel_Orbitals *pv, const int spin_mult, const int nspin=0) | |
| Constructor of class DensityMatrix for gamma-only calculation, where kvector is not required. | |
| void | init_dmr (const Grid_Driver *GridD_in, const UnitCell *ucell) |
| initialize density matrix DMR from UnitCell | |
| void | init_dmr (Record_adj &ra, const UnitCell *ucell) |
| initialize density matrix DMR from UnitCell and RA | |
| void | init_dmr (const hamilt::HContainer< TR > &_DMR_in) |
| initialize density matrix DMR from another HContainer now only support HContainer<double> | |
| void | init_dmr (const hamilt::HContainer< TRShift > &_DMR_in) |
| initialize density matrix DMR from another HContainer this is a temprory function for NSPIN=4 case since copy HContainer from another HContainer with different TR is not supported yet would be refactor in the future | |
| void | set_dmk (const int ispin, const int ik, const int i, const int j, const TK value) |
| set dmk element directly | |
| void | set_dmk_zero () |
| set dmk element to zero | |
| TK | get_dmk (const int ispin, const int ik, const int i, const int j) const |
| get a matrix element of density matrix dm(k) | |
| int | get_dmk_nks () const |
| get total number of k-points of density matrix dm(k) | |
| int | get_dmk_size () const |
| int | get_dmk_nrow () const |
| get number of rows of density matrix dm(k) | |
| int | get_dmk_ncol () const |
| get number of columns of density matrix dm(k) | |
| hamilt::HContainer< TR > * | get_dmr_ptr (const int ispin) const |
| get pointer of DMR | |
| bool | is_dmr_ready () const |
| check whether the stored DMR is a valid density matrix calculated from DMK init_dmr() resets the flag and cal_dmr()/cal_dmr_td() set it, so a freshly allocated, zeroed or file-read DMR is reported as not ready until the first wavefunction-derived calculation | |
| const std::vector< hamilt::HContainer< TR > * > & | get_dmr_vec () const |
| get pointer vector of DMR | |
| std::vector< hamilt::HContainer< TR > * > & | get_dmr_vec () |
| const std::vector< std::vector< TR > > & | get_dmr_save () const |
| std::vector< std::vector< TR > > & | get_dmr_save () |
| TK * | get_dmk_ptr (const int ik) const |
| get pointer of DMK | |
| const std::vector< std::vector< TK > > & | get_dmk_vec () const |
| get pointer vector of DMK | |
| std::vector< std::vector< TK > > & | get_dmk_vec () |
| void | set_dmk_ptr (const int ik, TK *DMK_in) |
| set dmk using a input TK* pointer please make sure the size of TK* is correct | |
| void | set_DMK_vector (const int ik, const std::vector< TK > &v) |
| int | get_DMK_nks () const |
| number of k-slots stored in dmk (spin_mult * _nk, flattened) | |
| void | cal_dmr (const int ik_in) |
| calculate density matrix DMR from dm(k) using blas::axpy | |
| void | cal_dmr_td (const std::map< ModuleBase::Vector3< int >, std::complex< double > > &phase_hybrid, const ModuleBase::Vector3< double > At, const int ik_in) |
| calculate density matrix DMR with additional vector potential phase, used for hybrid gauge tddft | |
| void | cal_dmr_full (hamilt::HContainer< std::complex< double > > *dmR_out, const int ik_in) const |
| calculate complex density matrix DMR with both real and imaginary part for noncollinear-spin calculation the stored dm(k) has been used to calculate the passin DMR | |
| void | switch_dmr (const int mode) |
| (Only nspin=2) switch DMR to total density matrix or magnetization density matrix | |
| void | save_dmr () |
| save dmr into dmr_save | |
| void | cal_dmr_full (hamilt::HContainer< std::complex< double > > *dmR_out, const int ik_in) const |
| void | cal_dmr_full (hamilt::HContainer< std::complex< double > > *dmR_out, const int ik_in) const |
| void | cal_dmr (const int ik_in) |
| void | cal_dmr (const int ik_in) |
| void | cal_dmr (const int ik_in) |
| void | cal_dmr_td (const std::map< ModuleBase::Vector3< int >, std::complex< double > > &phase_hybrid, const ModuleBase::Vector3< double > At, const int ik_in) |
| void | cal_dmr_td (const std::map< ModuleBase::Vector3< int >, std::complex< double > > &phase_hybrid, const ModuleBase::Vector3< double > At, const int ik_in) |
| void | cal_dmr_td (const std::map< ModuleBase::Vector3< int >, std::complex< double > > &phase_hybrid, const ModuleBase::Vector3< double > At, const int ik_in) |
Public Attributes | |
| std::vector< ModuleBase::ComplexMatrix > | edmk |
Private Types | |
| using | TRShift = typename ShiftRealComplex<TR>::type |
Private Member Functions | |
| void | clear_dmr () |
| delete all HContainer objects in dmr and clear the vector | |
Private Attributes | |
| std::vector< hamilt::HContainer< TR > * > | dmr |
| HContainer for density matrix in real space for 2D parallelization vector.size() = 1 for non-polarization and SOC vector.size() = 2 for spin-polarization. | |
| std::vector< std::vector< TR > > | dmr_save |
| bool | _dmr_ready = false |
| whether dmr holds a density matrix calculated from DMK (reset by init_dmr, set by cal_dmr) | |
| std::vector< hamilt::HContainer< TR > * > | dmr_grid |
| HContainer for density matrix in real space for grid parallelization same size semantics as dmr. | |
| std::vector< std::vector< TK > > | dmk |
| density matrix in k space, which is a vector[ik] DMK should be a [spin_mult][_nk][i][j] matrix, whose size is spin_mult * _nk * pv->get_nrow() * pv->get_ncol() | |
| const std::vector< ModuleBase::Vector3< double > > | _kvec_d |
| K_Vectors object, which is used to get k-point information. | |
| const Parallel_Orbitals * | pv = nullptr |
| Parallel_Orbitals object, which contain all information of 2D block cyclic distribution. | |
| int | spin_mult = 1 |
| spin multiplicity used to size the density matrix (1 - none spin and SOC ; 2 - spin polarization). This is NOT the physical nspin (1/2/4); it matches K_Vectors::spin_mult. | |
| int | nspin = 1 |
| the global physical nspin from INPUT (1/2/4). For SOC/noncollinear (nspin==4) the density matrix is stored with spin_mult==1 (a single 2x2 spin-block matrix), but cal_dmr/cal_dmr_td must still take the spin-resolved (Pauli) branch. spin_mult cannot distinguish this, so keep the global value here. Equals spin_mult for non-SOC cases. | |
| int | _nk = 0 |
| real number of k-points _nk is not equal to _kv->get_nks() when spin-polarization is considered _nk = kv->get_nks() / nspin when nspin=2 | |
| std::vector< TR > | dmr_origin |
| temporary pointers for switch DMR, only used with nspin=2 | |
| std::vector< TR > | dmr_tmp |
Friends | |
| void | module_dm::cal_dmr (const DensityMatrix< TK, TR > &dm, std::vector< hamilt::HContainer< TR > * > &dmR_out, const int ik_in) |
| void | module_dm::cal_dmr_td (DensityMatrix< TK, TR > &dm, std::vector< hamilt::HContainer< TR > * > &dmR_out, const std::map< ModuleBase::Vector3< int >, std::complex< double > > &phase_hybrid, const ModuleBase::Vector3< double > At, const int ik_in) |
| void | module_dm::cal_dmr_full (const DensityMatrix< TK, TR > &dm, hamilt::HContainer< std::complex< double > > *dmR_out, const int ik_in) |
| void | module_dm::accumulate_dmr (const DensityMatrix< TK, TR > &dm, std::vector< hamilt::HContainer< TR > * > &dmR_out, const std::map< ModuleBase::Vector3< int >, std::complex< double > > &phase_hybrid, const int ik_in, const char *func_name) |
| void | module_dm::add_dmr_real (const DensityMatrix< TK, TR > &dm, const DmrBlock &block, const int ik_begin, const std::vector< std::vector< TK > > &kphase_vec, const int ld_hk, const int ik_in, std::vector< TR * > &dmr_mats) |
| void | module_dm::add_dmr_soc (const DensityMatrix< TK, TR > &dm, const DmrBlock &block, const int ik_begin, const std::vector< std::vector< TK > > &kphase_vec, const int ld_hk, const int ik_in, const int col_stride, std::vector< TR * > &dmr_mats) |
DensityMatrix Class <TK,TR> = <double,double> for Gamma-only calculation <TK,TR> = <std::complex<double>,double> for multi-k calculation.
|
private |
| module_dm::DensityMatrix< TK, TR >::~DensityMatrix | ( | ) |
| module_dm::DensityMatrix< TK, TR >::DensityMatrix | ( | const Parallel_Orbitals * | pv, |
| const int | spin_mult, | ||
| const std::vector< ModuleBase::Vector3< double > > & | kvec_d, | ||
| const int | nk, | ||
| const int | nspin = 0 ) |
Constructor of class DensityMatrix for multi-k calculation.
| pv | pointer of Parallel_Orbitals object |
| spin_mult | spin multiplicity used to size the DM: 1 for input nspin 1 or 4 (non-collinear k points are not doubled), 2 for input nspin 2 (LSDA up/down). This is NOT the physical nspin (1/2/4); it matches K_Vectors::spin_mult. |
| kvec_d | direct coordinates of kpoints |
| nk | number of k-points, not always equal to K_Vectors::get_nks()/spin_mult. it will be set to kvec_d.size() if the value is invalid |
| nspin | the global physical nspin from INPUT (1/2/4); defaults to spin_mult for non-SOC cases where they coincide. Pass 4 explicitly for SOC/noncollinear calculations so that cal_dmr selects the spin-resolved (Pauli) branch. |
| module_dm::DensityMatrix< TK, TR >::DensityMatrix | ( | const Parallel_Orbitals * | pv, |
| const int | spin_mult, | ||
| const int | nspin = 0 ) |
Constructor of class DensityMatrix for gamma-only calculation, where kvector is not required.
| pv | pointer of Parallel_Orbitals object |
| spin_mult | spin multiplicity of the density matrix (1 or 2); NOT the physical nspin |
| nspin | the global physical nspin from INPUT (1/2/4); defaults to spin_mult. |
| void module_dm::DensityMatrix< TK, TR >::cal_dmr | ( | const int | ik_in | ) |
calculate density matrix DMR from dm(k) using blas::axpy
| ik_in | if ik_in < 0, calculate all k-points if ik_in >= 0, calculate only one k-point without summing over k-points |
| void module_dm::DensityMatrix< double, double >::cal_dmr | ( | const int | ik_in | ) |
| void module_dm::DensityMatrix< std::complex< double >, std::complex< double > >::cal_dmr | ( | const int | ik_in | ) |
| void module_dm::DensityMatrix< std::complex< double >, double >::cal_dmr | ( | const int | ik_in | ) |
| void module_dm::DensityMatrix< TK, TR >::cal_dmr_full | ( | hamilt::HContainer< std::complex< double > > * | dmR_out, |
| const int | ik_in ) const |
calculate complex density matrix DMR with both real and imaginary part for noncollinear-spin calculation the stored dm(k) has been used to calculate the passin DMR
| dmR_out | pointer of HContainer object to store the calculated complex DMR |
| ik_in | if ik_in < 0, calculate all k-points if ik_in >= 0, calculate only one k-point |
| void module_dm::DensityMatrix< std::complex< double >, double >::cal_dmr_full | ( | hamilt::HContainer< std::complex< double > > * | dmR_out, |
| const int | ik_in ) const |
| void module_dm::DensityMatrix< double, double >::cal_dmr_full | ( | hamilt::HContainer< std::complex< double > > * | dmR_out, |
| const int | ik_in ) const |
| void module_dm::DensityMatrix< TK, TR >::cal_dmr_td | ( | const std::map< ModuleBase::Vector3< int >, std::complex< double > > & | phase_hybrid, |
| const ModuleBase::Vector3< double > | At, | ||
| const int | ik_in ) |
calculate density matrix DMR with additional vector potential phase, used for hybrid gauge tddft
| ik_in | if ik_in < 0, calculate all k-points if ik_in >= 0, calculate only one k-point |
| void module_dm::DensityMatrix< std::complex< double >, std::complex< double > >::cal_dmr_td | ( | const std::map< ModuleBase::Vector3< int >, std::complex< double > > & | phase_hybrid, |
| const ModuleBase::Vector3< double > | At, | ||
| const int | ik_in ) |
| void module_dm::DensityMatrix< std::complex< double >, double >::cal_dmr_td | ( | const std::map< ModuleBase::Vector3< int >, std::complex< double > > & | phase_hybrid, |
| const ModuleBase::Vector3< double > | At, | ||
| const int | ik_in ) |
| void module_dm::DensityMatrix< double, double >::cal_dmr_td | ( | const std::map< ModuleBase::Vector3< int >, std::complex< double > > & | phase_hybrid, |
| const ModuleBase::Vector3< double > | At, | ||
| const int | ik_in ) |
|
private |
delete all HContainer objects in dmr and clear the vector
| TK module_dm::DensityMatrix< TK, TR >::get_dmk | ( | const int | ispin, |
| const int | ik, | ||
| const int | i, | ||
| const int | j ) const |
get a matrix element of density matrix dm(k)
| ispin | spin index (1 - spin up (support SOC) or 2 - spin down) |
| ik | k-point index |
| i | row index |
| j | column index |
| int module_dm::DensityMatrix< TK, TR >::get_dmk_ncol | ( | ) | const |
get number of columns of density matrix dm(k)
|
inline |
number of k-slots stored in dmk (spin_mult * _nk, flattened)
| int module_dm::DensityMatrix< TK, TR >::get_dmk_nks | ( | ) | const |
get total number of k-points of density matrix dm(k)
| int module_dm::DensityMatrix< TK, TR >::get_dmk_nrow | ( | ) | const |
get number of rows of density matrix dm(k)
| TK * module_dm::DensityMatrix< TK, TR >::get_dmk_ptr | ( | const int | ik | ) | const |
get pointer of DMK
| ik | k-point index, which is the index of dmk |
| int module_dm::DensityMatrix< TK, TR >::get_dmk_size | ( | ) | const |
|
inline |
|
inline |
get pointer vector of DMK
| hamilt::HContainer< TR > * module_dm::DensityMatrix< TK, TR >::get_dmr_ptr | ( | const int | ispin | ) | const |
get pointer of DMR
| ispin | spin index (1 - spin up (support SOC) or 2 - spin down) |
* pointer of DMR
|
inline |
|
inline |
|
inline |
|
inline |
get pointer vector of DMR
* vector of DMR
| void module_dm::DensityMatrix< TK, TR >::init_dmr | ( | const Grid_Driver * | GridD_in, |
| const UnitCell * | ucell ) |
initialize density matrix DMR from UnitCell
| GridD_in | pointer of Grid_Driver object (used to find ajacent atoms) |
| ucell | pointer of UnitCell object |
| void module_dm::DensityMatrix< TK, TR >::init_dmr | ( | const hamilt::HContainer< TR > & | _DMR_in | ) |
initialize density matrix DMR from another HContainer now only support HContainer<double>
| _DMR_in | pointer of another HContainer object |
| void module_dm::DensityMatrix< TK, TR >::init_dmr | ( | const hamilt::HContainer< TRShift > & | _DMR_in | ) |
initialize density matrix DMR from another HContainer this is a temprory function for NSPIN=4 case since copy HContainer from another HContainer with different TR is not supported yet would be refactor in the future
| _DMR_in |
| void module_dm::DensityMatrix< TK, TR >::init_dmr | ( | Record_adj & | ra, |
| const UnitCell * | ucell ) |
initialize density matrix DMR from UnitCell and RA
initialize density matrix DMR from UnitCell and RA (mainly used in UnitTest)
| ra | pointer of Record_adj object (used to find ajacent atoms) |
| ucell | pointer of UnitCell object |
|
inline |
check whether the stored DMR is a valid density matrix calculated from DMK init_dmr() resets the flag and cal_dmr()/cal_dmr_td() set it, so a freshly allocated, zeroed or file-read DMR is reported as not ready until the first wavefunction-derived calculation
| void module_dm::DensityMatrix< TK, TR >::save_dmr | ( | ) |
save dmr into dmr_save
| void module_dm::DensityMatrix< TK, TR >::set_dmk | ( | const int | ispin, |
| const int | ik, | ||
| const int | i, | ||
| const int | j, | ||
| const TK | value ) |
set dmk element directly
| ispin | spin index (1 - spin up (support SOC) or 2 - spin down) |
| ik | k-point index |
| i | row index |
| j | column index |
| value | value to be set |
| void module_dm::DensityMatrix< TK, TR >::set_dmk_ptr | ( | const int | ik, |
| TK * | DMK_in ) |
set dmk using a input TK* pointer please make sure the size of TK* is correct
|
inline |
| void module_dm::DensityMatrix< TK, TR >::set_dmk_zero | ( | ) |
set dmk element to zero
| void module_dm::DensityMatrix< TK, TR >::switch_dmr | ( | const int | mode | ) |
(Only nspin=2) switch DMR to total density matrix or magnetization density matrix
| mode | 0 - original density matrix; 1 - total density matrix; 2 - magnetization density matrix |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
private |
whether dmr holds a density matrix calculated from DMK (reset by init_dmr, set by cal_dmr)
|
private |
K_Vectors object, which is used to get k-point information.
|
private |
real number of k-points _nk is not equal to _kv->get_nks() when spin-polarization is considered _nk = kv->get_nks() / nspin when nspin=2
|
private |
density matrix in k space, which is a vector[ik] DMK should be a [spin_mult][_nk][i][j] matrix, whose size is spin_mult * _nk * pv->get_nrow() * pv->get_ncol()
|
private |
HContainer for density matrix in real space for 2D parallelization vector.size() = 1 for non-polarization and SOC vector.size() = 2 for spin-polarization.
|
private |
HContainer for density matrix in real space for grid parallelization same size semantics as dmr.
|
private |
temporary pointers for switch DMR, only used with nspin=2
|
private |
|
private |
| std::vector<ModuleBase::ComplexMatrix> module_dm::DensityMatrix< TK, TR >::edmk |
|
private |
the global physical nspin from INPUT (1/2/4). For SOC/noncollinear (nspin==4) the density matrix is stored with spin_mult==1 (a single 2x2 spin-block matrix), but cal_dmr/cal_dmr_td must still take the spin-resolved (Pauli) branch. spin_mult cannot distinguish this, so keep the global value here. Equals spin_mult for non-SOC cases.
|
private |
Parallel_Orbitals object, which contain all information of 2D block cyclic distribution.
|
private |
spin multiplicity used to size the density matrix (1 - none spin and SOC ; 2 - spin polarization). This is NOT the physical nspin (1/2/4); it matches K_Vectors::spin_mult.