Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions source/module_hamilt_lcao/module_gint/gint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,33 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
}
} else // NSPIN=4 case
{
#ifdef __MPI

// is=0:↑↑, 1:↑↓, 2:↓↑, 3:↓↓
const int row_set[4] = {0, 0, 1, 1};
const int col_set[4] = {0, 1, 0, 1};
int mg = DM2D[0]->get_paraV()->get_global_row_size()/2;
int ng = DM2D[0]->get_paraV()->get_global_col_size()/2;
int nb = DM2D[0]->get_paraV()->get_block_size()/2;
auto ijr_info = DM2D[0]->get_ijr_info();
#ifdef __MPI
int blacs_ctxt = DM2D[0]->get_paraV()->blacs_ctxt;

std::vector<int> iat2iwt(ucell->nat);
for (int iat = 0; iat < ucell->nat; iat++) {
iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2;
}
Parallel_Orbitals *pv = new Parallel_Orbitals();
pv->set(mg, ng, nb, blacs_ctxt);
pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
auto ijr_info = DM2D[0]->get_ijr_info();
this-> DM2D_tmp = new hamilt::HContainer<double>(pv, nullptr, &ijr_info);
this-> DM2D_tmp->set_zero();
#else
if (this->DM2D_tmp != nullptr) {
delete this->DM2D_tmp;
}
this-> DM2D_tmp = new hamilt::HContainer<double>(*this->hRGint);
this-> DM2D_tmp -> insert_ijrs(this->gridt->get_ijr_info(), *(this->ucell));
this-> DM2D_tmp -> allocate(nullptr, true);
#endif
ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size());
for (int is = 0; is < 4; is++){
for (int iap = 0; iap < DM2D[0]->size_atom_pairs(); ++iap) {
Expand All @@ -274,7 +282,7 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
int iat2 = ap.get_atom_j();
for (int ir = 0; ir < ap.get_R_size(); ++ir) {
const ModuleBase::Vector3<int> r_index = ap.get_R_index(ir);
double* matrix_out = DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
double* matrix_out = this-> DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer();
double* matrix_in = ap.get_pointer(ir);
for (int irow = 0; irow < ap.get_row_size()/2; irow ++) {
for (int icol = 0; icol < ap.get_col_size()/2; icol ++) {
Expand All @@ -285,11 +293,14 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
}
}
}
#ifdef __MPI
hamilt::transferParallels2Serials( *(this->DM2D_tmp), this->DMRGint[is]);
}
#else
//this->DMRGint_full = DM2D[0];
this->DMRGint[is]->set_zero();
this->DMRGint[is]->add(*(this->DM2D_tmp));
#endif
}

}
ModuleBase::timer::tick("Gint", "transfer_DMR");
}
15 changes: 9 additions & 6 deletions source/module_hamilt_lcao/module_gint/gint_k_pvpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
ModuleBase::TITLE("Gint_k", "transfer_pvpR");
ModuleBase::timer::tick("Gint_k", "transfer_pvpR");

auto ijr_info = hR->get_ijr_info();

#ifdef __MPI
int mg = hR->get_paraV()->get_global_row_size()/2;
int ng = hR->get_paraV()->get_global_col_size()/2;
int nb = hR->get_paraV()->get_block_size()/2;
#ifdef __MPI
int blacs_ctxt = hR->get_paraV()->blacs_ctxt;
std::vector<int> iat2iwt(ucell_in->nat);
for (int iat = 0; iat < ucell_in->nat; iat++) {
Expand All @@ -90,9 +92,9 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
Parallel_Orbitals *pv = new Parallel_Orbitals();
pv->set(mg, ng, nb, blacs_ctxt);
pv->set_atomic_trace(iat2iwt.data(), ucell_in->nat, mg);
auto ijr_info = hR->get_ijr_info();

this->hR_tmp = new hamilt::HContainer<std::complex<double>>(pv, nullptr, &ijr_info);
#endif

ModuleBase::Memory::record("Gint::hRGintCd", this->hR_tmp->get_memory_size());

//select hRGint_tmp
Expand Down Expand Up @@ -155,8 +157,12 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
}
}
}
#ifdef __MPI
// transfer hRGint_tmpCd to parallel hR_tmp
hamilt::transferSerials2Parallels( *hRGint_tmpCd, this->hR_tmp);
#else
this->hR_tmp = hRGint_tmpCd;
#endif
// merge hR_tmp to hR
for (int iap = 0; iap < hR->size_atom_pairs(); iap++)
{
Expand All @@ -182,9 +188,6 @@ void Gint_k::transfer_pvpR(hamilt::HContainer<std::complex<double>>* hR,
}
delete hRGint_tmpCd;
}
#else

#endif
ModuleBase::timer::tick("Gint_k", "transfer_pvpR");
return;
}
Loading