Skip to content

Commit a2f7ea7

Browse files
committed
fix serial bug
1 parent 237738a commit a2f7ea7

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

source/source_lcao/module_gint/gint_old.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,15 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
252252
}
253253
} else // NSPIN=4 case
254254
{
255-
#ifdef __MPI
255+
256256
// is=0:↑↑, 1:↑↓, 2:↓↑, 3:↓↓
257257
const int row_set[4] = {0, 0, 1, 1};
258258
const int col_set[4] = {0, 1, 0, 1};
259259
int mg = DM2D[0]->get_paraV()->get_global_row_size()/2;
260260
int ng = DM2D[0]->get_paraV()->get_global_col_size()/2;
261261
int nb = DM2D[0]->get_paraV()->get_block_size()/2;
262+
auto ijr_info = DM2D[0]->get_ijr_info();
263+
#ifdef __MPI
262264
int blacs_ctxt = DM2D[0]->get_paraV()->blacs_ctxt;
263265
std::vector<int> iat2iwt(ucell->nat);
264266
for (int iat = 0; iat < ucell->nat; iat++) {
@@ -267,8 +269,15 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
267269
Parallel_Orbitals *pv = new Parallel_Orbitals();
268270
pv->set(mg, ng, nb, blacs_ctxt);
269271
pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
270-
auto ijr_info = DM2D[0]->get_ijr_info();
271272
this-> dm2d_tmp = new hamilt::HContainer<double>(pv, nullptr, &ijr_info);
273+
#else
274+
if (this->dm2d_tmp != nullptr) {
275+
delete this->dm2d_tmp;
276+
}
277+
this-> dm2d_tmp = new hamilt::HContainer<double>(*this->hRGint);
278+
this-> dm2d_tmp -> insert_ijrs(this->gridt->get_ijr_info(), *(this->ucell));
279+
this-> dm2d_tmp -> allocate(nullptr, true);
280+
#endif
272281
ModuleBase::Memory::record("Gint::dm2d_tmp", this->dm2d_tmp->get_memory_size());
273282
for (int is = 0; is < 4; is++){
274283
for (int iap = 0; iap < DM2D[0]->size_atom_pairs(); ++iap) {
@@ -288,11 +297,14 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
288297
}
289298
}
290299
}
300+
#ifdef __MPI
291301
hamilt::transferParallels2Serials( *(this->dm2d_tmp), this->DMRGint[is]);
292-
}
293302
#else
294-
//this->DMRGint_full = DM2D[0];
303+
this->DMRGint[is]->set_zero();
304+
this->DMRGint[is]->add(*(this->dm2d_tmp));
295305
#endif
306+
}
307+
296308
}
297309
ModuleBase::timer::tick("Gint", "transfer_DMR");
298310
}

source/source_lcao/module_gint/temp_gint/gint_common.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ void transfer_dm_2d_to_gint(
235235
pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
236236
HContainer<T>* dm2d_tmp = new hamilt::HContainer<T>(pv, nullptr, &ijr_info);
237237
#else
238-
auto* dm2d_tmp = new hamilt::HContainer<double>(ucell->nat);
239-
dm2d_tmp -> insert_ijrs(gint_info.get_ijr_info(), *ucell);
238+
auto* dm2d_tmp = new hamilt::HContainer<T>(ucell->nat);
239+
dm2d_tmp -> insert_ijrs(&ijr_info, *ucell);
240240
dm2d_tmp -> allocate(nullptr, true);
241241
#endif
242242
for (int is = 0; is < 4; is++){

0 commit comments

Comments
 (0)