ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
operator_lcao.h
Go to the documentation of this file.
1#ifndef OPERATORLCAO_H
2#define OPERATORLCAO_H
9
10namespace hamilt {
11
12template <typename TK, typename TR>
13class OperatorLCAO : public Operator<TK> {
14 public:
15
17 HS_Matrix_K<TK>* hsk_in,
18 const std::vector<ModuleBase::Vector3<double>>& kvec_d_in,
19 HContainer<TR>* hR_in)
20 : hsk(hsk_in), kvec_d(kvec_d_in), hR(hR_in){}
21
22 virtual ~OperatorLCAO()
23 {
24 if (this->allocated_smatrix)
25 {
26 delete[] this->smatrix_k;
27 }
28 }
29
31 void bind_td_info(TD_info* info);
32
33 /* Function init(k) is used for update HR and HK ,
34 data pointers of HR and HK are not passed by this function, but passed by
35 constructors of every derived classes. No need to override init() in base
36 class, but must override in derived class */
37 virtual void init(const int ik_in) override;
38
39 void refresh_h();
40
41 /* Function getHR() is designed to update HR matrix only, it will loop all
42 contributeHR() functions in chain table. Detail of this function is still in
43 developed, HR matrix has two form: HR_all_spin and HR_one_spin. For NSPIN=2
44 case, HR_one_spin for spin-up and spin-down is not constructed at same time.
45 */
46 // void getHR(TR* hr_pointer);
47
48 /* Function contributeHR() is defined in derived class, for constructing
49 * <phi_{\mu, R}|H|phi_{\nu, 0}>
50 */
51 virtual void contributeHR() { return; }
52
53 /* Function matrixHk() is used for get information of HK matrix and SK matrix for diagolization.
54 Gamma_only case (TK = double), SK would not changed during one SCF loop, a template triangle matrix SK_temp is used
55 for accelerating. General case (TK = std::complex<double>), only pointers of HK and SK saved in OperatorLCAO
56 */
58 {
59 this->get_hs_pointers();
60#ifdef __MPI
62 (size_t)this->hsk->get_pv()->para_2d().nrloc(),
63 (size_t)this->hsk->get_pv()->para_2d().ncloc(),
64 this->hsk->get_pv()->para_2d().desc()};
66 (size_t)this->hsk->get_pv()->para_2d().nrloc(),
67 (size_t)this->hsk->get_pv()->para_2d().ncloc(),
68 this->hsk->get_pv()->para_2d().desc()};
69#else
71 (size_t)this->hsk->get_pv()->para_2d().nrloc(),
72 (size_t)this->hsk->get_pv()->para_2d().ncloc(),
73 nullptr};
74
76 (size_t)this->hsk->get_pv()->para_2d().nrloc(),
77 (size_t)this->hsk->get_pv()->para_2d().ncloc(),
78 nullptr};
79#endif
80 }
81
82 /* Function contributeHk() is defined in derived class, for constructing
83 * <phi_{\mu}|H|phi_{\nu}>(K)
84 */
85 virtual void contributeHk(int ik);
86
92 virtual void set_HR_fixed(void*) { return; }
93
97 void set_hr_done(bool hr_done_in);
98
102 virtual void set_current_spin(const int current_spin_in) { this->current_spin = current_spin_in; }
103
104 // protected:
105 // Hamiltonian matrices which are calculated in OperatorLCAO
107
108 // kvec_d
109 const std::vector<ModuleBase::Vector3<double>>& kvec_d;
110
111 protected:
112 TD_info* td_info_ = nullptr;
113
114 bool new_e_iteration = true;
115
118
121
123 bool hr_done = false;
124
125 private:
126
127 void get_hs_pointers();
128
132 TK* hmatrix_k = nullptr;
133 TK* smatrix_k = nullptr;
134
136 bool allocated_smatrix = false;
137};
138
139} // end namespace hamilt
140
141#endif
3 elements vector
Definition vector3.h:21
Definition td_info.h:18
Definition hcontainer.h:147
Definition hs_matrix_k.h:12
virtual ~OperatorLCAO()
Definition operator_lcao.h:22
virtual void set_current_spin(const int current_spin_in)
set current spin index
Definition operator_lcao.h:102
bool allocated_smatrix
only used for Gamma_only case
Definition operator_lcao.h:136
TD_info * td_info_
Definition operator_lcao.h:112
virtual void contributeHk(int ik)
Definition operator_lcao.cpp:276
virtual void set_HR_fixed(void *)
set_HR_fixed() is used for pass HR_fixed matrix to the next node in sub-chain table not used in base ...
Definition operator_lcao.h:92
HS_Matrix_K< TK > * hsk
Definition operator_lcao.h:106
hamilt::HContainer< TR > * hR
Real-space Hamiltonian pointer.
Definition operator_lcao.h:117
OperatorLCAO(HS_Matrix_K< TK > *hsk_in, const std::vector< ModuleBase::Vector3< double > > &kvec_d_in, HContainer< TR > *hR_in)
H(R) matrix, R is the Bravis lattice vector.
Definition operator_lcao.h:16
virtual void init(const int ik_in) override
Definition operator_lcao.cpp:84
void matrixHk(MatrixBlock< TK > &hk_in, MatrixBlock< TK > &sk_in)
Definition operator_lcao.h:57
void set_hr_done(bool hr_done_in)
reset the status of 'hr_done' (if H(R) is calculated)
Definition operator_lcao.cpp:79
void bind_td_info(TD_info *info)
Bind the solver-owned RT state once, after constructing the operator chain.
Definition operator_lcao.cpp:20
bool hr_done
if H(R) is calculated
Definition operator_lcao.h:123
int current_spin
current spin index
Definition operator_lcao.h:120
bool new_e_iteration
Definition operator_lcao.h:114
void get_hs_pointers()
Definition tmp_mocks.cpp:142
virtual void contributeHR()
Definition operator_lcao.h:51
TK * smatrix_k
Definition operator_lcao.h:133
const std::vector< ModuleBase::Vector3< double > > & kvec_d
Definition operator_lcao.h:109
TK * hmatrix_k
Definition operator_lcao.h:132
void refresh_h()
Definition operator_lcao.cpp:72
int ik
Definition operator.h:123
Operator()
Definition operator.cpp:9
Definition wf_op.cpp:6
A non-owning description of a matrix stored in memory.
Definition matrix_block.h:23