66namespace ModuleDFTU
77{
88
9- void DFTU::output ()
9+ void DFTU::output (const UnitCell &ucell )
1010{
1111 ModuleBase::TITLE (" DFTU" , " output" );
1212
1313 GlobalV::ofs_running << " //=========================L(S)DA+U===========================//" << std::endl;
1414
15- for (int T = 0 ; T < GlobalC:: ucell.ntype ; T++)
15+ for (int T = 0 ; T < ucell.ntype ; T++)
1616 {
17- const int NL = GlobalC:: ucell.atoms [T].nwl + 1 ;
17+ const int NL = ucell.atoms [T].nwl + 1 ;
1818
1919 for (int L = 0 ; L < NL; L++)
2020 {
21- const int N = GlobalC:: ucell.atoms [T].l_nchi [L];
21+ const int N = ucell.atoms [T].l_nchi [L];
2222
2323 if (L >= orbital_corr[T] && orbital_corr[T] != -1 )
2424 {
@@ -50,7 +50,7 @@ void DFTU::output()
5050 }
5151
5252 GlobalV::ofs_running << " Local occupation matrices" << std::endl;
53- this ->write_occup_m (GlobalV::ofs_running, true );
53+ this ->write_occup_m (ucell, GlobalV::ofs_running, true );
5454 GlobalV::ofs_running << " //=======================================================//" << std::endl;
5555
5656 // Write onsite.dm
@@ -64,7 +64,7 @@ void DFTU::output()
6464 std::cout << " DFTU::write_occup_m. Can't create file onsite.dm!" << std::endl;
6565 exit (0 );
6666 }
67- this ->write_occup_m (ofdftu);
67+ this ->write_occup_m (ucell, ofdftu);
6868 ofdftu.close ();
6969
7070 return ;
@@ -73,24 +73,26 @@ void DFTU::output()
7373// define the function calculate the eigenvalues of a matrix
7474std::vector<double > CalculateEigenvalues (std::vector<std::vector<double >>& A, int n);
7575
76- void DFTU::write_occup_m (std::ofstream &ofs, bool diag)
76+ void DFTU::write_occup_m (const UnitCell& ucell,
77+ std::ofstream &ofs,
78+ bool diag)
7779{
7880 ModuleBase::TITLE (" DFTU" , " write_occup_m" );
7981
8082 if (GlobalV::MY_RANK != 0 ) { return ;
8183}
8284
83- for (int T = 0 ; T < GlobalC:: ucell.ntype ; T++)
85+ for (int T = 0 ; T < ucell.ntype ; T++)
8486 {
8587 if (orbital_corr[T] == -1 ) {
8688 continue ;
8789}
88- const int NL = GlobalC:: ucell.atoms [T].nwl + 1 ;
90+ const int NL = ucell.atoms [T].nwl + 1 ;
8991 const int LC = orbital_corr[T];
9092
91- for (int I = 0 ; I < GlobalC:: ucell.atoms [T].na ; I++)
93+ for (int I = 0 ; I < ucell.atoms [T].na ; I++)
9294 {
93- const int iat = GlobalC:: ucell.itia2iat (T, I);
95+ const int iat = ucell.itia2iat (T, I);
9496 ofs << " atoms"
9597 << " " << iat << std::endl;
9698
@@ -100,7 +102,7 @@ void DFTU::write_occup_m(std::ofstream &ofs, bool diag)
100102 continue ;
101103}
102104
103- const int N = GlobalC:: ucell.atoms [T].l_nchi [l];
105+ const int N = ucell.atoms [T].l_nchi [l];
104106 ofs << " L"
105107 << " " << l << std::endl;
106108
@@ -220,7 +222,8 @@ void DFTU::write_occup_m(std::ofstream &ofs, bool diag)
220222 return ;
221223}
222224
223- void DFTU::read_occup_m (const std::string &fn)
225+ void DFTU::read_occup_m (const UnitCell& ucell,
226+ const std::string &fn)
224227{
225228 ModuleBase::TITLE (" DFTU" , " read_occup_m" );
226229
@@ -270,8 +273,8 @@ void DFTU::read_occup_m(const std::string &fn)
270273 ifdftu >> iat;
271274 ifdftu.ignore (150 , ' \n ' );
272275
273- T = GlobalC:: ucell.iat2it [iat];
274- const int NL = GlobalC:: ucell.atoms [T].nwl + 1 ;
276+ T = ucell.iat2it [iat];
277+ const int NL = ucell.atoms [T].nwl + 1 ;
275278 const int LC = orbital_corr[T];
276279
277280 for (int l = 0 ; l < NL; l++)
@@ -287,7 +290,7 @@ void DFTU::read_occup_m(const std::string &fn)
287290 ifdftu >> L;
288291 ifdftu.ignore (150 , ' \n ' );
289292
290- const int N = GlobalC:: ucell.atoms [T].l_nchi [L];
293+ const int N = ucell.atoms [T].l_nchi [L];
291294 for (int n = 0 ; n < N; n++)
292295 {
293296 // if(!Yukawa && n!=0) continue;
@@ -384,28 +387,28 @@ void DFTU::read_occup_m(const std::string &fn)
384387 return ;
385388}
386389
387- void DFTU::local_occup_bcast ()
390+ void DFTU::local_occup_bcast (const UnitCell& ucell )
388391{
389392 ModuleBase::TITLE (" DFTU" , " local_occup_bcast" );
390393
391- for (int T = 0 ; T < GlobalC:: ucell.ntype ; T++)
394+ for (int T = 0 ; T < ucell.ntype ; T++)
392395 {
393396 if (orbital_corr[T] == -1 ) {
394397 continue ;
395398}
396399
397- for (int I = 0 ; I < GlobalC:: ucell.atoms [T].na ; I++)
400+ for (int I = 0 ; I < ucell.atoms [T].na ; I++)
398401 {
399- const int iat = GlobalC:: ucell.itia2iat (T, I);
402+ const int iat = ucell.itia2iat (T, I);
400403 const int L = orbital_corr[T];
401404
402- for (int l = 0 ; l <= GlobalC:: ucell.atoms [T].nwl ; l++)
405+ for (int l = 0 ; l <= ucell.atoms [T].nwl ; l++)
403406 {
404407 if (l != orbital_corr[T]) {
405408 continue ;
406409}
407410
408- for (int n = 0 ; n < GlobalC:: ucell.atoms [T].l_nchi [l]; n++)
411+ for (int n = 0 ; n < ucell.atoms [T].l_nchi [l]; n++)
409412 {
410413 // if(!Yukawa && n!=0) continue;
411414 if (n != 0 ) {
0 commit comments