Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 9 additions & 9 deletions source/source_esolver/esolver_fp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ ESolver_FP::~ESolver_FP()
void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
{
ModuleBase::TITLE("ESolver_FP", "before_all_runners");
std::string fft_device = PARAM.inp.device;
std::string fft_precison = PARAM.inp.precision;
std::string fft_device = inp.device;
std::string fft_precison = inp.precision;
// LCAO basis doesn't support GPU acceleration on FFT currently
if(PARAM.inp.basis_type == "lcao")
if(inp.basis_type == "lcao")
{
fft_device = "cpu";
}
if ((PARAM.inp.precision=="single") || (PARAM.inp.precision=="mixing"))
if ((inp.precision=="single") || (inp.precision=="mixing"))
{
fft_precison = "mixing";
}
else if (PARAM.inp.precision=="double")
else if (inp.precision=="double")
{
fft_precison = "double";
}
Expand All @@ -79,8 +79,8 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
pw_rhod = pw_rho;
}
pw_big = static_cast<ModulePW::PW_Basis_Big*>(pw_rhod);
pw_big->setbxyz(PARAM.inp.bx, PARAM.inp.by, PARAM.inp.bz);
sf.set(pw_rhod, PARAM.inp.nbspline);
pw_big->setbxyz(inp.bx, inp.by, inp.bz);
sf.set(pw_rhod, inp.nbspline);

//! 1) read pseudopotentials
elecstate::read_pseudo(GlobalV::ofs_running, ucell);
Expand All @@ -89,7 +89,7 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
#ifdef __MPI
this->pw_rho->initmpi(GlobalV::NPROC_IN_POOL, GlobalV::RANK_IN_POOL, POOL_WORLD);
#endif
if (this->classname == "ESolver_OF" || PARAM.inp.of_ml_gene_data == 1)
if (this->classname == "ESolver_OF" || inp.of_ml_gene_data == 1)
{
this->pw_rho->setfullpw(inp.of_full_pw, inp.of_full_pw_dim);
}
Expand Down Expand Up @@ -143,7 +143,7 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
ModuleIO::print_rhofft(this->pw_rhod, this->pw_rho, this->pw_big, GlobalV::ofs_running);

//! 5) initialize the charge extrapolation method if necessary
this->CE.Init_CE(PARAM.inp.nspin, ucell.nat, this->pw_rhod->nrxx, inp.chg_extrap);
this->CE.Init_CE(inp.nspin, ucell.nat, this->pw_rhod->nrxx, inp.chg_extrap);

return;
}
Expand Down
49 changes: 23 additions & 26 deletions source/source_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,20 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
classname = "ESolver_KS";
basisname = "";

scf_thr = PARAM.inp.scf_thr;
scf_ene_thr = PARAM.inp.scf_ene_thr;
maxniter = PARAM.inp.scf_nmax;
niter = maxniter;
niter = inp.scf_nmax;
drho = 0.0;

std::string fft_device = PARAM.inp.device;
std::string fft_device = inp.device;

// Fast Fourier Transform
// LCAO basis doesn't support GPU acceleration on FFT currently
if(PARAM.inp.basis_type == "lcao")
if(inp.basis_type == "lcao")
{
fft_device = "cpu";
}
std::string fft_precision = PARAM.inp.precision;
std::string fft_precision = inp.precision;
#ifdef __ENABLE_FLOAT_FFTW
if (PARAM.inp.cal_cond && PARAM.inp.esolver_type == "sdft")
if (inp.cal_cond && inp.esolver_type == "sdft")
{
fft_precision = "mixing";
}
Expand All @@ -83,7 +80,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
ModulePW::PW_Basis_K_Big* tmp = static_cast<ModulePW::PW_Basis_K_Big*>(pw_wfc);

// should not use INPUT here, mohan 2024-05-12
tmp->setbxyz(PARAM.inp.bx, PARAM.inp.by, PARAM.inp.bz);
tmp->setbxyz(inp.bx, inp.by, inp.bz);

///----------------------------------------------------------
/// charge mixing
Expand All @@ -92,7 +89,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
p_chgmix->set_rhopw(this->pw_rho, this->pw_rhod);

// cell_factor
this->ppcell.cell_factor = PARAM.inp.cell_factor;
this->ppcell.cell_factor = inp.cell_factor;


//! 3) it has been established that
Expand All @@ -103,16 +100,16 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SETUP UNITCELL");

//! 4) setup the charge mixing parameters
p_chgmix->set_mixing(PARAM.inp.mixing_mode,
PARAM.inp.mixing_beta,
PARAM.inp.mixing_ndim,
PARAM.inp.mixing_gg0,
PARAM.inp.mixing_tau,
PARAM.inp.mixing_beta_mag,
PARAM.inp.mixing_gg0_mag,
PARAM.inp.mixing_gg0_min,
PARAM.inp.mixing_angle,
PARAM.inp.mixing_dmr,
p_chgmix->set_mixing(inp.mixing_mode,
inp.mixing_beta,
inp.mixing_ndim,
inp.mixing_gg0,
inp.mixing_tau,
inp.mixing_beta_mag,
inp.mixing_gg0_mag,
inp.mixing_gg0_min,
inp.mixing_angle,
inp.mixing_dmr,
ucell.omega,
ucell.tpiba);

Expand All @@ -127,7 +124,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
}

//! 6) Setup the k points according to symmetry.
this->kv.set(ucell,ucell.symm, PARAM.inp.kpoint_file, PARAM.inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running);
this->kv.set(ucell,ucell.symm, inp.kpoint_file, inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running);
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS");

//! 7) print information
Expand Down Expand Up @@ -235,9 +232,9 @@ void ESolver_KS<T, Device>::runner(UnitCell& ucell, const int istep)
// 2) SCF iterations
//----------------------------------------------------------------
bool conv_esolver = false;
this->niter = this->maxniter;
this->niter = PARAM.inp.scf_nmax;
this->diag_ethr = PARAM.inp.pw_diag_thr;
for (int iter = 1; iter <= this->maxniter; ++iter)
for (int iter = 1; iter <= PARAM.inp.scf_nmax; ++iter)
{
//----------------------------------------------------------------
// 3) initialization of SCF iterations
Expand Down Expand Up @@ -398,10 +395,10 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
}
#endif

conv_esolver = (drho < this->scf_thr && not_restart_step && is_U_converged);
conv_esolver = (drho < PARAM.inp.scf_thr && not_restart_step && is_U_converged);

// add energy threshold for SCF convergence
if (this->scf_ene_thr > 0.0)
if (PARAM.inp.scf_ene_thr > 0.0)
{
// calculate energy of output charge density
this->update_pot(ucell, istep, iter, conv_esolver);
Expand All @@ -415,7 +412,7 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
{
// update the convergence flag
conv_esolver
= (std::abs(this->pelec->f_en.etot_delta * ModuleBase::Ry_to_eV) < this->scf_ene_thr);
= (std::abs(this->pelec->f_en.etot_delta * ModuleBase::Ry_to_eV) < PARAM.inp.scf_ene_thr);
}
}

Expand Down
3 changes: 0 additions & 3 deletions source/source_esolver/esolver_ks.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,8 @@ class ESolver_KS : public ESolver_FP
std::string basisname; //! esolver_ks_lcao.cpp
double esolver_KS_ne = 0.0; //! number of electrons
double diag_ethr; //! the threshold for diagonalization
double scf_thr; //! scf density threshold
double scf_ene_thr; //! scf energy threshold
double drho; //! the difference between rho_in (before HSolver) and rho_out (After HSolver)
double hsolver_error; //! the error of HSolver
int maxniter; //! maximum iter steps for scf
int niter; //! iter steps actually used in scf
bool oscillate_esolver = false; // whether esolver is oscillated
};
Expand Down
52 changes: 26 additions & 26 deletions source/source_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
int ncol = 0;
if (PARAM.globalv.gamma_only_local)
{
nsk = PARAM.inp.nspin;
nsk = inp.nspin;
ncol = this->pv.ncol_bands;
if (PARAM.inp.ks_solver == "genelpa" || PARAM.inp.ks_solver == "elpa" || PARAM.inp.ks_solver == "lapack"
|| PARAM.inp.ks_solver == "pexsi" || PARAM.inp.ks_solver == "cusolver"
|| PARAM.inp.ks_solver == "cusolvermp")
if (inp.ks_solver == "genelpa" || inp.ks_solver == "elpa" || inp.ks_solver == "lapack"
|| inp.ks_solver == "pexsi" || inp.ks_solver == "cusolver"
|| inp.ks_solver == "cusolvermp")
{
ncol = this->pv.ncol;
}
Expand All @@ -154,22 +154,22 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
#ifdef __MPI
ncol = this->pv.ncol_bands;
#else
ncol = PARAM.inp.nbands;
ncol = inp.nbands;
#endif
}
this->psi = new psi::Psi<TK>(nsk, ncol, this->pv.nrow, this->kv.ngk, true);
}

// 5) read psi from file
if (PARAM.inp.init_wfc == "file")
if (inp.init_wfc == "file")
{
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir,
this->pv,
*(this->psi),
this->pelec,
this->pelec->klist->ik2iktot,
this->pelec->klist->get_nkstot(),
PARAM.inp.nspin))
inp.nspin))
{
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO", "read electronic wave functions failed");
}
Expand All @@ -178,16 +178,16 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
// 6) initialize the density matrix
// DensityMatrix is allocated here, DMK is also initialized here
// DMR is not initialized here, it will be constructed in each before_scf
dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->init_DM(&this->kv, &(this->pv), PARAM.inp.nspin);
dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->init_DM(&this->kv, &(this->pv), inp.nspin);

// 7) initialize exact exchange calculations
#ifdef __EXX
if (PARAM.inp.calculation == "scf" || PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax"
|| PARAM.inp.calculation == "md")
if (inp.calculation == "scf" || inp.calculation == "relax" || inp.calculation == "cell-relax"
|| inp.calculation == "md")
{
if (GlobalC::exx_info.info_global.cal_exx)
{
if (PARAM.inp.init_wfc != "file")
if (inp.init_wfc != "file")
{ // if init_wfc==file, directly enter the EXX loop
XC_Functional::set_xc_first_loop(ucell);
}
Expand All @@ -208,7 +208,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
#endif

// 8) initialize DFT+U
if (PARAM.inp.dft_plus_u)
if (inp.dft_plus_u)
{
auto* dftu = ModuleDFTU::DFTU::get_instance();
dftu->init(ucell, &this->pv, this->kv.get_nks(), &orb_);
Expand All @@ -219,7 +219,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");

// 10) inititlize the charge density
this->chr.allocate(PARAM.inp.nspin);
this->chr.allocate(inp.nspin);
this->pelec->omega = ucell.omega;

// 11) initialize the potential
Expand All @@ -238,13 +238,13 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
// 12) initialize deepks
#ifdef __MLALGO
LCAO_domain::DeePKS_init(ucell, pv, this->kv.get_nks(), orb_, this->ld, GlobalV::ofs_running);
if (PARAM.inp.deepks_scf)
if (inp.deepks_scf)
{
// load the DeePKS model from deep neural network
DeePKS_domain::load_model(PARAM.inp.deepks_model, ld.model_deepks);
DeePKS_domain::load_model(inp.deepks_model, ld.model_deepks);
// read pdm from file for NSCF or SCF-restart, do it only once in whole calculation
DeePKS_domain::read_pdm((PARAM.inp.init_chg == "file"),
PARAM.inp.deepks_equiv,
DeePKS_domain::read_pdm((inp.init_chg == "file"),
inp.deepks_equiv,
ld.init_pdm,
ucell.nat,
orb_.Alpha[0].getTotal_nchi() * ucell.nat,
Expand All @@ -257,11 +257,11 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa

// 13) set occupations
// tddft does not need to set occupations in the first scf
if (PARAM.inp.ocp && inp.esolver_type != "tddft")
if (inp.ocp && inp.esolver_type != "tddft")
{
elecstate::fixed_weights(PARAM.inp.ocp_kb,
PARAM.inp.nbands,
PARAM.inp.nelec,
elecstate::fixed_weights(inp.ocp_kb,
inp.nbands,
inp.nelec,
this->pelec->klist,
this->pelec->wg,
this->pelec->skip_weights);
Expand Down Expand Up @@ -289,7 +289,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
}

// 15) initialize rdmft, added by jghan
if (PARAM.inp.rdmft == true)
if (inp.rdmft == true)
{
rdmft_solver.init(this->GG,
this->GK,
Expand All @@ -300,8 +300,8 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
*(this->pelec),
this->orb_,
two_center_bundle_,
PARAM.inp.dft_functional,
PARAM.inp.rdmft_power_alpha);
inp.dft_functional,
inp.rdmft_power_alpha);
}

ModuleBase::timer::tick("ESolver_KS_LCAO", "before_all_runners");
Expand Down Expand Up @@ -853,7 +853,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
*this->p_hamilt,
*this->pelec,
*this->p_chgmix,
this->scf_ene_thr,
PARAM.inp.scf_ene_thr,
iter,
istep,
conv_esolver)
Expand All @@ -862,7 +862,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
*this->p_hamilt,
*this->pelec,
*this->p_chgmix,
this->scf_ene_thr,
PARAM.inp.scf_ene_thr,
iter,
istep,
conv_esolver);
Expand Down
6 changes: 3 additions & 3 deletions source/source_esolver/esolver_ks_lcaopw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ namespace ModuleESolver
this->kv.ngk,
true);
#ifdef __EXX
if (PARAM.inp.calculation == "scf" || PARAM.inp.calculation == "relax"
|| PARAM.inp.calculation == "cell-relax"
|| PARAM.inp.calculation == "md") {
if (inp.calculation == "scf" || inp.calculation == "relax"
|| inp.calculation == "cell-relax"
|| inp.calculation == "md") {
if (GlobalC::exx_info.info_global.cal_exx)
{
XC_Functional::set_xc_first_loop(ucell);
Expand Down
Loading
Loading