Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -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\

Expand All @@ -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\
Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -23,7 +22,6 @@ if(ENABLE_LCAO)
lcao_before_scf.cpp
esolver_gets.cpp
lcao_others.cpp
lcao_init_after_vc.cpp
)
endif()

Expand Down
75 changes: 19 additions & 56 deletions source/module_esolver/esolver_fp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModulePW::PW_Basis_Sup*>(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;
}
Expand Down
5 changes: 3 additions & 2 deletions source/module_esolver/esolver_fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
28 changes: 0 additions & 28 deletions source/module_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,34 +335,6 @@ void ESolver_KS<T, Device>::before_all_runners(const Input_para& inp, UnitCell&
#endif
}

//------------------------------------------------------------------------------
//! the 4th function of ESolver_KS: init_after_vc
//! mohan add 2024-05-11
//------------------------------------------------------------------------------
template <typename T, typename Device>
void ESolver_KS<T, Device>::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
Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/esolver_ks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/esolver_ks_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class ESolver_KS_LCAO : public ESolver_KS<TK> {

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;
Expand Down
18 changes: 17 additions & 1 deletion source/module_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,25 @@ void ESolver_KS_PW<T, Device>::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)
{
Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/esolver_ks_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class ESolver_KS_PW : public ESolver_KS<T, Device>

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);
Expand Down
100 changes: 39 additions & 61 deletions source/module_esolver/esolver_of.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(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<double>[pw_rho->npw];
}
}

void ESolver_OF::runner(int istep, UnitCell& ucell)
{
ModuleBase::timer::tick("ESolver_OF", "runner");
Expand Down Expand Up @@ -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<double>(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<double>[pw_rho->npw];
}
}
if (ucell.ionic_position_updated)
{
Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/esolver_of.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions source/module_esolver/lcao_before_scf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,9 @@ void ESolver_KS_LCAO<TK, TR>::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);
Expand Down
Loading
Loading