diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h index 7c08044b7c..c29ba87c0e 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h +++ b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h @@ -11,16 +11,19 @@ namespace hamilt { template class OperatorLCAO : public Operator { public: + OperatorLCAO( HS_Matrix_K* hsk_in, - const std::vector>& kvec_d_in, - HContainer* hR_in) + const std::vector>& kvec_d_in, //! k-point vectors + HContainer* 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 , @@ -47,7 +50,8 @@ class OperatorLCAO : public Operator { 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), only pointers of HK and SK saved in OperatorLCAO */ - void matrixHk(MatrixBlock& hk_in, MatrixBlock& sk_in) { + void matrixHk(MatrixBlock& hk_in, MatrixBlock& sk_in) + { this->get_hs_pointers(); #ifdef __MPI hk_in = MatrixBlock{hmatrix_k, @@ -59,8 +63,15 @@ class OperatorLCAO : public Operator { (size_t)this->hsk->get_pv()->ncol, this->hsk->get_pv()->desc}; #else - hk_in = MatrixBlock{hmatrix_k, (size_t)this->hsk->get_pv()->nrow, (size_t)this->hsk->get_pv()->ncol, nullptr}; - sk_in = MatrixBlock{smatrix_k, (size_t)this->hsk->get_pv()->nrow, (size_t)this->hsk->get_pv()->ncol, nullptr}; + hk_in = MatrixBlock{hmatrix_k, + (size_t)this->hsk->get_pv()->nrow, + (size_t)this->hsk->get_pv()->ncol, + nullptr}; + + sk_in = MatrixBlock{smatrix_k, + (size_t)this->hsk->get_pv()->nrow, + (size_t)this->hsk->get_pv()->ncol, + nullptr}; #endif } @@ -77,7 +88,7 @@ class OperatorLCAO : public Operator { 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); @@ -87,32 +98,33 @@ class OperatorLCAO : public Operator { 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* hsk = nullptr; const std::vector>& kvec_d; protected: bool new_e_iteration = true; - // Real space Hamiltonian pointer + //! Real-space Hamiltonian pointer hamilt::HContainer* 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 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' 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; };