From 7d4fe5aa9f48b57af742e06c74132593719457ec Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Thu, 21 Aug 2025 21:13:49 +0800 Subject: [PATCH 01/12] delete tem Hcontainer to reduce memory usage --- source/source_lcao/module_gint/gint.h | 2 +- source/source_lcao/module_gint/gint_old.cpp | 100 +++++++++++------- .../module_gint/temp_gint/gint_common.cpp | 91 ++++++++++------ .../module_gint/temp_gint/gint_info.h | 1 + .../source_lcao/module_lr/utils/gint_move.hpp | 4 +- 5 files changed, 121 insertions(+), 77 deletions(-) diff --git a/source/source_lcao/module_gint/gint.h b/source/source_lcao/module_gint/gint.h index 6ca6f53eab..979d5051e2 100644 --- a/source/source_lcao/module_gint/gint.h +++ b/source/source_lcao/module_gint/gint.h @@ -265,7 +265,7 @@ class Gint { std::vector*> DMRGint; //! tmp tools used in transfer_DM2DtoGrid - hamilt::HContainer* DMRGint_full = nullptr; + hamilt::HContainer* DM2D_tmp = nullptr; std::vector> pvdpRx_reduced; std::vector> pvdpRy_reduced; diff --git a/source/source_lcao/module_gint/gint_old.cpp b/source/source_lcao/module_gint/gint_old.cpp index caaf2f92c7..07f24a25ea 100644 --- a/source/source_lcao/module_gint/gint_old.cpp +++ b/source/source_lcao/module_gint/gint_old.cpp @@ -33,7 +33,7 @@ Gint::~Gint() { delete this->hRGint_tmp[is]; } #ifdef __MPI - delete this->DMRGint_full; + delete this->DM2D_tmp; #endif } @@ -171,10 +171,9 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons this->hRGint_tmp[is] = new hamilt::HContainer(ucell_in.nat); } #ifdef __MPI - if (this->DMRGint_full != nullptr) { - delete this->DMRGint_full; + if (this->DM2D_tmp != nullptr) { + delete this->DM2D_tmp; } - this->DMRGint_full = new hamilt::HContainer(ucell_in.nat); #endif } @@ -210,12 +209,6 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons ModuleBase::Memory::record("Gint::DMRGint", this->DMRGint[0]->get_memory_size() * this->DMRGint.size()*nspin); -#ifdef __MPI - this->DMRGint_full->insert_ijrs(this->gridt->get_ijr_info(), ucell_in, npol); - this->DMRGint_full->allocate(nullptr, true); - ModuleBase::Memory::record("Gint::DMRGint_full", - this->DMRGint_full->get_memory_size()); -#endif } } @@ -231,9 +224,7 @@ void Gint::reset_DMRGint(const int& nspin) { for (auto& d : this->DMRGint) { d->allocate(nullptr, false); } #ifdef __MPI - delete this->DMRGint_full; - this->DMRGint_full = new hamilt::HContainer(*this->hRGint); - this->DMRGint_full->allocate(nullptr, false); + delete this->DM2D_tmp; #endif } } @@ -262,37 +253,66 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { } else // NSPIN=4 case { #ifdef __MPI - hamilt::transferParallels2Serials(*DM2D[0], this->DMRGint_full); -#else - this->DMRGint_full = DM2D[0]; -#endif - std::vector tmp_pointer(4, nullptr); - for (int iap = 0; iap < this->DMRGint_full->size_atom_pairs(); ++iap) { - auto& ap = this->DMRGint_full->get_atom_pair(iap); - int iat1 = ap.get_atom_i(); - int iat2 = ap.get_atom_j(); - for (int ir = 0; ir < ap.get_R_size(); ++ir) { - const ModuleBase::Vector3 r_index = ap.get_R_index(ir); - for (int is = 0; is < 4; is++) { - tmp_pointer[is] = this->DMRGint[is] - ->find_matrix(iat1, iat2, r_index) - ->get_pointer(); - } - double* data_full = ap.get_pointer(ir); - for (int irow = 0; irow < ap.get_row_size(); irow += 2) { - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer[0])++ = data_full[icol]; - *(tmp_pointer[1])++ = data_full[icol + 1]; - } - data_full += ap.get_col_size(); - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer[2])++ = data_full[icol]; - *(tmp_pointer[3])++ = data_full[icol + 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; + int blacs_ctxt = DM2D[0]->get_paraV()->blacs_ctxt; + int *iat2iwt = new int[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, ucell->nat, mg); + auto ijr_info = DM2D[0]->get_ijr_info(); + this-> DM2D_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); + 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) { + auto& ap = DM2D[0]->get_atom_pair(iap); + int iat1 = ap.get_atom_i(); + int iat2 = ap.get_atom_j(); + for (int ir = 0; ir < ap.get_R_size(); ++ir) { + const ModuleBase::Vector3 r_index = ap.get_R_index(ir); + double* tmp_pointer = this -> DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer(); + double* data_full = ap.get_pointer(ir); + for (int irow = 0; irow < ap.get_row_size(); irow += 2) { + switch (is) {//todo: It can be written more compactly + case 0: + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol]; + } + data_full += ap.get_col_size() * 2; + break; + case 1: + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol + 1]; + } + data_full += ap.get_col_size() * 2; + break; + case 2: + data_full += ap.get_col_size(); + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol]; + } + data_full += ap.get_col_size(); + break; + case 3: + data_full += ap.get_col_size(); + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol + 1]; + } + data_full += ap.get_col_size(); + break; + } } - data_full += ap.get_col_size(); } } + hamilt::transferParallels2Serials( *(this->DM2D_tmp), this->DMRGint[is]); } +#else + //this->DMRGint_full = DM2D[0]; +#endif } ModuleBase::timer::tick("Gint", "transfer_DMR"); } \ No newline at end of file diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index fc3248ad93..4e09479c26 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -163,44 +163,67 @@ void transfer_dm_2d_to_gint( } else // NSPIN=4 case { #ifdef __MPI - const int npol = 2; - HContainer dm_full = gint_info.get_hr(npol); - hamilt::transferParallels2Serials(*dm[0], &dm_full); -#else - HContainer& dm_full = *(dm[0]); -#endif - std::vector tmp_pointer(4, nullptr); - for (int iap = 0; iap < dm_full.size_atom_pairs(); iap++) - { - auto& ap = dm_full.get_atom_pair(iap); - const int iat1 = ap.get_atom_i(); - const int iat2 = ap.get_atom_j(); - for (int ir = 0; ir < ap.get_R_size(); ir++) - { - const ModuleBase::Vector3 r_index = ap.get_R_index(ir); - for (int is = 0; is < 4; is++) - { - tmp_pointer[is] = - dm_gint[is].find_matrix(iat1, iat2, r_index)->get_pointer(); - } - T* data_full = ap.get_pointer(ir); - for (int irow = 0; irow < ap.get_row_size(); irow += 2) - { - for (int icol = 0; icol < ap.get_col_size(); icol += 2) - { - *(tmp_pointer[0])++ = data_full[icol]; - *(tmp_pointer[1])++ = data_full[icol + 1]; - } - data_full += ap.get_col_size(); - for (int icol = 0; icol < ap.get_col_size(); icol += 2) - { - *(tmp_pointer[2])++ = data_full[icol]; - *(tmp_pointer[3])++ = data_full[icol + 1]; + int mg = dm[0]->get_paraV()->get_global_row_size()/2; + int ng = dm[0]->get_paraV()->get_global_col_size()/2; + int nb = dm[0]->get_paraV()->get_block_size()/2; + int blacs_ctxt = dm[0]->get_paraV()->blacs_ctxt; + const UnitCell* ucell = gint_info.get_ucell(); + int *iat2iwt = new int[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, ucell->nat, mg); + auto ijr_info = dm[0]->get_ijr_info(); + HContainer* DM2D_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); + //ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size()); + for (int is = 0; is < 4; is++){ + for (int iap = 0; iap < dm[0]->size_atom_pairs(); ++iap) { + auto& ap = dm[0]->get_atom_pair(iap); + int iat1 = ap.get_atom_i(); + int iat2 = ap.get_atom_j(); + for (int ir = 0; ir < ap.get_R_size(); ++ir) { + const ModuleBase::Vector3 r_index = ap.get_R_index(ir); + T* tmp_pointer = DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer(); + T* data_full = ap.get_pointer(ir); + for (int irow = 0; irow < ap.get_row_size(); irow += 2) { + switch (is) {//todo: It can be written more compactly + case 0: + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol]; + } + data_full += ap.get_col_size() * 2; + break; + case 1: + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol + 1]; + } + data_full += ap.get_col_size() * 2; + break; + case 2: + data_full += ap.get_col_size(); + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol]; + } + data_full += ap.get_col_size(); + break; + case 3: + data_full += ap.get_col_size(); + for (int icol = 0; icol < ap.get_col_size(); icol += 2) { + *(tmp_pointer)++ = data_full[icol + 1]; + } + data_full += ap.get_col_size(); + break; + } } - data_full += ap.get_col_size(); } } + hamilt::transferParallels2Serials( *DM2D_tmp, &dm_gint[is]); } +#else + //HContainer& dm_full = *(dm[0]); +#endif } ModuleBase::timer::tick("Gint", "transfer_dm_2d_to_gint"); } diff --git a/source/source_lcao/module_gint/temp_gint/gint_info.h b/source/source_lcao/module_gint/temp_gint/gint_info.h index 7cfe476d25..356a62127e 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_info.h +++ b/source/source_lcao/module_gint/temp_gint/gint_info.h @@ -38,6 +38,7 @@ class GintInfo const std::vector& get_trace_lo() const{ return trace_lo_; } int get_lgd() const { return lgd_; } int get_nat() const { return ucell_->nat; } // return the number of atoms in the unitcell + const UnitCell* get_ucell() const { return ucell_; } int get_local_mgrid_num() const { return localcell_info_->get_mgrids_num(); } double get_mgrid_volume() const { return meshgrid_info_->get_volume(); } diff --git a/source/source_lcao/module_lr/utils/gint_move.hpp b/source/source_lcao/module_lr/utils/gint_move.hpp index 0faa68f39d..cddfbd3fe2 100644 --- a/source/source_lcao/module_lr/utils/gint_move.hpp +++ b/source/source_lcao/module_lr/utils/gint_move.hpp @@ -60,8 +60,8 @@ Gint& Gint::operator=(Gint&& rhs) this->pvdpRz_reduced = std::move(rhs.pvdpRz_reduced); this->DMRGint = std::move(rhs.DMRGint); this->hRGint_tmp = std::move(rhs.hRGint_tmp); - this->DMRGint_full = rhs.DMRGint_full; - rhs.DMRGint_full = nullptr; + this->DM2D_tmp = rhs.DM2D_tmp; + rhs.DM2D_tmp = nullptr; return *this; } From e6a198366e456ca8281a725febbbc05b3348e831 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Sat, 6 Sep 2025 21:03:43 +0800 Subject: [PATCH 02/12] simplify the compute code --- source/source_lcao/module_gint/gint_old.cpp | 40 +++++-------------- .../module_gint/temp_gint/gint_common.cpp | 40 +++++-------------- 2 files changed, 20 insertions(+), 60 deletions(-) diff --git a/source/source_lcao/module_gint/gint_old.cpp b/source/source_lcao/module_gint/gint_old.cpp index 07f24a25ea..1e38b5e9f4 100644 --- a/source/source_lcao/module_gint/gint_old.cpp +++ b/source/source_lcao/module_gint/gint_old.cpp @@ -253,6 +253,9 @@ void Gint::transfer_DM2DtoGrid(std::vector*> 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; @@ -274,36 +277,13 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { int iat2 = ap.get_atom_j(); for (int ir = 0; ir < ap.get_R_size(); ++ir) { const ModuleBase::Vector3 r_index = ap.get_R_index(ir); - double* tmp_pointer = this -> DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer(); - double* data_full = ap.get_pointer(ir); - for (int irow = 0; irow < ap.get_row_size(); irow += 2) { - switch (is) {//todo: It can be written more compactly - case 0: - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol]; - } - data_full += ap.get_col_size() * 2; - break; - case 1: - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol + 1]; - } - data_full += ap.get_col_size() * 2; - break; - case 2: - data_full += ap.get_col_size(); - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol]; - } - data_full += ap.get_col_size(); - break; - case 3: - data_full += ap.get_col_size(); - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol + 1]; - } - data_full += ap.get_col_size(); - break; + 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++){ + int index_i = irow* ap.get_col_size()/2 + icol; + int index_j = (irow*2+row_set[is]) * ap.get_col_size() + icol*2+col_set[is]; + matrix_out[index_i] = matrix_in[index_j]; } } } diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index 4e09479c26..37af480d7d 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -163,6 +163,9 @@ void transfer_dm_2d_to_gint( } 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 = dm[0]->get_paraV()->get_global_row_size()/2; int ng = dm[0]->get_paraV()->get_global_col_size()/2; int nb = dm[0]->get_paraV()->get_block_size()/2; @@ -185,36 +188,13 @@ void transfer_dm_2d_to_gint( int iat2 = ap.get_atom_j(); for (int ir = 0; ir < ap.get_R_size(); ++ir) { const ModuleBase::Vector3 r_index = ap.get_R_index(ir); - T* tmp_pointer = DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer(); - T* data_full = ap.get_pointer(ir); - for (int irow = 0; irow < ap.get_row_size(); irow += 2) { - switch (is) {//todo: It can be written more compactly - case 0: - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol]; - } - data_full += ap.get_col_size() * 2; - break; - case 1: - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol + 1]; - } - data_full += ap.get_col_size() * 2; - break; - case 2: - data_full += ap.get_col_size(); - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol]; - } - data_full += ap.get_col_size(); - break; - case 3: - data_full += ap.get_col_size(); - for (int icol = 0; icol < ap.get_col_size(); icol += 2) { - *(tmp_pointer)++ = data_full[icol + 1]; - } - data_full += ap.get_col_size(); - break; + T* matrix_out = DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer(); + T* 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 ++) { + int index_i = irow* ap.get_col_size()/2 + icol; + int index_j = (irow*2+row_set[is]) * ap.get_col_size() + icol*2+col_set[is]; + matrix_out[index_i] = matrix_in[index_j]; } } } From 6d2c711c6e2ca8f943dc46a42d61b31ad7403bdc Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Thu, 11 Sep 2025 13:26:19 +0800 Subject: [PATCH 03/12] change DM2D_tmp to dm2d_tmp, use vector instead of new --- source/source_lcao/module_gint/gint.h | 2 +- source/source_lcao/module_gint/gint_old.cpp | 20 +++++++++---------- .../module_gint/temp_gint/gint_common.cpp | 11 +++++----- .../source_lcao/module_lr/utils/gint_move.hpp | 4 ++-- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/source/source_lcao/module_gint/gint.h b/source/source_lcao/module_gint/gint.h index 979d5051e2..9810b913f2 100644 --- a/source/source_lcao/module_gint/gint.h +++ b/source/source_lcao/module_gint/gint.h @@ -265,7 +265,7 @@ class Gint { std::vector*> DMRGint; //! tmp tools used in transfer_DM2DtoGrid - hamilt::HContainer* DM2D_tmp = nullptr; + hamilt::HContainer* dm2d_tmp = nullptr; std::vector> pvdpRx_reduced; std::vector> pvdpRy_reduced; diff --git a/source/source_lcao/module_gint/gint_old.cpp b/source/source_lcao/module_gint/gint_old.cpp index 1e38b5e9f4..4c0f11c12a 100644 --- a/source/source_lcao/module_gint/gint_old.cpp +++ b/source/source_lcao/module_gint/gint_old.cpp @@ -33,7 +33,7 @@ Gint::~Gint() { delete this->hRGint_tmp[is]; } #ifdef __MPI - delete this->DM2D_tmp; + delete this->dm2d_tmp; #endif } @@ -171,8 +171,8 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons this->hRGint_tmp[is] = new hamilt::HContainer(ucell_in.nat); } #ifdef __MPI - if (this->DM2D_tmp != nullptr) { - delete this->DM2D_tmp; + if (this->dm2d_tmp != nullptr) { + delete this->dm2d_tmp; } #endif } @@ -224,7 +224,7 @@ void Gint::reset_DMRGint(const int& nspin) { for (auto& d : this->DMRGint) { d->allocate(nullptr, false); } #ifdef __MPI - delete this->DM2D_tmp; + delete this->dm2d_tmp; #endif } } @@ -260,16 +260,16 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { int ng = DM2D[0]->get_paraV()->get_global_col_size()/2; int nb = DM2D[0]->get_paraV()->get_block_size()/2; int blacs_ctxt = DM2D[0]->get_paraV()->blacs_ctxt; - int *iat2iwt = new int[ucell->nat]; + std::vector 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, ucell->nat, mg); + pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg); auto ijr_info = DM2D[0]->get_ijr_info(); - this-> DM2D_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); - ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size()); + this-> dm2d_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); + 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) { auto& ap = DM2D[0]->get_atom_pair(iap); @@ -277,7 +277,7 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { int iat2 = ap.get_atom_j(); for (int ir = 0; ir < ap.get_R_size(); ++ir) { const ModuleBase::Vector3 r_index = ap.get_R_index(ir); - double* matrix_out = this -> 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++){ @@ -288,7 +288,7 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { } } } - hamilt::transferParallels2Serials( *(this->DM2D_tmp), this->DMRGint[is]); + hamilt::transferParallels2Serials( *(this->dm2d_tmp), this->DMRGint[is]); } #else //this->DMRGint_full = DM2D[0]; diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index 37af480d7d..7c3649641d 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -171,16 +171,15 @@ void transfer_dm_2d_to_gint( int nb = dm[0]->get_paraV()->get_block_size()/2; int blacs_ctxt = dm[0]->get_paraV()->blacs_ctxt; const UnitCell* ucell = gint_info.get_ucell(); - int *iat2iwt = new int[ucell->nat]; + std::vector 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, ucell->nat, mg); + pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg); auto ijr_info = dm[0]->get_ijr_info(); - HContainer* DM2D_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); - //ModuleBase::Memory::record("Gint::DM2D_tmp", this->DM2D_tmp->get_memory_size()); + HContainer* dm2d_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); for (int is = 0; is < 4; is++){ for (int iap = 0; iap < dm[0]->size_atom_pairs(); ++iap) { auto& ap = dm[0]->get_atom_pair(iap); @@ -188,7 +187,7 @@ void transfer_dm_2d_to_gint( int iat2 = ap.get_atom_j(); for (int ir = 0; ir < ap.get_R_size(); ++ir) { const ModuleBase::Vector3 r_index = ap.get_R_index(ir); - T* matrix_out = DM2D_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer(); + T* matrix_out = dm2d_tmp -> find_matrix(iat1, iat2, r_index)->get_pointer(); T* 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 ++) { @@ -199,7 +198,7 @@ void transfer_dm_2d_to_gint( } } } - hamilt::transferParallels2Serials( *DM2D_tmp, &dm_gint[is]); + hamilt::transferParallels2Serials( *dm2d_tmp, &dm_gint[is]); } #else //HContainer& dm_full = *(dm[0]); diff --git a/source/source_lcao/module_lr/utils/gint_move.hpp b/source/source_lcao/module_lr/utils/gint_move.hpp index cddfbd3fe2..6b4a8c82e6 100644 --- a/source/source_lcao/module_lr/utils/gint_move.hpp +++ b/source/source_lcao/module_lr/utils/gint_move.hpp @@ -60,8 +60,8 @@ Gint& Gint::operator=(Gint&& rhs) this->pvdpRz_reduced = std::move(rhs.pvdpRz_reduced); this->DMRGint = std::move(rhs.DMRGint); this->hRGint_tmp = std::move(rhs.hRGint_tmp); - this->DM2D_tmp = rhs.DM2D_tmp; - rhs.DM2D_tmp = nullptr; + this->dm2d_tmp = rhs.dm2d_tmp; + rhs.dm2d_tmp = nullptr; return *this; } From 6daf2de92aece1cc9c20c1645020a9f4004ecf65 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Tue, 16 Sep 2025 11:05:35 +0800 Subject: [PATCH 04/12] delete hr_gint_full_ to reduce memory --- .../module_gint/temp_gint/gint_common.cpp | 186 +++++++++++------- .../module_gint/temp_gint/gint_common.h | 8 +- .../temp_gint/gint_vl_metagga_nspin4.cpp | 5 +- .../temp_gint/gint_vl_metagga_nspin4.h | 1 - .../temp_gint/gint_vl_metagga_nspin4_gpu.cpp | 5 +- .../temp_gint/gint_vl_metagga_nspin4_gpu.h | 1 - .../module_gint/temp_gint/gint_vl_nspin4.cpp | 5 +- .../module_gint/temp_gint/gint_vl_nspin4.h | 1 - .../temp_gint/gint_vl_nspin4_gpu.cpp | 5 +- .../temp_gint/gint_vl_nspin4_gpu.h | 1 - 10 files changed, 129 insertions(+), 89 deletions(-) diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index 7c3649641d..5b87579ba0 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -47,95 +47,149 @@ void compose_hr_gint(HContainer& hr_gint) ModuleBase::timer::tick("Gint", "compose_hr_gint"); } -void compose_hr_gint(const std::vector>& hr_gint_part, - HContainer>& hr_gint_full) +template +void transfer_hr_gint_to_hR(const HContainer& hr_gint, HContainer& hR) { - ModuleBase::TITLE("Gint", "compose_hr_gint"); - ModuleBase::timer::tick("Gint", "compose_hr_gint"); - for (int iap = 0; iap < hr_gint_full.size_atom_pairs(); iap++) + ModuleBase::TITLE("Gint", "transfer_hr_gint_to_hR"); + ModuleBase::timer::tick("Gint", "transfer_hr_gint_to_hR"); +#ifdef __MPI + int size = 0; + MPI_Comm_size(MPI_COMM_WORLD, &size); + if (size == 1) + { + hR.add(hr_gint); + } + else { - auto* ap = &(hr_gint_full.get_atom_pair(iap)); - const int iat1 = ap->get_atom_i(); - const int iat2 = ap->get_atom_j(); - if (iat1 <= iat2) + hamilt::transferSerials2Parallels(hr_gint, &hR); + } +#else + hR.add(hr_gint); +#endif + ModuleBase::timer::tick("Gint", "transfer_hr_gint_to_hR"); +} + + +void merge_hr_part_to_hR(const std::vector>& hRGint_tmp, + hamilt::HContainer>* hR, + const GintInfo& gint_info){ + ModuleBase::TITLE("Gint_k", "transfer_pvpR"); + ModuleBase::timer::tick("Gint_k", "transfer_pvpR"); + + 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; + const UnitCell* ucell_in = gint_info.get_ucell(); +#ifdef __MPI + int blacs_ctxt = hR->get_paraV()->blacs_ctxt; + std::vector iat2iwt(ucell_in->nat); + for (int iat = 0; iat < ucell_in->nat; iat++) { + iat2iwt[iat] = ucell_in->get_iat2iwt()[iat]/2; + } + 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(); + + auto* hR_tmp = new hamilt::HContainer>(pv, nullptr, &ijr_info); + + //select hRGint_tmp + std::vector first = {0, 1, 1, 0}; + std::vector second= {3, 2, 2, 3}; + //select position in the big matrix + std::vector row_set = {0, 0, 1, 1}; + std::vector col_set = {0, 1, 0, 1}; + //construct complex matrix + std::vector clx_i = {1, 0, 0, -1}; + std::vector clx_j = {0, 1, -1, 0}; + for (int is = 0; is < 4; is++){ + if(!PARAM.globalv.domag && (is==1 || is==2)) continue; + hR_tmp->set_zero(); + hamilt::HContainer>* hRGint_tmpCd = new hamilt::HContainer>(ucell_in->nat); + hRGint_tmpCd->insert_ijrs(&ijr_info, *ucell_in); + hRGint_tmpCd->allocate(nullptr, true); + hRGint_tmpCd->set_zero(); + for (int iap = 0; iap < hRGint_tmpCd->size_atom_pairs(); iap++) { - hamilt::AtomPair>* upper_ap = ap; - hamilt::AtomPair>* lower_ap = hr_gint_full.find_pair(iat2, iat1); - const hamilt::AtomPair* ap_nspin_0 = hr_gint_part[0].find_pair(iat1, iat2); - const hamilt::AtomPair* ap_nspin_3 = hr_gint_part[3].find_pair(iat1, iat2); - for (int ir = 0; ir < upper_ap->get_R_size(); ir++) + auto* ap = &hRGint_tmpCd->get_atom_pair(iap); + const int iat1 = ap->get_atom_i(); + const int iat2 = ap->get_atom_j(); + if (iat1 <= iat2) { - const auto R_index = upper_ap->get_R_index(ir); - auto upper_mat = upper_ap->find_matrix(R_index); - auto mat_nspin_0 = ap_nspin_0->find_matrix(R_index); - auto mat_nspin_3 = ap_nspin_3->find_matrix(R_index); - - // The row size and the col size of upper_matrix is double that of matrix_nspin_0 - for (int irow = 0; irow < mat_nspin_0->get_row_size(); ++irow) - { - for (int icol = 0; icol < mat_nspin_0->get_col_size(); ++icol) + hamilt::AtomPair>* upper_ap = ap; + hamilt::AtomPair>* lower_ap = hRGint_tmpCd->find_pair(iat2, iat1); + const hamilt::AtomPair* ap_nspin1 = hRGint_tmp[first[is]].find_pair(iat1, iat2); + const hamilt::AtomPair* ap_nspin2 = hRGint_tmp[second[is]].find_pair(iat1, iat2); + for (int ir = 0; ir < upper_ap->get_R_size(); ir++) + { + const auto R_index = upper_ap->get_R_index(ir); + auto upper_mat = upper_ap->find_matrix(R_index); + auto mat_nspin1 = ap_nspin1->find_matrix(R_index); + auto mat_nspin2 = ap_nspin2->find_matrix(R_index); + // The row size and the col size of upper_matrix is double that of matrix_nspin_0 + for (int irow = 0; irow < mat_nspin1->get_row_size(); ++irow) { - upper_mat->get_value(2*irow, 2*icol) = mat_nspin_0->get_value(irow, icol) + mat_nspin_3->get_value(irow, icol); - upper_mat->get_value(2*irow+1, 2*icol+1) = mat_nspin_0->get_value(irow, icol) - mat_nspin_3->get_value(irow, icol); + for (int icol = 0; icol < mat_nspin1->get_col_size(); ++icol) + { + upper_mat->get_value(irow, icol) = mat_nspin1->get_value(irow, icol) + + std::complex(clx_i[is], clx_j[is]) * mat_nspin2->get_value(irow, icol); + } } - } - - if (PARAM.globalv.domag) - { - const hamilt::AtomPair* ap_nspin_1 = hr_gint_part[1].find_pair(iat1, iat2); - const hamilt::AtomPair* ap_nspin_2 = hr_gint_part[2].find_pair(iat1, iat2); - const auto mat_nspin_1 = ap_nspin_1->find_matrix(R_index); - const auto mat_nspin_2 = ap_nspin_2->find_matrix(R_index); - for (int irow = 0; irow < mat_nspin_1->get_row_size(); ++irow) + //fill the lower triangle matrix + //When is=0 or 3, the real part does not need conjugation; + //when is=1 or 2, the small matrix is not Hermitian, so conjugation is not needed + if (iat1 < iat2) { - for (int icol = 0; icol < mat_nspin_1->get_col_size(); ++icol) + auto lower_mat = lower_ap->find_matrix(-R_index); + for (int irow = 0; irow < upper_mat->get_row_size(); ++irow) { - upper_mat->get_value(2*irow, 2*icol+1) = mat_nspin_1->get_value(irow, icol) + std::complex(0.0, 1.0) * mat_nspin_2->get_value(irow, icol); - upper_mat->get_value(2*irow+1, 2*icol) = mat_nspin_1->get_value(irow, icol) - std::complex(0.0, 1.0) * mat_nspin_2->get_value(irow, icol); + for (int icol = 0; icol < upper_mat->get_col_size(); ++icol) + { + lower_mat->get_value(icol, irow) = upper_mat->get_value(irow, icol); + } } } + } + } + } - // fill the lower triangle matrix - if (iat1 < iat2) + // transfer hRGint_tmpCd to parallel hR_tmp + hamilt::transferSerials2Parallels( *hRGint_tmpCd, hR_tmp); + // merge hR_tmp to hR + for (int iap = 0; iap < hR->size_atom_pairs(); iap++) + { + auto* ap = &hR->get_atom_pair(iap); + const int iat1 = ap->get_atom_i(); + const int iat2 = ap->get_atom_j(); + auto* ap_nspin = hR_tmp ->find_pair(iat1, iat2); + for (int ir = 0; ir < ap->get_R_size(); ir++) + { + const auto R_index = ap->get_R_index(ir); + auto upper_mat = ap->find_matrix(R_index); + auto mat_nspin = ap_nspin->find_matrix(R_index); + // The row size and the col size of upper_matrix is double that of matrix_nspin_0 + for (int irow = 0; irow < mat_nspin->get_row_size(); ++irow) { - auto lower_mat = lower_ap->find_matrix(-R_index); - for (int irow = 0; irow < upper_mat->get_row_size(); ++irow) + for (int icol = 0; icol < mat_nspin->get_col_size(); ++icol) { - for (int icol = 0; icol < upper_mat->get_col_size(); ++icol) - { - lower_mat->get_value(icol, irow) = conj(upper_mat->get_value(irow, icol)); - } + upper_mat->get_value(2*irow+row_set[is], 2*icol+col_set[is]) = + mat_nspin->get_value(irow, icol); } } } } - } - ModuleBase::timer::tick("Gint", "compose_hr_gint"); -} - -template -void transfer_hr_gint_to_hR(const HContainer& hr_gint, HContainer& hR) -{ - ModuleBase::TITLE("Gint", "transfer_hr_gint_to_hR"); - ModuleBase::timer::tick("Gint", "transfer_hr_gint_to_hR"); -#ifdef __MPI - int size = 0; - MPI_Comm_size(MPI_COMM_WORLD, &size); - if (size == 1) - { - hR.add(hr_gint); - } - else - { - hamilt::transferSerials2Parallels(hr_gint, &hR); + delete hRGint_tmpCd; } #else - hR.add(hr_gint); + #endif - ModuleBase::timer::tick("Gint", "transfer_hr_gint_to_hR"); + ModuleBase::timer::tick("Gint_k", "transfer_pvpR"); + return; } + + // gint_info should not have been a parameter, but it was added to initialize dm_gint_full // In the future, we might try to remove the gint_info parameter template diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.h b/source/source_lcao/module_gint/temp_gint/gint_common.h index 17a324df2b..a03c7307db 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.h +++ b/source/source_lcao/module_gint/temp_gint/gint_common.h @@ -6,12 +6,14 @@ namespace ModuleGint { // fill the lower triangle matrix with the upper triangle matrix void compose_hr_gint(HContainer& hr_gint); - // for nspin=4 case - void compose_hr_gint(const std::vector>& hr_gint_part, - HContainer>& hr_gint_full); + template void transfer_hr_gint_to_hR(const HContainer& hr_gint, HContainer& hR); + // for nspin=4 case + void merge_hr_part_to_hR(const std::vector>& hRGint_tmp, + hamilt::HContainer>* hR, + const GintInfo& gint_info); template void transfer_dm_2d_to_gint( diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.cpp b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.cpp index d5880600b0..5b4c45e5db 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.cpp @@ -14,8 +14,7 @@ void Gint_vl_metagga_nspin4::cal_gint() ModuleBase::timer::tick("Gint", "cal_gint_vl"); init_hr_gint_(); cal_hr_gint_(); - compose_hr_gint(hr_gint_part_, hr_gint_full_); - transfer_hr_gint_to_hR(hr_gint_full_, *hR_); + merge_hr_part_to_hR(hr_gint_part_, hR_, *gint_info_); ModuleBase::timer::tick("Gint", "cal_gint_vl"); } @@ -26,8 +25,6 @@ void Gint_vl_metagga_nspin4::init_hr_gint_() { hr_gint_part_[i] = gint_info_->get_hr(); } - const int npol = 2; - hr_gint_full_ = gint_info_->get_hr>(npol); } void Gint_vl_metagga_nspin4::cal_hr_gint_() diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.h b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.h index 12722fef21..138cb1a277 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.h +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4.h @@ -37,7 +37,6 @@ class Gint_vl_metagga_nspin4 : public Gint const int nspin_ = 4; std::vector> hr_gint_part_; - HContainer> hr_gint_full_; }; } \ No newline at end of file diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.cpp b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.cpp index 9adc4cb137..ec8b940710 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.cpp @@ -13,8 +13,7 @@ void Gint_vl_metagga_nspin4_gpu::cal_gint() ModuleBase::timer::tick("Gint", "cal_gint_vl"); init_hr_gint_(); cal_hr_gint_(); - compose_hr_gint(hr_gint_part_, hr_gint_full_); - transfer_hr_gint_to_hR(hr_gint_full_, *hR_); + merge_hr_part_to_hR(hr_gint_part_, hR_, *gint_info_); ModuleBase::timer::tick("Gint", "cal_gint_vl"); } @@ -25,8 +24,6 @@ void Gint_vl_metagga_nspin4_gpu::init_hr_gint_() { hr_gint_part_[i] = gint_info_->get_hr(); } - const int npol = 2; - hr_gint_full_ = gint_info_->get_hr>(npol); } void Gint_vl_metagga_nspin4_gpu::transfer_cpu_to_gpu_() diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.h b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.h index fd967a63ec..c5f6f7c729 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.h +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_metagga_nspin4_gpu.h @@ -42,7 +42,6 @@ class Gint_vl_metagga_nspin4_gpu : public Gint const int nspin_ = 4; std::vector> hr_gint_part_; - HContainer> hr_gint_full_; std::vector> vr_eff_d_; std::vector> vofk_d_; diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.cpp b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.cpp index 56aca5edeb..14350eb218 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.cpp @@ -13,8 +13,7 @@ void Gint_vl_nspin4::cal_gint() ModuleBase::timer::tick("Gint", "cal_gint_vl"); init_hr_gint_(); cal_hr_gint_(); - compose_hr_gint(hr_gint_part_, hr_gint_full_); - transfer_hr_gint_to_hR(hr_gint_full_, *hR_); + merge_hr_part_to_hR(hr_gint_part_, hR_, *gint_info_); ModuleBase::timer::tick("Gint", "cal_gint_vl"); } @@ -25,8 +24,6 @@ void Gint_vl_nspin4::init_hr_gint_() { hr_gint_part_[i] = gint_info_->get_hr(); } - const int npol = 2; - hr_gint_full_ = gint_info_->get_hr>(npol); } void Gint_vl_nspin4::cal_hr_gint_() diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.h b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.h index eed9827242..97aa47ca58 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.h +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4.h @@ -39,7 +39,6 @@ class Gint_vl_nspin4 : public Gint const int nspin_ = 4; std::vector> hr_gint_part_; - HContainer> hr_gint_full_; }; } // namespace ModuleGint \ No newline at end of file diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp index c070258db5..fa42ee3eb7 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp @@ -13,8 +13,7 @@ void Gint_vl_nspin4_gpu::cal_gint() ModuleBase::timer::tick("Gint", "cal_gint_vl"); init_hr_gint_(); cal_hr_gint_(); - compose_hr_gint(hr_gint_part_, hr_gint_full_); - transfer_hr_gint_to_hR(hr_gint_full_, *hR_); + merge_hr_part_to_hR(hr_gint_part_, *hR_, *gint_info_); ModuleBase::timer::tick("Gint", "cal_gint_vl"); } @@ -25,8 +24,6 @@ void Gint_vl_nspin4_gpu::init_hr_gint_() { hr_gint_part_[i] = gint_info_->get_hr(); } - const int npol = 2; - hr_gint_full_ = gint_info_->get_hr>(npol); } void Gint_vl_nspin4_gpu::transfer_cpu_to_gpu_() diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.h b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.h index 81215b33ac..6d17a9a1bb 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.h +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.h @@ -44,7 +44,6 @@ class Gint_vl_nspin4_gpu : public Gint const int nspin_ = 4; std::vector> hr_gint_part_; - HContainer> hr_gint_full_; std::vector> vr_eff_d_; std::vector> hr_gint_part_d_; From b822832d2c00853c278a8c5e83826003f26469b1 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Tue, 16 Sep 2025 12:04:10 +0800 Subject: [PATCH 05/12] add serial code --- .../module_gint/temp_gint/gint_common.cpp | 26 +++++++++++-------- .../temp_gint/gint_vl_nspin4_gpu.cpp | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index 5b87579ba0..d15a8f7e5e 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -80,6 +80,7 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t int ng = hR->get_paraV()->get_global_col_size()/2; int nb = hR->get_paraV()->get_block_size()/2; const UnitCell* ucell_in = gint_info.get_ucell(); + auto ijr_info = hR->get_ijr_info(); #ifdef __MPI int blacs_ctxt = hR->get_paraV()->blacs_ctxt; std::vector iat2iwt(ucell_in->nat); @@ -89,10 +90,9 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t 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(); - auto* hR_tmp = new hamilt::HContainer>(pv, nullptr, &ijr_info); - + hR_tmp->set_zero(); +#endif //select hRGint_tmp std::vector first = {0, 1, 1, 0}; std::vector second= {3, 2, 2, 3}; @@ -104,7 +104,6 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t std::vector clx_j = {0, 1, -1, 0}; for (int is = 0; is < 4; is++){ if(!PARAM.globalv.domag && (is==1 || is==2)) continue; - hR_tmp->set_zero(); hamilt::HContainer>* hRGint_tmpCd = new hamilt::HContainer>(ucell_in->nat); hRGint_tmpCd->insert_ijrs(&ijr_info, *ucell_in); hRGint_tmpCd->allocate(nullptr, true); @@ -153,9 +152,12 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t } } } - +#ifdef __MPI // transfer hRGint_tmpCd to parallel hR_tmp hamilt::transferSerials2Parallels( *hRGint_tmpCd, hR_tmp); +#else + auto* hR_tmp = hRGint_tmpCd; +#endif // merge hR_tmp to hR for (int iap = 0; iap < hR->size_atom_pairs(); iap++) { @@ -181,9 +183,6 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t } delete hRGint_tmpCd; } -#else - -#endif ModuleBase::timer::tick("Gint_k", "transfer_pvpR"); return; } @@ -216,13 +215,14 @@ void transfer_dm_2d_to_gint( } } 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 = dm[0]->get_paraV()->get_global_row_size()/2; int ng = dm[0]->get_paraV()->get_global_col_size()/2; int nb = dm[0]->get_paraV()->get_block_size()/2; +#ifdef __MPI int blacs_ctxt = dm[0]->get_paraV()->blacs_ctxt; const UnitCell* ucell = gint_info.get_ucell(); std::vector iat2iwt(ucell->nat); @@ -234,6 +234,7 @@ void transfer_dm_2d_to_gint( pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg); auto ijr_info = dm[0]->get_ijr_info(); HContainer* dm2d_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); +#endif for (int is = 0; is < 4; is++){ for (int iap = 0; iap < dm[0]->size_atom_pairs(); ++iap) { auto& ap = dm[0]->get_atom_pair(iap); @@ -252,11 +253,14 @@ void transfer_dm_2d_to_gint( } } } +#ifdef __MPI hamilt::transferParallels2Serials( *dm2d_tmp, &dm_gint[is]); - } #else - //HContainer& dm_full = *(dm[0]); + dm_gint[is].set_zero(); + dm_gint[is].add(*dm2d_tmp); #endif + } + } ModuleBase::timer::tick("Gint", "transfer_dm_2d_to_gint"); } diff --git a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp index fa42ee3eb7..4f9b86c0b4 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_vl_nspin4_gpu.cpp @@ -13,7 +13,7 @@ void Gint_vl_nspin4_gpu::cal_gint() ModuleBase::timer::tick("Gint", "cal_gint_vl"); init_hr_gint_(); cal_hr_gint_(); - merge_hr_part_to_hR(hr_gint_part_, *hR_, *gint_info_); + merge_hr_part_to_hR(hr_gint_part_, hR_, *gint_info_); ModuleBase::timer::tick("Gint", "cal_gint_vl"); } From 6353cf4bafb5fa494a145071727cbf6f00192057 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Tue, 16 Sep 2025 12:22:31 +0800 Subject: [PATCH 06/12] fix bug --- source/source_lcao/module_gint/temp_gint/gint_common.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index d15a8f7e5e..b4b030def0 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -222,9 +222,10 @@ void transfer_dm_2d_to_gint( int mg = dm[0]->get_paraV()->get_global_row_size()/2; int ng = dm[0]->get_paraV()->get_global_col_size()/2; int nb = dm[0]->get_paraV()->get_block_size()/2; + const UnitCell* ucell = gint_info.get_ucell(); + auto ijr_info = dm[0]->get_ijr_info(); #ifdef __MPI int blacs_ctxt = dm[0]->get_paraV()->blacs_ctxt; - const UnitCell* ucell = gint_info.get_ucell(); std::vector iat2iwt(ucell->nat); for (int iat = 0; iat < ucell->nat; iat++) { iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2; @@ -232,8 +233,11 @@ void transfer_dm_2d_to_gint( 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 = dm[0]->get_ijr_info(); HContainer* dm2d_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); +#else + dm2d_tmp = new hamilt::HContainer(ucell->nat); + dm2d_tmp -> insert_ijrs(gint_info.get_ijr_info(), *ucell); + dm2d_tmp -> allocate(nullptr, true); #endif for (int is = 0; is < 4; is++){ for (int iap = 0; iap < dm[0]->size_atom_pairs(); ++iap) { From 6dd0e6dc4551163b6b6311ca38d7d5209c57a03a Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Tue, 16 Sep 2025 12:31:47 +0800 Subject: [PATCH 07/12] fix a not declare bug --- source/source_lcao/module_gint/temp_gint/gint_common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index b4b030def0..4db42590fc 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -235,7 +235,7 @@ void transfer_dm_2d_to_gint( pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg); HContainer* dm2d_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); #else - dm2d_tmp = new hamilt::HContainer(ucell->nat); + auto* dm2d_tmp = new hamilt::HContainer(ucell->nat); dm2d_tmp -> insert_ijrs(gint_info.get_ijr_info(), *ucell); dm2d_tmp -> allocate(nullptr, true); #endif From a2f7ea74943138c82be7b1390496fb00fb42dc75 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Tue, 16 Sep 2025 12:50:46 +0800 Subject: [PATCH 08/12] fix serial bug --- source/source_lcao/module_gint/gint_old.cpp | 20 +++++++++++++++---- .../module_gint/temp_gint/gint_common.cpp | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/source/source_lcao/module_gint/gint_old.cpp b/source/source_lcao/module_gint/gint_old.cpp index 4c0f11c12a..294d8eb289 100644 --- a/source/source_lcao/module_gint/gint_old.cpp +++ b/source/source_lcao/module_gint/gint_old.cpp @@ -252,13 +252,15 @@ void Gint::transfer_DM2DtoGrid(std::vector*> 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 iat2iwt(ucell->nat); for (int iat = 0; iat < ucell->nat; iat++) { @@ -267,8 +269,15 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { 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(pv, nullptr, &ijr_info); +#else + if (this->dm2d_tmp != nullptr) { + delete this->dm2d_tmp; + } + this-> dm2d_tmp = new hamilt::HContainer(*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) { @@ -288,11 +297,14 @@ void Gint::transfer_DM2DtoGrid(std::vector*> 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"); } \ No newline at end of file diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index a2ff02be0c..d6863e9efc 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -235,8 +235,8 @@ void transfer_dm_2d_to_gint( pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg); HContainer* dm2d_tmp = new hamilt::HContainer(pv, nullptr, &ijr_info); #else - auto* dm2d_tmp = new hamilt::HContainer(ucell->nat); - dm2d_tmp -> insert_ijrs(gint_info.get_ijr_info(), *ucell); + auto* dm2d_tmp = new hamilt::HContainer(ucell->nat); + dm2d_tmp -> insert_ijrs(&ijr_info, *ucell); dm2d_tmp -> allocate(nullptr, true); #endif for (int is = 0; is < 4; is++){ From 57a3d2a6565f76a6187b660fa7630c7719303835 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Wed, 24 Sep 2025 11:20:27 +0800 Subject: [PATCH 09/12] Fix the issue of not resetting to zero in the loop --- .../module_gint/temp_gint/gint_common.cpp | 18 +++++++++++------- .../module_gint/temp_gint/gint_info.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index d6863e9efc..7b8b860d94 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -76,11 +76,13 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t ModuleBase::TITLE("Gint_k", "transfer_pvpR"); ModuleBase::timer::tick("Gint_k", "transfer_pvpR"); + const UnitCell* ucell_in = gint_info.get_ucell(); 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; - const UnitCell* ucell_in = gint_info.get_ucell(); - auto ijr_info = hR->get_ijr_info(); + hamilt::HContainer>* hR_tmp; + + #ifdef __MPI int blacs_ctxt = hR->get_paraV()->blacs_ctxt; std::vector iat2iwt(ucell_in->nat); @@ -90,9 +92,10 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t Parallel_Orbitals *pv = new Parallel_Orbitals(); pv->set(mg, ng, nb, blacs_ctxt); pv->set_atomic_trace(iat2iwt.data(), ucell_in->nat, mg); - auto* hR_tmp = new hamilt::HContainer>(pv, nullptr, &ijr_info); - hR_tmp->set_zero(); + auto ijr_info = hR->get_ijr_info(); + hR_tmp = new hamilt::HContainer>(pv, nullptr, &ijr_info); #endif + //select hRGint_tmp std::vector first = {0, 1, 1, 0}; std::vector second= {3, 2, 2, 3}; @@ -104,8 +107,9 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t std::vector clx_j = {0, 1, -1, 0}; for (int is = 0; is < 4; is++){ if(!PARAM.globalv.domag && (is==1 || is==2)) continue; + hR_tmp->set_zero(); hamilt::HContainer>* hRGint_tmpCd = new hamilt::HContainer>(ucell_in->nat); - hRGint_tmpCd->insert_ijrs(&ijr_info, *ucell_in); + hRGint_tmpCd->insert_ijrs( &(gint_info.get_ijr_info()), *(ucell_in)); hRGint_tmpCd->allocate(nullptr, true); hRGint_tmpCd->set_zero(); for (int iap = 0; iap < hRGint_tmpCd->size_atom_pairs(); iap++) @@ -152,11 +156,11 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t } } } -#ifdef __MPI // transfer hRGint_tmpCd to parallel hR_tmp +#ifdef __MPI hamilt::transferSerials2Parallels( *hRGint_tmpCd, hR_tmp); #else - auto* hR_tmp = hRGint_tmpCd; + hR_tmp = hRGint_tmpCd; #endif // merge hR_tmp to hR for (int iap = 0; iap < hR->size_atom_pairs(); iap++) diff --git a/source/source_lcao/module_gint/temp_gint/gint_info.h b/source/source_lcao/module_gint/temp_gint/gint_info.h index 356a62127e..0f311c1bcc 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_info.h +++ b/source/source_lcao/module_gint/temp_gint/gint_info.h @@ -39,6 +39,7 @@ class GintInfo int get_lgd() const { return lgd_; } int get_nat() const { return ucell_->nat; } // return the number of atoms in the unitcell const UnitCell* get_ucell() const { return ucell_; } + const std::vector& get_ijr_info() const {return ijr_info_;} int get_local_mgrid_num() const { return localcell_info_->get_mgrids_num(); } double get_mgrid_volume() const { return meshgrid_info_->get_volume(); } From f8e85bd3c5604dee54ae6e02b663a4ddf3855de4 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Wed, 24 Sep 2025 11:40:56 +0800 Subject: [PATCH 10/12] resolve confilct --- source/source_lcao/module_gint/gint_old.cpp | 1 - source/source_lcao/module_gint/temp_gint/gint_common.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/source/source_lcao/module_gint/gint_old.cpp b/source/source_lcao/module_gint/gint_old.cpp index fdcf4df5df..81c12e6d8f 100644 --- a/source/source_lcao/module_gint/gint_old.cpp +++ b/source/source_lcao/module_gint/gint_old.cpp @@ -269,7 +269,6 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { Parallel_Orbitals pv{}; 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(&pv, nullptr, &ijr_info); #else if (this->dm2d_tmp != nullptr) { diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index cc7e6ec60d..59130286e8 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -237,7 +237,6 @@ void transfer_dm_2d_to_gint( Parallel_Orbitals pv{}; pv.set(mg, ng, nb, blacs_ctxt); pv.set_atomic_trace(iat2iwt.data(), ucell->nat, mg); - auto ijr_info = dm[0]->get_ijr_info(); HContainer dm2d_tmp(&pv, nullptr, &ijr_info); #else auto* dm2d_tmp = new hamilt::HContainer(ucell->nat); From d6d800657d291a51b5ac9a40d47a034268a215e7 Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Wed, 24 Sep 2025 12:08:30 +0800 Subject: [PATCH 11/12] resolve confilct --- source/source_lcao/module_gint/temp_gint/gint_common.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index 59130286e8..a05b9104e8 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -250,7 +250,11 @@ void transfer_dm_2d_to_gint( int iat2 = ap.get_atom_j(); for (int ir = 0; ir < ap.get_R_size(); ++ir) { const ModuleBase::Vector3 r_index = ap.get_R_index(ir); +#ifdef __MPI T* matrix_out = dm2d_tmp.find_matrix(iat1, iat2, r_index)->get_pointer(); +#else + T* matrix_out = dm2d_tmp->find_matrix(iat1, iat2, r_index)->get_pointer(); +#endif T* 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 ++) { From 9f7febc85dbb261c6dbd3be7b80a177eeaaf9e8c Mon Sep 17 00:00:00 2001 From: hn <3022939753@qq.com> Date: Sun, 28 Sep 2025 01:52:40 +0800 Subject: [PATCH 12/12] Change the names to comply with the conventions --- source/source_estate/elecstate_lcao.cpp | 6 +- source/source_lcao/module_gint/gint.h | 10 +- .../module_gint/gint_force_cpu_interface.cpp | 10 +- .../module_gint/gint_gpu_interface.cpp | 6 +- .../source_lcao/module_gint/gint_k_pvpr.cpp | 8 +- source/source_lcao/module_gint/gint_old.cpp | 118 +++++++++--------- .../module_gint/gint_rho_cpu_interface.cpp | 8 +- .../module_gint/gint_vl_cpu_interface.cpp | 4 +- .../module_gint/grid_technique.cpp | 8 +- .../module_gint/temp_gint/gint_common.cpp | 8 +- .../module_gint/temp_gint/gint_common.h | 2 +- .../source_lcao/module_lr/utils/gint_move.hpp | 12 +- 12 files changed, 97 insertions(+), 103 deletions(-) diff --git a/source/source_estate/elecstate_lcao.cpp b/source/source_estate/elecstate_lcao.cpp index 0a02774687..7eaef537b0 100644 --- a/source/source_estate/elecstate_lcao.cpp +++ b/source/source_estate/elecstate_lcao.cpp @@ -35,7 +35,7 @@ void ElecStateLCAO>::psiToRho(const psi::Psigint_k->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint + this->gint_k->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer dm2d to DM_grid in gint Gint_inout inout(this->charge->rho, Gint_Tools::job_type::rho, PARAM.inp.nspin); this->gint_k->cal_gint(&inout); #else @@ -72,7 +72,7 @@ void ElecStateLCAO::psiToRho(const psi::Psi& psi) ModuleBase::GlobalFunc::NOTE("Calculate the charge on real space grid!"); #ifdef __OLD_GINT - this->gint_gamma->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint + this->gint_gamma->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer dm2d to DM_grid in gint Gint_inout inout(this->charge->rho, Gint_Tools::job_type::rho, PARAM.inp.nspin); this->gint_gamma->cal_gint(&inout); #else @@ -140,7 +140,7 @@ void ElecStateLCAO::dmToRho(std::vector pexsi_DM, std::vectorgint_gamma->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint + this->gint_gamma->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer dm2d to DM_grid in gint Gint_inout inout(this->charge->rho, Gint_Tools::job_type::rho, PARAM.inp.nspin); this->gint_gamma->cal_gint(&inout); #else diff --git a/source/source_lcao/module_gint/gint.h b/source/source_lcao/module_gint/gint.h index 9810b913f2..3c447b7e4f 100644 --- a/source/source_lcao/module_gint/gint.h +++ b/source/source_lcao/module_gint/gint.h @@ -26,7 +26,7 @@ class Gint { hamilt::HContainer* get_hRGint() const { return hRGint; } - std::vector*> get_DMRGint() const { return DMRGint; } + std::vector*> get_DMRGint() const { return dmr_gint; } int get_ncxyz() const { return ncxyz; } @@ -58,14 +58,14 @@ class Gint { void initialize_pvpR(const UnitCell& unitcell, const Grid_Driver* gd, const int& nspin); /** - * @brief resize DMRGint to nspin and reallocate the memory + * @brief resize dmr_gint to nspin and reallocate the memory */ void reset_DMRGint(const int& nspin); /** * @brief transfer DMR (2D para) to DMR (Grid para) in elecstate_lcao.cpp */ - void transfer_DM2DtoGrid(std::vector*> DM2D); + void transfer_DM2DtoGrid(std::vector*> dm2d); const Grid_Technique* gridt = nullptr; const UnitCell* ucell; @@ -256,13 +256,13 @@ class Gint { hamilt::HContainer* hRGint = nullptr; //! size of vec is 4, only used when nspin = 4 - std::vector*> hRGint_tmp; + std::vector*> hr_gint_tmp; //! stores Hamiltonian in sparse format hamilt::HContainer>* hRGintCd = nullptr; //! stores DMR in sparse format - std::vector*> DMRGint; + std::vector*> dmr_gint; //! tmp tools used in transfer_DM2DtoGrid hamilt::HContainer* dm2d_tmp = nullptr; diff --git a/source/source_lcao/module_gint/gint_force_cpu_interface.cpp b/source/source_lcao/module_gint/gint_force_cpu_interface.cpp index e3b6a30077..f4f346783d 100644 --- a/source/source_lcao/module_gint/gint_force_cpu_interface.cpp +++ b/source/source_lcao/module_gint/gint_force_cpu_interface.cpp @@ -82,7 +82,7 @@ void Gint::gint_kernel_force(Gint_inout* inout) { cal_flag.get_ptr_2D(), psir_vlbr3.get_ptr_2D(), psir_vlbr3_DM.get_ptr_2D(), - this->DMRGint[inout->ispin], + this->dmr_gint[inout->ispin], false); if(inout->isforce) @@ -230,19 +230,19 @@ void Gint::gint_kernel_force_meta(Gint_inout* inout) { //calculating g_mu(r) = sum_nu rho_mu,nu f_nu(r) Gint_Tools::mult_psi_DMR(*this->gridt, this->bxyz, LD_pool, grid_index, na_grid, block_index.data(), block_size.data(), cal_flag.get_ptr_2D(), - psir_vlbr3.get_ptr_2D(), psir_vlbr3_DM.get_ptr_2D(), this->DMRGint[inout->ispin], false); + psir_vlbr3.get_ptr_2D(), psir_vlbr3_DM.get_ptr_2D(), this->dmr_gint[inout->ispin], false); Gint_Tools::mult_psi_DMR(*this->gridt, this->bxyz, LD_pool, grid_index, na_grid, block_index.data(), block_size.data(), cal_flag.get_ptr_2D(), - dpsir_x_vlbr3.get_ptr_2D(), dpsirx_v_DM.get_ptr_2D(), this->DMRGint[inout->ispin], false); + dpsir_x_vlbr3.get_ptr_2D(), dpsirx_v_DM.get_ptr_2D(), this->dmr_gint[inout->ispin], false); Gint_Tools::mult_psi_DMR(*this->gridt, this->bxyz, LD_pool, grid_index, na_grid, block_index.data(), block_size.data(), cal_flag.get_ptr_2D(), - dpsir_y_vlbr3.get_ptr_2D(), dpsiry_v_DM.get_ptr_2D(), this->DMRGint[inout->ispin], false); + dpsir_y_vlbr3.get_ptr_2D(), dpsiry_v_DM.get_ptr_2D(), this->dmr_gint[inout->ispin], false); Gint_Tools::mult_psi_DMR(*this->gridt, this->bxyz, LD_pool, grid_index, na_grid, block_index.data(), block_size.data(), cal_flag.get_ptr_2D(), - dpsir_z_vlbr3.get_ptr_2D(), dpsirz_v_DM.get_ptr_2D(), this->DMRGint[inout->ispin], false); + dpsir_z_vlbr3.get_ptr_2D(), dpsirz_v_DM.get_ptr_2D(), this->dmr_gint[inout->ispin], false); if(inout->isforce) { diff --git a/source/source_lcao/module_gint/gint_gpu_interface.cpp b/source/source_lcao/module_gint/gint_gpu_interface.cpp index f033722ecf..8e8e362f23 100644 --- a/source/source_lcao/module_gint/gint_gpu_interface.cpp +++ b/source/source_lcao/module_gint/gint_gpu_interface.cpp @@ -18,7 +18,7 @@ void Gint::gpu_vlocal_interface(Gint_inout* inout) { ylmcoef[i] = ModuleBase::Ylm::ylmcoef[i]; } - hamilt::HContainer* hRGint_kernel = PARAM.inp.nspin != 4 ? this->hRGint : this->hRGint_tmp[inout->ispin]; + hamilt::HContainer* hRGint_kernel = PARAM.inp.nspin != 4 ? this->hRGint : this->hr_gint_tmp[inout->ispin]; GintKernel::gint_vl_gpu(hRGint_kernel, inout->vl, ylmcoef, @@ -45,7 +45,7 @@ void Gint::gpu_rho_interface(Gint_inout* inout) { int nrxx = this->gridt->ncx * this->gridt->ncy * this->nplane; for (int is = 0; is < PARAM.inp.nspin; ++is) { ModuleBase::GlobalFunc::ZEROS(inout->rho[is], nrxx); - GintKernel::gint_rho_gpu(this->DMRGint[is], + GintKernel::gint_rho_gpu(this->dmr_gint[is], ylmcoef, dr, this->gridt->rcuts.data(), @@ -76,7 +76,7 @@ void Gint::gpu_force_interface(Gint_inout* inout) { if (isforce || isstress) { std::vector force(nat * 3, 0.0); std::vector stress(6, 0.0); - GintKernel::gint_fvl_gpu(this->DMRGint[inout->ispin], + GintKernel::gint_fvl_gpu(this->dmr_gint[inout->ispin], inout->vl, force.data(), stress.data(), diff --git a/source/source_lcao/module_gint/gint_k_pvpr.cpp b/source/source_lcao/module_gint/gint_k_pvpr.cpp index e59ed4443d..8f98e1dcaf 100644 --- a/source/source_lcao/module_gint/gint_k_pvpr.cpp +++ b/source/source_lcao/module_gint/gint_k_pvpr.cpp @@ -89,8 +89,8 @@ void Gint_k::transfer_pvpR(hamilt::HContainer>* hR, { hamilt::AtomPair>* upper_ap = ap; hamilt::AtomPair>* lower_ap = this->hRGintCd->find_pair(iat2, iat1); - const hamilt::AtomPair* ap_nspin_0 = this->hRGint_tmp[0]->find_pair(iat1, iat2); - const hamilt::AtomPair* ap_nspin_3 = this->hRGint_tmp[3]->find_pair(iat1, iat2); + const hamilt::AtomPair* ap_nspin_0 = this->hr_gint_tmp[0]->find_pair(iat1, iat2); + const hamilt::AtomPair* ap_nspin_3 = this->hr_gint_tmp[3]->find_pair(iat1, iat2); for (int ir = 0; ir < upper_ap->get_R_size(); ir++) { const auto R_index = upper_ap->get_R_index(ir); @@ -110,8 +110,8 @@ void Gint_k::transfer_pvpR(hamilt::HContainer>* hR, if (PARAM.globalv.domag) { - const hamilt::AtomPair* ap_nspin_1 = this->hRGint_tmp[1]->find_pair(iat1, iat2); - const hamilt::AtomPair* ap_nspin_2 = this->hRGint_tmp[2]->find_pair(iat1, iat2); + const hamilt::AtomPair* ap_nspin_1 = this->hr_gint_tmp[1]->find_pair(iat1, iat2); + const hamilt::AtomPair* ap_nspin_2 = this->hr_gint_tmp[2]->find_pair(iat1, iat2); const auto mat_nspin_1 = ap_nspin_1->find_matrix(R_index); const auto mat_nspin_2 = ap_nspin_2->find_matrix(R_index); for (int irow = 0; irow < mat_nspin_1->get_row_size(); ++irow) diff --git a/source/source_lcao/module_gint/gint_old.cpp b/source/source_lcao/module_gint/gint_old.cpp index 81c12e6d8f..73b666581c 100644 --- a/source/source_lcao/module_gint/gint_old.cpp +++ b/source/source_lcao/module_gint/gint_old.cpp @@ -24,13 +24,13 @@ Gint::~Gint() { delete this->hRGint; delete this->hRGintCd; - // in gamma_only case, DMRGint.size()=0, - // in multi-k case, DMRGint.size()=nspin - for (int is = 0; is < this->DMRGint.size(); is++) { - delete this->DMRGint[is]; + // in gamma_only case, dmr_gint.size()=0, + // in multi-k case, dmr_gint.size()=nspin + for (int is = 0; is < this->dmr_gint.size(); is++) { + delete this->dmr_gint[is]; } - for(int is = 0; is < this->hRGint_tmp.size(); is++) { - delete this->hRGint_tmp[is]; + for(int is = 0; is < this->hr_gint_tmp .size(); is++) { + delete this->hr_gint_tmp [is]; } #ifdef __MPI delete this->dm2d_tmp; @@ -141,13 +141,12 @@ void Gint::prep_grid(const Grid_Technique& gt, void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, const int& nspin) { ModuleBase::TITLE("Gint", "initialize_pvpR"); - int npol = 1; - // there is the only resize code of DMRGint - if (this->DMRGint.size() == 0) { - this->DMRGint.resize(nspin); + // there is the only resize code of dmr_gint + if (this->dmr_gint.size() == 0) { + this->dmr_gint.resize(nspin); } - hRGint_tmp.resize(nspin); + hr_gint_tmp.resize(nspin); if (nspin != 4) { if (this->hRGint != nullptr) { delete this->hRGint; @@ -161,14 +160,14 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons this->hRGintCd = new hamilt::HContainer>(ucell_in.nat); for (int is = 0; is < nspin; is++) { - if (this->DMRGint[is] != nullptr) { - delete this->DMRGint[is]; + if (this->dmr_gint[is] != nullptr) { + delete this->dmr_gint[is]; } - if (this->hRGint_tmp[is] != nullptr) { - delete this->hRGint_tmp[is]; + if (this->hr_gint_tmp[is] != nullptr) { + delete this->hr_gint_tmp[is]; } - this->DMRGint[is] = new hamilt::HContainer(ucell_in.nat); - this->hRGint_tmp[is] = new hamilt::HContainer(ucell_in.nat); + this->dmr_gint[is] = new hamilt::HContainer(ucell_in.nat); + this->hr_gint_tmp[is] = new hamilt::HContainer(ucell_in.nat); } #ifdef __MPI if (this->dm2d_tmp != nullptr) { @@ -176,7 +175,6 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons } #endif } - if (PARAM.globalv.gamma_only_local && nspin != 4) { this->hRGint->fix_gamma(); } @@ -185,30 +183,30 @@ void Gint::initialize_pvpR(const UnitCell& ucell_in, const Grid_Driver* gd, cons this->hRGint->allocate(nullptr, true); ModuleBase::Memory::record("Gint::hRGint", this->hRGint->get_memory_size()); - // initialize DMRGint with hRGint when NSPIN != 4 - for (int is = 0; is < this->DMRGint.size(); is++) { - if (this->DMRGint[is] != nullptr) { - delete this->DMRGint[is]; + // initialize dmr_gint with hRGint when NSPIN != 4 + for (int is = 0; is < this->dmr_gint.size(); is++) { + if (this->dmr_gint[is] != nullptr) { + delete this->dmr_gint[is]; } - this->DMRGint[is] = new hamilt::HContainer(*this->hRGint); + this->dmr_gint[is] = new hamilt::HContainer(*this->hRGint); } - ModuleBase::Memory::record("Gint::DMRGint", - this->DMRGint[0]->get_memory_size() - * this->DMRGint.size()); + ModuleBase::Memory::record("Gint::dmr_gint", + this->dmr_gint[0]->get_memory_size() + * this->dmr_gint.size()); } else { this->hRGintCd->insert_ijrs(this->gridt->get_ijr_info(), ucell_in, npol); this->hRGintCd->allocate(nullptr, true); for(int is = 0; is < nspin; is++) { - this->hRGint_tmp[is]->insert_ijrs(this->gridt->get_ijr_info(), ucell_in); - this->DMRGint[is]->insert_ijrs(this->gridt->get_ijr_info(), ucell_in); - this->hRGint_tmp[is]->allocate(nullptr, true); - this->DMRGint[is]->allocate(nullptr, true); + this->hr_gint_tmp[is]->insert_ijrs(this->gridt->get_ijr_info(), ucell_in); + this->dmr_gint[is]->insert_ijrs(this->gridt->get_ijr_info(), ucell_in); + this->hr_gint_tmp[is]->allocate(nullptr, true); + this->dmr_gint[is]->allocate(nullptr, true); } - ModuleBase::Memory::record("Gint::hRGint_tmp", - this->hRGint_tmp[0]->get_memory_size()*nspin); - ModuleBase::Memory::record("Gint::DMRGint", - this->DMRGint[0]->get_memory_size() - * this->DMRGint.size()*nspin); + ModuleBase::Memory::record("Gint::hr_gint_tmp", + this->hr_gint_tmp[0]->get_memory_size()*nspin); + ModuleBase::Memory::record("Gint::dmr_gint", + this->dmr_gint[0]->get_memory_size() + * this->dmr_gint.size()*nspin); } } @@ -216,13 +214,13 @@ void Gint::reset_DMRGint(const int& nspin) { if (this->hRGint) { - for (auto& d : this->DMRGint) { delete d; } - this->DMRGint.resize(nspin); - this->DMRGint.shrink_to_fit(); - for (auto& d : this->DMRGint) { d = new hamilt::HContainer(*this->hRGint); } + for (auto& d : this->dmr_gint) { delete d; } + this->dmr_gint.resize(nspin); + this->dmr_gint.shrink_to_fit(); + for (auto& d : this->dmr_gint) { d = new hamilt::HContainer(*this->hRGint); } if (nspin == 4) { - for (auto& d : this->DMRGint) { d->allocate(nullptr, false); } + for (auto& d : this->dmr_gint) { d->allocate(nullptr, false); } #ifdef __MPI delete this->dm2d_tmp; #endif @@ -230,38 +228,35 @@ void Gint::reset_DMRGint(const int& nspin) } } -void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { +void Gint::transfer_DM2DtoGrid(std::vector*> dm2d) { ModuleBase::TITLE("Gint", "transfer_DMR"); - - // To check whether input parameter DM2D has been initialized + // To check whether input parameter dm2d has been initialized #ifdef __DEBUG - assert(!DM2D.empty() - && "Input parameter DM2D has not been initialized while calling " + assert(!dm2d.empty() + && "Input parameter dm2d has not been initialized while calling " "function transfer_DM2DtoGrid!"); #endif - ModuleBase::timer::tick("Gint", "transfer_DMR"); if (PARAM.inp.nspin != 4) { - for (int is = 0; is < this->DMRGint.size(); is++) { + for (int is = 0; is < this->dmr_gint.size(); is++) { #ifdef __MPI - hamilt::transferParallels2Serials(*DM2D[is], DMRGint[is]); + hamilt::transferParallels2Serials(*dm2d[is], dmr_gint[is]); #else - this->DMRGint[is]->set_zero(); - this->DMRGint[is]->add(*DM2D[is]); + this->dmr_gint[is]->set_zero(); + this->dmr_gint[is]->add(*dm2d[is]); #endif } } else // NSPIN=4 case { - // 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(); + 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; + int blacs_ctxt = dm2d[0]->get_paraV()->blacs_ctxt; std::vector iat2iwt(ucell->nat); for (int iat = 0; iat < ucell->nat; iat++) { iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2; @@ -278,11 +273,10 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { 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) { - auto& ap = DM2D[0]->get_atom_pair(iap); + for (int iap = 0; iap < dm2d[0]->size_atom_pairs(); ++iap) { + auto& ap = dm2d[0]->get_atom_pair(iap); int iat1 = ap.get_atom_i(); int iat2 = ap.get_atom_j(); for (int ir = 0; ir < ap.get_R_size(); ++ir) { @@ -299,10 +293,10 @@ void Gint::transfer_DM2DtoGrid(std::vector*> DM2D) { } } #ifdef __MPI - hamilt::transferParallels2Serials( *(this->dm2d_tmp), this->DMRGint[is]); + hamilt::transferParallels2Serials( *(this->dm2d_tmp), this->dmr_gint[is]); #else - this->DMRGint[is]->set_zero(); - this->DMRGint[is]->add(*(this->dm2d_tmp)); + this->dmr_gint[is]->set_zero(); + this->dmr_gint[is]->add(*(this->dm2d_tmp)); #endif }//is=4 delete this->dm2d_tmp; diff --git a/source/source_lcao/module_gint/gint_rho_cpu_interface.cpp b/source/source_lcao/module_gint/gint_rho_cpu_interface.cpp index 073a1821b0..2f41152fc3 100644 --- a/source/source_lcao/module_gint/gint_rho_cpu_interface.cpp +++ b/source/source_lcao/module_gint/gint_rho_cpu_interface.cpp @@ -76,7 +76,7 @@ void Gint::gint_kernel_rho(Gint_inout* inout) { cal_flag.get_ptr_2D(), psir_ylm_1.get_ptr_2D(), psir_DM.get_ptr_2D(), - this->DMRGint[is], + this->dmr_gint[is], inout->if_symm); // do sum_mu g_mu(r)psi_mu(r) to get electron density on grid @@ -156,7 +156,7 @@ void Gint::gint_kernel_tau(Gint_inout* inout) { cal_flag.get_ptr_2D(), dpsir_ylm_x.get_ptr_2D(), dpsix_DM.get_ptr_2D(), - this->DMRGint[is], + this->dmr_gint[is], true); Gint_Tools::mult_psi_DMR( *this->gridt, this->bxyz, @@ -166,7 +166,7 @@ void Gint::gint_kernel_tau(Gint_inout* inout) { cal_flag.get_ptr_2D(), dpsir_ylm_y.get_ptr_2D(), dpsiy_DM.get_ptr_2D(), - this->DMRGint[is], + this->dmr_gint[is], true); Gint_Tools::mult_psi_DMR( *this->gridt, this->bxyz, @@ -176,7 +176,7 @@ void Gint::gint_kernel_tau(Gint_inout* inout) { cal_flag.get_ptr_2D(), dpsir_ylm_z.get_ptr_2D(), dpsiz_DM.get_ptr_2D(), - this->DMRGint[is], + this->dmr_gint[is], true); //do sum_i,mu g_i,mu(r) * d/dx_i psi_mu(r) to get kinetic energy density on grid diff --git a/source/source_lcao/module_gint/gint_vl_cpu_interface.cpp b/source/source_lcao/module_gint/gint_vl_cpu_interface.cpp index 4f65c1147a..f913fab83e 100644 --- a/source/source_lcao/module_gint/gint_vl_cpu_interface.cpp +++ b/source/source_lcao/module_gint/gint_vl_cpu_interface.cpp @@ -12,7 +12,7 @@ void Gint::gint_kernel_vlocal(Gint_inout* inout) { const int ncyz = this->ny * this->nplane; const double dv = ucell.omega / this->ncxyz; const double delta_r = this->gridt->dr_uniform; - hamilt::HContainer* hRGint_kernel = PARAM.inp.nspin != 4 ? this->hRGint : this->hRGint_tmp[inout->ispin]; + hamilt::HContainer* hRGint_kernel = PARAM.inp.nspin != 4 ? this->hRGint : this->hr_gint_tmp[inout->ispin]; hRGint_kernel->set_zero(); #pragma omp parallel @@ -166,7 +166,7 @@ void Gint::gint_kernel_vlocal_meta(Gint_inout* inout) { const int ncyz = this->ny * this->nplane; const double dv = ucell.omega / this->ncxyz; const double delta_r = this->gridt->dr_uniform; - hamilt::HContainer* hRGint_kernel = PARAM.inp.nspin != 4 ? this->hRGint : this->hRGint_tmp[inout->ispin]; + hamilt::HContainer* hRGint_kernel = PARAM.inp.nspin != 4 ? this->hRGint : this->hr_gint_tmp[inout->ispin]; hRGint_kernel->set_zero(); const int nnrg = hRGint_kernel->get_nnr(); diff --git a/source/source_lcao/module_gint/grid_technique.cpp b/source/source_lcao/module_gint/grid_technique.cpp index 9241c81d0a..de52f4d5f9 100644 --- a/source/source_lcao/module_gint/grid_technique.cpp +++ b/source/source_lcao/module_gint/grid_technique.cpp @@ -556,7 +556,7 @@ void Grid_Technique::init_ijr_and_nnrg(const UnitCell& ucell, const Grid_Driver& { ModuleBase::TITLE("Grid_Technique", "init_ijr_and_nnrg"); - hamilt::HContainer hRGint_tmp(ucell.nat); + hamilt::HContainer hr_gint_tmp(ucell.nat); // prepare the row_index and col_index for construct AtomPairs, they are // same, name as orb_index std::vector orb_index(ucell.nat + 1); @@ -614,15 +614,15 @@ void Grid_Technique::init_ijr_and_nnrg(const UnitCell& ucell, const Grid_Driver& orb_index.data(), orb_index.data(), ucell.nat); - hRGint_tmp.insert_pair(tmp_atom_pair); + hr_gint_tmp.insert_pair(tmp_atom_pair); } } } } } } - this->ijr_info = hRGint_tmp.get_ijr_info(); - this->nnrg = hRGint_tmp.get_nnr(); + this->ijr_info = hr_gint_tmp.get_ijr_info(); + this->nnrg = hr_gint_tmp.get_nnr(); return; } diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.cpp b/source/source_lcao/module_gint/temp_gint/gint_common.cpp index a05b9104e8..69957f0b38 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/temp_gint/gint_common.cpp @@ -70,7 +70,7 @@ void transfer_hr_gint_to_hR(const HContainer& hr_gint, HContainer& hR) } -void merge_hr_part_to_hR(const std::vector>& hRGint_tmp, +void merge_hr_part_to_hR(const std::vector>& hr_gint_tmp , hamilt::HContainer>* hR, const GintInfo& gint_info){ ModuleBase::TITLE("Gint_k", "transfer_pvpR"); @@ -96,7 +96,7 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t hR_tmp = new hamilt::HContainer>(pv, nullptr, &ijr_info); #endif - //select hRGint_tmp + //select hr_gint_tmp std::vector first = {0, 1, 1, 0}; std::vector second= {3, 2, 2, 3}; //select position in the big matrix @@ -121,8 +121,8 @@ void merge_hr_part_to_hR(const std::vector>& hRGint_t { hamilt::AtomPair>* upper_ap = ap; hamilt::AtomPair>* lower_ap = hRGint_tmpCd->find_pair(iat2, iat1); - const hamilt::AtomPair* ap_nspin1 = hRGint_tmp[first[is]].find_pair(iat1, iat2); - const hamilt::AtomPair* ap_nspin2 = hRGint_tmp[second[is]].find_pair(iat1, iat2); + const hamilt::AtomPair* ap_nspin1 = hr_gint_tmp [first[is]].find_pair(iat1, iat2); + const hamilt::AtomPair* ap_nspin2 = hr_gint_tmp [second[is]].find_pair(iat1, iat2); for (int ir = 0; ir < upper_ap->get_R_size(); ir++) { const auto R_index = upper_ap->get_R_index(ir); diff --git a/source/source_lcao/module_gint/temp_gint/gint_common.h b/source/source_lcao/module_gint/temp_gint/gint_common.h index a03c7307db..0e04a7cffc 100644 --- a/source/source_lcao/module_gint/temp_gint/gint_common.h +++ b/source/source_lcao/module_gint/temp_gint/gint_common.h @@ -11,7 +11,7 @@ namespace ModuleGint template void transfer_hr_gint_to_hR(const HContainer& hr_gint, HContainer& hR); // for nspin=4 case - void merge_hr_part_to_hR(const std::vector>& hRGint_tmp, + void merge_hr_part_to_hR(const std::vector>& hr_gint_tmp , hamilt::HContainer>* hR, const GintInfo& gint_info); diff --git a/source/source_lcao/module_lr/utils/gint_move.hpp b/source/source_lcao/module_lr/utils/gint_move.hpp index 6b4a8c82e6..b7c01118ef 100644 --- a/source/source_lcao/module_lr/utils/gint_move.hpp +++ b/source/source_lcao/module_lr/utils/gint_move.hpp @@ -47,19 +47,19 @@ Gint& Gint::operator=(Gint&& rhs) rhs.hRGint = nullptr; this->hRGintCd = rhs.hRGintCd; rhs.hRGintCd = nullptr; - for (int i = 0; i < this->DMRGint.size(); i++) + for (int i = 0; i < this->dmr_gint.size(); i++) { - delete this->DMRGint[i]; + delete this->dmr_gint[i]; } - for (int i = 0; i < this->hRGint_tmp.size(); i++) + for (int i = 0; i < this->hr_gint_tmp .size(); i++) { - delete this->hRGint_tmp[i]; + delete this->hr_gint_tmp [i]; } this->pvdpRx_reduced = std::move(rhs.pvdpRx_reduced); this->pvdpRy_reduced = std::move(rhs.pvdpRy_reduced); this->pvdpRz_reduced = std::move(rhs.pvdpRz_reduced); - this->DMRGint = std::move(rhs.DMRGint); - this->hRGint_tmp = std::move(rhs.hRGint_tmp); + this->dmr_gint = std::move(rhs.dmr_gint); + this->hr_gint_tmp = std::move(rhs.hr_gint_tmp ); this->dm2d_tmp = rhs.dm2d_tmp; rhs.dm2d_tmp = nullptr;