@@ -78,33 +78,15 @@ namespace rdmft
7878template <typename TK, typename TR>
7979class RDMFT
8080{
81+
8182 public:
8283 RDMFT ();
8384 ~RDMFT ();
8485
85-
86- /* ***** these parameters are passed in from outside, don't need delete ******/
87- Parallel_Orbitals* ParaV = nullptr ;
86+ const Parallel_Orbitals* ParaV = nullptr ;
8887 Parallel_2D para_Eij;
89- // Parallel_Orbitals para_Eij;
90-
91- // GK and GG are used for multi-k grid integration and gamma only algorithms respectively
92- Gint_k* GK = nullptr ;
93- Gint_Gamma* GG = nullptr ;
94- Charge* charge = nullptr ;
9588 elecstate::ElecState* pelec = nullptr ; // just to gain Ewald and this->pelec->pot
96-
97- // update after ion step
98- UnitCell* ucell = nullptr ;
99- K_Vectors* kv = nullptr ;
100- // LCAO_Matrix* LM = nullptr;
101- ModulePW::PW_Basis* rho_basis = nullptr ;
102- ModuleBase::matrix* vloc = nullptr ;
103- ModuleBase::ComplexMatrix* sf = nullptr ;
104- LCAO_Orbitals* orb = nullptr ;
105- TwoCenterBundle* two_center_bundle = nullptr ;
106- // Local_Orbital_Charge* loc = nullptr; // would be delete in the future
107- /* ***** these parameters are passed in from outside, don't need delete ******/
89+ const K_Vectors* kv = nullptr ; // update after ion step
10890
10991 int nk_total = 0 ;
11092 int nbands_total;
@@ -124,11 +106,56 @@ class RDMFT
124106
125107 // E_RDMFT[4] stores ETV, Ehartree, Exc, Etotal respectively
126108 double E_RDMFT[4 ] = {0.0 };
109+ double Etotal = 0.0 ;
127110 // std::vector<double> E_RDMFT(4);
128111
112+ // ! initialization of rdmft calculation
113+ void init (Gint_Gamma& GG_in, Gint_k& GK_in, Parallel_Orbitals& ParaV_in, UnitCell& ucell_in,
114+ K_Vectors& kv_in, elecstate::ElecState& pelec_in, LCAO_Orbitals& orb_in, TwoCenterBundle& two_center_bundle_in, std::string XC_func_rdmft_in, double alpha_power_in);
115+
116+ // ! update in ion-step and get V_TV
117+ void update_ion (UnitCell& ucell_in, ModulePW::PW_Basis& rho_basis_in,
118+ ModuleBase::matrix& vloc_in, ModuleBase::ComplexMatrix& sf_in);
119+
120+ // ! update in elec-step
121+ // Or we can use rdmft_solver.wfc/occ_number directly when optimizing, so that the update_elec() function does not require parameters.
122+ void update_elec (const ModuleBase::matrix& occ_number_in, const psi::Psi<TK>& wfc_in, const Charge* charge_in = nullptr );
123+
124+ // ! update occ_number for optimization algorithms that depend on Hamilton
125+ void update_occNumber (const ModuleBase::matrix& occ_number_in);
126+
127+ // ! update occ_number for optimization algorithms that depend on Hamilton
128+ void update_wg (const ModuleBase::matrix& wg_in);
129+
130+ // ! do all calculation after update occNum&wfc, get Etotal and the gradient of energy with respect to the occNum&wfc
131+ double run (ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc);
132+
133+
134+ protected:
135+
136+ // ! get the special density matrix DM_XC(nk*nbasis_local*nbasis_local)
137+ void get_DM_XC (std::vector< std::vector<TK> >& DM_XC);
138+
139+ void cal_V_TV ();
140+
141+ void cal_V_hartree ();
142+
143+ // ! construct V_XC based on different XC_functional( i.e. RDMFT class member XC_func_rdmft)
144+ void cal_V_XC ();
145+
146+ double cal_E_gradient ();
147+
148+ void cal_Energy (const int cal_type = 1 );
149+
150+ // ! get the total Hamilton in k-space
151+ void cal_Hk_Hpsi ();
152+
153+ void update_charge ();
154+
155+ private:
156+
129157 hamilt::HContainer<TR>* HR_TV = nullptr ;
130158 hamilt::HContainer<TR>* HR_hartree = nullptr ;
131- // hamilt::HContainer<TR>* HR_XC = nullptr;
132159 hamilt::HContainer<TR>* HR_dft_XC = nullptr ;
133160 hamilt::HContainer<TR>* HR_exx_XC = nullptr ;
134161 // hamilt::HContainer<TR>* HR_local = nullptr;
@@ -156,7 +183,6 @@ class RDMFT
156183 psi::Psi<TK> H_wfc_exx_XC;
157184 psi::Psi<TK> H_wfc_dft_XC;
158185
159- // just for temperate. in the future when realize psiDotPsi() without pzgemm_/pdgemm_,we don't need it
160186 std::vector<TK> Eij_TV;
161187 std::vector<TK> Eij_hartree;
162188 std::vector<TK> Eij_XC;
@@ -166,11 +192,8 @@ class RDMFT
166192 hamilt::OperatorLCAO<TK, TR>* V_nonlocal = nullptr ;
167193 hamilt::OperatorLCAO<TK, TR>* V_local = nullptr ;
168194 hamilt::OperatorLCAO<TK, TR>* V_hartree = nullptr ;
169- // hamilt::OperatorLCAO<TK, TR>* V_XC = nullptr;
170195 hamilt::OperatorLCAO<TK, TR>* V_exx_XC = nullptr ;
171196 hamilt::OperatorLCAO<TK, TR>* V_dft_XC = nullptr ;
172- hamilt::OperatorLCAO<TK, TR>* V_hartree_XC = nullptr ;
173- // bool get_V_local_temp = true;
174197
175198#ifdef __EXX
176199 Exx_LRI<double >* Vxc_fromRI_d = nullptr ;
@@ -179,72 +202,32 @@ class RDMFT
179202 bool exx_spacegroup_symmetry = false ;
180203#endif
181204
182- double Etotal = 0.0 ;
183205 double etxc = 0.0 ;
184206 double vtxc = 0.0 ;
185207 bool only_exx_type = false ;
186208 const int cal_E_type = 1 ; // cal_type = 2 just support XC-functional without exx
187209
188- // ! initialization of rdmft calculation
189- void init (Gint_Gamma& GG_in, Gint_k& GK_in, Parallel_Orbitals& ParaV_in, UnitCell& ucell_in,
190- K_Vectors& kv_in, elecstate::ElecState& pelec_in, LCAO_Orbitals& orb_in, TwoCenterBundle& two_center_bundle_in, std::string XC_func_rdmft_in, double alpha_power_in);
191-
192- // ! update in ion-step and get V_TV
193- void update_ion (UnitCell& ucell_in, ModulePW::PW_Basis& rho_basis_in,
194- ModuleBase::matrix& vloc_in, ModuleBase::ComplexMatrix& sf_in);
195-
196- // ! update in elec-step
197- // Or we can use rdmft_solver.wfc/occ_number directly when optimizing, so that the update_elec() function does not require parameters.
198- void update_elec (const ModuleBase::matrix& occ_number_in, const psi::Psi<TK>& wfc_in, const Charge* charge_in = nullptr );
199-
200- // ! update occ_number for optimization algorithms that depend on Hamilton
201- void update_occNumber (const ModuleBase::matrix& occ_number_in);
202-
203- // ! update occ_number for optimization algorithms that depend on Hamilton
204- void update_wg (const ModuleBase::matrix& wg_in);
205-
206- // ! do all calculation after update occNum&wfc, get Etotal and the gradient of energy with respect to the occNum&wfc
207- double run (ModuleBase::matrix& E_gradient_occNum, psi::Psi<TK>& E_gradient_wfc);
208-
209-
210-
211- protected:
212-
213- // ! get the special density matrix DM_XC(nk*nbasis_local*nbasis_local)
214- void get_DM_XC (std::vector< std::vector<TK> >& DM_XC);
215-
216- void cal_V_TV ();
217210
218- void cal_V_hartree ();
219-
220- // ! construct V_XC based on different XC_functional( i.e. RDMFT class member XC_func_rdmft)
221- void cal_V_XC ();
222-
223- double cal_E_gradient ();
224-
225- void cal_Energy (const int cal_type = 1 );
226-
227-
228-
229- private:
230-
231- // ! get the total Hamilton in k-space
232- void cal_Hk_Hpsi ();
233-
234- void update_charge ();
211+ /* ***** these parameters are passed in from outside, don't need delete ******/
212+ // GK and GG are used for multi-k grid integration and gamma only algorithms respectively
213+ Gint_k* GK = nullptr ;
214+ Gint_Gamma* GG = nullptr ;
215+ Charge* charge = nullptr ;
235216
217+ // update after ion step
218+ const UnitCell* ucell = nullptr ;
219+ const ModulePW::PW_Basis* rho_basis = nullptr ;
220+ const ModuleBase::matrix* vloc = nullptr ;
221+ const ModuleBase::ComplexMatrix* sf = nullptr ;
222+ const LCAO_Orbitals* orb = nullptr ;
223+ const TwoCenterBundle* two_center_bundle = nullptr ;
236224
237225
238226};
239227
240228
241229
242-
243-
244-
245230}
246231
247232
248-
249-
250233#endif
0 commit comments