diff --git a/docs/advanced/json/json_add.md b/docs/advanced/json/json_add.md index 2632257a86..f954e84167 100644 --- a/docs/advanced/json/json_add.md +++ b/docs/advanced/json/json_add.md @@ -170,7 +170,7 @@ namespace Json { #ifdef __RAPIDJSON -void gen_general_info(Input *input) +void gen_general_info(const Parameter& param) { #ifdef VERSION diff --git a/source/Makefile.Objects b/source/Makefile.Objects index e8924a31a0..87f20643f0 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -492,6 +492,7 @@ OBJS_IO=input.o\ read_input_item_postprocess.o\ read_input_item_md.o\ read_input_item_other.o\ + bcast_globalv.o OBJS_IO_LCAO=cal_r_overlap_R.o\ write_orb_info.o\ diff --git a/source/driver.cpp b/source/driver.cpp index d9583dfc7c..688c58669a 100644 --- a/source/driver.cpp +++ b/source/driver.cpp @@ -49,7 +49,7 @@ void Driver::init() // (5) output the json file // Json::create_Json(&GlobalC::ucell.symm,GlobalC::ucell.atoms,&INPUT); - Json::create_Json(&GlobalC::ucell, &INPUT); + Json::create_Json(&GlobalC::ucell, PARAM); } void Driver::print_start_info() @@ -68,7 +68,6 @@ void Driver::print_start_info() #endif time_t time_now = time(nullptr); - INPUT.start_time = time_now; PARAM.set_start_time(time_now); GlobalV::ofs_running << " " " " @@ -116,11 +115,11 @@ void Driver::reading() { ModuleBase::timer::tick("Driver", "reading"); // temperarily - GlobalV::MY_RANK = PARAM.sys.myrank; - GlobalV::NPROC = PARAM.sys.nproc; + GlobalV::MY_RANK = PARAM.globalv.myrank; + GlobalV::NPROC = PARAM.globalv.nproc; // (1) read the input file - ModuleIO::ReadInput read_input(PARAM.sys.myrank); + ModuleIO::ReadInput read_input(PARAM.globalv.myrank); read_input.read_parameters(PARAM, GlobalV::global_in_card); // (2) create the output directory, running_*.log and print info diff --git a/source/driver_run.cpp b/source/driver_run.cpp index cdd3b6ea04..21fd23bb0b 100644 --- a/source/driver_run.cpp +++ b/source/driver_run.cpp @@ -3,6 +3,7 @@ #include "module_cell/module_neighbor/sltk_atom_arrange.h" #include "module_hamilt_pw/hamilt_pwdft/global.h" #include "module_io/input.h" +#include "module_parameter/parameter.h" #include "module_io/para_json.h" #include "module_io/print_info.h" #include "module_io/winput.h" @@ -45,10 +46,10 @@ void Driver::driver_run() { GlobalV::MIN_DIST_COEF); //! 2: initialize the ESolver (depends on a set-up ucell after `setup_cell`) - ModuleESolver::ESolver* p_esolver = ModuleESolver::init_esolver(INPUT, PARAM.inp, GlobalC::ucell); + ModuleESolver::ESolver* p_esolver = ModuleESolver::init_esolver(PARAM.inp, GlobalC::ucell); //! 3: initialize Esolver and fill json-structure - p_esolver->before_all_runners(INPUT, GlobalC::ucell); + p_esolver->before_all_runners(PARAM.inp, GlobalC::ucell); // this Json part should be moved to before_all_runners, mohan 2024-05-12 #ifdef __RAPIDJSON diff --git a/source/module_cell/read_atoms.cpp b/source/module_cell/read_atoms.cpp index 17d498815b..aa5071aed8 100644 --- a/source/module_cell/read_atoms.cpp +++ b/source/module_cell/read_atoms.cpp @@ -125,7 +125,7 @@ int UnitCell::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_running) // Peize Lin add 2016-09-23 #ifdef __MPI #ifdef __EXX - if( GlobalC::exx_info.info_global.cal_exx || INPUT.rpa ) + if( GlobalC::exx_info.info_global.cal_exx || PARAM.inp.rpa ) { if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ABFS_ORBITAL") ) { diff --git a/source/module_elecstate/elecstate_getters.cpp b/source/module_elecstate/elecstate_getters.cpp index c948fb08ce..90b4c3ffdd 100644 --- a/source/module_elecstate/elecstate_getters.cpp +++ b/source/module_elecstate/elecstate_getters.cpp @@ -2,7 +2,7 @@ #include "module_cell/unitcell.h" #include "module_hamilt_pw/hamilt_pwdft/global.h" -#include "module_io/input.h" +#include "module_parameter/parameter.h" #include "module_hamilt_general/module_xc/xc_functional.h" namespace elecstate @@ -25,7 +25,7 @@ int get_xc_func_type() std::string get_input_vdw_method() { - return INPUT.vdw_method; + return PARAM.inp.vdw_method; } double get_ucell_tot_magnetization() diff --git a/source/module_esolver/esolver.cpp b/source/module_esolver/esolver.cpp index c427f96859..a32b8e3f18 100644 --- a/source/module_esolver/esolver.cpp +++ b/source/module_esolver/esolver.cpp @@ -122,7 +122,7 @@ std::string determine_type() //Some API to operate E_Solver -ESolver* init_esolver(Input& input, const Input_para& input_para, UnitCell& ucell) +ESolver* init_esolver(const Input_para& inp, UnitCell& ucell) { //determine type of esolver based on INPUT information const std::string esolver_type = determine_type(); @@ -187,9 +187,9 @@ ESolver* init_esolver(Input& input, const Input_para& input_para, UnitCell& ucel { // use constructor rather than Init function to initialize reference (instead of pointers) to ucell if (GlobalV::GAMMA_ONLY_LOCAL) - return new LR::ESolver_LR(input_para, input, ucell); + return new LR::ESolver_LR(inp, ucell); else if (GlobalV::NSPIN < 2) - return new LR::ESolver_LR, double>(input_para, input, ucell); + return new LR::ESolver_LR, double>(inp, ucell); else throw std::runtime_error("LR-TDDFT is not implemented for spin polarized case"); } @@ -209,7 +209,7 @@ ESolver* init_esolver(Input& input, const Input_para& input_para, UnitCell& ucel { p_esolver = new ESolver_KS_LCAO, std::complex>(); } - p_esolver->before_all_runners(input, ucell); + p_esolver->before_all_runners(inp, ucell); p_esolver->runner(0, ucell); // scf-only // force and stress is not needed currently, // they will be supported after the analytical gradient @@ -221,12 +221,12 @@ ESolver* init_esolver(Input& input, const Input_para& input_para, UnitCell& ucel if (GlobalV::GAMMA_ONLY_LOCAL) p_esolver_lr = new LR::ESolver_LR( std::move(*dynamic_cast*>(p_esolver)), - input_para, + inp, ucell); else p_esolver_lr = new LR::ESolver_LR, double>( std::move(*dynamic_cast, double>*>(p_esolver)), - input_para, + inp, ucell); // clean the 1st ESolver_KS and swap the pointer ModuleESolver::clean_esolver(p_esolver, false); // do not call Cblacs_exit, remain it for the 2nd ESolver @@ -247,7 +247,7 @@ ESolver* init_esolver(Input& input, const Input_para& input_para, UnitCell& ucel } else if (esolver_type == "dp_pot") { - return new ESolver_DP(INPUT.mdp.pot_file); + return new ESolver_DP(PARAM.mdp.pot_file); } throw std::invalid_argument("esolver_type = "+std::string(esolver_type)+". Wrong in "+std::string(__FILE__)+" line "+std::to_string(__LINE__)); } diff --git a/source/module_esolver/esolver.h b/source/module_esolver/esolver.h index 26f8706b12..214db6b13c 100644 --- a/source/module_esolver/esolver.h +++ b/source/module_esolver/esolver.h @@ -4,7 +4,7 @@ #include "module_base/matrix.h" #include "module_cell/unitcell.h" #include "module_io/input.h" -#include "module_parameter/input_parameter.h" +#include "module_parameter/parameter.h" namespace ModuleESolver { @@ -21,7 +21,7 @@ class ESolver } //! initialize the energy solver by using input parameters and cell modules - virtual void before_all_runners(Input& inp, UnitCell& cell) = 0; + virtual void before_all_runners(const Input_para& inp, UnitCell& cell) = 0; //! run energy solver virtual void runner(const int istep, UnitCell& cell) = 0; @@ -85,7 +85,7 @@ std::string determine_type(); * * @return [out] A pointer to an ESolver object that will be initialized. */ -ESolver* init_esolver(Input& input, const Input_para& input_para, UnitCell& ucell); +ESolver* init_esolver(const Input_para& inp, UnitCell& ucell); void clean_esolver(ESolver*& pesolver, const bool lcao_cblacs_exit = false); diff --git a/source/module_esolver/esolver_dp.cpp b/source/module_esolver/esolver_dp.cpp index 34e0cc14c5..44f8a93cab 100644 --- a/source/module_esolver/esolver_dp.cpp +++ b/source/module_esolver/esolver_dp.cpp @@ -25,7 +25,7 @@ namespace ModuleESolver { -void ESolver_DP::before_all_runners(Input& inp, UnitCell& ucell) +void ESolver_DP::before_all_runners(const Input_para& inp, UnitCell& ucell) { ucell_ = &ucell; dp_potential = 0; diff --git a/source/module_esolver/esolver_dp.h b/source/module_esolver/esolver_dp.h index d675563986..537ef0d6b1 100644 --- a/source/module_esolver/esolver_dp.h +++ b/source/module_esolver/esolver_dp.h @@ -36,7 +36,7 @@ class ESolver_DP : public ESolver * @param inp input parameters * @param cell unitcell information */ - void before_all_runners(Input& inp, UnitCell& cell) override; + void before_all_runners(const Input_para& inp, UnitCell& cell) override; /** * @brief Run the DP solver for a given ion/md step and unit cell diff --git a/source/module_esolver/esolver_fp.cpp b/source/module_esolver/esolver_fp.cpp index 001c27067a..6f4b0704fb 100644 --- a/source/module_esolver/esolver_fp.cpp +++ b/source/module_esolver/esolver_fp.cpp @@ -23,8 +23,8 @@ ESolver_FP::ESolver_FP() // temporary, it will be removed pw_big = static_cast(pw_rhod); - pw_big->setbxyz(INPUT.bx, INPUT.by, INPUT.bz); - sf.set(pw_rhod, INPUT.nbspline); + pw_big->setbxyz(PARAM.inp.bx, PARAM.inp.by, PARAM.inp.bz); + sf.set(pw_rhod, PARAM.inp.nbspline); GlobalC::ucell.symm.epsilon = GlobalC::ucell.symm.epsilon_input = PARAM.inp.symmetry_prec; } @@ -39,7 +39,7 @@ ESolver_FP::~ESolver_FP() delete this->pelec; } -void ESolver_FP::before_all_runners(Input& inp, UnitCell& cell) +void ESolver_FP::before_all_runners(const Input_para& inp, UnitCell& cell) { ModuleBase::TITLE("ESolver_FP", "before_all_runners"); @@ -105,7 +105,7 @@ void ESolver_FP::before_all_runners(Input& inp, UnitCell& cell) return; } -void ESolver_FP::init_after_vc(Input& inp, UnitCell& cell) +void ESolver_FP::init_after_vc(const Input_para& inp, UnitCell& cell) { ModuleBase::TITLE("ESolver_FP", "init_after_vc"); @@ -174,7 +174,7 @@ void ESolver_FP::init_after_vc(Input& inp, UnitCell& cell) return; } -void ESolver_FP::print_rhofft(Input& inp, std::ofstream& ofs) +void ESolver_FP::print_rhofft(const Input_para& inp, std::ofstream& ofs) { std::cout << " UNIFORM GRID DIM : " << pw_rho->nx << " * " << pw_rho->ny << " * " << pw_rho->nz << std::endl; std::cout << " UNIFORM GRID DIM(BIG) : " << pw_big->nbx << " * " << pw_big->nby << " * " << pw_big->nbz @@ -219,7 +219,7 @@ void ESolver_FP::print_rhofft(Input& inp, std::ofstream& ofs) ofs << "\n\n\n\n"; ofs << "\n SETUP THE PLANE WAVE BASIS" << std::endl; - double ecut = 4 * INPUT.ecutwfc; + double ecut = 4 * PARAM.inp.ecutwfc; if (inp.nx * inp.ny * inp.nz > 0) { ecut = this->pw_rho->gridecut_lat * this->pw_rho->tpiba2; @@ -264,7 +264,7 @@ void ESolver_FP::print_rhofft(Input& inp, std::ofstream& ofs) ofs << std::endl; ofs << std::endl; ofs << std::endl; - double ecut = INPUT.ecutrho; + double ecut = PARAM.inp.ecutrho; if (inp.ndx * inp.ndy * inp.ndz > 0) { ecut = this->pw_rhod->gridecut_lat * this->pw_rhod->tpiba2; diff --git a/source/module_esolver/esolver_fp.h b/source/module_esolver/esolver_fp.h index cf7cd499c8..16a982ca8c 100644 --- a/source/module_esolver/esolver_fp.h +++ b/source/module_esolver/esolver_fp.h @@ -40,9 +40,9 @@ namespace ModuleESolver virtual ~ESolver_FP(); //! Initialize of the first-principels energy solver - virtual void before_all_runners(Input& inp, UnitCell& cell) override; + virtual void before_all_runners(const Input_para& inp, UnitCell& cell) override; - virtual void init_after_vc(Input& inp, UnitCell& cell); // liuyu add 2023-03-09 + virtual void init_after_vc(const Input_para& inp, UnitCell& cell); // liuyu add 2023-03-09 //! Electronic states elecstate::ElecState* pelec = nullptr; @@ -62,7 +62,7 @@ namespace ModuleESolver private: //! Print charge density using FFT - void print_rhofft(Input& inp, std::ofstream &ofs); + void print_rhofft(const Input_para& inp, std::ofstream &ofs); }; } diff --git a/source/module_esolver/esolver_ks.cpp b/source/module_esolver/esolver_ks.cpp index 8a67c7e9ba..703c951fff 100644 --- a/source/module_esolver/esolver_ks.cpp +++ b/source/module_esolver/esolver_ks.cpp @@ -56,7 +56,7 @@ ESolver_KS::ESolver_KS() ModulePW::PW_Basis_K_Big* tmp = static_cast(pw_wfc); // should not use INPUT here, mohan 2024-05-12 - tmp->setbxyz(INPUT.bx, INPUT.by, INPUT.bz); + tmp->setbxyz(PARAM.inp.bx, PARAM.inp.by, PARAM.inp.bz); ///---------------------------------------------------------- /// charge mixing @@ -67,10 +67,10 @@ ESolver_KS::ESolver_KS() ///---------------------------------------------------------- /// wavefunc ///---------------------------------------------------------- - this->wf.init_wfc = INPUT.init_wfc; - this->wf.mem_saver = INPUT.mem_saver; - this->wf.out_wfc_pw = INPUT.out_wfc_pw; - this->wf.out_wfc_r = INPUT.out_wfc_r; + this->wf.init_wfc = PARAM.inp.init_wfc; + this->wf.mem_saver = PARAM.inp.mem_saver; + this->wf.out_wfc_pw = PARAM.inp.out_wfc_pw; + this->wf.out_wfc_r = PARAM.inp.out_wfc_r; } //------------------------------------------------------------------------------ @@ -92,7 +92,7 @@ ESolver_KS::~ESolver_KS() //! mohan add 2024-05-11 //------------------------------------------------------------------------------ template -void ESolver_KS::before_all_runners(Input& inp, UnitCell& ucell) +void ESolver_KS::before_all_runners(const Input_para& inp, UnitCell& ucell) { ModuleBase::TITLE("ESolver_KS", "before_all_runners"); @@ -344,7 +344,7 @@ void ESolver_KS::before_all_runners(Input& inp, UnitCell& ucell) //! mohan add 2024-05-11 //------------------------------------------------------------------------------ template -void ESolver_KS::init_after_vc(Input& inp, UnitCell& ucell) +void ESolver_KS::init_after_vc(const Input_para& inp, UnitCell& ucell) { ModuleBase::TITLE("ESolver_KS", "init_after_vc"); @@ -388,7 +388,7 @@ void ESolver_KS::hamilt2density(const int istep, const int iter, cons //! mohan add 2024-05-11 //------------------------------------------------------------------------------ template -void ESolver_KS::print_wfcfft(Input& inp, std::ofstream& ofs) +void ESolver_KS::print_wfcfft(const Input_para& inp, std::ofstream& ofs) { ofs << "\n\n\n\n"; ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" @@ -718,7 +718,7 @@ void ESolver_KS::print_iter(const int iter, const double duration, const double ethr) { - this->pelec->print_etot(this->conv_elec, iter, drho, dkin, duration, INPUT.printe, ethr); + this->pelec->print_etot(this->conv_elec, iter, drho, dkin, duration, PARAM.inp.printe, ethr); } //------------------------------------------------------------------------------ diff --git a/source/module_esolver/esolver_ks.h b/source/module_esolver/esolver_ks.h index 8ffb1158f9..b9a1c843f9 100644 --- a/source/module_esolver/esolver_ks.h +++ b/source/module_esolver/esolver_ks.h @@ -42,9 +42,9 @@ class ESolver_KS : public ESolver_FP int out_freq_elec;// frequency for output - virtual void before_all_runners(Input& inp, UnitCell& cell) override; + virtual void before_all_runners(const Input_para& inp, UnitCell& cell) override; - virtual void init_after_vc(Input& inp, UnitCell& cell) override; // liuyu add 2023-03-09 + virtual void init_after_vc(const Input_para& inp, UnitCell& cell) override; // liuyu add 2023-03-09 virtual void runner(const int istep, UnitCell& cell) override; @@ -137,7 +137,7 @@ class ESolver_KS : public ESolver_FP std::string basisname; //PW or LCAO - void print_wfcfft(Input& inp, std::ofstream& ofs); -}; + void print_wfcfft(const Input_para& inp, std::ofstream &ofs); +}; } // end of namespace #endif diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index b0998a3bac..5dbc6c6d23 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -110,7 +110,7 @@ ESolver_KS_LCAO::~ESolver_KS_LCAO() //! 14) set occupations? //------------------------------------------------------------------------------ template -void ESolver_KS_LCAO::before_all_runners(Input& inp, UnitCell& ucell) +void ESolver_KS_LCAO::before_all_runners(const Input_para& inp, UnitCell& ucell) { ModuleBase::TITLE("ESolver_KS_LCAO", "before_all_runners"); ModuleBase::timer::tick("ESolver_KS_LCAO", "before_all_runners"); @@ -253,7 +253,7 @@ void ESolver_KS_LCAO::before_all_runners(Input& inp, UnitCell& ucell) //! mohan add 2024-05-11 //------------------------------------------------------------------------------ template -void ESolver_KS_LCAO::init_after_vc(Input& inp, UnitCell& ucell) +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"); @@ -386,7 +386,7 @@ void ESolver_KS_LCAO::after_all_runners() GlobalV::ofs_running << " !FINAL_ETOT_IS " << this->pelec->f_en.etot * ModuleBase::Ry_to_eV << " eV" << std::endl; GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl; - if (INPUT.out_dos != 0 || INPUT.out_band[0] != 0 || INPUT.out_proj_band != 0) + if (PARAM.inp.out_dos != 0 || PARAM.inp.out_band[0] != 0 || PARAM.inp.out_proj_band != 0) { GlobalV::ofs_running << "\n\n\n\n"; GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" @@ -426,7 +426,7 @@ void ESolver_KS_LCAO::after_all_runners() const int nspin0 = (GlobalV::NSPIN == 2) ? 2 : 1; - if (INPUT.out_band[0]) + if (PARAM.inp.out_band[0]) { for (int is = 0; is < nspin0; is++) { @@ -437,27 +437,27 @@ void ESolver_KS_LCAO::after_all_runners() ss2.str(), GlobalV::NBANDS, 0.0, - INPUT.out_band[1], + PARAM.inp.out_band[1], this->pelec->ekb, this->kv, &(GlobalC::Pkpoints)); } } // out_band - if (INPUT.out_proj_band) // Projeced band structure added by jiyy-2022-4-20 + if (PARAM.inp.out_proj_band) // Projeced band structure added by jiyy-2022-4-20 { ModuleIO::write_proj_band_lcao(this->psi, this->ParaV, this->pelec, this->kv, GlobalC::ucell, this->p_hamilt); } - if (INPUT.out_dos) + if (PARAM.inp.out_dos) { ModuleIO::out_dos_nao(this->psi, this->ParaV, this->pelec->ekb, this->pelec->wg, - INPUT.dos_edelta_ev, - INPUT.dos_scale, - INPUT.dos_sigma, + PARAM.inp.dos_edelta_ev, + PARAM.inp.dos_scale, + PARAM.inp.dos_sigma, *(this->pelec->klist), GlobalC::Pkpoints, GlobalC::ucell, @@ -499,7 +499,7 @@ void ESolver_KS_LCAO::after_all_runners() //! mohan add 2024-05-11 //------------------------------------------------------------------------------ template -void ESolver_KS_LCAO::init_basis_lcao(Input& inp, UnitCell& ucell) +void ESolver_KS_LCAO::init_basis_lcao(const Input_para& inp, UnitCell& ucell) { ModuleBase::TITLE("ESolver_KS_LCAO", "init_basis_lcao"); @@ -800,7 +800,7 @@ void ESolver_KS_LCAO::hamilt2density(int istep, int iter, double ethr) // 4) print bands for each k-point and each band for (int ik = 0; ik < this->kv.get_nks(); ++ik) { - this->pelec->print_band(ik, INPUT.printe, iter); + this->pelec->print_band(ik, PARAM.inp.printe, iter); } // 5) what's the exd used for? @@ -1211,7 +1211,7 @@ void ESolver_KS_LCAO::after_scf(const int istep) #ifdef __EXX // 11) write rpa information - if (INPUT.rpa) + if (PARAM.inp.rpa) { // ModuleRPA::DFT_RPA_interface // rpa_interface(GlobalC::exx_info.info_global); @@ -1367,7 +1367,7 @@ ModuleIO::Output_Mat_Sparse ESolver_KS_LCAO::create_Output_Mat_Spars return ModuleIO::Output_Mat_Sparse(hsolver::HSolverLCAO::out_mat_hsR, hsolver::HSolverLCAO::out_mat_dh, hsolver::HSolverLCAO::out_mat_t, - INPUT.out_mat_r, + PARAM.inp.out_mat_r, istep, this->pelec->pot->get_effective_v(), this->ParaV, diff --git a/source/module_esolver/esolver_ks_lcao.h b/source/module_esolver/esolver_ks_lcao.h index b82af80a9c..697014396c 100644 --- a/source/module_esolver/esolver_ks_lcao.h +++ b/source/module_esolver/esolver_ks_lcao.h @@ -27,9 +27,9 @@ class ESolver_KS_LCAO : public ESolver_KS { ESolver_KS_LCAO(); ~ESolver_KS_LCAO(); - void before_all_runners(Input& inp, UnitCell& cell) override; + void before_all_runners(const Input_para& inp, UnitCell& cell) override; - void init_after_vc(Input& inp, UnitCell& cell) override; + void init_after_vc(const Input_para& inp, UnitCell& cell) override; double cal_energy() override; @@ -87,7 +87,7 @@ class ESolver_KS_LCAO : public ESolver_KS { ModuleBase::matrix scs; bool have_force = false; - void init_basis_lcao(Input& inp, UnitCell& ucell); + void init_basis_lcao(const Input_para& inp, UnitCell& ucell); //--------------common for all calculation, not only scf------------- // set matrix and grid integral diff --git a/source/module_esolver/esolver_ks_lcao_elec.cpp b/source/module_esolver/esolver_ks_lcao_elec.cpp index 3699a53c7a..a77ccb92f0 100644 --- a/source/module_esolver/esolver_ks_lcao_elec.cpp +++ b/source/module_esolver/esolver_ks_lcao_elec.cpp @@ -159,7 +159,7 @@ void ESolver_KS_LCAO::beforesolver(const int istep) } // init wfc from file - if(istep == 0 && INPUT.init_wfc == "file") + if(istep == 0 && PARAM.inp.init_wfc == "file") { if (! ModuleIO::read_wfc_nao(GlobalV::global_readin_dir, this->ParaV, *(this->psi), this->pelec)) { @@ -255,7 +255,7 @@ void ESolver_KS_LCAO::before_scf(const int istep) if (GlobalC::ucell.cell_parameter_updated) { - this->init_after_vc(INPUT, GlobalC::ucell); + this->init_after_vc(PARAM.inp, GlobalC::ucell); } if (GlobalC::ucell.ionic_position_updated) { @@ -272,7 +272,7 @@ void ESolver_KS_LCAO::before_scf(const int istep) //---------------------------------------------------------- // about vdw, jiyy add vdwd3 and linpz add vdwd2 //---------------------------------------------------------- - auto vdw_solver = vdw::make_vdw(GlobalC::ucell, INPUT); + auto vdw_solver = vdw::make_vdw(GlobalC::ucell, PARAM.inp); if (vdw_solver != nullptr) { this->pelec->f_en.evdw = vdw_solver->get_energy(); @@ -477,7 +477,7 @@ void ESolver_KS_LCAO::others(const int istep) this->pw_big, this->ParaV, this->GG, - INPUT.out_wfc_pw, + PARAM.inp.out_wfc_pw, this->wf.out_wfc_r, this->kv, GlobalV::nelec, @@ -496,7 +496,7 @@ void ESolver_KS_LCAO::others(const int istep) this->pw_big, this->ParaV, this->GK, - INPUT.out_wfc_pw, + PARAM.inp.out_wfc_pw, this->wf.out_wfc_r, this->kv, GlobalV::nelec, @@ -679,18 +679,18 @@ void ESolver_KS_LCAO::nscf() { } // add by jingan in 2018.11.7 - if (GlobalV::CALCULATION == "nscf" && INPUT.towannier90) + if (GlobalV::CALCULATION == "nscf" && PARAM.inp.towannier90) { #ifdef __LCAO std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Wave function to Wannier90"); - if (INPUT.wannier_method == 1) { - toWannier90_LCAO_IN_PW myWannier(INPUT.out_wannier_mmn, - INPUT.out_wannier_amn, - INPUT.out_wannier_unk, - INPUT.out_wannier_eig, - INPUT.out_wannier_wvfn_formatted, - INPUT.nnkpfile, - INPUT.wannier_spin); + if (PARAM.inp.wannier_method == 1) { + toWannier90_LCAO_IN_PW myWannier(PARAM.inp.out_wannier_mmn, + PARAM.inp.out_wannier_amn, + PARAM.inp.out_wannier_unk, + PARAM.inp.out_wannier_eig, + PARAM.inp.out_wannier_wvfn_formatted, + PARAM.inp.nnkpfile, + PARAM.inp.wannier_spin); myWannier.calculate(this->pelec->ekb, this->pw_wfc, @@ -700,15 +700,15 @@ void ESolver_KS_LCAO::nscf() { this->psi, &(this->ParaV)); } - else if (INPUT.wannier_method == 2) + else if (PARAM.inp.wannier_method == 2) { - toWannier90_LCAO myWannier(INPUT.out_wannier_mmn, - INPUT.out_wannier_amn, - INPUT.out_wannier_unk, - INPUT.out_wannier_eig, - INPUT.out_wannier_wvfn_formatted, - INPUT.nnkpfile, - INPUT.wannier_spin); + toWannier90_LCAO myWannier(PARAM.inp.out_wannier_mmn, + PARAM.inp.out_wannier_amn, + PARAM.inp.out_wannier_unk, + PARAM.inp.out_wannier_eig, + PARAM.inp.out_wannier_wvfn_formatted, + PARAM.inp.nnkpfile, + PARAM.inp.wannier_spin); myWannier.calculate(this->pelec->ekb, this->kv, *(this->psi), &(this->ParaV)); } diff --git a/source/module_esolver/esolver_ks_lcao_tddft.cpp b/source/module_esolver/esolver_ks_lcao_tddft.cpp index 45d176ee4a..edfc1a3397 100644 --- a/source/module_esolver/esolver_ks_lcao_tddft.cpp +++ b/source/module_esolver/esolver_ks_lcao_tddft.cpp @@ -64,7 +64,7 @@ ESolver_KS_LCAO_TDDFT::~ESolver_KS_LCAO_TDDFT() } } -void ESolver_KS_LCAO_TDDFT::before_all_runners(Input& inp, UnitCell& ucell) +void ESolver_KS_LCAO_TDDFT::before_all_runners(const Input_para& inp, UnitCell& ucell) { // 1) run "before_all_runners" in ESolver_KS ESolver_KS::before_all_runners(inp, ucell); @@ -201,7 +201,7 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density(const int istep, const int iter, cons for (int ik = 0; ik < kv.get_nks(); ++ik) { - this->pelec_td->print_band(ik, INPUT.printe, iter); + this->pelec_td->print_band(ik, PARAM.inp.printe, iter); } // using new charge density. diff --git a/source/module_esolver/esolver_ks_lcao_tddft.h b/source/module_esolver/esolver_ks_lcao_tddft.h index bdf53f2f51..46a3ed084e 100644 --- a/source/module_esolver/esolver_ks_lcao_tddft.h +++ b/source/module_esolver/esolver_ks_lcao_tddft.h @@ -16,7 +16,7 @@ class ESolver_KS_LCAO_TDDFT : public ESolver_KS_LCAO, doubl ~ESolver_KS_LCAO_TDDFT(); - void before_all_runners(Input& inp, UnitCell& cell) override; + void before_all_runners(const Input_para& inp, UnitCell& cell) override; psi::Psi>* psi_laststep = nullptr; diff --git a/source/module_esolver/esolver_ks_lcaopw.cpp b/source/module_esolver/esolver_ks_lcaopw.cpp index 906a5c7807..b7c86aa0a0 100644 --- a/source/module_esolver/esolver_ks_lcaopw.cpp +++ b/source/module_esolver/esolver_ks_lcaopw.cpp @@ -82,7 +82,7 @@ namespace ModuleESolver } template - void ESolver_KS_LIP::before_all_runners(Input& inp, UnitCell& cell) + void ESolver_KS_LIP::before_all_runners(const Input_para& inp, UnitCell& cell) { ESolver_KS_PW::before_all_runners(inp, cell); #ifdef __EXX diff --git a/source/module_esolver/esolver_ks_lcaopw.h b/source/module_esolver/esolver_ks_lcaopw.h index 128ca5aeeb..ef5b73cc6a 100644 --- a/source/module_esolver/esolver_ks_lcaopw.h +++ b/source/module_esolver/esolver_ks_lcaopw.h @@ -23,7 +23,7 @@ namespace ModuleESolver /// All the other interfaces except this one are the same as ESolver_KS_PW. virtual void hamilt2density(const int istep, const int iter, const double ethr) override; - void before_all_runners(Input& inp, UnitCell& cell) override; + void before_all_runners(const Input_para& inp, UnitCell& cell) override; void iter_init(const int istep, const int iter) override; void after_all_runners()override; diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index 10f613bf7e..74724c6cd1 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -91,7 +91,7 @@ ESolver_KS_PW::~ESolver_KS_PW() { } template -void ESolver_KS_PW::Init_GlobalC(Input& inp, +void ESolver_KS_PW::Init_GlobalC(const Input_para& inp, UnitCell& ucell, pseudopot_cell_vnl& ppcell) { // GlobalC is a historically left-over namespace, it is used to store global @@ -144,7 +144,7 @@ void ESolver_KS_PW::Init_GlobalC(Input& inp, } template -void ESolver_KS_PW::before_all_runners(Input& inp, UnitCell& ucell) { +void ESolver_KS_PW::before_all_runners(const Input_para& inp, UnitCell& ucell) { // 1) call before_all_runners() of ESolver_KS ESolver_KS::before_all_runners(inp, ucell); @@ -232,7 +232,7 @@ void ESolver_KS_PW::deallocate_hamilt() this->p_hamilt = nullptr; } template -void ESolver_KS_PW::init_after_vc(Input& inp, UnitCell& ucell) { +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"); @@ -251,7 +251,7 @@ void ESolver_KS_PW::init_after_vc(Input& inp, UnitCell& ucell) { this->kv.kvec_d.data()); #ifdef __MPI - if (INPUT.pw_seed > 0) { + if (PARAM.inp.pw_seed > 0) { MPI_Allreduce(MPI_IN_PLACE, &this->pw_wfc->ggecut, 1, @@ -316,7 +316,7 @@ void ESolver_KS_PW::init_after_vc(Input& inp, UnitCell& ucell) { this->pw_wfc->nz); this->pw_wfc->initparameters(false, - INPUT.ecutwfc, + PARAM.inp.ecutwfc, this->kv.get_nks(), this->kv.kvec_d.data()); @@ -329,8 +329,8 @@ void ESolver_KS_PW::init_after_vc(Input& inp, UnitCell& ucell) { #ifdef USE_PAW if (GlobalV::use_paw) { - GlobalC::paw_cell.set_libpaw_ecut(INPUT.ecutwfc / 2.0, - INPUT.ecutwfc / 2.0); // in Hartree + 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, @@ -386,7 +386,7 @@ void ESolver_KS_PW::before_scf(const int istep) { ModuleBase::TITLE("ESolver_KS_PW", "before_scf"); if (GlobalC::ucell.cell_parameter_updated) { - this->init_after_vc(INPUT, GlobalC::ucell); + this->init_after_vc(PARAM.inp, GlobalC::ucell); } if (GlobalC::ucell.ionic_position_updated) { this->CE.update_all_dis(GlobalC::ucell); @@ -410,7 +410,7 @@ void ESolver_KS_PW::before_scf(const int istep) { //---------------------------------------------------------- // about vdw, jiyy add vdwd3 and linpz add vdwd2 //---------------------------------------------------------- - auto vdw_solver = vdw::make_vdw(GlobalC::ucell, INPUT); + auto vdw_solver = vdw::make_vdw(GlobalC::ucell, PARAM.inp); if (vdw_solver != nullptr) { this->pelec->f_en.evdw = vdw_solver->get_energy(); } @@ -524,9 +524,9 @@ void ESolver_KS_PW::others(const int istep) { } else if (cal_type == "gen_bessel") { Numerical_Descriptor nc; nc.output_descriptor(this->psi[0], - INPUT.bessel_descriptor_lmax, - INPUT.bessel_descriptor_rcut, - INPUT.bessel_descriptor_tolerence, + PARAM.inp.bessel_descriptor_lmax, + PARAM.inp.bessel_descriptor_rcut, + PARAM.inp.bessel_descriptor_tolerence, this->kv.get_nks()); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "GENERATE DESCRIPTOR FOR DEEPKS"); @@ -921,7 +921,7 @@ void ESolver_KS_PW::after_all_runners() { GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl; - if (INPUT.out_dos != 0 || INPUT.out_band[0] != 0) { + if (PARAM.inp.out_dos != 0 || PARAM.inp.out_band[0] != 0) { GlobalV::ofs_running << "\n\n\n\n"; GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" ">>>>>>>>>>>>>>>>>>>>>>>>>" @@ -964,13 +964,13 @@ void ESolver_KS_PW::after_all_runners() { &(GlobalC::Pkpoints)); //! compute density of states - if (INPUT.out_dos) { + if (PARAM.inp.out_dos) { ModuleIO::write_dos_pw(this->pelec->ekb, this->pelec->wg, this->kv, - INPUT.dos_edelta_ev, - INPUT.dos_scale, - INPUT.dos_sigma); + PARAM.inp.dos_edelta_ev, + PARAM.inp.dos_scale, + PARAM.inp.dos_sigma); if (nspin0 == 1) { GlobalV::ofs_running << " Fermi energy is " << this->pelec->eferm.ef @@ -985,7 +985,7 @@ void ESolver_KS_PW::after_all_runners() { } } - if (INPUT.out_band[0]) // pengfei 2014-10-13 + if (PARAM.inp.out_band[0]) // pengfei 2014-10-13 { for (int is = 0; is < nspin0; is++) { std::stringstream ss2; @@ -996,7 +996,7 @@ void ESolver_KS_PW::after_all_runners() { ss2.str(), GlobalV::NBANDS, 0.0, - INPUT.out_band[1], + PARAM.inp.out_band[1], this->pelec->ekb, this->kv, &(GlobalC::Pkpoints)); @@ -1011,13 +1011,13 @@ void ESolver_KS_PW::after_all_runners() { // ! Print out overlap before spillage optimization to generate atomic // orbitals if (winput::out_spillage <= 2) { - for (int i = 0; i < INPUT.bessel_nao_rcuts.size(); i++) { + for (int i = 0; i < PARAM.inp.bessel_nao_rcuts.size(); i++) { if (GlobalV::MY_RANK == 0) { std::cout << "update value: bessel_nao_rcut <- " - << std::fixed << INPUT.bessel_nao_rcuts[i] + << std::fixed << PARAM.inp.bessel_nao_rcuts[i] << " a.u." << std::endl; } - INPUT.bessel_nao_rcut = INPUT.bessel_nao_rcuts[i]; + INPUT.bessel_nao_rcut = PARAM.inp.bessel_nao_rcuts[i]; Numerical_Basis numerical_basis; numerical_basis.output_overlap(this->psi[0], this->sf, @@ -1041,19 +1041,19 @@ void ESolver_KS_PW::after_all_runners() { } //! Use Kubo-Greenwood method to compute conductivities - if (INPUT.cal_cond) { + if (PARAM.inp.cal_cond) { EleCond elec_cond(&GlobalC::ucell, &this->kv, this->pelec, this->pw_wfc, this->psi, &GlobalC::ppcell); - elec_cond.KG(INPUT.cond_smear, - INPUT.cond_fwhm, - INPUT.cond_wcut, - INPUT.cond_dw, - INPUT.cond_dt, - INPUT.cond_nonlocal, + elec_cond.KG(PARAM.inp.cond_smear, + PARAM.inp.cond_fwhm, + PARAM.inp.cond_wcut, + PARAM.inp.cond_dw, + PARAM.inp.cond_dt, + PARAM.inp.cond_nonlocal, this->pelec->wg); } } @@ -1152,15 +1152,15 @@ void ESolver_KS_PW::nscf() { } //! 6) calculate Wannier functions - if (INPUT.towannier90) { + if (PARAM.inp.towannier90) { std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Wannier functions calculation"); - toWannier90_PW wan(INPUT.out_wannier_mmn, - INPUT.out_wannier_amn, - INPUT.out_wannier_unk, - INPUT.out_wannier_eig, - INPUT.out_wannier_wvfn_formatted, - INPUT.nnkpfile, - INPUT.wannier_spin); + toWannier90_PW wan(PARAM.inp.out_wannier_mmn, + PARAM.inp.out_wannier_amn, + PARAM.inp.out_wannier_unk, + PARAM.inp.out_wannier_eig, + PARAM.inp.out_wannier_wvfn_formatted, + PARAM.inp.nnkpfile, + PARAM.inp.wannier_spin); wan.calculate(this->pelec->ekb, this->pw_wfc, diff --git a/source/module_esolver/esolver_ks_pw.h b/source/module_esolver/esolver_ks_pw.h index c434a61403..4b66d82064 100644 --- a/source/module_esolver/esolver_ks_pw.h +++ b/source/module_esolver/esolver_ks_pw.h @@ -21,9 +21,9 @@ class ESolver_KS_PW : public ESolver_KS ~ESolver_KS_PW(); - void before_all_runners(Input& inp, UnitCell& cell) override; + void before_all_runners(const Input_para& inp, UnitCell& cell) override; - void init_after_vc(Input& inp, UnitCell& cell) override; + void init_after_vc(const Input_para& inp, UnitCell& cell) override; double cal_energy() override; @@ -54,7 +54,7 @@ class ESolver_KS_PW : public ESolver_KS // temporary, this will be removed in the future; // Init Global class - void Init_GlobalC(Input& inp, UnitCell& ucell, pseudopot_cell_vnl& ppcell); + void Init_GlobalC(const Input_para& inp, UnitCell& ucell, pseudopot_cell_vnl& ppcell); virtual void allocate_hsolver(); virtual void deallocate_hsolver(); diff --git a/source/module_esolver/esolver_lj.cpp b/source/module_esolver/esolver_lj.cpp index d39d9e0465..3b767d6cd8 100644 --- a/source/module_esolver/esolver_lj.cpp +++ b/source/module_esolver/esolver_lj.cpp @@ -7,7 +7,7 @@ namespace ModuleESolver { - void ESolver_LJ::before_all_runners(Input& inp, UnitCell& ucell) + void ESolver_LJ::before_all_runners(const Input_para& inp, UnitCell& ucell) { ucell_ = &ucell; lj_potential = 0; diff --git a/source/module_esolver/esolver_lj.h b/source/module_esolver/esolver_lj.h index 368174d126..e7d573d825 100644 --- a/source/module_esolver/esolver_lj.h +++ b/source/module_esolver/esolver_lj.h @@ -14,7 +14,7 @@ namespace ModuleESolver classname = "ESolver_LJ"; } - void before_all_runners(Input& inp, UnitCell& cell) override; + void before_all_runners(const Input_para& inp, UnitCell& cell) override; void runner(const int istep, UnitCell& cell) override; diff --git a/source/module_esolver/esolver_of.cpp b/source/module_esolver/esolver_of.cpp index 1c10bdd1c1..b3354326b7 100644 --- a/source/module_esolver/esolver_of.cpp +++ b/source/module_esolver/esolver_of.cpp @@ -57,7 +57,7 @@ ESolver_OF::~ESolver_OF() delete this->opt_cg_mag_; } -void ESolver_OF::before_all_runners(Input& inp, UnitCell& ucell) +void ESolver_OF::before_all_runners(const Input_para& inp, UnitCell& ucell) { ESolver_FP::before_all_runners(inp, ucell); @@ -157,7 +157,7 @@ void ESolver_OF::before_all_runners(Input& inp, UnitCell& ucell) CE_.Init_CE(ucell.nat); } -void ESolver_OF::init_after_vc(Input& inp, UnitCell& ucell) +void ESolver_OF::init_after_vc(const Input_para& inp, UnitCell& ucell) { ModuleBase::timer::tick("ESolver_OF", "init_after_vc"); @@ -266,7 +266,7 @@ void ESolver_OF::before_opt(const int istep, UnitCell& ucell) { if (ucell.cell_parameter_updated) { - this->init_after_vc(INPUT, ucell); + this->init_after_vc(PARAM.inp, ucell); } if (ucell.ionic_position_updated) { diff --git a/source/module_esolver/esolver_of.h b/source/module_esolver/esolver_of.h index 5c48c23db5..1a329887c1 100644 --- a/source/module_esolver/esolver_of.h +++ b/source/module_esolver/esolver_of.h @@ -20,9 +20,9 @@ class ESolver_OF : public ESolver_FP ESolver_OF(); ~ESolver_OF(); - virtual void before_all_runners(Input& inp, UnitCell& ucell) override; + virtual void before_all_runners(const Input_para& inp, UnitCell& ucell) override; - virtual void init_after_vc(Input& 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; @@ -128,7 +128,7 @@ class ESolver_OF : public ESolver_FP } // ---------------------- interfaces to KEDF ------------------------ - void init_kedf(Input& inp); + void init_kedf(const Input_para& inp); void kinetic_potential(double** prho, double** pphi, ModuleBase::matrix& rpot); double kinetic_energy(); void kinetic_stress(ModuleBase::matrix& kinetic_stress); diff --git a/source/module_esolver/esolver_of_interface.cpp b/source/module_esolver/esolver_of_interface.cpp index d54c643792..8d766e2f6e 100644 --- a/source/module_esolver/esolver_of_interface.cpp +++ b/source/module_esolver/esolver_of_interface.cpp @@ -9,7 +9,7 @@ namespace ModuleESolver * * @param inp */ -void ESolver_OF::init_kedf(Input& inp) +void ESolver_OF::init_kedf(const Input_para& inp) { //! Thomas-Fermi (TF) KEDF, TF+ KEDF, and Want-Teter (WT) KEDF if (this->of_kinetic_ == "tf" || this->of_kinetic_ == "tf+" || this->of_kinetic_ == "wt") @@ -167,7 +167,7 @@ void ESolver_OF::kinetic_stress(ModuleBase::matrix& kinetic_stress_) if (this->of_kinetic_ == "wt") { - this->wt_->get_stress(pelec->charge->rho, this->pw_rho, INPUT.of_vw_weight); + this->wt_->get_stress(pelec->charge->rho, this->pw_rho, PARAM.inp.of_vw_weight); kinetic_stress_ += this->wt_->stress; } diff --git a/source/module_esolver/esolver_of_tool.cpp b/source/module_esolver/esolver_of_tool.cpp index e0fed9b42f..00792b67f4 100644 --- a/source/module_esolver/esolver_of_tool.cpp +++ b/source/module_esolver/esolver_of_tool.cpp @@ -426,7 +426,7 @@ void ESolver_OF::print_info() std::vector titles; std::vector energies_Ry; std::vector energies_eV; - if (INPUT.printe > 0 && ((this->iter_ + 1) % INPUT.printe == 0 || this->conv_ || this->iter_ == GlobalV::SCF_NMAX)) + if (PARAM.inp.printe > 0 && ((this->iter_ + 1) % PARAM.inp.printe == 0 || this->conv_ || this->iter_ == GlobalV::SCF_NMAX)) { titles.push_back("E_Total"); energies_Ry.push_back(this->pelec->f_en.etot); @@ -461,7 +461,7 @@ void ESolver_OF::print_info() titles.push_back("LKT KEDF"); energies_Ry.push_back(this->lkt_->lkt_energy); } - std::string vdw_method = INPUT.vdw_method; + std::string vdw_method = PARAM.inp.vdw_method; if (vdw_method == "d2") // Peize Lin add 2014-04, update 2021-03-09 { titles.push_back("E_vdwD2"); diff --git a/source/module_esolver/esolver_sdft_pw.cpp b/source/module_esolver/esolver_sdft_pw.cpp index 6be0dd165c..b8a42eadd4 100644 --- a/source/module_esolver/esolver_sdft_pw.cpp +++ b/source/module_esolver/esolver_sdft_pw.cpp @@ -38,7 +38,7 @@ ESolver_SDFT_PW::~ESolver_SDFT_PW() { } -void ESolver_SDFT_PW::before_all_runners(Input& inp, UnitCell& ucell) +void ESolver_SDFT_PW::before_all_runners(const Input_para& inp, UnitCell& ucell) { // 1) initialize parameters from int Input class this->nche_sto = inp.nche_sto; @@ -131,9 +131,9 @@ void ESolver_SDFT_PW::before_all_runners(Input& inp, UnitCell& ucell) void ESolver_SDFT_PW::before_scf(const int istep) { ESolver_KS_PW::before_scf(istep); - if (istep > 0 && INPUT.nbands_sto != 0 && INPUT.initsto_freq > 0 && istep % INPUT.initsto_freq == 0) + if (istep > 0 && PARAM.inp.nbands_sto != 0 && PARAM.inp.initsto_freq > 0 && istep % PARAM.inp.initsto_freq == 0) { - Update_Sto_Orbitals(this->stowf, INPUT.seed_sto); + Update_Sto_Orbitals(this->stowf, PARAM.inp.seed_sto); } } @@ -269,7 +269,7 @@ void ESolver_SDFT_PW::after_all_runners() ((hsolver::HSolverPW_SDFT*)phsol)->stoiter.cleanchiallorder(); // release lots of memories - if (INPUT.out_dos) + if (PARAM.inp.out_dos) { Sto_DOS sto_dos(this->pw_wfc, &this->kv, @@ -278,19 +278,19 @@ void ESolver_SDFT_PW::after_all_runners() this->p_hamilt, (hsolver::HSolverPW_SDFT*)phsol, &stowf); - sto_dos.decide_param(INPUT.dos_nche, - INPUT.emin_sto, - INPUT.emax_sto, - INPUT.dos_setemin, - INPUT.dos_setemax, - INPUT.dos_emin_ev, - INPUT.dos_emax_ev, - INPUT.dos_scale); - sto_dos.caldos(INPUT.dos_sigma, INPUT.dos_edelta_ev, INPUT.npart_sto); + sto_dos.decide_param(PARAM.inp.dos_nche, + PARAM.inp.emin_sto, + PARAM.inp.emax_sto, + PARAM.globalv.dos_setemin, + PARAM.globalv.dos_setemax, + PARAM.inp.dos_emin_ev, + PARAM.inp.dos_emax_ev, + PARAM.inp.dos_scale); + sto_dos.caldos(PARAM.inp.dos_sigma, PARAM.inp.dos_edelta_ev, PARAM.inp.npart_sto); } // sKG cost memory, and it should be placed at the end of the program - if (INPUT.cal_cond) + if (PARAM.inp.cal_cond) { Sto_EleCond sto_elecond(&GlobalC::ucell, &this->kv, @@ -302,15 +302,15 @@ void ESolver_SDFT_PW::after_all_runners() (hsolver::HSolverPW_SDFT*)phsol, &stowf); sto_elecond - .decide_nche(INPUT.cond_dt, INPUT.cond_dtbatch, 1e-8, this->nche_sto, INPUT.emin_sto, INPUT.emax_sto); - sto_elecond.sKG(INPUT.cond_smear, - INPUT.cond_fwhm, - INPUT.cond_wcut, - INPUT.cond_dw, - INPUT.cond_dt, - INPUT.cond_nonlocal, + .decide_nche(PARAM.inp.cond_dt, INPUT.cond_dtbatch, 1e-8, this->nche_sto, PARAM.inp.emin_sto, PARAM.inp.emax_sto); + sto_elecond.sKG(PARAM.inp.cond_smear, + PARAM.inp.cond_fwhm, + PARAM.inp.cond_wcut, + PARAM.inp.cond_dw, + PARAM.inp.cond_dt, + PARAM.inp.cond_nonlocal, INPUT.cond_dtbatch, - INPUT.npart_sto); + PARAM.inp.npart_sto); } } diff --git a/source/module_esolver/esolver_sdft_pw.h b/source/module_esolver/esolver_sdft_pw.h index f63b3c0a05..fd26d3ea22 100644 --- a/source/module_esolver/esolver_sdft_pw.h +++ b/source/module_esolver/esolver_sdft_pw.h @@ -15,7 +15,7 @@ class ESolver_SDFT_PW : public ESolver_KS_PW> ESolver_SDFT_PW(); ~ESolver_SDFT_PW(); - void before_all_runners(Input& inp, UnitCell& cell) override; + void before_all_runners(const Input_para& inp, UnitCell& cell) override; double cal_energy() override; diff --git a/source/module_esolver/test/esolver_dp_test.cpp b/source/module_esolver/test/esolver_dp_test.cpp index 9510d9e154..3774c09512 100644 --- a/source/module_esolver/test/esolver_dp_test.cpp +++ b/source/module_esolver/test/esolver_dp_test.cpp @@ -48,7 +48,7 @@ class ESolverDPTest : public ::testing::Test } ModuleESolver::ESolver_DP* esolver; - Input inp; + Input_para inp; UnitCell ucell; }; diff --git a/source/module_hamilt_general/module_vdw/test/vdw_test.cpp b/source/module_hamilt_general/module_vdw/test/vdw_test.cpp index facfd46af0..ac02dc6182 100644 --- a/source/module_hamilt_general/module_vdw/test/vdw_test.cpp +++ b/source/module_hamilt_general/module_vdw/test/vdw_test.cpp @@ -149,7 +149,7 @@ class vdwd2Test: public testing::Test { protected: UnitCell ucell; - Input input; + Input_para input; void SetUp(){ stru_ structure{std::vector{0.5,0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5}, @@ -349,7 +349,7 @@ class vdwd3Test: public testing::Test { protected: UnitCell ucell; - Input input; + Input_para input; void SetUp(){ stru_ structure{std::vector{0.5,0.5,0.0,0.5,0.0,0.5,0.0,0.5,0.5}, @@ -497,7 +497,7 @@ class vdwd3abcTest: public testing::Test { protected: UnitCell ucell; - Input input; + Input_para input; void SetUp(){ stru_ structure{ diff --git a/source/module_hamilt_general/module_vdw/vdw.cpp b/source/module_hamilt_general/module_vdw/vdw.cpp index 3e8eb8907f..4644ab7035 100644 --- a/source/module_hamilt_general/module_vdw/vdw.cpp +++ b/source/module_hamilt_general/module_vdw/vdw.cpp @@ -6,7 +6,7 @@ namespace vdw { -std::unique_ptr make_vdw(const UnitCell &ucell, const Input &input) +std::unique_ptr make_vdw(const UnitCell &ucell, const Input_para &input) { if (ucell.nat < 2 && input.vdw_method != "none") { diff --git a/source/module_hamilt_general/module_vdw/vdw.h b/source/module_hamilt_general/module_vdw/vdw.h index 0501f30f4e..94b54239cb 100644 --- a/source/module_hamilt_general/module_vdw/vdw.h +++ b/source/module_hamilt_general/module_vdw/vdw.h @@ -48,7 +48,7 @@ class Vdw virtual void cal_stress() = 0; }; -std::unique_ptr make_vdw(const UnitCell &ucell, const Input &input); +std::unique_ptr make_vdw(const UnitCell &ucell, const Input_para &input); } // namespace vdw diff --git a/source/module_hamilt_general/module_vdw/vdwd2_parameters.cpp b/source/module_hamilt_general/module_vdw/vdwd2_parameters.cpp index 82126608d7..de8bda7bcc 100644 --- a/source/module_hamilt_general/module_vdw/vdwd2_parameters.cpp +++ b/source/module_hamilt_general/module_vdw/vdwd2_parameters.cpp @@ -9,7 +9,7 @@ namespace vdw { -void Vdwd2Parameters::initial_parameters(const Input &input) +void Vdwd2Parameters::initial_parameters(const Input_para &input) { scaling_ = std::stod(input.vdw_s6); damping_ = input.vdw_d; diff --git a/source/module_hamilt_general/module_vdw/vdwd2_parameters.h b/source/module_hamilt_general/module_vdw/vdwd2_parameters.h index fdb608923a..ef981b2c0a 100644 --- a/source/module_hamilt_general/module_vdw/vdwd2_parameters.h +++ b/source/module_hamilt_general/module_vdw/vdwd2_parameters.h @@ -8,7 +8,7 @@ #define VDWD2_PARAMETERS_H #include -#include "module_io/input.h" +#include "module_parameter/parameter.h" #include "module_cell/unitcell.h" #include "vdw_parameters.h" @@ -31,7 +31,7 @@ class Vdwd2Parameters : public VdwParameters void R0_input(const std::string &file, const std::string &unit); void initset(const UnitCell &ucell); // init sets of vdwd2 once this correction is called - void initial_parameters(const Input &input); // initial parameters of Vdwd2 with INPUT file + void initial_parameters(const Input_para &input); // initial parameters of Vdwd2 with INPUT file inline const std::map C6() const { return C6_; } inline const std::map R0() const { return R0_; } diff --git a/source/module_hamilt_general/module_vdw/vdwd3_parameters.cpp b/source/module_hamilt_general/module_vdw/vdwd3_parameters.cpp index a94991557b..e0336c3828 100644 --- a/source/module_hamilt_general/module_vdw/vdwd3_parameters.cpp +++ b/source/module_hamilt_general/module_vdw/vdwd3_parameters.cpp @@ -11,7 +11,7 @@ namespace vdw { -void Vdwd3Parameters::initial_parameters(const Input &input) +void Vdwd3Parameters::initial_parameters(const Input_para &input) { mxc_.resize(max_elem_, 1); r0ab_.resize(max_elem_, std::vector(max_elem_, 0.0)); diff --git a/source/module_hamilt_general/module_vdw/vdwd3_parameters.h b/source/module_hamilt_general/module_vdw/vdwd3_parameters.h index b9d67fafb2..c5f005a7b7 100644 --- a/source/module_hamilt_general/module_vdw/vdwd3_parameters.h +++ b/source/module_hamilt_general/module_vdw/vdwd3_parameters.h @@ -7,7 +7,7 @@ #ifndef VDWD3_PARAMETERS_H #define VDWD3_PARAMETERS_H -#include "module_io/input.h" +#include "module_parameter/parameter.h" #include "vdw_parameters.h" namespace vdw @@ -21,7 +21,7 @@ class Vdwd3Parameters : public VdwParameters ~Vdwd3Parameters() = default; - void initial_parameters(const Input &input); + void initial_parameters(const Input_para &input); inline const std::string &version() const { return version_; } diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp index 6529d267f4..b449a322a9 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp @@ -169,7 +169,7 @@ void Force_Stress_LCAO::getForceStress(const bool isforce, // jiyy add 2019-05-18, update 2021-05-02 ModuleBase::matrix force_vdw; ModuleBase::matrix stress_vdw; - auto vdw_solver = vdw::make_vdw(GlobalC::ucell, INPUT); + auto vdw_solver = vdw::make_vdw(GlobalC::ucell, PARAM.inp); if (vdw_solver != nullptr) { if (isforce) diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp index 9fba745119..5a95b5c11d 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_gamma.cpp @@ -110,7 +110,7 @@ void Force_LCAO::allocate(const Parallel_Orbitals& pv, &GlobalC::GridD); // calculate asynchronous S matrix to output for Hefei-NAMD - if (INPUT.cal_syns) + if (PARAM.inp.cal_syns) { cal_deri = false; ModuleBase::WARNING_QUIT("cal_syns", "this function has been broken and will be fixed later."); diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp index b16eeb1fce..dd2d2743dc 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/FORCE_k.cpp @@ -136,7 +136,7 @@ void Force_LCAO>::allocate(const Parallel_Orbitals& pv, &GlobalC::GridD); // calculate asynchronous S matrix to output for Hefei-NAMD - if (INPUT.cal_syns) + if (PARAM.inp.cal_syns) { cal_deri = false; @@ -152,8 +152,8 @@ void Force_LCAO>::allocate(const Parallel_Orbitals& pv, two_center_bundle, &(GlobalC::GridD), nullptr, // delete lm.SlocR - INPUT.cal_syns, - INPUT.dmax); + PARAM.inp.cal_syns, + PARAM.inp.dmax); for (int ik = 0; ik < nks; ik++) { diff --git a/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp b/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp index 4dab2b1c76..cff6efe8ee 100644 --- a/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp +++ b/source/module_hamilt_lcao/module_dftu/dftu_yukawa.cpp @@ -23,9 +23,9 @@ void DFTU::cal_yukawa_lambda(double** rho, const int& nrxx) { ModuleBase::TITLE("DFTU", "cal_yukawa_lambda"); - if (INPUT.yukawa_lambda > 0) + if (PARAM.inp.yukawa_lambda > 0) { - this->lambda = INPUT.yukawa_lambda; + this->lambda = PARAM.inp.yukawa_lambda; return; } diff --git a/source/module_hamilt_pw/hamilt_ofdft/of_stress_pw.cpp b/source/module_hamilt_pw/hamilt_ofdft/of_stress_pw.cpp index 10a08feeff..c4c3e5fae5 100644 --- a/source/module_hamilt_pw/hamilt_ofdft/of_stress_pw.cpp +++ b/source/module_hamilt_pw/hamilt_ofdft/of_stress_pw.cpp @@ -62,10 +62,10 @@ void OF_Stress_PW::cal_stress(ModuleBase::matrix& sigmatot, } // hartree contribution - stress_har(sigmahar, this->rhopw, 1, pelec->charge); + stress_har(sigmahar, this->rhopw, true, pelec->charge); // ewald contribution - stress_ewa(sigmaewa, this->rhopw, 1); + stress_ewa(sigmaewa, this->rhopw, true); // xc contribution: add gradient corrections(non diagonal) for (int i = 0; i < 3; i++) @@ -75,10 +75,10 @@ void OF_Stress_PW::cal_stress(ModuleBase::matrix& sigmatot, stress_gga(sigmaxc, this->rhopw, pelec->charge); // local contribution - stress_loc(sigmaloc, this->rhopw, p_sf, 1, pelec->charge); + stress_loc(sigmaloc, this->rhopw, p_sf, true, pelec->charge); // nlcc - stress_cc(sigmaxcc, this->rhopw, p_sf, 1, pelec->charge); + stress_cc(sigmaxcc, this->rhopw, p_sf, true, pelec->charge); // vdw term stress_vdw(sigmavdw, ucell); @@ -121,7 +121,7 @@ void OF_Stress_PW::cal_stress(ModuleBase::matrix& sigmatot, void OF_Stress_PW::stress_vdw(ModuleBase::matrix& sigma, UnitCell& ucell) { - auto vdw_solver = vdw::make_vdw(ucell, INPUT); + auto vdw_solver = vdw::make_vdw(ucell, PARAM.inp); if (vdw_solver != nullptr) { sigma = vdw_solver->get_stress().to_matrix(); diff --git a/source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.cpp index b8342d4818..32d94adbe8 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/VNL_in_pw.cpp @@ -224,8 +224,8 @@ void pseudopot_cell_vnl::init(const int ntype, } // this->nqx = 10000; // calculted in allocate_nlpot.f90 - GlobalV::NQX = static_cast((sqrt(INPUT.ecutwfc) / GlobalV::DQ + 4.0) * cell_factor); - GlobalV::NQXQ = static_cast((sqrt(INPUT.ecutrho) / GlobalV::DQ + 4.0) * cell_factor); + GlobalV::NQX = static_cast((sqrt(PARAM.inp.ecutwfc) / GlobalV::DQ + 4.0) * cell_factor); + GlobalV::NQXQ = static_cast((sqrt(PARAM.inp.ecutrho) / GlobalV::DQ + 4.0) * cell_factor); // GlobalV::NQXQ = static_cast(((sqrt(INPUT.ecutrho) + qnorm) / GlobalV::DQ + 4.0) * cell_factor); // mohan update 2021-02-22 diff --git a/source/module_hamilt_pw/hamilt_pwdft/forces.cpp b/source/module_hamilt_pw/hamilt_pwdft/forces.cpp index f694aa1f8f..d3a2dafff6 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/forces.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/forces.cpp @@ -178,7 +178,7 @@ void Forces::cal_force(ModuleBase::matrix& force, ModuleBase::matrix stress_vdw_pw; //.create(3,3); ModuleBase::matrix force_vdw; force_vdw.create(nat, 3); - auto vdw_solver = vdw::make_vdw(GlobalC::ucell, INPUT); + auto vdw_solver = vdw::make_vdw(GlobalC::ucell, PARAM.inp); if (vdw_solver != nullptr) { const std::vector>& force_vdw_temp = vdw_solver->get_force(); diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_func_cc.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_func_cc.cpp index 77156391f6..c5052c6e32 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_func_cc.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_func_cc.cpp @@ -17,7 +17,7 @@ void Stress_Func::stress_cc(ModuleBase::matrix& sigma, FPTYPE fact=1.0; - if(is_pw&&INPUT.gamma_only) + if(is_pw&&PARAM.inp.gamma_only) { fact = 2.0; //is_pw:PW basis, gamma_only need to FPTYPE. } diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_func_ewa.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_func_ewa.cpp index 9807fdf675..3d4175be28 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_func_ewa.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_func_ewa.cpp @@ -50,7 +50,7 @@ void Stress_Func::stress_ewa(ModuleBase::matrix& sigma, ModulePW //sdewald is the diagonal term FPTYPE fact=1.0; - if (INPUT.gamma_only && is_pw) fact=2.0; + if (PARAM.inp.gamma_only && is_pw) fact=2.0; // else fact=1.0; #ifdef _OPENMP diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_func_har.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_func_har.cpp index d6f1f9aabc..e738cee620 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_func_har.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_func_har.cpp @@ -100,7 +100,7 @@ void Stress_Func::stress_har(ModuleBase::matrix& sigma, ModulePW // Parallel_Reduce::reduce_pool( ehart ); // ehart *= 0.5 * GlobalC::ucell.omega; //psic(:)=(0.0,0.0) - if(is_pw&&INPUT.gamma_only) + if(is_pw&&PARAM.inp.gamma_only) { for(int l=0;l<3;l++) { diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp index b922d39c67..7a97be57d7 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_func_kin.cpp @@ -109,7 +109,7 @@ void Stress_Func::stress_kin(ModuleBase::matrix& sigma, } } - if(INPUT.gamma_only) + if(PARAM.inp.gamma_only) { for(int l=0;l<3;l++) { diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_func_loc.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_func_loc.cpp index b26355077c..b54060135a 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_func_loc.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_func_loc.cpp @@ -22,7 +22,7 @@ void Stress_Func::stress_loc(ModuleBase::matrix& sigma, const int nspin_rho = (GlobalV::NSPIN == 2) ? 2 : 1; - if (INPUT.gamma_only && is_pw) fact=2.0; + if (PARAM.inp.gamma_only && is_pw) fact=2.0; diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp index 9efe6d34ce..a566dda0c5 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp @@ -147,7 +147,7 @@ void Stress_PW::cal_stress(ModuleBase::matrix& sigmatot, template void Stress_PW::stress_vdw(ModuleBase::matrix& sigma, UnitCell& ucell) { - auto vdw_solver = vdw::make_vdw(ucell, INPUT); + auto vdw_solver = vdw::make_vdw(ucell, PARAM.inp); if (vdw_solver != nullptr) { sigma = vdw_solver->get_stress().to_matrix(); diff --git a/source/module_hamilt_pw/hamilt_pwdft/wf_atomic.cpp b/source/module_hamilt_pw/hamilt_pwdft/wf_atomic.cpp index fa1335c859..08848994c8 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/wf_atomic.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/wf_atomic.cpp @@ -36,8 +36,10 @@ WF_atomic::~WF_atomic() //========================================================== void WF_atomic::init_at_1(Structure_Factor *sf_in) { - if(GlobalV::use_paw) return; - if (GlobalV::test_wf) ModuleBase::TITLE("WF_atomic","init_at_1"); + if(GlobalV::use_paw) { return; +} + if (GlobalV::test_wf) { ModuleBase::TITLE("WF_atomic","init_at_1"); +} ModuleBase::timer::tick("WF_atomic","init_at_1"); this->psf = sf_in; GlobalV::ofs_running << "\n Make real space PAO into reciprocal space." << std::endl; @@ -85,10 +87,11 @@ void WF_atomic::init_at_1(Structure_Factor *sf_in) { //std::cout << "\n T=" << it << " ic=" << ic << std::endl; int nmesh; - if(GlobalV::PSEUDO_MESH) + if(GlobalV::PSEUDO_MESH) { nmesh = atom->ncpp.mesh; - else + } else { nmesh = atom->ncpp.msh; +} // check the unit condition double *inner_part = new double[nmesh]; @@ -216,9 +219,10 @@ void WF_atomic::init_at_1(Structure_Factor *sf_in) return; }// end init_at_1 -void WF_atomic::print_PAOs(void)const +void WF_atomic::print_PAOs()const { - if (GlobalV::MY_RANK!=0) return; + if (GlobalV::MY_RANK!=0) { return; +} for (int it=0; it3) ModuleBase::TITLE("WF_atomic","atomic_wfc"); + if (GlobalV::test_wf>3) { ModuleBase::TITLE("WF_atomic","atomic_wfc"); +} ModuleBase::timer::tick("WF_atomic","atomic_wfc"); //========================================================= // This routine computes the superposition of atomic @@ -332,15 +337,20 @@ void WF_atomic::atomic_wfc(const int ik, ModuleBase::GlobalFunc::ZEROS(aux, np); for(int n1=0;n1<2*l+1;n1++){ const int lm = l*l +n1; - if(std::abs(soc.rotylm(n1,ind))>1e-8) - for(int ig=0; ig1e-8) { + for(int ig=0; ignpwx*is ) = lphase * fact[is] * sk[ig] * aux[ig] * flq[ig]; +} } - else - for(int ig=0; ignpwx*is) = std::complex(0.0 , 0.0); + else { + for(int ig=0; ignpwx*is) = std::complex(0.0 , 0.0); +} +} }//is index++; }//if @@ -353,15 +363,16 @@ void WF_atomic::atomic_wfc(const int ik, std::complex fup,fdown; int nc; //This routine creates two functions only in the case j=l+1/2 or exit in the other case - if(fabs(j-l+0.5)<1e-4) continue; + if(fabs(j-l+0.5)<1e-4) { continue; +} delete[] chiaux; chiaux = new double [np]; //Find the functions j= l- 1/2 - if(l==0) + if(l==0) { for(int ig=0;igGlobalC::ucell.natomwfc) ModuleBase::WARNING_QUIT("GlobalC::wf.atomic_wfc()","error: too many wfcs"); + if(index+2*l+1>GlobalC::ucell.natomwfc) { ModuleBase::WARNING_QUIT("GlobalC::wf.atomic_wfc()","error: too many wfcs"); +} for(int ig = 0;igGlobalC::ucell.natomwfc) ModuleBase::WARNING_QUIT("GlobalC::wf.atomic_wfc()","error: too many wfcs"); + if(index+2*l+1>GlobalC::ucell.natomwfc) { ModuleBase::WARNING_QUIT("GlobalC::wf.atomic_wfc()","error: too many wfcs"); +} for(int ig = 0;ig* psi, // srand(unsigned(INPUT.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); // } // #else - if (INPUT.pw_seed > 0) // qianrui add 2021-8-13 + if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 { - srand(unsigned(INPUT.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); + srand(unsigned(PARAM.inp.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); const int nxy = wfc_basis->fftnxy; const int nz = wfc_basis->nz; const int nstnz = wfc_basis->nst*nz; @@ -607,7 +621,8 @@ void WF_atomic::random_t(std::complex* psi, for(int ir=0; ir < nxy; ir++) { - if(wfc_basis->fftixy2ip[ir] < 0) continue; + if(wfc_basis->fftixy2ip[ir] < 0) { continue; +} if(GlobalV::RANK_IN_POOL==0) { for(int iz=0; iz* psi, { // #endif #else // !__MPI - if (INPUT.pw_seed > 0) // qianrui add 2021-8-13 + if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 { - srand(unsigned(INPUT.pw_seed + ik)); + srand(unsigned(PARAM.inp.pw_seed + ik)); } #endif // __MPI for (int iw = iw_start ;iw < iw_end;iw++) @@ -654,13 +669,14 @@ void WF_atomic::random_t(std::complex* psi, const FPTYPE gk2 = wfc_basis->getgk2(ik,ig); ppsi[ig] = std::complex(rr * cos(arg), rr * sin(arg)) / FPTYPE(gk2 + 1.0); } - if(GlobalV::NPOL==2)for (int ig = this->npwx;ig < this->npwx + ng;ig++) + if(GlobalV::NPOL==2) {for (int ig = this->npwx;ig < this->npwx + ng;ig++) { const FPTYPE rr = std::rand()/FPTYPE(RAND_MAX); const FPTYPE arg= ModuleBase::TWO_PI * std::rand()/FPTYPE(RAND_MAX); const FPTYPE gk2 = wfc_basis->getgk2(ik,ig-this->npwx); ppsi[ig] = std::complex(rr * cos(arg), rr * sin(arg)) / FPTYPE(gk2 + 1.0); } +} } #ifdef __MPI // #if ((!defined __CUDA) && (!defined __ROCM)) @@ -679,9 +695,9 @@ void WF_atomic::atomicrandom(ModuleBase::ComplexMatrix& psi, assert(psi.nr >= iw_end); const int ng = wfc_basis->npwk[ik]; #ifdef __MPI - if (INPUT.pw_seed > 0) // qianrui add 2021-8-13 + if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 { - srand(unsigned(INPUT.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); + srand(unsigned(PARAM.inp.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); const int nxy = wfc_basis->fftnxy; const int nz = wfc_basis->nz; const int nstnz = wfc_basis->nst*nz; @@ -697,7 +713,8 @@ void WF_atomic::atomicrandom(ModuleBase::ComplexMatrix& psi, { for(int ir=0; ir < nxy; ir++) { - if(wfc_basis->fftixy2ip[ir] < 0) continue; + if(wfc_basis->fftixy2ip[ir] < 0) { continue; +} if(GlobalV::RANK_IN_POOL==0) { for(int iz=0; iz 0) // qianrui add 2021-8-13 + if (PARAM.inp.pw_seed > 0) // qianrui add 2021-8-13 { - srand(unsigned(INPUT.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); + srand(unsigned(PARAM.inp.pw_seed + GlobalC::Pkpoints.startk_pool[GlobalV::MY_POOL] + ik)); } #endif double rr, arg; diff --git a/source/module_hamilt_pw/hamilt_stodft/sto_hchi.cpp b/source/module_hamilt_pw/hamilt_stodft/sto_hchi.cpp index 1bb37dedab..21e42f3fbb 100644 --- a/source/module_hamilt_pw/hamilt_stodft/sto_hchi.cpp +++ b/source/module_hamilt_pw/hamilt_stodft/sto_hchi.cpp @@ -8,8 +8,8 @@ Stochastic_hchi::Stochastic_hchi() { - Emin = INPUT.emin_sto; - Emax = INPUT.emax_sto; + Emin = PARAM.inp.emin_sto; + Emax = PARAM.inp.emax_sto; } Stochastic_hchi::~Stochastic_hchi() diff --git a/source/module_hamilt_pw/hamilt_stodft/sto_iter.cpp b/source/module_hamilt_pw/hamilt_stodft/sto_iter.cpp index fd87d31475..68118e7fec 100644 --- a/source/module_hamilt_pw/hamilt_stodft/sto_iter.cpp +++ b/source/module_hamilt_pw/hamilt_stodft/sto_iter.cpp @@ -47,10 +47,11 @@ void Stochastic_Iter::init(const int method_in, K_Vectors* pkv_in, ModulePW::PW_ const int norder = p_che->norder; const int nks = wfc_basis->nks; this->method = method_in; - if(method == 1) spolyv = new double [norder]; - else spolyv = new double [norder*norder]; - stofunc.Emin = INPUT.emin_sto; - stofunc.Emax = INPUT.emax_sto; + if(method == 1) { spolyv = new double [norder]; + } else { spolyv = new double [norder*norder]; +} + stofunc.Emin = PARAM.inp.emin_sto; + stofunc.Emax = PARAM.inp.emax_sto; if(this->method == 2) { @@ -101,16 +102,18 @@ void Stochastic_Iter::checkemm(const int& ik, const int istep, const int iter, S { ModuleBase::TITLE("Stochastic_Iter","checkemm"); //iter = 1,2,... istep = 0,1,2,... - // if( istep%INPUT.initsto_freq != 0 ) return; + // if( istep%PARAM.inp.initsto_freq != 0 ) return; const int npw = stowf.ngk[ik]; const int nks = stowf.nks; if(istep == 0) { - if(iter > 5) return; + if(iter > 5) { return; +} } else { - if(iter > 1) return; + if(iter > 1) { return; +} } const int norder = p_che->norder; @@ -132,7 +135,7 @@ void Stochastic_Iter::checkemm(const int& ik, const int istep, const int iter, S { pchi = &stowf.chi0->operator()(ik, ichi, 0); } - while (1) + while (true) { bool converge; converge = p_che->checkconverge( @@ -275,9 +278,10 @@ void Stochastic_Iter::itermu(const int iter, elecstate::ElecState* pes) { std::cout << "Fermi energy cannot be converged. Set THNE to " << th_ne << std::endl; th_ne *= 1e1; - if (th_ne > 1e1) + if (th_ne > 1e1) { ModuleBase::WARNING_QUIT("Stochastic_Iter", "Cannot converge feimi energy. Please retry with different random number"); +} } } pes->eferm.ef = this->stofunc.mu = mu0 = mu3; @@ -311,10 +315,11 @@ void Stochastic_Iter::calPn(const int& ik, Stochastic_WF& stowf) const int npwx = stowf.npwx; if(ik==0) { - if(this->method == 1) + if(this->method == 1) { ModuleBase::GlobalFunc::ZEROS(spolyv, norder); - else + } else { ModuleBase::GlobalFunc::ZEROS(spolyv, norder*norder); +} } std::complex * pchi; if(GlobalV::NBANDS > 0) @@ -553,15 +558,17 @@ void Stochastic_Iter::sum_stoband(Stochastic_WF& stowf, elecstate::ElecState* pe { GlobalV::ofs_running<<"Renormalize rho from ne = "<=0) if it is -1 (default), - // B-spline for Sturcture Factor isnot used. - - bool colour; // used for fun. - - bool t_in_h; // calculate the T or not. - bool vl_in_h; // calculate the vloc or not. - bool vnl_in_h; // calculate the vnl or not. - - bool vh_in_h; // calculate the hartree potential or not - bool vion_in_h; // calculate the local ionic potential or not - // only relevant when vl_in_h = 1 - - bool test_force; // test the force. - bool test_stress; // test the stress. - - //========================================================== - // iteration - //========================================================== - double scf_thr; // \sum |rhog_out - rhog_in |^2 - int scf_thr_type; // type of the criterion of scf_thr, 1: reci drho, 2: real - // drho - int scf_nmax; // number of max elec iter - int relax_nmax; // number of max ionic iter - std::string out_level; // control the output information. - bool out_md_control; // internal parameter , added by zhengdy 2019-04-07 - - //========================================================== - // occupation - //========================================================== - - std::string smearing_method; // "gaussian", - // "mp","methfessel-paxton" - // "mv","marzari-vanderbilt","cold" - // "fd","fermi-dirac" - double smearing_sigma; // - - //========================================================== - // potential / charge / wavefunction / energy - //========================================================== - - std::string init_wfc; // "file","atomic","random" - std::string init_chg; // "file","atomic" - bool psi_initializer; // whether use psi_initializer to initialize - // wavefunctions - - std::string chg_extrap; // xiaohui modify 2015-02-01 - - int mem_saver; // 1: save psi when nscf calculation. - - int printe; // mohan add 2011-03-16 - int out_freq_elec; // the frequency ( >= 0) of electronic iter to output - // charge density and wavefunction. 0: output only when - // converged - int out_freq_ion; // the frequency ( >= 0 ) of ionic step to output charge - // density and wavefunction. 0: output only when ion steps - // are finished - int out_chg; // output charge density. 0: no; 1: yes - int out_pot; // yes or no - int out_wfc_pw; // 0: no; 1: txt; 2: dat - bool out_wfc_r; // 0: no; 1: yes - int out_dos; // dos calculation. mohan add 20090909 - std::vector out_band; // band calculation pengfei 2014-10-13 - bool out_proj_band; // projected band structure calculation jiyy add - // 2022-05-11 - bool cal_syns; // calculate asynchronous S matrix to output - double dmax; // maximum displacement of all atoms in one step (bohr) - int out_interval; - bool out_app_flag; // whether output r(R), H(R), S(R), T(R), and dH(R) - // matrices in an append manner during MD liuyu - // 2023-03-20 - int out_ndigits; - bool out_mat_r; // jingan add 2019-8-14, output r(R) matrix. - bool out_alllog; // output all logs. - bool out_element_info; // output infomation of all element - - bool out_bandgap; // QO added for bandgap printing - - double dos_emin_ev; - double dos_emax_ev; - double dos_edelta_ev; - double dos_scale; - int dos_nche; // orders of Chebyshev expansions for dos - bool dos_setemin = false; // true: emin is set - bool dos_setemax = false; // true: emax is set - - double dos_sigma; // pengfei 2014-10-13 - - //========================================================== - // two center integrals in LCAO - // mohan add 2009-11-11 - //========================================================== - double lcao_ecut; // ecut of two center integral - double lcao_dk; // delta k used in two center integral - double lcao_dr; // dr used in two center integral - double lcao_rmax; // rmax(a.u.) to make table. - double search_radius; // 11.1 - bool search_pbc; // 11.2 - double onsite_radius; // the radius of on-site orbitals - - //========================================================== - // molecular dynamics - // added by Daye Zheng - //========================================================== + + // They will be removed. + int cond_dtbatch; + int nche_sto; + double md_tfirst; + double bessel_nao_rcut; // radial cutoff for spherical bessel functions(a.u.) MD_para mdp; - - //========================================================== - // vdw - // Peize Lin add 2014-03-31, jiyy update 2019-08-01 - //========================================================== - std::string vdw_method; // the method of vdw calculation - std::string vdw_s6; // scale parameter - std::string vdw_s8; // scale parameter - std::string vdw_a1; // damping function parameter - std::string vdw_a2; // damping function parameter - double vdw_d; // damping function parameter d - bool vdw_abc; // third-order term? - std::string vdw_cutoff_radius; // cutoff radius for std::pair interactions - std::string vdw_radius_unit; //"Bohr" or "Angstrom" - double vdw_cn_thr; // cutoff radius for calculating the coordination number - std::string vdw_cn_thr_unit; //"Bohr" or "Angstrom" - std::string vdw_C6_file; - std::string vdw_C6_unit; //"Bohr" or "Angstrom" - std::string vdw_R0_file; - std::string vdw_R0_unit; //"Bohr" or "Angstrom" - std::string vdw_cutoff_type; //"period" or "radius" - ModuleBase::Vector3 vdw_cutoff_period; - - bool ocp; - std::string ocp_set; - bool out_mul; // qifeng add 2019-9-10 - // added by zhengdy-soc - bool noncolin; - bool lspinorb; - double soc_lambda; - //========================================================== - // tddft - // Fuxiang He add 2016-10-26 - //========================================================== - - //========================================================== - // restart - // Peize Lin add 2020-04-04 - //========================================================== - bool restart_save; - bool restart_load; - // xiaohui add 2015-09-16 - bool input_error; - double cell_factor; // LiuXh add 20180619 - - //========================================================== - // DFT+U Xin Qu added on 2020-10-29 - //========================================================== - int dft_plus_u; ///< 1:DFT+U correction; 2:old DFT+U method; 0:standard DFT - ///< calculation(default) int* orbital_corr = nullptr; ///< which correlated orbitals need corrected ; - ///< d:2 ,f:3, do not need correction:-1 double* hubbard_u = nullptr; ///< Hubbard Coulomb interaction parameter U(ev) - int omc; ///< whether turn on occupation matrix control method or not - bool yukawa_potential; ///< default:false - double yukawa_lambda; ///< default:-1.0, which means we calculate lambda - double uramping; ///< default:-1.0, which means we do not use U-Ramping method - - //========================================================== - // DFT+DMFT Xin Qu added on 2021-08 - //========================================================== - bool dft_plus_dmft; // true:DFT+DMFT; false: standard DFT - // calcullation(default) - - //========================================================== - // RPA Rong Shi added on 2022-04 - //========================================================== - bool rpa; - std::string coulomb_type; - //========================================================== - // OFDFT sunliang added on 2022-05-05 - //========================================================== - std::string of_kinetic; // Kinetic energy functional, such as TF, VW, WT, TF+ - std::string of_method; // optimization method, include cg1, cg2, tn (default), bfgs - std::string of_conv; // select the convergence criterion, potential, energy - // (default), or both - double of_tole; // tolerance of the energy change (in Ry) for determining - // the convergence, default=2e-6 Ry - double of_tolp; // tolerance of potential for determining the convergence, - // default=1e-5 in a.u. - double of_tf_weight; // weight of TF KEDF - double of_vw_weight; // weight of vW KEDF - double of_wt_alpha; // parameter alpha of WT KEDF - double of_wt_beta; // parameter beta of WT KEDF - double of_wt_rho0; // set the average density of system, in Bohr^-3 - bool of_hold_rho0; // If set to 1, the rho0 will be fixed even if the volume - // of system has changed, it will be set to 1 automaticly - // if of_wt_rho0 is not zero. - double of_lkt_a; // parameter a of LKT KEDF - bool of_full_pw; // If set to 1, ecut will be ignored while collecting - // planewaves, so that all planewaves will be used. - int of_full_pw_dim; // If of_full_pw = 1, the dimention of FFT will be - // testricted to be (0) either odd or even; (1) odd - // only; (2) even only. - bool of_read_kernel; // If set to 1, the kernel of WT KEDF will be filled - // from file of_kernel_file, not from formula. Only - // usable for WT KEDF. - std::string of_kernel_file; // The name of WT kernel file. - - //========================================================== - // spherical bessel Peize Lin added on 2022-12-15 - //========================================================== - // the following are used when generating orb_matrix.dat - // int bessel_nao_lmax; // lmax used in descriptor - bool bessel_nao_smooth; // spherical bessel smooth or not - double bessel_nao_sigma; // spherical bessel smearing_sigma - std::string bessel_nao_ecut; // energy cutoff for spherical bessel functions(Ry) - double bessel_nao_rcut; // radial cutoff for spherical bessel functions(a.u.) - std::vector bessel_nao_rcuts; - double bessel_nao_tolerence; // tolerence for spherical bessel root - // the following are used when generating jle.orb - int bessel_descriptor_lmax; // lmax used in descriptor - bool bessel_descriptor_smooth; // spherical bessel smooth or not - double bessel_descriptor_sigma; // spherical bessel smearing_sigma - std::string bessel_descriptor_ecut; // energy cutoff for spherical bessel - // functions(Ry) - double bessel_descriptor_rcut; // radial cutoff for spherical bessel - // functions(a.u.) - double bessel_descriptor_tolerence; // tolerence for spherical bessel root - - //========================================================== - // device control denghui added on 2022-11-15 - //========================================================== - std::string device; - //========================================================== - // precision control denghui added on 2023-01-01 - //========================================================== - std::string precision; - - //========================================================== - // variables for test only - //========================================================== - bool test_skip_ewald = false; - - //========================================================== - // variables for PAW - //========================================================== - bool use_paw = false; - - //========================================================== - // variables for elpa - //========================================================== - - bool check_input = false; - - std::time_t start_time; - std::time_t get_start_time(void) const - { - return start_time; - } - - //========================================================== - //Beyond DFT - //========================================================== - int lr_nstates; // the number of 2-particle states to be solved - int nocc; // the number of occupied orbitals to form the 2-particle basis - int nvirt; // the number of virtual orbitals to form the 2-particle basis (nocc + nvirt <= nbands) - std::string xc_kernel; // xc kernel for LR-TDDFT - std::string lr_solver; // the solver for LR-TDDFT - double lr_thr; // convergence threshold of the LR-TDDFT eigensolver - std::vector abs_wavelen_range; // the range of wavelength(nm) to output the absorption spectrum - bool out_wfc_lr; - double abs_broadening; // the broadening (eta) for LR-TDDFT absorption spectrum - - private: - //========================================================== - // MEMBER FUNCTIONS : - // NAME : Read() - // NAME : Default(set the default value for variables) - // NAME : Check(check the values) - // NAME : Bcast(only used in paralle case,only read in data - // from first cpu, and distribute the data to the - // other processors) - //========================================================== - - // start time - - bool Read(const std::string& fn); - - void Default(void); - - void Default_2(void); // jiyy add 2019-08-04 - - void Check(void); - -#ifdef __MPI - void Bcast(void); -#endif - - int count_ntype(const std::string& fn); // sunliang add 2022-12-06 - + std::string stru_file; // file contains atomic positions -- xiaohui modify std::string bands_to_print_; // specify the bands to be calculated in the get_pchg - // calculation, formalism similar to ocp_set. public: - template - static void read_value(std::ifstream& ifs, T& var) - { - ifs >> var; - std::string line; - getline(ifs, line); // read the rest of the line, directly discard it. - return; - } - void read_kspacing(std::ifstream& ifs) - { - std::string s; - std::getline(ifs, s); - std::stringstream ss(s); - // read 3 values - int count = 0; - while ((ss >> kspacing[count]) && count < 3) - { - count++; - } - // if not read even one value, or read two values, the input is invalid. - if (count == 0 || count == 2) - { - std::cout << "kspacing can only accept one or three double values." << std::endl; - ifs.setstate(std::ios::failbit); - } - // if only read one value, set all to kspacing[0] - if (count == 1) - { - kspacing[1] = kspacing[0]; - kspacing[2] = kspacing[0]; - } - // std::cout << "count: " << count << " kspacing: " << kspacing[0] << " - // " << kspacing[1] << " " << kspacing[2] - // << std::endl; - }; - - /* I hope this function would be more and more useful if want to support - vector/list of input */ - template - void read_value2stdvector(std::ifstream& ifs, std::vector& var); - template - typename std::enable_if::value, T>::type cast_string(const std::string& str) - { - return std::stod(str); - } - template - typename std::enable_if::value, T>::type cast_string(const std::string& str) - { - if (str == "true" || str == "1") - return 1; - else if (str == "false" || str == "0") - return 0; - else - return std::stoi(str); - } - template - typename std::enable_if::value, T>::type cast_string(const std::string& str) - { - return (str == "true" || str == "1"); - } - template - typename std::enable_if::value, T>::type cast_string(const std::string& str) - { - return str; - } - void strtolower(char* sa, char* sb); - void read_bool(std::ifstream& ifs, bool& var); - // Return the const string pointer of private member bands_to_print_ // Not recommended to use this function directly, use get_out_band_kb() // instead diff --git a/source/module_io/input_conv.cpp b/source/module_io/input_conv.cpp index f6d7e8b4cf..11a28193bf 100644 --- a/source/module_io/input_conv.cpp +++ b/source/module_io/input_conv.cpp @@ -143,7 +143,7 @@ std::vector Input_Conv::convert_units(std::string params, double c) void Input_Conv::read_td_efield() { elecstate::H_TDDFT_pw::stype = PARAM.inp.td_stype; - if (INPUT.esolver_type == "tddft" && elecstate::H_TDDFT_pw::stype == 1) + if (PARAM.inp.esolver_type == "tddft" && elecstate::H_TDDFT_pw::stype == 1) { TD_Velocity::tddft_velocity = true; } @@ -164,7 +164,7 @@ void Input_Conv::read_td_efield() elecstate::H_TDDFT_pw::tstart = PARAM.inp.td_tstart; elecstate::H_TDDFT_pw::tend = PARAM.inp.td_tend; - elecstate::H_TDDFT_pw::dt = INPUT.mdp.md_dt / ModuleBase::AU_to_FS; + elecstate::H_TDDFT_pw::dt = PARAM.mdp.md_dt / ModuleBase::AU_to_FS; elecstate::H_TDDFT_pw::dt_int = elecstate::H_TDDFT_pw::dt; // space domain parameters @@ -262,29 +262,29 @@ void Input_Conv::Convert() { ModuleBase::TITLE("Input_Conv", "Convert"); ModuleBase::timer::tick("Input_Conv", "Convert"); - GlobalV::CALCULATION = PARAM.inp.sup.global_calculation; - GlobalV::double_grid = PARAM.inp.sup.double_grid; + GlobalV::CALCULATION = PARAM.globalv.global_calculation; + GlobalV::double_grid = PARAM.globalv.double_grid; //----------------------------------------------- // set read_file_dir //----------------------------------------------- - if (INPUT.read_file_dir == "auto") + if (PARAM.inp.read_file_dir == "auto") { GlobalV::global_readin_dir = GlobalV::global_out_dir; } else { - GlobalV::global_readin_dir = INPUT.read_file_dir + '/'; + GlobalV::global_readin_dir = PARAM.inp.read_file_dir + '/'; } //---------------------------------------------------------- // main parameters / electrons / spin ( 10/16 ) //---------------------------------------------------------- // suffix - if (INPUT.calculation == "md" && INPUT.mdp.md_restart) // md restart liuyu add 2023-04-12 + if (PARAM.inp.calculation == "md" && PARAM.mdp.md_restart) // md restart liuyu add 2023-04-12 { int istep = 0; - MD_func::current_md_info(GlobalV::MY_RANK, GlobalV::global_readin_dir, istep, INPUT.mdp.md_tfirst); - INPUT.mdp.md_tfirst *= ModuleBase::Hartree_to_K; - if (INPUT.read_file_dir == "auto") + MD_func::current_md_info(GlobalV::MY_RANK, GlobalV::global_readin_dir, istep, INPUT.md_tfirst); + INPUT.md_tfirst *= ModuleBase::Hartree_to_K; + if (PARAM.inp.read_file_dir == "auto") { GlobalV::stru_file = INPUT.stru_file = GlobalV::global_stru_dir + "STRU_MD_" + std::to_string(istep); } @@ -297,74 +297,52 @@ void Input_Conv::Convert() { GlobalV::stru_file = INPUT.stru_file; } - GlobalV::global_wannier_card = INPUT.wannier_card; - if (INPUT.kpoint_file != "") + GlobalV::global_wannier_card = PARAM.inp.wannier_card; + if (PARAM.inp.kpoint_file != "") { - GlobalV::global_kpoint_card = INPUT.kpoint_file; + GlobalV::global_kpoint_card = PARAM.inp.kpoint_file; } - if (INPUT.pseudo_dir != "") + if (PARAM.inp.pseudo_dir != "") { - GlobalV::global_pseudo_dir = INPUT.pseudo_dir + "/"; + GlobalV::global_pseudo_dir = PARAM.inp.pseudo_dir + "/"; } - if (INPUT.orbital_dir != "") + if (PARAM.inp.orbital_dir != "") { - GlobalV::global_orbital_dir = INPUT.orbital_dir + "/"; + GlobalV::global_orbital_dir = PARAM.inp.orbital_dir + "/"; } ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "pseudo_dir", GlobalV::global_pseudo_dir); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "orbital_dir", GlobalV::global_orbital_dir); - // GlobalV::global_pseudo_type = INPUT.pseudo_type; - GlobalC::ucell.setup(INPUT.latname, INPUT.ntype, INPUT.lmaxmax, INPUT.init_vel, INPUT.fixed_axes); + // GlobalV::global_pseudo_type = PARAM.inp.pseudo_type; + GlobalC::ucell.setup(PARAM.inp.latname, PARAM.inp.ntype, PARAM.inp.lmaxmax, PARAM.inp.init_vel, PARAM.inp.fixed_axes); - if (INPUT.calculation == "relax" || INPUT.calculation == "cell-relax") + if (PARAM.inp.calculation == "relax" || PARAM.inp.calculation == "cell-relax") { - if (INPUT.fixed_ibrav && !INPUT.relax_new) - { - ModuleBase::WARNING_QUIT("Input_Conv", "fixed_ibrav only available for relax_new = 1"); - } - if (INPUT.latname == "none" && INPUT.fixed_ibrav) - { - ModuleBase::WARNING_QUIT("Input_Conv", "to use fixed_ibrav, latname must be provided"); - } - if (INPUT.calculation == "relax" && INPUT.fixed_atoms) - { - ModuleBase::WARNING_QUIT("Input_Conv", "fixed_atoms is not meant to be used for calculation = relax"); - } - if (INPUT.relax_new && INPUT.relax_method != "cg") - { - INPUT.relax_new = false; - } - if (!INPUT.relax_new && (INPUT.fixed_axes == "shape" || INPUT.fixed_axes == "volume")) - { - ModuleBase::WARNING_QUIT("Input_Conv", - "fixed shape and fixed volume only " - "supported for relax_new = 1"); - } - GlobalV::fixed_atoms = INPUT.fixed_atoms; + GlobalV::fixed_atoms = PARAM.inp.fixed_atoms; } for (int i = 0; i < 3; i++) { - GlobalV::KSPACING[i] = INPUT.kspacing[i]; + GlobalV::KSPACING[i] = PARAM.inp.kspacing[i]; } - GlobalV::MIN_DIST_COEF = INPUT.min_dist_coef; - GlobalV::NBANDS = INPUT.nbands; - GlobalV::NBANDS_ISTATE = INPUT.nbands_istate; + GlobalV::MIN_DIST_COEF = PARAM.inp.min_dist_coef; + GlobalV::NBANDS = PARAM.inp.nbands; + GlobalV::NBANDS_ISTATE = PARAM.inp.nbands_istate; - GlobalV::device_flag = base_device::information::get_device_flag(INPUT.device, - INPUT.ks_solver, - INPUT.basis_type, - INPUT.gamma_only_local); + GlobalV::device_flag = base_device::information::get_device_flag(PARAM.inp.device, + PARAM.inp.ks_solver, + PARAM.inp.basis_type, + PARAM.globalv.gamma_only_local); - if (GlobalV::device_flag == "gpu" && INPUT.basis_type == "pw") + if (GlobalV::device_flag == "gpu" && PARAM.inp.basis_type == "pw") { - GlobalV::KPAR = base_device::information::get_device_kpar(INPUT.kpar); + GlobalV::KPAR = base_device::information::get_device_kpar(PARAM.inp.kpar); } else { - GlobalV::KPAR = INPUT.kpar; - GlobalV::NSTOGROUP = INPUT.bndpar; + GlobalV::KPAR = PARAM.inp.kpar; + GlobalV::NSTOGROUP = PARAM.inp.bndpar; } - GlobalV::precision_flag = INPUT.precision; + GlobalV::precision_flag = PARAM.inp.precision; if (GlobalV::device_flag == "cpu" and GlobalV::precision_flag == "single") { // cpu single precision is not supported while float_fftw lib is not available @@ -374,24 +352,24 @@ void Input_Conv::Convert() \n Please recompile with cmake flag \"-DENABLE_FLOAT_FFTW=ON\".\n"); #endif // __ENABLE_FLOAT_FFTW } - GlobalV::CALCULATION = INPUT.calculation; - GlobalV::ESOLVER_TYPE = INPUT.esolver_type; + GlobalV::CALCULATION = PARAM.inp.calculation; + GlobalV::ESOLVER_TYPE = PARAM.inp.esolver_type; - GlobalV::PSEUDORCUT = INPUT.pseudo_rcut; - GlobalV::PSEUDO_MESH = INPUT.pseudo_mesh; + GlobalV::PSEUDORCUT = PARAM.inp.pseudo_rcut; + GlobalV::PSEUDO_MESH = PARAM.inp.pseudo_mesh; - GlobalV::DFT_FUNCTIONAL = INPUT.dft_functional; - GlobalV::XC_TEMPERATURE = INPUT.xc_temperature; - GlobalV::NSPIN = INPUT.nspin; + GlobalV::DFT_FUNCTIONAL = PARAM.inp.dft_functional; + GlobalV::XC_TEMPERATURE = PARAM.inp.xc_temperature; + GlobalV::NSPIN = PARAM.inp.nspin; - GlobalV::CAL_FORCE = INPUT.cal_force; - GlobalV::FORCE_THR = INPUT.force_thr; + GlobalV::CAL_FORCE = PARAM.inp.cal_force; + GlobalV::FORCE_THR = PARAM.inp.force_thr; - GlobalV::STRESS_THR = INPUT.stress_thr; - GlobalV::PRESS1 = INPUT.press1; - GlobalV::PRESS2 = INPUT.press2; - GlobalV::PRESS3 = INPUT.press3; - GlobalV::out_element_info = INPUT.out_element_info; + GlobalV::STRESS_THR = PARAM.inp.stress_thr; + GlobalV::PRESS1 = PARAM.inp.press1; + GlobalV::PRESS2 = PARAM.inp.press2; + GlobalV::PRESS3 = PARAM.inp.press3; + GlobalV::out_element_info = PARAM.inp.out_element_info; #ifdef __LCAO Force_Stress_LCAO::force_invalid_threshold_ev = PARAM.inp.force_thr_ev2; Force_Stress_LCAO>::force_invalid_threshold_ev = PARAM.inp.force_thr_ev2; @@ -404,40 +382,40 @@ void Input_Conv::Convert() Ions_Move_Basic::relax_bfgs_rmin = PARAM.inp.relax_bfgs_rmin; Ions_Move_Basic::relax_bfgs_init = PARAM.inp.relax_bfgs_init; Ions_Move_Basic::out_stru = PARAM.inp.out_stru; // mohan add 2012-03-23 - Lattice_Change_Basic::fixed_axes = INPUT.fixed_axes; + Lattice_Change_Basic::fixed_axes = PARAM.inp.fixed_axes; - GlobalV::CAL_STRESS = INPUT.cal_stress; + GlobalV::CAL_STRESS = PARAM.inp.cal_stress; - GlobalV::NUM_STREAM = INPUT.nstream; + GlobalV::NUM_STREAM = PARAM.inp.nstream; - GlobalV::RELAX_METHOD = INPUT.relax_method; - GlobalV::relax_scale_force = INPUT.relax_scale_force; - GlobalV::relax_new = INPUT.relax_new; + GlobalV::RELAX_METHOD = PARAM.inp.relax_method; + GlobalV::relax_scale_force = PARAM.inp.relax_scale_force; + GlobalV::relax_new = PARAM.inp.relax_new; - GlobalV::use_paw = INPUT.use_paw; + GlobalV::use_paw = PARAM.inp.use_paw; - GlobalV::OUT_LEVEL = INPUT.out_level; - Ions_Move_CG::RELAX_CG_THR = INPUT.relax_cg_thr; // pengfei add 2013-09-09 + GlobalV::OUT_LEVEL = PARAM.inp.out_level; + Ions_Move_CG::RELAX_CG_THR = PARAM.inp.relax_cg_thr; // pengfei add 2013-09-09 ModuleSymmetry::Symmetry::symm_flag = std::stoi(PARAM.inp.symmetry); ModuleSymmetry::Symmetry::symm_autoclose = PARAM.inp.symmetry_autoclose; - GlobalV::BASIS_TYPE = INPUT.basis_type; - GlobalV::KS_SOLVER = INPUT.ks_solver; - GlobalV::SEARCH_RADIUS = INPUT.search_radius; - GlobalV::SEARCH_PBC = INPUT.search_pbc; + GlobalV::BASIS_TYPE = PARAM.inp.basis_type; + GlobalV::KS_SOLVER = PARAM.inp.ks_solver; + GlobalV::SEARCH_RADIUS = PARAM.inp.search_radius; + GlobalV::SEARCH_PBC = PARAM.inp.search_pbc; //---------------------------------------------------------- // planewave (8/8) //---------------------------------------------------------- - GlobalV::GAMMA_ONLY_LOCAL = INPUT.gamma_only_local; + GlobalV::GAMMA_ONLY_LOCAL = PARAM.globalv.gamma_only_local; //---------------------------------------------------------- // diagonalization (5/5) //---------------------------------------------------------- - GlobalV::DIAGO_PROC = INPUT.diago_proc; - GlobalV::PW_DIAG_NMAX = INPUT.pw_diag_nmax; - GlobalV::DIAGO_CG_PREC = INPUT.diago_cg_prec; - GlobalV::PW_DIAG_NDIM = INPUT.pw_diag_ndim; + GlobalV::DIAGO_PROC = PARAM.inp.diago_proc; + GlobalV::PW_DIAG_NMAX = PARAM.inp.pw_diag_nmax; + GlobalV::DIAGO_CG_PREC = PARAM.inp.diago_cg_prec; + GlobalV::PW_DIAG_NDIM = PARAM.inp.pw_diag_ndim; hsolver::HSolverPW, base_device::DEVICE_CPU>::diago_full_acc = PARAM.inp.diago_full_acc; hsolver::HSolverPW, base_device::DEVICE_CPU>::diago_full_acc = PARAM.inp.diago_full_acc; @@ -447,70 +425,63 @@ void Input_Conv::Convert() hsolver::HSolverPW, base_device::DEVICE_GPU>::diago_full_acc = PARAM.inp.diago_full_acc; #endif - GlobalV::PW_DIAG_THR = INPUT.pw_diag_thr; - GlobalV::NB2D = INPUT.nb2d; - GlobalV::NURSE = INPUT.nurse; - GlobalV::COLOUR = INPUT.colour; - GlobalV::T_IN_H = INPUT.t_in_h; - GlobalV::VL_IN_H = INPUT.vl_in_h; - GlobalV::VNL_IN_H = INPUT.vnl_in_h; - GlobalV::VH_IN_H = INPUT.vh_in_h; - GlobalV::VION_IN_H = INPUT.vion_in_h; - GlobalV::TEST_FORCE = INPUT.test_force; - GlobalV::TEST_STRESS = INPUT.test_stress; - GlobalV::test_skip_ewald = INPUT.test_skip_ewald; + GlobalV::PW_DIAG_THR = PARAM.inp.pw_diag_thr; + GlobalV::NB2D = PARAM.inp.nb2d; + GlobalV::NURSE = PARAM.inp.nurse; + GlobalV::COLOUR = PARAM.inp.colour; + GlobalV::T_IN_H = PARAM.inp.t_in_h; + GlobalV::VL_IN_H = PARAM.inp.vl_in_h; + GlobalV::VNL_IN_H = PARAM.inp.vnl_in_h; + GlobalV::VH_IN_H = PARAM.inp.vh_in_h; + GlobalV::VION_IN_H = PARAM.inp.vion_in_h; + GlobalV::TEST_FORCE = PARAM.inp.test_force; + GlobalV::TEST_STRESS = PARAM.inp.test_stress; + GlobalV::test_skip_ewald = PARAM.inp.test_skip_ewald; //---------------------------------------------------------- // iteration (1/3) //---------------------------------------------------------- - GlobalV::SCF_THR = INPUT.scf_thr; - GlobalV::SCF_THR_TYPE = INPUT.scf_thr_type; + GlobalV::SCF_THR = PARAM.inp.scf_thr; + GlobalV::SCF_THR_TYPE = PARAM.inp.scf_thr_type; #ifdef __LCAO - if (INPUT.dft_plus_u) + if (PARAM.inp.dft_plus_u) { - GlobalV::dft_plus_u = INPUT.dft_plus_u; - GlobalC::dftu.Yukawa = INPUT.yukawa_potential; - GlobalC::dftu.omc = INPUT.omc; + GlobalV::dft_plus_u = PARAM.inp.dft_plus_u; + GlobalC::dftu.Yukawa = PARAM.inp.yukawa_potential; + GlobalC::dftu.omc = PARAM.inp.omc; GlobalC::dftu.orbital_corr = INPUT.orbital_corr; - GlobalC::dftu.uramping = INPUT.uramping; + GlobalC::dftu.uramping = PARAM.globalv.uramping; GlobalC::dftu.mixing_dftu = PARAM.inp.mixing_dftu; - if (INPUT.yukawa_potential && INPUT.hubbard_u == nullptr) - { - // Duradev's rotational invariant formulation is implemented - // where only an effective U given by U-J is used - // unit is in eV - INPUT.hubbard_u = new double[GlobalC::ucell.ntype]; - } GlobalC::dftu.U = INPUT.hubbard_u; GlobalC::dftu.U0 = std::vector(INPUT.hubbard_u, INPUT.hubbard_u + GlobalC::ucell.ntype); - if (INPUT.uramping > 0.01) + if (PARAM.globalv.uramping > 0.01) { ModuleBase::GlobalFunc::ZEROS(GlobalC::dftu.U, GlobalC::ucell.ntype); } } - GlobalV::onsite_radius = INPUT.onsite_radius; + GlobalV::onsite_radius = PARAM.inp.onsite_radius; #endif //-------------------------------------------- // added by zhengdy-soc //-------------------------------------------- - if (INPUT.noncolin || INPUT.lspinorb) + if (PARAM.inp.noncolin || PARAM.inp.lspinorb) { GlobalV::NSPIN = 4; } if (GlobalV::NSPIN == 4) { - GlobalV::NONCOLIN = INPUT.noncolin; + GlobalV::NONCOLIN = PARAM.inp.noncolin; // wavefunctions are spinors with 2 components GlobalV::NPOL = 2; // set the domag variable to make a spin-orbit calculation with zero // magnetization GlobalV::DOMAG = false; GlobalV::DOMAG_Z = true; - GlobalV::LSPINORB = INPUT.lspinorb; - GlobalV::soc_lambda = INPUT.soc_lambda; - if (INPUT.gamma_only_local) + GlobalV::LSPINORB = PARAM.inp.lspinorb; + GlobalV::soc_lambda = PARAM.inp.soc_lambda; + if (PARAM.globalv.gamma_only_local) { ModuleBase::WARNING_QUIT("input_conv", "nspin=4(soc or noncollinear-spin) does " @@ -541,7 +512,7 @@ void Input_Conv::Convert() //---------------------------------------------------------- GlobalV::GATE_FLAG = PARAM.inp.gate_flag; GlobalV::nelec = PARAM.inp.nelec; - if (PARAM.inp.sup.two_fermi) + if (PARAM.globalv.two_fermi) { GlobalV::TWO_EFERMI = true; GlobalV::nupdown = PARAM.inp.nupdown; @@ -553,13 +524,6 @@ void Input_Conv::Convert() elecstate::Gatefield::block_up = PARAM.inp.block_up; elecstate::Gatefield::block_height = PARAM.inp.block_height; - //---------------------------------------------------------- - // Yu Liu add 2023-05-09 - //---------------------------------------------------------- - INPUT.mdp.force_thr = GlobalV::FORCE_THR; - INPUT.mdp.my_rank = GlobalV::MY_RANK; - INPUT.mdp.cal_stress = GlobalV::CAL_STRESS; - //---------------------------------------------------------- // Fuxiang He add 2016-10-26 //---------------------------------------------------------- @@ -585,22 +549,22 @@ void Input_Conv::Convert() // For example, when we studying nitrogen-vacancy center, // it requires an additional excitation of an electron conduction band to // simulate the excited state, used for TDDFT only. - GlobalV::ocp = INPUT.ocp; - GlobalV::ocp_set = INPUT.ocp_set; + GlobalV::ocp = PARAM.inp.ocp; + GlobalV::ocp_set = PARAM.inp.ocp_set; if (GlobalV::ocp == 1) { parse_expression(GlobalV::ocp_set, GlobalV::ocp_kb); } - GlobalV::out_mul = INPUT.out_mul; // qifeng add 2019/9/10 + GlobalV::out_mul = PARAM.inp.out_mul; // qifeng add 2019/9/10 //---------------------------------------------------------- // about restart, // Peize Lin add 2020-04-04 //---------------------------------------------------------- - if (INPUT.restart_save) + if (PARAM.inp.restart_save) { - std::string dft_functional_lower = INPUT.dft_functional; - std::transform(INPUT.dft_functional.begin(), INPUT.dft_functional.end(), dft_functional_lower.begin(), tolower); + std::string dft_functional_lower = PARAM.inp.dft_functional; + std::transform(PARAM.inp.dft_functional.begin(), PARAM.inp.dft_functional.end(), dft_functional_lower.begin(), tolower); GlobalC::restart.folder = GlobalV::global_readin_dir + "restart/"; ModuleBase::GlobalFunc::MAKE_DIR(GlobalC::restart.folder); if (dft_functional_lower == "hf" || dft_functional_lower == "pbe0" || dft_functional_lower == "hse" @@ -614,10 +578,10 @@ void Input_Conv::Convert() GlobalC::restart.info_save.save_charge = true; } } - if (INPUT.restart_load) + if (PARAM.inp.restart_load) { - std::string dft_functional_lower = INPUT.dft_functional; - std::transform(INPUT.dft_functional.begin(), INPUT.dft_functional.end(), dft_functional_lower.begin(), tolower); + std::string dft_functional_lower = PARAM.inp.dft_functional; + std::transform(PARAM.inp.dft_functional.begin(), PARAM.inp.dft_functional.end(), dft_functional_lower.begin(), tolower); GlobalC::restart.folder = GlobalV::global_readin_dir + "restart/"; if (dft_functional_lower == "hf" || dft_functional_lower == "pbe0" || dft_functional_lower == "hse" || dft_functional_lower == "opt_orb" || dft_functional_lower == "scan0") @@ -631,19 +595,14 @@ void Input_Conv::Convert() } } - if (GlobalV::CALCULATION == "cell-relax" && INPUT.cell_factor < 2.0) - { - INPUT.cell_factor = 2.0; // follows QE - } - //---------------------------------------------------------- // about exx, Peize Lin add 2018-06-20 //---------------------------------------------------------- #ifdef __EXX #ifdef __LCAO - std::string dft_functional_lower = INPUT.dft_functional; - std::transform(INPUT.dft_functional.begin(), INPUT.dft_functional.end(), dft_functional_lower.begin(), tolower); + std::string dft_functional_lower = PARAM.inp.dft_functional; + std::transform(PARAM.inp.dft_functional.begin(), PARAM.inp.dft_functional.end(), dft_functional_lower.begin(), tolower); if (dft_functional_lower == "hf" || dft_functional_lower == "pbe0" || dft_functional_lower == "scan0") { GlobalC::exx_info.info_global.cal_exx = true; @@ -664,7 +623,7 @@ void Input_Conv::Convert() GlobalC::exx_info.info_global.cal_exx = false; } - if (GlobalC::exx_info.info_global.cal_exx || Exx_Abfs::Jle::generate_matrix || INPUT.rpa) + if (GlobalC::exx_info.info_global.cal_exx || Exx_Abfs::Jle::generate_matrix || PARAM.inp.rpa) { // EXX case, convert all EXX related variables // GlobalC::exx_info.info_global.cal_exx = true; @@ -693,13 +652,12 @@ void Input_Conv::Convert() Exx_Abfs::Jle::tolerence = PARAM.inp.exx_opt_orb_tolerence; // EXX does not support symmetry=1 - if (INPUT.calculation != "nscf" && PARAM.inp.symmetry == "1") { + if (PARAM.inp.calculation != "nscf" && PARAM.inp.symmetry == "1") ModuleSymmetry::Symmetry::symm_flag = 0; -} } #endif // __LCAO #endif // __EXX - GlobalC::ppcell.cell_factor = INPUT.cell_factor; // LiuXh add 20180619 + GlobalC::ppcell.cell_factor = PARAM.inp.cell_factor; // LiuXh add 20180619 //---------------------------------------------------------- // reset symmetry flag to avoid error @@ -721,40 +679,40 @@ void Input_Conv::Convert() //---------------------------------------------------------- // main parameters / electrons / spin ( 2/16 ) //---------------------------------------------------------- - // electrons::nelup = INPUT.nelup; - // electrons::neldw = INPUT.neldw; + // electrons::nelup = PARAM.inp.nelup; + // electrons::neldw = PARAM.inp.neldw; //---------------------------------------------------------- // occupation (3/3) //---------------------------------------------------------- std::string occupations = "smearing"; - Occupy::decision(occupations, INPUT.smearing_method, INPUT.smearing_sigma); + Occupy::decision(occupations, PARAM.inp.smearing_method, PARAM.inp.smearing_sigma); //---------------------------------------------------------- // iteration //---------------------------------------------------------- - GlobalV::SCF_NMAX = INPUT.scf_nmax; - GlobalV::RELAX_NMAX = INPUT.relax_nmax; - GlobalV::md_prec_level = INPUT.mdp.md_prec_level; + GlobalV::SCF_NMAX = PARAM.inp.scf_nmax; + GlobalV::RELAX_NMAX = PARAM.inp.relax_nmax; + GlobalV::md_prec_level = PARAM.mdp.md_prec_level; //---------------------------------------------------------- // wavefunction / charge / potential / (2/4) //---------------------------------------------------------- - GlobalV::OUT_FREQ_ELEC = INPUT.out_freq_elec; - GlobalV::OUT_FREQ_ION = INPUT.out_freq_ion; - GlobalV::init_chg = INPUT.init_chg; - GlobalV::init_wfc = INPUT.init_wfc; - GlobalV::psi_initializer = INPUT.psi_initializer; - GlobalV::chg_extrap = INPUT.chg_extrap; // xiaohui modify 2015-02-01 - GlobalV::out_chg = INPUT.out_chg; + GlobalV::OUT_FREQ_ELEC = PARAM.inp.out_freq_elec; + GlobalV::OUT_FREQ_ION = PARAM.inp.out_freq_ion; + GlobalV::init_chg = PARAM.inp.init_chg; + GlobalV::init_wfc = PARAM.inp.init_wfc; + GlobalV::psi_initializer = PARAM.inp.psi_initializer; + GlobalV::chg_extrap = PARAM.inp.chg_extrap; // xiaohui modify 2015-02-01 + GlobalV::out_chg = PARAM.inp.out_chg; GlobalV::nelec = PARAM.inp.nelec; GlobalV::nelec_delta = PARAM.inp.nelec_delta; - GlobalV::out_pot = INPUT.out_pot; - GlobalV::out_app_flag = INPUT.out_app_flag; - GlobalV::out_ndigits = INPUT.out_ndigits; + GlobalV::out_pot = PARAM.inp.out_pot; + GlobalV::out_app_flag = PARAM.inp.out_app_flag; + GlobalV::out_ndigits = PARAM.inp.out_ndigits; - GlobalV::out_bandgap = INPUT.out_bandgap; // QO added for bandgap printing - GlobalV::out_interval = INPUT.out_interval; + GlobalV::out_bandgap = PARAM.inp.out_bandgap; // QO added for bandgap printing + GlobalV::out_interval = PARAM.inp.out_interval; #ifdef __LCAO hsolver::HSolverLCAO::out_mat_hs = PARAM.inp.out_mat_hs; hsolver::HSolverLCAO::out_mat_hsR = PARAM.inp.out_mat_hs2; // LiuXh add 2019-07-16 @@ -772,7 +730,7 @@ void Input_Conv::Convert() { elecstate::ElecStateLCAO>::out_wfc_lcao = PARAM.inp.out_wfc_lcao; } - if (INPUT.calculation == "nscf" && !INPUT.towannier90 && !INPUT.berry_phase) + if (PARAM.inp.calculation == "nscf" && !PARAM.inp.towannier90 && !PARAM.inp.berry_phase) { if (GlobalV::GAMMA_ONLY_LOCAL) { @@ -783,7 +741,7 @@ void Input_Conv::Convert() elecstate::ElecStateLCAO>::need_psi_grid = false; } } - if (INPUT.calculation == "test_neighbour" && GlobalV::NPROC > 1) + if (PARAM.inp.calculation == "test_neighbour" && GlobalV::NPROC > 1) { ModuleBase::WARNING_QUIT("Input_conv", "test_neighbour must be done with 1 processor"); } @@ -793,13 +751,13 @@ void Input_Conv::Convert() // About LCAO //---------------------------------------------------------- // mohan add 2021-04-16 - // ORB.ecutwfc = INPUT.lcao_ecut; - // ORB.dk = INPUT.lcao_dk; - // ORB.dR = INPUT.lcao_dr; - // ORB.Rmax = INPUT.lcao_rmax; + // ORB.ecutwfc = PARAM.inp.lcao_ecut; + // ORB.dk = PARAM.inp.lcao_dk; + // ORB.dR = PARAM.inp.lcao_dr; + // ORB.Rmax = PARAM.inp.lcao_rmax; // mohan add 2021-02-16 - berryphase::berry_phase_flag = INPUT.berry_phase; + berryphase::berry_phase_flag = PARAM.inp.berry_phase; //----------------------------------------------- // caoyu add for DeePKS diff --git a/source/module_io/input_conv_tmp.cpp b/source/module_io/input_conv_tmp.cpp index 39cab2e950..588f1e46da 100644 --- a/source/module_io/input_conv_tmp.cpp +++ b/source/module_io/input_conv_tmp.cpp @@ -8,246 +8,23 @@ void Input_Conv::tmp_convert() { INPUT.stru_file = PARAM.inp.stru_file; - INPUT.pseudo_dir = PARAM.inp.pseudo_dir; - INPUT.orbital_dir = PARAM.inp.orbital_dir; - INPUT.read_file_dir = PARAM.inp.read_file_dir; - INPUT.kpoint_file = PARAM.inp.kpoint_file; - INPUT.wannier_card = PARAM.inp.wannier_card; - INPUT.latname = PARAM.inp.latname; - INPUT.calculation = PARAM.inp.calculation; - INPUT.esolver_type = PARAM.inp.esolver_type; - INPUT.pseudo_rcut = PARAM.inp.pseudo_rcut; - INPUT.pseudo_mesh = PARAM.inp.pseudo_mesh; - INPUT.ntype = PARAM.inp.ntype; - INPUT.nbands = PARAM.inp.nbands; - INPUT.nbands_istate = PARAM.inp.nbands_istate; - INPUT.pw_seed = PARAM.inp.pw_seed; - INPUT.init_vel = PARAM.inp.init_vel; - INPUT.ref_cell_factor = PARAM.inp.ref_cell_factor; - - INPUT.kpar = PARAM.inp.kpar; - INPUT.berry_phase = PARAM.inp.berry_phase; - INPUT.gdir = PARAM.inp.gdir; - INPUT.kspacing[0] = PARAM.inp.kspacing[0]; - INPUT.kspacing[1] = PARAM.inp.kspacing[1]; - INPUT.kspacing[2] = PARAM.inp.kspacing[2]; - INPUT.min_dist_coef = PARAM.inp.min_dist_coef; - INPUT.towannier90 = PARAM.inp.towannier90; - INPUT.nnkpfile = PARAM.inp.nnkpfile; - INPUT.wannier_spin = PARAM.inp.wannier_spin; - INPUT.wannier_method = PARAM.inp.wannier_method; - INPUT.out_wannier_mmn = PARAM.inp.out_wannier_mmn; - INPUT.out_wannier_amn = PARAM.inp.out_wannier_amn; - INPUT.out_wannier_unk = PARAM.inp.out_wannier_unk; - INPUT.out_wannier_eig = PARAM.inp.out_wannier_eig; - INPUT.out_wannier_wvfn_formatted = PARAM.inp.out_wannier_wvfn_formatted; - - INPUT.nche_sto = PARAM.inp.nche_sto; - INPUT.nbands_sto = PARAM.inp.nbands_sto; - INPUT.seed_sto = PARAM.inp.seed_sto; - INPUT.initsto_ecut = PARAM.inp.initsto_ecut; - INPUT.emax_sto = PARAM.inp.emax_sto; - INPUT.emin_sto = PARAM.inp.emin_sto; - INPUT.bndpar = PARAM.inp.bndpar; - INPUT.initsto_freq = PARAM.inp.initsto_freq; - INPUT.method_sto = PARAM.inp.method_sto; - INPUT.npart_sto = PARAM.inp.npart_sto; - INPUT.cal_cond = PARAM.inp.cal_cond; - INPUT.cond_che_thr = PARAM.inp.cond_che_thr; - INPUT.cond_smear = PARAM.inp.cond_smear; - INPUT.cond_dw = PARAM.inp.cond_dw; - INPUT.cond_wcut = PARAM.inp.cond_wcut; - INPUT.cond_dt = PARAM.inp.cond_dt; + INPUT.bessel_nao_rcut = PARAM.globalv.bessel_nao_rcut; INPUT.cond_dtbatch = PARAM.inp.cond_dtbatch; - INPUT.cond_fwhm = PARAM.inp.cond_fwhm; - INPUT.cond_nonlocal = PARAM.inp.cond_nonlocal; - - INPUT.dft_functional = PARAM.inp.dft_functional; - INPUT.xc_temperature = PARAM.inp.xc_temperature; - INPUT.nspin = PARAM.inp.nspin; - INPUT.lmaxmax = PARAM.inp.lmaxmax; - - INPUT.basis_type = PARAM.inp.basis_type; - INPUT.ks_solver = PARAM.inp.ks_solver; - INPUT.cal_force = PARAM.inp.cal_force; - INPUT.force_thr = PARAM.inp.force_thr; - INPUT.stress_thr = PARAM.inp.stress_thr; - INPUT.press1 = PARAM.inp.press1; - INPUT.press2 = PARAM.inp.press2; - INPUT.press3 = PARAM.inp.press3; - INPUT.cal_stress = PARAM.inp.cal_stress; - INPUT.nstream = PARAM.inp.nstream; - INPUT.fixed_axes = PARAM.inp.fixed_axes; - INPUT.fixed_ibrav = PARAM.inp.fixed_ibrav; - INPUT.fixed_atoms = PARAM.inp.fixed_atoms; - INPUT.relax_method = PARAM.inp.relax_method; - INPUT.relax_new = PARAM.inp.relax_new; - INPUT.relax_cg_thr = PARAM.inp.relax_cg_thr; - INPUT.relax_scale_force = PARAM.inp.relax_scale_force; - INPUT.gamma_only = PARAM.inp.gamma_only; - INPUT.gamma_only_local = PARAM.inp.sup.gamma_only_local; - INPUT.fft_mode = PARAM.inp.fft_mode; - INPUT.ecutwfc = PARAM.inp.ecutwfc; - INPUT.ecutrho = PARAM.inp.ecutrho; - INPUT.erf_ecut = PARAM.inp.erf_ecut; - INPUT.erf_height = PARAM.inp.erf_height; - INPUT.erf_sigma = PARAM.inp.erf_sigma; - INPUT.ncx = PARAM.inp.sup.ncx; - INPUT.ncy = PARAM.inp.sup.ncy; - INPUT.ncz = PARAM.inp.sup.ncz; - INPUT.nx = PARAM.inp.nx; - INPUT.ny = PARAM.inp.ny; - INPUT.nz = PARAM.inp.nz; - INPUT.bx = PARAM.inp.bx; - INPUT.by = PARAM.inp.by; - INPUT.bz = PARAM.inp.bz; - INPUT.ndx = PARAM.inp.ndx; - INPUT.ndy = PARAM.inp.ndy; - INPUT.ndz = PARAM.inp.ndz; - INPUT.diago_proc = PARAM.inp.diago_proc; - INPUT.pw_diag_nmax = PARAM.inp.pw_diag_nmax; - INPUT.diago_cg_prec = PARAM.inp.diago_cg_prec; - INPUT.pw_diag_ndim = PARAM.inp.pw_diag_ndim; - INPUT.pw_diag_thr = PARAM.inp.pw_diag_thr; - INPUT.nb2d = PARAM.inp.nb2d; - INPUT.nurse = PARAM.inp.nurse; - INPUT.nbspline = PARAM.inp.nbspline; - INPUT.colour = PARAM.inp.colour; - INPUT.t_in_h = PARAM.inp.t_in_h; - INPUT.vl_in_h = PARAM.inp.vl_in_h; - INPUT.vnl_in_h = PARAM.inp.vnl_in_h; - INPUT.vh_in_h = PARAM.inp.vh_in_h; - INPUT.vion_in_h = PARAM.inp.vion_in_h; - INPUT.test_force = PARAM.inp.test_force; - INPUT.test_stress = PARAM.inp.test_stress; - INPUT.scf_thr = PARAM.inp.scf_thr; - INPUT.scf_thr_type = PARAM.inp.scf_thr_type; - INPUT.scf_nmax = PARAM.inp.scf_nmax; - INPUT.relax_nmax = PARAM.inp.relax_nmax; - INPUT.out_level = PARAM.inp.out_level; - INPUT.out_md_control = PARAM.inp.sup.out_md_control; - INPUT.smearing_method = PARAM.inp.smearing_method; - INPUT.smearing_sigma = PARAM.inp.smearing_sigma; - - INPUT.init_wfc = PARAM.inp.init_wfc; - INPUT.init_chg = PARAM.inp.init_chg; - INPUT.psi_initializer = PARAM.inp.psi_initializer; - INPUT.chg_extrap = PARAM.inp.chg_extrap; - INPUT.mem_saver = PARAM.inp.mem_saver; - INPUT.printe = PARAM.inp.printe; - INPUT.out_freq_elec = PARAM.inp.out_freq_elec; - INPUT.out_freq_ion = PARAM.inp.out_freq_ion; - INPUT.out_chg = PARAM.inp.out_chg; - INPUT.out_pot = PARAM.inp.out_pot; - INPUT.out_wfc_pw = PARAM.inp.out_wfc_pw; - INPUT.out_wfc_r = PARAM.inp.out_wfc_r; - INPUT.out_dos = PARAM.inp.out_dos; - INPUT.out_band = PARAM.inp.out_band; - INPUT.out_proj_band = PARAM.inp.out_proj_band; - INPUT.cal_syns = PARAM.inp.cal_syns; - INPUT.dmax = PARAM.inp.dmax; - INPUT.out_interval = PARAM.inp.out_interval; - INPUT.out_app_flag = PARAM.inp.out_app_flag; - INPUT.out_ndigits = PARAM.inp.out_ndigits; - INPUT.out_mat_r = PARAM.inp.out_mat_r; - INPUT.out_alllog = PARAM.inp.out_alllog; - INPUT.out_element_info = PARAM.inp.out_element_info; - INPUT.out_bandgap = PARAM.inp.out_bandgap; - INPUT.dos_emin_ev = PARAM.inp.dos_emin_ev; - INPUT.dos_emax_ev = PARAM.inp.dos_emax_ev; - INPUT.dos_edelta_ev = PARAM.inp.dos_edelta_ev; - INPUT.dos_scale = PARAM.inp.dos_scale; - INPUT.dos_nche = PARAM.inp.dos_nche; - INPUT.dos_setemin = PARAM.inp.sup.dos_setemin; - INPUT.dos_setemax = PARAM.inp.sup.dos_setemax; - INPUT.dos_sigma = PARAM.inp.dos_sigma; - INPUT.lcao_ecut = PARAM.inp.lcao_ecut; - INPUT.lcao_dk = PARAM.inp.lcao_dk; - INPUT.lcao_dr = PARAM.inp.lcao_dr; - INPUT.lcao_rmax = PARAM.inp.lcao_rmax; - INPUT.search_radius = PARAM.inp.search_radius; - INPUT.search_pbc = PARAM.inp.search_pbc; - INPUT.onsite_radius = PARAM.inp.onsite_radius; - + INPUT.nche_sto = PARAM.inp.nche_sto; INPUT.mdp = PARAM.mdp; - INPUT.vdw_method = PARAM.inp.vdw_method; - INPUT.vdw_s6 = PARAM.inp.vdw_s6; - INPUT.vdw_s8 = PARAM.inp.vdw_s8; - INPUT.vdw_a1 = PARAM.inp.vdw_a1; - INPUT.vdw_a2 = PARAM.inp.vdw_a2; - INPUT.vdw_d = PARAM.inp.vdw_d; - INPUT.vdw_abc = PARAM.inp.vdw_abc; - INPUT.vdw_cutoff_radius = PARAM.inp.vdw_cutoff_radius; - INPUT.vdw_radius_unit = PARAM.inp.vdw_radius_unit; - INPUT.vdw_cn_thr = PARAM.inp.vdw_cn_thr; - INPUT.vdw_cn_thr_unit = PARAM.inp.vdw_cn_thr_unit; - INPUT.vdw_C6_file = PARAM.inp.vdw_C6_file; - INPUT.vdw_C6_unit = PARAM.inp.vdw_C6_unit; - INPUT.vdw_R0_file = PARAM.inp.vdw_R0_file; - INPUT.vdw_R0_unit = PARAM.inp.vdw_R0_unit; - INPUT.vdw_cutoff_type = PARAM.inp.vdw_cutoff_type; - INPUT.vdw_cutoff_period = PARAM.inp.vdw_cutoff_period; - - INPUT.ocp = PARAM.inp.ocp; - INPUT.ocp_set = PARAM.inp.ocp_set; - INPUT.out_mul = PARAM.inp.out_mul; - INPUT.noncolin = PARAM.inp.noncolin; - INPUT.lspinorb = PARAM.inp.lspinorb; - INPUT.soc_lambda = PARAM.inp.soc_lambda; - - INPUT.restart_save = PARAM.inp.restart_save; - INPUT.restart_load = PARAM.inp.restart_load; - INPUT.cell_factor = PARAM.inp.cell_factor; - INPUT.dft_plus_u = PARAM.inp.dft_plus_u; + const int ntype = PARAM.inp.ntype; delete[] INPUT.orbital_corr; - INPUT.orbital_corr = new int[INPUT.ntype]; - for (int i = 0; i < INPUT.ntype; ++i) + INPUT.orbital_corr = new int[ntype]; + for (int i = 0; i < ntype; ++i) { INPUT.orbital_corr[i] = PARAM.inp.orbital_corr[i]; } delete[] INPUT.hubbard_u; - INPUT.hubbard_u = new double[INPUT.ntype]; - for (int i = 0; i < INPUT.ntype; ++i) + INPUT.hubbard_u = new double[ntype]; + for (int i = 0; i < ntype; ++i) { - INPUT.hubbard_u[i] = PARAM.inp.sup.hubbard_u[i]; + INPUT.hubbard_u[i] = PARAM.globalv.hubbard_u[i]; } - INPUT.omc = PARAM.inp.omc; - INPUT.yukawa_potential = PARAM.inp.yukawa_potential; - INPUT.yukawa_lambda = PARAM.inp.yukawa_lambda; - INPUT.uramping = PARAM.inp.sup.uramping; - INPUT.dft_plus_dmft = PARAM.inp.dft_plus_dmft; - INPUT.rpa = PARAM.inp.rpa; - INPUT.of_kinetic = PARAM.inp.of_kinetic; - INPUT.of_method = PARAM.inp.of_method; - INPUT.of_conv = PARAM.inp.of_conv; - INPUT.of_tole = PARAM.inp.of_tole; - INPUT.of_tolp = PARAM.inp.of_tolp; - INPUT.of_tf_weight = PARAM.inp.of_tf_weight; - INPUT.of_vw_weight = PARAM.inp.of_vw_weight; - INPUT.of_wt_alpha = PARAM.inp.of_wt_alpha; - INPUT.of_wt_beta = PARAM.inp.of_wt_beta; - INPUT.of_wt_rho0 = PARAM.inp.of_wt_rho0; - INPUT.of_hold_rho0 = PARAM.inp.of_hold_rho0; - INPUT.of_lkt_a = PARAM.inp.of_lkt_a; - INPUT.of_full_pw = PARAM.inp.of_full_pw; - INPUT.of_full_pw_dim = PARAM.inp.of_full_pw_dim; - INPUT.of_read_kernel = PARAM.inp.of_read_kernel; - INPUT.of_kernel_file = PARAM.inp.of_kernel_file; - INPUT.bessel_nao_smooth = PARAM.inp.bessel_nao_smooth; - INPUT.bessel_nao_sigma = PARAM.inp.bessel_nao_sigma; - INPUT.bessel_nao_ecut = PARAM.inp.bessel_nao_ecut; - INPUT.bessel_nao_rcut = PARAM.inp.sup.bessel_nao_rcut; - INPUT.bessel_nao_rcuts = PARAM.inp.bessel_nao_rcuts; - INPUT.bessel_nao_tolerence = PARAM.inp.bessel_nao_tolerence; - INPUT.bessel_descriptor_lmax = PARAM.inp.bessel_descriptor_lmax; - INPUT.bessel_descriptor_smooth = PARAM.inp.bessel_descriptor_smooth; - INPUT.bessel_descriptor_sigma = PARAM.inp.bessel_descriptor_sigma; - INPUT.bessel_descriptor_ecut = PARAM.inp.bessel_descriptor_ecut; - INPUT.bessel_descriptor_rcut = PARAM.inp.bessel_descriptor_rcut; - INPUT.bessel_descriptor_tolerence = PARAM.inp.bessel_descriptor_tolerence; - INPUT.device = PARAM.inp.device; - INPUT.precision = PARAM.inp.precision; - INPUT.test_skip_ewald = PARAM.inp.test_skip_ewald; - INPUT.use_paw = PARAM.inp.use_paw; + INPUT.bands_to_print_ = PARAM.inp.bands_to_print; } diff --git a/source/module_io/istate_envelope.cpp b/source/module_io/istate_envelope.cpp index 81384d200f..b537c20275 100644 --- a/source/module_io/istate_envelope.cpp +++ b/source/module_io/istate_envelope.cpp @@ -23,8 +23,8 @@ void IState_Envelope::begin(const psi::Psi* psid, const ModulePW::PW_Basis_Big* bigpw, const Parallel_Orbitals& para_orb, Gint_Gamma& gg, - int& out_wfc_pw, - int& out_wfc_r, + const int& out_wfc_pw, + const int& out_wfc_r, const K_Vectors& kv, const double nelec, const int nbands_istate, @@ -256,8 +256,8 @@ void IState_Envelope::begin(const psi::Psi>* psi, const ModulePW::PW_Basis_Big* bigpw, const Parallel_Orbitals& para_orb, Gint_k& gk, - int& out_wf, - int& out_wf_r, + const int& out_wf, + const int& out_wf_r, const K_Vectors& kv, const double nelec, const int nbands_istate, diff --git a/source/module_io/istate_envelope.h b/source/module_io/istate_envelope.h index 79e3f39850..0b075b8462 100644 --- a/source/module_io/istate_envelope.h +++ b/source/module_io/istate_envelope.h @@ -23,8 +23,8 @@ class IState_Envelope const ModulePW::PW_Basis_Big* bigpw, const Parallel_Orbitals& para_orb, Gint_Gamma& gg, - int& out_wfc_pw, - int& out_wfc_r, + const int& out_wfc_pw, + const int& out_wfc_r, const K_Vectors& kv, const double nelec, const int nbands_istate, @@ -41,8 +41,8 @@ class IState_Envelope const ModulePW::PW_Basis_Big* bigpw, const Parallel_Orbitals& para_orb, Gint_k& gg, - int& out_wfc_pw, - int& out_wfc_r, + const int& out_wfc_pw, + const int& out_wfc_r, const K_Vectors& kv, const double nelec, const int nbands_istate, @@ -61,8 +61,8 @@ class IState_Envelope const ModulePW::PW_Basis_Big* bigpw, const Parallel_Orbitals& para_orb, Gint_k& gk, - int& out_wfc_pw, - int& out_wfc_r, + const int& out_wfc_pw, + const int& out_wfc_r, const K_Vectors& kv, const double nelec, const int nbands_istate, @@ -79,8 +79,8 @@ class IState_Envelope const ModulePW::PW_Basis_Big* bigpw, const Parallel_Orbitals& para_orb, Gint_Gamma& gk, - int& out_wfc_pw, - int& out_wfc_r, + const int& out_wfc_pw, + const int& out_wfc_r, const K_Vectors& kv, const double nelec, const int nbands_istate, diff --git a/source/module_io/json_output/general_info.cpp b/source/module_io/json_output/general_info.cpp index 8621e61208..ac5146e9a2 100644 --- a/source/module_io/json_output/general_info.cpp +++ b/source/module_io/json_output/general_info.cpp @@ -3,7 +3,6 @@ #include "../para_json.h" #include "abacusjson.h" #include "module_base/parallel_global.h" -#include "module_io/input.h" #include "version.h" // Add json objects to gener_info @@ -11,7 +10,7 @@ namespace Json { #ifdef __RAPIDJSON -void gen_general_info(Input* input) +void gen_general_info(const Parameter& param) { #ifdef VERSION @@ -27,7 +26,7 @@ void gen_general_info(Input* input) #endif // start_time - std::time_t start_time = input->get_start_time(); + std::time_t start_time = param.globalv.start_time; std::string start_time_str; convert_time(start_time, start_time_str); @@ -46,25 +45,25 @@ void gen_general_info(Input* input) AbacusJson::add_json({"general_info", "version"}, version, false); AbacusJson::add_json({"general_info", "commit"}, commit, false); - AbacusJson::add_json({"general_info", "device"}, input->device, false); + AbacusJson::add_json({"general_info", "device"}, param.inp.device, false); AbacusJson::add_json({"general_info", "mpi_num"}, mpi_num, false); AbacusJson::add_json({"general_info", "omp_num"}, omp_num, false); - AbacusJson::add_json({"general_info", "pseudo_dir"}, input->pseudo_dir, false); - AbacusJson::add_json({"general_info", "orbital_dir"}, input->orbital_dir, false); - AbacusJson::add_json({"general_info", "stru_file"}, input->stru_file, false); - AbacusJson::add_json({"general_info", "kpt_file"}, input->kpoint_file, false); + AbacusJson::add_json({"general_info", "pseudo_dir"}, param.inp.pseudo_dir, false); + AbacusJson::add_json({"general_info", "orbital_dir"}, param.inp.orbital_dir, false); + AbacusJson::add_json({"general_info", "stru_file"}, param.inp.stru_file, false); + AbacusJson::add_json({"general_info", "kpt_file"}, param.inp.kpoint_file, false); AbacusJson::add_json({"general_info", "start_time"}, start_time_str, false); AbacusJson::add_json({"general_info", "end_time"}, end_time_str, false); // AbacusJson::add_Json(version,false,"general_info", "version"); // AbacusJson::add_Json(commit,false,"general_info", "commit"); - // AbacusJson::add_Json(input->device,false,"general_info", "device"); + // AbacusJson::add_Json(param.inp.device,false,"general_info", "device"); // AbacusJson::add_Json(mpi_num,false,"general_info", "mpi_num"); // AbacusJson::add_Json(omp_num,false,"general_info", "omp_num"); - // AbacusJson::add_Json(input->pseudo_dir,false,"general_info", "pseudo_dir"); - // AbacusJson::add_Json(input->orbital_dir,false,"general_info", "orbital_dir"); - // AbacusJson::add_Json(input->stru_file,false,"general_info", "stru_file"); - // AbacusJson::add_Json(input->kpoint_file,false,"general_info", "kpt_file"); + // AbacusJson::add_Json(param.inp.pseudo_dir,false,"general_info", "pseudo_dir"); + // AbacusJson::add_Json(param.inp.orbital_dir,false,"general_info", "orbital_dir"); + // AbacusJson::add_Json(param.inp.stru_file,false,"general_info", "stru_file"); + // AbacusJson::add_Json(param.inp.kpoint_file,false,"general_info", "kpt_file"); // AbacusJson::add_Json(start_time_str,false,"general_info", "start_time"); // AbacusJson::add_Json(end_time_str,false,"general_info", "end_time"); } diff --git a/source/module_io/json_output/general_info.h b/source/module_io/json_output/general_info.h index 3dcecf2c67..c94c59cd64 100644 --- a/source/module_io/json_output/general_info.h +++ b/source/module_io/json_output/general_info.h @@ -1,6 +1,6 @@ #ifndef GENERAL_INFO_H #define GENERAL_INFO_H -#include "module_io/input.h" +#include "module_parameter/parameter.h" /** * @brief In this part of the code to complete the general_info part of the json tree. @@ -8,7 +8,7 @@ namespace Json { #ifdef __RAPIDJSON -void gen_general_info(Input *input); +void gen_general_info(const Parameter& param); #endif } #endif \ No newline at end of file diff --git a/source/module_io/json_output/test/CMakeLists.txt b/source/module_io/json_output/test/CMakeLists.txt index 5628afca48..e6e91b9628 100644 --- a/source/module_io/json_output/test/CMakeLists.txt +++ b/source/module_io/json_output/test/CMakeLists.txt @@ -6,7 +6,7 @@ remove_definitions(-DUSE_PAW) AddTest( TARGET io_json_output_json - LIBS ${math_libs} base device cell_info + LIBS ${math_libs} base device cell_info parameter SOURCES para_json_test.cpp ../general_info.cpp ../init_info.cpp ../readin_info.cpp - ../../para_json.cpp ../abacusjson.cpp ../../input.cpp ../../output.cpp + ../../para_json.cpp ../abacusjson.cpp ../../output.cpp ) \ No newline at end of file diff --git a/source/module_io/json_output/test/para_json_test.cpp b/source/module_io/json_output/test/para_json_test.cpp index 6d6a06683d..795520d826 100644 --- a/source/module_io/json_output/test/para_json_test.cpp +++ b/source/module_io/json_output/test/para_json_test.cpp @@ -5,7 +5,7 @@ #include "../general_info.h" #include "../init_info.h" #include "../readin_info.h" -#include "module_io/input.h" +#include "module_parameter/parameter.h" #include "module_io/para_json.h" #include "version.h" @@ -209,16 +209,16 @@ TEST(AbacusJsonTest, GeneralInfo) std::time_t time_now = std::time(nullptr); std::string start_time_str; Json::convert_time(time_now, start_time_str); - INPUT.start_time = time_now; + PARAM.sys.start_time = time_now; - INPUT.device = "cpu"; - INPUT.pseudo_dir = "./abacus/test/pseudo_dir"; - INPUT.orbital_dir = "./abacus/test/orbital_dir"; - INPUT.stru_file = "./abacus/test/stru_file"; - INPUT.kpoint_file = "./abacus/test/kpoint_file"; + PARAM.input.device = "cpu"; + PARAM.input.pseudo_dir = "./abacus/test/pseudo_dir"; + PARAM.input.orbital_dir = "./abacus/test/orbital_dir"; + PARAM.input.stru_file = "./abacus/test/stru_file"; + PARAM.input.kpoint_file = "./abacus/test/kpoint_file"; // output the json file Json::AbacusJson::doc.Parse("{}"); - Json::gen_general_info(&INPUT); + Json::gen_general_info(PARAM); Json::json_output(); std::string filename = "abacus.json"; diff --git a/source/module_io/numerical_basis.cpp b/source/module_io/numerical_basis.cpp index 4b6249f2fe..565c7d1bfe 100644 --- a/source/module_io/numerical_basis.cpp +++ b/source/module_io/numerical_basis.cpp @@ -47,9 +47,9 @@ void Numerical_Basis::start_from_file_k(const int& ik, ModuleBase::ComplexMatrix if (!this->init_label) { // true stands for : start_from_file - this->bessel_basis.init(true, std::stod(INPUT.bessel_nao_ecut), ucell.ntype, ucell.lmax, - INPUT.bessel_nao_smooth, INPUT.bessel_nao_sigma, INPUT.bessel_nao_rcut, - INPUT.bessel_nao_tolerence, ucell); + this->bessel_basis.init(true, std::stod(PARAM.inp.bessel_nao_ecut), ucell.ntype, ucell.lmax, + PARAM.inp.bessel_nao_smooth, PARAM.inp.bessel_nao_sigma, PARAM.globalv.bessel_nao_rcut, + PARAM.inp.bessel_nao_tolerence, ucell); this->mu_index = this->init_mu_index(ucell); this->init_label = true; } @@ -70,9 +70,9 @@ void Numerical_Basis::output_overlap(const psi::Psi>& psi, if (!this->init_label) { // false stands for : 'Faln' is not used. - this->bessel_basis.init(false, std::stod(INPUT.bessel_nao_ecut), ucell.ntype, ucell.lmax, - INPUT.bessel_nao_smooth, INPUT.bessel_nao_sigma, INPUT.bessel_nao_rcut, - INPUT.bessel_nao_tolerence, ucell); + this->bessel_basis.init(false, std::stod(PARAM.inp.bessel_nao_ecut), ucell.ntype, ucell.lmax, + PARAM.inp.bessel_nao_smooth, PARAM.inp.bessel_nao_sigma, PARAM.globalv.bessel_nao_rcut, + PARAM.inp.bessel_nao_tolerence, ucell); this->mu_index = this->init_mu_index(ucell); this->init_label = true; } @@ -84,9 +84,9 @@ void Numerical_Basis::output_overlap(const psi::Psi>& psi, // the parameter 'winput::spillage_outdir' is read from INPUTw. ss << winput::spillage_outdir << "/"; - if (INPUT.bessel_nao_rcuts.size() > 1) + if (PARAM.inp.bessel_nao_rcuts.size() > 1) { - ss << "orb_matrix_rcut" << INPUT.bessel_nao_rcut << "deriv"; + ss << "orb_matrix_rcut" << PARAM.globalv.bessel_nao_rcut << "deriv"; } else { @@ -585,7 +585,7 @@ void Numerical_Basis::output_info(std::ofstream& ofs, const Bessel_Basis& bessel } } // ecutwfc_jlq determine the jlq corresponding to plane wave calculation. - ofs << INPUT.ecutwfc << " ecutwfc" << std::endl; // mohan add 2009-09-08 + ofs << PARAM.inp.ecutwfc << " ecutwfc" << std::endl; // mohan add 2009-09-08 // this parameter determine the total number of jlq. ofs << bessel_basis.get_ecut() << " ecutwfc_jlq" << std::endl; // mohan modify 2009-09-08 diff --git a/source/module_io/numerical_descriptor.cpp b/source/module_io/numerical_descriptor.cpp index 5eab902697..1300ab89f4 100644 --- a/source/module_io/numerical_descriptor.cpp +++ b/source/module_io/numerical_descriptor.cpp @@ -46,12 +46,12 @@ void Numerical_Descriptor::output_descriptor(const psi::Psi // Peize Lin change 2022.12.15 // 0 stands for : 'Faln' is not used. this->bessel_basis.init( - 0, - std::stod(INPUT.bessel_descriptor_ecut), + false, + std::stod(PARAM.inp.bessel_descriptor_ecut), GlobalC::ucell.ntype, this->lmax, - INPUT.bessel_descriptor_smooth, - INPUT.bessel_descriptor_sigma, + PARAM.inp.bessel_descriptor_smooth, + PARAM.inp.bessel_descriptor_sigma, rcut_in, tol_in, GlobalC::ucell @@ -335,7 +335,7 @@ normalization 2015-12-29 for (int ie=0; ie < nmax; ie++) } */ -void Numerical_Descriptor::init_mu_index(void) +void Numerical_Descriptor::init_mu_index() { GlobalV::ofs_running << " Initialize the mu index for deepks" << std::endl; GlobalV::ofs_running << " lmax = " << this->lmax << std::endl; diff --git a/source/module_io/para_json.cpp b/source/module_io/para_json.cpp index 69d7bf1867..8f0fdedf86 100644 --- a/source/module_io/para_json.cpp +++ b/source/module_io/para_json.cpp @@ -37,10 +37,10 @@ void json_output() #endif // __RAPIDJSON } -void create_Json(UnitCell* ucell, Input* input) +void create_Json(UnitCell* ucell, const Parameter& param) { #ifdef __RAPIDJSON - gen_general_info(input); + gen_general_info(param); gen_init(ucell); // gen_stru(ucell); #endif diff --git a/source/module_io/para_json.h b/source/module_io/para_json.h index 9fb665e587..97adea69aa 100644 --- a/source/module_io/para_json.h +++ b/source/module_io/para_json.h @@ -3,14 +3,14 @@ #include "module_cell/module_symmetry/symmetry.h" #include "module_cell/atom_spec.h" -#include "module_io/input.h" +#include "module_parameter/parameter.h" #include "module_cell/unitcell.h" namespace Json { // void create_Json(ModuleSymmetry::Symmetry *symm,Atom *atoms,Input *input); -void create_Json(UnitCell *ucell,Input *input); +void create_Json(UnitCell *ucell, const Parameter& input); // Output the json to abacus.json file void json_output(); diff --git a/source/module_io/read_input.cpp b/source/module_io/read_input.cpp index ad45783fb2..9615d86891 100644 --- a/source/module_io/read_input.cpp +++ b/source/module_io/read_input.cpp @@ -103,6 +103,7 @@ bool ReadInput::check_mode = false; ReadInput::ReadInput(const int& rank) { this->rank = rank; + this->set_globalv_bcast(); this->item_general(); this->item_pw(); this->item_sdft(); @@ -418,7 +419,7 @@ void ReadInput::check_ntype(const std::string& fn, int& param_ntype) if (!ifa) { GlobalV::ofs_warning << fn; - ModuleBase::WARNING_QUIT("Input::count_ntype", "Can not find the file containing atom positions.!"); + ModuleBase::WARNING_QUIT("ReadInput::check_ntype", "Can not find the file containing atom positions.!"); } int ntype_stru = 0; diff --git a/source/module_io/read_input.h b/source/module_io/read_input.h index 480776b1d6..c733bddae2 100644 --- a/source/module_io/read_input.h +++ b/source/module_io/read_input.h @@ -76,6 +76,8 @@ class ReadInput * @param item input_item */ void add_item(const Input_Item& item); + // add bcast functions for global values + void set_globalv_bcast(); // general items void item_general(); // items for pw diff --git a/source/module_io/read_input_item_general.cpp b/source/module_io/read_input_item_general.cpp index bcdc818bfd..fd7bf3ab5d 100644 --- a/source/module_io/read_input_item_general.cpp +++ b/source/module_io/read_input_item_general.cpp @@ -14,7 +14,7 @@ namespace ModuleIO // { // Input_Item item("suffix"); // item.annotation = "the name of main output directory"; -// read_sync_string(suffix); +// read_sync_string(input.suffix); // this->add_item(item); // } // @@ -50,68 +50,68 @@ void ReadInput::item_general() { Input_Item item("suffix"); item.annotation = "the name of main output directory"; - read_sync_string(suffix); + read_sync_string(input.suffix); this->add_item(item); } { Input_Item item("latname"); item.annotation = "the name of lattice name"; - read_sync_string(latname); + read_sync_string(input.latname); this->add_item(item); } { Input_Item item("stru_file"); item.annotation = "the filename of file containing atom positions"; - read_sync_string(stru_file); + read_sync_string(input.stru_file); this->add_item(item); } { Input_Item item("kpoint_file"); item.annotation = "the name of file containing k points"; - read_sync_string(kpoint_file); + read_sync_string(input.kpoint_file); this->add_item(item); } { Input_Item item("pseudo_dir"); item.annotation = "the directory containing pseudo files"; - read_sync_string(pseudo_dir); + read_sync_string(input.pseudo_dir); this->add_item(item); } { Input_Item item("orbital_dir"); item.annotation = "the directory containing orbital files"; - read_sync_string(orbital_dir); + read_sync_string(input.orbital_dir); this->add_item(item); } { Input_Item item("pseudo_rcut"); item.annotation = "default #exchange correlation functional"; - read_sync_double(pseudo_rcut); + read_sync_double(input.pseudo_rcut); this->add_item(item); } { Input_Item item("pseudo_mesh"); item.annotation = "0: use our own mesh to do radial renormalization; " "1: use mesh as in QE"; - read_sync_bool(pseudo_mesh); + read_sync_bool(input.pseudo_mesh); this->add_item(item); } { Input_Item item("lmaxmax"); item.annotation = "maximum of l channels used"; - read_sync_int(lmaxmax); + read_sync_int(input.lmaxmax); this->add_item(item); } { Input_Item item("dft_functional"); item.annotation = "exchange correlation functional"; - read_sync_string(dft_functional); + read_sync_string(input.dft_functional); this->add_item(item); } { Input_Item item("xc_temperature"); item.annotation = "temperature for finite temperature functionals"; - read_sync_double(xc_temperature); + read_sync_double(input.xc_temperature); this->add_item(item); } { @@ -120,11 +120,11 @@ void ReadInput::item_general() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.calculation = strvalue; std::string& calculation = para.input.calculation; - para.input.sup.global_calculation = calculation; + para.sys.global_calculation = calculation; if (calculation == "nscf" || calculation == "get_S") { // Maybe it should be modified. - para.input.sup.global_calculation = "nscf"; + para.sys.global_calculation = "nscf"; } }; item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -161,14 +161,13 @@ void ReadInput::item_general() } } }; - sync_string(calculation); - add_string_bcast(sup.global_calculation); + sync_string(input.calculation); this->add_item(item); } { Input_Item item("esolver_type"); item.annotation = "the energy solver: ksdft, sdft, ofdft, tddft, lj, dp"; - read_sync_string(esolver_type); + read_sync_string(input.esolver_type); item.check_value = [](const Input_Item& item, const Parameter& para) { const std::vector esolver_types = { "ksdft", "sdft", "ofdft", "tddft", "lj", "dp", "lr", "ks-lr" }; if (!find_str(esolver_types, para.input.esolver_type)) @@ -191,13 +190,13 @@ void ReadInput::item_general() Input_Item item("ntype"); item.annotation = "atom species number"; // check of ntype is done in check_ntype - read_sync_int(ntype); + read_sync_int(input.ntype); this->add_item(item); } { Input_Item item("nspin"); item.annotation = "1: single spin; 2: up and down spin; 4: noncollinear spin"; - read_sync_int(nspin); + read_sync_int(input.nspin); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.noncolin || para.input.lspinorb) { @@ -233,7 +232,7 @@ void ReadInput::item_general() ModuleBase::WARNING_QUIT("ReadInput", "kspacing can only accept one or three values."); } }; - sync_doublevec(kspacing, 3, 0.0); + sync_doublevec(input.kspacing, 3, 0.0); item.check_value = [](const Input_Item& item, const Parameter& para) { int kspacing_zero_num = 0; const std::vector& kspacing = para.input.kspacing; @@ -260,13 +259,13 @@ void ReadInput::item_general() Input_Item item("min_dist_coef"); item.annotation = "factor related to the allowed minimum distance " "between two atoms"; - read_sync_double(min_dist_coef); + read_sync_double(input.min_dist_coef); this->add_item(item); } { Input_Item item("nbands"); item.annotation = "number of bands"; - read_sync_int(nbands); + read_sync_int(input.nbands); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nbands < 0) { @@ -278,7 +277,7 @@ void ReadInput::item_general() { Input_Item item("nbands_istate"); item.annotation = "number of bands around Fermi level for get_pchg calulation"; - read_sync_int(nbands_istate); + read_sync_int(input.nbands_istate); this->add_item(item); } { @@ -287,13 +286,13 @@ void ReadInput::item_general() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.bands_to_print = longstring(item.str_values, item.get_size()); }; - sync_string(bands_to_print); + sync_string(input.bands_to_print); this->add_item(item); } { Input_Item item("symmetry"); item.annotation = "the control of symmetry"; - read_sync_string(symmetry); + read_sync_string(input.symmetry); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.symmetry == "default") { @@ -335,20 +334,20 @@ void ReadInput::item_general() } } }; - read_sync_bool(init_vel); + read_sync_bool(input.init_vel); this->add_item(item); } { Input_Item item("symmetry_prec"); item.annotation = "accuracy for symmetry"; - read_sync_double(symmetry_prec); + read_sync_double(input.symmetry_prec); this->add_item(item); } { Input_Item item("symmetry_autoclose"); item.annotation = "whether to close symmetry automatically when error " "occurs in symmetry analysis"; - read_sync_bool(symmetry_autoclose); + read_sync_bool(input.symmetry_autoclose); this->add_item(item); } { @@ -364,13 +363,13 @@ void ReadInput::item_general() ModuleBase::WARNING_QUIT("ReadInput", "nelec > 2*nbnd , bands not enough!"); } }; - read_sync_double(nelec); + read_sync_double(input.nelec); this->add_item(item); } { Input_Item item("nelec_delta"); item.annotation = "change in the number of total electrons"; - read_sync_double(nelec_delta); + read_sync_double(input.nelec_delta); this->add_item(item); } { @@ -379,36 +378,35 @@ void ReadInput::item_general() "and spin-down"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.nupdown = doublevalue; - para.input.sup.two_fermi = true; + para.sys.two_fermi = true; }; - sync_double(nupdown); - add_bool_bcast(sup.two_fermi); + sync_double(input.nupdown); this->add_item(item); } { Input_Item item("out_mul"); item.annotation = "mulliken charge or not"; - read_sync_bool(out_mul); + read_sync_bool(input.out_mul); this->add_item(item); } { Input_Item item("noncolin"); item.annotation = "using non-collinear-spin"; - read_sync_bool(noncolin); + read_sync_bool(input.noncolin); this->add_item(item); } { Input_Item item("lspinorb"); item.annotation = "consider the spin-orbit interaction"; - read_sync_bool(lspinorb); + read_sync_bool(input.lspinorb); this->add_item(item); } { Input_Item item("kpar"); item.annotation = "devide all processors into kpar groups and k points " "will be distributed among"; - read_sync_int(kpar); + read_sync_int(input.kpar); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.basis_type == "lcao" && para.input.kpar > 1) { @@ -421,7 +419,7 @@ void ReadInput::item_general() Input_Item item("bndpar"); item.annotation = "devide all processors into bndpar groups and bands " "will be distributed among each group"; - read_sync_int(bndpar); + read_sync_int(input.bndpar); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.esolver_type != "sdft") { @@ -439,13 +437,13 @@ void ReadInput::item_general() item.annotation = "the frequency ( >= 0) of electronic iter to output " "charge density and wavefunction. 0: " "output only when converged"; - read_sync_int(out_freq_elec); + read_sync_int(input.out_freq_elec); this->add_item(item); } { Input_Item item("dft_plus_dmft"); item.annotation = "true:DFT+DMFT; false: standard DFT calcullation(default)"; - read_sync_bool(dft_plus_dmft); + read_sync_bool(input.dft_plus_dmft); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.basis_type != "lcao" && para.input.dft_plus_dmft) { @@ -458,13 +456,13 @@ void ReadInput::item_general() Input_Item item("rpa"); item.annotation = "true:generate output files used in rpa calculation; " "false:(default)"; - read_sync_bool(rpa); + read_sync_bool(input.rpa); this->add_item(item); } { Input_Item item("printe"); item.annotation = "Print out energy for each band for every printe steps"; - read_sync_int(printe); + read_sync_int(input.printe); this->add_item(item); } { @@ -472,7 +470,7 @@ void ReadInput::item_general() item.annotation = "Only for nscf calculations. if set to 1, then a " "memory saving technique will be used for " "many k point calculations."; - read_sync_int(mem_saver); + read_sync_int(input.mem_saver); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.mem_saver == 1) { @@ -488,7 +486,7 @@ void ReadInput::item_general() { Input_Item item("diago_proc"); item.annotation = "the number of procs used to do diagonalization"; - read_sync_int(diago_proc); + read_sync_int(input.diago_proc); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.diago_proc > GlobalV::NPROC || para.input.diago_proc <= 0) { @@ -500,20 +498,20 @@ void ReadInput::item_general() { Input_Item item("nbspline"); item.annotation = "the order of B-spline basis"; - read_sync_int(nbspline); + read_sync_int(input.nbspline); this->add_item(item); } { Input_Item item("wannier_card"); item.annotation = "input card for wannier functions"; - read_sync_string(wannier_card); + read_sync_string(input.wannier_card); this->add_item(item); } { Input_Item item("soc_lambda"); item.annotation = "The fraction of averaged SOC pseudopotential is " "given by (1-soc_lambda)"; - read_sync_double(soc_lambda); + read_sync_double(input.soc_lambda); this->add_item(item); } { @@ -539,7 +537,7 @@ void ReadInput::item_general() para.input.cal_force = false; } }; - read_sync_bool(cal_force); + read_sync_bool(input.cal_force); this->add_item(item); } { @@ -547,25 +545,25 @@ void ReadInput::item_general() item.annotation = "the frequency ( >= 0 ) of ionic step to output " "charge density and wavefunction. 0: output " "only when ion steps are finished"; - read_sync_int(out_freq_ion); + read_sync_int(input.out_freq_ion); this->add_item(item); } { Input_Item item("elpa_num_thread"); item.annotation = "Number of threads need to use in elpa"; - read_sync_int(elpa_num_thread); + read_sync_int(input.elpa_num_thread); this->add_item(item); } { Input_Item item("device"); item.annotation = "the computing device for ABACUS"; - read_sync_string(device); + read_sync_string(input.device); this->add_item(item); } { Input_Item item("precision"); item.annotation = "the computing precision for ABACUS"; - read_sync_string(precision); + read_sync_string(input.precision); this->add_item(item); } } diff --git a/source/module_io/read_input_item_lcao.cpp b/source/module_io/read_input_item_lcao.cpp index 863e8b2ea2..2046234a86 100644 --- a/source/module_io/read_input_item_lcao.cpp +++ b/source/module_io/read_input_item_lcao.cpp @@ -12,7 +12,7 @@ void ReadInput::item_lcao() { Input_Item item("basis_type"); item.annotation = "PW; LCAO in pw; LCAO"; - read_sync_string(basis_type); + read_sync_string(input.basis_type); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.towannier90) { @@ -35,7 +35,7 @@ void ReadInput::item_lcao() Input_Item item("gamma_only"); item.annotation = "Only for localized orbitals set and gamma point. If " "set to 1, a fast algorithm is used"; - read_sync_bool(gamma_only); + read_sync_bool(input.gamma_only); item.reset_value = [](const Input_Item& item, Parameter& para) { Input_para& input = para.input; std::string& basis_type = input.basis_type; @@ -61,38 +61,37 @@ void ReadInput::item_lcao() } else if (basis_type == "lcao" && gamma_only == 1) { - input.sup.gamma_only_local = true; + para.sys.gamma_only_local = true; // std::cout << "gamma_only_local =" << gamma_only_local << // std::endl; if (input.esolver_type == "tddft") { GlobalV::ofs_running << " WARNING : gamma_only is not applicable for tddft" << std::endl; - input.sup.gamma_only_local = false; + para.sys.gamma_only_local = false; } } if ((input.out_mat_r || input.out_mat_hs2 || input.out_mat_t || input.out_mat_dh || input.out_hr_npz || input.out_dm_npz || input.dm_to_rho) - && input.sup.gamma_only_local) + && para.sys.gamma_only_local) { ModuleBase::WARNING_QUIT("ReadInput", "output of r(R)/H(R)/S(R)/T(R)/dH(R)/DM(R) is not " "available for gamma only calculations"); } }; - add_bool_bcast(sup.gamma_only_local); this->add_item(item); } { Input_Item item("search_radius"); item.annotation = "input search radius (Bohr)"; - read_sync_double(search_radius); + read_sync_double(input.search_radius); this->add_item(item); } { Input_Item item("search_pbc"); item.annotation = "input periodic boundary condition"; - read_sync_bool(search_pbc); + read_sync_bool(input.search_pbc); this->add_item(item); } { @@ -105,25 +104,25 @@ void ReadInput::item_lcao() ModuleBase::GlobalFunc::AUTO_SET("lcao_ecut", para.input.ecutwfc); } }; - read_sync_double(lcao_ecut); + read_sync_double(input.lcao_ecut); this->add_item(item); } { Input_Item item("lcao_dk"); item.annotation = "delta k for 1D integration in LCAO"; - read_sync_double(lcao_dk); + read_sync_double(input.lcao_dk); this->add_item(item); } { Input_Item item("lcao_dr"); item.annotation = "delta r for 1D integration in LCAO"; - read_sync_double(lcao_dr); + read_sync_double(input.lcao_dr); this->add_item(item); } { Input_Item item("lcao_rmax"); item.annotation = "max R for 1D two-center integration table"; - read_sync_double(lcao_rmax); + read_sync_double(input.lcao_rmax); this->add_item(item); } { @@ -152,19 +151,19 @@ void ReadInput::item_lcao() para.input.out_mat_hs[0] = 1; // print H(k) and S(k) } }; - sync_intvec(out_mat_hs, 2, 0); + sync_intvec(input.out_mat_hs, 2, 0); this->add_item(item); } { Input_Item item("out_mat_hs2"); item.annotation = "output H(R) and S(R) matrix"; - read_sync_bool(out_mat_hs2); + read_sync_bool(input.out_mat_hs2); this->add_item(item); } { Input_Item item("out_mat_dh"); item.annotation = "output of derivative of H(R) matrix"; - read_sync_bool(out_mat_dh); + read_sync_bool(input.out_mat_dh); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.out_mat_dh && para.input.nspin == 4) { @@ -176,13 +175,13 @@ void ReadInput::item_lcao() { Input_Item item("out_mat_xc"); item.annotation = "output exchange-correlation matrix in KS-orbital representation"; - read_sync_bool(out_mat_xc); + read_sync_bool(input.out_mat_xc); this->add_item(item); } { Input_Item item("out_hr_npz"); item.annotation = "output hr(I0,JR) submatrices in npz format"; - read_sync_bool(out_hr_npz); + read_sync_bool(input.out_hr_npz); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.out_hr_npz) { @@ -198,7 +197,7 @@ void ReadInput::item_lcao() { Input_Item item("out_dm_npz"); item.annotation = "output dmr(I0,JR) submatrices in npz format"; - read_sync_bool(out_dm_npz); + read_sync_bool(input.out_dm_npz); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.out_dm_npz) { @@ -214,7 +213,7 @@ void ReadInput::item_lcao() { Input_Item item("dm_to_rho"); item.annotation = "reads dmr in npz format and calculates electron density"; - read_sync_bool(dm_to_rho); + read_sync_bool(input.dm_to_rho); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.dm_to_rho && GlobalV::NPROC > 1) { @@ -234,44 +233,44 @@ void ReadInput::item_lcao() { Input_Item item("out_interval"); item.annotation = "interval for printing H(R) and S(R) matrix during MD"; - read_sync_int(out_interval); + read_sync_int(input.out_interval); this->add_item(item); } { Input_Item item("out_app_flag"); item.annotation = "whether output r(R), H(R), S(R), T(R), and dH(R) " "matrices in an append manner during MD"; - read_sync_bool(out_app_flag); + read_sync_bool(input.out_app_flag); this->add_item(item); } { Input_Item item("out_ndigits"); item.annotation = "the length of decimal part of output data"; - read_sync_int(out_ndigits); + read_sync_int(input.out_ndigits); this->add_item(item); } { Input_Item item("out_mat_t"); item.annotation = "output T(R) matrix"; - read_sync_bool(out_mat_t); + read_sync_bool(input.out_mat_t); this->add_item(item); } { Input_Item item("out_element_info"); item.annotation = "output (projected) wavefunction of each element"; - read_sync_bool(out_element_info); + read_sync_bool(input.out_element_info); this->add_item(item); } { Input_Item item("out_mat_r"); item.annotation = "output r(R) matrix"; - read_sync_bool(out_mat_r); + read_sync_bool(input.out_mat_r); this->add_item(item); } { Input_Item item("out_wfc_lcao"); item.annotation = "ouput LCAO wave functions, 0, no output 1: text, 2: binary"; - read_sync_int(out_wfc_lcao); + read_sync_int(input.out_wfc_lcao); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.qo_switch) { @@ -293,7 +292,7 @@ void ReadInput::item_lcao() { Input_Item item("bx"); item.annotation = "division of an element grid in FFT grid along x"; - read_sync_int(bx); + read_sync_int(input.bx); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.bx > 10) { @@ -314,7 +313,7 @@ void ReadInput::item_lcao() { Input_Item item("by"); item.annotation = "division of an element grid in FFT grid along y"; - read_sync_int(by); + read_sync_int(input.by); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.by > 10) { @@ -326,7 +325,7 @@ void ReadInput::item_lcao() { Input_Item item("bz"); item.annotation = "division of an element grid in FFT grid along z"; - read_sync_int(bz); + read_sync_int(input.bz); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.bz > 10) { @@ -338,13 +337,13 @@ void ReadInput::item_lcao() { Input_Item item("num_stream"); item.annotation = "the nstream in compute the LCAO with CUDA"; - read_sync_int(nstream); + read_sync_int(input.nstream); this->add_item(item); } { Input_Item item("elpa_num_thread"); item.annotation = "Number of threads need to use in elpa"; - read_sync_int(elpa_num_thread); + read_sync_int(input.elpa_num_thread); this->add_item(item); } } diff --git a/source/module_io/read_input_item_md.cpp b/source/module_io/read_input_item_md.cpp index 21759a6f09..48a311c952 100644 --- a/source/module_io/read_input_item_md.cpp +++ b/source/module_io/read_input_item_md.cpp @@ -10,13 +10,13 @@ void ReadInput::item_md() { Input_Item item("md_type"); item.annotation = "choose ensemble"; - read_sync_string(mdp.md_type); + read_sync_string(input.mdp.md_type); this->add_item(item); } { Input_Item item("md_thermostat"); item.annotation = "choose thermostat"; - read_sync_string(mdp.md_thermostat); + read_sync_string(input.mdp.md_thermostat); this->add_item(item); } { @@ -29,7 +29,7 @@ void ReadInput::item_md() para.input.mdp.md_nstep = 50; } }; - read_sync_int(mdp.md_nstep); + read_sync_int(input.mdp.md_nstep); this->add_item(item); } { @@ -40,43 +40,43 @@ void ReadInput::item_md() ModuleBase::WARNING_QUIT("ReadInput", "time interval of MD calculation should be positive"); } }; - read_sync_double(mdp.md_dt); + read_sync_double(input.mdp.md_dt); this->add_item(item); } { Input_Item item("md_tchain"); item.annotation = "number of Nose-Hoover chains"; - read_sync_int(mdp.md_tchain); + read_sync_int(input.mdp.md_tchain); this->add_item(item); } { Input_Item item("md_tfirst"); item.annotation = "temperature first"; - read_sync_double(mdp.md_tfirst); + read_sync_double(input.mdp.md_tfirst); this->add_item(item); } { Input_Item item("md_tlast"); item.annotation = "temperature last"; - read_sync_double(mdp.md_tlast); + read_sync_double(input.mdp.md_tlast); this->add_item(item); } { Input_Item item("md_dumpfreq"); item.annotation = "The period to dump MD information"; - read_sync_int(mdp.md_dumpfreq); + read_sync_int(input.mdp.md_dumpfreq); this->add_item(item); } { Input_Item item("md_restartfreq"); item.annotation = "The period to output MD restart information"; - read_sync_int(mdp.md_restartfreq); + read_sync_int(input.mdp.md_restartfreq); this->add_item(item); } { Input_Item item("md_seed"); item.annotation = "random seed for MD"; - read_sync_int(mdp.md_seed); + read_sync_int(input.mdp.md_seed); this->add_item(item); } { @@ -93,19 +93,19 @@ void ReadInput::item_md() para.input.mdp.md_prec_level = 0; } }; - read_sync_int(mdp.md_prec_level); + read_sync_int(input.mdp.md_prec_level); this->add_item(item); } { Input_Item item("ref_cell_factor"); item.annotation = "construct a reference cell bigger than the initial cell"; - read_sync_double(ref_cell_factor); + read_sync_double(input.ref_cell_factor); this->add_item(item); } { Input_Item item("md_restart"); item.annotation = "whether restart"; - read_sync_bool(mdp.md_restart); + read_sync_bool(input.mdp.md_restart); this->add_item(item); } { @@ -117,13 +117,13 @@ void ReadInput::item_md() ModuleBase::WARNING_QUIT("ReadInput", "lj_rule must be 1 or 2"); } }; - read_sync_int(mdp.lj_rule); + read_sync_int(input.mdp.lj_rule); this->add_item(item); } { Input_Item item("lj_eshift"); item.annotation = "whether to use energy shift for LJ potential"; - read_sync_bool(mdp.lj_eshift); + read_sync_bool(input.mdp.lj_eshift); this->add_item(item); } { @@ -136,11 +136,12 @@ void ReadInput::item_md() end(item.str_values), begin(para.input.mdp.lj_rcut), [](std::string str) { return std::stod(str); }); - para.input.sup.n_ljcut = count; }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.esolver_type == "lj" && para.input.sup.n_ljcut != 1 - && para.input.sup.n_ljcut != para.input.ntype * (para.input.ntype + 1) / 2) + if (!item.is_read()) + return; + size_t n_ljrcut = para.input.mdp.lj_rcut.size(); + if (n_ljrcut != 1 && n_ljrcut != para.input.ntype * (para.input.ntype + 1) / 2) { ModuleBase::WARNING_QUIT("ReadInput", " the number of lj_rcut should be 1 or ntype(ntype+1)/2 "); } @@ -152,9 +153,7 @@ void ReadInput::item_md() } } }; - add_int_bcast(sup.n_ljcut); - // We must firt bcast n_ljcut, then bcast mdp.lj_rcut - sync_doublevec(mdp.lj_rcut, para.input.sup.n_ljcut, 0.0); + sync_doublevec(input.mdp.lj_rcut, para.input.mdp.lj_rcut.size(), 0.0); this->add_item(item); } { @@ -167,18 +166,17 @@ void ReadInput::item_md() end(item.str_values), begin(para.input.mdp.lj_epsilon), [](std::string str) { return std::stod(str); }); - para.input.sup.n_ljepsilon = count; }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.esolver_type == "lj" && para.input.sup.n_ljepsilon != para.input.ntype - && para.input.sup.n_ljepsilon != para.input.ntype * (para.input.ntype + 1) / 2) + if (!item.is_read()) + return; + size_t n_ljepsilon = para.input.mdp.lj_epsilon.size(); + if (n_ljepsilon != para.input.ntype && n_ljepsilon != para.input.ntype * (para.input.ntype + 1) / 2) { ModuleBase::WARNING_QUIT("ReadInput", " the number of lj_epsilon should be ntype or ntype(ntype+1)/2 "); } }; - add_int_bcast(sup.n_ljepsilon); - // We must firt bcast n_ljepsilon, then bcast mdp.lj_epsilon - sync_doublevec(mdp.lj_epsilon, para.input.sup.n_ljepsilon, 0.0); + sync_doublevec(input.mdp.lj_epsilon, para.input.mdp.lj_epsilon.size(), 0.0); this->add_item(item); } { @@ -191,48 +189,47 @@ void ReadInput::item_md() end(item.str_values), begin(para.input.mdp.lj_sigma), [](std::string str) { return std::stod(str); }); - para.input.sup.n_ljsigma = count; }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.esolver_type == "lj" && para.input.sup.n_ljsigma != para.input.ntype - && para.input.sup.n_ljsigma != para.input.ntype * (para.input.ntype + 1) / 2) + if (!item.is_read()) + return; + size_t n_ljsigma = para.input.mdp.lj_sigma.size(); + if (n_ljsigma != para.input.ntype && n_ljsigma != para.input.ntype * (para.input.ntype + 1) / 2) { ModuleBase::WARNING_QUIT("ReadInput", " the number of lj_sigma should be ntype or ntype(ntype+1)/2 "); } }; - add_int_bcast(sup.n_ljsigma); - // We must firt bcast n_ljcut, then bcast mdp.lj_rcut - sync_doublevec(mdp.lj_sigma, para.input.sup.n_ljsigma, 0.0); + sync_doublevec(input.mdp.lj_sigma, para.input.mdp.lj_sigma.size(), 0.0); this->add_item(item); } { Input_Item item("pot_file"); item.annotation = "the filename of potential files for CMD such as DP"; - read_sync_string(mdp.pot_file); + read_sync_string(input.mdp.pot_file); this->add_item(item); } { Input_Item item("msst_direction"); item.annotation = "the direction of shock wave"; - read_sync_int(mdp.msst_direction); + read_sync_int(input.mdp.msst_direction); this->add_item(item); } { Input_Item item("msst_vel"); item.annotation = "the velocity of shock wave"; - read_sync_double(mdp.msst_vel); + read_sync_double(input.mdp.msst_vel); this->add_item(item); } { Input_Item item("msst_vis"); item.annotation = "artificial viscosity"; - read_sync_double(mdp.msst_vis); + read_sync_double(input.mdp.msst_vis); this->add_item(item); } { Input_Item item("msst_tscale"); item.annotation = "reduction in initial temperature"; - read_sync_double(mdp.msst_tscale); + read_sync_double(input.mdp.msst_tscale); this->add_item(item); } { @@ -244,7 +241,7 @@ void ReadInput::item_md() ModuleBase::WARNING_QUIT("ReadInput", "msst_qmass must be greater than 0!"); } }; - read_sync_double(mdp.msst_qmass); + read_sync_double(input.mdp.msst_qmass); this->add_item(item); } { @@ -256,62 +253,62 @@ void ReadInput::item_md() para.input.mdp.md_tfreq = 1.0 / 40 / para.input.mdp.md_dt; } }; - read_sync_double(mdp.md_tfreq); + read_sync_double(input.mdp.md_tfreq); this->add_item(item); } { Input_Item item("md_damp"); item.annotation = "damping parameter (time units) used to add force in " "Langevin method"; - read_sync_double(mdp.md_damp); + read_sync_double(input.mdp.md_damp); this->add_item(item); } { Input_Item item("md_nraise"); item.annotation = "parameters used when md_type=nvt"; - read_sync_int(mdp.md_nraise); + read_sync_int(input.mdp.md_nraise); this->add_item(item); } { Input_Item item("cal_syns"); item.annotation = "calculate asynchronous overlap matrix to output for Hefei-NAMD"; - read_sync_bool(cal_syns); + read_sync_bool(input.cal_syns); this->add_item(item); } { Input_Item item("dmax"); item.annotation = "maximum displacement of all atoms in one step (bohr)"; - read_sync_double(dmax); + read_sync_double(input.dmax); this->add_item(item); } { Input_Item item("md_tolerance"); item.annotation = "tolerance for velocity rescaling (K)"; - read_sync_double(mdp.md_tolerance); + read_sync_double(input.mdp.md_tolerance); this->add_item(item); } { Input_Item item("md_pmode"); item.annotation = "NPT ensemble mode: iso, aniso, tri"; - read_sync_string(mdp.md_pmode); + read_sync_string(input.mdp.md_pmode); this->add_item(item); } { Input_Item item("md_pcouple"); item.annotation = "whether couple different components: xyz, xy, yz, xz, none"; - read_sync_string(mdp.md_pcouple); + read_sync_string(input.mdp.md_pcouple); this->add_item(item); } { Input_Item item("md_pchain"); item.annotation = "num of thermostats coupled with barostat"; - read_sync_int(mdp.md_pchain); + read_sync_int(input.mdp.md_pchain); this->add_item(item); } { Input_Item item("md_pfirst"); item.annotation = "initial target pressure"; - read_sync_double(mdp.md_pfirst); + read_sync_double(input.mdp.md_pfirst); this->add_item(item); } { @@ -322,7 +319,7 @@ void ReadInput::item_md() para.input.mdp.md_plast = para.input.mdp.md_pfirst; } }; - read_sync_double(mdp.md_plast); + read_sync_double(input.mdp.md_plast); this->add_item(item); } { @@ -335,25 +332,25 @@ void ReadInput::item_md() para.input.mdp.md_pfreq = 1.0 / 400 / para.input.mdp.md_dt; } }; - read_sync_double(mdp.md_pfreq); + read_sync_double(input.mdp.md_pfreq); this->add_item(item); } { Input_Item item("dump_force"); item.annotation = "output atomic forces into the file MD_dump or not"; - read_sync_bool(mdp.dump_force); + read_sync_bool(input.mdp.dump_force); this->add_item(item); } { Input_Item item("dump_vel"); item.annotation = "output atomic velocities into the file MD_dump or not"; - read_sync_bool(mdp.dump_vel); + read_sync_bool(input.mdp.dump_vel); this->add_item(item); } { Input_Item item("dump_virial"); item.annotation = "output lattice virial into the file MD_dump or not"; - read_sync_bool(mdp.dump_virial); + read_sync_bool(input.mdp.dump_virial); this->add_item(item); } } diff --git a/source/module_io/read_input_item_other.cpp b/source/module_io/read_input_item_other.cpp index feb70e569f..43b48f8ef6 100644 --- a/source/module_io/read_input_item_other.cpp +++ b/source/module_io/read_input_item_other.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -16,7 +16,7 @@ void ReadInput::item_others() { Input_Item item("efield_flag"); item.annotation = "add electric field"; - read_sync_bool(efield_flag); + read_sync_bool(input.efield_flag); this->add_item(item); } { @@ -28,7 +28,7 @@ void ReadInput::item_others() ModuleBase::WARNING_QUIT("ReadInput", "dipole correction is not active if efield_flag=false !"); } }; - read_sync_bool(dip_cor_flag); + read_sync_bool(input.dip_cor_flag); this->add_item(item); } { @@ -42,26 +42,26 @@ void ReadInput::item_others() "efield if dip_cor_flag=false !"); } }; - read_sync_int(efield_dir); + read_sync_int(input.efield_dir); this->add_item(item); } { Input_Item item("efield_pos_max"); item.annotation = "position of the maximum of the saw-like potential " "along crystal axis efield_dir"; - read_sync_double(efield_pos_max); + read_sync_double(input.efield_pos_max); this->add_item(item); } { Input_Item item("efield_pos_dec"); item.annotation = "zone in the unit cell where the saw-like potential decreases"; - read_sync_double(efield_pos_dec); + read_sync_double(input.efield_pos_dec); this->add_item(item); } { Input_Item item("efield_amp"); item.annotation = "amplitude of the electric field"; - read_sync_double(efield_amp); + read_sync_double(input.efield_amp); this->add_item(item); } @@ -69,43 +69,43 @@ void ReadInput::item_others() { Input_Item item("gate_flag"); item.annotation = "compensating charge or not"; - read_sync_bool(gate_flag); + read_sync_bool(input.gate_flag); this->add_item(item); } { Input_Item item("zgate"); item.annotation = "position of charged plate"; - read_sync_double(zgate); + read_sync_double(input.zgate); this->add_item(item); } { Input_Item item("relax"); item.annotation = "allow relaxation along the specific direction"; - read_sync_bool(relax); + read_sync_bool(input.relax); this->add_item(item); } { Input_Item item("block"); item.annotation = "add a block potential or not"; - read_sync_bool(block); + read_sync_bool(input.block); this->add_item(item); } { Input_Item item("block_down"); item.annotation = "low bound of the block"; - read_sync_double(block_down); + read_sync_double(input.block_down); this->add_item(item); } { Input_Item item("block_up"); item.annotation = "high bound of the block"; - read_sync_double(block_up); + read_sync_double(input.block_up); this->add_item(item); } { Input_Item item("block_height"); item.annotation = "height of the block"; - read_sync_double(block_height); + read_sync_double(input.block_height); this->add_item(item); } @@ -113,67 +113,67 @@ void ReadInput::item_others() { Input_Item item("out_alllog"); item.annotation = "output information for each processor, when parallel"; - read_sync_bool(out_alllog); + read_sync_bool(input.out_alllog); this->add_item(item); } { Input_Item item("nurse"); item.annotation = "for coders"; - read_sync_int(nurse); + read_sync_int(input.nurse); this->add_item(item); } { Input_Item item("colour"); item.annotation = "for coders, make their live colourful"; - read_sync_bool(colour); + read_sync_bool(input.colour); this->add_item(item); } { Input_Item item("t_in_h"); item.annotation = "calculate the kinetic energy or not"; - read_sync_bool(t_in_h); + read_sync_bool(input.t_in_h); this->add_item(item); } { Input_Item item("vl_in_h"); item.annotation = "calculate the local potential or not"; - read_sync_bool(vl_in_h); + read_sync_bool(input.vl_in_h); this->add_item(item); } { Input_Item item("vnl_in_h"); item.annotation = "calculate the nonlocal potential or not"; - read_sync_bool(vnl_in_h); + read_sync_bool(input.vnl_in_h); this->add_item(item); } { Input_Item item("vh_in_h"); item.annotation = "calculate the hartree potential or not"; - read_sync_bool(vh_in_h); + read_sync_bool(input.vh_in_h); this->add_item(item); } { Input_Item item("vion_in_h"); item.annotation = "calculate the local ionic potential or not"; - read_sync_bool(vion_in_h); + read_sync_bool(input.vion_in_h); this->add_item(item); } { Input_Item item("test_force"); item.annotation = "test the force"; - read_sync_bool(test_force); + read_sync_bool(input.test_force); this->add_item(item); } { Input_Item item("test_stress"); item.annotation = "test the stress"; - read_sync_bool(test_stress); + read_sync_bool(input.test_stress); this->add_item(item); } { Input_Item item("test_skip_ewald"); item.annotation = "whether to skip ewald"; - read_sync_bool(test_skip_ewald); + read_sync_bool(input.test_skip_ewald); this->add_item(item); } @@ -181,7 +181,7 @@ void ReadInput::item_others() { Input_Item item("vdw_method"); item.annotation = "the method of calculating vdw (none ; d2 ; d3_0 ; d3_bj"; - read_sync_string(vdw_method); + read_sync_string(input.vdw_method); this->add_item(item); } { @@ -200,7 +200,7 @@ void ReadInput::item_others() } } }; - read_sync_string(vdw_s6); + read_sync_string(input.vdw_s6); this->add_item(item); } { @@ -219,7 +219,7 @@ void ReadInput::item_others() } } }; - read_sync_string(vdw_s8); + read_sync_string(input.vdw_s8); this->add_item(item); } { @@ -238,7 +238,7 @@ void ReadInput::item_others() } } }; - read_sync_string(vdw_a1); + read_sync_string(input.vdw_a1); this->add_item(item); } { @@ -257,31 +257,31 @@ void ReadInput::item_others() } } }; - read_sync_string(vdw_a2); + read_sync_string(input.vdw_a2); this->add_item(item); } { Input_Item item("vdw_d"); item.annotation = "damping parameter of d2"; - read_sync_double(vdw_d); + read_sync_double(input.vdw_d); this->add_item(item); } { Input_Item item("vdw_abc"); item.annotation = "third-order term?"; - read_sync_bool(vdw_abc); + read_sync_bool(input.vdw_abc); this->add_item(item); } { Input_Item item("vdw_c6_file"); item.annotation = "filename of C6"; - read_sync_string(vdw_C6_file); + read_sync_string(input.vdw_C6_file); this->add_item(item); } { Input_Item item("vdw_c6_unit"); item.annotation = "unit of C6, Jnm6/mol or eVA6"; - read_sync_string(vdw_C6_unit); + read_sync_string(input.vdw_C6_unit); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.vdw_C6_unit != "Jnm6/mol") && (para.input.vdw_C6_unit != "eVA6")) { @@ -293,13 +293,13 @@ void ReadInput::item_others() { Input_Item item("vdw_r0_file"); item.annotation = "filename of R0"; - read_sync_string(vdw_R0_file); + read_sync_string(input.vdw_R0_file); this->add_item(item); } { Input_Item item("vdw_r0_unit"); item.annotation = "unit of R0, A or Bohr"; - read_sync_string(vdw_R0_unit); + read_sync_string(input.vdw_R0_unit); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.vdw_R0_unit != "A") && (para.input.vdw_R0_unit != "Bohr")) { @@ -317,7 +317,7 @@ void ReadInput::item_others() ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_type must be radius or period"); } }; - read_sync_string(vdw_cutoff_type); + read_sync_string(input.vdw_cutoff_type); this->add_item(item); } { @@ -346,13 +346,13 @@ void ReadInput::item_others() ModuleBase::WARNING_QUIT("ReadInput", "vdw_cutoff_radius <= 0 is not allowd"); } }; - read_sync_string(vdw_cutoff_radius); + read_sync_string(input.vdw_cutoff_radius); this->add_item(item); } { Input_Item item("vdw_radius_unit"); item.annotation = "unit of radius cutoff for periodic structure"; - read_sync_string(vdw_radius_unit); + read_sync_string(input.vdw_radius_unit); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.vdw_radius_unit != "A") && (para.input.vdw_radius_unit != "Bohr")) { @@ -364,7 +364,7 @@ void ReadInput::item_others() { Input_Item item("vdw_cn_thr"); item.annotation = "radius cutoff for cn"; - read_sync_double(vdw_cn_thr); + read_sync_double(input.vdw_cn_thr); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.vdw_cn_thr <= 0) { @@ -376,7 +376,7 @@ void ReadInput::item_others() { Input_Item item("vdw_cn_thr_unit"); item.annotation = "unit of cn_thr, Bohr or Angstrom"; - read_sync_string(vdw_cn_thr_unit); + read_sync_string(input.vdw_cn_thr_unit); item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.input.vdw_cn_thr_unit != "A") && (para.input.vdw_cn_thr_unit != "Bohr")) { @@ -423,21 +423,22 @@ void ReadInput::item_others() { Input_Item item("exx_hybrid_alpha"); item.annotation = "fraction of Fock exchange in hybrid functionals"; - read_sync_string(exx_hybrid_alpha); + read_sync_string(input.exx_hybrid_alpha); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.exx_hybrid_alpha == "default") { std::string& dft_functional = para.input.dft_functional; std::string dft_functional_lower = dft_functional; std::transform(dft_functional.begin(), dft_functional.end(), dft_functional_lower.begin(), tolower); - if (dft_functional_lower == "hf") + if (dft_functional_lower == "hf") { para.input.exx_hybrid_alpha = "1"; - else if (dft_functional_lower == "pbe0" || dft_functional_lower == "hse" - || dft_functional_lower == "scan0") + } else if (dft_functional_lower == "pbe0" || dft_functional_lower == "hse" + || dft_functional_lower == "scan0") { para.input.exx_hybrid_alpha = "0.25"; - else // no exx in scf, but will change to non-zero in + } else { // no exx in scf, but will change to non-zero in // postprocess like rpa para.input.exx_hybrid_alpha = "0"; +} } }; item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -452,21 +453,21 @@ void ReadInput::item_others() { Input_Item item("exx_hse_omega"); item.annotation = "range-separation parameter in HSE functional"; - read_sync_double(exx_hse_omega); + read_sync_double(input.exx_hse_omega); this->add_item(item); } { Input_Item item("exx_separate_loop"); item.annotation = "if 1, a two-step method is employed, else it will " "start with a GGA-Loop, and then Hybrid-Loop"; - read_sync_bool(exx_separate_loop); + read_sync_bool(input.exx_separate_loop); this->add_item(item); } { Input_Item item("exx_hybrid_step"); item.annotation = "the maximal electronic iteration number in the " "evaluation of Fock exchange"; - read_sync_int(exx_hybrid_step); + read_sync_int(input.exx_hybrid_step); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_hybrid_step <= 0) { @@ -478,7 +479,7 @@ void ReadInput::item_others() { Input_Item item("exx_mixing_beta"); item.annotation = "mixing_beta for outer-loop when exx_separate_loop=1"; - read_sync_double(exx_mixing_beta); + read_sync_double(input.exx_mixing_beta); this->add_item(item); } { @@ -486,20 +487,21 @@ void ReadInput::item_others() item.annotation = "used to compensate for divergence points at G=0 in " "the evaluation of Fock exchange using " "lcao_in_pw method"; - read_sync_double(exx_lambda); + read_sync_double(input.exx_lambda); this->add_item(item); } { Input_Item item("exx_real_number"); item.annotation = "exx calculated in real or complex"; - read_sync_string(exx_real_number); + read_sync_string(input.exx_real_number); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.exx_real_number == "default") { - if (para.input.gamma_only) + if (para.input.gamma_only) { para.input.exx_real_number = "1"; - else + } else { para.input.exx_real_number = "0"; +} } }; this->add_item(item); @@ -507,61 +509,61 @@ void ReadInput::item_others() { Input_Item item("exx_pca_threshold"); item.annotation = "threshold to screen on-site ABFs in exx"; - read_sync_double(exx_pca_threshold); + read_sync_double(input.exx_pca_threshold); this->add_item(item); } { Input_Item item("exx_c_threshold"); item.annotation = "threshold to screen C matrix in exx"; - read_sync_double(exx_c_threshold); + read_sync_double(input.exx_c_threshold); this->add_item(item); } { Input_Item item("exx_v_threshold"); item.annotation = "threshold to screen C matrix in exx"; - read_sync_double(exx_v_threshold); + read_sync_double(input.exx_v_threshold); this->add_item(item); } { Input_Item item("exx_dm_threshold"); item.annotation = "threshold to screen density matrix in exx"; - read_sync_double(exx_dm_threshold); + read_sync_double(input.exx_dm_threshold); this->add_item(item); } { Input_Item item("exx_schwarz_threshold"); item.annotation = "threshold to screen exx using Cauchy-Schwartz inequality"; - read_sync_double(exx_schwarz_threshold); + read_sync_double(input.exx_schwarz_threshold); this->add_item(item); } { Input_Item item("exx_cauchy_threshold"); item.annotation = "threshold to screen exx using Cauchy-Schwartz inequality"; - read_sync_double(exx_cauchy_threshold); + read_sync_double(input.exx_cauchy_threshold); this->add_item(item); } { Input_Item item("exx_c_grad_threshold"); item.annotation = "threshold to screen nabla C matrix in exx"; - read_sync_double(exx_c_grad_threshold); + read_sync_double(input.exx_c_grad_threshold); this->add_item(item); } { Input_Item item("exx_v_grad_threshold"); item.annotation = "threshold to screen nabla V matrix in exx"; - read_sync_double(exx_v_grad_threshold); + read_sync_double(input.exx_v_grad_threshold); this->add_item(item); } { Input_Item item("exx_cauchy_force_threshold"); item.annotation = "threshold to screen exx force using Cauchy-Schwartz inequality"; - read_sync_double(exx_cauchy_force_threshold); + read_sync_double(input.exx_cauchy_force_threshold); this->add_item(item); } { Input_Item item("exx_cauchy_stress_threshold"); item.annotation = "threshold to screen exx stress using Cauchy-Schwartz inequality"; - read_sync_double(exx_cauchy_stress_threshold); + read_sync_double(input.exx_cauchy_stress_threshold); this->add_item(item); } { @@ -569,19 +571,20 @@ void ReadInput::item_others() item.annotation = "how many times larger the radial mesh required for " "calculating Columb potential is to that " "of atomic orbitals"; - read_sync_string(exx_ccp_rmesh_times); + read_sync_string(input.exx_ccp_rmesh_times); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.exx_ccp_rmesh_times == "default") { std::string& dft_functional = para.input.dft_functional; std::string dft_functional_lower = dft_functional; std::transform(dft_functional.begin(), dft_functional.end(), dft_functional_lower.begin(), tolower); - if (dft_functional_lower == "hf" || dft_functional_lower == "pbe0" || dft_functional_lower == "scan0") + if (dft_functional_lower == "hf" || dft_functional_lower == "pbe0" || dft_functional_lower == "scan0") { para.input.exx_ccp_rmesh_times = "5"; - else if (dft_functional_lower == "hse") + } else if (dft_functional_lower == "hse") { para.input.exx_ccp_rmesh_times = "1.5"; - else // no exx in scf + } else { // no exx in scf para.input.exx_ccp_rmesh_times = "1"; +} } }; item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -595,7 +598,7 @@ void ReadInput::item_others() { Input_Item item("exx_distribute_type"); item.annotation = "exx_distribute_type"; - read_sync_string(exx_distribute_type); + read_sync_string(input.exx_distribute_type); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_distribute_type != "htime" && para.input.exx_distribute_type != "kmeans2" && para.input.exx_distribute_type != "kmeans1" && para.input.exx_distribute_type != "order") @@ -610,7 +613,7 @@ void ReadInput::item_others() { Input_Item item("exx_opt_orb_lmax"); item.annotation = "the maximum l of the spherical Bessel functions for opt ABFs"; - read_sync_int(exx_opt_orb_lmax); + read_sync_int(input.exx_opt_orb_lmax); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_opt_orb_lmax < 0) { @@ -622,7 +625,7 @@ void ReadInput::item_others() { Input_Item item("exx_opt_orb_ecut"); item.annotation = "the cut-off of plane wave expansion for opt ABFs"; - read_sync_double(exx_opt_orb_ecut); + read_sync_double(input.exx_opt_orb_ecut); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_opt_orb_ecut < 0) { @@ -635,7 +638,7 @@ void ReadInput::item_others() Input_Item item("exx_opt_orb_tolerence"); item.annotation = "the threshold when solving for the zeros of " "spherical Bessel functions for opt ABFs"; - read_sync_double(exx_opt_orb_tolerence); + read_sync_double(input.exx_opt_orb_tolerence); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.exx_opt_orb_tolerence < 0) { @@ -649,7 +652,7 @@ void ReadInput::item_others() item.annotation = "how many times larger the radial mesh required for " "calculating Columb potential is to that " "of atomic orbitals"; - read_sync_double(rpa_ccp_rmesh_times); + read_sync_double(input.rpa_ccp_rmesh_times); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.rpa_ccp_rmesh_times < 1) { @@ -663,13 +666,13 @@ void ReadInput::item_others() { Input_Item item("td_force_dt"); item.annotation = "time of force change"; - read_sync_double(td_force_dt); + read_sync_double(input.td_force_dt); this->add_item(item); } { Input_Item item("td_vext"); item.annotation = "add extern potential or not"; - read_sync_bool(td_vext); + read_sync_bool(input.td_vext); this->add_item(item); } { @@ -678,67 +681,67 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_vext_dire = longstring(item.str_values, item.get_size()); }; - sync_string(td_vext_dire); + sync_string(input.td_vext_dire); this->add_item(item); } { Input_Item item("out_dipole"); item.annotation = "output dipole or not"; - read_sync_bool(out_dipole); + read_sync_bool(input.out_dipole); this->add_item(item); } { Input_Item item("out_efield"); item.annotation = "output dipole or not"; - read_sync_bool(out_efield); + read_sync_bool(input.out_efield); this->add_item(item); } { Input_Item item("out_current"); item.annotation = "output current or not"; - read_sync_bool(out_current); + read_sync_bool(input.out_current); this->add_item(item); } { Input_Item item("out_current_k"); item.annotation = "output current for each k"; - read_sync_bool(out_current_k); + read_sync_bool(input.out_current_k); this->add_item(item); } { Input_Item item("out_vecpot"); item.annotation = "output TDDFT vector potential or not"; - read_sync_bool(out_vecpot); + read_sync_bool(input.out_vecpot); this->add_item(item); } { Input_Item item("init_vecpot_file"); item.annotation = "init vector potential through file or not"; - read_sync_bool(init_vecpot_file); + read_sync_bool(input.init_vecpot_file); this->add_item(item); } { Input_Item item("td_print_eij"); item.annotation = "print eij or not"; - read_sync_double(td_print_eij); + read_sync_double(input.td_print_eij); this->add_item(item); } { Input_Item item("td_edm"); item.annotation = "the method to calculate the energy density matrix"; - read_sync_int(td_edm); + read_sync_int(input.td_edm); this->add_item(item); } { Input_Item item("td_propagator"); item.annotation = "method of propagator"; - read_sync_int(propagator); + read_sync_int(input.propagator); this->add_item(item); } { Input_Item item("td_stype"); item.annotation = "type of electric field in space domain"; - read_sync_int(td_stype); + read_sync_int(input.td_stype); this->add_item(item); } { @@ -747,31 +750,31 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_ttype = longstring(item.str_values, item.get_size()); }; - sync_string(td_ttype); + sync_string(input.td_ttype); this->add_item(item); } { Input_Item item("td_tstart"); item.annotation = " number of steps where electric field starts"; - read_sync_int(td_tstart); + read_sync_int(input.td_tstart); this->add_item(item); } { Input_Item item("td_tend"); item.annotation = "number of steps where electric field ends"; - read_sync_int(td_tend); + read_sync_int(input.td_tend); this->add_item(item); } { Input_Item item("td_lcut1"); item.annotation = "cut1 of interval in length gauge"; - read_sync_double(td_lcut1); + read_sync_double(input.td_lcut1); this->add_item(item); } { Input_Item item("td_lcut2"); item.annotation = "cut2 of interval in length gauge"; - read_sync_double(td_lcut2); + read_sync_double(input.td_lcut2); this->add_item(item); } { @@ -780,7 +783,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_gauss_freq = longstring(item.str_values, item.get_size()); }; - sync_string(td_gauss_freq); + sync_string(input.td_gauss_freq); this->add_item(item); } { @@ -789,7 +792,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_gauss_phase = longstring(item.str_values, item.get_size()); }; - sync_string(td_gauss_phase); + sync_string(input.td_gauss_phase); this->add_item(item); } { @@ -798,7 +801,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_gauss_sigma = longstring(item.str_values, item.get_size()); }; - sync_string(td_gauss_sigma); + sync_string(input.td_gauss_sigma); this->add_item(item); } { @@ -807,7 +810,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_gauss_t0 = longstring(item.str_values, item.get_size()); }; - sync_string(td_gauss_t0); + sync_string(input.td_gauss_t0); this->add_item(item); } { @@ -816,7 +819,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_gauss_amp = longstring(item.str_values, item.get_size()); }; - sync_string(td_gauss_amp); + sync_string(input.td_gauss_amp); this->add_item(item); } { @@ -825,7 +828,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trape_freq = longstring(item.str_values, item.get_size()); }; - sync_string(td_trape_freq); + sync_string(input.td_trape_freq); this->add_item(item); } { @@ -834,7 +837,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trape_phase = longstring(item.str_values, item.get_size()); }; - sync_string(td_trape_phase); + sync_string(input.td_trape_phase); this->add_item(item); } { @@ -843,7 +846,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trape_t1 = longstring(item.str_values, item.get_size()); }; - sync_string(td_trape_t1); + sync_string(input.td_trape_t1); this->add_item(item); } { @@ -852,7 +855,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trape_t2 = longstring(item.str_values, item.get_size()); }; - sync_string(td_trape_t2); + sync_string(input.td_trape_t2); this->add_item(item); } { @@ -861,7 +864,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trape_t3 = longstring(item.str_values, item.get_size()); }; - sync_string(td_trape_t3); + sync_string(input.td_trape_t3); this->add_item(item); } { @@ -870,7 +873,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trape_amp = longstring(item.str_values, item.get_size()); }; - sync_string(td_trape_amp); + sync_string(input.td_trape_amp); this->add_item(item); } { @@ -879,7 +882,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trigo_freq1 = longstring(item.str_values, item.get_size()); }; - sync_string(td_trigo_freq1); + sync_string(input.td_trigo_freq1); this->add_item(item); } { @@ -888,7 +891,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trigo_freq2 = longstring(item.str_values, item.get_size()); }; - sync_string(td_trigo_freq2); + sync_string(input.td_trigo_freq2); this->add_item(item); } { @@ -897,7 +900,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trigo_phase1 = longstring(item.str_values, item.get_size()); }; - sync_string(td_trigo_phase1); + sync_string(input.td_trigo_phase1); this->add_item(item); } { @@ -906,7 +909,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trigo_phase2 = longstring(item.str_values, item.get_size()); }; - sync_string(td_trigo_phase2); + sync_string(input.td_trigo_phase2); this->add_item(item); } { @@ -915,7 +918,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_trigo_amp = longstring(item.str_values, item.get_size()); }; - sync_string(td_trigo_amp); + sync_string(input.td_trigo_amp); this->add_item(item); } { @@ -924,7 +927,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_heavi_t0 = longstring(item.str_values, item.get_size()); }; - sync_string(td_heavi_t0); + sync_string(input.td_heavi_t0); this->add_item(item); } { @@ -933,13 +936,13 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.td_heavi_amp = longstring(item.str_values, item.get_size()); }; - sync_string(td_heavi_amp); + sync_string(input.td_heavi_amp); this->add_item(item); } { Input_Item item("ocp"); item.annotation = "change occupation or not"; - read_sync_bool(ocp); + read_sync_bool(input.ocp); this->add_item(item); } { @@ -948,7 +951,7 @@ void ReadInput::item_others() item.read_value = [](const Input_Item& item, Parameter& para) { para.input.ocp_set = longstring(item.str_values, item.get_size()); }; - sync_string(ocp_set); + sync_string(input.ocp_set); this->add_item(item); } @@ -956,7 +959,7 @@ void ReadInput::item_others() { Input_Item item("berry_phase"); item.annotation = "calculate berry phase or not"; - read_sync_bool(berry_phase); + read_sync_bool(input.berry_phase); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.berry_phase) { @@ -982,13 +985,13 @@ void ReadInput::item_others() Input_Item item("gdir"); item.annotation = "calculate the polarization in the direction of the " "lattice vector"; - read_sync_int(gdir); + read_sync_int(input.gdir); this->add_item(item); } { Input_Item item("towannier90"); item.annotation = "use wannier90 code interface or not"; - read_sync_bool(towannier90); + read_sync_bool(input.towannier90); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.towannier90) { @@ -1012,13 +1015,13 @@ void ReadInput::item_others() { Input_Item item("nnkpfile"); item.annotation = "the wannier90 code nnkp file name"; - read_sync_string(nnkpfile); + read_sync_string(input.nnkpfile); this->add_item(item); } { Input_Item item("wannier_spin"); item.annotation = "calculate spin in wannier90 code interface"; - read_sync_string(wannier_spin); + read_sync_string(input.wannier_spin); this->add_item(item); } { @@ -1044,37 +1047,37 @@ void ReadInput::item_others() para.input.wannier_method = 1; } }; - read_sync_int(wannier_method); + read_sync_int(input.wannier_method); this->add_item(item); } { Input_Item item("out_wannier_mmn"); item.annotation = "output .mmn file or not"; - read_sync_bool(out_wannier_mmn); + read_sync_bool(input.out_wannier_mmn); this->add_item(item); } { Input_Item item("out_wannier_amn"); item.annotation = "output .amn file or not"; - read_sync_bool(out_wannier_amn); + read_sync_bool(input.out_wannier_amn); this->add_item(item); } { Input_Item item("out_wannier_unk"); item.annotation = "output UNK. file or not"; - read_sync_bool(out_wannier_unk); + read_sync_bool(input.out_wannier_unk); this->add_item(item); } { Input_Item item("out_wannier_eig"); item.annotation = "output .eig file or not"; - read_sync_bool(out_wannier_eig); + read_sync_bool(input.out_wannier_eig); this->add_item(item); } { Input_Item item("out_wannier_wvfn_formatted"); item.annotation = "output UNK. file in text format or in binary format"; - read_sync_bool(out_wannier_wvfn_formatted); + read_sync_bool(input.out_wannier_wvfn_formatted); this->add_item(item); } @@ -1082,31 +1085,31 @@ void ReadInput::item_others() { Input_Item item("imp_sol"); item.annotation = "calculate implicit solvation correction or not"; - read_sync_bool(imp_sol); + read_sync_bool(input.imp_sol); this->add_item(item); } { Input_Item item("eb_k"); item.annotation = "the relative permittivity of the bulk solvent"; - read_sync_double(eb_k); + read_sync_double(input.eb_k); this->add_item(item); } { Input_Item item("tau"); item.annotation = "the effective surface tension parameter"; - read_sync_double(tau); + read_sync_double(input.tau); this->add_item(item); } { Input_Item item("sigma_k"); item.annotation = "the width of the diffuse cavity"; - read_sync_double(sigma_k); + read_sync_double(input.sigma_k); this->add_item(item); } { Input_Item item("nc_k"); item.annotation = "the cut-off charge density"; - read_sync_double(nc_k); + read_sync_double(input.nc_k); this->add_item(item); } @@ -1114,64 +1117,64 @@ void ReadInput::item_others() { Input_Item item("of_kinetic"); item.annotation = "kinetic energy functional, such as tf, vw, wt"; - read_sync_string(of_kinetic); + read_sync_string(input.of_kinetic); this->add_item(item); } { Input_Item item("of_method"); item.annotation = "optimization method used in OFDFT, including cg1, " "cg2, tn (default)"; - read_sync_string(of_method); + read_sync_string(input.of_method); this->add_item(item); } { Input_Item item("of_conv"); item.annotation = "the convergence criterion, potential, energy (default), or both"; - read_sync_string(of_conv); + read_sync_string(input.of_conv); this->add_item(item); } { Input_Item item("of_tole"); item.annotation = "tolerance of the energy change (in Ry) for " "determining the convergence, default=2e-6 Ry"; - read_sync_double(of_tole); + read_sync_double(input.of_tole); this->add_item(item); } { Input_Item item("of_tolp"); item.annotation = "tolerance of potential for determining the " "convergence, default=1e-5 in a.u."; - read_sync_double(of_tolp); + read_sync_double(input.of_tolp); this->add_item(item); } { Input_Item item("of_tf_weight"); item.annotation = "weight of TF KEDF"; - read_sync_double(of_tf_weight); + read_sync_double(input.of_tf_weight); this->add_item(item); } { Input_Item item("of_vw_weight"); item.annotation = "weight of vW KEDF"; - read_sync_double(of_vw_weight); + read_sync_double(input.of_vw_weight); this->add_item(item); } { Input_Item item("of_wt_alpha"); item.annotation = "parameter alpha of WT KEDF"; - read_sync_double(of_wt_alpha); + read_sync_double(input.of_wt_alpha); this->add_item(item); } { Input_Item item("of_wt_beta"); item.annotation = "parameter beta of WT KEDF"; - read_sync_double(of_wt_beta); + read_sync_double(input.of_wt_beta); this->add_item(item); } { Input_Item item("of_wt_rho0"); item.annotation = "the average density of system, used in WT KEDF, in Bohr^-3"; - read_sync_double(of_wt_rho0); + read_sync_double(input.of_wt_rho0); this->add_item(item); } { @@ -1179,7 +1182,7 @@ void ReadInput::item_others() item.annotation = "If set to 1, the rho0 will be fixed even if the " "volume of system has changed, it will be " "set to 1 automaticly if of_wt_rho0 is not zero"; - read_sync_bool(of_hold_rho0); + read_sync_bool(input.of_hold_rho0); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.of_wt_rho0 != 0) { @@ -1191,14 +1194,14 @@ void ReadInput::item_others() { Input_Item item("of_lkt_a"); item.annotation = "parameter a of LKT KEDF"; - read_sync_double(of_lkt_a); + read_sync_double(input.of_lkt_a); this->add_item(item); } { Input_Item item("of_full_pw"); item.annotation = "If set to 1, ecut will be ignored when collect " "planewaves, so that all planewaves will be used"; - read_sync_bool(of_full_pw); + read_sync_bool(input.of_full_pw); this->add_item(item); } { @@ -1206,7 +1209,7 @@ void ReadInput::item_others() item.annotation = "If of_full_pw = true, dimention of FFT is " "testricted to be (0) either odd or even; (1) odd " "only; (2) even only"; - read_sync_int(of_full_pw_dim); + read_sync_int(input.of_full_pw_dim); item.reset_value = [](const Input_Item& item, Parameter& para) { if (!para.input.of_full_pw) { @@ -1220,7 +1223,7 @@ void ReadInput::item_others() item.annotation = "If set to 1, the kernel of WT KEDF will be filled " "from file of_kernel_file, not from " "formula. Only usable for WT KEDF"; - read_sync_bool(of_read_kernel); + read_sync_bool(input.of_read_kernel); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.of_kinetic != "wt") { @@ -1232,7 +1235,7 @@ void ReadInput::item_others() { Input_Item item("of_kernel_file"); item.annotation = "The name of WT kernel file."; - read_sync_string(of_kernel_file); + read_sync_string(input.of_kernel_file); this->add_item(item); } @@ -1240,7 +1243,7 @@ void ReadInput::item_others() { Input_Item item("dft_plus_u"); item.annotation = "DFT+U correction method"; - read_sync_int(dft_plus_u); + read_sync_int(input.dft_plus_u); item.reset_value = [](const Input_Item& item, Parameter& para) { bool all_minus1 = true; for (auto& val: para.input.orbital_corr) @@ -1282,13 +1285,13 @@ void ReadInput::item_others() { Input_Item item("yukawa_lambda"); item.annotation = "default:0.0"; - read_sync_double(yukawa_lambda); + read_sync_double(input.yukawa_lambda); this->add_item(item); } { Input_Item item("yukawa_potential"); item.annotation = "default: false"; - read_sync_bool(yukawa_potential); + read_sync_bool(input.yukawa_potential); this->add_item(item); } { @@ -1296,7 +1299,7 @@ void ReadInput::item_others() item.annotation = "increasing U values during SCF"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.uramping_eV = doublevalue; - para.input.sup.uramping = para.input.uramping_eV / ModuleBase::Ry_to_eV; + para.sys.uramping = para.input.uramping_eV / ModuleBase::Ry_to_eV; }; item.reset_value = [](const Input_Item& item, Parameter& para) { bool all_minus1 = true; @@ -1310,27 +1313,26 @@ void ReadInput::item_others() } if (all_minus1) { - if (para.input.sup.uramping != 0.0) + if (para.sys.uramping != 0.0) { - para.input.sup.uramping = 0.0; + para.sys.uramping = 0.0; ModuleBase::WARNING("ReadInput", "No atoms are correlated, U-ramping is closed!!!"); } } }; - sync_double(uramping_eV); - add_double_bcast(sup.uramping); + sync_double(input.uramping_eV); this->add_item(item); } { Input_Item item("omc"); item.annotation = "the mode of occupation matrix control"; - read_sync_int(omc); + read_sync_int(input.omc); this->add_item(item); } { Input_Item item("onsite_radius"); item.annotation = "radius of the sphere for onsite projection (Bohr)"; - read_sync_double(onsite_radius); + read_sync_double(input.onsite_radius); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.dft_plus_u == 1 && para.input.onsite_radius == 0.0) { @@ -1348,19 +1350,20 @@ void ReadInput::item_others() for (int i = 0; i < count; i++) { para.input.hubbard_u_eV.push_back(std::stod(item.str_values[i])); - para.input.sup.hubbard_u.push_back(para.input.hubbard_u_eV[i] / ModuleBase::Ry_to_eV); + para.sys.hubbard_u.push_back(para.input.hubbard_u_eV[i] / ModuleBase::Ry_to_eV); } }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (!item.is_read()) + if (!item.is_read()) { return; - if (para.input.sup.hubbard_u.size() != para.input.ntype) +} + if (para.sys.hubbard_u.size() != para.input.ntype) { ModuleBase::WARNING_QUIT("ReadInput", "hubbard_u should have the same " "number of elements as ntype"); } - for (auto& value: para.input.sup.hubbard_u) + for (auto& value: para.sys.hubbard_u) { if (value < -1.0e-3) { @@ -1368,9 +1371,8 @@ void ReadInput::item_others() } } }; - // We must firt bcast ntype (in item_general), then bcast hubbard_u - sync_doublevec(hubbard_u_eV, para.input.ntype, 0.0); - add_doublevec_bcast(sup.hubbard_u, para.input.ntype, 0.0); + sync_doublevec(input.hubbard_u_eV, para.input.ntype, 0.0); + add_doublevec_bcast(sys.hubbard_u, para.input.ntype, 0.0); this->add_item(item); } { @@ -1386,8 +1388,9 @@ void ReadInput::item_others() }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (!item.is_read()) + if (!item.is_read()) { return; +} if (para.input.orbital_corr.size() != para.input.ntype) { ModuleBase::WARNING_QUIT("ReadInput", @@ -1402,8 +1405,7 @@ void ReadInput::item_others() } } }; - // We must firt bcast ntype (in item_general), then bcast orbital_corr - sync_intvec(orbital_corr, para.input.ntype, -1); + sync_intvec(input.orbital_corr, para.input.ntype, -1); this->add_item(item); } @@ -1411,7 +1413,7 @@ void ReadInput::item_others() { Input_Item item("bessel_nao_ecut"); item.annotation = "energy cutoff for spherical bessel functions(Ry)"; - read_sync_string(bessel_nao_ecut); + read_sync_string(input.bessel_nao_ecut); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.bessel_nao_ecut == "default") { @@ -1429,7 +1431,7 @@ void ReadInput::item_others() { Input_Item item("bessel_nao_tolerence"); item.annotation = "tolerence for spherical bessel root"; - read_sync_double(bessel_nao_tolerence); + read_sync_double(input.bessel_nao_tolerence); this->add_item(item); } { @@ -1441,45 +1443,43 @@ void ReadInput::item_others() { para.input.bessel_nao_rcuts.push_back(std::stod(item.str_values[i])); } - if (count > 0) - para.input.sup.bessel_nao_rcut = para.input.bessel_nao_rcuts[0]; // also compatible with + if (count > 0) { + para.sys.bessel_nao_rcut = para.input.bessel_nao_rcuts[0]; // also compatible with +} // old input file - para.input.sup.nrcut = count; + para.sys.nrcut = count; }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.sup.bessel_nao_rcut < 0) + if (para.sys.bessel_nao_rcut < 0) { ModuleBase::WARNING_QUIT("ReadInput", "bessel_nao_rcut must >= 0"); } }; - add_int_bcast(sup.nrcut); - add_double_bcast(sup.bessel_nao_rcut); - // We must firt bcast nrcut, then bcast bessel_nao_rcut - sync_doublevec(bessel_nao_rcuts, para.input.sup.nrcut, 0.0); + sync_doublevec(input.bessel_nao_rcuts, para.sys.nrcut, 0.0); this->add_item(item); } { Input_Item item("bessel_nao_smooth"); item.annotation = "spherical bessel smooth or not"; - read_sync_bool(bessel_nao_smooth); + read_sync_bool(input.bessel_nao_smooth); this->add_item(item); } { Input_Item item("bessel_nao_sigma"); item.annotation = "spherical bessel smearing_sigma"; - read_sync_double(bessel_nao_sigma); + read_sync_double(input.bessel_nao_sigma); this->add_item(item); } { Input_Item item("bessel_descriptor_lmax"); item.annotation = "lmax used in generating spherical bessel functions"; - read_sync_int(bessel_descriptor_lmax); + read_sync_int(input.bessel_descriptor_lmax); this->add_item(item); } { Input_Item item("bessel_descriptor_ecut"); item.annotation = "energy cutoff for spherical bessel functions(Ry)"; - read_sync_string(bessel_descriptor_ecut); + read_sync_string(input.bessel_descriptor_ecut); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.bessel_descriptor_ecut == "default") { @@ -1497,13 +1497,13 @@ void ReadInput::item_others() { Input_Item item("bessel_descriptor_tolerence"); item.annotation = "tolerence for spherical bessel root"; - read_sync_double(bessel_descriptor_tolerence); + read_sync_double(input.bessel_descriptor_tolerence); this->add_item(item); } { Input_Item item("bessel_descriptor_rcut"); item.annotation = "radial cutoff for spherical bessel functions(a.u.)"; - read_sync_double(bessel_descriptor_rcut); + read_sync_double(input.bessel_descriptor_rcut); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.bessel_descriptor_rcut < 0) { @@ -1515,13 +1515,13 @@ void ReadInput::item_others() { Input_Item item("bessel_descriptor_smooth"); item.annotation = "spherical bessel smooth or not"; - read_sync_bool(bessel_descriptor_smooth); + read_sync_bool(input.bessel_descriptor_smooth); this->add_item(item); } { Input_Item item("bessel_descriptor_sigma"); item.annotation = "sphereical bessel smearing_sigma"; - read_sync_double(bessel_descriptor_sigma); + read_sync_double(input.bessel_descriptor_sigma); this->add_item(item); } @@ -1529,7 +1529,7 @@ void ReadInput::item_others() { Input_Item item("sc_mag_switch"); item.annotation = "switch to control spin-constrained DFT"; - read_sync_bool(sc_mag_switch); + read_sync_bool(input.sc_mag_switch); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sc_mag_switch) { @@ -1559,13 +1559,13 @@ void ReadInput::item_others() { Input_Item item("decay_grad_switch"); item.annotation = "switch to control gradient break condition"; - read_sync_bool(decay_grad_switch); + read_sync_bool(input.decay_grad_switch); this->add_item(item); } { Input_Item item("sc_thr"); item.annotation = "Convergence criterion of spin-constrained iteration (RMS) in uB"; - read_sync_double(sc_thr); + read_sync_double(input.sc_thr); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sc_thr < 0) { @@ -1577,7 +1577,7 @@ void ReadInput::item_others() { Input_Item item("nsc"); item.annotation = "Maximal number of spin-constrained iteration"; - read_sync_int(nsc); + read_sync_int(input.nsc); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nsc <= 0) { @@ -1589,7 +1589,7 @@ void ReadInput::item_others() { Input_Item item("nsc_min"); item.annotation = "Minimum number of spin-constrained iteration"; - read_sync_int(nsc_min); + read_sync_int(input.nsc_min); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nsc_min <= 0) { @@ -1602,7 +1602,7 @@ void ReadInput::item_others() Input_Item item("sc_scf_nmin"); item.annotation = "Minimum number of outer scf loop before " "initializing lambda loop"; - read_sync_int(sc_scf_nmin); + read_sync_int(input.sc_scf_nmin); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sc_scf_nmin < 2) { @@ -1614,7 +1614,7 @@ void ReadInput::item_others() { Input_Item item("alpha_trial"); item.annotation = "Initial trial step size for lambda in eV/uB^2"; - read_sync_double(alpha_trial); + read_sync_double(input.alpha_trial); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.alpha_trial <= 0) { @@ -1626,7 +1626,7 @@ void ReadInput::item_others() { Input_Item item("sccut"); item.annotation = "Maximal step size for lambda in eV/uB"; - read_sync_double(sccut); + read_sync_double(input.sccut); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sccut <= 0) { @@ -1639,7 +1639,7 @@ void ReadInput::item_others() Input_Item item("sc_file"); item.annotation = "file name for parameters used in non-collinear " "spin-constrained DFT (json format)"; - read_sync_string(sc_file); + read_sync_string(input.sc_file); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.sc_mag_switch) { @@ -1657,20 +1657,20 @@ void ReadInput::item_others() { Input_Item item("qo_switch"); item.annotation = "switch to control quasiatomic orbital analysis"; - read_sync_bool(qo_switch); + read_sync_bool(input.qo_switch); this->add_item(item); } { Input_Item item("qo_basis"); item.annotation = "type of QO basis function: hydrogen: hydrogen-like " "basis, pswfc: read basis from pseudopotential"; - read_sync_string(qo_basis); + read_sync_string(input.qo_basis); this->add_item(item); } { Input_Item item("qo_thr"); item.annotation = "accuracy for evaluating cutoff radius of QO basis function"; - read_sync_double(qo_thr); + read_sync_double(input.qo_thr); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.qo_thr > 1e-6) { @@ -1701,11 +1701,11 @@ void ReadInput::item_others() else { std::string default_strategy; - if (para.input.qo_basis == "hydrogen") + if (para.input.qo_basis == "hydrogen") { default_strategy = "energy-valence"; - else if ((para.input.qo_basis == "pswfc") || (para.input.qo_basis == "szv")) + } else if ((para.input.qo_basis == "pswfc") || (para.input.qo_basis == "szv")) { default_strategy = "all"; - else + } else { ModuleBase::WARNING_QUIT("ReadInput", "When setting default values for qo_strategy, " @@ -1716,8 +1716,7 @@ void ReadInput::item_others() } } }; - // We must firt bcast ntype (in item_general), then bcast qo_strategy - sync_stringvec(qo_strategy, para.input.ntype, "all"); + sync_stringvec(input.qo_strategy, para.input.ntype, "all"); this->add_item(item); } { @@ -1731,8 +1730,9 @@ void ReadInput::item_others() } }; item.reset_value = [](const Input_Item& item, Parameter& para) { - if (!item.is_read()) + if (!item.is_read()) { return; +} if (para.input.qo_screening_coeff.size() != para.input.ntype) { if (para.input.qo_basis == "pswfc") @@ -1766,9 +1766,7 @@ void ReadInput::item_others() } } }; - // We must firt bcast ntype (in item_general), then bcast - // qo_screening_coeff - sync_doublevec(qo_screening_coeff, para.input.ntype, 0.1); + sync_doublevec(input.qo_screening_coeff, para.input.ntype, 0.1); this->add_item(item); } @@ -1776,121 +1774,121 @@ void ReadInput::item_others() { Input_Item item("pexsi_npole"); item.annotation = "Number of poles in expansion"; - read_sync_int(pexsi_npole); + read_sync_int(input.pexsi_npole); this->add_item(item); } { Input_Item item("pexsi_inertia"); item.annotation = "Whether inertia counting is used at the very " "beginning of PEXSI process"; - read_sync_bool(pexsi_inertia); + read_sync_bool(input.pexsi_inertia); this->add_item(item); } { Input_Item item("pexsi_nmax"); item.annotation = "Maximum number of PEXSI iterations after each " "inertia counting procedure"; - read_sync_int(pexsi_nmax); + read_sync_int(input.pexsi_nmax); this->add_item(item); } { Input_Item item("pexsi_comm"); item.annotation = "Whether to construct PSelInv communication pattern"; - read_sync_bool(pexsi_comm); + read_sync_bool(input.pexsi_comm); this->add_item(item); } { Input_Item item("pexsi_storage"); item.annotation = "Storage space used by the Selected Inversion " "algorithm for symmetric matrices"; - read_sync_bool(pexsi_storage); + read_sync_bool(input.pexsi_storage); this->add_item(item); } { Input_Item item("pexsi_ordering"); item.annotation = "Ordering strategy for factorization and selected inversion"; - read_sync_int(pexsi_ordering); + read_sync_int(input.pexsi_ordering); this->add_item(item); } { Input_Item item("pexsi_row_ordering"); item.annotation = "Row permutation strategy for factorization and " "selected inversion, 0: NoRowPerm, 1: LargeDiag"; - read_sync_int(pexsi_row_ordering); + read_sync_int(input.pexsi_row_ordering); this->add_item(item); } { Input_Item item("pexsi_nproc"); item.annotation = "Number of processors for parmetis"; - read_sync_int(pexsi_nproc); + read_sync_int(input.pexsi_nproc); this->add_item(item); } { Input_Item item("pexsi_symm"); item.annotation = "Matrix symmetry"; - read_sync_bool(pexsi_symm); + read_sync_bool(input.pexsi_symm); this->add_item(item); } { Input_Item item("pexsi_trans"); item.annotation = "Whether to transpose"; - read_sync_bool(pexsi_trans); + read_sync_bool(input.pexsi_trans); this->add_item(item); } { Input_Item item("pexsi_method"); item.annotation = "pole expansion method, 1: Cauchy Contour Integral, " "2: Moussa optimized method"; - read_sync_int(pexsi_method); + read_sync_int(input.pexsi_method); this->add_item(item); } { Input_Item item("pexsi_nproc_pole"); item.annotation = "Number of processes used by each pole"; - read_sync_int(pexsi_nproc_pole); + read_sync_int(input.pexsi_nproc_pole); this->add_item(item); } { Input_Item item("pexsi_temp"); item.annotation = "Temperature, in the same unit as H"; - read_sync_double(pexsi_temp); + read_sync_double(input.pexsi_temp); this->add_item(item); } { Input_Item item("pexsi_gap"); item.annotation = "Spectral gap"; - read_sync_double(pexsi_gap); + read_sync_double(input.pexsi_gap); this->add_item(item); } { Input_Item item("pexsi_delta_e"); item.annotation = "An upper bound for the spectral radius of S^{-1} H"; - read_sync_double(pexsi_delta_e); + read_sync_double(input.pexsi_delta_e); this->add_item(item); } { Input_Item item("pexsi_mu_lower"); item.annotation = "Initial guess of lower bound for mu"; - read_sync_double(pexsi_mu_lower); + read_sync_double(input.pexsi_mu_lower); this->add_item(item); } { Input_Item item("pexsi_mu_upper"); item.annotation = "Initial guess of upper bound for mu"; - read_sync_double(pexsi_mu_upper); + read_sync_double(input.pexsi_mu_upper); this->add_item(item); } { Input_Item item("pexsi_mu"); item.annotation = "Initial guess for mu (for the solver)"; - read_sync_double(pexsi_mu); + read_sync_double(input.pexsi_mu); this->add_item(item); } { Input_Item item("pexsi_mu_thr"); item.annotation = "Stopping criterion in terms of the chemical " "potential for the inertia counting procedure"; - read_sync_double(pexsi_mu_thr); + read_sync_double(input.pexsi_mu_thr); this->add_item(item); } { @@ -1898,14 +1896,14 @@ void ReadInput::item_others() item.annotation = "If the chemical potential is not in the initial " "interval, the interval is expanded by " "muInertiaExpansion"; - read_sync_double(pexsi_mu_expand); + read_sync_double(input.pexsi_mu_expand); this->add_item(item); } { Input_Item item("pexsi_mu_guard"); item.annotation = "Safe guard criterion in terms of the chemical potential to " "reinvoke the inertia counting procedure"; - read_sync_double(pexsi_mu_guard); + read_sync_double(input.pexsi_mu_guard); this->add_item(item); } { @@ -1913,14 +1911,14 @@ void ReadInput::item_others() item.annotation = "Stopping criterion of the PEXSI iteration in terms " "of the number of electrons compared to " "numElectronExact"; - read_sync_double(pexsi_elec_thr); + read_sync_double(input.pexsi_elec_thr); this->add_item(item); } { Input_Item item("pexsi_zero_thr"); item.annotation = "if the absolute value of matrix element is less " "than ZERO_Limit, it will be considered as 0"; - read_sync_double(pexsi_zero_thr); + read_sync_double(input.pexsi_zero_thr); this->add_item(item); } @@ -1928,13 +1926,13 @@ void ReadInput::item_others() { Input_Item item("lr_nstates"); item.annotation = "the number of 2-particle states to be solved"; - read_sync_int(lr_nstates); + read_sync_int(input.lr_nstates); this->add_item(item); } { Input_Item item("nocc"); item.annotation = "the number of occupied orbitals to form the 2-particle basis ( <= nelec/2)"; - read_sync_int(nocc); + read_sync_int(input.nocc); item.reset_value = [](const Input_Item& item, Parameter& para) { const int nocc_default = std::max(static_cast(para.input.nelec + 1) / 2, para.input.nbands); if (para.input.nocc <= 0 || para.input.nocc > nocc_default) { para.input.nocc = nocc_default; } @@ -1944,31 +1942,31 @@ void ReadInput::item_others() { Input_Item item("nvirt"); item.annotation = "the number of virtual orbitals to form the 2-particle basis (nocc + nvirt <= nbands)"; - read_sync_int(nvirt); + read_sync_int(input.nvirt); this->add_item(item); } { Input_Item item("xc_kernel"); item.annotation = "exchange correlation (XC) kernel for LR-TDDFT"; - read_sync_string(xc_kernel); + read_sync_string(input.xc_kernel); this->add_item(item); } { Input_Item item("lr_solver"); item.annotation = "the eigensolver for LR-TDDFT"; - read_sync_string(lr_solver); + read_sync_string(input.lr_solver); this->add_item(item); } { Input_Item item("lr_thr"); item.annotation = "convergence threshold of the LR-TDDFT eigensolver"; - read_sync_double(lr_thr); + read_sync_double(input.lr_thr); this->add_item(item); } { Input_Item item("out_wfc_lr"); item.annotation = "whether to output the eigenvectors (excitation amplitudes) in the particle-hole basis"; - read_sync_bool(out_wfc_lr); + read_sync_bool(input.out_wfc_lr); this->add_item(item); } { @@ -1985,13 +1983,13 @@ void ReadInput::item_others() auto& awr = para.input.abs_wavelen_range; if (awr.size() < 2) { ModuleBase::WARNING_QUIT("ReadInput", "abs_wavelen_range must have two values"); } }; - sync_doublevec(abs_wavelen_range, 2, 0.0); + sync_doublevec(input.abs_wavelen_range, 2, 0.0); this->add_item(item); } { Input_Item item("abs_broadening"); item.annotation = "the broadening (eta) for LR-TDDFT absorption spectrum"; - read_sync_double(abs_broadening); + read_sync_double(input.abs_broadening); this->add_item(item); } } diff --git a/source/module_io/read_input_item_postprocess.cpp b/source/module_io/read_input_item_postprocess.cpp index a8ea3a19cd..c84bce571c 100644 --- a/source/module_io/read_input_item_postprocess.cpp +++ b/source/module_io/read_input_item_postprocess.cpp @@ -9,13 +9,13 @@ void ReadInput::item_postprocess() { Input_Item item("smearing_method"); item.annotation = "type of smearing_method: gauss; fd; fixed; mp; mp2; mv"; - read_sync_string(smearing_method); + read_sync_string(input.smearing_method); this->add_item(item); } { Input_Item item("smearing_sigma"); item.annotation = "energy range for smearing"; - read_sync_double(smearing_sigma); + read_sync_double(input.smearing_sigma); this->add_item(item); } { @@ -33,13 +33,13 @@ void ReadInput::item_postprocess() { Input_Item item("mixing_type"); item.annotation = "plain; pulay; broyden"; - read_sync_string(mixing_mode); + read_sync_string(input.mixing_mode); this->add_item(item); } { Input_Item item("mixing_beta"); item.annotation = "mixing parameter: 0 means no new charge"; - read_sync_double(mixing_beta); + read_sync_double(input.mixing_beta); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.mixing_beta < 0.0) { @@ -66,25 +66,25 @@ void ReadInput::item_postprocess() { Input_Item item("mixing_ndim"); item.annotation = "mixing dimension in pulay or broyden"; - read_sync_int(mixing_ndim); + read_sync_int(input.mixing_ndim); this->add_item(item); } { Input_Item item("mixing_restart"); item.annotation = "threshold to restart mixing during SCF"; - read_sync_double(mixing_restart); + read_sync_double(input.mixing_restart); this->add_item(item); } { Input_Item item("mixing_gg0"); item.annotation = "mixing parameter in kerker"; - read_sync_double(mixing_gg0); + read_sync_double(input.mixing_gg0); this->add_item(item); } { Input_Item item("mixing_beta_mag"); item.annotation = "mixing parameter for magnetic density"; - read_sync_double(mixing_beta_mag); + read_sync_double(input.mixing_beta_mag); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.mixing_beta_mag < 0.0) { @@ -106,37 +106,37 @@ void ReadInput::item_postprocess() { Input_Item item("mixing_gg0_mag"); item.annotation = "mixing parameter in kerker"; - read_sync_double(mixing_gg0_mag); + read_sync_double(input.mixing_gg0_mag); this->add_item(item); } { Input_Item item("mixing_gg0_min"); item.annotation = "the minimum kerker coefficient"; - read_sync_double(mixing_gg0_min); + read_sync_double(input.mixing_gg0_min); this->add_item(item); } { Input_Item item("mixing_angle"); item.annotation = "angle mixing parameter for non-colinear calculations"; - read_sync_double(mixing_angle); + read_sync_double(input.mixing_angle); this->add_item(item); } { Input_Item item("mixing_tau"); item.annotation = "whether to mix tau in mGGA calculation"; - read_sync_bool(mixing_tau); + read_sync_bool(input.mixing_tau); this->add_item(item); } { Input_Item item("mixing_dftu"); item.annotation = "whether to mix locale in DFT+U calculation"; - read_sync_bool(mixing_dftu); + read_sync_bool(input.mixing_dftu); this->add_item(item); } { Input_Item item("mixing_dmr"); item.annotation = "whether to mix real-space density matrix"; - read_sync_bool(mixing_dmr); + read_sync_bool(input.mixing_dmr); this->add_item(item); } @@ -146,10 +146,9 @@ void ReadInput::item_postprocess() item.annotation = "minimal range for dos"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.dos_emin_ev = doublevalue; - para.input.sup.dos_setemin = true; + para.sys.dos_setemin = true; }; - sync_double(dos_emin_ev); - add_bool_bcast(sup.dos_setemin); + sync_double(input.dos_emin_ev); this->add_item(item); } { @@ -157,34 +156,33 @@ void ReadInput::item_postprocess() item.annotation = "maximal range for dos"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.dos_emax_ev = doublevalue; - para.input.sup.dos_setemax = true; + para.sys.dos_setemax = true; }; - sync_double(dos_emax_ev); - add_bool_bcast(sup.dos_setemax); + sync_double(input.dos_emax_ev); this->add_item(item); } { Input_Item item("dos_edelta_ev"); item.annotation = "delta energy for dos"; - read_sync_double(dos_edelta_ev); + read_sync_double(input.dos_edelta_ev); this->add_item(item); } { Input_Item item("dos_scale"); item.annotation = "scale dos range by"; - read_sync_double(dos_scale); + read_sync_double(input.dos_scale); this->add_item(item); } { Input_Item item("dos_sigma"); item.annotation = "gauss b coefficeinet(default=0.07)"; - read_sync_double(dos_sigma); + read_sync_double(input.dos_sigma); this->add_item(item); } { Input_Item item("dos_nche"); item.annotation = "orders of Chebyshev expansions for dos"; - read_sync_int(dos_nche); + read_sync_int(input.dos_nche); this->add_item(item); } } diff --git a/source/module_io/read_input_item_pw.cpp b/source/module_io/read_input_item_pw.cpp index 4202c3804e..92504aa5d5 100644 --- a/source/module_io/read_input_item_pw.cpp +++ b/source/module_io/read_input_item_pw.cpp @@ -10,13 +10,13 @@ void ReadInput::item_pw() { Input_Item item("ecutwfc"); item.annotation = "energy cutoff for wave functions"; - read_sync_double(ecutwfc); + read_sync_double(input.ecutwfc); this->add_item(item); } { Input_Item item("ecutrho"); item.annotation = "energy cutoff for charge density and potential"; - read_sync_double(ecutrho); + read_sync_double(input.ecutrho); item.reset_value = [](const Input_Item& item, Parameter& para) { Input_para& input = para.input; if (input.ecutrho <= 0.0) @@ -25,7 +25,7 @@ void ReadInput::item_pw() } if (input.nx * input.ny * input.nz == 0 && input.ecutrho / input.ecutwfc > 4 + 1e-8) { - input.sup.double_grid = true; + para.sys.double_grid = true; } }; item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -34,61 +34,60 @@ void ReadInput::item_pw() ModuleBase::WARNING_QUIT("ReadInput", "ecutrho/ecutwfc must >= 4"); } }; - add_bool_bcast(sup.double_grid); this->add_item(item); } { Input_Item item("erf_ecut"); item.annotation = "the value of the constant energy cutoff"; - read_sync_double(erf_ecut); + read_sync_double(input.erf_ecut); this->add_item(item); } { Input_Item item("erf_height"); item.annotation = "the height of the energy step for reciprocal vectors"; - read_sync_double(erf_height); + read_sync_double(input.erf_height); this->add_item(item); } { Input_Item item("erf_sigma"); item.annotation = "the width of the energy step for reciprocal vectors"; - read_sync_double(erf_sigma); + read_sync_double(input.erf_sigma); this->add_item(item); } { Input_Item item("fft_mode"); item.annotation = "mode of FFTW"; - read_sync_int(fft_mode); + read_sync_int(input.fft_mode); this->add_item(item); } { Input_Item item("pw_diag_nmax"); item.annotation = "max iteration number for cg"; - read_sync_int(pw_diag_nmax); + read_sync_int(input.pw_diag_nmax); this->add_item(item); } { Input_Item item("diago_cg_prec"); item.annotation = "diago_cg_prec"; - read_sync_int(diago_cg_prec); + read_sync_int(input.diago_cg_prec); this->add_item(item); } { Input_Item item("pw_diag_ndim"); item.annotation = "dimension of workspace for Davidson diagonalization"; - read_sync_int(pw_diag_ndim); + read_sync_int(input.pw_diag_ndim); this->add_item(item); } { Input_Item item("diago_full_acc"); item.annotation = "all the empty states are diagonalized"; - read_sync_bool(diago_full_acc); + read_sync_bool(input.diago_full_acc); this->add_item(item); } { Input_Item item("pw_diag_thr"); item.annotation = "threshold for eigenvalues is cg electron iterations"; - read_sync_double(pw_diag_thr); + read_sync_double(input.pw_diag_thr); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.calculation == "get_S" && para.input.basis_type == "pw") { @@ -101,7 +100,7 @@ void ReadInput::item_pw() { Input_Item item("nb2d"); item.annotation = "matrix 2d division"; - read_sync_int(nb2d); + read_sync_int(input.nb2d); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nb2d < 0) { @@ -113,7 +112,7 @@ void ReadInput::item_pw() { Input_Item item("scf_thr"); item.annotation = "charge density error"; - read_sync_double(scf_thr); + read_sync_double(input.scf_thr); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.scf_thr == -1.0) { @@ -142,7 +141,7 @@ void ReadInput::item_pw() Input_Item item("scf_thr_type"); item.annotation = "type of the criterion of scf_thr, 1: reci drho for " "pw, 2: real drho for lcao"; - read_sync_int(scf_thr_type); + read_sync_int(input.scf_thr_type); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.scf_thr_type == -1) { @@ -178,7 +177,7 @@ void ReadInput::item_pw() } } }; - read_sync_string(init_wfc); + read_sync_string(input.init_wfc); this->add_item(item); } { @@ -190,13 +189,13 @@ void ReadInput::item_pw() para.input.psi_initializer = true; } }; - read_sync_bool(psi_initializer); + read_sync_bool(input.psi_initializer); this->add_item(item); } { Input_Item item("init_chg"); item.annotation = "start charge is from 'atomic' or file"; - read_sync_string(init_chg); + read_sync_string(input.init_chg); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.calculation == "get_pchg" || para.input.calculation == "get_wf") { @@ -222,7 +221,7 @@ void ReadInput::item_pw() { Input_Item item("chg_extrap"); item.annotation = "atomic; first-order; second-order; dm:coefficients of SIA"; - read_sync_string(chg_extrap); + read_sync_string(input.chg_extrap); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.chg_extrap == "default" && para.input.calculation == "md") { @@ -251,7 +250,7 @@ void ReadInput::item_pw() if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") para.input.out_chg = 1; }; - read_sync_int(out_chg); + read_sync_int(input.out_chg); this->add_item(item); } { @@ -261,25 +260,25 @@ void ReadInput::item_pw() if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") para.input.out_pot = 0; }; - read_sync_int(out_pot); + read_sync_int(input.out_pot); this->add_item(item); } { Input_Item item("out_wfc_pw"); item.annotation = "output wave functions"; - read_sync_int(out_wfc_pw); + read_sync_int(input.out_wfc_pw); this->add_item(item); } { Input_Item item("out_wfc_r"); item.annotation = "output wave functions in realspace"; - read_sync_bool(out_wfc_r); + read_sync_bool(input.out_wfc_r); this->add_item(item); } { Input_Item item("out_dos"); item.annotation = "output energy and dos"; - read_sync_int(out_dos); + read_sync_int(input.out_dos); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") para.input.out_dos = 0; @@ -324,13 +323,13 @@ void ReadInput::item_pw() if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") para.input.out_band[0] = 0; }; - sync_intvec(out_band, 2, 0); + sync_intvec(input.out_band, 2, 0); this->add_item(item); } { Input_Item item("out_proj_band"); item.annotation = "output projected band structure"; - read_sync_bool(out_proj_band); + read_sync_bool(input.out_proj_band); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.calculation == "get_wf" || para.input.calculation == "get_pchg") para.input.out_proj_band = false; @@ -346,19 +345,19 @@ void ReadInput::item_pw() { Input_Item item("restart_save"); item.annotation = "print to disk every step for restart"; - read_sync_bool(restart_save); + read_sync_bool(input.restart_save); this->add_item(item); } { Input_Item item("restart_load"); item.annotation = "restart from disk"; - read_sync_bool(restart_load); + read_sync_bool(input.restart_load); this->add_item(item); } { Input_Item item("read_file_dir"); item.annotation = "directory of files for reading"; - read_sync_string(read_file_dir); + read_sync_string(input.read_file_dir); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.read_file_dir == "auto") { @@ -380,7 +379,7 @@ void ReadInput::item_pw() item.annotation = "number of points along x axis for FFT grid"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.nx = intvalue; - para.input.sup.ncx = intvalue; + para.sys.ncx = intvalue; }; item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.nx != 0) @@ -388,8 +387,7 @@ void ReadInput::item_pw() ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); } }; - sync_int(nx); - add_int_bcast(sup.ncx); + sync_int(input.nx); this->add_item(item); } { @@ -397,7 +395,7 @@ void ReadInput::item_pw() item.annotation = "number of points along y axis for FFT grid"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.ny = intvalue; - para.input.sup.ncy = intvalue; + para.sys.ncy = intvalue; }; item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.ny != 0) @@ -405,8 +403,7 @@ void ReadInput::item_pw() ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); } }; - sync_int(ny); - add_int_bcast(sup.ncy); + sync_int(input.ny); this->add_item(item); } { @@ -414,7 +411,7 @@ void ReadInput::item_pw() item.annotation = "number of points along z axis for FFT grid"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.nz = intvalue; - para.input.sup.ncz = intvalue; + para.sys.ncz = intvalue; }; item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.nx * para.input.ny * para.input.nz == 0 && para.input.nz != 0) @@ -422,18 +419,17 @@ void ReadInput::item_pw() ModuleBase::WARNING_QUIT("ReadInput", "nx, ny, nz should be all set to non-zero"); } }; - sync_int(nz); - add_int_bcast(sup.ncz); + sync_int(input.nz); this->add_item(item); } { Input_Item item("ndx"); item.annotation = "number of points along x axis for FFT smooth grid"; - read_sync_int(ndx); + read_sync_int(input.ndx); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.ndx > para.input.nx) { - para.input.sup.double_grid = true; + para.sys.double_grid = true; } }; item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -448,17 +444,16 @@ void ReadInput::item_pw() ModuleBase::WARNING_QUIT("ReadInput", "ndx should be greater than or equal to nx"); } }; - add_bool_bcast(sup.double_grid); this->add_item(item); } { Input_Item item("ndy"); item.annotation = "number of points along y axis for FFT smooth grid"; - read_sync_int(ndy); + read_sync_int(input.ndy); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.ndy > para.input.ny) { - para.input.sup.double_grid = true; + para.sys.double_grid = true; } }; item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -478,11 +473,11 @@ void ReadInput::item_pw() { Input_Item item("ndz"); item.annotation = "number of points along z axis for FFT smooth grid"; - read_sync_int(ndz); + read_sync_int(input.ndz); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.ndy > para.input.ny) { - para.input.sup.double_grid = true; + para.sys.double_grid = true; } }; item.check_value = [](const Input_Item& item, const Parameter& para) { @@ -502,13 +497,19 @@ void ReadInput::item_pw() { Input_Item item("cell_factor"); item.annotation = "used in the construction of the pseudopotential tables"; - read_sync_double(cell_factor); + read_sync_double(input.cell_factor); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.calculation == "cell-relax" && para.input.cell_factor < 2.0) + { + para.input.cell_factor = 2.0; // follows QE + } + }; this->add_item(item); } { Input_Item item("pw_seed"); item.annotation = "random seed for initializing wave functions"; - read_sync_int(pw_seed); + read_sync_int(input.pw_seed); this->add_item(item); } } diff --git a/source/module_io/read_input_item_relax.cpp b/source/module_io/read_input_item_relax.cpp index 22e3f4332c..818dcab26b 100644 --- a/source/module_io/read_input_item_relax.cpp +++ b/source/module_io/read_input_item_relax.cpp @@ -10,7 +10,7 @@ void ReadInput::item_relax() { Input_Item item("ks_solver"); item.annotation = "cg; dav; lapack; genelpa; scalapack_gvx; cusolver"; - read_sync_string(ks_solver); + read_sync_string(input.ks_solver); item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.ks_solver == "default") { @@ -144,7 +144,7 @@ void ReadInput::item_relax() { Input_Item item("scf_nmax"); item.annotation = "number of electron iterations"; - read_sync_int(scf_nmax); + read_sync_int(input.scf_nmax); this->add_item(item); } { @@ -166,7 +166,7 @@ void ReadInput::item_relax() } } }; - read_sync_int(relax_nmax); + read_sync_int(input.relax_nmax); this->add_item(item); } { @@ -179,13 +179,13 @@ void ReadInput::item_relax() para.input.out_stru = false; } }; - read_sync_bool(out_stru); + read_sync_bool(input.out_stru); this->add_item(item); } { Input_Item item("force_thr"); item.annotation = "force threshold, unit: Ry/Bohr"; - // read_sync_double(force_thr); + // read_sync_double(input.force_thr); item.read_value = [](const Input_Item& item, Parameter& para) { para.input.force_thr = doublevalue; }; item.reset_value = [](const Input_Item& item, Parameter& para) { if (para.input.force_thr == -1 && para.input.force_thr_ev == -1) @@ -203,81 +203,83 @@ void ReadInput::item_relax() ModuleBase::WARNING("ReadInput", "both force_thr and force_thr_ev are set, use force_thr"); para.input.force_thr_ev = para.input.force_thr * 13.6058 / 0.529177; } + para.input.mdp.force_thr = para.input.force_thr; // temperaory }; - sync_double(force_thr); + sync_double(input.force_thr); + add_double_bcast(input.mdp.force_thr); this->add_item(item); } { Input_Item item("force_thr_ev"); item.annotation = "force threshold, unit: eV/Angstrom"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.force_thr_ev = doublevalue; }; - sync_double(force_thr_ev); + sync_double(input.force_thr_ev); this->add_item(item); } { Input_Item item("force_thr_ev2"); item.annotation = "force invalid threshold, unit: eV/Angstrom"; - read_sync_double(force_thr_ev2); + read_sync_double(input.force_thr_ev2); this->add_item(item); } { Input_Item item("relax_cg_thr"); item.annotation = "threshold for switching from cg to bfgs, unit: eV/Angstrom"; - read_sync_double(relax_cg_thr); + read_sync_double(input.relax_cg_thr); this->add_item(item); } { Input_Item item("stress_thr"); item.annotation = "stress threshold"; - read_sync_double(stress_thr); + read_sync_double(input.stress_thr); this->add_item(item); } { Input_Item item("press1"); item.annotation = "target pressure, unit: KBar"; - read_sync_double(press1); + read_sync_double(input.press1); this->add_item(item); } { Input_Item item("press2"); item.annotation = "target pressure, unit: KBar"; - read_sync_double(press2); + read_sync_double(input.press2); this->add_item(item); } { Input_Item item("press3"); item.annotation = "target pressure, unit: KBar"; - read_sync_double(press3); + read_sync_double(input.press3); this->add_item(item); } { Input_Item item("relax_bfgs_w1"); item.annotation = "wolfe condition 1 for bfgs"; - read_sync_double(relax_bfgs_w1); + read_sync_double(input.relax_bfgs_w1); this->add_item(item); } { Input_Item item("relax_bfgs_w2"); item.annotation = "wolfe condition 2 for bfgs"; - read_sync_double(relax_bfgs_w2); + read_sync_double(input.relax_bfgs_w2); this->add_item(item); } { Input_Item item("relax_bfgs_rmax"); item.annotation = "maximal trust radius, unit: Bohr"; - read_sync_double(relax_bfgs_rmax); + read_sync_double(input.relax_bfgs_rmax); this->add_item(item); } { Input_Item item("relax_bfgs_rmin"); item.annotation = "minimal trust radius, unit: Bohr"; - read_sync_double(relax_bfgs_rmin); + read_sync_double(input.relax_bfgs_rmin); this->add_item(item); } { Input_Item item("relax_bfgs_init"); item.annotation = "initial trust radius, unit: Bohr"; - read_sync_double(relax_bfgs_init); + read_sync_double(input.relax_bfgs_init); this->add_item(item); } { @@ -296,33 +298,57 @@ void ReadInput::item_relax() { para.input.cal_stress = true; } + para.input.mdp.cal_stress = para.input.cal_stress; // temperaory }; - read_sync_bool(cal_stress); + read_sync_bool(input.cal_stress); + add_bool_bcast(input.mdp.cal_stress); this->add_item(item); } { Input_Item item("fixed_axes"); item.annotation = "which axes are fixed"; - read_sync_string(fixed_axes); + read_sync_string(input.fixed_axes); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if ((para.input.fixed_axes == "shape" || para.input.fixed_axes == "volume") && !para.input.relax_new) + { + ModuleBase::WARNING_QUIT("ReadInput", "fixed shape and fixed volume only supported for relax_new = 1"); + } + }; this->add_item(item); } { Input_Item item("fixed_ibrav"); item.annotation = "whether to preseve lattice type during relaxation"; - read_sync_bool(fixed_ibrav); + read_sync_bool(input.fixed_ibrav); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.fixed_ibrav && !para.input.relax_new) + { + ModuleBase::WARNING_QUIT("ReadInput", "fixed_ibrav only available for relax_new = 1"); + } + if (para.input.latname == "none" && para.input.fixed_ibrav) + { + ModuleBase::WARNING_QUIT("ReadInput", "to use fixed_ibrav, latname must be provided"); + } + }; this->add_item(item); } { Input_Item item("fixed_atoms"); item.annotation = "whether to preseve direct coordinates of atoms " "during relaxation"; - read_sync_bool(fixed_atoms); + read_sync_bool(input.fixed_atoms); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.fixed_atoms && para.input.calculation == "relax") + { + ModuleBase::WARNING_QUIT("ReadInput", "fixed_atoms is not meant to be used for calculation = relax"); + } + }; this->add_item(item); } { Input_Item item("relax_method"); item.annotation = "cg; bfgs; sd; cg; cg_bfgs;"; - read_sync_string(relax_method); + read_sync_string(input.relax_method); item.check_value = [](const Input_Item& item, const Parameter& para) { const std::vector relax_methods = {"cg", "bfgs", "sd", "cg_bfgs"}; if (!find_str(relax_methods, para.input.relax_method)) @@ -335,13 +361,19 @@ void ReadInput::item_relax() { Input_Item item("relax_new"); item.annotation = "whether to use the new relaxation method"; - read_sync_bool(relax_new); + read_sync_bool(input.relax_new); + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.relax_new && para.input.relax_method != "cg") + { + para.input.relax_new = false; + } + }; this->add_item(item); } { Input_Item item("relax_scale_force"); item.annotation = "controls the size of the first CG step if relax_new is true"; - read_sync_double(relax_scale_force); + read_sync_double(input.relax_scale_force); this->add_item(item); } { @@ -349,16 +381,15 @@ void ReadInput::item_relax() item.annotation = "ie(for electrons); i(for ions);"; item.read_value = [](const Input_Item& item, Parameter& para) { para.input.out_level = strvalue; - para.input.sup.out_md_control = true; + para.sys.out_md_control = true; }; item.reset_value = [](const Input_Item& item, Parameter& para) { - if (!para.input.sup.out_md_control && para.input.calculation == "md") + if (!para.sys.out_md_control && para.input.calculation == "md") { para.input.out_level = "m"; // zhengdy add 2019-04-07 } }; - sync_string(out_level); - add_bool_bcast(sup.out_md_control); + sync_string(input.out_level); this->add_item(item); } { @@ -371,12 +402,12 @@ void ReadInput::item_relax() } }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.sup.gamma_only_local == false && para.input.out_dm) + if (para.sys.gamma_only_local == false && para.input.out_dm) { ModuleBase::WARNING_QUIT("ReadInput", "out_dm with k-point algorithm is not implemented yet."); } }; - read_sync_bool(out_dm); + read_sync_bool(input.out_dm); this->add_item(item); } { @@ -389,24 +420,24 @@ void ReadInput::item_relax() } }; item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.sup.gamma_only_local == true && para.input.out_dm1) + if (para.sys.gamma_only_local == true && para.input.out_dm1) { ModuleBase::WARNING_QUIT("ReadInput", "out_dm1 is only for multi-k"); } }; - read_sync_bool(out_dm1); + read_sync_bool(input.out_dm1); this->add_item(item); } { Input_Item item("out_bandgap"); item.annotation = "if true, print out bandgap"; - read_sync_bool(out_bandgap); + read_sync_bool(input.out_bandgap); this->add_item(item); } { Input_Item item("use_paw"); item.annotation = "whether to use PAW in pw calculation"; - read_sync_bool(use_paw); + read_sync_bool(input.use_paw); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.use_paw) { @@ -428,44 +459,44 @@ void ReadInput::item_relax() { Input_Item item("deepks_out_labels"); item.annotation = ">0 compute descriptor for deepks"; - read_sync_bool(deepks_out_labels); + read_sync_bool(input.deepks_out_labels); this->add_item(item); } { Input_Item item("deepks_scf"); item.annotation = ">0 add V_delta to Hamiltonian"; - read_sync_bool(deepks_scf); + read_sync_bool(input.deepks_scf); this->add_item(item); } { Input_Item item("deepks_equiv"); item.annotation = "whether to use equivariant version of DeePKS"; - read_sync_bool(deepks_equiv); + read_sync_bool(input.deepks_equiv); this->add_item(item); } { Input_Item item("deepks_bandgap"); item.annotation = ">0 for bandgap label"; - read_sync_bool(deepks_bandgap); + read_sync_bool(input.deepks_bandgap); this->add_item(item); } { Input_Item item("deepks_v_delta"); item.annotation = ">0 for v_delta label. when output, 1 for v_delta_precalc, 2 for psialpha and grad_evdm ( can save memory )"; - read_sync_int(deepks_v_delta); + read_sync_int(input.deepks_v_delta); this->add_item(item); } { Input_Item item("deepks_out_unittest"); item.annotation = "if set 1, prints intermediate quantities that shall " "be used for making unit test"; - read_sync_bool(deepks_out_unittest); + read_sync_bool(input.deepks_out_unittest); this->add_item(item); } { Input_Item item("deepks_model"); item.annotation = "file dir of traced pytorch model: 'model.ptg"; - read_sync_string(deepks_model); + read_sync_string(input.deepks_model); this->add_item(item); } } diff --git a/source/module_io/read_input_item_sdft.cpp b/source/module_io/read_input_item_sdft.cpp index d33cfd9748..69db574320 100644 --- a/source/module_io/read_input_item_sdft.cpp +++ b/source/module_io/read_input_item_sdft.cpp @@ -10,7 +10,7 @@ void ReadInput::item_sdft() { Input_Item item("method_sto"); item.annotation = "1: slow and save memory, 2: fast and waste memory"; - read_sync_int(method_sto); + read_sync_int(input.method_sto); item.check_value = [](const Input_Item& item, const Parameter& para) { if (para.input.method_sto != 1 && para.input.method_sto != 2) { @@ -22,7 +22,7 @@ void ReadInput::item_sdft() { Input_Item item("npart_sto"); item.annotation = "Reduce memory when calculating Stochastic DOS"; - read_sync_int(npart_sto); + read_sync_int(input.npart_sto); this->add_item(item); } { @@ -66,99 +66,99 @@ void ReadInput::item_sdft() item.final_value << item.str_values[0]; } }; - add_int_bcast(nbands_sto); + add_int_bcast(input.nbands_sto); this->add_item(item); } { Input_Item item("nche_sto"); item.annotation = "Chebyshev expansion orders"; - read_sync_int(nche_sto); + read_sync_int(input.nche_sto); this->add_item(item); } { Input_Item item("emin_sto"); item.annotation = "trial energy to guess the lower bound of eigen " "energies of the Hamitonian operator"; - read_sync_double(emin_sto); + read_sync_double(input.emin_sto); this->add_item(item); } { Input_Item item("emax_sto"); item.annotation = "trial energy to guess the upper bound of eigen " "energies of the Hamitonian operator"; - read_sync_double(emax_sto); + read_sync_double(input.emax_sto); this->add_item(item); } { Input_Item item("seed_sto"); item.annotation = "the random seed to generate stochastic orbitals"; - read_sync_int(seed_sto); + read_sync_int(input.seed_sto); this->add_item(item); } { Input_Item item("initsto_ecut"); item.annotation = "maximum ecut to init stochastic bands"; - read_sync_double(initsto_ecut); + read_sync_double(input.initsto_ecut); this->add_item(item); } { Input_Item item("initsto_freq"); item.annotation = "frequency to generate new stochastic orbitals when running md"; - read_sync_int(initsto_freq); + read_sync_int(input.initsto_freq); this->add_item(item); } { Input_Item item("cal_cond"); item.annotation = "calculate electronic conductivities"; - read_sync_bool(cal_cond); + read_sync_bool(input.cal_cond); this->add_item(item); } { Input_Item item("cond_che_thr"); item.annotation = "control the error of Chebyshev expansions for conductivities"; - read_sync_double(cond_che_thr); + read_sync_double(input.cond_che_thr); this->add_item(item); } { Input_Item item("cond_dw"); item.annotation = "frequency interval for conductivities"; - read_sync_double(cond_dw); + read_sync_double(input.cond_dw); this->add_item(item); } { Input_Item item("cond_wcut"); item.annotation = "cutoff frequency (omega) for conductivities"; - read_sync_double(cond_wcut); + read_sync_double(input.cond_wcut); this->add_item(item); } { Input_Item item("cond_dt"); item.annotation = "t interval to integrate Onsager coefficiencies"; - read_sync_double(cond_dt); + read_sync_double(input.cond_dt); this->add_item(item); } { Input_Item item("cond_dtbatch"); item.annotation = "exp(iH*dt*cond_dtbatch) is expanded with Chebyshev expansion"; - read_sync_int(cond_dtbatch); + read_sync_int(input.cond_dtbatch); this->add_item(item); } { Input_Item item("cond_smear"); item.annotation = "Smearing method for conductivities"; - read_sync_int(cond_smear); + read_sync_int(input.cond_smear); this->add_item(item); } { Input_Item item("cond_fwhm"); item.annotation = "FWHM for conductivities"; - read_sync_double(cond_fwhm); + read_sync_double(input.cond_fwhm); this->add_item(item); } { Input_Item item("cond_nonlocal"); item.annotation = "Nonlocal effects for conductivities"; - read_sync_bool(cond_nonlocal); + read_sync_bool(input.cond_nonlocal); this->add_item(item); } } diff --git a/source/module_io/read_input_tool.h b/source/module_io/read_input_tool.h index ffb7a1f4e1..ce564fe7e4 100644 --- a/source/module_io/read_input_tool.h +++ b/source/module_io/read_input_tool.h @@ -14,42 +14,48 @@ #ifdef __MPI #define add_double_bcast(PARAMETER) \ { \ - bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_double(para.input.PARAMETER); }); \ + bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_double(para.PARAMETER); }); \ } #define add_int_bcast(PARAMETER) \ { \ - bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_int(para.input.PARAMETER); }); \ + bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_int(para.PARAMETER); }); \ } #define add_bool_bcast(PARAMETER) \ { \ - bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_bool(para.input.PARAMETER); }); \ + bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_bool(para.PARAMETER); }); \ } #define add_string_bcast(PARAMETER) \ { \ - bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_string(para.input.PARAMETER); }); \ + bcastfuncs.push_back([](Parameter& para) { Parallel_Common::bcast_string(para.PARAMETER); }); \ } #define add_doublevec_bcast(PARAMETER, N, FILL) \ { \ bcastfuncs.push_back([](Parameter& para) { \ - if (para.input.PARAMETER.size() != N) \ - para.input.PARAMETER.resize(N, FILL); \ - Parallel_Common::bcast_double(para.input.PARAMETER.data(), N); \ + int _vec_size = N; \ + Parallel_Common::bcast_int(_vec_size); \ + if (para.PARAMETER.size() != _vec_size) \ + para.PARAMETER.resize(_vec_size, FILL); \ + Parallel_Common::bcast_double(para.PARAMETER.data(), _vec_size); \ }); \ } #define add_intvec_bcast(PARAMETER, N, FILL) \ { \ bcastfuncs.push_back([](Parameter& para) { \ - if (para.input.PARAMETER.size() != N) \ - para.input.PARAMETER.resize(N, FILL); \ - Parallel_Common::bcast_int(para.input.PARAMETER.data(), N); \ + int _vec_size = N; \ + Parallel_Common::bcast_int(_vec_size); \ + if (para.PARAMETER.size() != _vec_size) \ + para.PARAMETER.resize(_vec_size, FILL); \ + Parallel_Common::bcast_int(para.PARAMETER.data(), _vec_size); \ }); \ } #define add_stringvec_bcast(PARAMETER, N, FILL) \ { \ bcastfuncs.push_back([](Parameter& para) { \ - if (para.input.PARAMETER.size() != N) \ - para.input.PARAMETER.resize(N, FILL); \ - Parallel_Common::bcast_string(para.input.PARAMETER.data(), N); \ + int _vec_size = N; \ + Parallel_Common::bcast_int(_vec_size); \ + if (para.PARAMETER.size() != _vec_size) \ + para.PARAMETER.resize(_vec_size, FILL); \ + Parallel_Common::bcast_string(para.PARAMETER.data(), _vec_size); \ }); \ } @@ -61,8 +67,8 @@ #define add_doublevec_bcast(PARAMETER, N, FILL) \ { \ bcastfuncs.push_back([](Parameter& para) { \ - if (para.input.PARAMETER.size() != N) \ - para.input.PARAMETER.resize(N, FILL); \ + if (para.PARAMETER.size() != N) \ + para.PARAMETER.resize(N, FILL); \ }); \ } @@ -73,54 +79,50 @@ #define sync_string(PARAMETER) \ { \ - item.get_final_value \ - = [](Input_Item& item, const Parameter& para) { item.final_value << para.input.PARAMETER; }; \ + item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \ add_string_bcast(PARAMETER); \ } #define sync_int(PARAMETER) \ { \ - item.get_final_value \ - = [](Input_Item& item, const Parameter& para) { item.final_value << para.input.PARAMETER; }; \ + item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \ add_int_bcast(PARAMETER); \ } #define sync_double(PARAMETER) \ { \ - item.get_final_value \ - = [](Input_Item& item, const Parameter& para) { item.final_value << para.input.PARAMETER; }; \ + item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \ add_double_bcast(PARAMETER); \ } #define sync_bool(PARAMETER) \ { \ - item.get_final_value \ - = [](Input_Item& item, const Parameter& para) { item.final_value << para.input.PARAMETER; }; \ + item.get_final_value = [](Input_Item& item, const Parameter& para) { item.final_value << para.PARAMETER; }; \ add_bool_bcast(PARAMETER); \ } #define sync_doublevec(PARAMETER, N, FILL) \ { \ - item.get_final_value = [](Input_Item& item, const Parameter& para) { \ + item.get_final_value = [](Input_Item& item, const Parameter& para) { \ for (int i = 0; i < N; i++) \ { \ - item.final_value << para.input.PARAMETER[i] << " "; \ + item.final_value << para.PARAMETER[i] << " "; \ } \ }; \ add_doublevec_bcast(PARAMETER, N, FILL); \ } #define sync_intvec(PARAMETER, N, FILL) \ { \ - item.get_final_value = [](Input_Item& item, const Parameter& para) { \ + item.get_final_value = [](Input_Item& item, const Parameter& para) { \ for (int i = 0; i < N; i++) \ { \ - item.final_value << para.input.PARAMETER[i] << " "; \ + item.final_value << para.PARAMETER[i] << " "; \ } \ }; \ add_intvec_bcast(PARAMETER, N, FILL); \ } #define sync_stringvec(PARAMETER, N, FILL) \ { \ - item.get_final_value = [](Input_Item& item, const Parameter& para) { \ + item.get_final_value = [](Input_Item& item, const Parameter& para) { \ for (int i = 0; i < N; i++) \ { \ - item.final_value << para.input.PARAMETER[i] << " "; \ + item.final_value << para.PARAMETER[i] << " "; \ } \ }; \ add_stringvec_bcast(PARAMETER, N, FILL); \ @@ -128,21 +130,21 @@ #define read_sync_string(PARAMETER) \ { \ - item.read_value = [](const Input_Item& item, Parameter& para) { para.input.PARAMETER = strvalue; }; \ + item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = strvalue; }; \ sync_string(PARAMETER); \ } #define read_sync_int(PARAMETER) \ { \ - item.read_value = [](const Input_Item& item, Parameter& para) { para.input.PARAMETER = intvalue; }; \ + item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = intvalue; }; \ sync_int(PARAMETER); \ } #define read_sync_double(PARAMETER) \ { \ - item.read_value = [](const Input_Item& item, Parameter& para) { para.input.PARAMETER = doublevalue; }; \ + item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = doublevalue; }; \ sync_double(PARAMETER); \ } #define read_sync_bool(PARAMETER) \ { \ - item.read_value = [](const Input_Item& item, Parameter& para) { para.input.PARAMETER = boolvalue; }; \ + item.read_value = [](const Input_Item& item, Parameter& para) { para.PARAMETER = boolvalue; }; \ sync_bool(PARAMETER); \ } diff --git a/source/module_io/test/input_conv_test.cpp b/source/module_io/test/input_conv_test.cpp deleted file mode 100644 index f466eb5895..0000000000 --- a/source/module_io/test/input_conv_test.cpp +++ /dev/null @@ -1,540 +0,0 @@ -#include "module_io/input_conv.h" - -#include "for_testing_input_conv.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" -#include "module_base/global_variable.h" -#include "module_hsolver/diago_elpa.h" -#include "module_hsolver/hsolver_pw.h" - -/************************************************ - * unit test of input_conv.cpp - ***********************************************/ - -/** - * - Tested Functions: - * - Convert() - */ - -#define private public -#include "module_io/input.h" - -class InputConvTest : public testing::Test -{ - protected: - std::string output; -}; - -TEST_F(InputConvTest, Conv) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - Input_Conv::Convert(); - EXPECT_EQ(GlobalV::stru_file, INPUT.stru_file); - EXPECT_EQ(GlobalV::global_wannier_card, "none"); - EXPECT_EQ(GlobalV::global_kpoint_card, INPUT.kpoint_file); - EXPECT_EQ(GlobalV::global_pseudo_dir, INPUT.pseudo_dir + "/"); - EXPECT_EQ(GlobalV::global_orbital_dir, INPUT.orbital_dir + "/"); - EXPECT_EQ(GlobalC::ucell.latName, "none"); - EXPECT_EQ(GlobalC::ucell.ntype, 1); - EXPECT_EQ(GlobalC::ucell.init_vel, false); - EXPECT_EQ(GlobalC::ucell.lc[0], 1); - EXPECT_EQ(GlobalC::ucell.lc[1], 1); - EXPECT_EQ(GlobalC::ucell.lc[2], 1); - EXPECT_EQ(GlobalV::KSPACING[0], 0.0); - EXPECT_EQ(GlobalV::KSPACING[1], 0.0); - EXPECT_EQ(GlobalV::KSPACING[2], 0.0); - EXPECT_DOUBLE_EQ(GlobalV::MIN_DIST_COEF, 0.2); - EXPECT_EQ(GlobalV::NBANDS, 8); - EXPECT_EQ(GlobalV::NBANDS_ISTATE, 5); - EXPECT_EQ(GlobalV::device_flag, "cpu"); - EXPECT_EQ(GlobalV::KPAR, 1); - EXPECT_EQ(GlobalV::NSTOGROUP, 1); - EXPECT_EQ(GlobalV::precision_flag, "double"); - EXPECT_EQ(GlobalV::CALCULATION, "scf"); - EXPECT_EQ(GlobalV::ESOLVER_TYPE, "ksdft"); - EXPECT_DOUBLE_EQ(GlobalV::PSEUDORCUT, 15.0); - EXPECT_EQ(GlobalV::PSEUDO_MESH, false); - EXPECT_EQ(GlobalV::DFT_FUNCTIONAL, "hse"); - EXPECT_DOUBLE_EQ(GlobalV::XC_TEMPERATURE, 0.0); - EXPECT_EQ(GlobalV::NSPIN, 1); - EXPECT_EQ(GlobalV::CAL_FORCE, 0); - EXPECT_NEAR(GlobalV::FORCE_THR, 0.001, 0.0000001); - EXPECT_DOUBLE_EQ(GlobalV::STRESS_THR, 0.01); - EXPECT_EQ(GlobalV::PRESS1, 0); - EXPECT_EQ(GlobalV::PRESS2, 0); - EXPECT_EQ(GlobalV::PRESS3, 0); - EXPECT_EQ(GlobalV::out_element_info, 0); - EXPECT_EQ(Force_Stress_LCAO::force_invalid_threshold_ev, 0); - EXPECT_EQ(Force_Stress_LCAO>::force_invalid_threshold_ev, 0); - EXPECT_DOUBLE_EQ(BFGS_Basic::relax_bfgs_w1, 0.01); - EXPECT_DOUBLE_EQ(BFGS_Basic::relax_bfgs_w2, 0.5); - EXPECT_DOUBLE_EQ(Ions_Move_Basic::relax_bfgs_rmax, 0.8); - EXPECT_DOUBLE_EQ(Ions_Move_Basic::relax_bfgs_rmin, 0.00001); - EXPECT_EQ(Ions_Move_Basic::relax_bfgs_init, 0.5); - EXPECT_EQ(Ions_Move_Basic::out_stru, 0); - EXPECT_EQ(Lattice_Change_Basic::fixed_axes, "None"); - EXPECT_EQ(GlobalV::CAL_STRESS, 0); - EXPECT_EQ(GlobalV::RELAX_METHOD, "cg"); - EXPECT_DOUBLE_EQ(GlobalV::relax_scale_force, 0.5); - EXPECT_EQ(GlobalV::relax_new, true); - EXPECT_EQ(GlobalV::OUT_LEVEL, "ie"); - EXPECT_DOUBLE_EQ(Ions_Move_CG::RELAX_CG_THR, 0.5); - EXPECT_EQ(ModuleSymmetry::Symmetry::symm_flag, 1); - EXPECT_EQ(GlobalV::BASIS_TYPE, "lcao"); - EXPECT_EQ(GlobalV::KS_SOLVER, "genelpa"); - EXPECT_EQ(GlobalV::SEARCH_RADIUS, -1); - EXPECT_EQ(GlobalV::SEARCH_PBC, 1); - EXPECT_EQ(GlobalV::GAMMA_ONLY_LOCAL, true); - EXPECT_EQ(GlobalV::DIAGO_PROC, 4); - EXPECT_EQ(GlobalV::PW_DIAG_NMAX, 50); - EXPECT_EQ(GlobalV::DIAGO_CG_PREC, 1); - EXPECT_EQ(GlobalV::PW_DIAG_NDIM, 4); - EXPECT_EQ(hsolver::HSolverPW>::diago_full_acc, false); - EXPECT_EQ(hsolver::HSolverPW>::diago_full_acc, false); - EXPECT_DOUBLE_EQ(GlobalV::PW_DIAG_THR, 0.01); - EXPECT_EQ(GlobalV::NB2D, 0); - EXPECT_EQ(GlobalV::NURSE, 0); - EXPECT_EQ(GlobalV::COLOUR, 0); - EXPECT_EQ(GlobalV::T_IN_H, 1); - EXPECT_EQ(GlobalV::VL_IN_H, 1); - EXPECT_EQ(GlobalV::VNL_IN_H, 1); - EXPECT_EQ(GlobalV::VH_IN_H, 1); - EXPECT_EQ(GlobalV::VION_IN_H, 1); - EXPECT_EQ(GlobalV::TEST_FORCE, 0); - EXPECT_EQ(GlobalV::TEST_STRESS, 0); - EXPECT_EQ(GlobalV::test_skip_ewald, 0); - EXPECT_DOUBLE_EQ(GlobalV::SCF_THR, 0.00000001); - EXPECT_EQ(GlobalV::SCF_THR_TYPE, 2); - EXPECT_EQ(GlobalV::LSPINORB, false); - EXPECT_EQ(GlobalV::NONCOLIN, false); - EXPECT_EQ(GlobalV::DOMAG, false); - EXPECT_EQ(GlobalV::DOMAG_Z, false); - EXPECT_EQ(GlobalV::NPOL, 1); - EXPECT_EQ(GlobalV::EFIELD_FLAG, 0); - EXPECT_EQ(GlobalV::DIP_COR_FLAG, 0); - EXPECT_EQ(elecstate::Efield::efield_dir, 2); - EXPECT_DOUBLE_EQ(elecstate::Efield::efield_pos_max, 0.5); - EXPECT_DOUBLE_EQ(elecstate::Efield::efield_pos_dec, 0.1); - EXPECT_EQ(elecstate::Efield::efield_amp, 0); - EXPECT_EQ(GlobalV::GATE_FLAG, 0); - EXPECT_EQ(GlobalV::nelec, 0); - EXPECT_EQ(GlobalV::nelec_delta, 0); - EXPECT_DOUBLE_EQ(elecstate::Gatefield::zgate, 0.5); - EXPECT_EQ(elecstate::Gatefield::relax, 0); - EXPECT_EQ(elecstate::Gatefield::block, 0); - EXPECT_DOUBLE_EQ(elecstate::Gatefield::block_down, 0.45); - EXPECT_DOUBLE_EQ(elecstate::Gatefield::block_up, 0.55); - EXPECT_DOUBLE_EQ(elecstate::Gatefield::block_height, 0.1); - EXPECT_EQ(module_tddft::Evolve_elec::td_force_dt, 0.02); - EXPECT_EQ(module_tddft::Evolve_elec::td_vext, false); - EXPECT_EQ(module_tddft::Evolve_elec::out_dipole, false); - EXPECT_EQ(module_tddft::Evolve_elec::out_efield, false); - EXPECT_EQ(module_tddft::Evolve_elec::td_print_eij, -1.0); - EXPECT_EQ(module_tddft::Evolve_elec::td_edm, 0); - EXPECT_EQ(GlobalV::ocp, false); - EXPECT_EQ(GlobalV::ocp_set, INPUT.ocp_set); - EXPECT_EQ(GlobalV::out_mul, 0); - EXPECT_EQ(GlobalC::ppcell.cell_factor, 1.2); - EXPECT_EQ(GlobalV::SCF_NMAX, 50); - EXPECT_EQ(GlobalV::RELAX_NMAX, 1); - EXPECT_EQ(GlobalV::OUT_FREQ_ELEC, 0); - EXPECT_EQ(GlobalV::OUT_FREQ_ION, 0); - EXPECT_EQ(GlobalV::init_chg, "atomic"); - EXPECT_EQ(GlobalV::chg_extrap, "atomic"); - EXPECT_EQ(GlobalV::out_chg, 0); - EXPECT_EQ(GlobalV::out_pot, 2); - EXPECT_EQ(GlobalV::out_app_flag, false); - EXPECT_EQ(GlobalV::out_bandgap, false); - EXPECT_EQ(hsolver::HSolverLCAO::out_mat_hs[0], false); - EXPECT_EQ(hsolver::HSolverLCAO>::out_mat_hs[0], false); - EXPECT_EQ(hsolver::HSolverLCAO::out_mat_hsR, false); - EXPECT_EQ(hsolver::HSolverLCAO>::out_mat_hsR, false); - EXPECT_EQ(hsolver::HSolverLCAO::out_mat_t, false); - EXPECT_EQ(hsolver::HSolverLCAO>::out_mat_t, false); - EXPECT_EQ(hsolver::HSolverLCAO::out_mat_dh, INPUT.out_mat_dh); - EXPECT_EQ(hsolver::HSolverLCAO>::out_mat_dh, INPUT.out_mat_dh); - EXPECT_EQ(hsolver::DiagoElpa::elpa_num_thread, -1); - EXPECT_EQ(hsolver::DiagoElpa>::elpa_num_thread, -1); - EXPECT_EQ(GlobalV::out_interval, 1); - EXPECT_EQ(elecstate::ElecStateLCAO::out_wfc_lcao, false); - EXPECT_EQ(berryphase::berry_phase_flag, false); - EXPECT_EQ(GlobalV::imp_sol, false); - EXPECT_EQ(GlobalV::eb_k, 80); - EXPECT_EQ(GlobalV::tau, INPUT.tau); - EXPECT_EQ(GlobalV::sigma_k, 0.6); - EXPECT_EQ(GlobalV::sigma_k, 0.6); - EXPECT_EQ(GlobalV::nc_k, 0.00037); - EXPECT_EQ(GlobalV::global_readin_dir, GlobalV::global_out_dir); - EXPECT_EQ(GlobalV::sc_mag_switch, 0); - - EXPECT_TRUE(GlobalV::decay_grad_switch); - EXPECT_EQ(GlobalV::sc_file, "sc.json"); - EXPECT_EQ(GlobalV::MIXING_RESTART, 0.0); - EXPECT_EQ(GlobalV::MIXING_DMR, false); - - EXPECT_EQ(GlobalV::NUM_STREAM, 4); -} - -TEST_F(InputConvTest, ConvRelax) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.calculation = "relax"; - INPUT.fixed_ibrav = true; - INPUT.relax_new = false; - std::string output2; - testing::internal::CaptureStdout(); - EXPECT_EXIT(Input_Conv::Convert(), ::testing::ExitedWithCode(0), ""); - output2 = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output2, testing::HasSubstr("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")); - EXPECT_THAT(output2, testing::HasSubstr(" NOTICE ")); - EXPECT_THAT(output2, testing::HasSubstr("fixed_ibrav only available for relax_new = 1")); - EXPECT_THAT(output2, testing::HasSubstr("CHECK IN FILE : warning.log")); - EXPECT_THAT(output2, testing::HasSubstr("TIME STATISTICS")); - INPUT.Read(input_file); - INPUT.calculation = "relax"; - INPUT.latname = "none"; - INPUT.fixed_ibrav = true; - testing::internal::CaptureStdout(); - EXPECT_EXIT(Input_Conv::Convert(), ::testing::ExitedWithCode(0), ""); - output2 = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output2, testing::HasSubstr("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")); - EXPECT_THAT(output2, testing::HasSubstr(" NOTICE ")); - EXPECT_THAT(output2, testing::HasSubstr("to use fixed_ibrav, latname must be provided")); - EXPECT_THAT(output2, testing::HasSubstr("CHECK IN FILE : warning.log")); - EXPECT_THAT(output2, testing::HasSubstr("TIME STATISTICS")); - INPUT.Read(input_file); - INPUT.calculation = "relax"; - INPUT.fixed_atoms = true; - testing::internal::CaptureStdout(); - EXPECT_EXIT(Input_Conv::Convert(), ::testing::ExitedWithCode(0), ""); - output2 = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output2, testing::HasSubstr("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")); - EXPECT_THAT(output2, testing::HasSubstr(" NOTICE ")); - EXPECT_THAT(output2, testing::HasSubstr("fixed_atoms is not meant to be used for calculation = relax")); - EXPECT_THAT(output2, testing::HasSubstr("CHECK IN FILE : warning.log")); - EXPECT_THAT(output2, testing::HasSubstr("TIME STATISTICS")); - INPUT.Read(input_file); - INPUT.calculation = "relax"; - INPUT.relax_new = false; - INPUT.fixed_axes = "shape"; - testing::internal::CaptureStdout(); - EXPECT_EXIT(Input_Conv::Convert(), ::testing::ExitedWithCode(0), ""); - output2 = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output2, testing::HasSubstr("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")); - EXPECT_THAT(output2, testing::HasSubstr(" NOTICE ")); - EXPECT_THAT(output2, testing::HasSubstr("fixed shape and fixed volume only supported for relax_new = 1")); - EXPECT_THAT(output2, testing::HasSubstr("CHECK IN FILE : warning.log")); - EXPECT_THAT(output2, testing::HasSubstr("TIME STATISTICS")); - INPUT.Default(); - INPUT.Read(input_file); - INPUT.calculation = "relax"; - INPUT.relax_new = true; - INPUT.relax_method = "sd"; - Input_Conv::Convert(); - EXPECT_EQ(INPUT.relax_new, false); -} - -TEST_F(InputConvTest, ConvGpu) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.device = "gpu"; - INPUT.ks_solver = "cg"; // lapack - INPUT.basis_type = "pw"; // LCAO - std::string output2; - testing::internal::CaptureStdout(); - EXPECT_EXIT(Input_Conv::Convert(), ::testing::ExitedWithCode(0), ""); - output2 = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output2, testing::HasSubstr("The GPU is not supported in this build!")); -} - -TEST_F(InputConvTest, dftplus) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.dft_plus_u = 1; - Input_Conv::Convert(); - EXPECT_EQ(GlobalV::dft_plus_u, 1); - EXPECT_EQ(GlobalC::dftu.Yukawa, false); - EXPECT_EQ(GlobalC::dftu.omc, false); // - EXPECT_EQ(GlobalC::dftu.orbital_corr, INPUT.orbital_corr); - EXPECT_EQ(GlobalC::dftu.mixing_dftu, false); - EXPECT_EQ(GlobalC::dftu.U, INPUT.hubbard_u); -} - -TEST_F(InputConvTest, nspin) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.noncolin = true; - INPUT.gamma_only_local = false; - Input_Conv::Convert(); - EXPECT_EQ(GlobalV::NSPIN, 4); - EXPECT_EQ(GlobalV::NONCOLIN, true); - EXPECT_EQ(GlobalV::NPOL, 2); - EXPECT_EQ(GlobalV::DOMAG, false); - EXPECT_EQ(GlobalV::DOMAG_Z, true); - EXPECT_EQ(GlobalV::LSPINORB, false); - EXPECT_EQ(GlobalV::soc_lambda, INPUT.soc_lambda); -} - -TEST_F(InputConvTest, nupdown) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - Input_Conv::Convert(); -} - -TEST_F(InputConvTest, restart_save) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.restart_save = true; - GlobalV::MY_RANK = 0; - INPUT.dft_functional = "hf"; - Input_Conv::Convert(); - EXPECT_EQ(GlobalC::restart.folder, GlobalV::global_readin_dir + "restart/"); - int a = access(GlobalC::restart.folder.c_str(), 0); - EXPECT_EQ(a, 0); - EXPECT_EQ(GlobalC::restart.info_save.save_charge, true); - EXPECT_EQ(GlobalC::restart.info_save.save_H, true); -} - -TEST_F(InputConvTest, restart_save2) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.restart_save = true; - INPUT.dft_functional = "default"; - Input_Conv::Convert(); - EXPECT_EQ(GlobalC::restart.info_save.save_charge, true); -} - -TEST_F(InputConvTest, restart_load) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.restart_load = true; - INPUT.dft_functional = "hf"; - Input_Conv::Convert(); - EXPECT_EQ(GlobalC::restart.folder, GlobalV::global_readin_dir + "restart/"); - EXPECT_EQ(GlobalC::restart.info_load.load_charge, true); - EXPECT_EQ(GlobalC::restart.info_load.load_H, true); -} - -TEST_F(InputConvTest, restart_load2) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.restart_load = true; - INPUT.dft_functional = "b3lyp"; - Input_Conv::Convert(); - EXPECT_EQ(GlobalC::restart.info_load.load_charge, true); -} - -TEST_F(InputConvTest, cell_factor) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.calculation = "cell-relax"; - INPUT.cell_factor = 1.0; - Input_Conv::Convert(); - EXPECT_EQ(INPUT.cell_factor, 2.0); -} - -TEST_F(InputConvTest, neighbour) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.calculation = "nscf"; - INPUT.towannier90 = false; - INPUT.berry_phase = false; - Input_Conv::Convert(); - EXPECT_EQ(elecstate::ElecStateLCAO::need_psi_grid, false); -} - -TEST_F(InputConvTest, neighbour2) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.calculation = "test_neighbour"; - GlobalV::NPROC = 2; - std::string output2; - testing::internal::CaptureStdout(); - EXPECT_EXIT(Input_Conv::Convert(), ::testing::ExitedWithCode(0), ""); - output2 = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output2, testing::HasSubstr("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")); - EXPECT_THAT(output2, testing::HasSubstr(" NOTICE ")); - EXPECT_THAT(output2, testing::HasSubstr("test_neighbour must be done with 1 processor")); - EXPECT_THAT(output2, testing::HasSubstr("CHECK IN FILE : warning.log")); - EXPECT_THAT(output2, testing::HasSubstr("TIME STATISTICS")); -} - -TEST_F(InputConvTest, compile) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.deepks_scf = true; - std::string output2; - testing::internal::CaptureStdout(); - EXPECT_EXIT(Input_Conv::Convert(), ::testing::ExitedWithCode(0), ""); - output2 = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output2, testing::HasSubstr("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")); - EXPECT_THAT(output2, testing::HasSubstr(" NOTICE ")); - EXPECT_THAT(output2, testing::HasSubstr("please compile with DeePKS")); - EXPECT_THAT(output2, testing::HasSubstr("CHECK IN FILE : warning.log")); - EXPECT_THAT(output2, testing::HasSubstr("TIME STATISTICS")); -} - -TEST_F(InputConvTest, globalReadinDir) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - INPUT.read_file_dir = "/root"; - Input_Conv::Convert(); - EXPECT_EQ(GlobalV::global_readin_dir, "/root/"); -} - -TEST_F(InputConvTest, parse) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - module_tddft::Evolve_elec::td_vext = true; - Input_Conv::Convert(); - EXPECT_EQ(module_tddft::Evolve_elec::td_vext_dire_case.size(), 0); -} - -TEST_F(InputConvTest, parse2) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - GlobalV::ocp = 1; - Input_Conv::Convert(); - EXPECT_EQ(GlobalV::ocp_kb.size(), 0); -} - -TEST_F(InputConvTest, ParseExpressionDouble) -{ - std::vector vec; - std::string input = "2*3.5 1.2 0.5"; - Input_Conv::parse_expression(input, vec); - EXPECT_EQ(vec.size(), 4); - EXPECT_DOUBLE_EQ(vec[0], 3.5); - EXPECT_DOUBLE_EQ(vec[1], 3.5); - EXPECT_DOUBLE_EQ(vec[2], 1.2); - EXPECT_DOUBLE_EQ(vec[3], 0.5); -} - -#ifdef __LCAO -TEST_F(InputConvTest, ConvertUnitsWithEmptyParams) -{ - std::string params = ""; - double c = 2.0; - std::vector expected = {}; - std::vector result = Input_Conv::convert_units(params, c); - EXPECT_EQ(result, expected); -} - -TEST_F(InputConvTest, ConvertUnitsWithSingleParam) -{ - std::string params = "1.23"; - double c = 2.0; - std::vector expected = {2.46}; - std::vector result = Input_Conv::convert_units(params, c); - EXPECT_EQ(result, expected); -} - -TEST_F(InputConvTest, ConvertUnitsWithMultipleParams) -{ - std::string params = "1.23 4.56 7.89"; - double c = 0.5; - std::vector expected = {0.615, 2.28, 3.945}; - std::vector result = Input_Conv::convert_units(params, c); - EXPECT_EQ(result, expected); -} - -TEST_F(InputConvTest, ReadTdEfieldTest) -{ - Input_Conv::read_td_efield(); - - EXPECT_EQ(elecstate::H_TDDFT_pw::stype, 0); - EXPECT_EQ(elecstate::H_TDDFT_pw::ttype[0], 0); - EXPECT_EQ(elecstate::H_TDDFT_pw::tstart, 1); - EXPECT_EQ(elecstate::H_TDDFT_pw::tend, 1000); - EXPECT_EQ(elecstate::H_TDDFT_pw::lcut1, 0.05); - EXPECT_EQ(elecstate::H_TDDFT_pw::lcut2, 0.95); - EXPECT_NEAR(elecstate::H_TDDFT_pw::gauss_omega[0], 22.13 * 2 * ModuleBase::PI * ModuleBase::AU_to_FS, 1e-8); - EXPECT_EQ(elecstate::H_TDDFT_pw::gauss_phase[0], 0.0); - EXPECT_NEAR(elecstate::H_TDDFT_pw::gauss_sigma[0], 30.0 / ModuleBase::AU_to_FS, 1e-8); - EXPECT_EQ(elecstate::H_TDDFT_pw::gauss_t0[0], 100.0); - EXPECT_NEAR(elecstate::H_TDDFT_pw::gauss_amp[0], 0.25 * ModuleBase::BOHR_TO_A / ModuleBase::Ry_to_eV, 1e-8); - EXPECT_NEAR(elecstate::H_TDDFT_pw::trape_omega[0], 1.60 * 2 * ModuleBase::PI * ModuleBase::AU_to_FS, 1e-8); - EXPECT_EQ(elecstate::H_TDDFT_pw::trape_phase[0], 0.0); - EXPECT_EQ(elecstate::H_TDDFT_pw::trape_t1[0], 1875); - EXPECT_EQ(elecstate::H_TDDFT_pw::trape_t2[0], 5625); - EXPECT_EQ(elecstate::H_TDDFT_pw::trape_t3[0], 7500); - EXPECT_NEAR(elecstate::H_TDDFT_pw::trape_amp[0], 2.74 * ModuleBase::BOHR_TO_A / ModuleBase::Ry_to_eV, 1e-8); - EXPECT_NEAR(elecstate::H_TDDFT_pw::trigo_omega1[0], 1.164656 * 2 * ModuleBase::PI * ModuleBase::AU_to_FS, 1e-8); - EXPECT_NEAR(elecstate::H_TDDFT_pw::trigo_omega2[0], 0.029116 * 2 * ModuleBase::PI * ModuleBase::AU_to_FS, 1e-8); - EXPECT_EQ(elecstate::H_TDDFT_pw::trigo_phase1[0], 0.0); - EXPECT_EQ(elecstate::H_TDDFT_pw::trigo_phase2[0], 0.0); - EXPECT_NEAR(elecstate::H_TDDFT_pw::trigo_amp[0], 2.74 * ModuleBase::BOHR_TO_A / ModuleBase::Ry_to_eV, 1e-8); - EXPECT_EQ(elecstate::H_TDDFT_pw::heavi_t0[0], 100); - EXPECT_NEAR(elecstate::H_TDDFT_pw::heavi_amp[0], 1.00 * ModuleBase::BOHR_TO_A / ModuleBase::Ry_to_eV, 1e-8); -} - -#ifdef __PEXSI -TEST_F(InputConvTest, PEXSI) -{ - INPUT.Default(); - std::string input_file = "./support/INPUT"; - INPUT.Read(input_file); - Input_Conv::Convert(); - EXPECT_EQ(pexsi::PEXSI_Solver::pexsi_npole, 40); - EXPECT_TRUE(pexsi::PEXSI_Solver::pexsi_inertia); - EXPECT_EQ(pexsi::PEXSI_Solver::pexsi_nmax, 80); - EXPECT_TRUE(pexsi::PEXSI_Solver::pexsi_comm); - EXPECT_TRUE(pexsi::PEXSI_Solver::pexsi_storage); - EXPECT_EQ(pexsi::PEXSI_Solver::pexsi_ordering, 0); - EXPECT_EQ(pexsi::PEXSI_Solver::pexsi_row_ordering, 1); - EXPECT_EQ(pexsi::PEXSI_Solver::pexsi_nproc, 1); - EXPECT_TRUE(pexsi::PEXSI_Solver::pexsi_symm); - EXPECT_FALSE(pexsi::PEXSI_Solver::pexsi_trans); - EXPECT_EQ(pexsi::PEXSI_Solver::pexsi_method, 1); - EXPECT_EQ(pexsi::PEXSI_Solver::pexsi_nproc_pole, 1); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_temp, 0.015); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_gap, 0); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_delta_e, 20); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_mu_lower, -10); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_mu_upper, 10); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_mu, 0); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_mu_thr, 0.05); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_mu_expand, 0.3); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_mu_guard, 0.2); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_elec_thr, 0.001); - EXPECT_DOUBLE_EQ(pexsi::PEXSI_Solver::pexsi_zero_thr, 1e-10); -} -#endif - -#endif - -#undef private diff --git a/source/module_io/test/read_input_ptest.cpp b/source/module_io/test/read_input_ptest.cpp index 43897b682b..d2ed8b1ddc 100644 --- a/source/module_io/test/read_input_ptest.cpp +++ b/source/module_io/test/read_input_ptest.cpp @@ -112,7 +112,7 @@ TEST_F(InputParaTest, ParaRead) EXPECT_EQ(param.inp.relax_method, "cg"); EXPECT_DOUBLE_EQ(param.inp.relax_cg_thr, 0.5); EXPECT_EQ(param.inp.out_level, "ie"); - EXPECT_TRUE(param.inp.sup.out_md_control); + EXPECT_TRUE(param.globalv.out_md_control); EXPECT_TRUE(param.inp.relax_new); EXPECT_DOUBLE_EQ(param.inp.relax_bfgs_w1, 0.01); EXPECT_DOUBLE_EQ(param.inp.relax_bfgs_w2, 0.5); @@ -122,16 +122,16 @@ TEST_F(InputParaTest, ParaRead) EXPECT_DOUBLE_EQ(param.inp.relax_scale_force, 0.5); EXPECT_EQ(param.inp.nbspline, -1); EXPECT_TRUE(param.inp.gamma_only); - EXPECT_TRUE(param.inp.sup.gamma_only_local); + EXPECT_TRUE(param.globalv.gamma_only_local); EXPECT_DOUBLE_EQ(param.inp.ecutwfc, 20.0); EXPECT_DOUBLE_EQ(param.inp.erf_ecut, 20.0); EXPECT_DOUBLE_EQ(param.inp.erf_height, 20.0); EXPECT_DOUBLE_EQ(param.inp.erf_sigma, 4.0); EXPECT_DOUBLE_EQ(param.inp.ecutrho, 80); EXPECT_EQ(param.inp.fft_mode, 0); - EXPECT_EQ(param.inp.sup.ncx, 0); - EXPECT_EQ(param.inp.sup.ncy, 0); - EXPECT_EQ(param.inp.sup.ncz, 0); + EXPECT_EQ(param.globalv.ncx, 0); + EXPECT_EQ(param.globalv.ncy, 0); + EXPECT_EQ(param.globalv.ncz, 0); EXPECT_EQ(param.inp.nx, 0); EXPECT_EQ(param.inp.ny, 0); EXPECT_EQ(param.inp.nz, 0); @@ -210,7 +210,7 @@ TEST_F(InputParaTest, ParaRead) EXPECT_TRUE(param.inp.bessel_nao_smooth); EXPECT_DOUBLE_EQ(param.inp.bessel_nao_sigma, 0.1); EXPECT_EQ(std::stod(param.inp.bessel_nao_ecut), 20); - EXPECT_DOUBLE_EQ(param.inp.sup.bessel_nao_rcut, 6.0); + EXPECT_DOUBLE_EQ(param.globalv.bessel_nao_rcut, 6.0); EXPECT_DOUBLE_EQ(param.inp.bessel_nao_tolerence, 1E-12); EXPECT_EQ(param.inp.bessel_descriptor_lmax, 2); EXPECT_TRUE(param.inp.bessel_descriptor_smooth); @@ -343,11 +343,11 @@ TEST_F(InputParaTest, ParaRead) EXPECT_FALSE(param.inp.of_read_kernel); EXPECT_EQ(param.inp.of_kernel_file, "WTkernel.txt"); EXPECT_EQ(param.inp.device, "cpu"); - EXPECT_EQ(param.inp.sup.ncx, 0); - EXPECT_EQ(param.inp.sup.ncy, 0); - EXPECT_EQ(param.inp.sup.ncz, 0); + EXPECT_EQ(param.globalv.ncx, 0); + EXPECT_EQ(param.globalv.ncy, 0); + EXPECT_EQ(param.globalv.ncz, 0); EXPECT_NEAR(param.inp.force_thr_ev, 0.025711245953622324, 1e-8); - EXPECT_DOUBLE_EQ(param.inp.sup.hubbard_u[0], 0); + EXPECT_DOUBLE_EQ(param.globalv.hubbard_u[0], 0); EXPECT_EQ(param.inp.orbital_corr[0], -1); EXPECT_EQ(param.inp.mdp.lj_rule, 2); EXPECT_FALSE(param.inp.mdp.lj_eshift); diff --git a/source/module_io/test/write_dos_pw_test.cpp b/source/module_io/test/write_dos_pw_test.cpp index d165458a05..b072b8a58b 100644 --- a/source/module_io/test/write_dos_pw_test.cpp +++ b/source/module_io/test/write_dos_pw_test.cpp @@ -1,13 +1,16 @@ #include "gtest/gtest.h" #include "gmock/gmock.h" #include "module_io/write_dos_pw.h" -#include "module_io/input.h" #ifdef __MPI #include "mpi.h" #endif #include "for_testing_klist.h" #include "dos_test.h" +#define private public +#include "module_parameter/parameter.h" +#undef private + /************************************************ * unit test of write_dos_pw ***********************************************/ @@ -19,7 +22,7 @@ * - density of states in pw basis calculation */ -Input INPUT; +Parameter PARAM; class DosPWTest : public ::testing::Test { @@ -47,10 +50,10 @@ TEST_F(DosPWTest,Dos1) EXPECT_EQ(dosp.is,0); double dos_scale = 0.01; GlobalV::NSPIN = 1; - INPUT.dos_emax_ev = dosp.emax_ev; - INPUT.dos_setemax = true; - INPUT.dos_emin_ev = dosp.emin_ev; - INPUT.dos_setemin = true; + PARAM.input.dos_emax_ev = dosp.emax_ev; + PARAM.sys.dos_setemax = true; + PARAM.input.dos_emin_ev = dosp.emin_ev; + PARAM.sys.dos_setemin = true; kv->set_nks(dosp.nks); kv->set_nkstot(dosp.nkstot); kv->isk.reserve(kv->get_nks()); @@ -97,10 +100,10 @@ TEST_F(DosPWTest,Dos2) EXPECT_EQ(dosp.is,0); double dos_scale = 0.01; GlobalV::NSPIN = 1; - INPUT.dos_emax_ev = dosp.emax_ev; - INPUT.dos_setemax = false; - INPUT.dos_emin_ev = dosp.emin_ev; - INPUT.dos_setemin = false; + PARAM.input.dos_emax_ev = dosp.emax_ev; + PARAM.sys.dos_setemax = false; + PARAM.input.dos_emin_ev = dosp.emin_ev; + PARAM.sys.dos_setemin = false; kv->set_nks(dosp.nks); kv->set_nkstot(dosp.nkstot); kv->isk.reserve(kv->get_nks()); diff --git a/source/module_io/test_serial/CMakeLists.txt b/source/module_io/test_serial/CMakeLists.txt index 4671eb60c2..c9a27476a2 100644 --- a/source/module_io/test_serial/CMakeLists.txt +++ b/source/module_io/test_serial/CMakeLists.txt @@ -15,6 +15,7 @@ add_library( ../read_input_item_postprocess.cpp ../read_input_item_md.cpp ../read_input.cpp + ../bcast_globalv.cpp ) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/module_io/test_serial/read_input_item_test.cpp b/source/module_io/test_serial/read_input_item_test.cpp index b13d776b14..96b429a916 100644 --- a/source/module_io/test_serial/read_input_item_test.cpp +++ b/source/module_io/test_serial/read_input_item_test.cpp @@ -237,7 +237,7 @@ TEST_F(InputTest, Item_test) param.input.ecutrho = 5; param.input.ecutwfc = 1; it->second.reset_value(it->second, param); - EXPECT_EQ(param.input.sup.double_grid, true); + EXPECT_EQ(param.sys.double_grid, true); param.input.ecutwfc = 1; param.input.ecutrho = 1; @@ -467,7 +467,7 @@ TEST_F(InputTest, Item_test) param.input.ndx = 2; param.input.nx = 1; it->second.reset_value(it->second, param); - EXPECT_EQ(param.input.sup.double_grid, true); + EXPECT_EQ(param.sys.double_grid, true); param.input.ndx = 1; param.input.ndy = 0; @@ -489,7 +489,7 @@ TEST_F(InputTest, Item_test) param.input.ndy = 2; param.input.ny = 1; it->second.reset_value(it->second, param); - EXPECT_EQ(param.input.sup.double_grid, true); + EXPECT_EQ(param.sys.double_grid, true); param.input.ndy = 1; param.input.ndz = 0; @@ -511,7 +511,7 @@ TEST_F(InputTest, Item_test) param.input.ndz = 2; param.input.nz = 1; it->second.reset_value(it->second, param); - EXPECT_EQ(param.input.sup.double_grid, true); + EXPECT_EQ(param.sys.double_grid, true); param.input.ndz = 1; param.input.nz = 2; @@ -528,6 +528,13 @@ TEST_F(InputTest, Item_test) output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output, testing::HasSubstr("NOTICE")); } + { // cell_factor + auto it = find_lable("cell_factor", readinput.input_lists); + param.input.calculation = "cell-relax"; + param.input.cell_factor = 1.0; + it->second.reset_value(it->second, param); + EXPECT_EQ(param.input.cell_factor, 2.0); + } { // ks_sovler auto it = find_lable("ks_solver", readinput.input_lists); param.input.ks_solver = "default"; @@ -618,6 +625,47 @@ TEST_F(InputTest, Item_test) it->second.reset_value(it->second, param); EXPECT_EQ(param.input.cal_stress, true); } + { // fixed_axes + auto it = find_lable("fixed_axes", readinput.input_lists); + param.input.fixed_axes = "shape"; + param.input.relax_new = false; + testing::internal::CaptureStdout(); + EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + + param.input.fixed_axes = "volume"; + param.input.relax_new = false; + testing::internal::CaptureStdout(); + EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + } + { // fixed_ibrav + auto it = find_lable("fixed_ibrav", readinput.input_lists); + param.input.fixed_ibrav = true; + param.input.relax_new = false; + testing::internal::CaptureStdout(); + EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + + param.input.fixed_ibrav = true; + param.input.latname = "none"; + testing::internal::CaptureStdout(); + EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + } + { // fixed_atoms + auto it = find_lable("fixed_atoms", readinput.input_lists); + param.input.fixed_atoms = true; + param.input.calculation = "relax"; + testing::internal::CaptureStdout(); + EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); + output = testing::internal::GetCapturedStdout(); + EXPECT_THAT(output, testing::HasSubstr("NOTICE")); + } { // relax_method auto it = find_lable("relax_method", readinput.input_lists); param.input.relax_method = "none"; @@ -626,6 +674,18 @@ TEST_F(InputTest, Item_test) output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output, testing::HasSubstr("NOTICE")); } + { //relax_new + auto it = find_lable("relax_new", readinput.input_lists); + param.input.relax_new = true; + param.input.relax_method = "cg"; + it->second.reset_value(it->second, param); + EXPECT_EQ(param.input.relax_new, true); + + param.input.relax_new = true; + param.input.relax_method = "none"; + it->second.reset_value(it->second, param); + EXPECT_EQ(param.input.relax_new, false); + } { // force_thr auto it = find_lable("force_thr", readinput.input_lists); param.input.force_thr = -1; @@ -649,7 +709,7 @@ TEST_F(InputTest, Item_test) auto it = find_lable("out_level", readinput.input_lists); param.input.out_level = "0"; param.input.calculation = "md"; - param.input.sup.out_md_control = false; + param.sys.out_md_control = false; it->second.reset_value(it->second, param); EXPECT_EQ(param.input.out_level, "m"); } @@ -660,7 +720,7 @@ TEST_F(InputTest, Item_test) it->second.reset_value(it->second, param); EXPECT_EQ(param.input.out_dm, false); - param.input.sup.gamma_only_local = false; + param.sys.gamma_only_local = false; param.input.out_dm = true; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); @@ -674,7 +734,7 @@ TEST_F(InputTest, Item_test) it->second.reset_value(it->second, param); EXPECT_EQ(param.input.out_dm1, false); - param.input.sup.gamma_only_local = true; + param.sys.gamma_only_local = true; param.input.out_dm1 = true; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); @@ -768,11 +828,11 @@ TEST_F(InputTest, Item_test) param.input.gamma_only = true; param.input.esolver_type = "tddft"; it->second.reset_value(it->second, param); - EXPECT_EQ(param.input.sup.gamma_only_local, false); + EXPECT_EQ(param.sys.gamma_only_local, false); param.input.esolver_type = "lcao"; param.input.out_mat_r = true; - param.input.sup.gamma_only_local = true; + param.sys.gamma_only_local = true; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.reset_value(it->second, param), ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); @@ -1325,10 +1385,10 @@ TEST_F(InputTest, Item_test) } { // uramping auto it = find_lable("uramping", readinput.input_lists); - param.input.sup.uramping = 1; + param.sys.uramping = 1; param.input.orbital_corr = {-1, -1}; it->second.reset_value(it->second, param); - EXPECT_EQ(param.input.sup.uramping, 0); + EXPECT_EQ(param.sys.uramping, 0); } { // onsite_radius auto it = find_lable("onsite_radius", readinput.input_lists); @@ -1341,7 +1401,7 @@ TEST_F(InputTest, Item_test) auto it = find_lable("hubbard_u", readinput.input_lists); param.input.ntype = 2; it->second.str_values = {"1.0", "2.0"}; - param.input.sup.hubbard_u = {1.0, 2.0}; + param.sys.hubbard_u = {1.0, 2.0}; it->second.check_value(it->second, param); param.input.ntype = 3; testing::internal::CaptureStdout(); @@ -1350,7 +1410,7 @@ TEST_F(InputTest, Item_test) EXPECT_THAT(output, testing::HasSubstr("NOTICE")); param.input.ntype = 2; - param.input.sup.hubbard_u = {1.0, -1.0}; + param.sys.hubbard_u = {1.0, -1.0}; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); @@ -1390,7 +1450,7 @@ TEST_F(InputTest, Item_test) } { // bessel_nao_rcut auto it = find_lable("bessel_nao_rcut", readinput.input_lists); - param.input.sup.bessel_nao_rcut = -1; + param.sys.bessel_nao_rcut = -1; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); @@ -1605,6 +1665,7 @@ TEST_F(InputTest, Item_test) auto it = find_lable("lj_rcut", readinput.input_lists); param.input.ntype = 2; param.input.esolver_type = "lj"; + it->second.str_values = {"1.0", "2.0"}; param.input.mdp.lj_rcut = {1.0, 2.0}; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); @@ -1612,6 +1673,7 @@ TEST_F(InputTest, Item_test) EXPECT_THAT(output, testing::HasSubstr("NOTICE")); param.input.mdp.lj_rcut = {1.0, 2.0, -1.0}; + it->second.str_values = {"1.0", "2.0", "-1.0"}; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); @@ -1622,6 +1684,7 @@ TEST_F(InputTest, Item_test) param.input.ntype = 2; param.input.esolver_type = "lj"; param.input.mdp.lj_epsilon = {1.0}; + it->second.str_values = {"1.0"}; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); @@ -1632,6 +1695,7 @@ TEST_F(InputTest, Item_test) param.input.ntype = 2; param.input.esolver_type = "lj"; param.input.mdp.lj_sigma = {1.0}; + it->second.str_values = {"1.0"}; testing::internal::CaptureStdout(); EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(0), ""); output = testing::internal::GetCapturedStdout(); diff --git a/source/module_io/write_dos_lcao.cpp b/source/module_io/write_dos_lcao.cpp index 1559889e5b..5a73ff7edf 100644 --- a/source/module_io/write_dos_lcao.cpp +++ b/source/module_io/write_dos_lcao.cpp @@ -66,17 +66,17 @@ void ModuleIO::write_dos_lcao(const psi::Psi* psi, emax *= ModuleBase::Ry_to_eV; emin *= ModuleBase::Ry_to_eV; - if (INPUT.dos_setemax) + if (PARAM.globalv.dos_setemax) { - emax = INPUT.dos_emax_ev; + emax = PARAM.inp.dos_emax_ev; } - if (INPUT.dos_setemin) + if (PARAM.globalv.dos_setemin) { - emin = INPUT.dos_emin_ev; + emin = PARAM.inp.dos_emin_ev; } - if (!INPUT.dos_setemax && !INPUT.dos_setemin) + if (!PARAM.globalv.dos_setemax && !PARAM.globalv.dos_setemin) { // scale up a little bit so the end peaks are displaced better double delta = (emax - emin) * dos_scale; @@ -377,17 +377,17 @@ void ModuleIO::write_dos_lcao(const psi::Psi>* psi, emax *= ModuleBase::Ry_to_eV; emin *= ModuleBase::Ry_to_eV; - if (INPUT.dos_setemax) + if (PARAM.globalv.dos_setemax) { - emax = INPUT.dos_emax_ev; + emax = PARAM.inp.dos_emax_ev; } - if (INPUT.dos_setemin) + if (PARAM.globalv.dos_setemin) { - emin = INPUT.dos_emin_ev; + emin = PARAM.inp.dos_emin_ev; } - if (!INPUT.dos_setemax && !INPUT.dos_setemin) + if (!PARAM.globalv.dos_setemax && !PARAM.globalv.dos_setemin) { // scale up a little bit so the end peaks are displaced better double delta = (emax - emin) * dos_scale; diff --git a/source/module_io/write_dos_pw.cpp b/source/module_io/write_dos_pw.cpp index 190e812468..f8c2408ecd 100644 --- a/source/module_io/write_dos_pw.cpp +++ b/source/module_io/write_dos_pw.cpp @@ -2,7 +2,7 @@ #include "cal_dos.h" #include "module_base/parallel_reduce.h" -#include "module_io/input.h" +#include "module_parameter/parameter.h" void ModuleIO::write_dos_pw(const ModuleBase::matrix& ekb, const ModuleBase::matrix& wg, @@ -37,11 +37,11 @@ void ModuleIO::write_dos_pw(const ModuleBase::matrix& ekb, emax *= ModuleBase::Ry_to_eV; emin *= ModuleBase::Ry_to_eV; - if (INPUT.dos_setemax) - emax = INPUT.dos_emax_ev; - if (INPUT.dos_setemin) - emin = INPUT.dos_emin_ev; - if (!INPUT.dos_setemax && !INPUT.dos_setemin) + if (PARAM.globalv.dos_setemax) + emax = PARAM.inp.dos_emax_ev; + if (PARAM.globalv.dos_setemin) + emin = PARAM.inp.dos_emin_ev; + if (!PARAM.globalv.dos_setemax && !PARAM.globalv.dos_setemin) { // scale up a little bit so the end peaks are displaced better double delta = (emax - emin) * dos_scale; diff --git a/source/module_io/write_wfc_pw.cpp b/source/module_io/write_wfc_pw.cpp index e25eb0268c..59a3d94bad 100644 --- a/source/module_io/write_wfc_pw.cpp +++ b/source/module_io/write_wfc_pw.cpp @@ -8,7 +8,7 @@ #include "module_base/global_variable.h" #include "module_base/parallel_global.h" #include "module_base/tool_title.h" -#include "module_io/input.h" +#include "module_parameter/parameter.h" void ModuleIO::write_wfc_pw(const std::string& fn, const psi::Psi>& psi, @@ -24,21 +24,21 @@ void ModuleIO::write_wfc_pw(const std::string& fn, for(int ik = 0; ik < nkstot ; ++ik) { std::stringstream wfss; - if(INPUT.out_wfc_pw==1) + if(PARAM.inp.out_wfc_pw==1) wfss<lat0 << std::setw(10) << wfcpw->tpiba << std::endl; ofs2<<"\n"<G.e11<G.e12<G.e13<lat0 << wfcpw->tpiba << 72; // 4 int + 7 double is 72B wfs2<<72<G.e11<G.e12<G.e13 <G.e21<G.e22<G.e23 @@ -169,7 +169,7 @@ void ModuleIO::write_wfc_pw(const std::string& fn, #else int id=0; #endif - if(INPUT.out_wfc_pw==1) + if(PARAM.inp.out_wfc_pw==1) { std::ofstream ofs2( wfilename[ikstot].c_str(),std::ios::app); if(id==0) ofs2 << "\n< Band "<" <" <::ESolver_LR(ModuleESolver::ESolver_KS_LCAO&& ks_sol } template -LR::ESolver_LR::ESolver_LR(const Input_para& inp, Input& inp_tmp, UnitCell& ucell) : input(inp), ucell(ucell) +LR::ESolver_LR::ESolver_LR(const Input_para& inp, UnitCell& ucell) : input(inp), ucell(ucell) { redirect_log(inp.out_alllog); ModuleBase::TITLE("ESolver_LR", "ESolver_LR"); @@ -217,7 +217,7 @@ LR::ESolver_LR::ESolver_LR(const Input_para& inp, Input& inp_tmp, UnitCel std::transform(xc_kernel.begin(), xc_kernel.end(), xc_kernel.begin(), tolower); // necessary steps in ESolver_FP - ESolver_FP::before_all_runners(inp_tmp, ucell); + ESolver_FP::before_all_runners(inp, ucell); this->pelec = new elecstate::ElecStateLCAO(); // necessary steps in ESolver_KS::before_all_runners : symmetry and k-points @@ -367,6 +367,7 @@ LR::ESolver_LR::ESolver_LR(const Input_para& inp, Input& inp_tmp, UnitCel #endif // ModuleBase::Ylm::set_coefficients() is deprecated } + template void LR::ESolver_LR::runner(int istep, UnitCell& cell) { diff --git a/source/module_lr/esolver_lrtd_lcao.h b/source/module_lr/esolver_lrtd_lcao.h index d891e10fe1..df26aef673 100644 --- a/source/module_lr/esolver_lrtd_lcao.h +++ b/source/module_lr/esolver_lrtd_lcao.h @@ -30,7 +30,7 @@ namespace LR /// @brief a move constructor from ESolver_KS_LCAO ESolver_LR(ModuleESolver::ESolver_KS_LCAO&& ks_sol, const Input_para& inp, UnitCell& ucell); /// @brief a from-scratch constructor - ESolver_LR(const Input_para& inp, Input& inp_tmp, UnitCell& ucell); + ESolver_LR(const Input_para& inp, UnitCell& ucell); ~ESolver_LR() { delete this->pot; delete this->psi_ks; @@ -39,9 +39,9 @@ namespace LR ///input: input, call, basis(LCAO), psi(ground state), elecstate // initialize sth. independent of the ground state - virtual void before_all_runners(Input& inp, UnitCell& cell) override {}; + virtual void before_all_runners(const Input_para& inp, UnitCell& cell) override {}; - virtual void init_after_vc(Input& 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; diff --git a/source/module_md/test/fire_test.cpp b/source/module_md/test/fire_test.cpp index 4570b6bc71..bfd53c4304 100644 --- a/source/module_md/test/fire_test.cpp +++ b/source/module_md/test/fire_test.cpp @@ -39,22 +39,25 @@ class FIREtest : public testing::Test protected: MD_base* mdrun; UnitCell ucell; + Input_para input; + ModuleESolver::ESolver* p_esolver; void SetUp() { Setcell::setupcell(ucell); - Setcell::parameters(); + Setcell::parameters(input); - ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver = new ModuleESolver::ESolver_LJ(); + p_esolver->before_all_runners(input, ucell); - mdrun = new FIRE(INPUT.mdp, ucell); + mdrun = new FIRE(input.mdp, ucell); mdrun->setup(p_esolver, GlobalV::global_readin_dir); } void TearDown() { delete mdrun; + delete p_esolver; } }; diff --git a/source/module_md/test/langevin_test.cpp b/source/module_md/test/langevin_test.cpp index 02c6ad8db6..2eff577723 100644 --- a/source/module_md/test/langevin_test.cpp +++ b/source/module_md/test/langevin_test.cpp @@ -39,22 +39,25 @@ class Langevin_test : public testing::Test protected: MD_base* mdrun; UnitCell ucell; + Input_para input; + ModuleESolver::ESolver* p_esolver; void SetUp() { Setcell::setupcell(ucell); - Setcell::parameters(); + Setcell::parameters(input); - ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver = new ModuleESolver::ESolver_LJ(); + p_esolver->before_all_runners(input, ucell); - mdrun = new Langevin(INPUT.mdp, ucell); + mdrun = new Langevin(input.mdp, ucell); mdrun->setup(p_esolver, GlobalV::global_readin_dir); } void TearDown() { delete mdrun; + delete p_esolver; } }; diff --git a/source/module_md/test/lj_pot_test.cpp b/source/module_md/test/lj_pot_test.cpp index 62f6c8b4ad..62345106be 100644 --- a/source/module_md/test/lj_pot_test.cpp +++ b/source/module_md/test/lj_pot_test.cpp @@ -24,6 +24,7 @@ class LJ_pot_test : public testing::Test double potential; int natom; UnitCell ucell; + Input_para input; void SetUp() { @@ -33,7 +34,7 @@ class LJ_pot_test : public testing::Test force = new ModuleBase::Vector3[natom]; stress.create(3, 3); - Setcell::parameters(); + Setcell::parameters(input); } void TearDown() @@ -45,7 +46,7 @@ class LJ_pot_test : public testing::Test TEST_F(LJ_pot_test, potential) { ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver->before_all_runners(input, ucell); MD_func::force_virial(p_esolver, 0, ucell, potential, force, true, stress); EXPECT_NEAR(potential, -0.011957818623534381, doublethreshold); } @@ -53,7 +54,7 @@ TEST_F(LJ_pot_test, potential) TEST_F(LJ_pot_test, force) { ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver->before_all_runners(input, ucell); MD_func::force_virial(p_esolver, 0, ucell, potential, force, true, stress); EXPECT_NEAR(force[0].x, 0.00049817733089377704, doublethreshold); EXPECT_NEAR(force[0].y, 0.00082237246837022328, doublethreshold); @@ -72,7 +73,7 @@ TEST_F(LJ_pot_test, force) TEST_F(LJ_pot_test, stress) { ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver->before_all_runners(input, ucell); MD_func::force_virial(p_esolver, 0, ucell, potential, force, true, stress); EXPECT_NEAR(stress(0, 0), 8.0360222227631859e-07, doublethreshold); EXPECT_NEAR(stress(0, 1), 1.7207745586539077e-07, doublethreshold); diff --git a/source/module_md/test/md_func_test.cpp b/source/module_md/test/md_func_test.cpp index 93fd217553..c3368510e5 100644 --- a/source/module_md/test/md_func_test.cpp +++ b/source/module_md/test/md_func_test.cpp @@ -58,11 +58,12 @@ class MD_func_test : public testing::Test int natom; // atom number double temperature; // temperature int frozen_freedom; // frozen_freedom + Input_para input; void SetUp() { Setcell::setupcell(ucell); - Setcell::parameters(); + Setcell::parameters(input); natom = ucell.nat; allmass = new double[natom]; pos = new ModuleBase::Vector3[natom]; @@ -209,7 +210,7 @@ TEST_F(MD_func_test, compute_stress) TEST_F(MD_func_test, dump_info) { - MD_func::dump_info(0, GlobalV::global_out_dir, ucell, INPUT.mdp, virial, force, vel); + MD_func::dump_info(0, GlobalV::global_out_dir, ucell, input.mdp, virial, force, vel); std::ifstream ifs("MD_dump"); std::string output_str; getline(ifs, output_str); @@ -255,7 +256,7 @@ TEST_F(MD_func_test, dump_info) ifs.close(); // append - MD_func::dump_info(1, GlobalV::global_out_dir, ucell, INPUT.mdp, virial, force, vel); + MD_func::dump_info(1, GlobalV::global_out_dir, ucell, input.mdp, virial, force, vel); std::ifstream ifs2("MD_dump"); getline(ifs2, output_str); EXPECT_THAT(output_str, testing::HasSubstr("MDSTEP: 0")); diff --git a/source/module_md/test/msst_test.cpp b/source/module_md/test/msst_test.cpp index 9a98214688..9c037d02e2 100644 --- a/source/module_md/test/msst_test.cpp +++ b/source/module_md/test/msst_test.cpp @@ -39,22 +39,25 @@ class MSST_test : public testing::Test protected: MD_base* mdrun; UnitCell ucell; + Input_para input; + ModuleESolver::ESolver* p_esolver; void SetUp() { Setcell::setupcell(ucell); - Setcell::parameters(); + Setcell::parameters(input); - ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver = new ModuleESolver::ESolver_LJ(); + p_esolver->before_all_runners(input, ucell); - mdrun = new MSST(INPUT.mdp, ucell); + mdrun = new MSST(input.mdp, ucell); mdrun->setup(p_esolver, GlobalV::global_readin_dir); } void TearDown() { delete mdrun; + delete p_esolver; } }; diff --git a/source/module_md/test/nhchain_test.cpp b/source/module_md/test/nhchain_test.cpp index 5cd2dc6382..2f3d8a67a2 100644 --- a/source/module_md/test/nhchain_test.cpp +++ b/source/module_md/test/nhchain_test.cpp @@ -32,30 +32,32 @@ * - Nose_Hoover::print_md * - output MD information such as energy, temperature, and pressure */ - +Input_para input; // md_pfirst/md_last will change at differen tests class NHC_test : public testing::Test { protected: MD_base* mdrun; UnitCell ucell; + ModuleESolver::ESolver* p_esolver; void SetUp() { Setcell::setupcell(ucell); - Setcell::parameters(); + Setcell::parameters(input); - ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver = new ModuleESolver::ESolver_LJ(); + p_esolver->before_all_runners(input, ucell); - INPUT.mdp.md_type = "npt"; - INPUT.mdp.md_pmode = "tri"; - mdrun = new Nose_Hoover(INPUT.mdp, ucell); + input.mdp.md_type = "npt"; + input.mdp.md_pmode = "tri"; + mdrun = new Nose_Hoover(input.mdp, ucell); mdrun->setup(p_esolver, GlobalV::global_readin_dir); } void TearDown() { delete mdrun; + delete p_esolver; } }; diff --git a/source/module_md/test/setcell.h b/source/module_md/test/setcell.h index b76320f969..dbd0e43b57 100644 --- a/source/module_md/test/setcell.h +++ b/source/module_md/test/setcell.h @@ -7,7 +7,7 @@ #include "module_cell/module_neighbor/sltk_atom_arrange.h" #include "module_cell/module_neighbor/sltk_grid_driver.h" #include "module_cell/unitcell.h" -#include "module_io/input.h" +#include "module_parameter/parameter.h" Magnetism::Magnetism() { @@ -74,12 +74,16 @@ class Setcell ucell.nat = 4; ucell.atoms[0].na = 4; - ucell.init_vel = 1; + ucell.init_vel = true; delete[] ucell.atoms[0].tau; + delete[] ucell.atoms[0].dis; delete[] ucell.atoms[0].taud; delete[] ucell.atoms[0].vel; delete[] ucell.atoms[0].mbl; + delete[] ucell.atoms[0].angle1; + delete[] ucell.atoms[0].angle2; + delete[] ucell.atoms[0].m_loc_; ucell.atoms[0].tau = new ModuleBase::Vector3[4]; ucell.atoms[0].dis = new ModuleBase::Vector3[4]; ucell.atoms[0].taud = new ModuleBase::Vector3[4]; @@ -120,42 +124,42 @@ class Setcell ucell.set_iat2itia(); }; - static void parameters() + static void parameters(Input_para& input) { GlobalV::global_out_dir = "./"; GlobalV::global_readin_dir = "./"; GlobalV::SEARCH_RADIUS = 8.5 * ModuleBase::ANGSTROM_AU; - GlobalV::CAL_STRESS = 1; + GlobalV::CAL_STRESS = true; - INPUT.mdp.dump_virial = true; - INPUT.mdp.dump_force = true; - INPUT.mdp.dump_vel = true; - INPUT.mdp.cal_stress = true; + input.mdp.dump_virial = true; + input.mdp.dump_force = true; + input.mdp.dump_vel = true; + input.mdp.cal_stress = true; - INPUT.mdp.md_restart = 0; - INPUT.mdp.md_dt = 1; - INPUT.mdp.md_tfirst = INPUT.mdp.md_tlast = 300; + input.mdp.md_restart = false; + input.mdp.md_dt = 1; + input.mdp.md_tfirst = input.mdp.md_tlast = 300; GlobalV::ESOLVER_TYPE = "lj"; - INPUT.mdp.lj_rcut = {8.5}; - INPUT.mdp.lj_epsilon = {0.01032}; - INPUT.mdp.lj_sigma = {3.405}; + input.mdp.lj_rcut = {8.5}; + input.mdp.lj_epsilon = {0.01032}; + input.mdp.lj_sigma = {3.405}; - INPUT.mdp.msst_direction = 2; - INPUT.mdp.msst_qmass = 1; - INPUT.mdp.msst_vel = 0; - INPUT.mdp.msst_vis = 0; - INPUT.mdp.msst_tscale = 0.01; + input.mdp.msst_direction = 2; + input.mdp.msst_qmass = 1; + input.mdp.msst_vel = 0; + input.mdp.msst_vis = 0; + input.mdp.msst_tscale = 0.01; - INPUT.mdp.md_tfreq = 1; - INPUT.mdp.md_tchain = 4; - INPUT.mdp.md_pfreq = 1; - INPUT.mdp.md_pchain = 4; + input.mdp.md_tfreq = 1; + input.mdp.md_tchain = 4; + input.mdp.md_pfreq = 1; + input.mdp.md_pchain = 4; - INPUT.mdp.md_damp = 1; + input.mdp.md_damp = 1; - INPUT.mdp.md_nraise = 2; - INPUT.mdp.md_tolerance = 0; + input.mdp.md_nraise = 2; + input.mdp.md_tolerance = 0; }; }; diff --git a/source/module_md/test/verlet_test.cpp b/source/module_md/test/verlet_test.cpp index 9209d40e82..d586ebcf92 100644 --- a/source/module_md/test/verlet_test.cpp +++ b/source/module_md/test/verlet_test.cpp @@ -40,16 +40,17 @@ class Verlet_test : public testing::Test protected: MD_base* mdrun; UnitCell ucell; + Input_para input; void SetUp() { Setcell::setupcell(ucell); - Setcell::parameters(); + Setcell::parameters(input); ModuleESolver::ESolver* p_esolver = new ModuleESolver::ESolver_LJ(); - p_esolver->before_all_runners(INPUT, ucell); + p_esolver->before_all_runners(input, ucell); - mdrun = new Verlet(INPUT.mdp, ucell); + mdrun = new Verlet(input.mdp, ucell); mdrun->setup(p_esolver, GlobalV::global_readin_dir); } diff --git a/source/module_parameter/input_parameter.h b/source/module_parameter/input_parameter.h index 36d9cc2ead..764f3ca2f7 100644 --- a/source/module_parameter/input_parameter.h +++ b/source/module_parameter/input_parameter.h @@ -6,39 +6,10 @@ #include "md_parameter.h" #include "module_base/vector3.h" -// It stores parameters not defined in INPUT file -struct Input_supplement -{ - bool two_fermi = false; ///< true if "nupdown" is set - - // for lj pot - int n_ljcut = 0; ///< number of lj_rcut, assuming 0 as no values provided - int n_ljepsilon = 0; ///< number of lj_epsilon, assuming 0 as no values provided - int n_ljsigma = 0; ///< number of lj_sigma, assuming 0 as no values provided - - // For parameter "bessel_nao_rcuts" - int nrcut = 0; ///< number of bessel_nao_rcuts, assuming 0 as no values provided - double bessel_nao_rcut = 6.0; ///< radial cutoff for spherical bessel functions(a.u.) - - bool dos_setemin = false; ///< true: "dos_emin_ev" is set - bool dos_setemax = false; ///< true: "dos_emax_ev" is set - int ncx = 0, ncy = 0, - ncz = 0; ///< three dimension of FFT charge/grid, same as "nx,ny,nz" - bool out_md_control = false; ///< true if "out_level" is set - bool rpa_setorb = false; ///< true if "rpa" is set - bool gamma_only_local = false; ///< true if "gamma_only" is true and "lcao" - ///< is true; for local orbitals. - bool double_grid = false; ///< true if "ndx,ndy,ndz" is larger than "nx,ny,nz" - double uramping = -10.0 / 13.6; /// U-Ramping method (Ry) - std::vector hubbard_u = {}; ///< Hubbard Coulomb interaction parameter U (Ry) - std::string global_calculation = "scf"; ///< global calculation type decided by "calculation" -}; - // It stores all input parameters both defined in INPUT file and not defined in // INPUT file struct Input_para { - Input_supplement sup; // --------------------------------------------------------------- // -------------- INPUT Parameters ---------------- // --------------------------------------------------------------- diff --git a/source/module_parameter/md_parameter.h b/source/module_parameter/md_parameter.h index 92c9ddde56..8c72c565bc 100644 --- a/source/module_parameter/md_parameter.h +++ b/source/module_parameter/md_parameter.h @@ -59,6 +59,8 @@ struct MD_para bool dump_virial = true; ///< output lattice virial into the file MD_dump or ///< not. liuyu 2023-03-01 + // !!! + // They are repeated in the MD_para and Parameter, which is not good. double force_thr = 1.0e-3; ///< force convergence threshold in FIRE method bool cal_stress = false; ///< whether calculate stress int my_rank = 0; ///< MPI rank of the processor diff --git a/source/module_parameter/parameter.cpp b/source/module_parameter/parameter.cpp index d4881a6808..86da7b6580 100644 --- a/source/module_parameter/parameter.cpp +++ b/source/module_parameter/parameter.cpp @@ -4,11 +4,12 @@ Parameter PARAM; void Parameter::set_rank_nproc(const int& myrank, const int& nproc) { - system.myrank = myrank; - system.nproc = nproc; + sys.myrank = myrank; + sys.nproc = nproc; + input.mdp.my_rank = myrank; } void Parameter::set_start_time(const std::time_t& start_time) { - system.start_time = start_time; + sys.start_time = start_time; } \ No newline at end of file diff --git a/source/module_parameter/parameter.h b/source/module_parameter/parameter.h index 4766e3c6e1..38b544f2ed 100644 --- a/source/module_parameter/parameter.h +++ b/source/module_parameter/parameter.h @@ -23,8 +23,8 @@ class Parameter const Input_para& inp = input; // We can only read the value of mdp, but cannot modify it. const MD_para& mdp = input.mdp; - // We can only read the value of other parameters, but cannot modify it. - const System_para& sys = system; + // We can only read the value of globalv parameters, but cannot modify it. + const System_para& globalv = sys; // Set the rank & nproc void set_rank_nproc(const int& myrank, const int& nproc); @@ -37,7 +37,7 @@ class Parameter // INPUT parameters Input_para input; // System parameters - System_para system; + System_para sys; }; extern Parameter PARAM; diff --git a/source/module_parameter/system_parameter.h b/source/module_parameter/system_parameter.h index 53de0742c0..2c40b87e05 100644 --- a/source/module_parameter/system_parameter.h +++ b/source/module_parameter/system_parameter.h @@ -6,7 +6,7 @@ struct System_para { // --------------------------------------------------------------- - // -------------- Other Parameters ---------------- + // -------------- Parameters ---------------------- // --------------------------------------------------------------- int myrank = 0; int nproc = 1; @@ -14,5 +14,28 @@ struct System_para int npool = 1; int nproc_in_pool = 1; std::time_t start_time = 0; + + // --------------------------------------------------------------- + // ------------ parameters not defined in INPUT file ------------- + // ------------ but decided by INPUT parameters ------------- + // --------------------------------------------------------------- + bool two_fermi = false; ///< true if "nupdown" is set + + // For parameter "bessel_nao_rcuts" + int nrcut = 0; ///< number of bessel_nao_rcuts, assuming 0 as no values provided + double bessel_nao_rcut = 6.0; ///< radial cutoff for spherical bessel functions(a.u.) + + bool dos_setemin = false; ///< true: "dos_emin_ev" is set + bool dos_setemax = false; ///< true: "dos_emax_ev" is set + int ncx = 0, ncy = 0, + ncz = 0; ///< three dimension of FFT charge/grid, same as "nx,ny,nz" + bool out_md_control = false; ///< true if "out_level" is set + bool rpa_setorb = false; ///< true if "rpa" is set + bool gamma_only_local = false; ///< true if "gamma_only" is true and "lcao" + ///< is true; for local orbitals. + bool double_grid = false; ///< true if "ndx,ndy,ndz" is larger than "nx,ny,nz" + double uramping = -10.0 / 13.6; /// U-Ramping method (Ry) + std::vector hubbard_u = {}; ///< Hubbard Coulomb interaction parameter U (Ry) + std::string global_calculation = "scf"; ///< global calculation type decided by "calculation" }; #endif \ No newline at end of file diff --git a/source/module_relax/relax_new/relax.cpp b/source/module_relax/relax_new/relax.cpp index 06b75acb44..6d45587dbb 100644 --- a/source/module_relax/relax_new/relax.cpp +++ b/source/module_relax/relax_new/relax.cpp @@ -140,7 +140,7 @@ bool Relax::setup_gradient(const ModuleBase::matrix& force, const ModuleBase::ma grad_cell.zero_out(); ModuleBase::matrix stress_ev = stress * (GlobalC::ucell.omega * ModuleBase::Ry_to_eV); - if(INPUT.fixed_axes == "shape") + if(PARAM.inp.fixed_axes == "shape") { double pressure = (stress_ev(0,0) + stress_ev(1,1) + stress_ev(2,2)) / 3.0; stress_ev.zero_out(); @@ -148,14 +148,14 @@ bool Relax::setup_gradient(const ModuleBase::matrix& force, const ModuleBase::ma stress_ev(1,1) = pressure; stress_ev(2,2) = pressure; } - else if(INPUT.fixed_axes == "volume") + else if(PARAM.inp.fixed_axes == "volume") { double pressure = (stress_ev(0,0) + stress_ev(1,1) + stress_ev(2,2)) / 3.0; stress_ev(0,0) -= pressure; stress_ev(1,1) -= pressure; stress_ev(2,2) -= pressure; } - else if (INPUT.fixed_axes != "None") + else if (PARAM.inp.fixed_axes != "None") { //Note stress is given in the directions of lattice vectors //So we need to first convert to Cartesian and then apply the constraint @@ -509,12 +509,12 @@ void Relax::move_cell_ions(const bool is_new_dir) } GlobalC::ucell.latvec += move_cell * (step_size * fac * fac_stress); - if(INPUT.fixed_axes == "volume") + if(PARAM.inp.fixed_axes == "volume") { double omega_new = std::abs(GlobalC::ucell.latvec.Det()) * pow(GlobalC::ucell.lat0, 3); GlobalC::ucell.latvec *= pow(GlobalC::ucell.omega / omega_new, 1.0/3.0); } - if(INPUT.fixed_ibrav) + if(PARAM.inp.fixed_ibrav) { GlobalC::ucell.remake_cell(); } diff --git a/source/module_relax/relax_new/test/CMakeLists.txt b/source/module_relax/relax_new/test/CMakeLists.txt index cf6b4af67d..e323756322 100644 --- a/source/module_relax/relax_new/test/CMakeLists.txt +++ b/source/module_relax/relax_new/test/CMakeLists.txt @@ -14,8 +14,8 @@ AddTest( AddTest( TARGET relax_new_relax SOURCES relax_test.cpp ../relax.cpp ../line_search.cpp ../../../module_base/tool_quit.cpp ../../../module_base/global_variable.cpp ../../../module_base/global_file.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp - ../../../module_base/matrix3.cpp ../../../module_base/intarray.cpp ../../../module_base/tool_title.cpp ../../../module_io/input.cpp + ../../../module_base/matrix3.cpp ../../../module_base/intarray.cpp ../../../module_base/tool_title.cpp ../../../module_base/global_function.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix.cpp ../../../module_base/complexarray.cpp ../../../module_base/tool_quit.cpp ../../../module_base/realarray.cpp - LIBS ${math_libs} + LIBS ${math_libs} parameter ) \ No newline at end of file diff --git a/source/module_relax/relax_new/test/relax_test.cpp b/source/module_relax/relax_new/test/relax_test.cpp index a01df6e775..ac6478e6aa 100644 --- a/source/module_relax/relax_new/test/relax_test.cpp +++ b/source/module_relax/relax_new/test/relax_test.cpp @@ -1,15 +1,18 @@ #include "gtest/gtest.h" #include "../relax.h" #include "module_cell/unitcell.h" -#include "module_io/input.h" #include "relax_test.h" #include +#define private public +#include "module_parameter/parameter.h" +#undef private class Test_SETGRAD : public testing::Test { protected: Relax rl; std::vector result; + Input_para& input = PARAM.input; void SetUp() { @@ -84,22 +87,22 @@ class Test_SETGRAD : public testing::Test //reset lattice vector GlobalC::ucell.latvec.Identity(); - INPUT.fixed_axes = "shape"; + input.fixed_axes = "shape"; rl.init_relax(nat); rl.relax_step(force_in,stress_in,0.0); push_result(); //reset lattice vector GlobalC::ucell.latvec.Identity(); - INPUT.fixed_axes = "volume"; + input.fixed_axes = "volume"; rl.init_relax(nat); rl.relax_step(force_in,stress_in,0.0); push_result(); //reset lattice vector GlobalC::ucell.latvec.Identity(); - INPUT.fixed_axes = "a"; //anything other than "None" - INPUT.fixed_ibrav = 1; + input.fixed_axes = "a"; //anything other than "None" + input.fixed_ibrav = true; GlobalC::ucell.lc[0] = 0; GlobalC::ucell.lc[1] = 0; GlobalC::ucell.lc[2] = 0; diff --git a/source/module_relax/relax_new/test/relax_test.h b/source/module_relax/relax_new/test/relax_test.h index c2d8ab7dca..c2b6da9287 100644 --- a/source/module_relax/relax_new/test/relax_test.h +++ b/source/module_relax/relax_new/test/relax_test.h @@ -55,6 +55,4 @@ void ModuleSymmetry::Symmetry::symmetrize_mat3(ModuleBase::matrix& sigma, const void ModuleSymmetry::Symmetry::symmetrize_vec3_nat(double* v)const {}; Structure_Factor::Structure_Factor() {}; Structure_Factor::~Structure_Factor(){}; -void Structure_Factor::setup_structure_factor(UnitCell* Ucell, const ModulePW::PW_Basis* rho_basis){}; - -extern Input INPUT; \ No newline at end of file +void Structure_Factor::setup_structure_factor(UnitCell* Ucell, const ModulePW::PW_Basis* rho_basis){}; \ No newline at end of file