@@ -247,25 +247,33 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
247247 }
248248 } else // NSPIN=4 case
249249 {
250- # ifdef __MPI
250+
251251 // is=0:↑↑, 1:↑↓, 2:↓↑, 3:↓↓
252252 const int row_set[4 ] = {0 , 0 , 1 , 1 };
253253 const int col_set[4 ] = {0 , 1 , 0 , 1 };
254254 int mg = DM2D [0 ]->get_paraV ()->get_global_row_size ()/2 ;
255255 int ng = DM2D [0 ]->get_paraV ()->get_global_col_size ()/2 ;
256256 int nb = DM2D [0 ]->get_paraV ()->get_block_size ()/2 ;
257+ auto ijr_info = DM2D [0 ]->get_ijr_info ();
258+ #ifdef __MPI
257259 int blacs_ctxt = DM2D [0 ]->get_paraV ()->blacs_ctxt ;
258-
259260 std::vector<int > iat2iwt (ucell->nat );
260261 for (int iat = 0 ; iat < ucell->nat ; iat++) {
261262 iat2iwt[iat] = ucell->get_iat2iwt ()[iat]/2 ;
262263 }
263264 Parallel_Orbitals *pv = new Parallel_Orbitals ();
264265 pv->set (mg, ng, nb, blacs_ctxt);
265266 pv->set_atomic_trace (iat2iwt.data (), ucell->nat , mg);
266- auto ijr_info = DM2D [0 ]->get_ijr_info ();
267267 this -> DM2D_tmp = new hamilt::HContainer<double >(pv, nullptr , &ijr_info);
268268 this -> DM2D_tmp->set_zero ();
269+ #else
270+ if (this ->DM2D_tmp != nullptr ) {
271+ delete this ->DM2D_tmp ;
272+ }
273+ this -> DM2D_tmp = new hamilt::HContainer<double >(*this ->hRGint );
274+ this -> DM2D_tmp -> insert_ijrs (this ->gridt ->get_ijr_info (), *(this ->ucell ));
275+ this -> DM2D_tmp -> allocate (nullptr , true );
276+ #endif
269277 ModuleBase::Memory::record (" Gint::DM2D_tmp" , this ->DM2D_tmp ->get_memory_size ());
270278 for (int is = 0 ; is < 4 ; is++){
271279 for (int iap = 0 ; iap < DM2D [0 ]->size_atom_pairs (); ++iap) {
@@ -274,7 +282,7 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
274282 int iat2 = ap.get_atom_j ();
275283 for (int ir = 0 ; ir < ap.get_R_size (); ++ir) {
276284 const ModuleBase::Vector3<int > r_index = ap.get_R_index (ir);
277- double * matrix_out = DM2D_tmp -> find_matrix (iat1, iat2, r_index)->get_pointer ();
285+ double * matrix_out = this -> DM2D_tmp -> find_matrix (iat1, iat2, r_index)->get_pointer ();
278286 double * matrix_in = ap.get_pointer (ir);
279287 for (int irow = 0 ; irow < ap.get_row_size ()/2 ; irow ++) {
280288 for (int icol = 0 ; icol < ap.get_col_size ()/2 ; icol ++) {
@@ -285,11 +293,14 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
285293 }
286294 }
287295 }
296+ #ifdef __MPI
288297 hamilt::transferParallels2Serials ( *(this ->DM2D_tmp ), this ->DMRGint [is]);
289- }
290298#else
291- // this->DMRGint_full = DM2D[0];
299+ this ->DMRGint [is]->set_zero ();
300+ this ->DMRGint [is]->add (*(this ->DM2D_tmp ));
292301#endif
302+ }
303+
293304 }
294305 ModuleBase::timer::tick (" Gint" , " transfer_DMR" );
295306}
0 commit comments