@@ -29,23 +29,23 @@ extern "C"
2929
3030namespace ModuleDFTU
3131{
32- void DFTU::copy_locale ()
32+ void DFTU::copy_locale (const UnitCell& ucell )
3333{
3434 ModuleBase::TITLE (" DFTU" , " copy_locale" );
3535 ModuleBase::timer::tick (" DFTU" , " copy_locale" );
3636
37- for (int T = 0 ; T < GlobalC:: ucell.ntype ; T++)
37+ for (int T = 0 ; T < ucell.ntype ; T++)
3838 {
3939 if (orbital_corr[T] == -1 )
4040 continue ;
4141
42- for (int I = 0 ; I < GlobalC:: ucell.atoms [T].na ; I++)
42+ for (int I = 0 ; I < ucell.atoms [T].na ; I++)
4343 {
44- const int iat = GlobalC:: ucell.itia2iat (T, I);
44+ const int iat = ucell.itia2iat (T, I);
4545
46- for (int l = 0 ; l < GlobalC:: ucell.atoms [T].nwl + 1 ; l++)
46+ for (int l = 0 ; l < ucell.atoms [T].nwl + 1 ; l++)
4747 {
48- const int N = GlobalC:: ucell.atoms [T].l_nchi [l];
48+ const int N = ucell.atoms [T].l_nchi [l];
4949
5050 for (int n = 0 ; n < N; n++)
5151 {
@@ -65,22 +65,22 @@ void DFTU::copy_locale()
6565 ModuleBase::timer::tick (" DFTU" , " copy_locale" );
6666}
6767
68- void DFTU::zero_locale ()
68+ void DFTU::zero_locale (const UnitCell& ucell )
6969{
7070 ModuleBase::TITLE (" DFTU" , " zero_locale" );
7171 ModuleBase::timer::tick (" DFTU" , " zero_locale" );
7272
73- for (int T = 0 ; T < GlobalC:: ucell.ntype ; T++)
73+ for (int T = 0 ; T < ucell.ntype ; T++)
7474 {
7575 if (orbital_corr[T] == -1 ) continue ;
7676
77- for (int I = 0 ; I < GlobalC:: ucell.atoms [T].na ; I++)
77+ for (int I = 0 ; I < ucell.atoms [T].na ; I++)
7878 {
79- const int iat = GlobalC:: ucell.itia2iat (T, I);
79+ const int iat = ucell.itia2iat (T, I);
8080
81- for (int l = 0 ; l < GlobalC:: ucell.atoms [T].nwl + 1 ; l++)
81+ for (int l = 0 ; l < ucell.atoms [T].nwl + 1 ; l++)
8282 {
83- const int N = GlobalC:: ucell.atoms [T].l_nchi [l];
83+ const int N = ucell.atoms [T].l_nchi [l];
8484
8585 for (int n = 0 ; n < N; n++)
8686 {
@@ -100,25 +100,26 @@ void DFTU::zero_locale()
100100 ModuleBase::timer::tick (" DFTU" , " zero_locale" );
101101}
102102
103- void DFTU::mix_locale (const double & mixing_beta)
103+ void DFTU::mix_locale (const UnitCell& ucell,
104+ const double & mixing_beta)
104105{
105106 ModuleBase::TITLE (" DFTU" , " mix_locale" );
106107 ModuleBase::timer::tick (" DFTU" , " mix_locale" );
107108
108109 double beta = mixing_beta;
109110
110- for (int T = 0 ; T < GlobalC:: ucell.ntype ; T++)
111+ for (int T = 0 ; T < ucell.ntype ; T++)
111112 {
112113 if (orbital_corr[T] == -1 )
113114 continue ;
114115
115- for (int I = 0 ; I < GlobalC:: ucell.atoms [T].na ; I++)
116+ for (int I = 0 ; I < ucell.atoms [T].na ; I++)
116117 {
117- const int iat = GlobalC:: ucell.itia2iat (T, I);
118+ const int iat = ucell.itia2iat (T, I);
118119
119- for (int l = 0 ; l < GlobalC:: ucell.atoms [T].nwl + 1 ; l++)
120+ for (int l = 0 ; l < ucell.atoms [T].nwl + 1 ; l++)
120121 {
121- const int N = GlobalC:: ucell.atoms [T].l_nchi [l];
122+ const int N = ucell.atoms [T].l_nchi [l];
122123
123124 for (int n = 0 ; n < N; n++)
124125 {
@@ -139,16 +140,17 @@ void DFTU::mix_locale(const double& mixing_beta)
139140}
140141
141142void DFTU::cal_occup_m_k (const int iter,
142- const std::vector<std::vector<std::complex <double >>>& dm_k,
143- const K_Vectors& kv,
144- const double & mixing_beta,
145- hamilt::Hamilt<std::complex <double >>* p_ham)
143+ const UnitCell& ucell,
144+ const std::vector<std::vector<std::complex <double >>>& dm_k,
145+ const K_Vectors& kv,
146+ const double & mixing_beta,
147+ hamilt::Hamilt<std::complex <double >>* p_ham)
146148{
147149 ModuleBase::TITLE (" DFTU" , " cal_occup_m_k" );
148150 ModuleBase::timer::tick (" DFTU" , " cal_occup_m_k" );
149151
150- this ->copy_locale ();
151- this ->zero_locale ();
152+ this ->copy_locale (ucell );
153+ this ->zero_locale (ucell );
152154
153155 // =================Part 1======================
154156 // call SCALAPACK routine to calculate the product of the S and density matrix
@@ -196,24 +198,24 @@ void DFTU::cal_occup_m_k(const int iter,
196198#endif
197199
198200 const int spin = kv.isk [ik];
199- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
201+ for (int it = 0 ; it < ucell.ntype ; it++)
200202 {
201- const int NL = GlobalC:: ucell.atoms [it].nwl + 1 ;
203+ const int NL = ucell.atoms [it].nwl + 1 ;
202204 const int LC = orbital_corr[it];
203205
204206 if (LC == -1 )
205207 continue ;
206208
207- for (int ia = 0 ; ia < GlobalC:: ucell.atoms [it].na ; ia++)
209+ for (int ia = 0 ; ia < ucell.atoms [it].na ; ia++)
208210 {
209- const int iat = GlobalC:: ucell.itia2iat (it, ia);
211+ const int iat = ucell.itia2iat (it, ia);
210212
211213 for (int l = 0 ; l < NL; l++)
212214 {
213215 if (l != orbital_corr[it])
214216 continue ;
215217
216- const int N = GlobalC:: ucell.atoms [it].l_nchi [l];
218+ const int N = ucell.atoms [it].l_nchi [l];
217219
218220 for (int n = 0 ; n < N; n++)
219221 {
@@ -260,24 +262,24 @@ void DFTU::cal_occup_m_k(const int iter,
260262 } // end it
261263 } // ik
262264
263- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
265+ for (int it = 0 ; it < ucell.ntype ; it++)
264266 {
265- const int NL = GlobalC:: ucell.atoms [it].nwl + 1 ;
267+ const int NL = ucell.atoms [it].nwl + 1 ;
266268 const int LC = orbital_corr[it];
267269
268270 if (LC == -1 )
269271 continue ;
270272
271- for (int ia = 0 ; ia < GlobalC:: ucell.atoms [it].na ; ia++)
273+ for (int ia = 0 ; ia < ucell.atoms [it].na ; ia++)
272274 {
273- const int iat = GlobalC:: ucell.itia2iat (it, ia);
275+ const int iat = ucell.itia2iat (it, ia);
274276
275277 for (int l = 0 ; l < NL; l++)
276278 {
277279 if (l != orbital_corr[it])
278280 continue ;
279281
280- const int N = GlobalC:: ucell.atoms [it].l_nchi [l];
282+ const int N = ucell.atoms [it].l_nchi [l];
281283
282284 for (int n = 0 ; n < N; n++)
283285 {
@@ -346,20 +348,24 @@ void DFTU::cal_occup_m_k(const int iter,
346348
347349 if (mixing_dftu && initialed_locale)
348350 {
349- this ->mix_locale (mixing_beta);
351+ this ->mix_locale (ucell, mixing_beta);
350352 }
351353
352354 this ->initialed_locale = true ;
353355 ModuleBase::timer::tick (" DFTU" , " cal_occup_m_k" );
354356 return ;
355357}
356358
357- void DFTU::cal_occup_m_gamma (const int iter, const std::vector<std::vector<double >> &dm_gamma, const double & mixing_beta, hamilt::Hamilt<double >* p_ham)
359+ void DFTU::cal_occup_m_gamma (const int iter,
360+ const UnitCell &ucell,
361+ const std::vector<std::vector<double >> &dm_gamma,
362+ const double & mixing_beta,
363+ hamilt::Hamilt<double >* p_ham)
358364{
359365 ModuleBase::TITLE (" DFTU" , " cal_occup_m_gamma" );
360366 ModuleBase::timer::tick (" DFTU" , " cal_occup_m_gamma" );
361- this ->copy_locale ();
362- this ->zero_locale ();
367+ this ->copy_locale (ucell );
368+ this ->zero_locale (ucell );
363369
364370 // =================Part 1======================
365371 // call PBLAS routine to calculate the product of the S and density matrix
@@ -396,21 +402,21 @@ void DFTU::cal_occup_m_gamma(const int iter, const std::vector<std::vector<doubl
396402 this ->paraV ->desc );
397403#endif
398404
399- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
405+ for (int it = 0 ; it < ucell.ntype ; it++)
400406 {
401- const int NL = GlobalC:: ucell.atoms [it].nwl + 1 ;
407+ const int NL = ucell.atoms [it].nwl + 1 ;
402408 if (orbital_corr[it] == -1 )
403409 continue ;
404- for (int ia = 0 ; ia < GlobalC:: ucell.atoms [it].na ; ia++)
410+ for (int ia = 0 ; ia < ucell.atoms [it].na ; ia++)
405411 {
406- const int iat = GlobalC:: ucell.itia2iat (it, ia);
412+ const int iat = ucell.itia2iat (it, ia);
407413
408414 for (int l = 0 ; l < NL; l++)
409415 {
410416 if (l != orbital_corr[it])
411417 continue ;
412418
413- const int N = GlobalC:: ucell.atoms [it].l_nchi [l];
419+ const int N = ucell.atoms [it].l_nchi [l];
414420
415421 for (int n = 0 ; n < N; n++)
416422 {
@@ -494,7 +500,7 @@ void DFTU::cal_occup_m_gamma(const int iter, const std::vector<std::vector<doubl
494500
495501 if (mixing_dftu && initialed_locale)
496502 {
497- this ->mix_locale (mixing_beta);
503+ this ->mix_locale (ucell, mixing_beta);
498504 }
499505
500506 this ->initialed_locale = true ;
0 commit comments