Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5d8b0c7
update timer, add std
mohanchen Mar 27, 2024
b5bcc7f
update the format of esolver_fp.cpp
mohanchen Mar 27, 2024
3c69ace
add description in esolver_fp.h
mohanchen Mar 27, 2024
e1551cf
update a few esolver files
mohanchen Mar 27, 2024
f0a5c3b
update esolver description for LCAO
mohanchen Mar 27, 2024
1c8ed86
update some formats of esolver codes
mohanchen Mar 27, 2024
ea0e2c4
update esolver_ks_pw.cpp formats
mohanchen Mar 27, 2024
ae36b11
update formats of esolver_ks_pw.cpp and esolver_ks_pw.h
mohanchen Mar 27, 2024
16b0f76
update esolver_ks_lcao_tddft.cpp formats
mohanchen Mar 27, 2024
1768c88
update format of esolver_sdft_pw.cpp
mohanchen Mar 27, 2024
6a606ed
update the format of esolver_sdft_pw_tool.cpp
mohanchen Mar 27, 2024
cac11ea
keep formating esolver_ks_pw.cpp
mohanchen Mar 27, 2024
e191f6c
formating esolver_of_interface.cpp
mohanchen Mar 27, 2024
8eddd5a
change GlobalC::ucell to ucell in esolver_ks.cpp
mohanchen Mar 27, 2024
bcf4d54
remove some GlobalC::ucell in esolver_sdft_pw.cpp
mohanchen Mar 27, 2024
1ca6574
refactor the code before getting rid of RA in esolver_lcao
mohanchen Mar 28, 2024
7987684
refactor before getting rid of LOWF
mohanchen Mar 28, 2024
186609f
refactor before getting rid of LCAO_hamilt.h and LCAO_matrix.h
mohanchen Mar 28, 2024
fc02fb8
refactor wavefunc_in_pw
mohanchen Mar 28, 2024
7a8064f
refactor density matrix
mohanchen Mar 28, 2024
f95129d
refactor the format cal_dm_psi.cpp
mohanchen Mar 28, 2024
98234ae
format forces.cpp
mohanchen Mar 30, 2024
583214c
refactor esolver_of_tool.cpp
mohanchen Mar 30, 2024
2638dd3
resolve conflict
mohanchen Mar 30, 2024
9505a9f
change member function beforescf in Esolver to before_scf
mohanchen Mar 31, 2024
313893e
change afterscf to after_scf
mohanchen Mar 31, 2024
7317a47
change updatepot to update_pot
mohanchen Mar 31, 2024
730b460
change eachiterinit to iter_init, change eachiterfinish to iter_finish
mohanchen Mar 31, 2024
31760e8
refactor esolvers, change member function names of most esolvers
mohanchen Mar 31, 2024
cccbb14
reformat esolver.h
mohanchen Mar 31, 2024
270a39d
update tests for esolvers
mohanchen Mar 31, 2024
bfc8ac7
add TITLE in esolver_ks_lcao
mohanchen Mar 31, 2024
3e15388
update esolver_ks_lcao
mohanchen Mar 31, 2024
413e73f
update esolver_lcao
mohanchen Mar 31, 2024
3f2006a
update timer::tick in esolver_lcao
mohanchen Mar 31, 2024
78c08cf
try to delete LCAO_Matrix in LCAO_Hamilt, and try to delete Parallel_…
mohanchen Mar 31, 2024
76b23de
fix the compiling issue with LCAO_hamilt.hpp
mohanchen Mar 31, 2024
4018fa2
try to divide the FORCE_k.cpp into several small files
mohanchen Mar 31, 2024
eee4f97
fix conflicts
mohanchen Mar 31, 2024
34add55
divide FORCE_k into foverlap_k.cpp ftvnl_dphi_k.cpp fvl_dphi_k.cpp fv…
mohanchen Mar 31, 2024
0469d94
get rid of UHM in FORCE_k.cpp
mohanchen Mar 31, 2024
2eac633
cannot compile, but I have modified some files in order to get rid of…
mohanchen Mar 31, 2024
21d4637
keep updating, cannot run
mohanchen Mar 31, 2024
3e01810
update write_Vxc, cannot run yet
mohanchen Mar 31, 2024
be3b80a
keep updating gint_gamma and gint_k
mohanchen Apr 1, 2024
37066e5
update LCAO_matrix.cpp
mohanchen Apr 1, 2024
d128c11
divide force files, and update Makefile.Objects
mohanchen Apr 1, 2024
a2e25b3
update LCAO_hamilt.cpp
mohanchen Apr 1, 2024
d6e6492
Merge branch 'deepmodeling:develop' into develop
mohanchen Apr 1, 2024
e182760
Merge branch 'divide_force' into develop.
mohanchen Apr 1, 2024
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
4 changes: 4 additions & 0 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@ OBJS_LCAO=DM_gamma.o\
FORCE_gamma_tvnl.o\
FORCE_gamma_vl.o\
FORCE_k.o\
foverlap_k.o\
ftvnl_dphi_k.o\
fvl_dphi_k.o\
fvnl_dbeta_k.o\
LCAO_gen_fixedH.o\
LCAO_hamilt.o\
LCAO_matrix.o\
Expand Down
16 changes: 10 additions & 6 deletions source/module_elecstate/elecstate_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ void ElecStateLCAO<std::complex<double>>::psiToRho(const psi::Psi<std::complex<d
//------------------------------------------------------------

ModuleBase::GlobalFunc::NOTE("Calculate the charge on real space grid!");
this->uhm->GK.transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint
this->gint_k->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint
Gint_inout inout(this->loc->DM_R, this->charge->rho, Gint_Tools::job_type::rho);
this->uhm->GK.cal_gint(&inout);
this->gint_k->cal_gint(&inout);

if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
Expand All @@ -153,7 +153,7 @@ void ElecStateLCAO<std::complex<double>>::psiToRho(const psi::Psi<std::complex<d
ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx);
}
Gint_inout inout1(this->loc->DM_R, this->charge->kin_r, Gint_Tools::job_type::tau);
this->uhm->GK.cal_gint(&inout1);
this->gint_k->cal_gint(&inout1);
}

this->charge->renormalize_rho();
Expand Down Expand Up @@ -216,17 +216,21 @@ void ElecStateLCAO<double>::psiToRho(const psi::Psi<double>& psi)
// calculate the charge density on real space grid.
//------------------------------------------------------------
ModuleBase::GlobalFunc::NOTE("Calculate the charge on real space grid!");
this->uhm->GG.transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint

this->gint_gamma->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint

Gint_inout inout(this->loc->DM, this->charge->rho, Gint_Tools::job_type::rho);
this->uhm->GG.cal_gint(&inout);

this->gint_gamma->cal_gint(&inout);

if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
for (int is = 0; is < GlobalV::NSPIN; is++)
{
ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[is], this->charge->nrxx);
}
Gint_inout inout1(this->loc->DM, this->charge->kin_r, Gint_Tools::job_type::tau);
this->uhm->GG.cal_gint(&inout1);
this->gint_gamma->cal_gint(&inout1);
}

this->charge->renormalize_rho();
Expand Down
20 changes: 14 additions & 6 deletions source/module_elecstate/elecstate_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#define ELECSTATELCAO_H

#include "elecstate.h"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.h"
#include "module_hamilt_lcao/module_gint/gint_gamma.h"
#include "module_hamilt_lcao/module_gint/gint_k.h"
#include "module_hamilt_lcao/hamilt_lcaodft/local_orbital_charge.h"
#include "module_hamilt_lcao/hamilt_lcaodft/local_orbital_wfc.h"
#include "module_elecstate/module_dm/density_matrix.h"
Expand All @@ -18,22 +19,27 @@ class ElecStateLCAO : public ElecState
const K_Vectors* klist_in ,
int nks_in,
Local_Orbital_Charge* loc_in ,
Gint_Gamma* gint_gamma_in, //mohan add 2024-04-01
Gint_k* gint_k_in, //mohan add 2024-04-01
LCAO_Hamilt* uhm_in ,
Local_Orbital_wfc* lowf_in ,
ModulePW::PW_Basis* rhopw_in ,
ModulePW::PW_Basis_Big* bigpw_in )
{
init_ks(chg_in, klist_in, nks_in, rhopw_in, bigpw_in);
this->loc = loc_in;
this->uhm = uhm_in;
this->gint_gamma = gint_gamma_in; // mohan add 2024-04-01
this->gint_k = gint_k_in; // mohan add 2024-04-01
this->lowf = lowf_in;
this->classname = "ElecStateLCAO";
}

virtual ~ElecStateLCAO()
{
if (this->DM != nullptr)
delete this->DM;
if (this->DM != nullptr)
{
delete this->DM;
}
}

// void init(Charge* chg_in):charge(chg_in){} override;
Expand Down Expand Up @@ -69,7 +75,9 @@ class ElecStateLCAO : public ElecState
// void rhoBandK(const psi::Psi<std::complex<double>>& psi);

Local_Orbital_Charge* loc = nullptr;
LCAO_Hamilt* uhm = nullptr;
Gint_Gamma* gint_gamma = nullptr; // mohan add 2024-04-01
Gint_k* gint_k = nullptr; // mohan add 2024-04-01
//LCAO_Hamilt* uhm = nullptr; // mohan modify 2024-04-01
Local_Orbital_wfc* lowf = nullptr;
DensityMatrix<TK,double>* DM = nullptr;

Expand All @@ -86,4 +94,4 @@ bool ElecStateLCAO<TK>::need_psi_grid = 1;

} // namespace elecstate

#endif
#endif
7 changes: 3 additions & 4 deletions source/module_elecstate/elecstate_lcao_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ void ElecStateLCAO_TDDFT::psiToRho_td(const psi::Psi<std::complex<double>>& psi)
//------------------------------------------------------------

ModuleBase::GlobalFunc::NOTE("Calculate the charge on real space grid!");
this->uhm->GK.transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint
this->gint_k->transfer_DM2DtoGrid(this->DM->get_DMR_vector()); // transfer DM2D to DM_grid in gint
Gint_inout inout(this->loc->DM_R, this->charge->rho, Gint_Tools::job_type::rho); // rho calculation
this->uhm->GK.cal_gint(&inout);
this->gint_k->cal_gint(&inout);

this->charge->renormalize_rho();

Expand Down Expand Up @@ -110,5 +110,4 @@ void ElecStateLCAO_TDDFT::calculate_weights_td()
}



} // namespace elecstate
} // namespace elecstate
8 changes: 4 additions & 4 deletions source/module_elecstate/elecstate_lcao_tddft.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "elecstate.h"
#include "elecstate_lcao.h"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.h"
#include "module_hamilt_lcao/module_gint/gint_k.h"
#include "module_hamilt_lcao/hamilt_lcaodft/local_orbital_charge.h"
#include "module_hamilt_lcao/hamilt_lcaodft/local_orbital_wfc.h"

Expand All @@ -16,14 +16,14 @@ class ElecStateLCAO_TDDFT : public ElecStateLCAO<std::complex<double>>
const K_Vectors* klist_in ,
int nks_in,
Local_Orbital_Charge* loc_in ,
LCAO_Hamilt* uhm_in ,
Gint_k* gint_k_in, //mohan add 2024-04-01
Local_Orbital_wfc* lowf_in ,
ModulePW::PW_Basis* rhopw_in ,
ModulePW::PW_Basis_Big* bigpw_in )
{
init_ks(chg_in, klist_in, nks_in, rhopw_in, bigpw_in);
this->loc = loc_in;
this->uhm = uhm_in;
this->gint_k = gint_k_in;
this->lowf = lowf_in;
this->classname = "ElecStateLCAO_TDDFT";
}
Expand All @@ -33,4 +33,4 @@ class ElecStateLCAO_TDDFT : public ElecStateLCAO<std::complex<double>>

} // namespace elecstate

#endif
#endif
38 changes: 31 additions & 7 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ void ESolver_KS_LCAO<TK, TR>::init(Input& inp, UnitCell& ucell)
// autoset nbands in ElecState, it should before basis_init (for Psi 2d divid)
if (this->pelec == nullptr)
{
this->pelec = new elecstate::ElecStateLCAO<TK>(&(this->chr),
this->pelec = new elecstate::ElecStateLCAO<TK>(
&(this->chr),
&(this->kv),
this->kv.nks,
&(this->LOC),
&(this->GG), // mohan add 2024-04-01
&(this->GK), // mohan add 2024-04-01
&(this->UHM),
&(this->LOWF),
this->pw_rho,
Expand Down Expand Up @@ -255,6 +258,8 @@ void ESolver_KS_LCAO<TK, TR>::init_after_vc(Input& inp, UnitCell& ucell)
&(this->kv),
this->kv.nks,
&(this->LOC),
&(this->GG), // mohan add 2024-04-01
&(this->GK), // mohan add 2024-04-01
&(this->UHM),
&(this->LOWF),
this->pw_rho,
Expand Down Expand Up @@ -313,6 +318,8 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(ModuleBase::matrix& force)
this->pelec,
this->psi,
this->UHM,
this->GG, // mohan add 2024-04-01
this->GK, // mohan add 2024-04-01
force,
this->scs,
this->sf,
Expand Down Expand Up @@ -665,7 +672,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(const int istep, const int iter)
// update Gint_K
if (!GlobalV::GAMMA_ONLY_LOCAL)
{
this->UHM.GK.renew();
this->GK.renew();
}
// update real space Hamiltonian
this->p_hamilt->refresh();
Expand Down Expand Up @@ -803,7 +810,7 @@ void ESolver_KS_LCAO<TK, TR>::update_pot(const int istep, const int iter)
{
if (!GlobalV::GAMMA_ONLY_LOCAL && hsolver::HSolverLCAO<TK>::out_mat_hs[0])
{
this->UHM.GK.renew(true);
this->GK.renew(true);
}
for (int ik = 0; ik < this->kv.nks; ++ik)
{
Expand Down Expand Up @@ -1016,9 +1023,24 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(const int istep)
bool out_exc = true; // tmp, add parameter!
if (GlobalV::out_mat_xc)
{
ModuleIO::write_Vxc<TK, TR>(GlobalV::NSPIN, GlobalV::NLOCAL, GlobalV::DRANK,
*this->psi, GlobalC::ucell, this->sf, *this->pw_rho, *this->pw_rhod, GlobalC::ppcell.vloc,
*this->pelec->charge, this->UHM, this->LM, this->LOC, this->kv, this->pelec->wg, GlobalC::GridD);
ModuleIO::write_Vxc<TK, TR>(
GlobalV::NSPIN,
GlobalV::NLOCAL,
GlobalV::DRANK,
*this->psi,
GlobalC::ucell,
this->sf,
*this->pw_rho,
*this->pw_rhod,
GlobalC::ppcell.vloc,
*this->pelec->charge,
this->GG,
this->GK,
this->LM,
this->LOC,
this->kv,
this->pelec->wg,
GlobalC::GridD);
}

#ifdef __EXX
Expand Down Expand Up @@ -1181,14 +1203,16 @@ ModuleIO::Output_DM1 ESolver_KS_LCAO<TK, TR>::create_Output_DM1(int istep)
template <typename TK, typename TR>
ModuleIO::Output_Mat_Sparse<TK> ESolver_KS_LCAO<TK, TR>::create_Output_Mat_Sparse(int istep)
{
return ModuleIO::Output_Mat_Sparse<TK>(hsolver::HSolverLCAO<TK>::out_mat_hsR,
return ModuleIO::Output_Mat_Sparse<TK>(
hsolver::HSolverLCAO<TK>::out_mat_hsR,
hsolver::HSolverLCAO<TK>::out_mat_dh,
hsolver::HSolverLCAO<TK>::out_mat_t,
INPUT.out_mat_r,
istep,
this->pelec->pot->get_effective_v(),
*this->LOWF.ParaV,
this->UHM,
this->GK, // mohan add 2024-04-01
this->LM,
this->kv,
this->p_hamilt);
Expand Down
10 changes: 10 additions & 0 deletions source/module_esolver/esolver_ks_lcao.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include "module_hamilt_lcao/hamilt_lcaodft/local_orbital_charge.h"
#include "module_hamilt_lcao/hamilt_lcaodft/local_orbital_wfc.h"
#include "module_hamilt_lcao/hamilt_lcaodft/LCAO_hamilt.h"
// for grid integration
#include "module_hamilt_lcao/module_gint/gint_gamma.h"
#include "module_hamilt_lcao/module_gint/gint_k.h"

#include "module_basis/module_ao/ORB_control.h"
#ifdef __EXX
#include "module_ri/Mix_DMk_2D.h"
Expand Down Expand Up @@ -75,6 +79,12 @@ namespace ModuleESolver
// we will get rid of this class soon, don't use it, mohan 2024-03-28
LCAO_Hamilt UHM;

// used for k-dependent grid integration.
Gint_k GK;

// used for gamma only algorithms.
Gint_Gamma GG;

// we will get rid of this class soon, don't use it, mohan 2024-03-28
LCAO_Matrix LM;

Expand Down
25 changes: 15 additions & 10 deletions source/module_esolver/esolver_ks_lcao_elec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
}

// prepare grid in Gint
this->UHM.grid_prepare(this->GridT, *this->pw_rho, *this->pw_big);
this->UHM.grid_prepare(
this->GridT,
this->GG,
this->GK,
*this->pw_rho,
*this->pw_big);

// init Hamiltonian
if (this->p_hamilt != nullptr)
Expand All @@ -137,8 +142,8 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
if (this->p_hamilt == nullptr)
{
elecstate::DensityMatrix<TK, double>* DM = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
this->p_hamilt = new hamilt::HamiltLCAO<TK, TR>(GlobalV::GAMMA_ONLY_LOCAL ? &(this->UHM.GG) : nullptr,
GlobalV::GAMMA_ONLY_LOCAL ? nullptr : &(this->UHM.GK),
this->p_hamilt = new hamilt::HamiltLCAO<TK, TR>(GlobalV::GAMMA_ONLY_LOCAL ? &(this->GG) : nullptr,
GlobalV::GAMMA_ONLY_LOCAL ? nullptr : &(this->GK),
&(this->UHM.genH),
&(this->LM),
&(this->LOC),
Expand Down Expand Up @@ -194,29 +199,29 @@ void ESolver_KS_LCAO<TK, TR>::beforesolver(const int istep)
if (GlobalV::GAMMA_ONLY_LOCAL)
{
Gint_inout inout(this->LOC.DM, this->pelec->charge->rho, Gint_Tools::job_type::rho);
this->UHM.GG.cal_gint(&inout);
this->GG.cal_gint(&inout);
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
for (int is = 0; is < GlobalV::NSPIN; is++)
{
ModuleBase::GlobalFunc::ZEROS(this->pelec->charge->kin_r[0], this->pw_rho->nrxx);
}
Gint_inout inout1(this->LOC.DM, this->pelec->charge->kin_r, Gint_Tools::job_type::tau);
this->UHM.GG.cal_gint(&inout1);
this->GG.cal_gint(&inout1);
}
}
else
{
Gint_inout inout(this->LOC.DM_R, this->pelec->charge->rho, Gint_Tools::job_type::rho);
this->UHM.GK.cal_gint(&inout);
this->GK.cal_gint(&inout);
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
{
for (int is = 0; is < GlobalV::NSPIN; is++)
{
ModuleBase::GlobalFunc::ZEROS(this->pelec->charge->kin_r[0], this->pw_rho->nrxx);
}
Gint_inout inout1(this->LOC.DM_R, this->pelec->charge->kin_r, Gint_Tools::job_type::tau);
this->UHM.GK.cal_gint(&inout1);
this->GK.cal_gint(&inout1);
}
}

Expand Down Expand Up @@ -389,7 +394,7 @@ void ESolver_KS_LCAO<TK, TR>::others(const int istep)
else if (GlobalV::CALCULATION == "get_pchg")
{
IState_Charge ISC(this->psi, this->LOC);
ISC.begin(this->UHM.GG,
ISC.begin(this->GG,
this->pelec,
this->pw_rho,
this->pw_big,
Expand All @@ -411,7 +416,7 @@ void ESolver_KS_LCAO<TK, TR>::others(const int istep)
this->pw_wfc,
this->pw_big,
this->LOWF,
this->UHM.GG,
this->GG,
INPUT.out_wfc_pw,
this->wf.out_wfc_r,
this->kv,
Expand All @@ -427,7 +432,7 @@ void ESolver_KS_LCAO<TK, TR>::others(const int istep)
this->pw_wfc,
this->pw_big,
this->LOWF,
this->UHM.GK,
this->GK,
INPUT.out_wfc_pw,
this->wf.out_wfc_r,
this->kv,
Expand Down
6 changes: 3 additions & 3 deletions source/module_esolver/esolver_ks_lcao_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ void ESolver_KS_LCAO_TDDFT::init(Input& inp, UnitCell& ucell)
this->pelec = new elecstate::ElecStateLCAO_TDDFT(&(this->chr),
&(kv),
kv.nks,
&(this->LOC),
&(this->UHM),
&(this->LOC),
&(this->GK), // mohan add 2024-04-01
&(this->LOWF),
this->pw_rho,
pw_big);
Expand Down Expand Up @@ -264,7 +264,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
{
if (!GlobalV::GAMMA_ONLY_LOCAL)
{
this->UHM.GK.renew(true);
this->GK.renew(true);
}
for (int ik = 0; ik < kv.nks; ++ik)
{
Expand Down
Loading