From 9cc044e3b2f261df173876376609c530aea14cf8 Mon Sep 17 00:00:00 2001 From: dzzz2001 <153698752+dzzz2001@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:31:58 +0800 Subject: [PATCH] Refactor: remove some unused variables in module_gint (#5568) * remove some unused variables * small change * remove some redundant lines * modify the class interface of grid_meshk * remove grid_index.h * modify some comment * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- source/module_base/vector3.h | 3 ++ source/module_hamilt_lcao/module_gint/gint.h | 4 -- .../module_gint/gint_gamma_env.cpp | 1 - .../module_gint/gint_k_env.cpp | 7 +--- .../module_gint/gint_vl.cpp | 17 ++------ .../module_gint/gint_vl_cpu_interface.cpp | 16 +++---- .../module_gint/grid_index.h | 20 --------- .../module_gint/grid_meshcell.h | 6 ++- .../module_gint/grid_meshk.cpp | 42 ++++++++----------- .../module_gint/grid_meshk.h | 22 +++++----- .../module_gint/grid_technique.h | 17 -------- .../module_gint/gtask_force.cpp | 16 ++----- .../module_gint/gtask_rho.cpp | 16 ++----- .../module_gint/gtask_vl.cpp | 11 ++--- .../module_gint/mult_psi_dmr.cpp | 21 ++-------- 15 files changed, 65 insertions(+), 154 deletions(-) delete mode 100644 source/module_hamilt_lcao/module_gint/grid_index.h diff --git a/source/module_base/vector3.h b/source/module_base/vector3.h index 504adf5804..fda97c5482 100644 --- a/source/module_base/vector3.h +++ b/source/module_base/vector3.h @@ -36,6 +36,9 @@ template class Vector3 Vector3(const Vector3 &v) : x(v.x), y(v.y), z(v.z){}; // Peize Lin add 2018-07-16 explicit Vector3(const std::array &v) :x(v[0]), y(v[1]), z(v[2]){} + template + explicit Vector3(const Vector3& other) : x(static_cast(other.x)), y(static_cast(other.y)), z(static_cast(other.z)) {} + Vector3(Vector3 &&v) noexcept : x(v.x), y(v.y), z(v.z) {} /** diff --git a/source/module_hamilt_lcao/module_gint/gint.h b/source/module_hamilt_lcao/module_gint/gint.h index dc991de6b1..b0601af2d5 100644 --- a/source/module_hamilt_lcao/module_gint/gint.h +++ b/source/module_hamilt_lcao/module_gint/gint.h @@ -133,7 +133,6 @@ class Gint { //! calculate local potential contribution to the Hamiltonian //! na_grid: how many atoms on this (i,j,k) grid - //! block_iw: dim is [na_grid], index of wave function for each block //! block_size: dim is [block_size], number of columns of a band //! block_index: dim is [na_grid+1], total number of atomic orbitals //! grid_index: index of grid group, for tracing iat @@ -141,11 +140,9 @@ class Gint { //! psir_ylm: dim is [bxyz][LD_pool] //! psir_vlbr3: dim is [bxyz][LD_pool] //! hR: HContainer for storing the matrix elements - void cal_meshball_vlocal( const int na_grid, const int LD_pool, - const int* const block_iw, const int* const block_size, const int* const block_index, const int grid_index, @@ -154,7 +151,6 @@ class Gint { const double* const* const psir_vlbr3, hamilt::HContainer* hR); - //! in gint_fvl.cpp //! calculate vl contributuion to force & stress via grid integrals void gint_kernel_force(const int na_grid, diff --git a/source/module_hamilt_lcao/module_gint/gint_gamma_env.cpp b/source/module_hamilt_lcao/module_gint/gint_gamma_env.cpp index 666a715895..708fea818a 100644 --- a/source/module_hamilt_lcao/module_gint/gint_gamma_env.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_gamma_env.cpp @@ -19,7 +19,6 @@ void Gint_Gamma::cal_env(const double* wfc, double* rho, UnitCell& ucell) } const int nbx = this->gridt->nbx; const int nby = this->gridt->nby; - const int nbz_start = this->gridt->nbzp_start; const int nbz = this->gridt->nbzp; const int ncyz = this->ny * this->nplane; // mohan add 2012-03-25 const int bxyz = this->bxyz; diff --git a/source/module_hamilt_lcao/module_gint/gint_k_env.cpp b/source/module_hamilt_lcao/module_gint/gint_k_env.cpp index a844205516..b6510a0a51 100644 --- a/source/module_hamilt_lcao/module_gint/gint_k_env.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_k_env.cpp @@ -6,6 +6,7 @@ #include "module_basis/module_ao/ORB_read.h" #include "module_hamilt_pw/hamilt_pwdft/global.h" #include "module_base/array_pool.h" +#include "module_base/vector3.h" void Gint_k::cal_env_k(int ik, const std::complex* psi_k, @@ -26,7 +27,6 @@ void Gint_k::cal_env_k(int ik, } const int nbx = this->gridt->nbx; const int nby = this->gridt->nby; - const int nbz_start = this->gridt->nbzp_start; const int nbz = this->gridt->nbzp; const int ncyz = this->ny * this->nplane; // mohan add 2012-03-25 @@ -88,10 +88,7 @@ void Gint_k::cal_env_k(int ik, // find R by which_unitcell and cal kphase const int id_ucell = this->gridt->which_unitcell[mcell_index1]; - const int Rx = this->gridt->ucell_index2x[id_ucell] + this->gridt->min_ucell_para[0]; - const int Ry = this->gridt->ucell_index2y[id_ucell] + this->gridt->min_ucell_para[1]; - const int Rz = this->gridt->ucell_index2z[id_ucell] + this->gridt->min_ucell_para[2]; - ModuleBase::Vector3 R((double)Rx, (double)Ry, (double)Rz); + ModuleBase::Vector3 R(this->gridt->get_ucell_coords(id_ucell)); // std::cout << "kvec_d: " << kvec_d[ik].x << " " << kvec_d[ik].y << " " << kvec_d[ik].z << std::endl; // std::cout << "kvec_c: " << kvec_c[ik].x << " " << kvec_c[ik].y << " " << kvec_c[ik].z << std::endl; // std::cout << "R: " << R.x << " " << R.y << " " << R.z << std::endl; diff --git a/source/module_hamilt_lcao/module_gint/gint_vl.cpp b/source/module_hamilt_lcao/module_gint/gint_vl.cpp index 826c8730e0..da33737c3c 100644 --- a/source/module_hamilt_lcao/module_gint/gint_vl.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_vl.cpp @@ -8,6 +8,7 @@ #include "module_base/blas_connector.h" #include "module_base/timer.h" #include "module_base/array_pool.h" +#include "module_base/vector3.h" //#include #ifdef _OPENMP @@ -22,7 +23,6 @@ void Gint::cal_meshball_vlocal( const int na_grid, // how many atoms on this (i,j,k) grid const int LD_pool, - const int*const block_iw, // block_iw[na_grid], index of wave functions for each block const int*const block_size, // block_size[na_grid], number of columns of a band const int*const block_index, // block_index[na_grid+1], count total number of atomis orbitals const int grid_index, // index of grid group, for tracing global atom index @@ -41,18 +41,14 @@ void Gint::cal_meshball_vlocal( const int bcell1 = mcell_index + ia1; const int iat1 = this->gridt->which_atom[bcell1]; const int id1 = this->gridt->which_unitcell[bcell1]; - const int r1x = this->gridt->ucell_index2x[id1]; - const int r1y = this->gridt->ucell_index2y[id1]; - const int r1z = this->gridt->ucell_index2z[id1]; + const ModuleBase::Vector3 r1 = this->gridt->get_ucell_coords(id1); for(int ia2=0; ia2gridt->which_atom[bcell2]; const int id2 = this->gridt->which_unitcell[bcell2]; - const int r2x = this->gridt->ucell_index2x[id2]; - const int r2y = this->gridt->ucell_index2y[id2]; - const int r2z = this->gridt->ucell_index2z[id2]; + const ModuleBase::Vector3 r2 = this->gridt->get_ucell_coords(id2); if(iat1<=iat2) { @@ -77,12 +73,7 @@ void Gint::cal_meshball_vlocal( const int ib_length = last_ib-first_ib; if(ib_length<=0) { continue; } - // calculate the BaseMatrix of atom-pair - const int dRx = r1x - r2x; - const int dRy = r1y - r2y; - const int dRz = r1z - r2z; - - const auto tmp_matrix = hR->find_matrix(iat1, iat2, dRx, dRy, dRz); + const auto tmp_matrix = hR->find_matrix(iat1, iat2, r1-r2); if (tmp_matrix == nullptr) { continue; diff --git a/source/module_hamilt_lcao/module_gint/gint_vl_cpu_interface.cpp b/source/module_hamilt_lcao/module_gint/gint_vl_cpu_interface.cpp index 670d4afec7..c7629ba387 100644 --- a/source/module_hamilt_lcao/module_gint/gint_vl_cpu_interface.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_vl_cpu_interface.cpp @@ -72,7 +72,7 @@ void Gint::gint_kernel_vlocal(Gint_inout* inout) { //integrate (psi_mu*v(r)*dv) * psi_nu on grid //and accumulates to the corresponding element in Hamiltonian this->cal_meshball_vlocal( - na_grid, LD_pool, block_iw.data(), block_size.data(), block_index.data(), grid_index, + na_grid, LD_pool, block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(),psir_ylm.get_ptr_2D(), psir_vlbr3.get_ptr_2D(), &hRGint_thread); } @@ -158,13 +158,13 @@ void Gint::gint_kernel_dvlocal(Gint_inout* inout) { //integrate (psi_mu*v(r)*dv) * psi_nu on grid //and accumulates to the corresponding element in Hamiltonian this->cal_meshball_vlocal(na_grid, LD_pool, block_size.data(), block_index.data(), - block_iw.data(), grid_index, cal_flag.get_ptr_2D(),psir_vlbr3.get_ptr_2D(), + grid_index, cal_flag.get_ptr_2D(),psir_vlbr3.get_ptr_2D(), dpsir_ylm_x.get_ptr_2D(), &pvdpRx_thread); this->cal_meshball_vlocal(na_grid, LD_pool, block_size.data(), block_index.data(), - block_iw.data(), grid_index, cal_flag.get_ptr_2D(),psir_vlbr3.get_ptr_2D(), + grid_index, cal_flag.get_ptr_2D(),psir_vlbr3.get_ptr_2D(), dpsir_ylm_y.get_ptr_2D(), &pvdpRy_thread); this->cal_meshball_vlocal(na_grid, LD_pool, block_size.data(), block_index.data(), - block_iw.data(), grid_index, cal_flag.get_ptr_2D(),psir_vlbr3.get_ptr_2D(), + grid_index, cal_flag.get_ptr_2D(),psir_vlbr3.get_ptr_2D(), dpsir_ylm_z.get_ptr_2D(), &pvdpRz_thread); } #pragma omp critical(gint_k) @@ -281,18 +281,18 @@ void Gint::gint_kernel_vlocal_meta(Gint_inout* inout) { //integrate (psi_mu*v(r)*dv) * psi_nu on grid //and accumulates to the corresponding element in Hamiltonian this->cal_meshball_vlocal( - na_grid, LD_pool, block_iw.data(), block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), + na_grid, LD_pool, block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), psir_ylm.get_ptr_2D(), psir_vlbr3.get_ptr_2D(), &hRGint_thread); //integrate (d/dx_i psi_mu*vk(r)*dv) * (d/dx_i psi_nu) on grid (x_i=x,y,z) //and accumulates to the corresponding element in Hamiltonian this->cal_meshball_vlocal( - na_grid, LD_pool, block_iw.data(), block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), + na_grid, LD_pool, block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), dpsir_ylm_x.get_ptr_2D(), dpsix_vlbr3.get_ptr_2D(), &hRGint_thread); this->cal_meshball_vlocal( - na_grid, LD_pool, block_iw.data(), block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), + na_grid, LD_pool, block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), dpsir_ylm_y.get_ptr_2D(), dpsiy_vlbr3.get_ptr_2D(), &hRGint_thread); this->cal_meshball_vlocal( - na_grid, LD_pool, block_iw.data(), block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), + na_grid, LD_pool, block_size.data(), block_index.data(), grid_index, cal_flag.get_ptr_2D(), dpsir_ylm_z.get_ptr_2D(), dpsiz_vlbr3.get_ptr_2D(), &hRGint_thread); } diff --git a/source/module_hamilt_lcao/module_gint/grid_index.h b/source/module_hamilt_lcao/module_gint/grid_index.h deleted file mode 100644 index 460e82b7d9..0000000000 --- a/source/module_hamilt_lcao/module_gint/grid_index.h +++ /dev/null @@ -1,20 +0,0 @@ -#include "module_base/vector3.h" -/// index structure for grid integral module -/// in ABACUS, this index is stored for tracing: -/// 1. starting row and column index (mu, nu) -/// 2. R distance from atom 1 and atom2 (dR) -/// 3. number of orbitals for atom1 and atom2 (nw1, nw2) -namespace gridIntegral -{ - -struct gridIndex -{ - int nnrg; - int mu; - int nu; - ModuleBase::Vector3 dR; - int nw1; - int nw2; -}; - -} \ No newline at end of file diff --git a/source/module_hamilt_lcao/module_gint/grid_meshcell.h b/source/module_hamilt_lcao/module_gint/grid_meshcell.h index 71d57b5e88..67a1863ed0 100644 --- a/source/module_hamilt_lcao/module_gint/grid_meshcell.h +++ b/source/module_hamilt_lcao/module_gint/grid_meshcell.h @@ -18,6 +18,10 @@ class Grid_MeshCell: public Grid_MeshK int nbzp_start,nbzp; // save the position of each meshcell. std::vector> meshcell_pos; + + private: + // latvec0 and GT are not used in current code. + // these two variables may be removed in the future. ModuleBase::Matrix3 meshcell_latvec0; ModuleBase::Matrix3 meshcell_GT; @@ -45,7 +49,7 @@ class Grid_MeshCell: public Grid_MeshK const int &nbzp_in); void init_latvec(const UnitCell &ucell); - void init_meshcell_pos(void); + void init_meshcell_pos(); }; diff --git a/source/module_hamilt_lcao/module_gint/grid_meshk.cpp b/source/module_hamilt_lcao/module_gint/grid_meshk.cpp index b0c491f546..65db07437f 100644 --- a/source/module_hamilt_lcao/module_gint/grid_meshk.cpp +++ b/source/module_hamilt_lcao/module_gint/grid_meshk.cpp @@ -31,25 +31,14 @@ int Grid_MeshK::cal_Rindex(const int &u1, const int &u2, const int &u3)const return (x3 + x2 * this->nu3 + x1 * this->nu2 * this->nu3); } -void Grid_MeshK::init_ucell_para(void) +ModuleBase::Vector3 Grid_MeshK::get_ucell_coords(const int &Rindex)const { - this->max_ucell_para=std::vector(3,0); - this->max_ucell_para[0]=this->maxu1; - this->max_ucell_para[1]=this->maxu2; - this->max_ucell_para[2]=this->maxu3; - - this->min_ucell_para=std::vector(3,0); - this->min_ucell_para[0]=this->minu1; - this->min_ucell_para[1]=this->minu2; - this->min_ucell_para[2]=this->minu3; - - this->num_ucell_para=std::vector(4,0); - this->num_ucell_para[0]=this->nu1; - this->num_ucell_para[1]=this->nu2; - this->num_ucell_para[2]=this->nu3; - this->num_ucell_para[3]=this->nutot; -} + const int x = ucell_index2x[Rindex]; + const int y = ucell_index2y[Rindex]; + const int z = ucell_index2z[Rindex]; + return ModuleBase::Vector3(x, y, z); +} void Grid_MeshK::cal_extended_cell(const int &dxe, const int &dye, const int &dze,const int& nbx, const int& nby, const int& nbz) { @@ -66,8 +55,10 @@ void Grid_MeshK::cal_extended_cell(const int &dxe, const int &dye, const int &dz this->minu2 = (-dye+1) / nby - 1; this->minu3 = (-dze+1) / nbz - 1; - if(PARAM.inp.test_gridt)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"MaxUnitcell",maxu1,maxu2,maxu3); - if(PARAM.inp.test_gridt)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"MinUnitcell",minu1,minu2,minu3); + if(PARAM.inp.test_gridt) {ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"MaxUnitcell",maxu1,maxu2,maxu3); +} + if(PARAM.inp.test_gridt) {ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"MinUnitcell",minu1,minu2,minu3); +} //-------------------------------------- // number of unitcell in each direction. @@ -77,9 +68,10 @@ void Grid_MeshK::cal_extended_cell(const int &dxe, const int &dye, const int &dz this->nu3 = maxu3 - minu3 + 1; this->nutot = nu1 * nu2 * nu3; - init_ucell_para(); - if(PARAM.inp.test_gridt)ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"UnitCellNumber",nu1,nu2,nu3); - if(PARAM.inp.out_level != "m") ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"UnitCellTotal",nutot); + if(PARAM.inp.test_gridt) {ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"UnitCellNumber",nu1,nu2,nu3); +} + if(PARAM.inp.out_level != "m") { ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"UnitCellTotal",nutot); +} this->ucell_index2x = std::vector(nutot, 0); @@ -97,9 +89,9 @@ void Grid_MeshK::cal_extended_cell(const int &dxe, const int &dye, const int &dz const int cell = cal_Rindex(i,j,k); assert(cellucell_index2x[cell] = i-minu1; - this->ucell_index2y[cell] = j-minu2; - this->ucell_index2z[cell] = k-minu3; + this->ucell_index2x[cell] = i; + this->ucell_index2y[cell] = j; + this->ucell_index2z[cell] = k; } } diff --git a/source/module_hamilt_lcao/module_gint/grid_meshk.h b/source/module_hamilt_lcao/module_gint/grid_meshk.h index c541a0b20f..22f27e1c78 100644 --- a/source/module_hamilt_lcao/module_gint/grid_meshk.h +++ b/source/module_hamilt_lcao/module_gint/grid_meshk.h @@ -2,29 +2,23 @@ #define GRID_MESHK_H #include "module_base/global_function.h" #include "module_base/global_variable.h" +#include "module_base/vector3.h" class Grid_MeshK { public: Grid_MeshK(); ~Grid_MeshK(); - // from 1D index to unitcell. - std::vector ucell_index2x; - std::vector ucell_index2y; - std::vector ucell_index2z; - - // the unitcell parameters. - std::vector max_ucell_para; - std::vector min_ucell_para; - std::vector num_ucell_para; // calculate the index of unitcell. int cal_Rindex(const int& u1, const int& u2, const int& u3)const; + ModuleBase::Vector3 get_ucell_coords(const int& Rindex)const; + /// move operator for the next ESolver to directly use its infomation Grid_MeshK& operator=(Grid_MeshK&& rhs) = default; - protected: + private: // the max and the min unitcell. int maxu1; int maxu2; @@ -40,11 +34,15 @@ class Grid_MeshK int nu3; int nutot; + // from 1D index to unitcell. + std::vector ucell_index2x; + std::vector ucell_index2y; + std::vector ucell_index2z; + + protected: // calculate the extended unitcell. void cal_extended_cell(const int &dxe, const int &dye, const int &dze, const int& nbx, const int& nby, const int& nbz); - // initialize the unitcell parameters. - void init_ucell_para(void); }; #endif diff --git a/source/module_hamilt_lcao/module_gint/grid_technique.h b/source/module_hamilt_lcao/module_gint/grid_technique.h index 6f6b5cb095..7a3eac4d19 100644 --- a/source/module_hamilt_lcao/module_gint/grid_technique.h +++ b/source/module_hamilt_lcao/module_gint/grid_technique.h @@ -1,7 +1,6 @@ #ifndef GRID_TECHNIQUE_H #define GRID_TECHNIQUE_H -#include "grid_index.h" #include "grid_meshball.h" #include "module_basis/module_ao/ORB_read.h" #include "module_basis/module_ao/parallel_orbitals.h" @@ -84,9 +83,6 @@ class Grid_Technique : public Grid_MeshBall { std::vector> dpsi_u; std::vector> d2psi_u; - // indexes for nnrg -> orbital index + R index - std::vector nnrg_index; - // Determine whether the grid point integration is initialized. bool init_malloced; @@ -132,19 +128,6 @@ class Grid_Technique : public Grid_MeshBall { // store the information of atom pairs on this processor, used to initialize hcontainer. // The meaning of ijr can be referred to in the get_ijr_info function in hcontainer.cpp. std::vector ijr_info; - int maxB1; - int maxB2; - int maxB3; - - int minB1; - int minB2; - int minB3; - - int nB1; - int nB2; - int nB3; - - int nbox; void cal_max_box_index(); // atoms on meshball diff --git a/source/module_hamilt_lcao/module_gint/gtask_force.cpp b/source/module_hamilt_lcao/module_gint/gtask_force.cpp index c1df50ab7e..186bf37257 100644 --- a/source/module_hamilt_lcao/module_gint/gtask_force.cpp +++ b/source/module_hamilt_lcao/module_gint/gtask_force.cpp @@ -3,6 +3,7 @@ #include "gint_force_gpu.h" #include "module_base/ylm.h" #include "module_hamilt_lcao/module_gint/gint_tools.h" +#include "module_base/vector3.h" namespace GintKernel { @@ -102,12 +103,8 @@ void alloc_mult_force(const hamilt::HContainer* dm, const int mcell_index1 = bcell_start_index + atom1; const int iat1 = gridt.which_atom[mcell_index1]; const int uc1 = gridt.which_unitcell[mcell_index1]; - const int rx1 = gridt.ucell_index2x[uc1]; - const int ry1 = gridt.ucell_index2y[uc1]; - const int rz1 = gridt.ucell_index2z[uc1]; + const ModuleBase::Vector3 r1 = gridt.get_ucell_coords(uc1); const int it1 = ucell.iat2it[iat1]; - const int lo1 - = gridt.trace_lo[ucell.itiaiw2iwt(it1, ucell.iat2ia[iat1], 0)]; const int nw1 = ucell.atoms[it1].nw; for (int atom2 = 0; atom2 < gridt.how_many_atoms[grid_index];atom2++) @@ -115,18 +112,13 @@ void alloc_mult_force(const hamilt::HContainer* dm, const int mcell_index2 = bcell_start_index + atom2; const int iat2 = gridt.which_atom[mcell_index2]; const int uc2 = gridt.which_unitcell[mcell_index2]; - const int rx2 = gridt.ucell_index2x[uc2]; - const int ry2 = gridt.ucell_index2y[uc2]; - const int rz2 = gridt.ucell_index2z[uc2]; - const int offset = dm->find_matrix_offset(iat1, iat2, rx1-rx2, ry1-ry2, rz1-rz2); + const ModuleBase::Vector3 r2 = gridt.get_ucell_coords(uc2); + const int offset = dm->find_matrix_offset(iat1, iat2, r1-r2); if (offset == -1) { continue; } const int it2 = ucell.iat2it[iat2]; - const int lo2 = gridt.trace_lo[ucell.itiaiw2iwt(it2, - ucell.iat2ia[iat2], - 0)]; const int nw2 = ucell.atoms[it2].nw; const int mat_A_idx = (pre_atoms + atom2) * nwmax * gridt.bxyz; diff --git a/source/module_hamilt_lcao/module_gint/gtask_rho.cpp b/source/module_hamilt_lcao/module_gint/gtask_rho.cpp index c24e7ed11a..9a7e618b42 100644 --- a/source/module_hamilt_lcao/module_gint/gtask_rho.cpp +++ b/source/module_hamilt_lcao/module_gint/gtask_rho.cpp @@ -1,6 +1,7 @@ #include "gint_rho_gpu.h" #include "module_base/ylm.h" #include "module_hamilt_lcao/module_gint/gint_tools.h" +#include "module_base/vector3.h" #include "omp.h" namespace GintKernel { @@ -85,12 +86,8 @@ void alloc_mult_dot_rho(const hamilt::HContainer* dm, const int mcell_index1 = bcell_start_index + atom1; const int iat1 = gridt.which_atom[mcell_index1]; const int uc1 = gridt.which_unitcell[mcell_index1]; - const int rx1 = gridt.ucell_index2x[uc1]; - const int ry1 = gridt.ucell_index2y[uc1]; - const int rz1 = gridt.ucell_index2z[uc1]; + const ModuleBase::Vector3 r1 = gridt.get_ucell_coords(uc1); const int it1 = ucell.iat2it[iat1]; - const int lo1 - = gridt.trace_lo[ucell.itiaiw2iwt(it1, ucell.iat2ia[iat1], 0)]; const int nw1 = ucell.atoms[it1].nw; for (int atom2 = atom1; atom2 < gridt.how_many_atoms[grid_index]; @@ -99,18 +96,13 @@ void alloc_mult_dot_rho(const hamilt::HContainer* dm, const int mcell_index2 = bcell_start_index + atom2; const int iat2 = gridt.which_atom[mcell_index2]; const int uc2 = gridt.which_unitcell[mcell_index2]; - const int rx2 = gridt.ucell_index2x[uc2]; - const int ry2 = gridt.ucell_index2y[uc2]; - const int rz2 = gridt.ucell_index2z[uc2]; - const int offset = dm->find_matrix_offset(iat1, iat2, rx1-rx2, ry1-ry2, rz1-rz2); + const ModuleBase::Vector3 r2 = gridt.get_ucell_coords(uc2); + const int offset = dm->find_matrix_offset(iat1, iat2, r1-r2); if (offset == -1) { continue; } const int it2 = ucell.iat2it[iat2]; - const int lo2 = gridt.trace_lo[ucell.itiaiw2iwt(it2, - ucell.iat2ia[iat2], - 0)]; const int nw2 = ucell.atoms[it2].nw; const int mat_A_idx = bcell_start_psir + atom2 * nwmax; diff --git a/source/module_hamilt_lcao/module_gint/gtask_vl.cpp b/source/module_hamilt_lcao/module_gint/gtask_vl.cpp index d4f08750a9..ba09ea0949 100644 --- a/source/module_hamilt_lcao/module_gint/gtask_vl.cpp +++ b/source/module_hamilt_lcao/module_gint/gtask_vl.cpp @@ -3,6 +3,7 @@ #include "gint_vl_gpu.h" #include "module_base/ylm.h" #include "module_hamilt_lcao/module_gint/gint_tools.h" +#include "module_base/vector3.h" namespace GintKernel { @@ -97,19 +98,15 @@ void alloc_mult_vlocal(const hamilt::HContainer* hRGint, { const int iat1 = gridt.which_atom[bcell_start_index + atom1]; const int uc1 = gridt.which_unitcell[bcell_start_index + atom1]; - const int rx1 = gridt.ucell_index2x[uc1]; - const int ry1 = gridt.ucell_index2y[uc1]; - const int rz1 = gridt.ucell_index2z[uc1]; + const ModuleBase::Vector3 r1 = gridt.get_ucell_coords(uc1); const int it1 = ucell.iat2it[iat1]; for (int atom2 = 0; atom2 < atom_num; atom2++) { const int iat2 = gridt.which_atom[bcell_start_index + atom2]; const int uc2 = gridt.which_unitcell[bcell_start_index + atom2]; - const int rx2 = gridt.ucell_index2x[uc2]; - const int ry2 = gridt.ucell_index2y[uc2]; - const int rz2 = gridt.ucell_index2z[uc2]; - int offset = hRGint->find_matrix_offset(iat1, iat2, rx1-rx2, ry1-ry2, rz1-rz2); + const ModuleBase::Vector3 r2 = gridt.get_ucell_coords(uc2); + int offset = hRGint->find_matrix_offset(iat1, iat2, r1-r2); if (offset == -1) { continue; diff --git a/source/module_hamilt_lcao/module_gint/mult_psi_dmr.cpp b/source/module_hamilt_lcao/module_gint/mult_psi_dmr.cpp index cdbd940672..fabe3b0773 100644 --- a/source/module_hamilt_lcao/module_gint/mult_psi_dmr.cpp +++ b/source/module_hamilt_lcao/module_gint/mult_psi_dmr.cpp @@ -32,14 +32,10 @@ void mult_psi_DMR( { const int bcell1 = gt.bcell_start[grid_index] + ia1; const int iat1 = gt.which_atom[bcell1]; - const int T1 = ucell.iat2it[iat1]; - const int I1 = ucell.iat2ia[iat1]; //! get cell R1, this step is redundant in gamma_only case. const int id1 = gt.which_unitcell[bcell1]; - const int R1x = gt.ucell_index2x[id1]; - const int R1y = gt.ucell_index2y[id1]; - const int R1z = gt.ucell_index2z[id1]; + const ModuleBase::Vector3 r1 = gt.get_ucell_coords(id1); //! density if (if_symm) @@ -74,23 +70,14 @@ void mult_psi_DMR( for (int ia2 = start; ia2 < na_grid; ia2++) { const int bcell2 = gt.bcell_start[grid_index] + ia2; - const int T2 = ucell.iat2it[gt.which_atom[bcell2]]; const int iat2 = gt.which_atom[bcell2]; const int id2 = gt.which_unitcell[bcell2]; - - //! get cell R2, this step is redundant in gamma_only case. - const int R2x = gt.ucell_index2x[id2]; - const int R2y = gt.ucell_index2y[id2]; - const int R2z = gt.ucell_index2z[id2]; - //! calculate the 'offset': R2 position relative - //! to R1 atom, this step is redundant in gamma_only case. - const int dRx = R1x - R2x; - const int dRy = R1y - R2y; - const int dRz = R1z - R2z; + //! get cell R2, this step is redundant in gamma_only case. + const ModuleBase::Vector3 r2 = gt.get_ucell_coords(id2); // get AtomPair - const auto tmp_matrix = DM->find_matrix(iat1, iat2, dRx, dRy, dRz); + const auto tmp_matrix = DM->find_matrix(iat1, iat2, r1-r2); if (tmp_matrix == nullptr) { continue;