Skip to content

Commit

Permalink
seperate out set_matrix_grid.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanchen committed Jul 27, 2024
1 parent bef8d9a commit 417c865
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
1 change: 1 addition & 0 deletions source/module_esolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
121 changes: 121 additions & 0 deletions source/module_esolver/set_matrix_grid.cpp
Original file line number Diff line number Diff line change
@@ -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 <typename TK, typename TR>
void ESolver_KS_LCAO<TK, TR>::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<double> rcuts;
std::vector<std::vector<double>> psi_u;
std::vector<std::vector<double>> dpsi_u;
std::vector<std::vector<double>> 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;
}

}

0 comments on commit 417c865

Please sign in to comment.