From 417c8655cec95976b4d0ddcea903e3938b773137 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sat, 27 Jul 2024 19:45:58 +0800 Subject: [PATCH] seperate out set_matrix_grid.cpp --- source/Makefile.Objects | 1 + source/module_esolver/CMakeLists.txt | 1 + source/module_esolver/set_matrix_grid.cpp | 121 ++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 source/module_esolver/set_matrix_grid.cpp diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 368d5d5e5e..2319325739 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -247,6 +247,7 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\ esolver_ks_lcao_tddft.o\ dpks_cal_e_delta_band.cpp.o\ dftu_cal_occup_m.o\ + set_matrix_grid.o\ io_npz.o\ OBJS_GINT=gint.o\ diff --git a/source/module_esolver/CMakeLists.txt b/source/module_esolver/CMakeLists.txt index 036c132a2f..932d501851 100644 --- a/source/module_esolver/CMakeLists.txt +++ b/source/module_esolver/CMakeLists.txt @@ -19,6 +19,7 @@ if(ENABLE_LCAO) esolver_ks_lcao_tddft.cpp dpks_cal_e_delta_band.cpp io_npz.cpp + set_matrix_grid.cpp dftu_cal_occup_m.cpp ) endif() diff --git a/source/module_esolver/set_matrix_grid.cpp b/source/module_esolver/set_matrix_grid.cpp new file mode 100644 index 0000000000..ae25bc2bb3 --- /dev/null +++ b/source/module_esolver/set_matrix_grid.cpp @@ -0,0 +1,121 @@ +#include "esolver_ks_lcao.h" + +/* +#include "module_elecstate/module_charge/symmetry_rho.h" +#include "module_esolver/esolver_ks_lcao.h" +#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h" +#include "module_hamilt_lcao/module_dftu/dftu.h" +#include "module_hamilt_pw/hamilt_pwdft/global.h" +// +#include "module_base/timer.h" +#include "module_cell/module_neighbor/sltk_atom_arrange.h" +#include "module_cell/module_neighbor/sltk_grid_driver.h" +#include "module_io/berryphase.h" +#include "module_io/istate_charge.h" +#include "module_io/istate_envelope.h" +#include "module_io/to_wannier90_lcao.h" +#include "module_io/to_wannier90_lcao_in_pw.h" +#include "module_io/write_HS_R.h" +#include "module_parameter/parameter.h" +#ifdef __DEEPKS +#include "module_hamilt_lcao/module_deepks/LCAO_deepks.h" +#endif +#include "module_elecstate/elecstate_lcao.h" +#include "module_elecstate/module_dm/cal_dm_psi.h" +#include "module_hamilt_general/module_ewald/H_Ewald_pw.h" +#include "module_hamilt_general/module_vdw/vdw.h" +#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_domain.h" +#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.h" +#include "module_hamilt_lcao/hamilt_lcaodft/operator_lcao/operator_lcao.h" +#include "module_hamilt_lcao/module_deltaspin/spin_constrain.h" +#include "module_io/rho_io.h" +#include "module_io/write_pot.h" +#include "module_io/write_wfc_nao.h" +#include "module_io/read_wfc_nao.h" +#include "module_base/formatter.h" +#ifdef __EXX +#include "module_io/restart_exx_csr.h" +#endif +*/ + + +namespace ModuleESolver +{ + +template +void ESolver_KS_LCAO::set_matrix_grid(Record_adj& ra) +{ + ModuleBase::TITLE("ESolver_KS_LCAO", "set_matrix_grid"); + ModuleBase::timer::tick("ESolver_KS_LCAO", "set_matrix_grid"); + + // (1) Find adjacent atoms for each atom. + GlobalV::SEARCH_RADIUS = atom_arrange::set_sr_NL(GlobalV::ofs_running, + GlobalV::OUT_LEVEL, + GlobalC::ORB.get_rcutmax_Phi(), + GlobalC::ucell.infoNL.get_rcutmax_Beta(), + GlobalV::GAMMA_ONLY_LOCAL); + + atom_arrange::search(PARAM.inp.search_pbc, + GlobalV::ofs_running, + GlobalC::GridD, + GlobalC::ucell, + GlobalV::SEARCH_RADIUS, + GlobalV::test_atom_input); + + // ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running,"SEARCH ADJACENT + // ATOMS"); + + // (3) Periodic condition search for each grid. + double dr_uniform = 0.001; + std::vector rcuts; + std::vector> psi_u; + std::vector> dpsi_u; + std::vector> d2psi_u; + + Gint_Tools::init_orb(dr_uniform, rcuts, GlobalC::ucell, psi_u, dpsi_u, d2psi_u); + + this->GridT.set_pbc_grid(this->pw_rho->nx, + this->pw_rho->ny, + this->pw_rho->nz, + this->pw_big->bx, + this->pw_big->by, + this->pw_big->bz, + this->pw_big->nbx, + this->pw_big->nby, + this->pw_big->nbz, + this->pw_big->nbxx, + this->pw_big->nbzp_start, + this->pw_big->nbzp, + this->pw_rho->ny, + this->pw_rho->nplane, + this->pw_rho->startz_current, + GlobalC::ucell, + dr_uniform, + rcuts, + psi_u, + dpsi_u, + d2psi_u, + PARAM.inp.nstream); + psi_u.clear(); + psi_u.shrink_to_fit(); + dpsi_u.clear(); + dpsi_u.shrink_to_fit(); + d2psi_u.clear(); + d2psi_u.shrink_to_fit(); + // (2)For each atom, calculate the adjacent atoms in different cells + // and allocate the space for H(R) and S(R). + // If k point is used here, allocate HlocR after atom_arrange. + Parallel_Orbitals* pv = &this->ParaV; + ra.for_2d(*pv, GlobalV::GAMMA_ONLY_LOCAL); + if (!GlobalV::GAMMA_ONLY_LOCAL) + { + // need to first calculae lgd. + // using GridT.init. + this->GridT.cal_nnrg(pv); + } + + ModuleBase::timer::tick("ESolver_KS_LCAO", "set_matrix_grid"); + return; +} + +}