From 70faf8e48b9b22b8799099da07489ee839323eee Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Tue, 4 Jul 2023 21:32:04 +0800 Subject: [PATCH 1/5] fix a titile --- source/module_basis/module_ao/parallel_orbitals.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/module_basis/module_ao/parallel_orbitals.cpp b/source/module_basis/module_ao/parallel_orbitals.cpp index 43364affbe7..2a68afd5a46 100644 --- a/source/module_basis/module_ao/parallel_orbitals.cpp +++ b/source/module_basis/module_ao/parallel_orbitals.cpp @@ -136,7 +136,7 @@ int Parallel_Orbitals::set_nloc_wfc_Eij( std::ofstream& ofs_running, std::ofstream& ofs_warning) { - ModuleBase::TITLE("Parallel_Orbitals", "set_local2global"); + ModuleBase::TITLE("Parallel_Orbitals", "set_nloc_wfc_Eij"); // for wavefuncton , calculate nbands_loc int end_id; int block = N_A / nb; @@ -154,7 +154,7 @@ int Parallel_Orbitals::set_nloc_wfc_Eij( } else { - ModuleBase::WARNING_QUIT("Parallel_Orbitals::set_local2global", "some processor has no bands-row-blocks."); + ModuleBase::WARNING_QUIT("Parallel_Orbitals::set_nloc_wfc_Eij", "some processor has no bands-row-blocks."); } } int col_b_bands = block / dim1; From 05f31c2cccba8e51f23d315c3b7d5e425a1943f6 Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Tue, 4 Jul 2023 21:43:56 +0800 Subject: [PATCH 2/5] rename index mapping arrays --- source/module_basis/module_ao/ORB_control.cpp | 2 +- source/module_basis/module_ao/parallel_2d.cpp | 60 +++++++++---------- source/module_basis/module_ao/parallel_2d.h | 8 +-- .../module_ao/parallel_orbitals.cpp | 4 +- .../module_ao/test/parallel_2d_test.cpp | 10 ++-- source/module_elecstate/cal_dm.h | 8 +-- source/module_esolver/esolver_ks_lcao.cpp | 4 +- .../module_esolver/esolver_ks_lcao_elec.cpp | 24 ++++---- .../hamilt_lcaodft/FORCE_STRESS.cpp | 8 +-- .../hamilt_lcaodft/FORCE_gamma.cpp | 14 ++--- .../hamilt_lcaodft/FORCE_gamma_edm.cpp | 4 +- .../hamilt_lcaodft/FORCE_gamma_tvnl.cpp | 12 ++-- .../hamilt_lcaodft/FORCE_k.cpp | 36 +++++------ .../hamilt_lcaodft/LCAO_gen_fixedH.cpp | 34 +++++------ .../hamilt_lcaodft/LCAO_hamilt.cpp | 32 +++++----- .../hamilt_lcaodft/LCAO_hamilt.hpp | 4 +- .../hamilt_lcaodft/LCAO_matrix.cpp | 24 ++++---- .../hamilt_lcaodft/LCAO_nnr.cpp | 8 +-- .../hamilt_lcaodft/dm_2d.cpp | 4 +- .../operator_lcao/deepks_lcao.cpp | 14 ++--- .../hamilt_lcaodft/record_adj.cpp | 4 +- .../module_deepks/LCAO_deepks.h | 48 +++++++-------- .../module_deepks/LCAO_deepks_fdelta.cpp | 16 ++--- .../module_deepks/LCAO_deepks_interface.cpp | 8 +-- .../module_deepks/LCAO_deepks_odelta.cpp | 8 +-- .../module_deepks/LCAO_deepks_pdm.cpp | 32 +++++----- .../module_deepks/LCAO_deepks_psialpha.cpp | 16 ++--- .../module_deepks/LCAO_deepks_torch.cpp | 8 +-- .../module_deepks/LCAO_deepks_vdelta.cpp | 36 +++++------ .../module_deepks/test/LCAO_deepks_test.cpp | 48 +++++++-------- .../module_deepks/test/nnr.cpp | 12 ++-- .../module_deepks/test/parallel_orbitals.cpp | 32 +++++----- .../module_deepks/test/parallel_orbitals.h | 4 +- .../module_dftu/dftu_folding.cpp | 8 +-- .../module_dftu/dftu_force.cpp | 24 ++++---- .../module_dftu/dftu_occup.cpp | 16 ++--- .../module_dftu/dftu_tools.cpp | 8 +-- .../module_gint/gint_k_sparse.cpp | 8 +-- .../module_gint/gint_k_sparse1.cpp | 8 +-- .../module_hcontainer/atom_pair.cpp | 4 +- .../test/test_hcontainer.cpp | 10 ++-- .../test/test_hcontainer_complex.cpp | 10 ++-- source/module_io/cal_r_overlap_R.cpp | 8 +-- source/module_io/istate_charge.cpp | 2 +- source/module_io/mulliken_charge.cpp | 40 ++++++------- source/module_io/single_R_io.cpp | 4 +- source/module_io/test/single_R_io_test.cpp | 16 ++--- source/module_io/unk_overlap_lcao.cpp | 8 +-- source/module_io/write_HS.cpp | 36 +++++------ source/module_io/write_dm_sparse.cpp | 4 +- source/module_io/write_dos_lcao.cpp | 8 +-- source/module_io/write_proj_band_lcao.cpp | 8 +-- source/module_ri/RI_2D_Comm.cpp | 8 +-- source/module_ri/RI_2D_Comm.hpp | 12 ++-- source/module_ri/RPA_LRI.hpp | 4 +- 55 files changed, 420 insertions(+), 420 deletions(-) diff --git a/source/module_basis/module_ao/ORB_control.cpp b/source/module_basis/module_ao/ORB_control.cpp index 95881081065..a7fa6742f31 100644 --- a/source/module_basis/module_ao/ORB_control.cpp +++ b/source/module_basis/module_ao/ORB_control.cpp @@ -213,7 +213,7 @@ void ORB_control::setup_2d_division(std::ofstream& ofs_running, ModuleBase::WARNING_QUIT("Parallel_Orbitals::set_global2local", "Check ks_solver."); } // (2) set the trace, then we can calculate the nnr. - // for 2d: calculate po.nloc first, then trace_loc_row and trace_loc_col + // for 2d: calculate po.nloc first, then global2local_row and global2local_col // for O(N): calculate the three together. this->ParaV.set_global2local(nlocal, nlocal, div_2d, ofs_running); } diff --git a/source/module_basis/module_ao/parallel_2d.cpp b/source/module_basis/module_ao/parallel_2d.cpp index e7a9c47c03b..097e2671fe1 100644 --- a/source/module_basis/module_ao/parallel_2d.cpp +++ b/source/module_basis/module_ao/parallel_2d.cpp @@ -5,8 +5,8 @@ Parallel_2D::Parallel_2D() {} Parallel_2D::~Parallel_2D() { - delete[] trace_loc_row; - delete[] trace_loc_col; + delete[] global2local_row; + delete[] global2local_col; } void Parallel_2D::set_proc_dim(const int& dsize, bool mode /*= 0*/) @@ -35,9 +35,9 @@ void Parallel_2D::set_proc_dim(const int& dsize, bool mode /*= 0*/) bool Parallel_2D::in_this_processor(const int& iw1_all, const int& iw2_all) const { - if (trace_loc_row[iw1_all] == -1) + if (global2local_row[iw1_all] == -1) return false; - else if (trace_loc_col[iw2_all] == -1) + else if (global2local_col[iw2_all] == -1) return false; return true; } @@ -50,8 +50,8 @@ void Parallel_2D::set_global2local(const int& M_A, const int& N_A, this->init_global2local(M_A, N_A, ofs_running); if (!div_2d) // xiaohui add 2013-09-02 { - for (int i = 0; i < M_A; i++) this->trace_loc_row[i] = i; - for (int i = 0; i < N_A; i++) this->trace_loc_col[i] = i; + for (int i = 0; i < M_A; i++) this->global2local_row[i] = i; + for (int i = 0; i < N_A; i++) this->global2local_col[i] = i; this->nrow = M_A; this->ncol = N_A; this->nloc = this->nrow * this->ncol; @@ -61,19 +61,19 @@ void Parallel_2D::set_global2local(const int& M_A, const int& N_A, // ofs_running << " nrow=" << nrow << std::endl; for (int irow = 0; irow < this->nrow; irow++) { - int global_row = this->row_set[irow]; - this->trace_loc_row[global_row] = irow; + int global_row = this->local2global_row[irow]; + this->global2local_row[global_row] = irow; // ofs_running << " global_row=" << global_row - // << " trace_loc_row=" << this->trace_loc_row[global_row] << std::endl; + // << " global2local_row=" << this->global2local_row[global_row] << std::endl; } // ofs_running << " ncol=" << ncol << std::endl; for (int icol = 0; icol < this->ncol; icol++) { - int global_col = this->col_set[icol]; - this->trace_loc_col[global_col] = icol; + int global_col = this->local2global_col[icol]; + this->global2local_col[global_col] = icol; // ofs_running << " global_col=" << global_col - // << " trace_loc_col=" << this->trace_loc_row[global_col] << std::endl; + // << " global2local_col=" << this->global2local_row[global_col] << std::endl; } } @@ -86,17 +86,17 @@ void Parallel_2D::init_global2local(const int& M_A, const int& N_A, std::ofstrea assert(M_A > 0); assert(N_A > 0); - delete[] this->trace_loc_row; - delete[] this->trace_loc_col; + delete[] this->global2local_row; + delete[] this->global2local_col; - ModuleBase::GlobalFunc::OUT(ofs_running, "trace_loc_row dimension", M_A); - ModuleBase::GlobalFunc::OUT(ofs_running, "trace_loc_col dimension", N_A); + ModuleBase::GlobalFunc::OUT(ofs_running, "global2local_row dimension", M_A); + ModuleBase::GlobalFunc::OUT(ofs_running, "global2local_col dimension", N_A); - this->trace_loc_row = new int[M_A]; - this->trace_loc_col = new int[N_A]; + this->global2local_row = new int[M_A]; + this->global2local_col = new int[N_A]; - for (int i = 0; i < M_A; i++) this->trace_loc_row[i] = -1; - for (int i = 0; i < N_A; i++) this->trace_loc_col[i] = -1; + for (int i = 0; i < M_A; i++) this->global2local_row[i] = -1; + for (int i = 0; i < N_A; i++) this->global2local_col[i] = -1; ModuleBase::Memory::record("trace_row_col", sizeof(int) * M_A); ModuleBase::Memory::record("trace_row_col", sizeof(int) * N_A); @@ -242,17 +242,17 @@ int Parallel_2D::set_local2global( if (this->testpb)ModuleBase::GlobalFunc::OUT(ofs_running, "Local rows (including nb)", this->nrow); - // (5) row_set, it's a global index : + // (5) local2global_row, it's a global index : // save explicitly : every row in this processor // belongs to which row in the global matrix. - this->row_set.resize(this->nrow); + this->local2global_row.resize(this->nrow); j = 0; for (int i = 0; i < row_b; i++) { for (int k = 0; k < nb && (coord[0] * nb + i * nb * dim[0] + k < M_A); k++, j++) { - this->row_set[j] = coord[0] * nb + i * nb * dim[0] + k; - // ofs_running << " j=" << j << " row_set=" << this->row_set[j] << std::endl; + this->local2global_row[j] = coord[0] * nb + i * nb * dim[0] + k; + // ofs_running << " j=" << j << " local2global_row=" << this->local2global_row[j] << std::endl; } } @@ -311,14 +311,14 @@ int Parallel_2D::set_local2global( //set nloc this->nloc = this->nrow * this->ncol; - this->col_set.resize(this->ncol); + this->local2global_col.resize(this->ncol); j = 0; for (int i = 0; i < col_b; i++) { for (int k = 0; k < nb && (coord[1] * nb + i * nb * dim[1] + k < N_A); k++, j++) { - this->col_set[j] = coord[1] * nb + i * nb * dim[1] + k; + this->local2global_col[j] = coord[1] * nb + i * nb * dim[1] + k; } } return 0; @@ -330,9 +330,9 @@ void Parallel_2D::set_serial(const int& M_A, const int& N_A) this->nrow = M_A; this->ncol = N_A; this->nloc = this->nrow * this->ncol; - this->row_set.resize(this->nrow); - this->col_set.resize(this->ncol); - for (int i = 0; i < this->nrow; i++) this->row_set[i] = i; - for (int i = 0; i < this->ncol; i++) this->col_set[i] = i; + this->local2global_row.resize(this->nrow); + this->local2global_col.resize(this->ncol); + for (int i = 0; i < this->nrow; i++) this->local2global_row[i] = i; + for (int i = 0; i < this->ncol; i++) this->local2global_col[i] = i; } #endif \ No newline at end of file diff --git a/source/module_basis/module_ao/parallel_2d.h b/source/module_basis/module_ao/parallel_2d.h index f1a09173c69..9cbe1f5aa53 100644 --- a/source/module_basis/module_ao/parallel_2d.h +++ b/source/module_basis/module_ao/parallel_2d.h @@ -16,12 +16,12 @@ class Parallel_2D ~Parallel_2D(); /// map from global index to local index - int* trace_loc_row = nullptr; - int* trace_loc_col = nullptr; + int* global2local_row = nullptr; + int* global2local_col = nullptr; /// map from local index to global index - std::vector row_set; // Peize Lin change int* to vector 2022.08.03 - std::vector col_set; + std::vector local2global_row; // Peize Lin change int* to vector 2022.08.03 + std::vector local2global_col; /// local size (nloc = nrow * ncol) int nrow; diff --git a/source/module_basis/module_ao/parallel_orbitals.cpp b/source/module_basis/module_ao/parallel_orbitals.cpp index 2a68afd5a46..2291b360bc6 100644 --- a/source/module_basis/module_ao/parallel_orbitals.cpp +++ b/source/module_basis/module_ao/parallel_orbitals.cpp @@ -41,7 +41,7 @@ void Parallel_Orbitals::set_atomic_trace(const int* iat2iwt, const int &nat, con //find the first row index of atom iat for(int i=0;itrace_loc_row[irow]!=-1) + if (this->global2local_row[irow] != -1) { this->atom_begin_row[iat] = irow; break; @@ -51,7 +51,7 @@ void Parallel_Orbitals::set_atomic_trace(const int* iat2iwt, const int &nat, con //find the first col index of atom iat for(int i=0;itrace_loc_col[icol]!=-1) + if (this->global2local_col[icol] != -1) { this->atom_begin_col[iat] = icol; break; diff --git a/source/module_basis/module_ao/test/parallel_2d_test.cpp b/source/module_basis/module_ao/test/parallel_2d_test.cpp index 7911d7d4cf9..f029e240e8d 100644 --- a/source/module_basis/module_ao/test/parallel_2d_test.cpp +++ b/source/module_basis/module_ao/test/parallel_2d_test.cpp @@ -117,11 +117,11 @@ TEST_F(test_para2d, Divide2D) sum += arr[i]; return sum; }; - EXPECT_EQ(sum_array(p2d.trace_loc_row, gr), lr * (lr - 1) / 2 - (gr - lr)); - EXPECT_EQ(sum_array(p2d.trace_loc_col, gc), lc * (lc - 1) / 2 - (gc - lc)); + EXPECT_EQ(sum_array(p2d.global2local_row, gr), lr * (lr - 1) / 2 - (gr - lr)); + EXPECT_EQ(sum_array(p2d.global2local_col, gc), lc * (lc - 1) / 2 - (gc - lc)); for (int i = 0;i < lr;++i) for (int j = 0;j < lc;++j) - EXPECT_TRUE(p2d.in_this_processor(p2d.row_set[i], p2d.col_set[j])); + EXPECT_TRUE(p2d.in_this_processor(p2d.local2global_row[i], p2d.local2global_col[j])); } } } @@ -149,9 +149,9 @@ TEST_F(test_para2d, Serial) //3. set_global2local p2d.set_global2local(gr, gc, false, ofs_running); for (int i = 0;i < gr;++i) - EXPECT_EQ(p2d.trace_loc_row[i], i); + EXPECT_EQ(p2d.global2local_row[i], i); for (int i = 0;i < gc;++i) - EXPECT_EQ(p2d.trace_loc_col[i], i); + EXPECT_EQ(p2d.global2local_col[i], i); } } #endif diff --git a/source/module_elecstate/cal_dm.h b/source/module_elecstate/cal_dm.h index e0c1d23ba27..5bb4194a15d 100644 --- a/source/module_elecstate/cal_dm.h +++ b/source/module_elecstate/cal_dm.h @@ -33,13 +33,13 @@ inline void cal_dm(const Parallel_Orbitals* ParaV, const ModuleBase::matrix& wg, int ib_global = 0; for (int ib_local = 0; ib_local < nbands_local; ++ib_local) { - while (ib_local != ParaV->trace_loc_col[ib_global]) + while (ib_local != ParaV->global2local_col[ib_global]) { ++ib_global; if (ib_global >= wg.nc) { break; - ModuleBase::WARNING_QUIT("ElecStateLCAO::cal_dm", "please check trace_loc_col!"); + ModuleBase::WARNING_QUIT("ElecStateLCAO::cal_dm", "please check global2local_col!"); } } if (ib_global >= wg.nc) continue; @@ -91,13 +91,13 @@ inline void cal_dm(const Parallel_Orbitals* ParaV, const ModuleBase::matrix& wg, int ib_global = 0; for (int ib_local = 0; ib_local < nbands_local; ++ib_local) { - while (ib_local != ParaV->trace_loc_col[ib_global]) + while (ib_local != ParaV->global2local_col[ib_global]) { ++ib_global; if (ib_global >= wg.nc) { break; - ModuleBase::WARNING_QUIT("ElecStateLCAO::cal_dm", "please check trace_loc_col!"); + ModuleBase::WARNING_QUIT("ElecStateLCAO::cal_dm", "please check global2local_col!"); } } if (ib_global >= wg.nc) continue; diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index 18bbf965bc7..200cadd9a43 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -577,12 +577,12 @@ void ESolver_KS_LCAO::hamilt2density(int istep, int iter, double ethr) const Parallel_Orbitals* pv = this->LOWF.ParaV; if (GlobalV::GAMMA_ONLY_LOCAL) { - GlobalC::ld.cal_e_delta_band(this->LOC.dm_gamma, pv->trace_loc_row, pv->trace_loc_col, pv->nrow); + GlobalC::ld.cal_e_delta_band(this->LOC.dm_gamma, pv->global2local_row, pv->global2local_col, pv->nrow); } else { GlobalC::ld - .cal_e_delta_band_k(this->LOC.dm_k, pv->trace_loc_row, pv->trace_loc_col, kv.nks, pv->nrow, pv->ncol); + .cal_e_delta_band_k(this->LOC.dm_k, pv->global2local_row, pv->global2local_col, kv.nks, pv->nrow, pv->ncol); } } #endif diff --git a/source/module_esolver/esolver_ks_lcao_elec.cpp b/source/module_esolver/esolver_ks_lcao_elec.cpp index 8e5a88be4ec..dfd041d56c7 100644 --- a/source/module_esolver/esolver_ks_lcao_elec.cpp +++ b/source/module_esolver/esolver_ks_lcao_elec.cpp @@ -252,8 +252,8 @@ namespace ModuleESolver GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, GlobalC::UOT); if (GlobalV::deepks_out_unittest) @@ -262,8 +262,8 @@ namespace ModuleESolver GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, GlobalC::UOT); } } @@ -598,8 +598,8 @@ namespace ModuleESolver GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col); + pv->global2local_row, + pv->global2local_col); } else { @@ -607,8 +607,8 @@ namespace ModuleESolver GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, this->kv.nks, this->kv.kvec_d); } @@ -619,8 +619,8 @@ namespace ModuleESolver GlobalC::ld.add_v_delta(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, pv->nrow, pv->ncol); } @@ -629,8 +629,8 @@ namespace ModuleESolver GlobalC::ld.add_v_delta_k(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, pv->nnr); } } diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp index b2b984eeed4..a9c4bf33c8c 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp @@ -376,8 +376,8 @@ void Force_Stress_LCAO::getForceStress(const bool isforce, GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, isstress); } else @@ -386,8 +386,8 @@ void Force_Stress_LCAO::getForceStress(const bool isforce, GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, kv.nks, kv.kvec_d, isstress); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp index 1300e4785cf..d3de5dbbc91 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp @@ -66,16 +66,16 @@ void Force_LCAO_gamma::ftable_gamma(const bool isforce, GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col); + pv->global2local_row, + pv->global2local_col); GlobalC::ld.cal_descriptor(); GlobalC::ld.cal_gedm(GlobalC::ucell.nat); GlobalC::ld.cal_f_delta_gamma(loc.dm_gamma[0], GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, isstress, svnl_dalpha); #ifdef __MPI @@ -94,13 +94,13 @@ void Force_LCAO_gamma::ftable_gamma(const bool isforce, GlobalC::ld.add_v_delta(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, pv->nrow, pv->ncol); GlobalC::ld.check_v_delta(pv->nrow, pv->ncol); - GlobalC::ld.cal_e_delta_band(loc.dm_gamma, pv->trace_loc_row, pv->trace_loc_col, pv->nrow); + GlobalC::ld.cal_e_delta_band(loc.dm_gamma, pv->global2local_row, pv->global2local_col, pv->nrow); std::ofstream ofs("E_delta_bands.dat"); ofs << std::setprecision(10) << GlobalC::ld.e_delta_band; std::ofstream ofs1("E_delta.dat"); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp index a7cd72b1db4..0907bd314c7 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp @@ -44,8 +44,8 @@ void Force_LCAO_gamma::cal_foverlap( const int iat = GlobalC::ucell.iwt2iat[i]; for(int j=0; jtrace_loc_row[j]; - const int nu = loc.ParaV->trace_loc_col[i]; + const int mu = loc.ParaV->global2local_row[j]; + const int nu = loc.ParaV->global2local_col[i]; if(mu>=0 && nu>=0) { const int index = mu * loc.ParaV->ncol + nu; diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp index 6995435d505..0dab8aaf778 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp @@ -54,8 +54,8 @@ void Force_LCAO_gamma::cal_fvnl_dbeta_new( for (int iw1=0; iw1ParaV->trace_loc_row[iw1_all]; - const int iw2_local = this->ParaV->trace_loc_col[iw1_all]; + const int iw1_local = this->ParaV->global2local_row[iw1_all]; + const int iw2_local = this->ParaV->global2local_col[iw1_all]; if(iw1_local < 0 && iw2_local < 0) continue; std::vector> nlm; @@ -114,12 +114,12 @@ void Force_LCAO_gamma::cal_fvnl_dbeta_new( for (int iw1=0; iw1ParaV->trace_loc_row[iw1_all]; + const int iw1_local = this->ParaV->global2local_row[iw1_all]; if(iw1_local < 0)continue; for (int iw2=0; iw2ParaV->trace_loc_col[iw2_all]; + const int iw2_local = this->ParaV->global2local_col[iw2_all]; if(iw2_local < 0)continue; double nlm[3] = {0,0,0}; @@ -232,8 +232,8 @@ void Force_LCAO_gamma::cal_ftvnl_dphi( const int iat = GlobalC::ucell.iwt2iat[i]; for(int j=0; jParaV->trace_loc_row[j]; - const int nu = this->ParaV->trace_loc_col[i]; + const int mu = this->ParaV->global2local_row[j]; + const int nu = this->ParaV->global2local_col[i]; if (mu >= 0 && nu >= 0 ) { diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp index 7a9c8e7bccd..09cffab4f3d 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp @@ -99,8 +99,8 @@ void Force_LCAO_k::ftable_k(const bool isforce, GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, kv.nks, kv.kvec_d); GlobalC::ld.cal_descriptor(); @@ -110,8 +110,8 @@ void Force_LCAO_k::ftable_k(const bool isforce, GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, kv.nks, kv.kvec_d, isstress, @@ -132,8 +132,8 @@ void Force_LCAO_k::ftable_k(const bool isforce, GlobalC::ld.add_v_delta_k(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, pv->nnr); GlobalC::ld.check_v_delta_k(pv->nnr); for (int ik = 0; ik < kv.nks; ik++) @@ -141,8 +141,8 @@ void Force_LCAO_k::ftable_k(const bool isforce, uhm.LM->folding_fixedH(ik, kv.kvec_d); } GlobalC::ld.cal_e_delta_band_k(loc.dm_k, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, kv.nks, pv->nrow, pv->ncol); @@ -442,7 +442,7 @@ void Force_LCAO_k::cal_foverlap_k(const bool isforce, const int iw1_all = start1 + jj; // HPSEPS - const int mu = pv->trace_loc_row[iw1_all]; + const int mu = pv->global2local_row[iw1_all]; if (mu < 0) continue; @@ -451,7 +451,7 @@ void Force_LCAO_k::cal_foverlap_k(const bool isforce, const int iw2_all = start2 + kk; // HPSEPS - const int nu = pv->trace_loc_col[iw2_all]; + const int nu = pv->global2local_col[iw2_all]; if (nu < 0) continue; //============================================================== @@ -597,13 +597,13 @@ void Force_LCAO_k::cal_ftvnl_dphi_k(double** dm2d, for (int jj = 0; jj < atom1->nw; ++jj) { const int iw1_all = start1 + jj; - const int mu = pv->trace_loc_row[iw1_all]; + const int mu = pv->global2local_row[iw1_all]; if (mu < 0) continue; for (int kk = 0; kk < atom2->nw; ++kk) { const int iw2_all = start2 + kk; - const int nu = pv->trace_loc_col[iw2_all]; + const int nu = pv->global2local_col[iw2_all]; if (nu < 0) continue; //============================================================== @@ -806,8 +806,8 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, for (int iw1 = 0; iw1 < nw1_tot; ++iw1) { const int iw1_all = start1 + iw1; - const int iw1_local = pv->trace_loc_row[iw1_all]; - const int iw2_local = pv->trace_loc_col[iw1_all]; + const int iw1_local = pv->global2local_row[iw1_all]; + const int iw2_local = pv->global2local_col[iw1_all]; if (iw1_local < 0 && iw2_local < 0) continue; const int iw1_0 = iw1 / GlobalV::NPOL; @@ -1002,7 +1002,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int j0 = j / GlobalV::NPOL; // added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->trace_loc_row[iw1_all]; + const int mu = pv->global2local_row[iw1_all]; if (mu < 0) continue; @@ -1010,7 +1010,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int k0 = k / GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->trace_loc_col[iw2_all]; + const int nu = pv->global2local_col[iw2_all]; if (nu < 0) continue; @@ -1106,7 +1106,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int j0 = j / GlobalV::NPOL; // added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->trace_loc_row[iw1_all]; + const int mu = pv->global2local_row[iw1_all]; if (mu < 0) continue; @@ -1116,7 +1116,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int k0 = k / GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->trace_loc_col[iw2_all]; + const int nu = pv->global2local_col[iw2_all]; if (nu < 0) continue; total_nnr++; diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp index 43d58cc75fd..51aa227dae2 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp @@ -131,8 +131,8 @@ void LCAO_gen_fixedH::build_ST_new(const char& dtype, const bool& calc_deri, con // the difference is that here we use {L,N,m} for ccycle, // build_Nonlocal_mu use atom.nw for cycle. // so, here we use ParaO::in_this_processor, - // in build_Non... use trace_loc_row - // and trace_loc_col directly, + // in build_Non... use global2local_row + // and global2local_col directly, if (!pv->in_this_processor(iw1_all, iw2_all)) { ++iw2_all; @@ -159,7 +159,7 @@ void LCAO_gen_fixedH::build_ST_new(const char& dtype, const bool& calc_deri, con { // mohan add 2010-06-29 // set the value in Hloc and Sloc - // according to trace_loc_row and trace_loc_col + // according to global2local_row and global2local_col // the last paramete: 1 for Sloc, 2 for Hloc // and 3 for Hloc_fixed. this->LM->set_HSgamma(iw1_all, iw2_all, olm[0], dtype, HSloc); @@ -273,11 +273,11 @@ void LCAO_gen_fixedH::build_ST_new(const char& dtype, const bool& calc_deri, con { for(int jj=0; jjnw * GlobalV::NPOL; ++jj) { - const int mu = pv->trace_loc_row[start1+jj]; + const int mu = pv->global2local_row[start1+jj]; if(mu<0)continue; for(int kk=0; kknw * GlobalV::NPOL; ++kk) { - const int nu = pv->trace_loc_col[start2+kk]; + const int nu = pv->global2local_col[start2+kk]; if(nu<0)continue; ++total_nnr; ++nnr; @@ -396,8 +396,8 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri for (int iw1=0; iw1trace_loc_row[iw1_all]; - const int iw2_local = pv->trace_loc_col[iw1_all]; + const int iw1_local = pv->global2local_row[iw1_all]; + const int iw2_local = pv->global2local_col[iw1_all]; if(iw1_local < 0 && iw2_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; std::vector> nlm; @@ -590,7 +590,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int j0 = j/GlobalV::NPOL;//added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->trace_loc_row[iw1_all]; + const int mu = pv->global2local_row[iw1_all]; if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -599,7 +599,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int k0 = k/GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->trace_loc_col[iw2_all]; + const int nu = pv->global2local_col[iw2_all]; if(nu < 0)continue; if(!calc_deri) @@ -737,7 +737,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int j0 = j/GlobalV::NPOL;//added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->trace_loc_row[iw1_all]; + const int mu = pv->global2local_row[iw1_all]; if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -746,7 +746,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int k0 = k/GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->trace_loc_col[iw2_all]; + const int nu = pv->global2local_col[iw2_all]; if(nu < 0)continue; total_nnr++; nnr++; @@ -844,8 +844,8 @@ void LCAO_gen_fixedH::build_Nonlocal_beta_new(double* HSloc) //update by liuyu 2 for(int iw1=0; iw1trace_loc_row[iw1_all]; - const int iw2_local = pv->trace_loc_col[iw1_all]; + const int iw1_local = pv->global2local_row[iw1_all]; + const int iw2_local = pv->global2local_col[iw1_all]; if(iw1_local < 0 && iw2_local < 0) continue; @@ -908,13 +908,13 @@ void LCAO_gen_fixedH::build_Nonlocal_beta_new(double* HSloc) //update by liuyu 2 for(int iw1=0; iw1trace_loc_row[iw1_all]; + const int iw1_local = pv->global2local_row[iw1_all]; if(iw1_local < 0) continue; const int iw1_0 = iw1/GlobalV::NPOL; for(int iw2=0; iw2trace_loc_col[iw2_all]; + const int iw2_local = pv->global2local_col[iw2_all]; if(iw2_local < 0) continue; const int iw2_0 = iw2/GlobalV::NPOL; #ifdef _OPENMP @@ -948,8 +948,8 @@ void LCAO_gen_fixedH::build_Nonlocal_beta_new(double* HSloc) //update by liuyu 2 } assert(ib==nlm1.size()); - const int ir = pv->trace_loc_row[ iw1_all ]; - const int ic = pv->trace_loc_col[ iw2_all ]; + const int ir = pv->global2local_row[ iw1_all ]; + const int ic = pv->global2local_col[ iw2_all ]; long index=0; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp index b4f5bef128a..46ffb7635e9 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp @@ -147,14 +147,14 @@ void LCAO_Hamilt::calculate_STN_R_sparse(const int ¤t_spin, const double & for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->trace_loc_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row[iw1_all]; if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->trace_loc_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col[iw2_all]; if(nu<0)continue; @@ -269,14 +269,14 @@ void LCAO_Hamilt::calculate_STN_R_sparse_for_S(const double &sparse_threshold) for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->trace_loc_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row[iw1_all]; if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->trace_loc_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col[iw2_all]; if(nu<0)continue; @@ -450,14 +450,14 @@ void LCAO_Hamilt::calculate_STN_R_sparse_for_T(const double &sparse_threshold) for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->trace_loc_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row[iw1_all]; if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->trace_loc_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col[iw2_all]; if(nu<0)continue; @@ -552,10 +552,10 @@ void LCAO_Hamilt::calculat_HR_dftu_sparse(const int ¤t_spin, const double { for (auto &row_loop : iter->second) { - ir = this->LM->ParaV->trace_loc_row[row_loop.first]; + ir = this->LM->ParaV->global2local_row[row_loop.first]; for (auto &col_loop : row_loop.second) { - ic = this->LM->ParaV->trace_loc_col[col_loop.first]; + ic = this->LM->ParaV->global2local_col[col_loop.first]; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { iic = ir + ic * this->LM->ParaV->nrow; @@ -573,12 +573,12 @@ void LCAO_Hamilt::calculat_HR_dftu_sparse(const int ¤t_spin, const double for (int i = 0; i < GlobalV::NLOCAL; ++i) { - ir = this->LM->ParaV->trace_loc_row[i]; + ir = this->LM->ParaV->global2local_row[i]; if (ir >= 0) { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - ic = this->LM->ParaV->trace_loc_col[j]; + ic = this->LM->ParaV->global2local_col[j]; if (ic >= 0) { if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) @@ -664,10 +664,10 @@ void LCAO_Hamilt::calculat_HR_dftu_soc_sparse(const int ¤t_spin, const dou { for (auto &row_loop : iter->second) { - ir = this->LM->ParaV->trace_loc_row[row_loop.first]; + ir = this->LM->ParaV->global2local_row[row_loop.first]; for (auto &col_loop : row_loop.second) { - ic = this->LM->ParaV->trace_loc_col[col_loop.first]; + ic = this->LM->ParaV->global2local_col[col_loop.first]; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { iic = ir + ic * this->LM->ParaV->nrow; @@ -685,12 +685,12 @@ void LCAO_Hamilt::calculat_HR_dftu_soc_sparse(const int ¤t_spin, const dou for (int i = 0; i < GlobalV::NLOCAL; ++i) { - ir = this->LM->ParaV->trace_loc_row[i]; + ir = this->LM->ParaV->global2local_row[i]; if (ir >= 0) { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - ic = this->LM->ParaV->trace_loc_col[j]; + ic = this->LM->ParaV->global2local_col[j]; if (ic >= 0) { if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) @@ -891,14 +891,14 @@ void LCAO_Hamilt::calculate_dSTN_R_sparse(const int ¤t_spin, const double for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->trace_loc_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row[iw1_all]; if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->trace_loc_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col[iw2_all]; if(nu<0)continue; diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp index 17706bab06a..70213da6c8b 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp @@ -47,12 +47,12 @@ void LCAO_Hamilt::calculate_HR_exx_sparse( for(size_t iw0=0; iw0LM->ParaV->trace_loc_row[iwt0]; + const int iwt0_local = this->LM->ParaV->global2local_row[iwt0]; if(iwt0_local<0) continue; for(size_t iw1=0; iw1LM->ParaV->trace_loc_col[iwt1]; + const int iwt1_local = this->LM->ParaV->global2local_col[iwt1]; if(iwt1_local<0) continue; if(std::abs(Hexx(iw0,iw1)) > sparse_threshold) diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp index f60797ec710..5f1e78bbca7 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp @@ -146,8 +146,8 @@ void LCAO_Matrix::set_HSgamma( { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may be < 0 !!! - const int ir = this->ParaV->trace_loc_row[ iw1_all ]; - const int ic = this->ParaV->trace_loc_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row[ iw1_all ]; + const int ic = this->ParaV->global2local_col[ iw2_all ]; //const int index = ir * ParaO.ncol + ic; long index=0; @@ -183,8 +183,8 @@ void LCAO_Matrix::set_HSk(const int &iw1_all, const int &iw2_all, const std::com { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may < 0!!!!!!!!!!!!!!!! - const int ir = this->ParaV->trace_loc_row[ iw1_all ]; - const int ic = this->ParaV->trace_loc_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row[ iw1_all ]; + const int ic = this->ParaV->global2local_col[ iw2_all ]; //const int index = ir * this->ParaV->ncol + ic; long index; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) @@ -228,8 +228,8 @@ void LCAO_Matrix::set_force { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may < 0!!!!!!!!!!!!!!!! - const int ir = this->ParaV->trace_loc_row[ iw1_all ]; - const int ic = this->ParaV->trace_loc_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row[ iw1_all ]; + const int ic = this->ParaV->global2local_col[ iw2_all ]; const long index = ir * this->ParaV->ncol + ic; if( index >= this->ParaV->nloc) @@ -278,8 +278,8 @@ void LCAO_Matrix::set_stress { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may < 0!!!!!!!!!!!!!!!! - const int ir = this->ParaV->trace_loc_row[ iw1_all ]; - const int ic = this->ParaV->trace_loc_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row[ iw1_all ]; + const int ic = this->ParaV->global2local_col[ iw2_all ]; const long index = ir * this->ParaV->ncol + ic; if( index >= this->ParaV->nloc) @@ -855,8 +855,8 @@ void LCAO_Matrix::destroy_Hloc_fixedR_tr(void) void LCAO_Matrix::set_HR_tr(const int &Rx, const int &Ry, const int &Rz, const int &iw1_all, const int &iw2_all, const double &v) { - const int ir = this->ParaV->trace_loc_row[ iw1_all ]; - const int ic = this->ParaV->trace_loc_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row[ iw1_all ]; + const int ic = this->ParaV->global2local_col[ iw2_all ]; //std::cout<<"ir: "< &v) { - const int ir = this->ParaV->trace_loc_row[ iw1_all ]; - const int ic = this->ParaV->trace_loc_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row[ iw1_all ]; + const int ic = this->ParaV->global2local_col[ iw2_all ]; //std::cout<<"ir: "<trace_loc_row[iat]; - const int nu = pv->trace_loc_col[iat2]; + const int mu = pv->global2local_row[iat]; + const int nu = pv->global2local_col[iat2]; this->nnrg_index.push_back(gridIntegral::gridIndex{this->nnrg, mu, nu, GlobalC::GridD.getBox(ad), atom1->nw, atom2->nw}); const int nelement = atom1->nw * atom2->nw; @@ -460,12 +460,12 @@ void LCAO_Matrix::folding_fixedH( { \ /* the index of orbitals in this processor */ \ const int iw1_all = start + ii; \ - const int mu = pv->trace_loc_row[iw1_all]; \ + const int mu = pv->global2local_row[iw1_all]; \ if(mu<0) {continue;} \ for(int jj=0; jjnw*GlobalV::NPOL; jj++) \ { \ int iw2_all = start2 + jj; \ - const int nu = pv->trace_loc_col[iw2_all]; \ + const int nu = pv->global2local_col[iw2_all]; \ if(nu<0) {continue;} // DO STH. diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp index baf93268e8b..a94cd1d0d98 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp @@ -72,12 +72,12 @@ void Local_Orbital_Charge::cal_dm_R( for (int iw1 = 0;iw1 < GlobalC::ucell.atoms[T1].nw;++iw1) { int iw1_all = start1 + iw1; - int mu = this->ParaV->trace_loc_row[iw1_all]; + int mu = this->ParaV->global2local_row[iw1_all]; if (mu < 0)continue; for (int iw2 = 0;iw2 < GlobalC::ucell.atoms[T2].nw;++iw2) { int iw2_all = start2 + iw2; - int nu = this->ParaV->trace_loc_col[iw2_all]; + int nu = this->ParaV->global2local_col[iw2_all]; if (nu < 0)continue; //Caution: output of pzgemm_ : col first in **each** proc itself !! dm2d[ispin][irrstart + count] += (dm_k[ik](nu, mu) * phase).real(); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp index 487c3d58951..e0b9e3cbcba 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp @@ -27,15 +27,15 @@ void DeePKS>::contributeHR() GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col); + pv->global2local_row, + pv->global2local_col); GlobalC::ld.cal_descriptor(); GlobalC::ld.cal_gedm(GlobalC::ucell.nat); GlobalC::ld.add_v_delta(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->trace_loc_row, - pv->trace_loc_col, + pv->global2local_row, + pv->global2local_col, pv->nrow, pv->ncol); @@ -62,8 +62,8 @@ void DeePKS>>::contributeHR() GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - this->LM->ParaV->trace_loc_row, - this->LM->ParaV->trace_loc_col, + this->LM->ParaV->global2local_row, + this->LM->ParaV->global2local_col, this->nks, this->kvec_d); GlobalC::ld.cal_descriptor(); @@ -72,7 +72,7 @@ void DeePKS>>::contributeHR() // calculate H_V_deltaR from saved GlobalC::ld - .add_v_delta_k(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, this->LM->ParaV->trace_loc_row, this->LM->ParaV->trace_loc_col, this->LM->ParaV->nnr); + .add_v_delta_k(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, this->LM->ParaV->global2local_row, this->LM->ParaV->global2local_col, this->LM->ParaV->nnr); GlobalC::ld.set_hr_cal(false); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp index db7dd47117d..1bda02e21e6 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp @@ -128,13 +128,13 @@ void Record_adj::for_2d(Parallel_Orbitals &pv, bool gamma_only) { // the index of orbitals in this processor const int iw1_all = start1 + ii; - const int mu = pv.trace_loc_row[iw1_all]; + const int mu = pv.global2local_row[iw1_all]; if(mu<0)continue; for(int jj=0; jj& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nks, const std::vector> &kvec_d); void check_projected_dm(void); @@ -296,15 +296,15 @@ class LCAO_Deepks const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const bool isstress); void cal_gdmx_k(const std::vector& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nks, const std::vector> &kvec_d, const bool isstress); @@ -334,15 +334,15 @@ class LCAO_Deepks void add_v_delta(const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nrow, const int ncol); void add_v_delta_k(const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nnr_in); void check_v_delta(const int nrow, const int ncol); @@ -350,12 +350,12 @@ class LCAO_Deepks ///calculate tr(\rho V_delta) void cal_e_delta_band(const std::vector& dm/**<[in] density matrix*/, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nrow); void cal_e_delta_band_k(const std::vector& dm/**<[in] density matrix*/, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nks, const int nrow, const int ncol); @@ -379,8 +379,8 @@ class LCAO_Deepks const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const bool isstress, ModuleBase::matrix& svnl_dalpha); //for multi-k, pulay and HF terms of force are calculated together @@ -388,8 +388,8 @@ class LCAO_Deepks const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nks, const std::vector> &kvec_d, const bool isstress, ModuleBase::matrix& svnl_dalpha); diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp index 76387bcc571..87c28837874 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp @@ -38,8 +38,8 @@ void LCAO_Deepks::cal_f_delta_gamma(const ModuleBase::matrix& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const bool isstress, ModuleBase::matrix& svnl_dalpha) { ModuleBase::TITLE("LCAO_Deepks", "cal_f_delta_gamma"); @@ -100,13 +100,13 @@ void LCAO_Deepks::cal_f_delta_gamma(const ModuleBase::matrix& dm, for (int iw1=0; iw1& dm const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nks, const std::vector> &kvec_d, const bool isstress, ModuleBase::matrix& svnl_dalpha) @@ -287,13 +287,13 @@ void LCAO_Deepks::cal_f_delta_k(const std::vector& dm for (int iw1=0; iw1 tmp = 0.0; diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp index c5b1a1a7c18..46a279e36a6 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp @@ -118,11 +118,11 @@ void LCAO_Deepks_Interface::out_deepks_labels(double etot, // so it is printed no matter even if deepks_out_labels is not used if (GlobalV::GAMMA_ONLY_LOCAL) { - ld->cal_projected_DM(dm_gamma[0], ucell, orb, GridD, ParaV->trace_loc_row, ParaV->trace_loc_col); + ld->cal_projected_DM(dm_gamma[0], ucell, orb, GridD, ParaV->global2local_row, ParaV->global2local_col); } else { - ld->cal_projected_DM_k(dm_k, ucell, orb, GridD, ParaV->trace_loc_row, ParaV->trace_loc_col, nks, kvec_d); + ld->cal_projected_DM_k(dm_k, ucell, orb, GridD, ParaV->global2local_row, ParaV->global2local_col, nks, kvec_d); } ld->check_projected_dm(); // print out the projected dm for NSCF calculaiton ld->cal_descriptor(); // final descriptor @@ -136,11 +136,11 @@ void LCAO_Deepks_Interface::out_deepks_labels(double etot, { if (GlobalV::GAMMA_ONLY_LOCAL) { - ld->cal_e_delta_band(dm_gamma, ParaV->trace_loc_row, ParaV->trace_loc_col, ParaV->nrow); + ld->cal_e_delta_band(dm_gamma, ParaV->global2local_row, ParaV->global2local_col, ParaV->nrow); } else { - ld->cal_e_delta_band_k(dm_k, ParaV->trace_loc_row, ParaV->trace_loc_col, nks, ParaV->nrow, ParaV->ncol); + ld->cal_e_delta_band_k(dm_k, ParaV->global2local_row, ParaV->global2local_col, nks, ParaV->nrow, ParaV->ncol); } std::cout << "E_delta_band = " << std::setprecision(8) << ld->e_delta_band << " Ry" << " = " << std::setprecision(8) << ld->e_delta_band * ModuleBase::Ry_to_eV << " eV" diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp index ecdbfb6dab5..ea986a95adc 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp @@ -22,8 +22,8 @@ void LCAO_Deepks::cal_o_delta(const std::vector> { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - const int mu = ParaO.trace_loc_row[j]; - const int nu = ParaO.trace_loc_col[i]; + const int mu = ParaO.global2local_row[j]; + const int nu = ParaO.global2local_col[i]; if (mu >= 0 && nu >= 0) { @@ -58,8 +58,8 @@ void LCAO_Deepks::cal_o_delta_k(const std::vector= 0 && nu >= 0) { diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp index ea3925e642b..989ca87bfb1 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp @@ -29,8 +29,8 @@ void LCAO_Deepks::cal_projected_DM(const ModuleBase::matrix &dm, const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col) + const int* global2local_row, + const int* global2local_col) { ModuleBase::TITLE("LCAO_Deepks", "cal_projected_DM"); ModuleBase::timer::tick("LCAO_Deepks","cal_projected_DM"); @@ -109,14 +109,14 @@ void LCAO_Deepks::cal_projected_DM(const ModuleBase::matrix &dm, for (int iw1=0; iw1> &kvec_d) { @@ -249,13 +249,13 @@ void LCAO_Deepks::cal_projected_DM_k(const std::vector& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nks, const std::vector> &kvec_d, const bool isstress) @@ -642,13 +642,13 @@ void LCAO_Deepks::cal_gdmx_k(const std::vector& dm, for (int iw1=0; iw1> nlm; @@ -132,8 +132,8 @@ void LCAO_Deepks::check_psialpha(const bool& calc_deri, const UnitCell &ucell, const LCAO_Orbitals &orb, Grid_Driver &GridD, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const ORB_gen_tables &UOT) { ModuleBase::TITLE("LCAO_Deepks", "check_psialpha"); @@ -226,8 +226,8 @@ void LCAO_Deepks::check_psialpha(const bool& calc_deri, ofs_x << "iw : " << iw1_all << std::endl; ofs_y << "iw : " << iw1_all << std::endl; ofs_z << "iw : " << iw1_all << std::endl; - const int iw1_local = trace_loc_row[iw1_all]; - const int iw2_local = trace_loc_col[iw1_all]; + const int iw1_local = global2local_row[iw1_all]; + const int iw2_local = global2local_col[iw1_all]; if(iw1_local < 0 && iw2_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp index 44e749c28b6..87003b8781a 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp @@ -467,13 +467,13 @@ void LCAO_Deepks::cal_orbital_precalc(const std::vectornw*GlobalV::NPOL; iw1++) { const int iw1_all = start1 + iw1; - const int mu = trace_loc_row[iw1_all]; + const int mu = global2local_row[iw1_all]; if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -298,7 +298,7 @@ void LCAO_Deepks::add_v_delta_k(const UnitCell &ucell, for (int iw2=0; iw2nw*GlobalV::NPOL; iw2++) { const int iw2_all = start2 + iw2; - const int nu = trace_loc_col[iw2_all]; + const int nu = global2local_col[iw2_all]; if(nu < 0)continue; std::vector nlm1 = this->nlm_save_k[iat][key_1][iw1_all][0]; @@ -336,7 +336,7 @@ void LCAO_Deepks::add_v_delta_k(const UnitCell &ucell, { const int j0 = j/GlobalV::NPOL;//added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = trace_loc_row[iw1_all]; + const int mu = global2local_row[iw1_all]; if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -345,7 +345,7 @@ void LCAO_Deepks::add_v_delta_k(const UnitCell &ucell, { const int k0 = k/GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = trace_loc_col[iw2_all]; + const int nu = global2local_col[iw2_all]; if(nu < 0)continue; nnr++; @@ -379,8 +379,8 @@ void LCAO_Deepks::check_v_delta_k(const int nnr) //calculating sum of correction band energies //for gamma_only calculations void LCAO_Deepks::cal_e_delta_band(const std::vector &dm, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nrow) { ModuleBase::TITLE("LCAO_Deepks", "cal_e_delta_band"); @@ -389,8 +389,8 @@ void LCAO_Deepks::cal_e_delta_band(const std::vector &dm, { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - const int mu = trace_loc_row[j]; - const int nu = trace_loc_col[i]; + const int mu = global2local_row[j]; + const int nu = global2local_col[i]; if (mu >= 0 && nu >= 0) { @@ -411,8 +411,8 @@ void LCAO_Deepks::cal_e_delta_band(const std::vector &dm, //calculating sum of correction band energies //for multi_k calculations void LCAO_Deepks::cal_e_delta_band_k(const std::vector &dm, - const int* trace_loc_row, - const int* trace_loc_col, + const int* global2local_row, + const int* global2local_col, const int nks, const int nrow, const int ncol) @@ -423,8 +423,8 @@ void LCAO_Deepks::cal_e_delta_band_k(const std::vector= 0 && nu >= 0) { diff --git a/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.cpp b/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.cpp index b79600816ee..41cda0e95aa 100644 --- a/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.cpp +++ b/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.cpp @@ -35,16 +35,16 @@ void test_deepks::check_psialpha(void) ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, OGT); ld.check_psialpha(GlobalV::CAL_FORCE, ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, OGT); this->compare_with_ref("psialpha.dat","psialpha_ref.dat"); this->compare_with_ref("dpsialpha_x.dat","dpsialpha_x_ref.dat"); @@ -101,8 +101,8 @@ void test_deepks::check_pdm(void) ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col); + ParaO.global2local_row, + ParaO.global2local_col); } else { @@ -111,8 +111,8 @@ void test_deepks::check_pdm(void) ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, kv.nkstot, kv.kvec_d); } @@ -129,8 +129,8 @@ void test_deepks::check_gdmx(void) ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, 0); } else @@ -139,8 +139,8 @@ void test_deepks::check_gdmx(void) ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, kv.nkstot, kv.kvec_d, 0); @@ -235,16 +235,16 @@ void test_deepks::check_e_deltabands(void) if(GlobalV::GAMMA_ONLY_LOCAL) { this->ld.cal_e_delta_band(dm, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, ParaO.nrow); } else { this->folding_nnr(kv); this->ld.cal_e_delta_band_k(dm_k, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, kv.nkstot, ParaO.nrow, ParaO.ncol); @@ -263,8 +263,8 @@ void test_deepks::check_v_delta() this->ld.add_v_delta(ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, ParaO.nrow, ParaO.ncol); this->ld.check_v_delta(ParaO.nrow,ParaO.ncol); @@ -277,8 +277,8 @@ void test_deepks::check_v_delta() this->ld.add_v_delta_k(ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, nnr); this->ld.check_v_delta_k(nnr); this->compare_with_ref("H_V_deltaR.dat","H_V_deltaR_ref.dat"); @@ -295,8 +295,8 @@ void test_deepks::check_f_delta() ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, 1, svnl_dalpha); } else @@ -305,8 +305,8 @@ void test_deepks::check_f_delta() ucell, ORB, Test_Deepks::GridD, - ParaO.trace_loc_row, - ParaO.trace_loc_col, + ParaO.global2local_row, + ParaO.global2local_col, kv.nkstot, kv.kvec_d, 1,svnl_dalpha); diff --git a/source/module_hamilt_lcao/module_deepks/test/nnr.cpp b/source/module_hamilt_lcao/module_deepks/test/nnr.cpp index 66074d30b9e..d783b34971d 100644 --- a/source/module_hamilt_lcao/module_deepks/test/nnr.cpp +++ b/source/module_hamilt_lcao/module_deepks/test/nnr.cpp @@ -50,13 +50,13 @@ void test_deepks::cal_nnr(void) // the index of orbitals in this processor // according to HPSEPS's division method. const int iw1_all = start1 + ii; - const int mu = ParaO.trace_loc_row[iw1_all]; + const int mu = ParaO.global2local_row[iw1_all]; if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = ParaO.trace_loc_col[iw2_all]; + const int nu = ParaO.global2local_col[iw2_all]; if(nu<0)continue; int iic; diff --git a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp b/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp index 5f53aeece50..1475747560e 100644 --- a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp +++ b/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp @@ -5,14 +5,14 @@ namespace Test_Deepks Parallel_Orbitals::Parallel_Orbitals() { - trace_loc_row = nullptr; - trace_loc_col = nullptr; + global2local_row = nullptr; + global2local_col = nullptr; } Parallel_Orbitals::~Parallel_Orbitals() { - delete[] trace_loc_row; - delete[] trace_loc_col; + delete[] global2local_row; + delete[] global2local_col; } void Parallel_Orbitals::set_global2local(void) @@ -20,28 +20,28 @@ namespace Test_Deepks ModuleBase::TITLE("Parallel_Orbitals","set_trace"); assert(GlobalV::NLOCAL>0); - delete[] trace_loc_row; - delete[] trace_loc_col; + delete[] global2local_row; + delete[] global2local_col; - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"trace_loc_row dimension",GlobalV::NLOCAL); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"trace_loc_col dimension",GlobalV::NLOCAL); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"global2local_row dimension",GlobalV::NLOCAL); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"global2local_col dimension",GlobalV::NLOCAL); - trace_loc_row = new int[GlobalV::NLOCAL]; - trace_loc_col = new int[GlobalV::NLOCAL]; + global2local_row = new int[GlobalV::NLOCAL]; + global2local_col = new int[GlobalV::NLOCAL]; // mohan update 2011-04-07 for(int i=0; inrow = GlobalV::NLOCAL; this->ncol = GlobalV::NLOCAL; diff --git a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.h b/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.h index cfa8c3fd53e..b3a9148e066 100644 --- a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.h +++ b/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.h @@ -14,8 +14,8 @@ namespace Test_Deepks Parallel_Orbitals(); ~Parallel_Orbitals(); - int* trace_loc_row; - int* trace_loc_col; + int* global2local_row; + int* global2local_col; void set_global2local(void); int ncol; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp b/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp index 1297d34d5da..abb0a40b311 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp @@ -70,14 +70,14 @@ void DFTU::fold_dSR_gamma(const int dim1, const int dim2, double* dSR_gamma) { const int jj0 = jj / GlobalV::NPOL; const int iw1_all = start1 + jj0; - const int mu = this->LM->ParaV->trace_loc_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row[iw1_all]; if (mu < 0) continue; for (int kk = 0; kk < atom2->nw * GlobalV::NPOL; ++kk) { const int kk0 = kk / GlobalV::NPOL; const int iw2_all = start2 + kk0; - const int nu = this->LM->ParaV->trace_loc_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col[iw2_all]; if (nu < 0) continue; dSR_gamma[nu * this->LM->ParaV->nrow + mu] += dS_ptr[nnr] * this->LM->DH_r[nnr * 3 + dim2]; @@ -188,13 +188,13 @@ void DFTU::folding_matrix_k(const int ik, const int dim1, const int dim2, std::c { // the index of orbitals in this processor const int iw1_all = start1 + ii; - const int mu = this->LM->ParaV->trace_loc_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row[iw1_all]; if (mu < 0) continue; for (int jj = 0; jj < atom2->nw * GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->trace_loc_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col[iw2_all]; if (nu < 0) continue; int iic; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_force.cpp b/source/module_hamilt_lcao/module_dftu/dftu_force.cpp index bedd4c2922e..ebfbdf1ca23 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_force.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_force.cpp @@ -203,12 +203,12 @@ void DFTU::cal_force_k(const int ik, for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->row_set[ir]; + const int iwt1 = this->LM->ParaV->local2global_row[ir]; const int iat1 = GlobalC::ucell.iwt2iat[iwt1]; for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->col_set[ic]; + const int iwt2 = this->LM->ParaV->local2global_col[ic]; const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) force_dftu(iat1, dim) += dm_VU_dSm[irc].real(); @@ -250,8 +250,8 @@ void DFTU::cal_force_k(const int ik, for (int ipol = 0; ipol < GlobalV::NPOL; ipol++) { const int iwt = this->iatlnmipol2iwt[iat][l][n][m][ipol]; - const int mu = this->LM->ParaV->trace_loc_row[iwt]; - const int nu = this->LM->ParaV->trace_loc_col[iwt]; + const int mu = this->LM->ParaV->global2local_row[iwt]; + const int nu = this->LM->ParaV->global2local_col[iwt]; if (mu < 0 || nu < 0) continue; force_dftu(iat, dim) += dm_VU_dSm[nu * this->LM->ParaV->nrow + mu].real(); @@ -299,10 +299,10 @@ void DFTU::cal_stress_k(const int ik, for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->row_set[ir]; + const int iwt1 = this->LM->ParaV->local2global_row[ir]; for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->col_set[ic]; + const int iwt2 = this->LM->ParaV->local2global_col[ic]; const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) stress_dftu(dim1, dim2) += 2.0 * dm_VU_sover[irc].real(); @@ -345,12 +345,12 @@ void DFTU::cal_force_gamma(const double* rho_VU, ModuleBase::matrix& force_dftu) for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->row_set[ir]; + const int iwt1 = this->LM->ParaV->local2global_row[ir]; const int iat1 = GlobalC::ucell.iwt2iat[iwt1]; for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->col_set[ic]; + const int iwt2 = this->LM->ParaV->local2global_col[ic]; const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) force_dftu(iat1, dim) += dm_VU_dSm[irc]; @@ -394,8 +394,8 @@ void DFTU::cal_force_gamma(const double* rho_VU, ModuleBase::matrix& force_dftu) for (int ipol = 0; ipol < GlobalV::NPOL; ipol++) { const int iwt = this->iatlnmipol2iwt[iat][l][n][m][ipol]; - const int mu = this->LM->ParaV->trace_loc_row[iwt]; - const int nu = this->LM->ParaV->trace_loc_col[iwt]; + const int mu = this->LM->ParaV->global2local_row[iwt]; + const int nu = this->LM->ParaV->global2local_col[iwt]; if (mu < 0 || nu < 0) continue; force_dftu(iat, dim) += dm_VU_dSm[nu * this->LM->ParaV->nrow + mu]; @@ -441,11 +441,11 @@ void DFTU::cal_stress_gamma(const double* rho_VU, ModuleBase::matrix& stress_dft for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->row_set[ir]; + const int iwt1 = this->LM->ParaV->local2global_row[ir]; for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->col_set[ic]; + const int iwt2 = this->LM->ParaV->local2global_col[ic]; const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) stress_dftu(dim1, dim2) += 2.0 * dm_VU_sover[irc]; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp b/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp index 60d81a49d30..7e92e94b17d 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp @@ -215,16 +215,16 @@ void DFTU::cal_occup_m_k(const int iter, for (int ipol0 = 0; ipol0 < GlobalV::NPOL; ipol0++) { const int iwt0 = this->iatlnmipol2iwt[iat][l][n][m0][ipol0]; - const int mu = this->LM->ParaV->trace_loc_row[iwt0]; - const int mu_prime = this->LM->ParaV->trace_loc_col[iwt0]; + const int mu = this->LM->ParaV->global2local_row[iwt0]; + const int mu_prime = this->LM->ParaV->global2local_col[iwt0]; for (int m1 = 0; m1 < 2 * l + 1; m1++) { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { const int iwt1 = this->iatlnmipol2iwt[iat][l][n][m1][ipol1]; - const int nu = this->LM->ParaV->trace_loc_col[iwt1]; - const int nu_prime = this->LM->ParaV->trace_loc_row[iwt1]; + const int nu = this->LM->ParaV->global2local_col[iwt1]; + const int nu_prime = this->LM->ParaV->global2local_row[iwt1]; const int irc = nu * this->LM->ParaV->nrow + mu; const int irc_prime = mu_prime * this->LM->ParaV->nrow + nu_prime; @@ -409,16 +409,16 @@ void DFTU::cal_occup_m_gamma(const int iter, std::vector &dm for (int ipol0 = 0; ipol0 < GlobalV::NPOL; ipol0++) { const int iwt0 = this->iatlnmipol2iwt[iat][l][n][m0][ipol0]; - const int mu = this->LM->ParaV->trace_loc_row[iwt0]; - const int mu_prime = this->LM->ParaV->trace_loc_col[iwt0]; + const int mu = this->LM->ParaV->global2local_row[iwt0]; + const int mu_prime = this->LM->ParaV->global2local_col[iwt0]; for (int m1 = 0; m1 < 2 * l + 1; m1++) { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { const int iwt1 = this->iatlnmipol2iwt[iat][l][n][m1][ipol1]; - const int nu = this->LM->ParaV->trace_loc_col[iwt1]; - const int nu_prime = this->LM->ParaV->trace_loc_row[iwt1]; + const int nu = this->LM->ParaV->global2local_col[iwt1]; + const int nu_prime = this->LM->ParaV->global2local_row[iwt1]; const int irc = nu * this->LM->ParaV->nrow + mu; const int irc_prime = mu_prime * this->LM->ParaV->nrow + nu_prime; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp b/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp index 08563587f78..98cbf1f7b3f 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp @@ -31,7 +31,7 @@ void DFTU::cal_VU_pot_mat_complex(const int spin, const bool newlocale, std::com { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { - const int mu = this->LM->ParaV->trace_loc_row[this->iatlnmipol2iwt[iat][L][n][m1][ipol1]]; + const int mu = this->LM->ParaV->global2local_row[this->iatlnmipol2iwt[iat][L][n][m1][ipol1]]; if (mu < 0) continue; @@ -40,7 +40,7 @@ void DFTU::cal_VU_pot_mat_complex(const int spin, const bool newlocale, std::com for (int ipol2 = 0; ipol2 < GlobalV::NPOL; ipol2++) { const int nu - = this->LM->ParaV->trace_loc_col[this->iatlnmipol2iwt[iat][L][n][m2][ipol2]]; + = this->LM->ParaV->global2local_col[this->iatlnmipol2iwt[iat][L][n][m2][ipol2]]; if (nu < 0) continue; @@ -87,7 +87,7 @@ void DFTU::cal_VU_pot_mat_real(const int spin, const bool newlocale, double* VU) { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { - const int mu = this->LM->ParaV->trace_loc_row[this->iatlnmipol2iwt[iat][L][n][m1][ipol1]]; + const int mu = this->LM->ParaV->global2local_row[this->iatlnmipol2iwt[iat][L][n][m1][ipol1]]; if (mu < 0) continue; for (int m2 = 0; m2 < 2 * L + 1; m2++) @@ -95,7 +95,7 @@ void DFTU::cal_VU_pot_mat_real(const int spin, const bool newlocale, double* VU) for (int ipol2 = 0; ipol2 < GlobalV::NPOL; ipol2++) { const int nu - = this->LM->ParaV->trace_loc_col[this->iatlnmipol2iwt[iat][L][n][m2][ipol2]]; + = this->LM->ParaV->global2local_col[this->iatlnmipol2iwt[iat][L][n][m2][ipol2]]; if (nu < 0) continue; diff --git a/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp b/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp index a829126be1b..d1e64178297 100644 --- a/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp @@ -110,11 +110,11 @@ void Gint_k::distribute_pvpR_sparseMatrix( Parallel_Reduce::reduce_double_pool(tmp, GlobalV::NLOCAL); - if (LM->ParaV->trace_loc_row[row] >= 0) + if (LM->ParaV->global2local_row[row] >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->trace_loc_col[col] >= 0) + if(LM->ParaV->global2local_col[col] >= 0) { if (std::abs(tmp[col]) > sparse_threshold) { @@ -244,11 +244,11 @@ void Gint_k::distribute_pvpR_soc_sparseMatrix( Parallel_Reduce::reduce_complex_double_pool(tmp_soc, GlobalV::NLOCAL); - if (LM->ParaV->trace_loc_row[row] >= 0) + if (LM->ParaV->global2local_row[row] >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->trace_loc_col[col] >= 0) + if(LM->ParaV->global2local_col[col] >= 0) { if (std::abs(tmp_soc[col]) > sparse_threshold) { diff --git a/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp b/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp index f3a66da6044..4f396e73a38 100644 --- a/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp @@ -110,11 +110,11 @@ void Gint_k::distribute_pvdpR_sparseMatrix( Parallel_Reduce::reduce_double_pool(tmp, GlobalV::NLOCAL); - if (LM->ParaV->trace_loc_row[row] >= 0) + if (LM->ParaV->global2local_row[row] >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->trace_loc_col[col] >= 0) + if(LM->ParaV->global2local_col[col] >= 0) { if (std::abs(tmp[col]) > sparse_threshold) { @@ -266,11 +266,11 @@ void Gint_k::distribute_pvdpR_soc_sparseMatrix( Parallel_Reduce::reduce_complex_double_pool(tmp_soc, GlobalV::NLOCAL); - if (LM->ParaV->trace_loc_row[row] >= 0) + if (LM->ParaV->global2local_row[row] >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->trace_loc_col[col] >= 0) + if(LM->ParaV->global2local_col[col] >= 0) { if (std::abs(tmp_soc[col]) > sparse_threshold) { diff --git a/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp b/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp index 4850c8e0595..fe31db76039 100644 --- a/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp @@ -525,8 +525,8 @@ void AtomPair::add_to_array(std::complex* array, const std::complex& kp template T& AtomPair::get_matrix_value(const size_t& i_row_global, const size_t& j_col_global) const { - int i_row_local = this->paraV == nullptr? i_row_global : this->paraV->trace_loc_row[i_row_global]; - int j_col_local = this->paraV == nullptr? j_col_global : this->paraV->trace_loc_col[j_col_global]; + int i_row_local = this->paraV == nullptr? i_row_global : this->paraV->global2local_row[i_row_global]; + int j_col_local = this->paraV == nullptr? j_col_global : this->paraV->global2local_col[j_col_global]; #ifdef __DEBUG assert(i_row_local != -1 && j_col_local != -1); assert(current_R < this->values.size()); diff --git a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp index 4e237c9934a..9c753a4ae5f 100644 --- a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp @@ -594,14 +594,14 @@ TEST_F(HContainerTest, atompair_funcs) hamilt::AtomPair atom_ij5(0, 1, 1, 1, 1, &PO, correct_array); hamilt::AtomPair atom_ij6(1, 0, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, correct_array); hamilt::AtomPair atom_ij7(1, 1, 1, 1, 1, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, correct_array); - // get_matrix_value will use trace_loc_row and trace_loc_col in Parallel_Orbitals + // get_matrix_value will use global2local_row and global2local_col in Parallel_Orbitals // so we need to set them - PO.trace_loc_col = new int[4]; - PO.trace_loc_row = new int[4]; + PO.global2local_col = new int[4]; + PO.global2local_row = new int[4]; for(int i=0;i<4;++i) { - PO.trace_loc_col[i] = i; - PO.trace_loc_row[i] = i; + PO.global2local_col[i] = i; + PO.global2local_row[i] = i; } for(int i=0;i<4;++i) { diff --git a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp index 68c693baded..f5d006359f1 100644 --- a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp @@ -553,14 +553,14 @@ TEST_F(HContainerTest, atompair_funcs) hamilt::AtomPair> atom_ij5(0, 1, 1, 1, 1, &PO, correct_array); hamilt::AtomPair> atom_ij6(1, 0, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, correct_array); hamilt::AtomPair> atom_ij7(1, 1, 1, 1, 1, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, correct_array); - // get_matrix_value will use trace_loc_row and trace_loc_col in Parallel_Orbitals + // get_matrix_value will use global2local_row and global2local_col in Parallel_Orbitals // so we need to set them - PO.trace_loc_col = new int[4]; - PO.trace_loc_row = new int[4]; + PO.global2local_col = new int[4]; + PO.global2local_row = new int[4]; for(int i=0;i<4;++i) { - PO.trace_loc_col[i] = i; - PO.trace_loc_row[i] = i; + PO.global2local_col[i] = i; + PO.global2local_row[i] = i; } for(int i=0;i<4;++i) { diff --git a/source/module_io/cal_r_overlap_R.cpp b/source/module_io/cal_r_overlap_R.cpp index f28649cc921..a2dd9b30856 100644 --- a/source/module_io/cal_r_overlap_R.cpp +++ b/source/module_io/cal_r_overlap_R.cpp @@ -291,12 +291,12 @@ void cal_r_overlap_R::out_rR(const int &istep) int ir, ic; for(int iw1 = 0; iw1 < GlobalV::NLOCAL; iw1++) { - ir = this->ParaV->trace_loc_row[iw1]; + ir = this->ParaV->global2local_row[iw1]; if(ir >= 0) { for(int iw2 = 0; iw2 < GlobalV::NLOCAL; iw2++) { - ic = this->ParaV->trace_loc_col[iw2]; + ic = this->ParaV->global2local_col[iw2]; if(ic >= 0) { int orb_index_row = iw1 / GlobalV::NPOL; @@ -528,12 +528,12 @@ void cal_r_overlap_R::out_rR_other(const int &istep, const std::setParaV->trace_loc_row[iw1]; + ir = this->ParaV->global2local_row[iw1]; if(ir >= 0) { for(int iw2 = 0; iw2 < GlobalV::NLOCAL; iw2++) { - ic = this->ParaV->trace_loc_col[iw2]; + ic = this->ParaV->global2local_col[iw2]; if(ic >= 0) { int orb_index_row = iw1 / GlobalV::NPOL; diff --git a/source/module_io/istate_charge.cpp b/source/module_io/istate_charge.cpp index 24da6a6f525..4af47daa1a7 100644 --- a/source/module_io/istate_charge.cpp +++ b/source/module_io/istate_charge.cpp @@ -181,7 +181,7 @@ void IState_Charge::idmatrix(const int& ib, elecstate::ElecState* pelec) for (int is = 0; is != GlobalV::NSPIN; ++is) { std::vector wg_local(this->loc->ParaV->ncol, 0.0); - const int ib_local = this->loc->ParaV->trace_loc_col[ib]; + const int ib_local = this->loc->ParaV->global2local_col[ib]; int fermi_band = 0; fermi_band = static_cast((GlobalV::nelec + 1) / 2 + 1.0e-8); diff --git a/source/module_io/mulliken_charge.cpp b/source/module_io/mulliken_charge.cpp index 239187e0477..7b744547e31 100644 --- a/source/module_io/mulliken_charge.cpp +++ b/source/module_io/mulliken_charge.cpp @@ -67,8 +67,8 @@ ModuleBase::matrix ModuleIO::cal_mulliken(const std::vector for(size_t i=0; i!=GlobalV::NLOCAL; ++i) if(uhm.LM->ParaV->in_this_processor(i, i)) { - const int ir = uhm.LM->ParaV->trace_loc_row[i]; - const int ic = uhm.LM->ParaV->trace_loc_col[i]; + const int ir = uhm.LM->ParaV->global2local_row[i]; + const int ic = uhm.LM->ParaV->global2local_col[i]; MecMulP(is, i) += mud(ic, ir); } } @@ -85,26 +85,26 @@ ModuleBase::matrix ModuleIO::cal_mulliken(const std::vector const int k2 = 2*j+1; if(uhm.LM->ParaV->in_this_processor(k1, k1)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k1]; - const int ic = uhm.LM->ParaV->trace_loc_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row[k1]; + const int ic = uhm.LM->ParaV->global2local_col[k1]; MecMulP(0, j) += mud(ir, ic); } if(uhm.LM->ParaV->in_this_processor(k1, k2)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k1]; - const int ic = uhm.LM->ParaV->trace_loc_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row[k1]; + const int ic = uhm.LM->ParaV->global2local_col[k2]; MecMulP(1, j) += mud(ir, ic); } if(uhm.LM->ParaV->in_this_processor(k2, k1)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k2]; - const int ic = uhm.LM->ParaV->trace_loc_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row[k2]; + const int ic = uhm.LM->ParaV->global2local_col[k1]; MecMulP(2, j) += mud(ir, ic); } if(uhm.LM->ParaV->in_this_processor(k2, k2)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k2]; - const int ic = uhm.LM->ParaV->trace_loc_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row[k2]; + const int ic = uhm.LM->ParaV->global2local_col[k2]; MecMulP(3, j) += mud(ir, ic); } } @@ -171,8 +171,8 @@ ModuleBase::matrix ModuleIO::cal_mulliken_k(const std::vectorParaV->in_this_processor(i, i)) { - const int ir = uhm.LM->ParaV->trace_loc_row[i]; - const int ic = uhm.LM->ParaV->trace_loc_col[i]; + const int ir = uhm.LM->ParaV->global2local_row[i]; + const int ic = uhm.LM->ParaV->global2local_col[i]; MecMulP(spin, i) += mud(ic, ir).real(); } } @@ -188,29 +188,29 @@ ModuleBase::matrix ModuleIO::cal_mulliken_k(const std::vectorParaV->in_this_processor(k1, k1)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k1]; - const int ic = uhm.LM->ParaV->trace_loc_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row[k1]; + const int ic = uhm.LM->ParaV->global2local_col[k1]; MecMulP(0, j) += mud(ic, ir).real(); MecMulP(3, j) += mud(ic, ir).real(); } if(uhm.LM->ParaV->in_this_processor(k1, k2)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k1]; - const int ic = uhm.LM->ParaV->trace_loc_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row[k1]; + const int ic = uhm.LM->ParaV->global2local_col[k2]; MecMulP(1, j) += mud(ic, ir).real(); MecMulP(2, j) += mud(ic, ir).imag(); } if(uhm.LM->ParaV->in_this_processor(k2, k1)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k2]; - const int ic = uhm.LM->ParaV->trace_loc_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row[k2]; + const int ic = uhm.LM->ParaV->global2local_col[k1]; MecMulP(1, j) += mud(ic, ir).real(); MecMulP(2, j) -= mud(ic, ir).imag(); } if(uhm.LM->ParaV->in_this_processor(k2, k2)) { - const int ir = uhm.LM->ParaV->trace_loc_row[k2]; - const int ic = uhm.LM->ParaV->trace_loc_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row[k2]; + const int ic = uhm.LM->ParaV->global2local_col[k2]; MecMulP(0, j) += mud(ic, ir).real(); MecMulP(3, j) -= mud(ic, ir).real(); } diff --git a/source/module_io/single_R_io.cpp b/source/module_io/single_R_io.cpp index 648e87e7736..3b1be73f608 100644 --- a/source/module_io/single_R_io.cpp +++ b/source/module_io/single_R_io.cpp @@ -33,7 +33,7 @@ void ModuleIO::output_single_R(std::ofstream &ofs, const std::map= 0) + if(pv.global2local_row[row] >= 0) { auto iter = XR.find(row); if (iter != XR.end()) @@ -146,7 +146,7 @@ void ModuleIO::output_soc_single_R(std::ofstream &ofs, const std::map[GlobalV::NLOCAL]; ModuleBase::GlobalFunc::ZEROS(line, GlobalV::NLOCAL); - if(pv.trace_loc_row[row] >= 0) + if(pv.global2local_row[row] >= 0) { auto iter = XR.find(row); if (iter != XR.end()) diff --git a/source/module_io/test/single_R_io_test.cpp b/source/module_io/test/single_R_io_test.cpp index 4de85475098..8f81d3bc609 100644 --- a/source/module_io/test/single_R_io_test.cpp +++ b/source/module_io/test/single_R_io_test.cpp @@ -15,12 +15,12 @@ Parallel_2D::Parallel_2D(){} Parallel_2D::~Parallel_2D(){} Parallel_Orbitals::Parallel_Orbitals() { - trace_loc_row = nullptr; + global2local_row = nullptr; } Parallel_Orbitals::~Parallel_Orbitals() { - delete[] trace_loc_row; + delete[] global2local_row; } TEST(ModuleIOTest, OutputSingleR) @@ -36,12 +36,12 @@ TEST(ModuleIOTest, OutputSingleR) const bool binary = false; Parallel_Orbitals pv; GlobalV::NLOCAL=5; - pv.trace_loc_row = new int[GlobalV::NLOCAL]; - pv.trace_loc_row[0] = 0; - pv.trace_loc_row[1] = 1; - pv.trace_loc_row[2] = -1; - pv.trace_loc_row[3] = 2; - pv.trace_loc_row[4] = -1; //Some rows have trace_loc_row < 0 + pv.global2local_row = new int[GlobalV::NLOCAL]; + pv.global2local_row[0] = 0; + pv.global2local_row[1] = 1; + pv.global2local_row[2] = -1; + pv.global2local_row[3] = 2; + pv.global2local_row[4] = -1; //Some rows have global2local_row < 0 std::map> XR = { {0, {{1, 0.5}, {3, 0.3}}}, {1, {{0, 0.2}, {2, 0.4}}}, diff --git a/source/module_io/unk_overlap_lcao.cpp b/source/module_io/unk_overlap_lcao.cpp index 666918ffa50..1be71016918 100644 --- a/source/module_io/unk_overlap_lcao.cpp +++ b/source/module_io/unk_overlap_lcao.cpp @@ -697,8 +697,8 @@ void unkOverlap_lcao::prepare_midmatrix_pblas(const int ik_L, { for (int iw_col = 0; iw_col < GlobalV::NLOCAL; iw_col++) // global { - int ir = pv.trace_loc_row[ iw_row ]; // local - int ic = pv.trace_loc_col[ iw_col ]; // local + int ir = pv.global2local_row[ iw_row ]; // local + int ic = pv.global2local_col[ iw_col ]; // local if(ir >= 0 && ic >= 0) { @@ -761,8 +761,8 @@ std::complex unkOverlap_lcao::det_berryphase(const int ik_L, for(int i = 0; i < occBands; i++) // global { - int ir = lowf.ParaV->trace_loc_row[ i ]; // local - int ic = lowf.ParaV->trace_loc_col[ i ]; // local + int ir = lowf.ParaV->global2local_row[ i ]; // local + int ic = lowf.ParaV->global2local_col[ i ]; // local if(ir >= 0 && ic >= 0) { int index = ic*lowf.ParaV->nrow+ir; diff --git a/source/module_io/write_HS.cpp b/source/module_io/write_HS.cpp index c31ae825719..57bec858423 100644 --- a/source/module_io/write_HS.cpp +++ b/source/module_io/write_HS.cpp @@ -185,13 +185,13 @@ void ModuleIO::save_HS_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -286,13 +286,13 @@ void ModuleIO::save_HS_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -429,13 +429,13 @@ void ModuleIO::save_HS_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -530,13 +530,13 @@ void ModuleIO::save_HS_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -705,13 +705,13 @@ void ModuleIO::save_HS_complex_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -806,13 +806,13 @@ void ModuleIO::save_HS_complex_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -950,13 +950,13 @@ void ModuleIO::save_HS_complex_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -1051,13 +1051,13 @@ void ModuleIO::save_HS_complex_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.trace_loc_row[i]; + ir = pv.global2local_row[i]; if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.trace_loc_col[j]; + ic = pv.global2local_col[j]; if (ic >= 0) { int iic; @@ -1219,13 +1219,13 @@ void ModuleIO::save_HSR_tr(const int current_spin, LCAO_Matrix &lm) // ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); // ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = lm.ParaV->trace_loc_row[i]; + ir = lm.ParaV->global2local_row[i]; if (ir >= 0) { // for(int j=i; jtrace_loc_col[j]; + ic = lm.ParaV->global2local_col[j]; if (ic >= 0) { // lineH[j-i] = H[ir*lm.ParaV->ncol+ic]; diff --git a/source/module_io/write_dm_sparse.cpp b/source/module_io/write_dm_sparse.cpp index 3c8e4329f17..f9df2a8561f 100644 --- a/source/module_io/write_dm_sparse.cpp +++ b/source/module_io/write_dm_sparse.cpp @@ -90,14 +90,14 @@ void ModuleIO::get_dm_sparse(const int &is, double** dm2d, const Parallel_Orbita for(int ii=0; iinw; ii++) { const int iw1_all = start + ii; - const int mu = ParaV->trace_loc_row[iw1_all]; + const int mu = ParaV->global2local_row[iw1_all]; if(mu<0)continue; for(int jj=0; jjnw; jj++) { int iw2_all = start2 + jj; - const int nu = ParaV->trace_loc_col[iw2_all]; + const int nu = ParaV->global2local_col[iw2_all]; if(nu<0)continue; diff --git a/source/module_io/write_dos_lcao.cpp b/source/module_io/write_dos_lcao.cpp index 1157965a0e4..31429362eae 100644 --- a/source/module_io/write_dos_lcao.cpp +++ b/source/module_io/write_dos_lcao.cpp @@ -165,8 +165,8 @@ void ModuleIO::write_dos_lcao(const psi::Psi* psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->trace_loc_row[j]; - const int ic = pv->trace_loc_col[i]; + const int ir = pv->global2local_row[j]; + const int ic = pv->global2local_col[i]; waveg[j] = Mulk[0](ic, ir) * psid[0](ic, ir); const double x = waveg[j].real(); BlasConnector::axpy(np, x, Gauss, 1, pdosk[is].c + j * pdosk[is].nc, 1); @@ -264,8 +264,8 @@ void ModuleIO::write_dos_lcao(const psi::Psi* psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->trace_loc_row[j]; - const int ic = pv->trace_loc_col[i]; + const int ir = pv->global2local_row[j]; + const int ic = pv->global2local_col[i]; waveg[j] = Mulk[0](ic, ir) * psi[0](ic, ir); const double x = waveg[j].real(); diff --git a/source/module_io/write_proj_band_lcao.cpp b/source/module_io/write_proj_band_lcao.cpp index f72e812c905..5c8808d9c2f 100644 --- a/source/module_io/write_proj_band_lcao.cpp +++ b/source/module_io/write_proj_band_lcao.cpp @@ -93,8 +93,8 @@ void ModuleIO::write_proj_band_lcao(const psi::Psi *psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->trace_loc_row[j]; - const int ic = pv->trace_loc_col[i]; + const int ir = pv->global2local_row[j]; + const int ic = pv->global2local_col[i]; weightk(is, i * GlobalV::NLOCAL + j) = Mulk[0](ic, ir) * psid[0](ic, ir); } } @@ -175,8 +175,8 @@ void ModuleIO::write_proj_band_lcao(const psi::Psi *psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->trace_loc_row[j]; - const int ic = pv->trace_loc_col[i]; + const int ir = pv->global2local_row[j]; + const int ic = pv->global2local_col[i]; weightk(ik, i * GlobalV::NLOCAL + j) = Mulk[0](ic, ir) * psi[0](ic, ir); } diff --git a/source/module_ri/RI_2D_Comm.cpp b/source/module_ri/RI_2D_Comm.cpp index e7686d41832..cb0cf9522a3 100644 --- a/source/module_ri/RI_2D_Comm.cpp +++ b/source/module_ri/RI_2D_Comm.cpp @@ -19,18 +19,18 @@ auto RI_2D_Comm::get_2D_judge(const Parallel_Orbitals &pv) const std::map nspin_b = {{1,1}, {2,1}, {4,2}}; std::vector> iat0_list(nspin_b.at(GlobalV::NSPIN)); - for (int iwt0_2D = 0; iwt0_2D < pv.row_set.size(); ++iwt0_2D) + for (int iwt0_2D = 0; iwt0_2D < pv.local2global_row.size(); ++iwt0_2D) { - const int iwt0 = pv.row_set[iwt0_2D]; + const int iwt0 = pv.local2global_row[iwt0_2D]; int iat0, iw0_b, is0_b; std::tie(iat0,iw0_b,is0_b) = RI_2D_Comm::get_iat_iw_is_block(iwt0); iat0_list[is0_b].insert(iat0); } std::vector> iat1_list(nspin_b.at(GlobalV::NSPIN)); - for (int iwt1_2D = 0; iwt1_2D < pv.col_set.size(); ++iwt1_2D) + for (int iwt1_2D = 0; iwt1_2D < pv.local2global_col.size(); ++iwt1_2D) { - const int iwt1 = pv.col_set[iwt1_2D]; + const int iwt1 = pv.local2global_col[iwt1_2D]; int iat1, iw1_b, is1_b; std::tie(iat1,iw1_b,is1_b) = RI_2D_Comm::get_iat_iw_is_block(iwt1); iat1_list[is1_b].insert(iat1); diff --git a/source/module_ri/RI_2D_Comm.hpp b/source/module_ri/RI_2D_Comm.hpp index b148a0bcc37..7b0f2814e56 100644 --- a/source/module_ri/RI_2D_Comm.hpp +++ b/source/module_ri/RI_2D_Comm.hpp @@ -53,8 +53,8 @@ auto RI_2D_Comm::split_m2D_ktoR(const K_Vectors &kv, const std::vector::out_eigen_vector(const Parallel_Orbitals ¶v, const psi: { std::vector> wfc_iks(GlobalV::NLOCAL, zero); - const int ib_local = parav.trace_loc_col[ib_global]; + const int ib_local = parav.global2local_col[ib_global]; if (ib_local >= 0) for (int ir = 0; ir < psi.get_nbasis(); ir++) - wfc_iks[parav.row_set[ir]] = psi(ik + nks_tot * is, ib_local, ir); + wfc_iks[parav.local2global_row[ir]] = psi(ik + nks_tot * is, ib_local, ir); std::vector> tmp = wfc_iks; #ifdef __MPI From b1e5c47458bf8e962669edc14ba41708cbc39553 Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Thu, 6 Jul 2023 16:31:49 +0800 Subject: [PATCH 3/5] add getters global2local, local2global --- source/module_basis/module_ao/parallel_2d.cpp | 53 +++++++------- source/module_basis/module_ao/parallel_2d.h | 41 ++++++++--- .../module_ao/parallel_orbitals.cpp | 4 +- .../module_ao/test/parallel_2d_test.cpp | 23 +++--- source/module_elecstate/cal_dm.h | 4 +- source/module_esolver/esolver_ks_lcao.cpp | 4 +- .../module_esolver/esolver_ks_lcao_elec.cpp | 40 ++++------- .../hamilt_lcaodft/FORCE_STRESS.cpp | 25 +++---- .../hamilt_lcaodft/FORCE_gamma.cpp | 32 ++++----- .../hamilt_lcaodft/FORCE_gamma_edm.cpp | 4 +- .../hamilt_lcaodft/FORCE_gamma_tvnl.cpp | 12 ++-- .../hamilt_lcaodft/FORCE_k.cpp | 42 +++++------ .../hamilt_lcaodft/LCAO_gen_fixedH.cpp | 28 ++++---- .../hamilt_lcaodft/LCAO_hamilt.cpp | 32 ++++----- .../hamilt_lcaodft/LCAO_hamilt.hpp | 4 +- .../hamilt_lcaodft/LCAO_matrix.cpp | 29 ++++---- .../hamilt_lcaodft/LCAO_nnr.cpp | 8 +-- .../hamilt_lcaodft/dm_2d.cpp | 4 +- .../operator_lcao/deepks_lcao.cpp | 24 +++---- .../hamilt_lcaodft/record_adj.cpp | 4 +- .../module_deepks/LCAO_deepks.cpp | 17 +++-- .../module_deepks/LCAO_deepks.h | 71 ++++++------------- .../module_deepks/LCAO_deepks_fdelta.cpp | 16 ++--- .../module_deepks/LCAO_deepks_interface.cpp | 16 ++--- .../module_deepks/LCAO_deepks_odelta.cpp | 19 +++-- .../module_deepks/LCAO_deepks_pdm.cpp | 32 ++++----- .../module_deepks/LCAO_deepks_psialpha.cpp | 16 ++--- .../module_deepks/LCAO_deepks_torch.cpp | 14 ++-- .../module_deepks/LCAO_deepks_vdelta.cpp | 65 +++++++---------- .../module_deepks/test/LCAO_deepks_test.cpp | 59 ++++----------- .../module_deepks/test/nnr.cpp | 12 ++-- .../module_deepks/test/parallel_orbitals.cpp | 8 +-- .../module_dftu/dftu_folding.cpp | 8 +-- .../module_dftu/dftu_force.cpp | 24 +++---- .../module_dftu/dftu_occup.cpp | 16 ++--- .../module_dftu/dftu_tools.cpp | 8 +-- .../module_gint/gint_k_sparse.cpp | 8 +-- .../module_gint/gint_k_sparse1.cpp | 8 +-- .../module_hcontainer/atom_pair.cpp | 4 +- .../test/test_hcontainer.cpp | 11 +-- .../test/test_hcontainer_complex.cpp | 11 +-- source/module_io/cal_r_overlap_R.cpp | 8 +-- source/module_io/istate_charge.cpp | 2 +- source/module_io/mulliken_charge.cpp | 40 +++++------ source/module_io/single_R_io.cpp | 4 +- source/module_io/test/single_R_io_test.cpp | 23 +++--- source/module_io/unk_overlap_lcao.cpp | 8 +-- source/module_io/write_HS.cpp | 36 +++++----- source/module_io/write_dm_sparse.cpp | 4 +- source/module_io/write_dos_lcao.cpp | 8 +-- source/module_io/write_proj_band_lcao.cpp | 8 +-- source/module_ri/RI_2D_Comm.cpp | 8 +-- source/module_ri/RI_2D_Comm.hpp | 12 ++-- source/module_ri/RPA_LRI.hpp | 4 +- 54 files changed, 453 insertions(+), 572 deletions(-) diff --git a/source/module_basis/module_ao/parallel_2d.cpp b/source/module_basis/module_ao/parallel_2d.cpp index 097e2671fe1..7c2f9c372b0 100644 --- a/source/module_basis/module_ao/parallel_2d.cpp +++ b/source/module_basis/module_ao/parallel_2d.cpp @@ -5,8 +5,8 @@ Parallel_2D::Parallel_2D() {} Parallel_2D::~Parallel_2D() { - delete[] global2local_row; - delete[] global2local_col; + delete[] global2local_row_; + delete[] global2local_col_; } void Parallel_2D::set_proc_dim(const int& dsize, bool mode /*= 0*/) @@ -35,9 +35,9 @@ void Parallel_2D::set_proc_dim(const int& dsize, bool mode /*= 0*/) bool Parallel_2D::in_this_processor(const int& iw1_all, const int& iw2_all) const { - if (global2local_row[iw1_all] == -1) + if (global2local_row(iw1_all) == -1) return false; - else if (global2local_col[iw2_all] == -1) + else if (global2local_col(iw2_all) == -1) return false; return true; } @@ -50,8 +50,8 @@ void Parallel_2D::set_global2local(const int& M_A, const int& N_A, this->init_global2local(M_A, N_A, ofs_running); if (!div_2d) // xiaohui add 2013-09-02 { - for (int i = 0; i < M_A; i++) this->global2local_row[i] = i; - for (int i = 0; i < N_A; i++) this->global2local_col[i] = i; + for (int i = 0; i < M_A; i++) this->global2local_row_[i] = i; + for (int i = 0; i < N_A; i++) this->global2local_col_[i] = i; this->nrow = M_A; this->ncol = N_A; this->nloc = this->nrow * this->ncol; @@ -61,19 +61,15 @@ void Parallel_2D::set_global2local(const int& M_A, const int& N_A, // ofs_running << " nrow=" << nrow << std::endl; for (int irow = 0; irow < this->nrow; irow++) { - int global_row = this->local2global_row[irow]; - this->global2local_row[global_row] = irow; - // ofs_running << " global_row=" << global_row - // << " global2local_row=" << this->global2local_row[global_row] << std::endl; + int global_row = this->local2global_row(irow); + this->global2local_row_[global_row] = irow; } // ofs_running << " ncol=" << ncol << std::endl; for (int icol = 0; icol < this->ncol; icol++) { - int global_col = this->local2global_col[icol]; - this->global2local_col[global_col] = icol; - // ofs_running << " global_col=" << global_col - // << " global2local_col=" << this->global2local_row[global_col] << std::endl; + int global_col = this->local2global_col(icol); + this->global2local_col_[global_col] = icol; } } @@ -86,17 +82,17 @@ void Parallel_2D::init_global2local(const int& M_A, const int& N_A, std::ofstrea assert(M_A > 0); assert(N_A > 0); - delete[] this->global2local_row; - delete[] this->global2local_col; + delete[] this->global2local_row_; + delete[] this->global2local_col_; ModuleBase::GlobalFunc::OUT(ofs_running, "global2local_row dimension", M_A); ModuleBase::GlobalFunc::OUT(ofs_running, "global2local_col dimension", N_A); - this->global2local_row = new int[M_A]; - this->global2local_col = new int[N_A]; + this->global2local_row_ = new int[M_A]; + this->global2local_col_ = new int[N_A]; - for (int i = 0; i < M_A; i++) this->global2local_row[i] = -1; - for (int i = 0; i < N_A; i++) this->global2local_col[i] = -1; + for (int i = 0; i < M_A; i++) this->global2local_row_[i] = -1; + for (int i = 0; i < N_A; i++) this->global2local_col_[i] = -1; ModuleBase::Memory::record("trace_row_col", sizeof(int) * M_A); ModuleBase::Memory::record("trace_row_col", sizeof(int) * N_A); @@ -245,14 +241,13 @@ int Parallel_2D::set_local2global( // (5) local2global_row, it's a global index : // save explicitly : every row in this processor // belongs to which row in the global matrix. - this->local2global_row.resize(this->nrow); + this->local2global_row_.resize(this->nrow); j = 0; for (int i = 0; i < row_b; i++) { for (int k = 0; k < nb && (coord[0] * nb + i * nb * dim[0] + k < M_A); k++, j++) { - this->local2global_row[j] = coord[0] * nb + i * nb * dim[0] + k; - // ofs_running << " j=" << j << " local2global_row=" << this->local2global_row[j] << std::endl; + this->local2global_row_[j] = coord[0] * nb + i * nb * dim[0] + k; } } @@ -311,14 +306,14 @@ int Parallel_2D::set_local2global( //set nloc this->nloc = this->nrow * this->ncol; - this->local2global_col.resize(this->ncol); + this->local2global_col_.resize(this->ncol); j = 0; for (int i = 0; i < col_b; i++) { for (int k = 0; k < nb && (coord[1] * nb + i * nb * dim[1] + k < N_A); k++, j++) { - this->local2global_col[j] = coord[1] * nb + i * nb * dim[1] + k; + this->local2global_col_[j] = coord[1] * nb + i * nb * dim[1] + k; } } return 0; @@ -330,9 +325,9 @@ void Parallel_2D::set_serial(const int& M_A, const int& N_A) this->nrow = M_A; this->ncol = N_A; this->nloc = this->nrow * this->ncol; - this->local2global_row.resize(this->nrow); - this->local2global_col.resize(this->ncol); - for (int i = 0; i < this->nrow; i++) this->local2global_row[i] = i; - for (int i = 0; i < this->ncol; i++) this->local2global_col[i] = i; + this->local2global_row_.resize(this->nrow); + this->local2global_col_.resize(this->ncol); + for (int i = 0; i < this->nrow; i++) this->local2global_row_[i] = i; + for (int i = 0; i < this->ncol; i++) this->local2global_col_[i] = i; } #endif \ No newline at end of file diff --git a/source/module_basis/module_ao/parallel_2d.h b/source/module_basis/module_ao/parallel_2d.h index 9cbe1f5aa53..a9a45672188 100644 --- a/source/module_basis/module_ao/parallel_2d.h +++ b/source/module_basis/module_ao/parallel_2d.h @@ -15,14 +15,6 @@ class Parallel_2D Parallel_2D(); ~Parallel_2D(); - /// map from global index to local index - int* global2local_row = nullptr; - int* global2local_col = nullptr; - - /// map from local index to global index - std::vector local2global_row; // Peize Lin change int* to vector 2022.08.03 - std::vector local2global_col; - /// local size (nloc = nrow * ncol) int nrow; int ncol; @@ -51,6 +43,30 @@ class Parallel_2D /// total number of elements of matrix in this processor int get_local_size()const { return this->nloc; }; + /// get the local index of a global index (row) + int global2local_row(const int& igr) const + { + return this->global2local_row_[igr]; + } + + /// get the local index of a global index (col) + int global2local_col(const int& igc) const + { + return this->global2local_col_[igc]; + } + + /// get the global index of a local index (row) + int local2global_row(const int& ilr) const + { + return this->local2global_row_[ilr]; + } + + /// get the global index of a local index (col) + int local2global_col(const int& ilc) const + { + return this->local2global_col_[ilc]; + } + /// check whether an element is in this processor /// (check whether local-index > 0 ) bool in_this_processor(const int& iw1_all, const int& iw2_all) const; @@ -94,6 +110,15 @@ class Parallel_2D std::ofstream& ofs_running); protected: + + /// map from global index to local index + int* global2local_row_ = nullptr; + int* global2local_col_ = nullptr; + + /// map from local index to global index + std::vector local2global_row_; // Peize Lin change int* to vector 2022.08.03 + std::vector local2global_col_; + /// set the map from local index to global index void init_global2local(const int& M_A/**< global row size*/, const int& N_A/**< global col size*/, diff --git a/source/module_basis/module_ao/parallel_orbitals.cpp b/source/module_basis/module_ao/parallel_orbitals.cpp index 2291b360bc6..3ea9ec0535b 100644 --- a/source/module_basis/module_ao/parallel_orbitals.cpp +++ b/source/module_basis/module_ao/parallel_orbitals.cpp @@ -41,7 +41,7 @@ void Parallel_Orbitals::set_atomic_trace(const int* iat2iwt, const int &nat, con //find the first row index of atom iat for(int i=0;iglobal2local_row[irow] != -1) + if (this->global2local_row_[irow] != -1) { this->atom_begin_row[iat] = irow; break; @@ -51,7 +51,7 @@ void Parallel_Orbitals::set_atomic_trace(const int* iat2iwt, const int &nat, con //find the first col index of atom iat for(int i=0;iglobal2local_col[icol] != -1) + if (this->global2local_col_[icol] != -1) { this->atom_begin_col[iat] = icol; break; diff --git a/source/module_basis/module_ao/test/parallel_2d_test.cpp b/source/module_basis/module_ao/test/parallel_2d_test.cpp index f029e240e8d..534af3304ae 100644 --- a/source/module_basis/module_ao/test/parallel_2d_test.cpp +++ b/source/module_basis/module_ao/test/parallel_2d_test.cpp @@ -110,18 +110,21 @@ TEST_F(test_para2d, Divide2D) //5. set_global2local p2d.set_global2local(gr, gc, true, ofs_running); - auto sum_array = [](const int* arr, const int& size) -> int + auto sum_array = [&p2d](const int& gr, const int& gc) -> std::pair { - int sum = 0; - for (int i = 0; i < size; ++i) - sum += arr[i]; - return sum; + int sum_row = 0; int sum_col = 0; + for (int i = 0; i < gr; ++i) + sum_row += p2d.global2local_row(i); + for (int i = 0; i < gc; ++i) + sum_col += p2d.global2local_col(i); + return { sum_row, sum_col }; }; - EXPECT_EQ(sum_array(p2d.global2local_row, gr), lr * (lr - 1) / 2 - (gr - lr)); - EXPECT_EQ(sum_array(p2d.global2local_col, gc), lc * (lc - 1) / 2 - (gc - lc)); + std::pair sumrc = sum_array(gr, gc); + EXPECT_EQ(std::get<0>(sumrc), lr * (lr - 1) / 2 - (gr - lr)); + EXPECT_EQ(std::get<1>(sumrc), lc * (lc - 1) / 2 - (gc - lc)); for (int i = 0;i < lr;++i) for (int j = 0;j < lc;++j) - EXPECT_TRUE(p2d.in_this_processor(p2d.local2global_row[i], p2d.local2global_col[j])); + EXPECT_TRUE(p2d.in_this_processor(p2d.local2global_row(i), p2d.local2global_col(j))); } } } @@ -149,9 +152,9 @@ TEST_F(test_para2d, Serial) //3. set_global2local p2d.set_global2local(gr, gc, false, ofs_running); for (int i = 0;i < gr;++i) - EXPECT_EQ(p2d.global2local_row[i], i); + EXPECT_EQ(p2d.global2local_row(i), i); for (int i = 0;i < gc;++i) - EXPECT_EQ(p2d.global2local_col[i], i); + EXPECT_EQ(p2d.global2local_col(i), i); } } #endif diff --git a/source/module_elecstate/cal_dm.h b/source/module_elecstate/cal_dm.h index 5bb4194a15d..71a829e54a6 100644 --- a/source/module_elecstate/cal_dm.h +++ b/source/module_elecstate/cal_dm.h @@ -33,7 +33,7 @@ inline void cal_dm(const Parallel_Orbitals* ParaV, const ModuleBase::matrix& wg, int ib_global = 0; for (int ib_local = 0; ib_local < nbands_local; ++ib_local) { - while (ib_local != ParaV->global2local_col[ib_global]) + while (ib_local != ParaV->global2local_col(ib_global)) { ++ib_global; if (ib_global >= wg.nc) @@ -91,7 +91,7 @@ inline void cal_dm(const Parallel_Orbitals* ParaV, const ModuleBase::matrix& wg, int ib_global = 0; for (int ib_local = 0; ib_local < nbands_local; ++ib_local) { - while (ib_local != ParaV->global2local_col[ib_global]) + while (ib_local != ParaV->global2local_col(ib_global)) { ++ib_global; if (ib_global >= wg.nc) diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index 200cadd9a43..b9c4f7aebe8 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -577,12 +577,12 @@ void ESolver_KS_LCAO::hamilt2density(int istep, int iter, double ethr) const Parallel_Orbitals* pv = this->LOWF.ParaV; if (GlobalV::GAMMA_ONLY_LOCAL) { - GlobalC::ld.cal_e_delta_band(this->LOC.dm_gamma, pv->global2local_row, pv->global2local_col, pv->nrow); + GlobalC::ld.cal_e_delta_band(this->LOC.dm_gamma); } else { GlobalC::ld - .cal_e_delta_band_k(this->LOC.dm_k, pv->global2local_row, pv->global2local_col, kv.nks, pv->nrow, pv->ncol); + .cal_e_delta_band_k(this->LOC.dm_k, kv.nks); } } #endif diff --git a/source/module_esolver/esolver_ks_lcao_elec.cpp b/source/module_esolver/esolver_ks_lcao_elec.cpp index dfd041d56c7..f1954cb56d9 100644 --- a/source/module_esolver/esolver_ks_lcao_elec.cpp +++ b/source/module_esolver/esolver_ks_lcao_elec.cpp @@ -252,8 +252,6 @@ namespace ModuleESolver GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, GlobalC::UOT); if (GlobalV::deepks_out_unittest) @@ -262,8 +260,6 @@ namespace ModuleESolver GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, GlobalC::UOT); } } @@ -595,43 +591,33 @@ namespace ModuleESolver if (GlobalV::GAMMA_ONLY_LOCAL) { GlobalC::ld.cal_projected_DM(this->LOC.dm_gamma[0], - GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col); + GlobalC::ucell, + GlobalC::ORB, + GlobalC::GridD); } else { GlobalC::ld.cal_projected_DM_k(this->LOC.dm_k, - GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - this->kv.nks, - this->kv.kvec_d); + GlobalC::ucell, + GlobalC::ORB, + GlobalC::GridD, + this->kv.nks, + this->kv.kvec_d); } GlobalC::ld.cal_descriptor(); // final descriptor GlobalC::ld.cal_gedm(GlobalC::ucell.nat); if (GlobalV::GAMMA_ONLY_LOCAL) { GlobalC::ld.add_v_delta(GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - pv->nrow, - pv->ncol); + GlobalC::ORB, + GlobalC::GridD); } else { GlobalC::ld.add_v_delta_k(GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - pv->nnr); + GlobalC::ORB, + GlobalC::GridD, + pv->nnr); } } #endif diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp index a9c4bf33c8c..2d94b2e211f 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp @@ -364,7 +364,6 @@ void Force_Stress_LCAO::getForceStress(const bool isforce, // DeePKS force, caoyu add 2021-06-03 if (GlobalV::deepks_out_labels) // not parallelized yet { - const Parallel_Orbitals* pv = loc.ParaV; GlobalC::ld.save_npy_f(fcs, "f_tot.npy", GlobalC::ucell.nat); // Ty/Bohr, F_tot if (GlobalV::deepks_scf) { @@ -373,24 +372,20 @@ void Force_Stress_LCAO::getForceStress(const bool isforce, if (GlobalV::GAMMA_ONLY_LOCAL) { GlobalC::ld.cal_gdmx(loc.dm_gamma[0], - GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - isstress); + GlobalC::ucell, + GlobalC::ORB, + GlobalC::GridD, + isstress); } else { GlobalC::ld.cal_gdmx_k(loc.dm_k, - GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - kv.nks, - kv.kvec_d, - isstress); + GlobalC::ucell, + GlobalC::ORB, + GlobalC::GridD, + kv.nks, + kv.kvec_d, + isstress); } if (GlobalV::deepks_out_unittest) GlobalC::ld.check_gdmx(GlobalC::ucell.nat); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp index d3de5dbbc91..7b929bfb62a 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp @@ -63,21 +63,17 @@ void Force_LCAO_gamma::ftable_gamma(const bool isforce, if (GlobalV::deepks_scf) { GlobalC::ld.cal_projected_DM(loc.dm_gamma[0], - GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col); + GlobalC::ucell, + GlobalC::ORB, + GlobalC::GridD); GlobalC::ld.cal_descriptor(); GlobalC::ld.cal_gedm(GlobalC::ucell.nat); GlobalC::ld.cal_f_delta_gamma(loc.dm_gamma[0], - GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - isstress, - svnl_dalpha); + GlobalC::ucell, + GlobalC::ORB, + GlobalC::GridD, + isstress, + svnl_dalpha); #ifdef __MPI Parallel_Reduce::reduce_double_all(GlobalC::ld.F_delta.c, GlobalC::ld.F_delta.nr * GlobalC::ld.F_delta.nc); if (isstress) @@ -92,15 +88,11 @@ void Force_LCAO_gamma::ftable_gamma(const bool isforce, GlobalC::ld.check_descriptor(GlobalC::ucell); GlobalC::ld.check_gedm(); GlobalC::ld.add_v_delta(GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - pv->nrow, - pv->ncol); - GlobalC::ld.check_v_delta(pv->nrow, pv->ncol); + GlobalC::ORB, + GlobalC::GridD); + GlobalC::ld.check_v_delta(); - GlobalC::ld.cal_e_delta_band(loc.dm_gamma, pv->global2local_row, pv->global2local_col, pv->nrow); + GlobalC::ld.cal_e_delta_band(loc.dm_gamma); std::ofstream ofs("E_delta_bands.dat"); ofs << std::setprecision(10) << GlobalC::ld.e_delta_band; std::ofstream ofs1("E_delta.dat"); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp index 0907bd314c7..8f3fc964322 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_edm.cpp @@ -44,8 +44,8 @@ void Force_LCAO_gamma::cal_foverlap( const int iat = GlobalC::ucell.iwt2iat[i]; for(int j=0; jglobal2local_row[j]; - const int nu = loc.ParaV->global2local_col[i]; + const int mu = loc.ParaV->global2local_row(j); + const int nu = loc.ParaV->global2local_col(i); if(mu>=0 && nu>=0) { const int index = mu * loc.ParaV->ncol + nu; diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp index 0dab8aaf778..7e78a2b05d4 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma_tvnl.cpp @@ -54,8 +54,8 @@ void Force_LCAO_gamma::cal_fvnl_dbeta_new( for (int iw1=0; iw1ParaV->global2local_row[iw1_all]; - const int iw2_local = this->ParaV->global2local_col[iw1_all]; + const int iw1_local = this->ParaV->global2local_row(iw1_all); + const int iw2_local = this->ParaV->global2local_col(iw1_all); if(iw1_local < 0 && iw2_local < 0) continue; std::vector> nlm; @@ -114,12 +114,12 @@ void Force_LCAO_gamma::cal_fvnl_dbeta_new( for (int iw1=0; iw1ParaV->global2local_row[iw1_all]; + const int iw1_local = this->ParaV->global2local_row(iw1_all); if(iw1_local < 0)continue; for (int iw2=0; iw2ParaV->global2local_col[iw2_all]; + const int iw2_local = this->ParaV->global2local_col(iw2_all); if(iw2_local < 0)continue; double nlm[3] = {0,0,0}; @@ -232,8 +232,8 @@ void Force_LCAO_gamma::cal_ftvnl_dphi( const int iat = GlobalC::ucell.iwt2iat[i]; for(int j=0; jParaV->global2local_row[j]; - const int nu = this->ParaV->global2local_col[i]; + const int mu = this->ParaV->global2local_row(j); + const int nu = this->ParaV->global2local_col(i); if (mu >= 0 && nu >= 0 ) { diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp index 09cffab4f3d..27af5e95d13 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp @@ -98,9 +98,7 @@ void Force_LCAO_k::ftable_k(const bool isforce, GlobalC::ld.cal_projected_DM_k(loc.dm_k, GlobalC::ucell, GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, + GlobalC::GridD, kv.nks, kv.kvec_d); GlobalC::ld.cal_descriptor(); @@ -109,9 +107,7 @@ void Force_LCAO_k::ftable_k(const bool isforce, GlobalC::ld.cal_f_delta_k(loc.dm_k, GlobalC::ucell, GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, + GlobalC::GridD, kv.nks, kv.kvec_d, isstress, @@ -130,22 +126,16 @@ void Force_LCAO_k::ftable_k(const bool isforce, GlobalC::ld.check_descriptor(GlobalC::ucell); GlobalC::ld.check_gedm(); GlobalC::ld.add_v_delta_k(GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - pv->nnr); + GlobalC::ORB, + GlobalC::GridD, + pv->nnr); GlobalC::ld.check_v_delta_k(pv->nnr); for (int ik = 0; ik < kv.nks; ik++) { uhm.LM->folding_fixedH(ik, kv.kvec_d); } GlobalC::ld.cal_e_delta_band_k(loc.dm_k, - pv->global2local_row, - pv->global2local_col, - kv.nks, - pv->nrow, - pv->ncol); + kv.nks); std::ofstream ofs("E_delta_bands.dat"); ofs << std::setprecision(10) << GlobalC::ld.e_delta_band; std::ofstream ofs1("E_delta.dat"); @@ -442,7 +432,7 @@ void Force_LCAO_k::cal_foverlap_k(const bool isforce, const int iw1_all = start1 + jj; // HPSEPS - const int mu = pv->global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if (mu < 0) continue; @@ -451,7 +441,7 @@ void Force_LCAO_k::cal_foverlap_k(const bool isforce, const int iw2_all = start2 + kk; // HPSEPS - const int nu = pv->global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if (nu < 0) continue; //============================================================== @@ -597,13 +587,13 @@ void Force_LCAO_k::cal_ftvnl_dphi_k(double** dm2d, for (int jj = 0; jj < atom1->nw; ++jj) { const int iw1_all = start1 + jj; - const int mu = pv->global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if (mu < 0) continue; for (int kk = 0; kk < atom2->nw; ++kk) { const int iw2_all = start2 + kk; - const int nu = pv->global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if (nu < 0) continue; //============================================================== @@ -806,8 +796,8 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, for (int iw1 = 0; iw1 < nw1_tot; ++iw1) { const int iw1_all = start1 + iw1; - const int iw1_local = pv->global2local_row[iw1_all]; - const int iw2_local = pv->global2local_col[iw1_all]; + const int iw1_local = pv->global2local_row(iw1_all); + const int iw2_local = pv->global2local_col(iw1_all); if (iw1_local < 0 && iw2_local < 0) continue; const int iw1_0 = iw1 / GlobalV::NPOL; @@ -1002,7 +992,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int j0 = j / GlobalV::NPOL; // added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if (mu < 0) continue; @@ -1010,7 +1000,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int k0 = k / GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if (nu < 0) continue; @@ -1106,7 +1096,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int j0 = j / GlobalV::NPOL; // added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if (mu < 0) continue; @@ -1116,7 +1106,7 @@ void Force_LCAO_k::cal_fvnl_dbeta_k_new(double** dm2d, { const int k0 = k / GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if (nu < 0) continue; total_nnr++; diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp index 51aa227dae2..85234f28eea 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_gen_fixedH.cpp @@ -273,11 +273,11 @@ void LCAO_gen_fixedH::build_ST_new(const char& dtype, const bool& calc_deri, con { for(int jj=0; jjnw * GlobalV::NPOL; ++jj) { - const int mu = pv->global2local_row[start1+jj]; + const int mu = pv->global2local_row(start1 + jj); if(mu<0)continue; for(int kk=0; kknw * GlobalV::NPOL; ++kk) { - const int nu = pv->global2local_col[start2+kk]; + const int nu = pv->global2local_col(start2 + kk); if(nu<0)continue; ++total_nnr; ++nnr; @@ -396,8 +396,8 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri for (int iw1=0; iw1global2local_row[iw1_all]; - const int iw2_local = pv->global2local_col[iw1_all]; + const int iw1_local = pv->global2local_row(iw1_all); + const int iw2_local = pv->global2local_col(iw1_all); if(iw1_local < 0 && iw2_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; std::vector> nlm; @@ -590,7 +590,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int j0 = j/GlobalV::NPOL;//added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -599,7 +599,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int k0 = k/GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if(nu < 0)continue; if(!calc_deri) @@ -737,7 +737,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int j0 = j/GlobalV::NPOL;//added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = pv->global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -746,7 +746,7 @@ void LCAO_gen_fixedH::build_Nonlocal_mu_new(double* NLloc, const bool &calc_deri { const int k0 = k/GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = pv->global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if(nu < 0)continue; total_nnr++; nnr++; @@ -844,8 +844,8 @@ void LCAO_gen_fixedH::build_Nonlocal_beta_new(double* HSloc) //update by liuyu 2 for(int iw1=0; iw1global2local_row[iw1_all]; - const int iw2_local = pv->global2local_col[iw1_all]; + const int iw1_local = pv->global2local_row(iw1_all); + const int iw2_local = pv->global2local_col(iw1_all); if(iw1_local < 0 && iw2_local < 0) continue; @@ -908,13 +908,13 @@ void LCAO_gen_fixedH::build_Nonlocal_beta_new(double* HSloc) //update by liuyu 2 for(int iw1=0; iw1global2local_row[iw1_all]; + const int iw1_local = pv->global2local_row(iw1_all); if(iw1_local < 0) continue; const int iw1_0 = iw1/GlobalV::NPOL; for(int iw2=0; iw2global2local_col[iw2_all]; + const int iw2_local = pv->global2local_col(iw2_all); if(iw2_local < 0) continue; const int iw2_0 = iw2/GlobalV::NPOL; #ifdef _OPENMP @@ -948,8 +948,8 @@ void LCAO_gen_fixedH::build_Nonlocal_beta_new(double* HSloc) //update by liuyu 2 } assert(ib==nlm1.size()); - const int ir = pv->global2local_row[ iw1_all ]; - const int ic = pv->global2local_col[ iw2_all ]; + const int ir = pv->global2local_row(iw1_all); + const int ic = pv->global2local_col(iw2_all); long index=0; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp index 46ffb7635e9..48327caf749 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.cpp @@ -147,14 +147,14 @@ void LCAO_Hamilt::calculate_STN_R_sparse(const int ¤t_spin, const double & for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->global2local_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row(iw1_all); if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->global2local_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col(iw2_all); if(nu<0)continue; @@ -269,14 +269,14 @@ void LCAO_Hamilt::calculate_STN_R_sparse_for_S(const double &sparse_threshold) for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->global2local_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row(iw1_all); if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->global2local_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col(iw2_all); if(nu<0)continue; @@ -450,14 +450,14 @@ void LCAO_Hamilt::calculate_STN_R_sparse_for_T(const double &sparse_threshold) for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->global2local_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row(iw1_all); if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->global2local_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col(iw2_all); if(nu<0)continue; @@ -552,10 +552,10 @@ void LCAO_Hamilt::calculat_HR_dftu_sparse(const int ¤t_spin, const double { for (auto &row_loop : iter->second) { - ir = this->LM->ParaV->global2local_row[row_loop.first]; + ir = this->LM->ParaV->global2local_row(row_loop.first); for (auto &col_loop : row_loop.second) { - ic = this->LM->ParaV->global2local_col[col_loop.first]; + ic = this->LM->ParaV->global2local_col(col_loop.first); if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { iic = ir + ic * this->LM->ParaV->nrow; @@ -573,12 +573,12 @@ void LCAO_Hamilt::calculat_HR_dftu_sparse(const int ¤t_spin, const double for (int i = 0; i < GlobalV::NLOCAL; ++i) { - ir = this->LM->ParaV->global2local_row[i]; + ir = this->LM->ParaV->global2local_row(i); if (ir >= 0) { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - ic = this->LM->ParaV->global2local_col[j]; + ic = this->LM->ParaV->global2local_col(j); if (ic >= 0) { if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) @@ -664,10 +664,10 @@ void LCAO_Hamilt::calculat_HR_dftu_soc_sparse(const int ¤t_spin, const dou { for (auto &row_loop : iter->second) { - ir = this->LM->ParaV->global2local_row[row_loop.first]; + ir = this->LM->ParaV->global2local_row(row_loop.first); for (auto &col_loop : row_loop.second) { - ic = this->LM->ParaV->global2local_col[col_loop.first]; + ic = this->LM->ParaV->global2local_col(col_loop.first); if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { iic = ir + ic * this->LM->ParaV->nrow; @@ -685,12 +685,12 @@ void LCAO_Hamilt::calculat_HR_dftu_soc_sparse(const int ¤t_spin, const dou for (int i = 0; i < GlobalV::NLOCAL; ++i) { - ir = this->LM->ParaV->global2local_row[i]; + ir = this->LM->ParaV->global2local_row(i); if (ir >= 0) { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - ic = this->LM->ParaV->global2local_col[j]; + ic = this->LM->ParaV->global2local_col(j); if (ic >= 0) { if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) @@ -891,14 +891,14 @@ void LCAO_Hamilt::calculate_dSTN_R_sparse(const int ¤t_spin, const double for(int ii=0; iinw*GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = this->LM->ParaV->global2local_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row(iw1_all); if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->global2local_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col(iw2_all); if(nu<0)continue; diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp index 70213da6c8b..162bae73859 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp @@ -47,12 +47,12 @@ void LCAO_Hamilt::calculate_HR_exx_sparse( for(size_t iw0=0; iw0LM->ParaV->global2local_row[iwt0]; + const int iwt0_local = this->LM->ParaV->global2local_row(iwt0); if(iwt0_local<0) continue; for(size_t iw1=0; iw1LM->ParaV->global2local_col[iwt1]; + const int iwt1_local = this->LM->ParaV->global2local_col(iwt1); if(iwt1_local<0) continue; if(std::abs(Hexx(iw0,iw1)) > sparse_threshold) diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp index 5f1e78bbca7..06dec457862 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.cpp @@ -47,16 +47,17 @@ void LCAO_Matrix::divide_HS_in_frag(const bool isGamma, Parallel_Orbitals &pv, c GlobalC::ld.init(GlobalC::ORB, GlobalC::ucell.nat, GlobalC::ucell.ntype, + pv, na); if(GlobalV::deepks_scf) { if(isGamma) { - GlobalC::ld.allocate_V_delta(GlobalC::ucell.nat, pv.nloc); + GlobalC::ld.allocate_V_delta(GlobalC::ucell.nat); } else { - GlobalC::ld.allocate_V_delta(GlobalC::ucell.nat, pv.nloc, nks); + GlobalC::ld.allocate_V_delta(GlobalC::ucell.nat, nks); } } } @@ -146,8 +147,8 @@ void LCAO_Matrix::set_HSgamma( { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may be < 0 !!! - const int ir = this->ParaV->global2local_row[ iw1_all ]; - const int ic = this->ParaV->global2local_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row(iw1_all); + const int ic = this->ParaV->global2local_col(iw2_all); //const int index = ir * ParaO.ncol + ic; long index=0; @@ -183,8 +184,8 @@ void LCAO_Matrix::set_HSk(const int &iw1_all, const int &iw2_all, const std::com { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may < 0!!!!!!!!!!!!!!!! - const int ir = this->ParaV->global2local_row[ iw1_all ]; - const int ic = this->ParaV->global2local_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row(iw1_all); + const int ic = this->ParaV->global2local_col(iw2_all); //const int index = ir * this->ParaV->ncol + ic; long index; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) @@ -228,8 +229,8 @@ void LCAO_Matrix::set_force { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may < 0!!!!!!!!!!!!!!!! - const int ir = this->ParaV->global2local_row[ iw1_all ]; - const int ic = this->ParaV->global2local_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row(iw1_all); + const int ic = this->ParaV->global2local_col(iw2_all); const long index = ir * this->ParaV->ncol + ic; if( index >= this->ParaV->nloc) @@ -278,8 +279,8 @@ void LCAO_Matrix::set_stress { // use iw1_all and iw2_all to set Hloc // becareful! The ir and ic may < 0!!!!!!!!!!!!!!!! - const int ir = this->ParaV->global2local_row[ iw1_all ]; - const int ic = this->ParaV->global2local_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row(iw1_all); + const int ic = this->ParaV->global2local_col(iw2_all); const long index = ir * this->ParaV->ncol + ic; if( index >= this->ParaV->nloc) @@ -855,8 +856,8 @@ void LCAO_Matrix::destroy_Hloc_fixedR_tr(void) void LCAO_Matrix::set_HR_tr(const int &Rx, const int &Ry, const int &Rz, const int &iw1_all, const int &iw2_all, const double &v) { - const int ir = this->ParaV->global2local_row[ iw1_all ]; - const int ic = this->ParaV->global2local_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row(iw1_all); + const int ic = this->ParaV->global2local_col(iw2_all); //std::cout<<"ir: "< &v) { - const int ir = this->ParaV->global2local_row[ iw1_all ]; - const int ic = this->ParaV->global2local_col[ iw2_all ]; + const int ir = this->ParaV->global2local_row(iw1_all); + const int ic = this->ParaV->global2local_col(iw2_all); //std::cout<<"ir: "<global2local_row[iat]; - const int nu = pv->global2local_col[iat2]; + const int mu = pv->global2local_row(iat); + const int nu = pv->global2local_col(iat2); this->nnrg_index.push_back(gridIntegral::gridIndex{this->nnrg, mu, nu, GlobalC::GridD.getBox(ad), atom1->nw, atom2->nw}); const int nelement = atom1->nw * atom2->nw; @@ -460,12 +460,12 @@ void LCAO_Matrix::folding_fixedH( { \ /* the index of orbitals in this processor */ \ const int iw1_all = start + ii; \ - const int mu = pv->global2local_row[iw1_all]; \ + const int mu = pv->global2local_row(iw1_all); \ if(mu<0) {continue;} \ for(int jj=0; jjnw*GlobalV::NPOL; jj++) \ { \ int iw2_all = start2 + jj; \ - const int nu = pv->global2local_col[iw2_all]; \ + const int nu = pv->global2local_col(iw2_all); \ if(nu<0) {continue;} // DO STH. diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp index a94cd1d0d98..aaa969134b0 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/dm_2d.cpp @@ -72,12 +72,12 @@ void Local_Orbital_Charge::cal_dm_R( for (int iw1 = 0;iw1 < GlobalC::ucell.atoms[T1].nw;++iw1) { int iw1_all = start1 + iw1; - int mu = this->ParaV->global2local_row[iw1_all]; + int mu = this->ParaV->global2local_row(iw1_all); if (mu < 0)continue; for (int iw2 = 0;iw2 < GlobalC::ucell.atoms[T2].nw;++iw2) { int iw2_all = start2 + iw2; - int nu = this->ParaV->global2local_col[iw2_all]; + int nu = this->ParaV->global2local_col(iw2_all); if (nu < 0)continue; //Caution: output of pzgemm_ : col first in **each** proc itself !! dm2d[ispin][irrstart + count] += (dm_k[ik](nu, mu) * phase).real(); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp index e0b9e3cbcba..223de7ceb99 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/deepks_lcao.cpp @@ -26,18 +26,12 @@ void DeePKS>::contributeHR() GlobalC::ld.cal_projected_DM(this->loc->dm_gamma[0], GlobalC::ucell, GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col); + GlobalC::GridD); GlobalC::ld.cal_descriptor(); GlobalC::ld.cal_gedm(GlobalC::ucell.nat); GlobalC::ld.add_v_delta(GlobalC::ucell, GlobalC::ORB, - GlobalC::GridD, - pv->global2local_row, - pv->global2local_col, - pv->nrow, - pv->ncol); + GlobalC::GridD); GlobalC::ld.set_hr_cal(false); @@ -59,20 +53,18 @@ void DeePKS>>::contributeHR() ModuleBase::timer::tick("DeePKS", "contributeHR"); GlobalC::ld.cal_projected_DM_k(this->loc->dm_k, - GlobalC::ucell, - GlobalC::ORB, - GlobalC::GridD, - this->LM->ParaV->global2local_row, - this->LM->ParaV->global2local_col, - this->nks, - this->kvec_d); + GlobalC::ucell, + GlobalC::ORB, + GlobalC::GridD, + this->nks, + this->kvec_d); GlobalC::ld.cal_descriptor(); // calculate dE/dD GlobalC::ld.cal_gedm(GlobalC::ucell.nat); // calculate H_V_deltaR from saved GlobalC::ld - .add_v_delta_k(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, this->LM->ParaV->global2local_row, this->LM->ParaV->global2local_col, this->LM->ParaV->nnr); + .add_v_delta_k(GlobalC::ucell, GlobalC::ORB, GlobalC::GridD, this->LM->ParaV->nnr); GlobalC::ld.set_hr_cal(false); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp index 1bda02e21e6..c648e25fa32 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/record_adj.cpp @@ -128,13 +128,13 @@ void Record_adj::for_2d(Parallel_Orbitals &pv, bool gamma_only) { // the index of orbitals in this processor const int iw1_all = start1 + ii; - const int mu = pv.global2local_row[iw1_all]; + const int mu = pv.global2local_row(iw1_all); if(mu<0)continue; for(int jj=0; jj na) + const Parallel_Orbitals& pv_in, + std::vector na) { ModuleBase::TITLE("LCAO_Deepks", "init"); @@ -113,6 +114,8 @@ void LCAO_Deepks::init( this->init_index(ntype, nat, na, tot_inl, orb); this->allocate_nlm(nat); + this->pv = &pv_in; + return; } @@ -256,7 +259,7 @@ void LCAO_Deepks::del_gdmepsl() } -void LCAO_Deepks::allocate_V_delta(const int nat, const int nloc, const int nks) +void LCAO_Deepks::allocate_V_delta(const int nat, const int nks) { ModuleBase::TITLE("LCAO_Deepks", "allocate_V_delta"); @@ -264,16 +267,16 @@ void LCAO_Deepks::allocate_V_delta(const int nat, const int nloc, const int nks) if(GlobalV::GAMMA_ONLY_LOCAL) { delete[] this->H_V_delta; - this->H_V_delta = new double[nloc]; - ModuleBase::GlobalFunc::ZEROS(this->H_V_delta, nloc); + this->H_V_delta = new double[pv->nloc]; + ModuleBase::GlobalFunc::ZEROS(this->H_V_delta, pv->nloc); } else { H_V_delta_k = new std::complex* [nks]; for(int ik=0;ikH_V_delta_k[ik] = new std::complex[nloc]; - ModuleBase::GlobalFunc::ZEROS(this->H_V_delta_k[ik], nloc); + this->H_V_delta_k[ik] = new std::complex[pv->nloc]; + ModuleBase::GlobalFunc::ZEROS(this->H_V_delta_k[ik], pv->nloc); } } diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks.h b/source/module_hamilt_lcao/module_deepks/LCAO_deepks.h index 74a4f296948..60eaf956115 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks.h +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks.h @@ -189,10 +189,11 @@ class LCAO_Deepks void init(const LCAO_Orbitals &orb, const int nat, const int ntype, + const Parallel_Orbitals& pv_in, std::vector na); ///Allocate memory for correction to Hamiltonian - void allocate_V_delta(const int nat,const int nloc, const int nks=1); + void allocate_V_delta(const int nat, const int nks = 1); void allocate_V_deltaR(const int nnr); // array for storing gdmx, used for calculating gvx @@ -236,17 +237,13 @@ class LCAO_Deepks void build_psialpha(const bool& cal_deri/**< [in] 0 for 2-center intergration, 1 for its derivation*/, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const ORB_gen_tables &UOT); void check_psialpha(const bool& cal_deri/**< [in] 0 for 2-center intergration, 1 for its derivation*/, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const ORB_gen_tables &UOT); //------------------- @@ -277,15 +274,11 @@ class LCAO_Deepks void cal_projected_DM(const ModuleBase::matrix& dm/**< [in] density matrix*/, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col); + Grid_Driver& GridD); void cal_projected_DM_k(const std::vector& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const int nks, const std::vector> &kvec_d); void check_projected_dm(void); @@ -295,16 +288,12 @@ class LCAO_Deepks void cal_gdmx(const ModuleBase::matrix& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const bool isstress); void cal_gdmx_k(const std::vector& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const int nks, const std::vector> &kvec_d, const bool isstress); @@ -333,32 +322,19 @@ class LCAO_Deepks ///add dV to the Hamiltonian matrix void add_v_delta(const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, - const int nrow, - const int ncol); + Grid_Driver& GridD); void add_v_delta_k(const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const int nnr_in); - - void check_v_delta(const int nrow, const int ncol); + + void check_v_delta(); void check_v_delta_k(const int nnr); ///calculate tr(\rho V_delta) - void cal_e_delta_band(const std::vector& dm/**<[in] density matrix*/, - const int* global2local_row, - const int* global2local_col, - const int nrow); + void cal_e_delta_band(const std::vector& dm/**<[in] density matrix*/); void cal_e_delta_band_k(const std::vector& dm/**<[in] density matrix*/, - const int* global2local_row, - const int* global2local_col, - const int nks, - const int nrow, - const int ncol); + const int nks); //------------------- // LCAO_deepks_fdelta.cpp @@ -378,18 +354,14 @@ class LCAO_Deepks void cal_f_delta_gamma(const ModuleBase::matrix& dm/**< [in] density matrix*/, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const bool isstress, ModuleBase::matrix& svnl_dalpha); //for multi-k, pulay and HF terms of force are calculated together void cal_f_delta_k(const std::vector& dm/**<[in] density matrix*/, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const int nks, const std::vector> &kvec_d, const bool isstress, ModuleBase::matrix& svnl_dalpha); @@ -409,10 +381,8 @@ class LCAO_Deepks public: - void cal_o_delta(const std::vector>& dm_hl/**<[in] modified density matrix that contains HOMO and LUMO only*/, - const Parallel_Orbitals &ParaO); + void cal_o_delta(const std::vector>& dm_hl/**<[in] modified density matrix that contains HOMO and LUMO only*/); void cal_o_delta_k(const std::vector>& dm_hl/**<[in] modified density matrix that contains HOMO and LUMO only*/, - const Parallel_Orbitals &ParaO, const int nks); //------------------- @@ -484,8 +454,7 @@ class LCAO_Deepks const int nat, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const Parallel_Orbitals &ParaO); + Grid_Driver& GridD); //calculates orbital_precalc for multi-k case void cal_orbital_precalc_k(const std::vector>& dm_hl/**<[in] density matrix*/, @@ -494,11 +463,11 @@ class LCAO_Deepks const std::vector> &kvec_d, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const Parallel_Orbitals &ParaO); + Grid_Driver& GridD); private: + const Parallel_Orbitals* pv; void cal_gvdm(const int nat); //------------------- diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp index 87c28837874..10698126166 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_fdelta.cpp @@ -37,9 +37,7 @@ void stress_fill( void LCAO_Deepks::cal_f_delta_gamma(const ModuleBase::matrix& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const bool isstress, ModuleBase::matrix& svnl_dalpha) { ModuleBase::TITLE("LCAO_Deepks", "cal_f_delta_gamma"); @@ -100,13 +98,13 @@ void LCAO_Deepks::cal_f_delta_gamma(const ModuleBase::matrix& dm, for (int iw1=0; iw1global2local_col(iw1_all); if(iw1_local < 0)continue; for (int iw2=0; iw2global2local_row(iw2_all); if(iw2_local < 0)continue; double nlm[3]={0,0,0}; @@ -215,9 +213,7 @@ void LCAO_Deepks::cal_f_delta_gamma(const ModuleBase::matrix& dm, void LCAO_Deepks::cal_f_delta_k(const std::vector& dm/**<[in] density matrix*/, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const int nks, const std::vector> &kvec_d, const bool isstress, ModuleBase::matrix& svnl_dalpha) @@ -287,13 +283,13 @@ void LCAO_Deepks::cal_f_delta_k(const std::vector& dm for (int iw1=0; iw1global2local_col(iw1_all); if(iw1_local < 0)continue; for (int iw2=0; iw2global2local_row(iw2_all); if(iw2_local < 0)continue; double dm_current; std::complex tmp = 0.0; diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp index 46a279e36a6..666326525df 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp @@ -73,10 +73,10 @@ void LCAO_Deepks_Interface::out_deepks_labels(double etot, } } - ld->cal_orbital_precalc(dm_bandgap_gamma, nat, ucell, orb, GridD, *ParaV); + ld->cal_orbital_precalc(dm_bandgap_gamma, nat, ucell, orb, GridD); ld->save_npy_orbital_precalc(nat, nks); - ld->cal_o_delta(dm_bandgap_gamma, *ParaV); + ld->cal_o_delta(dm_bandgap_gamma); ld->save_npy_o(deepks_bands - ld->o_delta, "o_base.npy", nks); } // end deepks_scf gamma-only; else // multi-k bandgap label @@ -98,9 +98,9 @@ void LCAO_Deepks_Interface::out_deepks_labels(double etot, } // ld->cal_o_delta_k(dm_bandgap_k, ParaV, nks); - ld->cal_orbital_precalc_k(dm_bandgap_k, nat, nks, kvec_d, ucell, orb, GridD, *ParaV); + ld->cal_orbital_precalc_k(dm_bandgap_k, nat, nks, kvec_d, ucell, orb, GridD); ld->save_npy_orbital_precalc(nat, nks); - ld->cal_o_delta_k(dm_bandgap_k, *ParaV, nks); + ld->cal_o_delta_k(dm_bandgap_k, nks); ld->save_npy_o(deepks_bands - ld->o_delta, "o_base.npy", nks); } // end deepks_scf multi-k } // end deepks_scf == 1 @@ -118,11 +118,11 @@ void LCAO_Deepks_Interface::out_deepks_labels(double etot, // so it is printed no matter even if deepks_out_labels is not used if (GlobalV::GAMMA_ONLY_LOCAL) { - ld->cal_projected_DM(dm_gamma[0], ucell, orb, GridD, ParaV->global2local_row, ParaV->global2local_col); + ld->cal_projected_DM(dm_gamma[0], ucell, orb, GridD); } else { - ld->cal_projected_DM_k(dm_k, ucell, orb, GridD, ParaV->global2local_row, ParaV->global2local_col, nks, kvec_d); + ld->cal_projected_DM_k(dm_k, ucell, orb, GridD, nks, kvec_d); } ld->check_projected_dm(); // print out the projected dm for NSCF calculaiton ld->cal_descriptor(); // final descriptor @@ -136,11 +136,11 @@ void LCAO_Deepks_Interface::out_deepks_labels(double etot, { if (GlobalV::GAMMA_ONLY_LOCAL) { - ld->cal_e_delta_band(dm_gamma, ParaV->global2local_row, ParaV->global2local_col, ParaV->nrow); + ld->cal_e_delta_band(dm_gamma); } else { - ld->cal_e_delta_band_k(dm_k, ParaV->global2local_row, ParaV->global2local_col, nks, ParaV->nrow, ParaV->ncol); + ld->cal_e_delta_band_k(dm_k, nks); } std::cout << "E_delta_band = " << std::setprecision(8) << ld->e_delta_band << " Ry" << " = " << std::setprecision(8) << ld->e_delta_band * ModuleBase::Ry_to_eV << " eV" diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp index ea986a95adc..b5498a09cc5 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_odelta.cpp @@ -12,7 +12,7 @@ #include "LCAO_deepks.h" #include "module_base/parallel_reduce.h" -void LCAO_Deepks::cal_o_delta(const std::vector> &dm_hl, const Parallel_Orbitals &ParaO) +void LCAO_Deepks::cal_o_delta(const std::vector>& dm_hl) { ModuleBase::TITLE("LCAO_Deepks", "cal_o_delta"); this->o_delta.zero_out(); @@ -22,12 +22,12 @@ void LCAO_Deepks::cal_o_delta(const std::vector> { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - const int mu = ParaO.global2local_row[j]; - const int nu = ParaO.global2local_col[i]; + const int mu = pv->global2local_row(j); + const int nu = pv->global2local_col(i); if (mu >= 0 && nu >= 0) { - const int index = nu*ParaO.nrow + mu; + const int index = nu * pv->nrow + mu; for (int is = 0; is < GlobalV::NSPIN; ++is) { this->o_delta(0,hl) += dm_hl[hl][is](nu, mu) * this->H_V_delta[index]; @@ -43,8 +43,7 @@ void LCAO_Deepks::cal_o_delta(const std::vector> //calculating the correction of (LUMO-HOMO) energies, i.e., band gap corrections //for multi_k calculations -void LCAO_Deepks::cal_o_delta_k(const std::vector> &dm_hl, - const Parallel_Orbitals &ParaO, +void LCAO_Deepks::cal_o_delta_k(const std::vector>& dm_hl, const int nks) { ModuleBase::TITLE("LCAO_Deepks", "cal_o_delta_k"); @@ -58,19 +57,19 @@ void LCAO_Deepks::cal_o_delta_k(const std::vectorglobal2local_row(j); + const int nu = pv->global2local_col(i); if (mu >= 0 && nu >= 0) { int iic; if(GlobalV::KS_SOLVER=="genelpa" || GlobalV::KS_SOLVER=="scalapack_gvx") // save the matrix as column major format { - iic = mu + nu*ParaO.nrow; + iic = mu + nu * pv->nrow; } else { - iic = mu*ParaO.ncol + nu; + iic = mu * pv->ncol + nu; } o_delta_k += dm_hl[hl][ik](nu, mu) * this->H_V_delta_k[ik][iic]; } diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp index 989ca87bfb1..2c2908e9d80 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_pdm.cpp @@ -28,9 +28,7 @@ void LCAO_Deepks::cal_projected_DM(const ModuleBase::matrix &dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col) + Grid_Driver& GridD) { ModuleBase::TITLE("LCAO_Deepks", "cal_projected_DM"); ModuleBase::timer::tick("LCAO_Deepks","cal_projected_DM"); @@ -109,14 +107,14 @@ void LCAO_Deepks::cal_projected_DM(const ModuleBase::matrix &dm, for (int iw1=0; iw1global2local_col(iw1_all); if(iw1_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; for (int iw2=0; iw2global2local_row(iw2_all); if(iw2_local < 0)continue; const int iw2_0 = iw2/GlobalV::NPOL; @@ -160,9 +158,7 @@ void LCAO_Deepks::cal_projected_DM(const ModuleBase::matrix &dm, void LCAO_Deepks::cal_projected_DM_k(const std::vector& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const int nks, const std::vector> &kvec_d) { @@ -249,13 +245,13 @@ void LCAO_Deepks::cal_projected_DM_k(const std::vectorglobal2local_col(iw1_all); if(iw1_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; for (int iw2=0; iw2global2local_row(iw2_all); if(iw2_local < 0)continue; const int iw2_0 = iw2/GlobalV::NPOL; @@ -333,9 +329,7 @@ void LCAO_Deepks::check_projected_dm(void) void LCAO_Deepks::cal_gdmx(const ModuleBase::matrix &dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const bool isstress) { ModuleBase::TITLE("LCAO_Deepks", "cal_gdmx"); @@ -422,13 +416,13 @@ void LCAO_Deepks::cal_gdmx(const ModuleBase::matrix &dm, for (int iw1=0; iw1global2local_col(iw1_all); if(iw1_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; for (int iw2=0; iw2global2local_row(iw2_all); if(iw2_local < 0)continue; const int iw2_0 = iw2/GlobalV::NPOL; @@ -547,9 +541,7 @@ void LCAO_Deepks::cal_gdmx(const ModuleBase::matrix &dm, void LCAO_Deepks::cal_gdmx_k(const std::vector& dm, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const int nks, const std::vector> &kvec_d, const bool isstress) @@ -642,13 +634,13 @@ void LCAO_Deepks::cal_gdmx_k(const std::vector& dm, for (int iw1=0; iw1global2local_col(iw1_all); if(iw1_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; for (int iw2=0; iw2global2local_row(iw2_all); if(iw2_local < 0)continue; const int iw2_0 = iw2/GlobalV::NPOL; diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_psialpha.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_psialpha.cpp index 35361bed40c..053129cf23a 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_psialpha.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_psialpha.cpp @@ -15,9 +15,7 @@ void LCAO_Deepks::build_psialpha(const bool& calc_deri, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const ORB_gen_tables &UOT) { ModuleBase::TITLE("LCAO_Deepks", "build_psialpha"); @@ -83,8 +81,8 @@ void LCAO_Deepks::build_psialpha(const bool& calc_deri, for (int iw1=0; iw1global2local_row(iw1_all); + const int iw2_local = pv->global2local_col(iw1_all); if(iw1_local < 0 && iw2_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; std::vector> nlm; @@ -131,9 +129,7 @@ void LCAO_Deepks::build_psialpha(const bool& calc_deri, void LCAO_Deepks::check_psialpha(const bool& calc_deri, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const int* global2local_row, - const int* global2local_col, + Grid_Driver& GridD, const ORB_gen_tables &UOT) { ModuleBase::TITLE("LCAO_Deepks", "check_psialpha"); @@ -226,8 +222,8 @@ void LCAO_Deepks::check_psialpha(const bool& calc_deri, ofs_x << "iw : " << iw1_all << std::endl; ofs_y << "iw : " << iw1_all << std::endl; ofs_z << "iw : " << iw1_all << std::endl; - const int iw1_local = global2local_row[iw1_all]; - const int iw2_local = global2local_col[iw1_all]; + const int iw1_local = pv->global2local_row(iw1_all); + const int iw2_local = pv->global2local_col(iw1_all); if(iw1_local < 0 && iw2_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; diff --git a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp index 87003b8781a..3adddab38b2 100644 --- a/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp +++ b/source/module_hamilt_lcao/module_deepks/LCAO_deepks_torch.cpp @@ -417,8 +417,7 @@ void LCAO_Deepks::cal_orbital_precalc(const std::vectorglobal2local_row(iw1_all); if(iw1_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; for (int iw2=0; iw2global2local_col(iw2_all); if(iw2_local < 0)continue; const int iw2_0 = iw2/GlobalV::NPOL; @@ -588,8 +587,7 @@ void LCAO_Deepks::cal_orbital_precalc_k(const std::vector> &kvec_d, const UnitCell &ucell, const LCAO_Orbitals &orb, - Grid_Driver &GridD, - const Parallel_Orbitals &ParaO) + Grid_Driver& GridD) { ModuleBase::TITLE("LCAO_Deepks", "calc_orbital_precalc_k"); @@ -644,13 +642,13 @@ void LCAO_Deepks::cal_orbital_precalc_k(const std::vectorglobal2local_col(iw1_all); if(iw1_local < 0)continue; for (int iw2=0; iw2global2local_row(iw2_all); if(iw2_local < 0)continue; for(int ik=0;ikH_V_delta,nrow*ncol); //init before calculate + ModuleBase::GlobalFunc::ZEROS(this->H_V_delta, pv->nrow * pv->ncol); //init before calculate const double Rcut_Alpha = orb.Alpha[0].getRcut(); @@ -76,13 +72,13 @@ void LCAO_Deepks::add_v_delta(const UnitCell &ucell, for (int iw1=0; iw1global2local_row(iw1_all); if(iw1_local < 0)continue; const int iw1_0 = iw1/GlobalV::NPOL; for (int iw2=0; iw2global2local_col(iw2_all); if(iw2_local < 0)continue; const int iw2_0 = iw2/GlobalV::NPOL; @@ -115,11 +111,11 @@ void LCAO_Deepks::add_v_delta(const UnitCell &ucell, if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { - iic=iw1_local+iw2_local*nrow; + iic = iw1_local + iw2_local * pv->nrow; } else { - iic=iw1_local*ncol+iw2_local; + iic = iw1_local * pv->ncol + iw2_local; } this->H_V_delta[iic] += nlm; }//iw2 @@ -133,22 +129,22 @@ void LCAO_Deepks::add_v_delta(const UnitCell &ucell, return; } -void LCAO_Deepks::check_v_delta(const int nrow, const int ncol) +void LCAO_Deepks::check_v_delta() { std::ofstream ofs("H_V_delta.dat"); ofs << std::setprecision(10); - for(int irow=0;irownrow;irow++) { - for (int icol=0;icolncol;icol++) { int iic; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { - iic=irow+icol*nrow; + iic = irow + icol * pv->nrow; } else { - iic=irow*ncol+icol; + iic = irow * pv->ncol + icol; } ofs<nw*GlobalV::NPOL; iw1++) { const int iw1_all = start1 + iw1; - const int mu = global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -298,7 +292,7 @@ void LCAO_Deepks::add_v_delta_k(const UnitCell &ucell, for (int iw2=0; iw2nw*GlobalV::NPOL; iw2++) { const int iw2_all = start2 + iw2; - const int nu = global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if(nu < 0)continue; std::vector nlm1 = this->nlm_save_k[iat][key_1][iw1_all][0]; @@ -336,7 +330,7 @@ void LCAO_Deepks::add_v_delta_k(const UnitCell &ucell, { const int j0 = j/GlobalV::NPOL;//added by zhengdy-soc const int iw1_all = start1 + j; - const int mu = global2local_row[iw1_all]; + const int mu = pv->global2local_row(iw1_all); if(mu < 0)continue; // fix a serious bug: atom2[T2] -> atom2 @@ -345,7 +339,7 @@ void LCAO_Deepks::add_v_delta_k(const UnitCell &ucell, { const int k0 = k/GlobalV::NPOL; const int iw2_all = start2 + k; - const int nu = global2local_col[iw2_all]; + const int nu = pv->global2local_col(iw2_all); if(nu < 0)continue; nnr++; @@ -378,10 +372,7 @@ void LCAO_Deepks::check_v_delta_k(const int nnr) //calculating sum of correction band energies //for gamma_only calculations -void LCAO_Deepks::cal_e_delta_band(const std::vector &dm, - const int* global2local_row, - const int* global2local_col, - const int nrow) +void LCAO_Deepks::cal_e_delta_band(const std::vector& dm) { ModuleBase::TITLE("LCAO_Deepks", "cal_e_delta_band"); this->e_delta_band = 0; @@ -389,12 +380,12 @@ void LCAO_Deepks::cal_e_delta_band(const std::vector &dm, { for (int j = 0; j < GlobalV::NLOCAL; ++j) { - const int mu = global2local_row[j]; - const int nu = global2local_col[i]; + const int mu = pv->global2local_row(j); + const int nu = pv->global2local_col(i); if (mu >= 0 && nu >= 0) { - const int index=nu*nrow+mu; + const int index = nu * pv->nrow + mu; for (int is = 0; is < dm.size(); ++is) //dm.size() == GlobalV::NSPIN { this->e_delta_band += dm[is](nu, mu) * this->H_V_delta[index]; @@ -410,12 +401,8 @@ void LCAO_Deepks::cal_e_delta_band(const std::vector &dm, //calculating sum of correction band energies //for multi_k calculations -void LCAO_Deepks::cal_e_delta_band_k(const std::vector &dm, - const int* global2local_row, - const int* global2local_col, - const int nks, - const int nrow, - const int ncol) +void LCAO_Deepks::cal_e_delta_band_k(const std::vector& dm, + const int nks) { ModuleBase::TITLE("LCAO_Deepks", "cal_e_delta_band"); std::complex e_delta_band_k=std::complex(0.0,0.0); @@ -423,19 +410,19 @@ void LCAO_Deepks::cal_e_delta_band_k(const std::vectorglobal2local_row(j); + const int nu = pv->global2local_col(i); if (mu >= 0 && nu >= 0) { int iic; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER()) { - iic=mu+nu*nrow; + iic = mu + nu * pv->nrow; } else { - iic=mu*ncol+nu; + iic = mu * pv->ncol + nu; } for(int ik=0;ikcompare_with_ref("psialpha.dat","psialpha_ref.dat"); this->compare_with_ref("dpsialpha_x.dat","dpsialpha_x_ref.dat"); @@ -100,9 +97,7 @@ void test_deepks::check_pdm(void) this->ld.cal_projected_DM(dm[0], ucell, ORB, - Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col); + Test_Deepks::GridD); } else { @@ -110,9 +105,7 @@ void test_deepks::check_pdm(void) this->ld.cal_projected_DM_k(dm_k, ucell, ORB, - Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col, + Test_Deepks::GridD, kv.nkstot, kv.kvec_d); } @@ -128,9 +121,7 @@ void test_deepks::check_gdmx(void) this->ld.cal_gdmx(dm[0], ucell, ORB, - Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col, + Test_Deepks::GridD, 0); } else @@ -138,9 +129,7 @@ void test_deepks::check_gdmx(void) this->ld.cal_gdmx_k(dm_k, ucell, ORB, - Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col, + Test_Deepks::GridD, kv.nkstot, kv.kvec_d, 0); @@ -213,11 +202,11 @@ void test_deepks::check_edelta(void) this->ld.load_model("model.ptg"); if(GlobalV::GAMMA_ONLY_LOCAL) { - this->ld.allocate_V_delta(ucell.nat,ParaO.nloc); + this->ld.allocate_V_delta(ucell.nat); } else { - this->ld.allocate_V_delta(ucell.nat,ParaO.nloc,kv.nkstot); + this->ld.allocate_V_delta(ucell.nat, kv.nkstot); } this->ld.cal_gedm(ucell.nat); @@ -234,20 +223,12 @@ void test_deepks::check_e_deltabands(void) { if(GlobalV::GAMMA_ONLY_LOCAL) { - this->ld.cal_e_delta_band(dm, - ParaO.global2local_row, - ParaO.global2local_col, - ParaO.nrow); + this->ld.cal_e_delta_band(dm); } else { this->folding_nnr(kv); - this->ld.cal_e_delta_band_k(dm_k, - ParaO.global2local_row, - ParaO.global2local_col, - kv.nkstot, - ParaO.nrow, - ParaO.ncol); + this->ld.cal_e_delta_band_k(dm_k, kv.nkstot); } std::ofstream ofs("E_delta_bands.dat"); @@ -262,12 +243,8 @@ void test_deepks::check_v_delta() { this->ld.add_v_delta(ucell, ORB, - Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col, - ParaO.nrow, - ParaO.ncol); - this->ld.check_v_delta(ParaO.nrow,ParaO.ncol); + Test_Deepks::GridD); + this->ld.check_v_delta(); this->compare_with_ref("H_V_delta.dat","H_V_delta_ref.dat"); } else @@ -277,8 +254,6 @@ void test_deepks::check_v_delta() this->ld.add_v_delta_k(ucell, ORB, Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col, nnr); this->ld.check_v_delta_k(nnr); this->compare_with_ref("H_V_deltaR.dat","H_V_deltaR_ref.dat"); @@ -295,8 +270,6 @@ void test_deepks::check_f_delta() ucell, ORB, Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col, 1, svnl_dalpha); } else @@ -305,8 +278,6 @@ void test_deepks::check_f_delta() ucell, ORB, Test_Deepks::GridD, - ParaO.global2local_row, - ParaO.global2local_col, kv.nkstot, kv.kvec_d, 1,svnl_dalpha); diff --git a/source/module_hamilt_lcao/module_deepks/test/nnr.cpp b/source/module_hamilt_lcao/module_deepks/test/nnr.cpp index d783b34971d..959fab34edd 100644 --- a/source/module_hamilt_lcao/module_deepks/test/nnr.cpp +++ b/source/module_hamilt_lcao/module_deepks/test/nnr.cpp @@ -50,13 +50,13 @@ void test_deepks::cal_nnr(void) // the index of orbitals in this processor // according to HPSEPS's division method. const int iw1_all = start1 + ii; - const int mu = ParaO.global2local_row[iw1_all]; + const int mu = ParaO.global2local_row(iw1_all); if(mu<0)continue; for(int jj=0; jjnw*GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = ParaO.global2local_col[iw2_all]; + const int nu = ParaO.global2local_col(iw2_all); if(nu<0)continue; int iic; diff --git a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp b/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp index 1475747560e..323afd5dfba 100644 --- a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp +++ b/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp @@ -31,8 +31,8 @@ namespace Test_Deepks // mohan update 2011-04-07 for(int i=0; inrow = GlobalV::NLOCAL; this->ncol = GlobalV::NLOCAL; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp b/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp index abb0a40b311..bf32c439403 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_folding.cpp @@ -70,14 +70,14 @@ void DFTU::fold_dSR_gamma(const int dim1, const int dim2, double* dSR_gamma) { const int jj0 = jj / GlobalV::NPOL; const int iw1_all = start1 + jj0; - const int mu = this->LM->ParaV->global2local_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row(iw1_all); if (mu < 0) continue; for (int kk = 0; kk < atom2->nw * GlobalV::NPOL; ++kk) { const int kk0 = kk / GlobalV::NPOL; const int iw2_all = start2 + kk0; - const int nu = this->LM->ParaV->global2local_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col(iw2_all); if (nu < 0) continue; dSR_gamma[nu * this->LM->ParaV->nrow + mu] += dS_ptr[nnr] * this->LM->DH_r[nnr * 3 + dim2]; @@ -188,13 +188,13 @@ void DFTU::folding_matrix_k(const int ik, const int dim1, const int dim2, std::c { // the index of orbitals in this processor const int iw1_all = start1 + ii; - const int mu = this->LM->ParaV->global2local_row[iw1_all]; + const int mu = this->LM->ParaV->global2local_row(iw1_all); if (mu < 0) continue; for (int jj = 0; jj < atom2->nw * GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = this->LM->ParaV->global2local_col[iw2_all]; + const int nu = this->LM->ParaV->global2local_col(iw2_all); if (nu < 0) continue; int iic; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_force.cpp b/source/module_hamilt_lcao/module_dftu/dftu_force.cpp index ebfbdf1ca23..539f8a80ccf 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_force.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_force.cpp @@ -203,12 +203,12 @@ void DFTU::cal_force_k(const int ik, for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->local2global_row[ir]; + const int iwt1 = this->LM->ParaV->local2global_row(ir); const int iat1 = GlobalC::ucell.iwt2iat[iwt1]; for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->local2global_col[ic]; + const int iwt2 = this->LM->ParaV->local2global_col(ic); const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) force_dftu(iat1, dim) += dm_VU_dSm[irc].real(); @@ -250,8 +250,8 @@ void DFTU::cal_force_k(const int ik, for (int ipol = 0; ipol < GlobalV::NPOL; ipol++) { const int iwt = this->iatlnmipol2iwt[iat][l][n][m][ipol]; - const int mu = this->LM->ParaV->global2local_row[iwt]; - const int nu = this->LM->ParaV->global2local_col[iwt]; + const int mu = this->LM->ParaV->global2local_row(iwt); + const int nu = this->LM->ParaV->global2local_col(iwt); if (mu < 0 || nu < 0) continue; force_dftu(iat, dim) += dm_VU_dSm[nu * this->LM->ParaV->nrow + mu].real(); @@ -299,10 +299,10 @@ void DFTU::cal_stress_k(const int ik, for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->local2global_row[ir]; + const int iwt1 = this->LM->ParaV->local2global_row(ir); for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->local2global_col[ic]; + const int iwt2 = this->LM->ParaV->local2global_col(ic); const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) stress_dftu(dim1, dim2) += 2.0 * dm_VU_sover[irc].real(); @@ -345,12 +345,12 @@ void DFTU::cal_force_gamma(const double* rho_VU, ModuleBase::matrix& force_dftu) for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->local2global_row[ir]; + const int iwt1 = this->LM->ParaV->local2global_row(ir); const int iat1 = GlobalC::ucell.iwt2iat[iwt1]; for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->local2global_col[ic]; + const int iwt2 = this->LM->ParaV->local2global_col(ic); const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) force_dftu(iat1, dim) += dm_VU_dSm[irc]; @@ -394,8 +394,8 @@ void DFTU::cal_force_gamma(const double* rho_VU, ModuleBase::matrix& force_dftu) for (int ipol = 0; ipol < GlobalV::NPOL; ipol++) { const int iwt = this->iatlnmipol2iwt[iat][l][n][m][ipol]; - const int mu = this->LM->ParaV->global2local_row[iwt]; - const int nu = this->LM->ParaV->global2local_col[iwt]; + const int mu = this->LM->ParaV->global2local_row(iwt); + const int nu = this->LM->ParaV->global2local_col(iwt); if (mu < 0 || nu < 0) continue; force_dftu(iat, dim) += dm_VU_dSm[nu * this->LM->ParaV->nrow + mu]; @@ -441,11 +441,11 @@ void DFTU::cal_stress_gamma(const double* rho_VU, ModuleBase::matrix& stress_dft for (int ir = 0; ir < this->LM->ParaV->nrow; ir++) { - const int iwt1 = this->LM->ParaV->local2global_row[ir]; + const int iwt1 = this->LM->ParaV->local2global_row(ir); for (int ic = 0; ic < this->LM->ParaV->ncol; ic++) { - const int iwt2 = this->LM->ParaV->local2global_col[ic]; + const int iwt2 = this->LM->ParaV->local2global_col(ic); const int irc = ic * this->LM->ParaV->nrow + ir; if (iwt1 == iwt2) stress_dftu(dim1, dim2) += 2.0 * dm_VU_sover[irc]; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp b/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp index 7e92e94b17d..57f4ac9c193 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_occup.cpp @@ -215,16 +215,16 @@ void DFTU::cal_occup_m_k(const int iter, for (int ipol0 = 0; ipol0 < GlobalV::NPOL; ipol0++) { const int iwt0 = this->iatlnmipol2iwt[iat][l][n][m0][ipol0]; - const int mu = this->LM->ParaV->global2local_row[iwt0]; - const int mu_prime = this->LM->ParaV->global2local_col[iwt0]; + const int mu = this->LM->ParaV->global2local_row(iwt0); + const int mu_prime = this->LM->ParaV->global2local_col(iwt0); for (int m1 = 0; m1 < 2 * l + 1; m1++) { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { const int iwt1 = this->iatlnmipol2iwt[iat][l][n][m1][ipol1]; - const int nu = this->LM->ParaV->global2local_col[iwt1]; - const int nu_prime = this->LM->ParaV->global2local_row[iwt1]; + const int nu = this->LM->ParaV->global2local_col(iwt1); + const int nu_prime = this->LM->ParaV->global2local_row(iwt1); const int irc = nu * this->LM->ParaV->nrow + mu; const int irc_prime = mu_prime * this->LM->ParaV->nrow + nu_prime; @@ -409,16 +409,16 @@ void DFTU::cal_occup_m_gamma(const int iter, std::vector &dm for (int ipol0 = 0; ipol0 < GlobalV::NPOL; ipol0++) { const int iwt0 = this->iatlnmipol2iwt[iat][l][n][m0][ipol0]; - const int mu = this->LM->ParaV->global2local_row[iwt0]; - const int mu_prime = this->LM->ParaV->global2local_col[iwt0]; + const int mu = this->LM->ParaV->global2local_row(iwt0); + const int mu_prime = this->LM->ParaV->global2local_col(iwt0); for (int m1 = 0; m1 < 2 * l + 1; m1++) { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { const int iwt1 = this->iatlnmipol2iwt[iat][l][n][m1][ipol1]; - const int nu = this->LM->ParaV->global2local_col[iwt1]; - const int nu_prime = this->LM->ParaV->global2local_row[iwt1]; + const int nu = this->LM->ParaV->global2local_col(iwt1); + const int nu_prime = this->LM->ParaV->global2local_row(iwt1); const int irc = nu * this->LM->ParaV->nrow + mu; const int irc_prime = mu_prime * this->LM->ParaV->nrow + nu_prime; diff --git a/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp b/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp index 98cbf1f7b3f..c48cfd925b2 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_tools.cpp @@ -31,7 +31,7 @@ void DFTU::cal_VU_pot_mat_complex(const int spin, const bool newlocale, std::com { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { - const int mu = this->LM->ParaV->global2local_row[this->iatlnmipol2iwt[iat][L][n][m1][ipol1]]; + const int mu = this->LM->ParaV->global2local_row(this->iatlnmipol2iwt[iat][L][n][m1][ipol1]); if (mu < 0) continue; @@ -40,7 +40,7 @@ void DFTU::cal_VU_pot_mat_complex(const int spin, const bool newlocale, std::com for (int ipol2 = 0; ipol2 < GlobalV::NPOL; ipol2++) { const int nu - = this->LM->ParaV->global2local_col[this->iatlnmipol2iwt[iat][L][n][m2][ipol2]]; + = this->LM->ParaV->global2local_col(this->iatlnmipol2iwt[iat][L][n][m2][ipol2]); if (nu < 0) continue; @@ -87,7 +87,7 @@ void DFTU::cal_VU_pot_mat_real(const int spin, const bool newlocale, double* VU) { for (int ipol1 = 0; ipol1 < GlobalV::NPOL; ipol1++) { - const int mu = this->LM->ParaV->global2local_row[this->iatlnmipol2iwt[iat][L][n][m1][ipol1]]; + const int mu = this->LM->ParaV->global2local_row(this->iatlnmipol2iwt[iat][L][n][m1][ipol1]); if (mu < 0) continue; for (int m2 = 0; m2 < 2 * L + 1; m2++) @@ -95,7 +95,7 @@ void DFTU::cal_VU_pot_mat_real(const int spin, const bool newlocale, double* VU) for (int ipol2 = 0; ipol2 < GlobalV::NPOL; ipol2++) { const int nu - = this->LM->ParaV->global2local_col[this->iatlnmipol2iwt[iat][L][n][m2][ipol2]]; + = this->LM->ParaV->global2local_col(this->iatlnmipol2iwt[iat][L][n][m2][ipol2]); if (nu < 0) continue; diff --git a/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp b/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp index d1e64178297..e95137fd3e6 100644 --- a/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_k_sparse.cpp @@ -110,11 +110,11 @@ void Gint_k::distribute_pvpR_sparseMatrix( Parallel_Reduce::reduce_double_pool(tmp, GlobalV::NLOCAL); - if (LM->ParaV->global2local_row[row] >= 0) + if (LM->ParaV->global2local_row(row) >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->global2local_col[col] >= 0) + if(LM->ParaV->global2local_col(col) >= 0) { if (std::abs(tmp[col]) > sparse_threshold) { @@ -244,11 +244,11 @@ void Gint_k::distribute_pvpR_soc_sparseMatrix( Parallel_Reduce::reduce_complex_double_pool(tmp_soc, GlobalV::NLOCAL); - if (LM->ParaV->global2local_row[row] >= 0) + if (LM->ParaV->global2local_row(row) >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->global2local_col[col] >= 0) + if(LM->ParaV->global2local_col(col) >= 0) { if (std::abs(tmp_soc[col]) > sparse_threshold) { diff --git a/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp b/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp index 4f396e73a38..32e20fb2064 100644 --- a/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp @@ -110,11 +110,11 @@ void Gint_k::distribute_pvdpR_sparseMatrix( Parallel_Reduce::reduce_double_pool(tmp, GlobalV::NLOCAL); - if (LM->ParaV->global2local_row[row] >= 0) + if (LM->ParaV->global2local_row(row) >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->global2local_col[col] >= 0) + if(LM->ParaV->global2local_col(col) >= 0) { if (std::abs(tmp[col]) > sparse_threshold) { @@ -266,11 +266,11 @@ void Gint_k::distribute_pvdpR_soc_sparseMatrix( Parallel_Reduce::reduce_complex_double_pool(tmp_soc, GlobalV::NLOCAL); - if (LM->ParaV->global2local_row[row] >= 0) + if (LM->ParaV->global2local_row(row) >= 0) { for(int col = 0; col < GlobalV::NLOCAL; ++col) { - if(LM->ParaV->global2local_col[col] >= 0) + if(LM->ParaV->global2local_col(col) >= 0) { if (std::abs(tmp_soc[col]) > sparse_threshold) { diff --git a/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp b/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp index fe31db76039..ab9f3989db6 100644 --- a/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/atom_pair.cpp @@ -525,8 +525,8 @@ void AtomPair::add_to_array(std::complex* array, const std::complex& kp template T& AtomPair::get_matrix_value(const size_t& i_row_global, const size_t& j_col_global) const { - int i_row_local = this->paraV == nullptr? i_row_global : this->paraV->global2local_row[i_row_global]; - int j_col_local = this->paraV == nullptr? j_col_global : this->paraV->global2local_col[j_col_global]; + int i_row_local = this->paraV == nullptr ? i_row_global : this->paraV->global2local_row(i_row_global); + int j_col_local = this->paraV == nullptr ? j_col_global : this->paraV->global2local_col(j_col_global); #ifdef __DEBUG assert(i_row_local != -1 && j_col_local != -1); assert(current_R < this->values.size()); diff --git a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp index 9c753a4ae5f..8c22d833ad1 100644 --- a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp @@ -447,8 +447,6 @@ TEST_F(HContainerTest, atompair_funcs) PO.atom_begin_row[i] = i*2; // nw = 2, value should be i*nw PO.atom_begin_col[i] = i*2; } - PO.nrow = 4; - PO.ncol = 4; hamilt::AtomPair atom_ij(0, 0, &PO, nullptr); hamilt::AtomPair atom_ij2(0, 1, 1, 1, 1, &PO, nullptr); hamilt::AtomPair atom_ij3(1, 0, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, nullptr); @@ -596,13 +594,8 @@ TEST_F(HContainerTest, atompair_funcs) hamilt::AtomPair atom_ij7(1, 1, 1, 1, 1, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, correct_array); // get_matrix_value will use global2local_row and global2local_col in Parallel_Orbitals // so we need to set them - PO.global2local_col = new int[4]; - PO.global2local_row = new int[4]; - for(int i=0;i<4;++i) - { - PO.global2local_col[i] = i; - PO.global2local_row[i] = i; - } + std::ofstream ofs("test_hcontainer.log"); + PO.set_global2local(4, 4, false, ofs); for(int i=0;i<4;++i) { for(int j=0;j<4;++j) diff --git a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp index f5d006359f1..90feca64db7 100644 --- a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp @@ -447,8 +447,6 @@ TEST_F(HContainerTest, atompair_funcs) PO.atom_begin_row[i] = i*2; // nw = 2, value should be i*nw PO.atom_begin_col[i] = i*2; } - PO.nrow = 4; - PO.ncol = 4; hamilt::AtomPair> atom_ij(0, 0, &PO, nullptr); hamilt::AtomPair> atom_ij2(0, 1, 1, 1, 1, &PO, nullptr); hamilt::AtomPair> atom_ij3(1, 0, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, nullptr); @@ -555,13 +553,8 @@ TEST_F(HContainerTest, atompair_funcs) hamilt::AtomPair> atom_ij7(1, 1, 1, 1, 1, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, correct_array); // get_matrix_value will use global2local_row and global2local_col in Parallel_Orbitals // so we need to set them - PO.global2local_col = new int[4]; - PO.global2local_row = new int[4]; - for(int i=0;i<4;++i) - { - PO.global2local_col[i] = i; - PO.global2local_row[i] = i; - } + std::ofstream ofs("test_hcontainer_complex.log"); + PO.set_global2local(4, 4, false, ofs); for(int i=0;i<4;++i) { for(int j=0;j<4;++j) diff --git a/source/module_io/cal_r_overlap_R.cpp b/source/module_io/cal_r_overlap_R.cpp index a2dd9b30856..deef52bdef8 100644 --- a/source/module_io/cal_r_overlap_R.cpp +++ b/source/module_io/cal_r_overlap_R.cpp @@ -291,12 +291,12 @@ void cal_r_overlap_R::out_rR(const int &istep) int ir, ic; for(int iw1 = 0; iw1 < GlobalV::NLOCAL; iw1++) { - ir = this->ParaV->global2local_row[iw1]; + ir = this->ParaV->global2local_row(iw1); if(ir >= 0) { for(int iw2 = 0; iw2 < GlobalV::NLOCAL; iw2++) { - ic = this->ParaV->global2local_col[iw2]; + ic = this->ParaV->global2local_col(iw2); if(ic >= 0) { int orb_index_row = iw1 / GlobalV::NPOL; @@ -528,12 +528,12 @@ void cal_r_overlap_R::out_rR_other(const int &istep, const std::setParaV->global2local_row[iw1]; + ir = this->ParaV->global2local_row(iw1); if(ir >= 0) { for(int iw2 = 0; iw2 < GlobalV::NLOCAL; iw2++) { - ic = this->ParaV->global2local_col[iw2]; + ic = this->ParaV->global2local_col(iw2); if(ic >= 0) { int orb_index_row = iw1 / GlobalV::NPOL; diff --git a/source/module_io/istate_charge.cpp b/source/module_io/istate_charge.cpp index 4af47daa1a7..d07376d7a9b 100644 --- a/source/module_io/istate_charge.cpp +++ b/source/module_io/istate_charge.cpp @@ -181,7 +181,7 @@ void IState_Charge::idmatrix(const int& ib, elecstate::ElecState* pelec) for (int is = 0; is != GlobalV::NSPIN; ++is) { std::vector wg_local(this->loc->ParaV->ncol, 0.0); - const int ib_local = this->loc->ParaV->global2local_col[ib]; + const int ib_local = this->loc->ParaV->global2local_col(ib); int fermi_band = 0; fermi_band = static_cast((GlobalV::nelec + 1) / 2 + 1.0e-8); diff --git a/source/module_io/mulliken_charge.cpp b/source/module_io/mulliken_charge.cpp index 7b744547e31..1ebfbe921fa 100644 --- a/source/module_io/mulliken_charge.cpp +++ b/source/module_io/mulliken_charge.cpp @@ -67,8 +67,8 @@ ModuleBase::matrix ModuleIO::cal_mulliken(const std::vector for(size_t i=0; i!=GlobalV::NLOCAL; ++i) if(uhm.LM->ParaV->in_this_processor(i, i)) { - const int ir = uhm.LM->ParaV->global2local_row[i]; - const int ic = uhm.LM->ParaV->global2local_col[i]; + const int ir = uhm.LM->ParaV->global2local_row(i); + const int ic = uhm.LM->ParaV->global2local_col(i); MecMulP(is, i) += mud(ic, ir); } } @@ -85,26 +85,26 @@ ModuleBase::matrix ModuleIO::cal_mulliken(const std::vector const int k2 = 2*j+1; if(uhm.LM->ParaV->in_this_processor(k1, k1)) { - const int ir = uhm.LM->ParaV->global2local_row[k1]; - const int ic = uhm.LM->ParaV->global2local_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row(k1); + const int ic = uhm.LM->ParaV->global2local_col(k1); MecMulP(0, j) += mud(ir, ic); } if(uhm.LM->ParaV->in_this_processor(k1, k2)) { - const int ir = uhm.LM->ParaV->global2local_row[k1]; - const int ic = uhm.LM->ParaV->global2local_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row(k1); + const int ic = uhm.LM->ParaV->global2local_col(k2); MecMulP(1, j) += mud(ir, ic); } if(uhm.LM->ParaV->in_this_processor(k2, k1)) { - const int ir = uhm.LM->ParaV->global2local_row[k2]; - const int ic = uhm.LM->ParaV->global2local_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row(k2); + const int ic = uhm.LM->ParaV->global2local_col(k1); MecMulP(2, j) += mud(ir, ic); } if(uhm.LM->ParaV->in_this_processor(k2, k2)) { - const int ir = uhm.LM->ParaV->global2local_row[k2]; - const int ic = uhm.LM->ParaV->global2local_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row(k2); + const int ic = uhm.LM->ParaV->global2local_col(k2); MecMulP(3, j) += mud(ir, ic); } } @@ -171,8 +171,8 @@ ModuleBase::matrix ModuleIO::cal_mulliken_k(const std::vectorParaV->in_this_processor(i, i)) { - const int ir = uhm.LM->ParaV->global2local_row[i]; - const int ic = uhm.LM->ParaV->global2local_col[i]; + const int ir = uhm.LM->ParaV->global2local_row(i); + const int ic = uhm.LM->ParaV->global2local_col(i); MecMulP(spin, i) += mud(ic, ir).real(); } } @@ -188,29 +188,29 @@ ModuleBase::matrix ModuleIO::cal_mulliken_k(const std::vectorParaV->in_this_processor(k1, k1)) { - const int ir = uhm.LM->ParaV->global2local_row[k1]; - const int ic = uhm.LM->ParaV->global2local_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row(k1); + const int ic = uhm.LM->ParaV->global2local_col(k1); MecMulP(0, j) += mud(ic, ir).real(); MecMulP(3, j) += mud(ic, ir).real(); } if(uhm.LM->ParaV->in_this_processor(k1, k2)) { - const int ir = uhm.LM->ParaV->global2local_row[k1]; - const int ic = uhm.LM->ParaV->global2local_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row(k1); + const int ic = uhm.LM->ParaV->global2local_col(k2); MecMulP(1, j) += mud(ic, ir).real(); MecMulP(2, j) += mud(ic, ir).imag(); } if(uhm.LM->ParaV->in_this_processor(k2, k1)) { - const int ir = uhm.LM->ParaV->global2local_row[k2]; - const int ic = uhm.LM->ParaV->global2local_col[k1]; + const int ir = uhm.LM->ParaV->global2local_row(k2); + const int ic = uhm.LM->ParaV->global2local_col(k1); MecMulP(1, j) += mud(ic, ir).real(); MecMulP(2, j) -= mud(ic, ir).imag(); } if(uhm.LM->ParaV->in_this_processor(k2, k2)) { - const int ir = uhm.LM->ParaV->global2local_row[k2]; - const int ic = uhm.LM->ParaV->global2local_col[k2]; + const int ir = uhm.LM->ParaV->global2local_row(k2); + const int ic = uhm.LM->ParaV->global2local_col(k2); MecMulP(0, j) += mud(ic, ir).real(); MecMulP(3, j) -= mud(ic, ir).real(); } diff --git a/source/module_io/single_R_io.cpp b/source/module_io/single_R_io.cpp index 3b1be73f608..d40b298b186 100644 --- a/source/module_io/single_R_io.cpp +++ b/source/module_io/single_R_io.cpp @@ -33,7 +33,7 @@ void ModuleIO::output_single_R(std::ofstream &ofs, const std::map= 0) + if(pv.global2local_row(row) >= 0) { auto iter = XR.find(row); if (iter != XR.end()) @@ -146,7 +146,7 @@ void ModuleIO::output_soc_single_R(std::ofstream &ofs, const std::map[GlobalV::NLOCAL]; ModuleBase::GlobalFunc::ZEROS(line, GlobalV::NLOCAL); - if(pv.global2local_row[row] >= 0) + if(pv.global2local_row(row) >= 0) { auto iter = XR.find(row); if (iter != XR.end()) diff --git a/source/module_io/test/single_R_io_test.cpp b/source/module_io/test/single_R_io_test.cpp index 8f81d3bc609..378fa9a259e 100644 --- a/source/module_io/test/single_R_io_test.cpp +++ b/source/module_io/test/single_R_io_test.cpp @@ -15,12 +15,23 @@ Parallel_2D::Parallel_2D(){} Parallel_2D::~Parallel_2D(){} Parallel_Orbitals::Parallel_Orbitals() { - global2local_row = nullptr; + global2local_row_ = nullptr; } Parallel_Orbitals::~Parallel_Orbitals() { - delete[] global2local_row; + delete[] global2local_row_; +} + +void Parallel_2D::set_global2local(const int& M_A, const int& N_A, + const bool& div_2d, std::ofstream& ofs_running) +{ + this->global2local_row_ = new int[5]; + this->global2local_row_[0] = 0; + this->global2local_row_[1] = 1; + this->global2local_row_[2] = -1; + this->global2local_row_[3] = 2; + this->global2local_row_[4] = -1; //Some rows have global2local_row_ < 0 } TEST(ModuleIOTest, OutputSingleR) @@ -35,13 +46,7 @@ TEST(ModuleIOTest, OutputSingleR) const double sparse_threshold = 1e-8; const bool binary = false; Parallel_Orbitals pv; - GlobalV::NLOCAL=5; - pv.global2local_row = new int[GlobalV::NLOCAL]; - pv.global2local_row[0] = 0; - pv.global2local_row[1] = 1; - pv.global2local_row[2] = -1; - pv.global2local_row[3] = 2; - pv.global2local_row[4] = -1; //Some rows have global2local_row < 0 + pv.set_global2local(5, 5, false, ofs); std::map> XR = { {0, {{1, 0.5}, {3, 0.3}}}, {1, {{0, 0.2}, {2, 0.4}}}, diff --git a/source/module_io/unk_overlap_lcao.cpp b/source/module_io/unk_overlap_lcao.cpp index 1be71016918..6c26ee05be8 100644 --- a/source/module_io/unk_overlap_lcao.cpp +++ b/source/module_io/unk_overlap_lcao.cpp @@ -697,8 +697,8 @@ void unkOverlap_lcao::prepare_midmatrix_pblas(const int ik_L, { for (int iw_col = 0; iw_col < GlobalV::NLOCAL; iw_col++) // global { - int ir = pv.global2local_row[ iw_row ]; // local - int ic = pv.global2local_col[ iw_col ]; // local + int ir = pv.global2local_row(iw_row); // local + int ic = pv.global2local_col(iw_col); // local if(ir >= 0 && ic >= 0) { @@ -761,8 +761,8 @@ std::complex unkOverlap_lcao::det_berryphase(const int ik_L, for(int i = 0; i < occBands; i++) // global { - int ir = lowf.ParaV->global2local_row[ i ]; // local - int ic = lowf.ParaV->global2local_col[ i ]; // local + int ir = lowf.ParaV->global2local_row(i); // local + int ic = lowf.ParaV->global2local_col(i); // local if(ir >= 0 && ic >= 0) { int index = ic*lowf.ParaV->nrow+ir; diff --git a/source/module_io/write_HS.cpp b/source/module_io/write_HS.cpp index 57bec858423..c56d8f7085d 100644 --- a/source/module_io/write_HS.cpp +++ b/source/module_io/write_HS.cpp @@ -185,13 +185,13 @@ void ModuleIO::save_HS_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -286,13 +286,13 @@ void ModuleIO::save_HS_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -429,13 +429,13 @@ void ModuleIO::save_HS_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -530,13 +530,13 @@ void ModuleIO::save_HS_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -705,13 +705,13 @@ void ModuleIO::save_HS_complex_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -806,13 +806,13 @@ void ModuleIO::save_HS_complex_triangle(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL - i); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL - i); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = i; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -950,13 +950,13 @@ void ModuleIO::save_HS_complex_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -1051,13 +1051,13 @@ void ModuleIO::save_HS_complex_complete(const int istep, ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = pv.global2local_row[i]; + ir = pv.global2local_row(i); if (ir >= 0) { // data collection for (int j = 0; j < GlobalV::NLOCAL; j++) { - ic = pv.global2local_col[j]; + ic = pv.global2local_col(j); if (ic >= 0) { int iic; @@ -1219,13 +1219,13 @@ void ModuleIO::save_HSR_tr(const int current_spin, LCAO_Matrix &lm) // ModuleBase::GlobalFunc::ZEROS(lineH, GlobalV::NLOCAL); // ModuleBase::GlobalFunc::ZEROS(lineS, GlobalV::NLOCAL); - ir = lm.ParaV->global2local_row[i]; + ir = lm.ParaV->global2local_row(i); if (ir >= 0) { // for(int j=i; jglobal2local_col[j]; + ic = lm.ParaV->global2local_col(j); if (ic >= 0) { // lineH[j-i] = H[ir*lm.ParaV->ncol+ic]; diff --git a/source/module_io/write_dm_sparse.cpp b/source/module_io/write_dm_sparse.cpp index f9df2a8561f..76b09707b08 100644 --- a/source/module_io/write_dm_sparse.cpp +++ b/source/module_io/write_dm_sparse.cpp @@ -90,14 +90,14 @@ void ModuleIO::get_dm_sparse(const int &is, double** dm2d, const Parallel_Orbita for(int ii=0; iinw; ii++) { const int iw1_all = start + ii; - const int mu = ParaV->global2local_row[iw1_all]; + const int mu = ParaV->global2local_row(iw1_all); if(mu<0)continue; for(int jj=0; jjnw; jj++) { int iw2_all = start2 + jj; - const int nu = ParaV->global2local_col[iw2_all]; + const int nu = ParaV->global2local_col(iw2_all); if(nu<0)continue; diff --git a/source/module_io/write_dos_lcao.cpp b/source/module_io/write_dos_lcao.cpp index 31429362eae..8bd62eb5c64 100644 --- a/source/module_io/write_dos_lcao.cpp +++ b/source/module_io/write_dos_lcao.cpp @@ -165,8 +165,8 @@ void ModuleIO::write_dos_lcao(const psi::Psi* psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->global2local_row[j]; - const int ic = pv->global2local_col[i]; + const int ir = pv->global2local_row(j); + const int ic = pv->global2local_col(i); waveg[j] = Mulk[0](ic, ir) * psid[0](ic, ir); const double x = waveg[j].real(); BlasConnector::axpy(np, x, Gauss, 1, pdosk[is].c + j * pdosk[is].nc, 1); @@ -264,8 +264,8 @@ void ModuleIO::write_dos_lcao(const psi::Psi* psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->global2local_row[j]; - const int ic = pv->global2local_col[i]; + const int ir = pv->global2local_row(j); + const int ic = pv->global2local_col(i); waveg[j] = Mulk[0](ic, ir) * psi[0](ic, ir); const double x = waveg[j].real(); diff --git a/source/module_io/write_proj_band_lcao.cpp b/source/module_io/write_proj_band_lcao.cpp index 5c8808d9c2f..531383a27ab 100644 --- a/source/module_io/write_proj_band_lcao.cpp +++ b/source/module_io/write_proj_band_lcao.cpp @@ -93,8 +93,8 @@ void ModuleIO::write_proj_band_lcao(const psi::Psi *psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->global2local_row[j]; - const int ic = pv->global2local_col[i]; + const int ir = pv->global2local_row(j); + const int ic = pv->global2local_col(i); weightk(is, i * GlobalV::NLOCAL + j) = Mulk[0](ic, ir) * psid[0](ic, ir); } } @@ -175,8 +175,8 @@ void ModuleIO::write_proj_band_lcao(const psi::Psi *psid, if (pv->in_this_processor(j, i)) { - const int ir = pv->global2local_row[j]; - const int ic = pv->global2local_col[i]; + const int ir = pv->global2local_row(j); + const int ic = pv->global2local_col(i); weightk(ik, i * GlobalV::NLOCAL + j) = Mulk[0](ic, ir) * psi[0](ic, ir); } diff --git a/source/module_ri/RI_2D_Comm.cpp b/source/module_ri/RI_2D_Comm.cpp index cb0cf9522a3..336511813c4 100644 --- a/source/module_ri/RI_2D_Comm.cpp +++ b/source/module_ri/RI_2D_Comm.cpp @@ -19,18 +19,18 @@ auto RI_2D_Comm::get_2D_judge(const Parallel_Orbitals &pv) const std::map nspin_b = {{1,1}, {2,1}, {4,2}}; std::vector> iat0_list(nspin_b.at(GlobalV::NSPIN)); - for (int iwt0_2D = 0; iwt0_2D < pv.local2global_row.size(); ++iwt0_2D) + for (int iwt0_2D = 0; iwt0_2D < pv.nrow; ++iwt0_2D) { - const int iwt0 = pv.local2global_row[iwt0_2D]; + const int iwt0 = pv.local2global_row(iwt0_2D); int iat0, iw0_b, is0_b; std::tie(iat0,iw0_b,is0_b) = RI_2D_Comm::get_iat_iw_is_block(iwt0); iat0_list[is0_b].insert(iat0); } std::vector> iat1_list(nspin_b.at(GlobalV::NSPIN)); - for (int iwt1_2D = 0; iwt1_2D < pv.local2global_col.size(); ++iwt1_2D) + for (int iwt1_2D = 0; iwt1_2D < pv.ncol; ++iwt1_2D) { - const int iwt1 = pv.local2global_col[iwt1_2D]; + const int iwt1 = pv.local2global_col(iwt1_2D); int iat1, iw1_b, is1_b; std::tie(iat1,iw1_b,is1_b) = RI_2D_Comm::get_iat_iw_is_block(iwt1); iat1_list[is1_b].insert(iat1); diff --git a/source/module_ri/RI_2D_Comm.hpp b/source/module_ri/RI_2D_Comm.hpp index 7b0f2814e56..4a5746272d7 100644 --- a/source/module_ri/RI_2D_Comm.hpp +++ b/source/module_ri/RI_2D_Comm.hpp @@ -53,8 +53,8 @@ auto RI_2D_Comm::split_m2D_ktoR(const K_Vectors &kv, const std::vector::out_eigen_vector(const Parallel_Orbitals ¶v, const psi: { std::vector> wfc_iks(GlobalV::NLOCAL, zero); - const int ib_local = parav.global2local_col[ib_global]; + const int ib_local = parav.global2local_col(ib_global); if (ib_local >= 0) for (int ir = 0; ir < psi.get_nbasis(); ir++) - wfc_iks[parav.local2global_row[ir]] = psi(ik + nks_tot * is, ib_local, ir); + wfc_iks[parav.local2global_row(ir)] = psi(ik + nks_tot * is, ib_local, ir); std::vector> tmp = wfc_iks; #ifdef __MPI From 651c1314d2953153d5f83701c706a3338038d24b Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Thu, 6 Jul 2023 22:30:57 +0800 Subject: [PATCH 4/5] fix deepks test --- .../module_deepks/test/CMakeLists.txt | 2 +- .../module_deepks/test/LCAO_deepks_test.h | 2 +- .../test/LCAO_deepks_test_prep.cpp | 3 +- .../module_deepks/test/parallel_orbitals.cpp | 52 ------------------- 4 files changed, 4 insertions(+), 55 deletions(-) delete mode 100644 source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp diff --git a/source/module_hamilt_lcao/module_deepks/test/CMakeLists.txt b/source/module_hamilt_lcao/module_deepks/test/CMakeLists.txt index d0622a3ac3c..00478a87f53 100644 --- a/source/module_hamilt_lcao/module_deepks/test/CMakeLists.txt +++ b/source/module_hamilt_lcao/module_deepks/test/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable( test_deepks - main_deepks.cpp klist_1.cpp LCAO_deepks_test_prep.cpp LCAO_deepks_test.cpp nnr.cpp parallel_orbitals.cpp + main_deepks.cpp klist_1.cpp LCAO_deepks_test_prep.cpp LCAO_deepks_test.cpp nnr.cpp ) if(ENABLE_COVERAGE) diff --git a/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.h b/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.h index 2b8753116f7..3f8f5f1438a 100644 --- a/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.h +++ b/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test.h @@ -36,7 +36,7 @@ class test_deepks UnitCell ucell; - Test_Deepks::Parallel_Orbitals ParaO; + Parallel_Orbitals ParaO; Test_Deepks::K_Vectors kv; LCAO_Deepks ld; diff --git a/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp b/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp index 85d6c3e0282..0ebf1c03be6 100644 --- a/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp +++ b/source/module_hamilt_lcao/module_deepks/test/LCAO_deepks_test_prep.cpp @@ -13,7 +13,8 @@ void test_deepks::preparation() this->set_orbs(ucell.lat0); this->prep_neighbour(); - this->ParaO.set_global2local(); + this->ParaO.set_global2local(GlobalV::NLOCAL, GlobalV::NLOCAL, + false, GlobalV::ofs_running); } void test_deepks::set_parameters() diff --git a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp b/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp deleted file mode 100644 index 323afd5dfba..00000000000 --- a/source/module_hamilt_lcao/module_deepks/test/parallel_orbitals.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "parallel_orbitals.h" - -namespace Test_Deepks -{ - - Parallel_Orbitals::Parallel_Orbitals() - { - global2local_row = nullptr; - global2local_col = nullptr; - } - - Parallel_Orbitals::~Parallel_Orbitals() - { - delete[] global2local_row; - delete[] global2local_col; - } - - void Parallel_Orbitals::set_global2local(void) - { - ModuleBase::TITLE("Parallel_Orbitals","set_trace"); - assert(GlobalV::NLOCAL>0); - - delete[] global2local_row; - delete[] global2local_col; - - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"global2local_row dimension",GlobalV::NLOCAL); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"global2local_col dimension",GlobalV::NLOCAL); - - global2local_row = new int[GlobalV::NLOCAL]; - global2local_col = new int[GlobalV::NLOCAL]; - // mohan update 2011-04-07 - for(int i=0; inrow = GlobalV::NLOCAL; - this->ncol = GlobalV::NLOCAL; - this->nloc=nrow*ncol; - - return; - } -} \ No newline at end of file From 6ee1e7231f7912b95306fc1262cd4ad4713624b5 Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Fri, 7 Jul 2023 00:07:51 +0800 Subject: [PATCH 5/5] fix tests --- .../module_hcontainer/test/test_hcontainer.cpp | 2 ++ .../module_hcontainer/test/test_hcontainer_complex.cpp | 2 ++ source/module_io/test/single_R_io_test.cpp | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp index 8c22d833ad1..2e87127bd60 100644 --- a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer.cpp @@ -447,6 +447,8 @@ TEST_F(HContainerTest, atompair_funcs) PO.atom_begin_row[i] = i*2; // nw = 2, value should be i*nw PO.atom_begin_col[i] = i*2; } + PO.nrow = 4; + PO.ncol = 4; hamilt::AtomPair atom_ij(0, 0, &PO, nullptr); hamilt::AtomPair atom_ij2(0, 1, 1, 1, 1, &PO, nullptr); hamilt::AtomPair atom_ij3(1, 0, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, nullptr); diff --git a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp index 90feca64db7..c3d6408d37b 100644 --- a/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp +++ b/source/module_hamilt_lcao/module_hcontainer/test/test_hcontainer_complex.cpp @@ -447,6 +447,8 @@ TEST_F(HContainerTest, atompair_funcs) PO.atom_begin_row[i] = i*2; // nw = 2, value should be i*nw PO.atom_begin_col[i] = i*2; } + PO.nrow = 4; + PO.ncol = 4; hamilt::AtomPair> atom_ij(0, 0, &PO, nullptr); hamilt::AtomPair> atom_ij2(0, 1, 1, 1, 1, &PO, nullptr); hamilt::AtomPair> atom_ij3(1, 0, PO.atom_begin_row.data(), PO.atom_begin_col.data(), 2, nullptr); diff --git a/source/module_io/test/single_R_io_test.cpp b/source/module_io/test/single_R_io_test.cpp index 378fa9a259e..7bfc74f8b2c 100644 --- a/source/module_io/test/single_R_io_test.cpp +++ b/source/module_io/test/single_R_io_test.cpp @@ -26,7 +26,7 @@ Parallel_Orbitals::~Parallel_Orbitals() void Parallel_2D::set_global2local(const int& M_A, const int& N_A, const bool& div_2d, std::ofstream& ofs_running) { - this->global2local_row_ = new int[5]; + this->global2local_row_ = new int[M_A]; this->global2local_row_[0] = 0; this->global2local_row_[1] = 1; this->global2local_row_[2] = -1; @@ -46,7 +46,8 @@ TEST(ModuleIOTest, OutputSingleR) const double sparse_threshold = 1e-8; const bool binary = false; Parallel_Orbitals pv; - pv.set_global2local(5, 5, false, ofs); + GlobalV::NLOCAL = 5; + pv.set_global2local(GlobalV::NLOCAL, GlobalV::NLOCAL, false, ofs); std::map> XR = { {0, {{1, 0.5}, {3, 0.3}}}, {1, {{0, 0.2}, {2, 0.4}}},