@@ -76,10 +76,6 @@ void DFTU::cal_occ_pw(const int iter, const void* psi_in, const ModuleBase::matr
7676 this ->locale [iat][target_l][0 ][0 ].c [ind_m1m2 + tlp1_2] += (occ[1 ] + occ[2 ]).real ();
7777 this ->locale [iat][target_l][0 ][0 ].c [ind_m1m2 + 2 * tlp1_2] += (occ[1 ] - occ[2 ]).imag ();
7878 this ->locale [iat][target_l][0 ][0 ].c [ind_m1m2 + 3 * tlp1_2] += (occ[0 ] - occ[3 ]).real ();
79- this ->uom_array [eff_pot_pw_index[iat]+ind_m1m2] = this ->locale [iat][target_l][0 ][0 ].c [ind_m1m2];
80- this ->uom_array [eff_pot_pw_index[iat]+ind_m1m2+tlp1_2] = this ->locale [iat][target_l][0 ][0 ].c [ind_m1m2 + tlp1_2];
81- this ->uom_array [eff_pot_pw_index[iat]+ind_m1m2+2 *tlp1_2] = this ->locale [iat][target_l][0 ][0 ].c [ind_m1m2 + 2 * tlp1_2];
82- this ->uom_array [eff_pot_pw_index[iat]+ind_m1m2+3 *tlp1_2] = this ->locale [iat][target_l][0 ][0 ].c [ind_m1m2 + 3 * tlp1_2];
8379 ind_m1m2++;
8480 }
8581 }
@@ -192,6 +188,29 @@ void DFTU::cal_occ_pw(const int iter, const void* psi_in, const ModuleBase::matr
192188 }
193189#endif
194190
191+ // reduce locale from all k-pools
192+ for (int iat = 0 ; iat < cell.nat ; iat++)
193+ {
194+ const int it = cell.iat2it [iat];
195+ const int target_l = this ->orbital_corr [it];
196+ if (target_l == -1 )
197+ {
198+ continue ;
199+ }
200+ const int fold = GlobalV::NSPIN == 4 ? 4 : 1 ;
201+ const int size = (2 * target_l + 1 ) * (2 * target_l + 1 );
202+ Parallel_Reduce::reduce_double_allpool (GlobalV::KPAR , GlobalV::NPROC_IN_POOL , this ->locale [iat][target_l][0 ][0 ].c , size * fold);
203+ // save locale matrix for this iat to uom_save
204+ if (this ->uom_save .size () != 0 )
205+ for (int mm=0 ;mm<size*fold;mm++)
206+ {
207+ this ->uom_save [eff_pot_pw_index[iat]+mm] = this ->locale [iat][target_l][0 ][0 ].c [mm];
208+ }
209+ if (GlobalV::NSPIN == 2 )
210+ {
211+ Parallel_Reduce::reduce_double_allpool (GlobalV::KPAR , GlobalV::NPROC_IN_POOL , this ->locale [iat][target_l][0 ][1 ].c , size);
212+ }
213+ }
195214 // to test omc method: save locale and reset occupation matrix to target values
196215 if (mixing_dftu && initialed_locale)
197216 {
@@ -209,13 +228,7 @@ void DFTU::cal_occ_pw(const int iter, const void* psi_in, const ModuleBase::matr
209228 {
210229 continue ;
211230 }
212- const int fold = GlobalV::NSPIN == 4 ? 4 : 1 ;
213231 const int size = (2 * target_l + 1 ) * (2 * target_l + 1 );
214- Parallel_Reduce::reduce_double_allpool (GlobalV::KPAR , GlobalV::NPROC_IN_POOL , this ->locale [iat][target_l][0 ][0 ].c , size * fold);
215- if (GlobalV::NSPIN == 2 )
216- {
217- Parallel_Reduce::reduce_double_allpool (GlobalV::KPAR , GlobalV::NPROC_IN_POOL , this ->locale [iat][target_l][0 ][1 ].c , size);
218- }
219232 // update effective potential
220233 const double u_value = this ->U [it];
221234 std::complex <double >* vu_iat = &(this ->eff_pot_pw [this ->eff_pot_pw_index [iat]]);
0 commit comments