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
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
40 changes: 20 additions & 20 deletions source/source_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ 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;
scf_thr = inp.scf_thr;
scf_ene_thr = inp.scf_ene_thr;
maxniter = inp.scf_nmax;
niter = maxniter;
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 +83,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 +92,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 +103,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 +127,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
48 changes: 24 additions & 24 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"&& PARAM.inp.esolver_type != "tddft")
if (inp.init_wfc == "file" && inp.esolver_type != "tddft")
{
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
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
24 changes: 12 additions & 12 deletions source/source_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
this->pelec->omega = ucell.omega;

//! 3) inititlize the charge density.
this->chr.allocate(PARAM.inp.nspin);
this->chr.allocate(inp.nspin);

//! 4) initialize the potential.
if (this->pelec->pot == nullptr)
Expand All @@ -194,9 +194,9 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "NON-LOCAL POTENTIAL");

//! 7) Allocate and initialize psi
this->p_psi_init = new psi::PSIInit<T, Device>(PARAM.inp.init_wfc,
PARAM.inp.ks_solver,
PARAM.inp.basis_type,
this->p_psi_init = new psi::PSIInit<T, Device>(inp.init_wfc,
inp.ks_solver,
inp.basis_type,
GlobalV::MY_RANK,
ucell,
this->sf,
Expand All @@ -206,28 +206,28 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p

allocate_psi(this->psi, this->kv.get_nks(), this->kv.ngk, PARAM.globalv.nbands_l, this->pw_wfc->npwk_max);

this->p_psi_init->prepare_init(PARAM.inp.pw_seed);
this->p_psi_init->prepare_init(inp.pw_seed);

this->kspw_psi = PARAM.inp.device == "gpu" || PARAM.inp.precision == "single"
this->kspw_psi = inp.device == "gpu" || inp.precision == "single"
? new psi::Psi<T, Device>(this->psi[0])
: reinterpret_cast<psi::Psi<T, Device>*>(this->psi);

ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT BASIS");

//! 8) setup occupations
if (PARAM.inp.ocp)
if (inp.ocp)
{
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);
}

// 9) initialize exx pw
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 && GlobalC::exx_info.info_global.separate_loop == true)
{
Expand Down
10 changes: 5 additions & 5 deletions source/source_esolver/esolver_of.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void ESolver_OF::before_all_runners(UnitCell& ucell, const Input_para& inp)
}

// Setup the k points according to symmetry.
kv.set(ucell,ucell.symm, PARAM.inp.kpoint_file, PARAM.inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running);
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");

// print information
Expand Down Expand Up @@ -127,12 +127,12 @@ void ESolver_OF::before_all_runners(UnitCell& ucell, const Input_para& inp)

// Initialize KEDF
// Calculate electron numbers, which will be used to initialize WT KEDF
this->nelec_ = new double[PARAM.inp.nspin];
if (PARAM.inp.nspin == 1)
this->nelec_ = new double[inp.nspin];
if (inp.nspin == 1)
{
this->nelec_[0] = PARAM.inp.nelec;
this->nelec_[0] = inp.nelec;
}
else if (PARAM.inp.nspin == 2)
else if (inp.nspin == 2)
{
// in fact, nelec_spin will not be used anymore
this->pelec->init_nelec_spin();
Expand Down
2 changes: 1 addition & 1 deletion source/source_esolver/esolver_sdft_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void ESolver_SDFT_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input
true);
ModuleBase::Memory::record("SDFT::shchi", size * sizeof(T));

if (PARAM.inp.nbands > 0)
if (inp.nbands > 0)
{
this->stowf.chiortho
= new psi::Psi<T, Device>(this->kv.get_nks(),
Expand Down
Loading