@@ -17,8 +17,11 @@ void DFTU::cal_occ_pw(const int iter, const void* psi_in, const ModuleBase::matr
1717{
1818 ModuleBase::timer::tick (" DFTU" , " cal_occ_pw" );
1919 this ->copy_locale ();
20- this -> zero_locale ();
20+
2121
22+ if (this ->initialed_locale == false )
23+ {
24+ this ->zero_locale ();
2225 if (PARAM .inp .device == " cpu" )
2326 {
2427 auto * onsite_p = projectors::OnsiteProjector<double , base_device::DEVICE_CPU >::get_instance ();
@@ -211,6 +214,28 @@ void DFTU::cal_occ_pw(const int iter, const void* psi_in, const ModuleBase::matr
211214 Parallel_Reduce::reduce_double_allpool (GlobalV::KPAR , GlobalV::NPROC_IN_POOL , this ->locale [iat][target_l][0 ][1 ].c , size);
212215 }
213216 }
217+ }// end if initialed_locale
218+ else
219+ {
220+ for (int iat = 0 ; iat < cell.nat ; iat++)
221+ {
222+ const int it = cell.iat2it [iat];
223+ const int target_l = this ->orbital_corr [it];
224+ if (target_l == -1 )
225+ {
226+ continue ;
227+ }
228+ const int fold = GlobalV::NSPIN == 4 ? 4 : 1 ;
229+ const int size = (2 * target_l + 1 ) * (2 * target_l + 1 );
230+ // save locale matrix for this iat to uom_array
231+ if (this ->uom_array .size () != 0 )
232+ for (int mm=0 ;mm<size*fold;mm++)
233+ {
234+ this ->uom_array [eff_pot_pw_index[iat]+mm] = this ->locale [iat][target_l][0 ][0 ].c [mm];
235+ if (GlobalV::NSPIN == 2 ) this ->uom_array [eff_pot_pw_index[iat]+mm + locale[iat][target_l][0 ][0 ].nr *locale[iat][target_l][0 ][0 ].nc ] = this ->locale [iat][target_l][0 ][1 ].c [mm];
236+ }
237+ }
238+ }
214239 // to test omc method: save locale and reset occupation matrix to target values
215240 if (mixing_dftu && p_chgmix != nullptr )
216241 {
@@ -308,7 +333,7 @@ void DFTU::cal_occ_pw(const int iter, const void* psi_in, const ModuleBase::matr
308333 }
309334 // print calculated locale to check
310335 // this->mix_locale(0);
311- initialed_locale = true ;
336+ initialed_locale = false ;
312337
313338 // update effective potential
314339 ModuleBase::timer::tick (" DFTU" , " cal_occ_pw" );
0 commit comments