From 3c5807085d9a7b52782801dbf5f5a9599ac93b56 Mon Sep 17 00:00:00 2001 From: wqzhou <33364058+WHUweiqingzhou@users.noreply.github.com> Date: Thu, 11 Jul 2024 21:37:02 +0800 Subject: [PATCH] Refactor: remove `LCAO_Matrix` from several class (#4645) * remove lm from clear_zero_elements * remove lm from save_HSR_sparse * remove lm from cal_HR_exx * remove lm from output_dHR * remove lm from output_dHR 2 * remove lm from output_dHR 3 * remove lm from output_TR * remove lm from output_TR 2 * remove lm from output_SR * remove lm from out_dos_nao/out_dos_lcao * remove lm from write_proj_band_lcao * remove lm from Output_Sk * fix bug * fix build error of ouput_sk --- source/module_esolver/esolver_ks_lcao.cpp | 6 ++-- .../module_esolver/esolver_ks_lcao_elec.cpp | 4 +-- .../hamilt_lcaodft/LCAO_allocate.cpp | 2 +- .../hamilt_lcaodft/LCAO_hamilt.hpp | 8 ++--- .../hamilt_lcaodft/spar_dh.cpp | 28 +++++++-------- .../hamilt_lcaodft/spar_dh.h | 4 +-- .../hamilt_lcaodft/spar_exx.h | 5 ++- .../hamilt_lcaodft/spar_hsr.cpp | 9 +++-- .../hamilt_lcaodft/spar_hsr.h | 3 +- .../hamilt_lcaodft/spar_st.cpp | 6 ++-- .../hamilt_lcaodft/spar_st.h | 3 -- .../module_hamilt_lcao/module_gint/gint_k.h | 6 ++-- .../module_gint/gint_k_sparse1.cpp | 6 ++-- source/module_io/dos_nao.cpp | 6 +--- source/module_io/dos_nao.h | 1 - source/module_io/output_mat_sparse.cpp | 3 +- source/module_io/output_sk.cpp | 4 +-- source/module_io/output_sk.h | 3 +- source/module_io/restart.h | 5 +-- source/module_io/restart_exx_csr.h | 2 +- .../module_io/test/output_mulliken_mock.cpp | 4 +-- .../module_io/test/output_mulliken_test.cpp | 6 ++-- source/module_io/write_HS.h | 3 -- source/module_io/write_HS_R.cpp | 17 ++++----- source/module_io/write_HS_R.h | 4 +-- source/module_io/write_HS_sparse.cpp | 26 +++++++------- source/module_io/write_HS_sparse.h | 7 ++-- source/module_io/write_dos_lcao.cpp | 3 -- source/module_io/write_dos_lcao.h | 2 -- source/module_io/write_proj_band_lcao.cpp | 35 +++++++++---------- source/module_io/write_proj_band_lcao.h | 4 +-- 31 files changed, 96 insertions(+), 129 deletions(-) diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index 601b77030b..899fa25e4f 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -466,13 +466,12 @@ void ESolver_KS_LCAO::after_all_runners() if (INPUT.out_proj_band) // Projeced band structure added by jiyy-2022-4-20 { - ModuleIO::write_proj_band_lcao(this->psi, this->LM, this->pelec, this->kv, GlobalC::ucell, this->p_hamilt); + ModuleIO::write_proj_band_lcao(this->psi, this->ParaV, this->pelec, this->kv, GlobalC::ucell, this->p_hamilt); } if (INPUT.out_dos) { ModuleIO::out_dos_nao(this->psi, - this->LM, this->ParaV, this->pelec->ekb, this->pelec->wg, @@ -1408,8 +1407,7 @@ void ESolver_KS_LCAO::cal_mag(const int istep, const bool print) GlobalC::ucell.get_atomCounts(), GlobalC::ucell.get_lnchiCounts(), GlobalV::NSPIN); - auto out_sk = ModuleIO::Output_Sk(&(this->LM), - this->p_hamilt, + auto out_sk = ModuleIO::Output_Sk(this->p_hamilt, &(this->ParaV), GlobalV::NSPIN, this->kv.get_nks()); diff --git a/source/module_esolver/esolver_ks_lcao_elec.cpp b/source/module_esolver/esolver_ks_lcao_elec.cpp index cab134de43..aa5baf3a02 100644 --- a/source/module_esolver/esolver_ks_lcao_elec.cpp +++ b/source/module_esolver/esolver_ks_lcao_elec.cpp @@ -559,7 +559,7 @@ void ESolver_KS_LCAO, double>::get_S(void) std::cout << " The file is saved in " << fn << std::endl; - ModuleIO::output_SR(ParaV, this->LM, GlobalC::GridD, this->p_hamilt, fn); + ModuleIO::output_SR(ParaV, GlobalC::GridD, this->p_hamilt, fn); return; } @@ -601,7 +601,7 @@ void ESolver_KS_LCAO, std::complex>::get_S(void) std::cout << " The file is saved in " << fn << std::endl; - ModuleIO::output_SR(ParaV, this->LM, GlobalC::GridD, this->p_hamilt, fn); + ModuleIO::output_SR(ParaV, GlobalC::GridD, this->p_hamilt, fn); return; } diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_allocate.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_allocate.cpp index 1a74ffa001..a948eaed07 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_allocate.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_allocate.cpp @@ -7,7 +7,7 @@ namespace LCAO_domain { void divide_HS_in_frag(const bool isGamma, Parallel_Orbitals& pv,const int& nks) { - ModuleBase::TITLE("LCAO_Matrix", "divide_HS_in_frag"); + ModuleBase::TITLE("LCAO_domain", "divide_HS_in_frag"); //(1), (2): set up matrix division have been moved into ESolver_KS_LCAO::init_basis_lcao // just pass `ParaV` as pointer is enough diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp index 6dff5fd4f0..bc22a889bf 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.hpp @@ -11,8 +11,6 @@ #include "module_base/timer.h" #include "module_hamilt_lcao/hamilt_lcaodft/spar_exx.h" #include "module_ri/RI_2D_Comm.h" -// use LCAO_Matrix -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" #include #include @@ -26,7 +24,7 @@ // Peize Lin add 2022.09.13 template void sparse_format::cal_HR_exx( - LCAO_Matrix& lm, // mohan add 2024-04-06 + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, const int& current_spin, const double& sparse_threshold, @@ -84,7 +82,7 @@ void sparse_format::cal_HR_exx( for (size_t iw0 = 0; iw0 < Hexx.shape[0]; ++iw0) { const int iwt0 = RI_2D_Comm::get_iwt(iat0, iw0, is0_b); - const int iwt0_local = lm.ParaV->global2local_row(iwt0); + const int iwt0_local = pv.global2local_row(iwt0); if (iwt0_local < 0) { continue; @@ -92,7 +90,7 @@ void sparse_format::cal_HR_exx( for (size_t iw1 = 0; iw1 < Hexx.shape[1]; ++iw1) { const int iwt1 = RI_2D_Comm::get_iwt(iat1, iw1, is1_b); - const int iwt1_local = lm.ParaV->global2local_col(iwt1); + const int iwt1_local = pv.global2local_col(iwt1); if (iwt1_local < 0) { continue; diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.cpp index af0d471e3c..ef013ecdfb 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.cpp @@ -2,7 +2,7 @@ #include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h" -void sparse_format::cal_dH(LCAO_Matrix& lm, +void sparse_format::cal_dH(const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, Grid_Driver& grid, const TwoCenterBundle& two_center_bundle, @@ -14,7 +14,7 @@ void sparse_format::cal_dH(LCAO_Matrix& lm, sparse_format::set_R_range(HS_Arrays.all_R_coor, grid); - const int nnr = lm.ParaV->nnr; + const int nnr = pv.nnr; ForceStressArrays fsr_dh; @@ -22,9 +22,9 @@ void sparse_format::cal_dH(LCAO_Matrix& lm, fsr_dh.DHloc_fixedR_y = new double[nnr]; fsr_dh.DHloc_fixedR_z = new double[nnr]; - ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_x, lm.ParaV->nloc); - ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_y, lm.ParaV->nloc); - ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_z, lm.ParaV->nloc); + ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_x, pv.nloc); + ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_y, pv.nloc); + ModuleBase::GlobalFunc::ZEROS(fsr_dh.DHloc_fixedR_z, pv.nloc); // cal dT= in LCAO // cal T + VNL(P1) in LCAO basis if (GlobalV::CAL_STRESS) @@ -36,7 +36,7 @@ void sparse_format::cal_dH(LCAO_Matrix& lm, true, GlobalC::ucell, GlobalC::ORB, - *lm.ParaV, + pv, two_center_bundle, &GlobalC::GridD, nullptr); // delete unused parameter lm.Hloc_fixedR @@ -50,13 +50,13 @@ void sparse_format::cal_dH(LCAO_Matrix& lm, true, GlobalC::ucell, GlobalC::ORB, - *lm.ParaV, + pv, two_center_bundle, &GlobalC::GridD, nullptr); // delete unused parameter lm.Hloc_fixedR } - LCAO_domain::build_Nonlocal_mu_new(*lm.ParaV, + LCAO_domain::build_Nonlocal_mu_new(pv, fsr_dh, nullptr, true, @@ -65,14 +65,14 @@ void sparse_format::cal_dH(LCAO_Matrix& lm, *(two_center_bundle.overlap_orb_beta), &GlobalC::GridD); - sparse_format::cal_dSTN_R(lm, HS_Arrays, fsr_dh, grid, current_spin, sparse_thr); + sparse_format::cal_dSTN_R(pv, HS_Arrays, fsr_dh, grid, current_spin, sparse_thr); delete[] fsr_dh.DHloc_fixedR_x; delete[] fsr_dh.DHloc_fixedR_y; delete[] fsr_dh.DHloc_fixedR_z; gint_k - .cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, lm.ParaV, GlobalC::ucell, GlobalC::GridD); + .cal_dvlocal_R_sparseMatrix(current_spin, sparse_thr, HS_Arrays, &pv, GlobalC::ucell, GlobalC::GridD); return; } @@ -102,7 +102,7 @@ void sparse_format::set_R_range(std::set>& all_R_coor, return; } -void sparse_format::cal_dSTN_R(LCAO_Matrix& lm, +void sparse_format::cal_dSTN_R(const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, ForceStressArrays& fsr, Grid_Driver& grid, @@ -178,7 +178,7 @@ void sparse_format::cal_dSTN_R(LCAO_Matrix& lm, for (int ii = 0; ii < atom1->nw * GlobalV::NPOL; ii++) { const int iw1_all = start + ii; - const int mu = lm.ParaV->global2local_row(iw1_all); + const int mu = pv.global2local_row(iw1_all); if (mu < 0) { @@ -188,7 +188,7 @@ void sparse_format::cal_dSTN_R(LCAO_Matrix& lm, for (int jj = 0; jj < atom2->nw * GlobalV::NPOL; jj++) { int iw2_all = start2 + jj; - const int nu = lm.ParaV->global2local_col(iw2_all); + const int nu = pv.global2local_col(iw2_all); if (nu < 0) { @@ -230,7 +230,7 @@ void sparse_format::cal_dSTN_R(LCAO_Matrix& lm, void sparse_format::destroy_dH_R_sparse(LCAO_HS_Arrays& HS_Arrays) { - ModuleBase::TITLE("LCAO_Matrix", "destroy_dH_R_sparse"); + ModuleBase::TITLE("LCAO_domain", "destroy_dH_R_sparse"); if (GlobalV::NSPIN != 4) { diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.h b/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.h index cc78a8019b..b969e6ff69 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.h +++ b/source/module_hamilt_lcao/hamilt_lcaodft/spar_dh.h @@ -10,7 +10,7 @@ namespace sparse_format { -void cal_dH(LCAO_Matrix& lm, +void cal_dH(const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, Grid_Driver& grid, const TwoCenterBundle& two_center_bundle, @@ -22,7 +22,7 @@ void cal_dH(LCAO_Matrix& lm, void set_R_range(std::set>& all_R_coor, Grid_Driver& grid); // be called by 'cal_dH_sparse' -void cal_dSTN_R(LCAO_Matrix& lm, +void cal_dSTN_R(const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, ForceStressArrays& fsr, // mohan add 2024-06-16 Grid_Driver& grid, diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/spar_exx.h b/source/module_hamilt_lcao/hamilt_lcaodft/spar_exx.h index 317f31202c..a9b7b7156f 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/spar_exx.h +++ b/source/module_hamilt_lcao/hamilt_lcaodft/spar_exx.h @@ -9,16 +9,15 @@ #include #include -// use LCAO_Matrix #include "module_hamilt_lcao/hamilt_lcaodft/LCAO_HS_arrays.hpp" -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" +#include "module_basis/module_ao/parallel_orbitals.h" namespace sparse_format { template void cal_HR_exx( - LCAO_Matrix& lm, + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, const int& current_spin, const double& sparse_thr, diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp index 801c700150..5e089ef8a9 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.cpp @@ -93,14 +93,14 @@ void sparse_format::cal_HSR(const Parallel_Orbitals& pv, // if EXX is considered if (GlobalC::exx_info.info_global.cal_exx) { if (GlobalC::exx_info.info_ri.real_number) { - sparse_format::cal_HR_exx(lm, + sparse_format::cal_HR_exx(pv, HS_Arrays, current_spin, sparse_thr, nmp, *lm.Hexxd); } else { - sparse_format::cal_HR_exx(lm, + sparse_format::cal_HR_exx(pv, HS_Arrays, current_spin, sparse_thr, @@ -111,7 +111,7 @@ void sparse_format::cal_HSR(const Parallel_Orbitals& pv, #endif // __MPI #endif // __EXX - sparse_format::clear_zero_elements(lm, HS_Arrays, current_spin, sparse_thr); + sparse_format::clear_zero_elements(HS_Arrays, current_spin, sparse_thr); return; } @@ -237,8 +237,7 @@ void sparse_format::cal_HContainer_td( } // in case there are elements smaller than the threshold -void sparse_format::clear_zero_elements(LCAO_Matrix& lm, - LCAO_HS_Arrays& HS_Arrays, +void sparse_format::clear_zero_elements(LCAO_HS_Arrays& HS_Arrays, const int& current_spin, const double& sparse_thr) { ModuleBase::TITLE("sparse_format", "clear_zero_elements"); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.h b/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.h index 13dd667019..e4c438763b 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.h +++ b/source/module_hamilt_lcao/hamilt_lcaodft/spar_hsr.h @@ -39,8 +39,7 @@ void cal_HContainer_td( std::map, std::map>>>& target); -void clear_zero_elements(LCAO_Matrix& lm, - LCAO_HS_Arrays& HS_Arrays, +void clear_zero_elements(LCAO_HS_Arrays& HS_Arrays, const int& current_spin, const double& sparse_thr); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.cpp index df36a98954..1a20086a09 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.cpp @@ -54,7 +54,6 @@ void sparse_format::cal_SR( void sparse_format::cal_TR(const UnitCell& ucell, const Parallel_Orbitals& pv, - LCAO_Matrix& lm, LCAO_HS_Arrays& HS_Arrays, Grid_Driver& grid, const TwoCenterBundle& two_center_bundle, @@ -62,7 +61,7 @@ void sparse_format::cal_TR(const UnitCell& ucell, ModuleBase::TITLE("sparse_format", "cal_TR"); // need to rebuild T(R) - HS_Arrays.Hloc_fixedR.resize(lm.ParaV->nnr); + HS_Arrays.Hloc_fixedR.resize(pv.nnr); LCAO_domain::zeros_HSR('T', HS_Arrays); @@ -82,14 +81,13 @@ void sparse_format::cal_TR(const UnitCell& ucell, sparse_format::set_R_range(HS_Arrays.all_R_coor, grid); - sparse_format::cal_STN_R_for_T(ucell, pv, lm, HS_Arrays, grid, sparse_thr); + sparse_format::cal_STN_R_for_T(ucell, pv, HS_Arrays, grid, sparse_thr); return; } void sparse_format::cal_STN_R_for_T(const UnitCell& ucell, const Parallel_Orbitals& pv, - LCAO_Matrix& lm, LCAO_HS_Arrays& HS_arrays, Grid_Driver& grid, const double& sparse_thr) { diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.h b/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.h index cad9e0d708..06749e6a21 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.h +++ b/source/module_hamilt_lcao/hamilt_lcaodft/spar_st.h @@ -2,7 +2,6 @@ #define SPARSE_FORMAT_ST_H #include "module_hamilt_lcao/hamilt_lcaodft/LCAO_HS_arrays.hpp" -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" #include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h" namespace sparse_format { @@ -21,7 +20,6 @@ void cal_SR(const Parallel_Orbitals& pv, //! calculate kinetic matrix with lattice vector R void cal_TR(const UnitCell& ucell, const Parallel_Orbitals& pv, - LCAO_Matrix& lm, LCAO_HS_Arrays& HS_arrays, Grid_Driver& grid, const TwoCenterBundle& two_center_bundle, @@ -30,7 +28,6 @@ void cal_TR(const UnitCell& ucell, //! cal_STN_R_for_T is only called by cal_TR void cal_STN_R_for_T(const UnitCell& ucell, const Parallel_Orbitals& pv, - LCAO_Matrix& lm, LCAO_HS_Arrays& HS_arrays, Grid_Driver& grid, const double& sparse_thr); diff --git a/source/module_hamilt_lcao/module_gint/gint_k.h b/source/module_hamilt_lcao/module_gint/gint_k.h index e7c8954aa3..b3b0b90111 100644 --- a/source/module_hamilt_lcao/module_gint/gint_k.h +++ b/source/module_hamilt_lcao/module_gint/gint_k.h @@ -83,7 +83,7 @@ class Gint_k : public Gint { std::map>>& pvdpR_sparseMatrix, LCAO_HS_Arrays& HS_Arrays, - Parallel_Orbitals* pv); + const Parallel_Orbitals* pv); void distribute_pvdpR_soc_sparseMatrix( const int dim, @@ -93,12 +93,12 @@ class Gint_k : public Gint { std::map>>>& pvdpR_soc_sparseMatrix, LCAO_HS_Arrays& HS_Arrays, - Parallel_Orbitals* pv); + const Parallel_Orbitals* pv); void cal_dvlocal_R_sparseMatrix(const int& current_spin, const double& sparse_threshold, LCAO_HS_Arrays& HS_Arrays, - Parallel_Orbitals* pv, + const Parallel_Orbitals* pv, UnitCell& ucell, Grid_Driver& gdriver); 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 355b5f4313..49678592e0 100644 --- a/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp +++ b/source/module_hamilt_lcao/module_gint/gint_k_sparse1.cpp @@ -16,7 +16,7 @@ void Gint_k::distribute_pvdpR_sparseMatrix( const double& sparse_threshold, const std::map, std::map>>& pvdpR_sparseMatrix, LCAO_HS_Arrays& HS_Arrays, - Parallel_Orbitals* pv) + const Parallel_Orbitals* pv) { ModuleBase::TITLE("Gint_k", "distribute_pvdpR_sparseMatrix"); @@ -170,7 +170,7 @@ void Gint_k::distribute_pvdpR_soc_sparseMatrix( const std::map, std::map>>>& pvdpR_soc_sparseMatrix, LCAO_HS_Arrays& HS_Arrays, - Parallel_Orbitals* pv) + const Parallel_Orbitals* pv) { ModuleBase::TITLE("Gint_k", "distribute_pvdpR_soc_sparseMatrix"); @@ -320,7 +320,7 @@ void Gint_k::distribute_pvdpR_soc_sparseMatrix( void Gint_k::cal_dvlocal_R_sparseMatrix(const int& current_spin, const double& sparse_threshold, LCAO_HS_Arrays& HS_Arrays, - Parallel_Orbitals* pv, + const Parallel_Orbitals* pv, UnitCell& ucell, Grid_Driver& gdriver) { diff --git a/source/module_io/dos_nao.cpp b/source/module_io/dos_nao.cpp index 1a36df5f12..be18094fdb 100644 --- a/source/module_io/dos_nao.cpp +++ b/source/module_io/dos_nao.cpp @@ -7,7 +7,6 @@ namespace ModuleIO { /// @brief manege the output of dos in numerical atomic basis case /// @param[in] psi -/// @param[in] lm /// @param[in] pv /// @param[in] ekb /// @param[in] wg @@ -22,7 +21,6 @@ namespace ModuleIO template void out_dos_nao( const psi::Psi* psi, - LCAO_Matrix &lm, const Parallel_Orbitals &pv, const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, @@ -38,7 +36,7 @@ namespace ModuleIO { ModuleBase::TITLE("Module_IO", "out_dos_nao"); - write_dos_lcao(psi, lm, pv, ekb, wg, dos_edelta_ev, dos_scale, dos_sigma, kv, p_ham); + write_dos_lcao(psi, pv, ekb, wg, dos_edelta_ev, dos_scale, dos_sigma, kv, p_ham); int nspin0 = (GlobalV::NSPIN == 2) ? 2 : 1; if (INPUT.out_dos == 3) @@ -64,7 +62,6 @@ namespace ModuleIO template void out_dos_nao( const psi::Psi* psi, - LCAO_Matrix &lm, const Parallel_Orbitals &pv, const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, @@ -80,7 +77,6 @@ template void out_dos_nao( template void out_dos_nao( const psi::Psi>* psi, - LCAO_Matrix &lm, const Parallel_Orbitals &pv, const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, diff --git a/source/module_io/dos_nao.h b/source/module_io/dos_nao.h index b40bc19f41..aa3207f432 100644 --- a/source/module_io/dos_nao.h +++ b/source/module_io/dos_nao.h @@ -11,7 +11,6 @@ namespace ModuleIO template void out_dos_nao( const psi::Psi* psi, - LCAO_Matrix &lm, const Parallel_Orbitals &pv, const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, diff --git a/source/module_io/output_mat_sparse.cpp b/source/module_io/output_mat_sparse.cpp index eabcdb1648..9d6bf53b0b 100644 --- a/source/module_io/output_mat_sparse.cpp +++ b/source/module_io/output_mat_sparse.cpp @@ -50,7 +50,6 @@ void Output_Mat_Sparse>::write() output_TR(_istep, GlobalC::ucell, this->_pv, - this->_lm, HS_Arrays, this->_grid, two_center_bundle_); // LiuXh add 2019-07-15 @@ -62,7 +61,7 @@ void Output_Mat_Sparse>::write() output_dHR(_istep, this->_v_eff, this->_gint_k, // mohan add 2024-04-01 - this->_lm, + this->_pv, HS_Arrays, this->_grid, // mohan add 2024-04-06 two_center_bundle_, diff --git a/source/module_io/output_sk.cpp b/source/module_io/output_sk.cpp index 96c0663579..c3f2359d19 100644 --- a/source/module_io/output_sk.cpp +++ b/source/module_io/output_sk.cpp @@ -6,8 +6,8 @@ namespace ModuleIO { template -Output_Sk::Output_Sk(LCAO_Matrix* LM, hamilt::Hamilt* p_hamilt, Parallel_Orbitals* ParaV, int nspin, int nks) - : LM_(LM), p_hamilt_(p_hamilt), ParaV_(ParaV), nspin_(nspin), nks_(nks) +Output_Sk::Output_Sk(hamilt::Hamilt* p_hamilt, Parallel_Orbitals* ParaV, int nspin, int nks) + : p_hamilt_(p_hamilt), ParaV_(ParaV), nspin_(nspin), nks_(nks) { } diff --git a/source/module_io/output_sk.h b/source/module_io/output_sk.h index 005db5e1a1..fceba4e871 100644 --- a/source/module_io/output_sk.h +++ b/source/module_io/output_sk.h @@ -12,12 +12,11 @@ class Output_Sk { public: /// constructur of Output_Sk - Output_Sk(LCAO_Matrix* LM, hamilt::Hamilt* p_hamilt, Parallel_Orbitals* ParaV, int nspin, int nks); + Output_Sk(hamilt::Hamilt* p_hamilt, Parallel_Orbitals* ParaV, int nspin, int nks); /// @brief the function to get Sk for a given k-point TK* get_Sk(int ik); private: - LCAO_Matrix* LM_ = nullptr; hamilt::Hamilt* p_hamilt_ = nullptr; Parallel_Orbitals* ParaV_ = nullptr; int nks_; diff --git a/source/module_io/restart.h b/source/module_io/restart.h index 4de577a29f..c5f97bcca9 100644 --- a/source/module_io/restart.h +++ b/source/module_io/restart.h @@ -3,8 +3,9 @@ #include #include "module_base/global_function.h" -#ifdef __LCAO -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" +#include "module_base/abfs-vector3_order.h" +#ifdef __EXX +#include #endif class Restart { diff --git a/source/module_io/restart_exx_csr.h b/source/module_io/restart_exx_csr.h index e722d80e8b..7dbb778c2b 100644 --- a/source/module_io/restart_exx_csr.h +++ b/source/module_io/restart_exx_csr.h @@ -21,7 +21,7 @@ namespace ModuleIO const std::map>>& Hexxs); /// calculate CSR sparse matrix from the global matrix stored with RI::Tensor - /// the return type is same as LCAO_Matrix::SR_sparse, HR_sparse, etc. + /// the return type is same as SR_sparse, HR_sparse, etc. template std::map, std::map>> calculate_RI_Tensor_sparse(const double& sparse_threshold, diff --git a/source/module_io/test/output_mulliken_mock.cpp b/source/module_io/test/output_mulliken_mock.cpp index cd6e66ad76..e03db49db9 100644 --- a/source/module_io/test/output_mulliken_mock.cpp +++ b/source/module_io/test/output_mulliken_mock.cpp @@ -128,8 +128,8 @@ template class Output_DMK; template class Output_DMK>; template -Output_Sk::Output_Sk(LCAO_Matrix* LM, hamilt::Hamilt* p_hamilt, Parallel_Orbitals* ParaV, int nspin, int nks) - : LM_(LM), p_hamilt_(p_hamilt), ParaV_(ParaV), nspin_(nspin), nks_(nks) +Output_Sk::Output_Sk(hamilt::Hamilt* p_hamilt, Parallel_Orbitals* ParaV, int nspin, int nks) + : p_hamilt_(p_hamilt), ParaV_(ParaV), nspin_(nspin), nks_(nks) { } diff --git a/source/module_io/test/output_mulliken_test.cpp b/source/module_io/test/output_mulliken_test.cpp index fac1a1900a..a400300353 100644 --- a/source/module_io/test/output_mulliken_test.cpp +++ b/source/module_io/test/output_mulliken_test.cpp @@ -41,7 +41,7 @@ TYPED_TEST(OutputMullikenTest, nspin1) this->ncol = 13; this->paraV.init(this->nrow, this->ncol, 1, MPI_COMM_WORLD, 0); auto cell_index = CellIndex(this->atomLabels, this->atomCounts, this->lnchiCounts, 1); - auto out_sk = ModuleIO::Output_Sk(nullptr, nullptr, &this->paraV, 1, 1); + auto out_sk = ModuleIO::Output_Sk(nullptr, &this->paraV, 1, 1); auto out_dmk = ModuleIO::Output_DMK(nullptr, &this->paraV, 1, 1); auto mulp = ModuleIO::Output_Mulliken(&(out_sk), &(out_dmk), &(this->paraV), &(cell_index), {0}, 1); mulp.write(0, "./"); @@ -60,7 +60,7 @@ TYPED_TEST(OutputMullikenTest, nspin2) this->ncol = 13; this->paraV.init(this->nrow, this->ncol, 1, MPI_COMM_WORLD, 0); auto cell_index = CellIndex(this->atomLabels, this->atomCounts, this->lnchiCounts, 2); - auto out_sk = ModuleIO::Output_Sk(nullptr, nullptr, &this->paraV, 2, 1); + auto out_sk = ModuleIO::Output_Sk(nullptr, &this->paraV, 2, 1); auto out_dmk = ModuleIO::Output_DMK(nullptr, &this->paraV, 2, 1); auto mulp = ModuleIO::Output_Mulliken(&(out_sk), &(out_dmk), &(this->paraV), &(cell_index), {0, 1}, 2); mulp.write(0, "./"); @@ -83,7 +83,7 @@ TYPED_TEST(OutputMullikenTest, nspin4) this->ncol = 26; this->paraV.init(this->nrow, this->ncol, 1, MPI_COMM_WORLD, 0); auto cell_index = CellIndex(this->atomLabels, this->atomCounts, this->lnchiCounts, 4); - auto out_sk = ModuleIO::Output_Sk>(nullptr, nullptr, &this->paraV, 4, 1); + auto out_sk = ModuleIO::Output_Sk>(nullptr, &this->paraV, 4, 1); auto out_dmk = ModuleIO::Output_DMK>(nullptr, &this->paraV, 4, 1); auto mulp = ModuleIO::Output_Mulliken>(&(out_sk), &(out_dmk), &(this->paraV), &(cell_index), {0}, 4); diff --git a/source/module_io/write_HS.h b/source/module_io/write_HS.h index 31eace2cff..0a9225d684 100644 --- a/source/module_io/write_HS.h +++ b/source/module_io/write_HS.h @@ -3,7 +3,6 @@ #include "module_base/global_function.h" #include "module_base/global_variable.h" -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" #include @@ -33,8 +32,6 @@ namespace ModuleIO const Parallel_2D& pv, const int drank); - // comment out this function for not used - // void save_HSR_tr(const int current_spin, LCAO_Matrix& lm); // LiuXh add 2019-07-15 // mohan comment out 2021-02-10 // void save_HS_ccf(const int &iter, const int &Hnnz, const int *colptr_H, const int *rowind_H, diff --git a/source/module_io/write_HS_R.cpp b/source/module_io/write_HS_R.cpp index 3edc7eb28a..12dc6728bf 100644 --- a/source/module_io/write_HS_R.cpp +++ b/source/module_io/write_HS_R.cpp @@ -72,7 +72,7 @@ void ModuleIO::output_HSR(const int& istep, } ModuleIO::save_HSR_sparse(istep, - lm, + pv, HS_Arrays, sparse_thr, binary, @@ -89,7 +89,7 @@ void ModuleIO::output_HSR(const int& istep, void ModuleIO::output_dHR(const int& istep, const ModuleBase::matrix& v_eff, Gint_k& gint_k, // mohan add 2024-04-01 - LCAO_Matrix& lm, // mohan add 2024-04-01 + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, Grid_Driver& grid, // mohan add 2024-04-06 const TwoCenterBundle& two_center_bundle, @@ -107,7 +107,7 @@ void ModuleIO::output_dHR(const int& istep, // mohan add 2024-04-01 const int cspin = 0; - sparse_format::cal_dH(lm, + sparse_format::cal_dH(pv, HS_Arrays, grid, two_center_bundle, @@ -130,7 +130,7 @@ void ModuleIO::output_dHR(const int& istep, } } - sparse_format::cal_dH(lm, + sparse_format::cal_dH(pv, HS_Arrays, grid, two_center_bundle, @@ -140,7 +140,7 @@ void ModuleIO::output_dHR(const int& istep, } } // mohan update 2024-04-01 - ModuleIO::save_dH_sparse(istep, lm, HS_Arrays, sparse_thr, binary); + ModuleIO::save_dH_sparse(istep, pv, HS_Arrays, sparse_thr, binary); sparse_format::destroy_dH_R_sparse(HS_Arrays); @@ -151,7 +151,6 @@ void ModuleIO::output_dHR(const int& istep, } void ModuleIO::output_SR(Parallel_Orbitals& pv, - LCAO_Matrix& lm, Grid_Driver& grid, hamilt::Hamilt>* p_ham, const std::string& SR_filename, @@ -177,7 +176,7 @@ void ModuleIO::output_SR(Parallel_Orbitals& pv, sparse_thr, binary, SR_filename, - *lm.ParaV, + pv, "S", istep); @@ -190,7 +189,6 @@ void ModuleIO::output_SR(Parallel_Orbitals& pv, void ModuleIO::output_TR(const int istep, const UnitCell& ucell, const Parallel_Orbitals& pv, - LCAO_Matrix& lm, LCAO_HS_Arrays& HS_Arrays, Grid_Driver& grid, const TwoCenterBundle& two_center_bundle, @@ -209,7 +207,6 @@ void ModuleIO::output_TR(const int istep, sparse_format::cal_TR(ucell, pv, - lm, HS_Arrays, grid, two_center_bundle, @@ -220,7 +217,7 @@ void ModuleIO::output_TR(const int istep, sparse_thr, binary, sst.str().c_str(), - *(lm.ParaV), + pv, "T", istep); diff --git a/source/module_io/write_HS_R.h b/source/module_io/write_HS_R.h index 4e6412a8df..d9b6c21b60 100644 --- a/source/module_io/write_HS_R.h +++ b/source/module_io/write_HS_R.h @@ -28,7 +28,7 @@ void output_HSR(const int& istep, void output_dHR(const int& istep, const ModuleBase::matrix& v_eff, Gint_k& gint_k, // mohan add 2024-04-01 - LCAO_Matrix& lm, // mohan add 2024-04-01 + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, Grid_Driver& grid, // mohan add 2024-04-06 const TwoCenterBundle& two_center_bundle, @@ -39,7 +39,6 @@ void output_dHR(const int& istep, void output_TR(const int istep, const UnitCell& ucell, const Parallel_Orbitals& pv, - LCAO_Matrix& lm, LCAO_HS_Arrays& HS_Arrays, Grid_Driver& grid, const TwoCenterBundle& two_center_bundle, @@ -48,7 +47,6 @@ void output_TR(const int istep, const double& sparse_threshold = 1e-10); void output_SR(Parallel_Orbitals& pv, - LCAO_Matrix& lm, Grid_Driver& grid, hamilt::Hamilt>* p_ham, const std::string& SR_filename = "data-SR-sparse_SPIN0.csr", diff --git a/source/module_io/write_HS_sparse.cpp b/source/module_io/write_HS_sparse.cpp index 39195ca58e..b7a05baf8d 100644 --- a/source/module_io/write_HS_sparse.cpp +++ b/source/module_io/write_HS_sparse.cpp @@ -7,7 +7,7 @@ #include "single_R_io.h" void ModuleIO::save_HSR_sparse(const int& istep, - LCAO_Matrix& lm, + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, const double& sparse_thr, const bool& binary, @@ -253,20 +253,20 @@ void ModuleIO::save_HSR_sparse(const int& istep, ->HR_sparse_td_vel[ispin][R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } else { output_single_R(g1[ispin], HR_sparse_ptr[ispin][R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } } else { output_single_R(g1[ispin], HR_soc_sparse_ptr[R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } } } @@ -291,13 +291,13 @@ void ModuleIO::save_HSR_sparse(const int& istep, SR_sparse_ptr[R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } else { output_single_R(g2, SR_soc_sparse_ptr[R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } } @@ -323,7 +323,7 @@ void ModuleIO::save_HSR_sparse(const int& istep, } void ModuleIO::save_dH_sparse(const int& istep, - LCAO_Matrix& lm, + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, const double& sparse_thr, const bool& binary) { @@ -601,13 +601,13 @@ void ModuleIO::save_dH_sparse(const int& istep, dHRx_sparse_ptr[ispin][R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } else { output_single_R(g1x[ispin], dHRx_soc_sparse_ptr[R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } } if (dHy_nonzero_num[ispin][count] > 0) { @@ -616,13 +616,13 @@ void ModuleIO::save_dH_sparse(const int& istep, dHRy_sparse_ptr[ispin][R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } else { output_single_R(g1y[ispin], dHRy_soc_sparse_ptr[R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } } if (dHz_nonzero_num[ispin][count] > 0) { @@ -631,13 +631,13 @@ void ModuleIO::save_dH_sparse(const int& istep, dHRz_sparse_ptr[ispin][R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } else { output_single_R(g1z[ispin], dHRz_soc_sparse_ptr[R_coor], sparse_thr, binary, - *lm.ParaV); + pv); } } } diff --git a/source/module_io/write_HS_sparse.h b/source/module_io/write_HS_sparse.h index a27221f43e..d600471a4a 100644 --- a/source/module_io/write_HS_sparse.h +++ b/source/module_io/write_HS_sparse.h @@ -3,7 +3,8 @@ #include "module_base/global_function.h" #include "module_base/global_variable.h" -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" +#include "module_basis/module_ao/parallel_orbitals.h" +#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_HS_arrays.hpp" #include @@ -12,7 +13,7 @@ namespace ModuleIO // jingan add 2021-6-4, modify 2021-12-2 void save_HSR_sparse(const int& istep, - LCAO_Matrix& lm, + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, const double& sparse_thr, const bool& binary, @@ -21,7 +22,7 @@ void save_HSR_sparse(const int& istep, const std::string& HR_filename_down); void save_dH_sparse(const int& istep, - LCAO_Matrix& lm, + const Parallel_Orbitals& pv, LCAO_HS_Arrays& HS_Arrays, const double& sparse_thr, const bool& binary); diff --git a/source/module_io/write_dos_lcao.cpp b/source/module_io/write_dos_lcao.cpp index 0c8b917265..1559889e5b 100644 --- a/source/module_io/write_dos_lcao.cpp +++ b/source/module_io/write_dos_lcao.cpp @@ -16,7 +16,6 @@ #ifdef __LCAO #include "module_cell/module_neighbor/sltk_atom_arrange.h" //qifeng-2019-01-21 #include "module_cell/module_neighbor/sltk_grid_driver.h" -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" #include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h" #endif @@ -28,7 +27,6 @@ template <> void ModuleIO::write_dos_lcao(const psi::Psi* psi, - LCAO_Matrix& lm, const Parallel_Orbitals& pv, const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, @@ -343,7 +341,6 @@ void ModuleIO::write_dos_lcao(const psi::Psi* psi, template <> void ModuleIO::write_dos_lcao(const psi::Psi>* psi, - LCAO_Matrix& lm, const Parallel_Orbitals& pv, const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, diff --git a/source/module_io/write_dos_lcao.h b/source/module_io/write_dos_lcao.h index 3abdb16178..ebfd057a34 100644 --- a/source/module_io/write_dos_lcao.h +++ b/source/module_io/write_dos_lcao.h @@ -6,7 +6,6 @@ #include "module_psi/psi.h" #include "module_hamilt_general/hamilt.h" #include "module_basis/module_ao/parallel_orbitals.h" -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" namespace ModuleIO { @@ -14,7 +13,6 @@ namespace ModuleIO template void write_dos_lcao( const psi::Psi* psi, - LCAO_Matrix &lm, const Parallel_Orbitals &pv, const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, diff --git a/source/module_io/write_proj_band_lcao.cpp b/source/module_io/write_proj_band_lcao.cpp index 32425dc130..98bae4eb56 100644 --- a/source/module_io/write_proj_band_lcao.cpp +++ b/source/module_io/write_proj_band_lcao.cpp @@ -11,7 +11,7 @@ template<> void ModuleIO::write_proj_band_lcao( const psi::Psi* psi, - LCAO_Matrix& lm, + const Parallel_Orbitals &pv, const elecstate::ElecState* pelec, const K_Vectors& kv, const UnitCell &ucell, @@ -20,7 +20,6 @@ void ModuleIO::write_proj_band_lcao( ModuleBase::TITLE("ModuleIO", "write_proj_band_lcao"); ModuleBase::timer::tick("ModuleIO", "write_proj_band_lcao"); - const Parallel_Orbitals* pv = lm.ParaV; // get the date pointer of SK const double* sk = dynamic_cast*>(p_ham)->getSk(); @@ -48,7 +47,7 @@ void ModuleIO::write_proj_band_lcao( { std::vector Mulk; Mulk.resize(1); - Mulk[0].create(pv->ncol, pv->nrow); + Mulk[0].create(pv.ncol, pv.nrow); psi->fix_k(is); for (int i = 0; i < GlobalV::NBANDS; ++i) @@ -66,26 +65,26 @@ void ModuleIO::write_proj_band_lcao( sk, &one_int, &one_int, - pv->desc, + pv.desc, psi->get_pointer(), &one_int, &NB, - pv->desc, + pv.desc, &one_int, &zero_float, Mulk[0].c, &one_int, &NB, - pv->desc, + pv.desc, &one_int); #endif for (int j = 0; j < GlobalV::NLOCAL; ++j) { - if (pv->in_this_processor(j, i)) + 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) * psi[0](ic, ir); } } @@ -168,7 +167,7 @@ void ModuleIO::write_proj_band_lcao( template<> void ModuleIO::write_proj_band_lcao( const psi::Psi>* psi, - LCAO_Matrix& lm, + const Parallel_Orbitals &pv, const elecstate::ElecState* pelec, const K_Vectors& kv, const UnitCell& ucell, @@ -177,8 +176,6 @@ void ModuleIO::write_proj_band_lcao( ModuleBase::TITLE("ModuleIO", "write_proj_band_lcao"); ModuleBase::timer::tick("ModuleIO", "write_proj_band_lcao"); - const Parallel_Orbitals* pv = lm.ParaV; - int nspin0 = 1; if (GlobalV::NSPIN == 2) nspin0 = 2; @@ -202,7 +199,7 @@ void ModuleIO::write_proj_band_lcao( { std::vector Mulk; Mulk.resize(1); - Mulk[0].create(pv->ncol, pv->nrow); + Mulk[0].create(pv.ncol, pv.nrow); for (int ik = 0; ik < kv.get_nks(); ik++) { @@ -246,27 +243,27 @@ void ModuleIO::write_proj_band_lcao( sk, &one_int, &one_int, - pv->desc, + pv.desc, p_dwfc, &one_int, &NB, - pv->desc, + pv.desc, &one_int, &zero_float[0], Mulk[0].c, &one_int, &NB, - pv->desc, + pv.desc, &one_int); #endif for (int j = 0; j < GlobalV::NLOCAL; ++j) { - if (pv->in_this_processor(j, i)) + 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_io/write_proj_band_lcao.h b/source/module_io/write_proj_band_lcao.h index 1da65b6169..89cb6e6f7d 100644 --- a/source/module_io/write_proj_band_lcao.h +++ b/source/module_io/write_proj_band_lcao.h @@ -5,16 +5,16 @@ #include "module_cell/module_neighbor/sltk_grid_driver.h" #include "module_cell/unitcell.h" #include "module_elecstate/elecstate.h" -#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_matrix.h" #include "module_psi/psi.h" #include "module_hamilt_general/hamilt.h" +#include "module_basis/module_ao/parallel_orbitals.h" namespace ModuleIO { template void write_proj_band_lcao( const psi::Psi* psi, - LCAO_Matrix& lm, + const Parallel_Orbitals &pv, const elecstate::ElecState* pelec, const K_Vectors& kv, const UnitCell &ucell,