From 44159e4db7d675fa974c857582dffc1410c55c9d Mon Sep 17 00:00:00 2001 From: YuLiu98 Date: Thu, 21 Nov 2024 09:36:38 +0800 Subject: [PATCH] Refactor: remove init_after_vc --- source/Makefile.Objects | 2 - source/module_esolver/CMakeLists.txt | 2 - source/module_esolver/esolver_fp.cpp | 75 ++----- source/module_esolver/esolver_fp.h | 5 +- source/module_esolver/esolver_ks.cpp | 28 --- source/module_esolver/esolver_ks.h | 2 - source/module_esolver/esolver_ks_lcao.h | 2 - source/module_esolver/esolver_ks_pw.cpp | 18 +- source/module_esolver/esolver_ks_pw.h | 2 - source/module_esolver/esolver_of.cpp | 100 ++++----- source/module_esolver/esolver_of.h | 2 - source/module_esolver/lcao_before_scf.cpp | 7 +- source/module_esolver/lcao_init_after_vc.cpp | 79 ------- source/module_esolver/pw_init_after_vc.cpp | 205 ------------------- source/module_lr/esolver_lrtd_lcao.h | 2 - 15 files changed, 81 insertions(+), 450 deletions(-) delete mode 100644 source/module_esolver/lcao_init_after_vc.cpp delete mode 100644 source/module_esolver/pw_init_after_vc.cpp diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 260adfad0c..7bfbbac338 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -245,7 +245,6 @@ OBJS_ESOLVER=esolver.o\ esolver_of.o\ esolver_of_tool.o\ esolver_of_interface.o\ - pw_init_after_vc.o\ pw_init_globalc.o\ pw_others.o\ @@ -256,7 +255,6 @@ OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\ lcao_before_scf.o\ esolver_gets.o\ lcao_others.o\ - lcao_init_after_vc.o\ OBJS_GINT=gint.o\ gint_gamma_env.o\ diff --git a/source/module_esolver/CMakeLists.txt b/source/module_esolver/CMakeLists.txt index 13fa6c99e6..77b8b0e9cc 100644 --- a/source/module_esolver/CMakeLists.txt +++ b/source/module_esolver/CMakeLists.txt @@ -10,7 +10,6 @@ list(APPEND objects esolver_of.cpp esolver_of_interface.cpp esolver_of_tool.cpp - pw_init_after_vc.cpp pw_init_globalc.cpp pw_others.cpp ) @@ -23,7 +22,6 @@ if(ENABLE_LCAO) lcao_before_scf.cpp esolver_gets.cpp lcao_others.cpp - lcao_init_after_vc.cpp ) endif() diff --git a/source/module_esolver/esolver_fp.cpp b/source/module_esolver/esolver_fp.cpp index 02c87facca..e67fe546ad 100644 --- a/source/module_esolver/esolver_fp.cpp +++ b/source/module_esolver/esolver_fp.cpp @@ -262,81 +262,44 @@ void ESolver_FP::after_scf(const int istep) PARAM.inp.out_elf[1]); } } - - // #ifdef __RAPIDJSON - // // add Json of efermi energy converge - // Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver); - // // add nkstot,nkstot_ibz to output json - // int Jnkstot = this->pelec->klist->get_nkstot(); - // Json::add_nkstot(Jnkstot); - // #endif //__RAPIDJSON } -void ESolver_FP::init_after_vc(const Input_para& inp, UnitCell& cell) +void ESolver_FP::before_scf(const int istep) { - ModuleBase::TITLE("ESolver_FP", "init_after_vc"); + ModuleBase::TITLE("ESolver_FP", "before_scf"); - if (inp.mdp.md_prec_level == 2) - { - if (inp.nx * inp.ny * inp.nz == 0) - { - this->pw_rho->initgrids(cell.lat0, cell.latvec, 4.0 * inp.ecutwfc); - } - else - { - this->pw_rho->initgrids(cell.lat0, cell.latvec, inp.nx, inp.ny, inp.nz); - } - - this->pw_rho->initparameters(false, 4.0 * inp.ecutwfc); - this->pw_rho->setuptransform(); - this->pw_rho->collect_local_pw(); - this->pw_rho->collect_uniqgg(); - - if ( PARAM.globalv.double_grid) - { - ModulePW::PW_Basis_Sup* pw_rhod_sup = static_cast(pw_rhod); - if (inp.ndx * inp.ndy * inp.ndz == 0) - { - this->pw_rhod->initgrids(cell.lat0, cell.latvec, inp.ecutrho); - } - else - { - this->pw_rhod->initgrids(cell.lat0, cell.latvec, inp.ndx, inp.ndy, inp.ndz); - } - this->pw_rhod->initparameters(false, inp.ecutrho); - pw_rhod_sup->setuptransform(this->pw_rho); - this->pw_rhod->collect_local_pw(); - this->pw_rhod->collect_uniqgg(); - } - } - else + if (GlobalC::ucell.cell_parameter_updated) { // only G-vector and K-vector are changed due to the change of lattice // vector FFT grids do not change!! - pw_rho->initgrids(cell.lat0, cell.latvec, pw_rho->nx, pw_rho->ny, pw_rho->nz); + pw_rho->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, pw_rho->nx, pw_rho->ny, pw_rho->nz); pw_rho->collect_local_pw(); pw_rho->collect_uniqgg(); - if ( PARAM.globalv.double_grid) + if (PARAM.globalv.double_grid) { - this->pw_rhod->initgrids(cell.lat0, cell.latvec, pw_rhod->nx, pw_rhod->ny, pw_rhod->nz); + this->pw_rhod->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, pw_rhod->nx, pw_rhod->ny, pw_rhod->nz); this->pw_rhod->collect_local_pw(); this->pw_rhod->collect_uniqgg(); } GlobalC::ppcell.init_vloc(GlobalC::ppcell.vloc, pw_rhod); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL"); - } - this->pelec->omega = GlobalC::ucell.omega; - if (ModuleSymmetry::Symmetry::symm_flag == 1) - { - cell.symm.analy_sys(cell.lat, cell.st, cell.atoms, GlobalV::ofs_running); - ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SYMMETRY"); - } + this->pelec->omega = GlobalC::ucell.omega; + + if (ModuleSymmetry::Symmetry::symm_flag == 1) + { + GlobalC::ucell.symm.analy_sys(GlobalC::ucell.lat, + GlobalC::ucell.st, + GlobalC::ucell.atoms, + GlobalV::ofs_running); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SYMMETRY"); + } - kv.set_after_vc(PARAM.inp.nspin, cell.G, cell.latvec); - ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); + kv.set_after_vc(PARAM.inp.nspin, GlobalC::ucell.G, GlobalC::ucell.latvec); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); + } return; } diff --git a/source/module_esolver/esolver_fp.h b/source/module_esolver/esolver_fp.h index 3d953fc4c5..e78cb3bd6d 100644 --- a/source/module_esolver/esolver_fp.h +++ b/source/module_esolver/esolver_fp.h @@ -33,11 +33,12 @@ namespace ModuleESolver virtual void before_all_runners(const Input_para& inp, UnitCell& cell) override; protected: + //! Something to do before SCF iterations. + virtual void before_scf(const int istep); + //! Something to do after SCF iterations when SCF is converged or comes to the max iter step. virtual void after_scf(const int istep); - virtual void init_after_vc(const Input_para& inp, UnitCell& cell); // liuyu add 2023-03-09 - //! Electronic states elecstate::ElecState* pelec = nullptr; diff --git a/source/module_esolver/esolver_ks.cpp b/source/module_esolver/esolver_ks.cpp index 7d2bb0b3b4..254ffb513b 100644 --- a/source/module_esolver/esolver_ks.cpp +++ b/source/module_esolver/esolver_ks.cpp @@ -335,34 +335,6 @@ void ESolver_KS::before_all_runners(const Input_para& inp, UnitCell& #endif } -//------------------------------------------------------------------------------ -//! the 4th function of ESolver_KS: init_after_vc -//! mohan add 2024-05-11 -//------------------------------------------------------------------------------ -template -void ESolver_KS::init_after_vc(const Input_para& inp, UnitCell& ucell) -{ - ModuleBase::TITLE("ESolver_KS", "init_after_vc"); - - ESolver_FP::init_after_vc(inp, ucell); - - if (inp.mdp.md_prec_level == 2) - { - // initialize the real-space uniform grid for FFT and parallel - // distribution of plane waves - GlobalC::Pgrid.init(this->pw_rhod->nx, - this->pw_rhod->ny, - this->pw_rhod->nz, - this->pw_rhod->nplane, - this->pw_rhod->nrxx, - pw_big->nbz, - pw_big->bz); // mohan add 2010-07-22, update 2011-05-04 - - // Calculate Structure factor - this->sf.setup_structure_factor(&ucell, this->pw_rhod); - } -} - //------------------------------------------------------------------------------ //! the 5th function of ESolver_KS: hamilt2density_single //! mohan add 2024-05-11 diff --git a/source/module_esolver/esolver_ks.h b/source/module_esolver/esolver_ks.h index aedcfba1d2..9e046c7edb 100644 --- a/source/module_esolver/esolver_ks.h +++ b/source/module_esolver/esolver_ks.h @@ -38,8 +38,6 @@ class ESolver_KS : public ESolver_FP //! Something to do before SCF iterations. virtual void before_scf(const int istep) {}; - virtual void init_after_vc(const Input_para& inp, UnitCell& cell) override; // liuyu add 2023-03-09 - //! Something to do before hamilt2density function in each iter loop. virtual void iter_init(const int istep, const int iter); diff --git a/source/module_esolver/esolver_ks_lcao.h b/source/module_esolver/esolver_ks_lcao.h index 6d017c5103..a52160095c 100644 --- a/source/module_esolver/esolver_ks_lcao.h +++ b/source/module_esolver/esolver_ks_lcao.h @@ -29,8 +29,6 @@ class ESolver_KS_LCAO : public ESolver_KS { void before_all_runners(const Input_para& inp, UnitCell& cell) override; - void init_after_vc(const Input_para& inp, UnitCell& cell) override; - double cal_energy() override; void cal_force(ModuleBase::matrix& force) override; diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index a8b00b1a09..b5d62efc16 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -195,9 +195,25 @@ void ESolver_KS_PW::before_scf(const int istep) { ModuleBase::TITLE("ESolver_KS_PW", "before_scf"); + //! 1) call before_scf() of ESolver_FP + ESolver_FP::before_scf(istep); + if (GlobalC::ucell.cell_parameter_updated) { - this->init_after_vc(PARAM.inp, GlobalC::ucell); + GlobalC::ppcell.init_vnl(GlobalC::ucell, this->pw_rhod); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "NON-LOCAL POTENTIAL"); + + this->pw_wfc->initgrids(GlobalC::ucell.lat0, + GlobalC::ucell.latvec, + this->pw_wfc->nx, + this->pw_wfc->ny, + this->pw_wfc->nz); + + this->pw_wfc->initparameters(false, PARAM.inp.ecutwfc, this->kv.get_nks(), this->kv.kvec_d.data()); + + this->pw_wfc->collect_local_pw(PARAM.inp.erf_ecut, PARAM.inp.erf_height, PARAM.inp.erf_sigma); + + this->p_wf_init->make_table(this->kv.get_nks(), &this->sf); } if (GlobalC::ucell.ionic_position_updated) { diff --git a/source/module_esolver/esolver_ks_pw.h b/source/module_esolver/esolver_ks_pw.h index a5f2d717ee..aa06f5ccd7 100644 --- a/source/module_esolver/esolver_ks_pw.h +++ b/source/module_esolver/esolver_ks_pw.h @@ -46,8 +46,6 @@ class ESolver_KS_PW : public ESolver_KS virtual void hamilt2density_single(const int istep, const int iter, const double ethr) override; - void init_after_vc(const Input_para& inp, UnitCell& cell) override; - // temporary, this will be removed in the future; // Init Global class void Init_GlobalC(const Input_para& inp, UnitCell& ucell, pseudopot_cell_vnl& ppcell); diff --git a/source/module_esolver/esolver_of.cpp b/source/module_esolver/esolver_of.cpp index a3bb656efd..7b6fece3b8 100644 --- a/source/module_esolver/esolver_of.cpp +++ b/source/module_esolver/esolver_of.cpp @@ -153,66 +153,6 @@ void ESolver_OF::before_all_runners(const Input_para& inp, UnitCell& ucell) this->allocate_array(); } -void ESolver_OF::init_after_vc(const Input_para& inp, UnitCell& ucell) -{ - ModuleBase::timer::tick("ESolver_OF", "init_after_vc"); - - ESolver_FP::init_after_vc(inp, ucell); - - this->dV_ = ucell.omega / this->pw_rho->nxyz; - - if (inp.mdp.md_prec_level == 2) - { - // initialize the real-space uniform grid for FFT and parallel - // distribution of plane waves - GlobalC::Pgrid.init(this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, - this->pw_rho->nplane, - this->pw_rho->nrxx, - pw_big->nbz, - pw_big->bz); // mohan add 2010-07-22, update 2011-05-04 - - // Calculate Structure factor - this->sf.setup_structure_factor(&ucell, this->pw_rho); - } - - // initialize elecstate, including potential - this->init_elecstate(ucell); - GlobalC::ppcell.init_vnl(ucell, pw_rho); - - // Initialize KEDF - this->init_kedf(inp); - - // Initialize optimization methods - this->init_opt(); - - // Refresh the arrays - delete this->psi_; - this->psi_ = new psi::Psi(1, PARAM.inp.nspin, this->pw_rho->nrxx); - for (int is = 0; is < PARAM.inp.nspin; ++is) - { - this->pphi_[is] = this->psi_->get_pointer(is); - } - - delete this->ptemp_rho_; - this->ptemp_rho_ = new Charge(); - this->ptemp_rho_->set_rhopw(this->pw_rho); - this->ptemp_rho_->allocate(PARAM.inp.nspin); - - for (int is = 0; is < PARAM.inp.nspin; ++is) - { - delete[] this->pdLdphi_[is]; - delete[] this->pdEdphi_[is]; - delete[] this->pdirect_[is]; - delete[] this->precip_dir_[is]; - this->pdLdphi_[is] = new double[this->pw_rho->nrxx]; - this->pdEdphi_[is] = new double[this->pw_rho->nrxx]; - this->pdirect_[is] = new double[this->pw_rho->nrxx]; - this->precip_dir_[is] = new std::complex[pw_rho->npw]; - } -} - void ESolver_OF::runner(int istep, UnitCell& ucell) { ModuleBase::timer::tick("ESolver_OF", "runner"); @@ -260,9 +200,47 @@ void ESolver_OF::runner(int istep, UnitCell& ucell) */ void ESolver_OF::before_opt(const int istep, UnitCell& ucell) { + //! 1) call before_scf() of ESolver_FP + ESolver_FP::before_scf(istep); + if (ucell.cell_parameter_updated) { - this->init_after_vc(PARAM.inp, ucell); + this->dV_ = ucell.omega / this->pw_rho->nxyz; + + // initialize elecstate, including potential + this->init_elecstate(ucell); + GlobalC::ppcell.init_vnl(ucell, pw_rho); + + // Initialize KEDF + this->init_kedf(PARAM.inp); + + // Initialize optimization methods + this->init_opt(); + + // Refresh the arrays + delete this->psi_; + this->psi_ = new psi::Psi(1, PARAM.inp.nspin, this->pw_rho->nrxx); + for (int is = 0; is < PARAM.inp.nspin; ++is) + { + this->pphi_[is] = this->psi_->get_pointer(is); + } + + delete this->ptemp_rho_; + this->ptemp_rho_ = new Charge(); + this->ptemp_rho_->set_rhopw(this->pw_rho); + this->ptemp_rho_->allocate(PARAM.inp.nspin); + + for (int is = 0; is < PARAM.inp.nspin; ++is) + { + delete[] this->pdLdphi_[is]; + delete[] this->pdEdphi_[is]; + delete[] this->pdirect_[is]; + delete[] this->precip_dir_[is]; + this->pdLdphi_[is] = new double[this->pw_rho->nrxx]; + this->pdEdphi_[is] = new double[this->pw_rho->nrxx]; + this->pdirect_[is] = new double[this->pw_rho->nrxx]; + this->precip_dir_[is] = new std::complex[pw_rho->npw]; + } } if (ucell.ionic_position_updated) { diff --git a/source/module_esolver/esolver_of.h b/source/module_esolver/esolver_of.h index b9e57bb1ae..183976df8f 100644 --- a/source/module_esolver/esolver_of.h +++ b/source/module_esolver/esolver_of.h @@ -21,8 +21,6 @@ class ESolver_OF : public ESolver_FP virtual void before_all_runners(const Input_para& inp, UnitCell& ucell) override; - virtual void init_after_vc(const Input_para& inp, UnitCell& ucell) override; - virtual void runner(const int istep, UnitCell& ucell) override; virtual void after_all_runners() override; diff --git a/source/module_esolver/lcao_before_scf.cpp b/source/module_esolver/lcao_before_scf.cpp index 6e00a336a6..ea4bb2f879 100644 --- a/source/module_esolver/lcao_before_scf.cpp +++ b/source/module_esolver/lcao_before_scf.cpp @@ -177,10 +177,9 @@ void ESolver_KS_LCAO::before_scf(const int istep) { ModuleBase::TITLE("ESolver_KS_LCAO", "before_scf"); - if (GlobalC::ucell.cell_parameter_updated) - { - this->init_after_vc(PARAM.inp, GlobalC::ucell); - } + //! 1) call before_scf() of ESolver_FP + ESolver_FP::before_scf(istep); + if (GlobalC::ucell.ionic_position_updated) { this->CE.update_all_dis(GlobalC::ucell); diff --git a/source/module_esolver/lcao_init_after_vc.cpp b/source/module_esolver/lcao_init_after_vc.cpp deleted file mode 100644 index 3666cdd6ee..0000000000 --- a/source/module_esolver/lcao_init_after_vc.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "esolver_ks_lcao.h" - -#include "module_base/global_variable.h" -#include "module_base/tool_title.h" -#include "module_parameter/parameter.h" - -//--------------temporary---------------------------- -#include - -#include "module_base/global_function.h" -#include "module_cell/module_neighbor/sltk_grid_driver.h" -#include "module_elecstate/module_charge/symmetry_rho.h" -#include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_io/print_info.h" - - -//-----HSolver ElecState Hamilt-------- -#include "module_elecstate/elecstate_lcao.h" -#include "module_hamilt_lcao/hamilt_lcaodft/hamilt_lcao.h" -#include "module_hsolver/hsolver_lcao.h" -//--------------------------------------------------- - - -namespace ModuleESolver -{ - -//------------------------------------------------------------------------------ -//! the 4th function of ESolver_KS_LCAO: init_after_vc -//! mohan add 2024-05-11 -//------------------------------------------------------------------------------ -template -void ESolver_KS_LCAO::init_after_vc(const Input_para& inp, UnitCell& ucell) -{ - ModuleBase::TITLE("ESolver_KS_LCAO", "init_after_vc"); - ModuleBase::timer::tick("ESolver_KS_LCAO", "init_after_vc"); - - ESolver_KS::init_after_vc(inp, ucell); - if (inp.mdp.md_prec_level == 2) - { - delete this->pelec; - this->pelec = new elecstate::ElecStateLCAO( - &(this->chr), - &(this->kv), - this->kv.get_nks(), - &(this->GG), // mohan add 2024-04-01 - &(this->GK), // mohan add 2024-04-01 - this->pw_rho, - this->pw_big); - - dynamic_cast*>(this->pelec) - ->init_DM(&this->kv, &this->pv, PARAM.inp.nspin); - - GlobalC::ppcell.init_vloc(GlobalC::ppcell.vloc, this->pw_rho); - - this->pelec->charge->allocate(PARAM.inp.nspin); - this->pelec->omega = GlobalC::ucell.omega; - - // Initialize the potential. - if (this->pelec->pot == nullptr) - { - this->pelec->pot = new elecstate::Potential(this->pw_rhod, - this->pw_rho, - &GlobalC::ucell, - &(GlobalC::ppcell.vloc), - &(this->sf), - &(this->pelec->f_en.etxc), - &(this->pelec->f_en.vtxc)); - } - } - - ModuleBase::timer::tick("ESolver_KS_LCAO", "init_after_vc"); - return; -} - - -template class ESolver_KS_LCAO; -template class ESolver_KS_LCAO, double>; -template class ESolver_KS_LCAO, std::complex>; -} diff --git a/source/module_esolver/pw_init_after_vc.cpp b/source/module_esolver/pw_init_after_vc.cpp deleted file mode 100644 index 4dea9b784c..0000000000 --- a/source/module_esolver/pw_init_after_vc.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include "esolver_ks_pw.h" - -#include "module_base/global_variable.h" -#include "module_hamilt_pw/hamilt_pwdft/elecond.h" -#include "module_io/input_conv.h" -#include "module_io/nscf_band.h" -#include "module_io/output_log.h" -#include "module_io/write_dos_pw.h" -#include "module_io/write_istate_info.h" -#include "module_io/write_wfc_pw.h" - -#include - -//--------------temporary---------------------------- -#include "module_elecstate/module_charge/symmetry_rho.h" -#include "module_elecstate/occupy.h" -#include "module_hamilt_general/module_ewald/H_Ewald_pw.h" -#include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_io/print_info.h" -//-----force------------------- -#include "module_hamilt_pw/hamilt_pwdft/forces.h" -//-----stress------------------ -#include "module_hamilt_pw/hamilt_pwdft/stress_pw.h" -//--------------------------------------------------- -#include "module_base/memory.h" -#include "module_base/module_device/device.h" -#include "module_elecstate/elecstate_pw.h" -#include "module_hamilt_general/module_vdw/vdw.h" -#include "module_hamilt_pw/hamilt_pwdft/hamilt_pw.h" -#include "module_hsolver/diago_iter_assist.h" -#include "module_hsolver/hsolver_pw.h" -#include "module_hsolver/kernels/dngvd_op.h" -#include "module_hsolver/kernels/math_kernel_op.h" -#include "module_io/berryphase.h" -#include "module_io/numerical_basis.h" -#include "module_io/numerical_descriptor.h" -#include "module_io/to_wannier90_pw.h" -#include "module_io/winput.h" -#include "module_io/write_elecstat_pot.h" -#include "module_io/write_wfc_r.h" -#include "module_parameter/parameter.h" -#ifdef USE_PAW -#include "module_cell/module_paw/paw_cell.h" -#endif -#include -#include -#include "module_base/formatter.h" - -namespace ModuleESolver { - -template -void ESolver_KS_PW::init_after_vc(const Input_para& inp, UnitCell& ucell) { - ModuleBase::TITLE("ESolver_KS_PW", "init_after_vc"); - ModuleBase::timer::tick("ESolver_KS_PW", "init_after_vc"); - - ESolver_KS::init_after_vc(inp, ucell); - - if (inp.mdp.md_prec_level == 2) { - this->pw_wfc->initgrids(ucell.lat0, - ucell.latvec, - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz); - - this->pw_wfc->initparameters(false, - inp.ecutwfc, - this->kv.get_nks(), - this->kv.kvec_d.data()); - -#ifdef __MPI - if (PARAM.inp.pw_seed > 0) { - MPI_Allreduce(MPI_IN_PLACE, - &this->pw_wfc->ggecut, - 1, - MPI_DOUBLE, - MPI_MAX, - MPI_COMM_WORLD); - } - // qianrui add 2021-8-13 to make different kpar parameters can get the - // same results -#endif - - this->pw_wfc->setuptransform(); - - for (int ik = 0; ik < this->kv.get_nks(); ++ik) { - this->kv.ngk[ik] = this->pw_wfc->npwk[ik]; - } - - this->pw_wfc->collect_local_pw(inp.erf_ecut, - inp.erf_height, - inp.erf_sigma); - this->already_initpsi = false; - - delete this->pelec; - this->pelec - = new elecstate::ElecStatePW(this->pw_wfc, - &(this->chr), - (K_Vectors*)(&(this->kv)), - &ucell, - &GlobalC::ppcell, - this->pw_rhod, - this->pw_rho, - this->pw_big); - - this->pelec->charge->allocate(PARAM.inp.nspin); - - //! setup cell volume - this->pelec->omega = ucell.omega; - - delete this->pelec->pot; - - this->pelec->pot = new elecstate::Potential(this->pw_rhod, - this->pw_rho, - &ucell, - &GlobalC::ppcell.vloc, - &(this->sf), - &(this->pelec->f_en.etxc), - &(this->pelec->f_en.vtxc)); - - // temporary - this->Init_GlobalC(inp, ucell, GlobalC::ppcell); - } else { - GlobalC::ppcell.init_vnl(ucell, this->pw_rhod); - ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, - "NON-LOCAL POTENTIAL"); - - this->pw_wfc->initgrids(ucell.lat0, - ucell.latvec, - this->pw_wfc->nx, - this->pw_wfc->ny, - this->pw_wfc->nz); - - this->pw_wfc->initparameters(false, - PARAM.inp.ecutwfc, - this->kv.get_nks(), - this->kv.kvec_d.data()); - - this->pw_wfc->collect_local_pw(inp.erf_ecut, - inp.erf_height, - inp.erf_sigma); - - this->p_wf_init->make_table(this->kv.get_nks(), &this->sf); - } - -#ifdef USE_PAW - if (PARAM.inp.use_paw) { - GlobalC::paw_cell.set_libpaw_ecut(PARAM.inp.ecutwfc / 2.0, - PARAM.inp.ecutwfc / 2.0); // in Hartree - GlobalC::paw_cell.set_libpaw_fft(this->pw_wfc->nx, - this->pw_wfc->ny, - this->pw_wfc->nz, - this->pw_wfc->nx, - this->pw_wfc->ny, - this->pw_wfc->nz, - this->pw_wfc->startz, - this->pw_wfc->numz); - -#ifdef __MPI - if (GlobalV::RANK_IN_POOL == 0) { - GlobalC::paw_cell.prepare_paw(); - } -#else - GlobalC::paw_cell.prepare_paw(); -#endif - GlobalC::paw_cell.set_sij(); - - std::vector> rhoijp; - std::vector> rhoijselect; - std::vector nrhoijsel; -#ifdef __MPI - if (GlobalV::RANK_IN_POOL == 0) { - GlobalC::paw_cell.get_rhoijp(rhoijp, rhoijselect, nrhoijsel); - - for (int iat = 0; iat < ucell.nat; iat++) { - GlobalC::paw_cell.set_rhoij(iat, - nrhoijsel[iat], - rhoijselect[iat].size(), - rhoijselect[iat].data(), - rhoijp[iat].data()); - } - } -#else - GlobalC::paw_cell.get_rhoijp(rhoijp, rhoijselect, nrhoijsel); - - for (int iat = 0; iat < ucell.nat; iat++) { - GlobalC::paw_cell.set_rhoij(iat, - nrhoijsel[iat], - rhoijselect[iat].size(), - rhoijselect[iat].data(), - rhoijp[iat].data()); - } -#endif - } -#endif - - ModuleBase::timer::tick("ESolver_KS_PW", "init_after_vc"); -} - -template class ESolver_KS_PW, base_device::DEVICE_CPU>; -template class ESolver_KS_PW, base_device::DEVICE_CPU>; -#if ((defined __CUDA) || (defined __ROCM)) -template class ESolver_KS_PW, base_device::DEVICE_GPU>; -template class ESolver_KS_PW, base_device::DEVICE_GPU>; -#endif -} // namespace ModuleESolver diff --git a/source/module_lr/esolver_lrtd_lcao.h b/source/module_lr/esolver_lrtd_lcao.h index 62e27e4fa8..8ae33ef05a 100644 --- a/source/module_lr/esolver_lrtd_lcao.h +++ b/source/module_lr/esolver_lrtd_lcao.h @@ -38,8 +38,6 @@ namespace LR ///input: input, call, basis(LCAO), psi(ground state), elecstate // initialize sth. independent of the ground state virtual void before_all_runners(const Input_para& inp, UnitCell& cell) override {}; - - virtual void init_after_vc(const Input_para& inp, UnitCell& cell) override {}; virtual void runner(int istep, UnitCell& ucell) override; virtual void after_all_runners() override;