ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Types | Private Attributes | List of all members
elecstate::DensityMatrix< TK, TR > Class Template Reference

#include <density_matrix.h>

Collaboration diagram for elecstate::DensityMatrix< TK, TR >:

Public Member Functions

 ~DensityMatrix ()
 Destructor of class DensityMatrix.
 
 DensityMatrix (const Parallel_Orbitals *_paraV, const int nspin, const std::vector< ModuleBase::Vector3< double > > &kvec_d, const int nk)
 Constructor of class DensityMatrix for multi-k calculation.
 
 DensityMatrix (const Parallel_Orbitals *_paraV, const int nspin)
 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_pointer (const int ispin) const
 get pointer of DMR
 
const std::vector< hamilt::HContainer< TR > * > & get_DMR_vector () const
 get pointer vector of DMR
 
std::vector< hamilt::HContainer< TR > * > & get_DMR_vector ()
 
const std::vector< std::vector< TR > > & get_DMR_save () const
 
std::vector< std::vector< TR > > & get_DMR_save ()
 
TK * get_DMK_pointer (const int ik) const
 get pointer of DMK
 
const std::vector< std::vector< TK > > & get_DMK_vector () const
 get pointer vector of DMK
 
std::vector< std::vector< TK > > & get_DMK_vector ()
 
void set_DMK_pointer (const int ik, TK *DMK_in)
 set _DMK using a input TK* pointer please make sure the size of TK* is correct
 
const Parallel_Orbitalsget_paraV_pointer () const
 get pointer of paraV
 
const std::vector< ModuleBase::Vector3< double > > & get_kvec_d () const
 
void cal_DMR (const int ik_in=-1)
 calculate density matrix DMR from dm(k) using blas::axpy if ik_in < 0, calculate all k-points if ik_in >= 0, calculate only one k-point without summing over k-points
 
void cal_DMR_td (const UnitCell &ucell, const ModuleBase::Vector3< double > At, const int ik_in=-1)
 calculate density matrix DMR with additional vector potential phase, used for hybrid gauge tddft if ik_in < 0, calculate all k-points if ik_in >= 0, calculate only one k-point without summing over k-points
 
void cal_DMR_full (hamilt::HContainer< std::complex< double > > *dmR_out) 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 write_DMK (const std::string directory, const int ispin, const int ik)
 write density matrix dm(ik) into *.dmk
 
void read_DMK (const std::string directory, const int ispin, const int ik)
 read *.dmk into density matrix dm(ik)
 
void save_DMR ()
 save _DMR into _DMR_save
 
void cal_DMR (const int ik_in)
 
void cal_DMR_td (const UnitCell &ucell, const ModuleBase::Vector3< double > At, const int ik_in)
 
void cal_DMR_full (hamilt::HContainer< std::complex< double > > *dmR_out) const
 
void cal_DMR_full (hamilt::HContainer< std::complex< double > > *dmR_out) const
 
void cal_DMR (const int ik_in)
 
void write_DMK (const std::string directory, const int ispin, const int ik)
 
void write_DMK (const std::string directory, const int ispin, const int ik)
 
void cal_DMR (int ik_in)
 

Public Attributes

std::vector< ModuleBase::ComplexMatrixEDMK
 

Private Types

using TRShift = typename ShiftRealComplex< TR >::type
 

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
 
std::vector< hamilt::HContainer< TR > * > _DMR_grid
 HContainer for density matrix in real space for gird parallelization vector.size() = 1 for non-polarization and SOC vector.size() = 2 for spin-polarization.
 
std::vector< std::vector< TK > > _DMK
 density matrix in k space, which is a vector[ik] DMK should be a [_nspin][_nk][i][j] matrix, whose size is _nspin * _nk * _paraV->get_nrow() * _paraV->get_ncol()
 
const std::vector< ModuleBase::Vector3< double > > _kvec_d
 K_Vectors object, which is used to get k-point information.
 
const Parallel_Orbitals_paraV = nullptr
 Parallel_Orbitals object, which contain all information of 2D block cyclic distribution.
 
int _nspin = 1
 spin-polarization index (1 - none spin and SOC ; 2 - spin polarization) Attention: this is not as same as GlovalV::NSPIN _nspin means the number of isolated spin-polarization states
 
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
 
TR * dmr_tmp_ = nullptr
 

Member Typedef Documentation

◆ TRShift

template<typename TK , typename TR >
using elecstate::DensityMatrix< TK, TR >::TRShift = typename ShiftRealComplex<TR>::type
private

Constructor & Destructor Documentation

◆ ~DensityMatrix()

template<typename TK , typename TR >
elecstate::DensityMatrix< TK, TR >::~DensityMatrix ( )

Destructor of class DensityMatrix.

◆ DensityMatrix() [1/2]

template<typename TK , typename TR >
elecstate::DensityMatrix< TK, TR >::DensityMatrix ( const Parallel_Orbitals _paraV,
const int  nspin,
const std::vector< ModuleBase::Vector3< double > > &  kvec_d,
const int  nk 
)

Constructor of class DensityMatrix for multi-k calculation.

Parameters
_paraVpointer of Parallel_Orbitals object
nspinnumber of spin of the density matrix, set by user according to global nspin (usually {nspin_global -> nspin_dm} = {1->1, 2->2, 4->1}, but sometimes 2->1 like in LR-TDDFT)
kvec_ddirect coordinates of kpoints
nknumber of k-points, not always equal to K_Vectors::get_nks()/nspin_dm. it will be set to kvec_d.size() if the value is invalid
Here is the call graph for this function:

◆ DensityMatrix() [2/2]

template<typename TK , typename TR >
elecstate::DensityMatrix< TK, TR >::DensityMatrix ( const Parallel_Orbitals _paraV,
const int  nspin 
)

Constructor of class DensityMatrix for gamma-only calculation, where kvector is not required.

Parameters
_paraVpointer of Parallel_Orbitals object
nspinnumber of spin of the density matrix, set by user according to global nspin (usually {nspin_global -> nspin_dm} = {1->1, 2->2, 4->1}, but sometimes 2->1 like in LR-TDDFT)

Member Function Documentation

◆ cal_DMR() [1/4]

void elecstate::DensityMatrix< std::complex< double >, double >::cal_DMR ( const int  ik_in)
Here is the call graph for this function:

◆ cal_DMR() [2/4]

void elecstate::DensityMatrix< double, double >::cal_DMR ( const int  ik_in)
Here is the call graph for this function:

◆ cal_DMR() [3/4]

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::cal_DMR ( const int  ik_in = -1)

calculate density matrix DMR from dm(k) using blas::axpy if ik_in < 0, calculate all k-points if ik_in >= 0, calculate only one k-point without summing over k-points

Here is the caller graph for this function:

◆ cal_DMR() [4/4]

void elecstate::DensityMatrix< std::complex< double >, std::complex< double > >::cal_DMR ( int  ik_in)
Here is the call graph for this function:

◆ cal_DMR_full() [1/3]

void elecstate::DensityMatrix< double, double >::cal_DMR_full ( hamilt::HContainer< std::complex< double > > *  dmR_out) const

◆ cal_DMR_full() [2/3]

void elecstate::DensityMatrix< std::complex< double >, double >::cal_DMR_full ( hamilt::HContainer< std::complex< double > > *  dmR_out) const
Here is the call graph for this function:

◆ cal_DMR_full() [3/3]

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::cal_DMR_full ( hamilt::HContainer< std::complex< double > > *  dmR_out) 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

Parameters
dmR_outpointer of HContainer object to store the calculated complex DMR
Here is the caller graph for this function:

◆ cal_DMR_td() [1/2]

void elecstate::DensityMatrix< std::complex< double >, double >::cal_DMR_td ( const UnitCell ucell,
const ModuleBase::Vector3< double >  At,
const int  ik_in 
)
Here is the call graph for this function:

◆ cal_DMR_td() [2/2]

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::cal_DMR_td ( const UnitCell ucell,
const ModuleBase::Vector3< double >  At,
const int  ik_in = -1 
)

calculate density matrix DMR with additional vector potential phase, used for hybrid gauge tddft if ik_in < 0, calculate all k-points if ik_in >= 0, calculate only one k-point without summing over k-points

◆ get_DMK()

template<typename TK , typename TR >
TK elecstate::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)

Parameters
ispinspin index (1 - spin up (support SOC) or 2 - spin down)
ikk-point index
irow index
jcolumn index
Returns
T a matrix element of density matrix dm(k)
Here is the caller graph for this function:

◆ get_DMK_ncol()

template<typename TK , typename TR >
int elecstate::DensityMatrix< TK, TR >::get_DMK_ncol ( ) const

get number of columns of density matrix dm(k)

Here is the caller graph for this function:

◆ get_DMK_nks()

template<typename TK , typename TR >
int elecstate::DensityMatrix< TK, TR >::get_DMK_nks ( ) const

get total number of k-points of density matrix dm(k)

Here is the caller graph for this function:

◆ get_DMK_nrow()

template<typename TK , typename TR >
int elecstate::DensityMatrix< TK, TR >::get_DMK_nrow ( ) const

get number of rows of density matrix dm(k)

Here is the caller graph for this function:

◆ get_DMK_pointer()

template<typename TK , typename TR >
TK * elecstate::DensityMatrix< TK, TR >::get_DMK_pointer ( const int  ik) const

get pointer of DMK

Parameters
ikk-point index, which is the index of _DMK
Returns
TK* pointer of DMK
Here is the caller graph for this function:

◆ get_DMK_size()

template<typename TK , typename TR >
int elecstate::DensityMatrix< TK, TR >::get_DMK_size ( ) const
Here is the caller graph for this function:

◆ get_DMK_vector() [1/2]

template<typename TK , typename TR >
std::vector< std::vector< TK > > & elecstate::DensityMatrix< TK, TR >::get_DMK_vector ( )
inline

◆ get_DMK_vector() [2/2]

template<typename TK , typename TR >
const std::vector< std::vector< TK > > & elecstate::DensityMatrix< TK, TR >::get_DMK_vector ( ) const
inline

get pointer vector of DMK

Here is the caller graph for this function:

◆ get_DMR_pointer()

template<typename TK , typename TR >
hamilt::HContainer< TR > * elecstate::DensityMatrix< TK, TR >::get_DMR_pointer ( const int  ispin) const

get pointer of DMR

Parameters
ispinspin index (1 - spin up (support SOC) or 2 - spin down)
Returns
HContainer

* pointer of DMR

Here is the caller graph for this function:

◆ get_DMR_save() [1/2]

template<typename TK , typename TR >
std::vector< std::vector< TR > > & elecstate::DensityMatrix< TK, TR >::get_DMR_save ( )
inline

◆ get_DMR_save() [2/2]

template<typename TK , typename TR >
const std::vector< std::vector< TR > > & elecstate::DensityMatrix< TK, TR >::get_DMR_save ( ) const
inline
Here is the caller graph for this function:

◆ get_DMR_vector() [1/2]

template<typename TK , typename TR >
std::vector< hamilt::HContainer< TR > * > & elecstate::DensityMatrix< TK, TR >::get_DMR_vector ( )
inline

◆ get_DMR_vector() [2/2]

template<typename TK , typename TR >
const std::vector< hamilt::HContainer< TR > * > & elecstate::DensityMatrix< TK, TR >::get_DMR_vector ( ) const
inline

get pointer vector of DMR

Returns
HContainer

* vector of DMR

Here is the caller graph for this function:

◆ get_kvec_d()

template<typename TK , typename TR >
const std::vector< ModuleBase::Vector3< double > > & elecstate::DensityMatrix< TK, TR >::get_kvec_d ( ) const
inline

◆ get_paraV_pointer()

template<typename TK , typename TR >
const Parallel_Orbitals * elecstate::DensityMatrix< TK, TR >::get_paraV_pointer ( ) const
inline

get pointer of paraV

Here is the caller graph for this function:

◆ init_DMR() [1/4]

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::init_DMR ( const Grid_Driver GridD_in,
const UnitCell ucell 
)

initialize density matrix DMR from UnitCell

Parameters
GridD_inpointer of Grid_Driver object (used to find ajacent atoms)
ucellpointer of UnitCell object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_DMR() [2/4]

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::init_DMR ( const hamilt::HContainer< TR > &  _DMR_in)

initialize density matrix DMR from another HContainer now only support HContainer<double>

Parameters
_DMR_inpointer of another HContainer object

◆ init_DMR() [3/4]

template<typename TK , typename TR >
void elecstate::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

Parameters
_DMR_in
Here is the call graph for this function:

◆ init_DMR() [4/4]

template<typename TK , typename TR >
void elecstate::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)

Parameters
rapointer of Record_adj object (used to find ajacent atoms)
ucellpointer of UnitCell object
Here is the call graph for this function:

◆ read_DMK()

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::read_DMK ( const std::string  directory,
const int  ispin,
const int  ik 
)

read *.dmk into density matrix dm(ik)

Parameters
directorydirectory of *.dmk files
ispinspin index (1 - spin up (support SOC) or 2 - spin down)
ikk-point index
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_DMR()

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::save_DMR ( )

save _DMR into _DMR_save

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

◆ set_DMK()

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::set_DMK ( const int  ispin,
const int  ik,
const int  i,
const int  j,
const TK  value 
)

set _DMK element directly

Parameters
ispinspin index (1 - spin up (support SOC) or 2 - spin down)
ikk-point index
irow index
jcolumn index
valuevalue to be set
Here is the caller graph for this function:

◆ set_DMK_pointer()

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::set_DMK_pointer ( const int  ik,
TK *  DMK_in 
)

set _DMK using a input TK* pointer please make sure the size of TK* is correct

Here is the caller graph for this function:

◆ set_DMK_zero()

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::set_DMK_zero ( )

set _DMK element to zero

Here is the call graph for this function:

◆ switch_dmr()

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::switch_dmr ( const int  mode)

(Only nspin=2) switch DMR to total density matrix or magnetization density matrix

Parameters
mode0 - original density matrix; 1 - total density matrix; 2 - magnetization density matrix
Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_DMK() [1/3]

template<typename TK , typename TR >
void elecstate::DensityMatrix< TK, TR >::write_DMK ( const std::string  directory,
const int  ispin,
const int  ik 
)

write density matrix dm(ik) into *.dmk

Parameters
directorydirectory of *.dmk files
ispinspin index (1 - spin up (support SOC) or 2 - spin down)
ikk-point index
Here is the caller graph for this function:

◆ write_DMK() [2/3]

void elecstate::DensityMatrix< double, double >::write_DMK ( const std::string  directory,
const int  ispin,
const int  ik 
)
Here is the call graph for this function:

◆ write_DMK() [3/3]

void elecstate::DensityMatrix< std::complex< double >, double >::write_DMK ( const std::string  directory,
const int  ispin,
const int  ik 
)
Here is the call graph for this function:

Member Data Documentation

◆ _DMK

template<typename TK , typename TR >
std::vector<std::vector<TK> > elecstate::DensityMatrix< TK, TR >::_DMK
private

density matrix in k space, which is a vector[ik] DMK should be a [_nspin][_nk][i][j] matrix, whose size is _nspin * _nk * _paraV->get_nrow() * _paraV->get_ncol()

◆ _DMR

template<typename TK , typename TR >
std::vector<hamilt::HContainer<TR>*> elecstate::DensityMatrix< TK, TR >::_DMR
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.

◆ _DMR_grid

template<typename TK , typename TR >
std::vector<hamilt::HContainer<TR>*> elecstate::DensityMatrix< TK, TR >::_DMR_grid
private

HContainer for density matrix in real space for gird parallelization vector.size() = 1 for non-polarization and SOC vector.size() = 2 for spin-polarization.

◆ _DMR_save

template<typename TK , typename TR >
std::vector<std::vector<TR> > elecstate::DensityMatrix< TK, TR >::_DMR_save
private

◆ _kvec_d

template<typename TK , typename TR >
const std::vector<ModuleBase::Vector3<double> > elecstate::DensityMatrix< TK, TR >::_kvec_d
private

K_Vectors object, which is used to get k-point information.

◆ _nk

template<typename TK , typename TR >
int elecstate::DensityMatrix< TK, TR >::_nk = 0
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

◆ _nspin

template<typename TK , typename TR >
int elecstate::DensityMatrix< TK, TR >::_nspin = 1
private

spin-polarization index (1 - none spin and SOC ; 2 - spin polarization) Attention: this is not as same as GlovalV::NSPIN _nspin means the number of isolated spin-polarization states

◆ _paraV

template<typename TK , typename TR >
const Parallel_Orbitals* elecstate::DensityMatrix< TK, TR >::_paraV = nullptr
private

Parallel_Orbitals object, which contain all information of 2D block cyclic distribution.

◆ dmr_origin_

template<typename TK , typename TR >
std::vector<TR> elecstate::DensityMatrix< TK, TR >::dmr_origin_
private

temporary pointers for switch DMR, only used with nspin=2

◆ dmr_tmp_

template<typename TK , typename TR >
TR* elecstate::DensityMatrix< TK, TR >::dmr_tmp_ = nullptr
private

◆ EDMK

template<typename TK , typename TR >
std::vector<ModuleBase::ComplexMatrix> elecstate::DensityMatrix< TK, TR >::EDMK

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