Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ namespace hamilt {
template <typename TK, typename TR>
class OperatorLCAO : public Operator<TK> {
public:

OperatorLCAO(
HS_Matrix_K<TK>* hsk_in,
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
HContainer<TR>* hR_in)
const std::vector<ModuleBase::Vector3<double>>& kvec_d_in, //! k-point vectors
HContainer<TR>* hR_in) //! H(R) matrix, R is the Bravis lattice vector
: hsk(hsk_in), kvec_d(kvec_d_in), hR(hR_in){}

virtual ~OperatorLCAO()
{
if (this->allocated_smatrix) {
if (this->allocated_smatrix)
{
delete[] this->smatrix_k;
}
}
}

/* Function init(k) is used for update HR and HK ,
Expand All @@ -47,7 +50,8 @@ class OperatorLCAO : public Operator<TK> {
Gamma_only case (TK = double), SK would not changed during one SCF loop, a template triangle matrix SK_temp is used
for accelerating. General case (TK = std::complex<double>), only pointers of HK and SK saved in OperatorLCAO
*/
void matrixHk(MatrixBlock<TK>& hk_in, MatrixBlock<TK>& sk_in) {
void matrixHk(MatrixBlock<TK>& hk_in, MatrixBlock<TK>& sk_in)
{
this->get_hs_pointers();
#ifdef __MPI
hk_in = MatrixBlock<TK>{hmatrix_k,
Expand All @@ -59,8 +63,15 @@ class OperatorLCAO : public Operator<TK> {
(size_t)this->hsk->get_pv()->ncol,
this->hsk->get_pv()->desc};
#else
hk_in = MatrixBlock<TK>{hmatrix_k, (size_t)this->hsk->get_pv()->nrow, (size_t)this->hsk->get_pv()->ncol, nullptr};
sk_in = MatrixBlock<TK>{smatrix_k, (size_t)this->hsk->get_pv()->nrow, (size_t)this->hsk->get_pv()->ncol, nullptr};
hk_in = MatrixBlock<TK>{hmatrix_k,
(size_t)this->hsk->get_pv()->nrow,
(size_t)this->hsk->get_pv()->ncol,
nullptr};

sk_in = MatrixBlock<TK>{smatrix_k,
(size_t)this->hsk->get_pv()->nrow,
(size_t)this->hsk->get_pv()->ncol,
nullptr};
#endif
}

Expand All @@ -77,7 +88,7 @@ class OperatorLCAO : public Operator<TK> {
virtual void set_HR_fixed(void*) { return; }

/**
* @brief reset hr_done status
* @brief reset the status of 'hr_done' (if H(R) is calculated)
*/
void set_hr_done(bool hr_done_in);

Expand All @@ -87,32 +98,33 @@ class OperatorLCAO : public Operator<TK> {
void set_current_spin(const int current_spin_in);

// protected:
// Hamiltonian matrix which are calculated in OperatorLCAO
// Hamiltonian matrices which are calculated in OperatorLCAO
HS_Matrix_K<TK>* hsk = nullptr;
const std::vector<ModuleBase::Vector3<double>>& kvec_d;

protected:
bool new_e_iteration = true;

// Real space Hamiltonian pointer
//! Real-space Hamiltonian pointer
hamilt::HContainer<TR>* hR = nullptr;

// current spin index
//! current spin index
int current_spin = 0;

// if HR is calculated
//! if H(R) is calculated
bool hr_done = false;

private:

void get_hs_pointers();

// there are H and S matrix for each k point in reciprocal space
// type double for gamma_only case, type complex<double> for multi-k-points
// case
//! there are H and S matrix for each k point in reciprocal space
//! 'double' type for gamma_only case,
//! 'complex<double>' type for multi k-points case
TK* hmatrix_k = nullptr;
TK* smatrix_k = nullptr;

// only used for Gamma_only case
//! only used for Gamma_only case
bool allocated_smatrix = false;
};

Expand Down
Loading