diff --git a/source/module_io/CMakeLists.txt b/source/module_io/CMakeLists.txt index da92f571c7d..364d075d0b9 100644 --- a/source/module_io/CMakeLists.txt +++ b/source/module_io/CMakeLists.txt @@ -25,6 +25,7 @@ list(APPEND objects output_log.cpp output_rho.cpp output_potential.cpp + parameter_pool.cpp ) list(APPEND objects_advanced diff --git a/source/module_io/DEFAULT_TYPE.conf b/source/module_io/DEFAULT_TYPE.conf new file mode 100644 index 00000000000..ca72514c737 --- /dev/null +++ b/source/module_io/DEFAULT_TYPE.conf @@ -0,0 +1,308 @@ +suffix string +stru_file string +pseudo_dir string +orbital_dir string +read_file_dir string +kpoint_file string +wannier_card string +latname string +calculation string +esolver_type string +pseudo_rcut double +pseudo_mesh bool +ntype int +nbands int +nbands_istate int +pw_seed int +init_vel bool +ref_cell_factor double +symmetry int +symmetry_prec double +kpar int +berry_phase bool +gdir int +kspacing[3] double +min_dist_coef double +towannier90 bool +nnkpfile string +wannier_spin string +nche_sto int +nbands_sto int +nbndsto_str string +seed_sto int +emax_sto double +emin_sto double +bndpar int +initsto_freq int +method_sto int +npart_sto int +cal_cond bool +cond_nche int +cond_dw double +cond_wcut double +cond_dt int +cond_dtbatch int +cond_fwhm double +cond_nonlocal bool +dft_functional string +xc_temperature double +nspin int +nupdown double +nelec double +lmaxmax int +basis_type string +ks_solver string +cal_force bool +force_thr double +force_thr_ev2 double +stress_thr double +press1 double +press2 double +press3 double +cal_stress bool +fixed_axes string +fixed_ibrav bool +fixed_atoms bool +relax_method string +relax_new bool +relax_cg_thr double +relax_bfgs_w1 double +relax_bfgs_w2 double +relax_bfgs_rmax double +relax_bfgs_rmin double +relax_bfgs_init double +relax_scale_force double +gamma_only bool +gamma_only_local bool +ecutwfc double +ecutrho double +ncx int +ncy int +ncz int +nx int +ny int +nz int +bx int +by int +bz int +diago_proc int +pw_diag_nmax int +diago_cg_prec int +pw_diag_ndim int +pw_diag_thr double +nb2d int +nurse int +nbspline int +colour bool +t_in_h bool +vl_in_h bool +vnl_in_h bool +vh_in_h bool +vion_in_h bool +test_force bool +test_stress bool +scf_thr double +scf_thr_type int +scf_nmax int +relax_nmax int +out_stru bool +out_level string +out_md_control bool +occupations string +smearing_method string +smearing_sigma double +mixing_mode string +mixing_beta double +mixing_ndim int +mixing_gg0 double +mixing_tau bool +mixing_dftu bool +init_wfc string +init_chg string +chg_extrap string +mem_saver int +printe int +out_freq_elec int +out_freq_ion int +out_chg bool +out_dm bool +out_dm1 bool +out_pot int +out_wfc_pw int +out_wfc_r bool +out_dos bool +out_band bool +out_proj_band bool +out_mat_hs bool +cal_syns bool +dmax double +out_mat_hs2 bool +out_mat_dh bool +out_interval int +out_app_flag bool +out_mat_t bool +out_mat_r bool +out_wfc_lcao bool +out_alllog bool +out_element_info bool +out_bandgap bool +dos_emin_ev double +dos_emax_ev double +dos_edelta_ev double +dos_scale double +dos_nche int +dos_set +emin bool +dos_setemax bool +dos_sigma double +lcao_ecut double +lcao_dk double +lcao_dr double +lcao_rmax double +search_radius double +search_pbc bool +mdp MD_para +efield_flag bool +dip_cor_flag bool +efield_dir int +efield_pos_max double +efield_pos_dec double +efield_amp double +gate_flag bool +zgate double +relax bool +block bool +block_down double +block_up double +block_height double +vdw_method string +vdw_s6 string +vdw_s8 string +vdw_a1 string +vdw_a2 string +vdw_d double +vdw_abc bool +vdw_cutoff_radius string +vdw_radius_unit string +vdw_cn_thr double +vdw_cn_thr_unit string +vdw_C6_file string +vdw_C6_unit string +vdw_R0_file string +vdw_R0_unit string +vdw_cutoff_type string +vdw_cutoff_period ModuleBase::Vector3 +ocp bool +ocp_set string +out_mul bool +noncolin bool +lspinorb bool +soc_lambda double +exx_hybrid_alpha string +exx_hse_omega double +exx_separate_loop bool +exx_hybrid_step int +exx_mixing_beta double +exx_lambda double +exx_real_number string +exx_pca_threshold double +exx_c_threshold double +exx_v_threshold double +exx_dm_threshold double +exx_schwarz_threshold double +exx_cauchy_threshold double +exx_c_grad_threshold double +exx_v_grad_threshold double +exx_cauchy_force_threshold double +exx_cauchy_stress_threshold double +exx_ccp_threshold double +exx_ccp_rmesh_times string +exx_distribute_type string +exx_opt_orb_lmax int +exx_opt_orb_ecut double +exx_opt_orb_tolerence double +td_force_dt double +td_vext bool +td_vext_dire string +out_dipole bool +out_efield bool +td_print_eij double +td_edm int +propagator int +td_stype int +td_ttype string +td_tstart int +td_tend int +td_lcut1 double +td_lcut2 double +td_gauss_freq string +td_gauss_phase string +td_gauss_sigma string +td_gauss_t0 string +td_gauss_amp string +td_trape_freq string +td_trape_phase string +td_trape_t1 string +td_trape_t2 string +td_trape_t3 string +td_trape_amp string +td_trigo_freq1 string +td_trigo_freq2 string +td_trigo_phase1 string +td_trigo_phase2 string +td_trigo_amp string +td_heavi_t0 string +td_heavi_amp string +restart_save bool +restart_load bool +input_error bool +cell_factor double +dft_plus_u bool +orbital_corr int* +hubbard_u double* +omc int +yukawa_potential bool +yukawa_lambda double +dft_plus_dmft bool +rpa bool +coulomb_type std::string +deepks_out_labels bool +deepks_scf bool +deepks_bandgap bool +deepks_out_unittest bool +deepks_model string +imp_sol bool +eb_k double +tau double +sigma_k double +nc_k double +of_kinetic string +of_method string +of_conv string +of_tole double +of_tolp double +of_tf_weight double +of_vw_weight double +of_wt_alpha double +of_wt_beta double +of_wt_rho0 double +of_hold_rho0 bool +of_lkt_a double +of_full_pw bool +of_full_pw_dim int +of_read_kernel bool +of_kernel_file string +bessel_nao_smooth bool +bessel_nao_sigma double +bessel_nao_ecut string +bessel_nao_rcut double +bessel_nao_tolerence double +bessel_descriptor_lmax int +bessel_descriptor_smooth bool +bessel_descriptor_sigma double +bessel_descriptor_ecut string +bessel_descriptor_rcut double +bessel_descriptor_tolerence double +device std::string +precision std::string +test_skip_ewald bool \ No newline at end of file diff --git a/source/module_io/DEFAULT_VALUE.conf b/source/module_io/DEFAULT_VALUE.conf new file mode 100644 index 00000000000..5503d197501 --- /dev/null +++ b/source/module_io/DEFAULT_VALUE.conf @@ -0,0 +1,298 @@ + suffix "ABACUS" + stru_file "" + kpoint_file "" + pseudo_dir "" + orbital_dir "" + read_file_dir "auto" + wannier_card "none" + latname "none" + calculation "scf" + esolver_type "ksdft" + pseudo_rcut 15.0 + pseudo_mesh false + ntype 0 + nbands 0 + nbands_sto 256 + nbndsto_str "256" + nbands_istate 5 + pw_seed 1 + emin_sto 0.0 + emax_sto 0.0 + nche_sto 100 + seed_sto 0 + bndpar 1 + kpar 1 + initsto_freq 0 + method_sto 2 + npart_sto 1 + cal_cond false + dos_nche 100 + cond_nche 20 + cond_dw 0.1 + cond_wcut 10 + cond_dt 0.02 + cond_dtbatch 4 + cond_fwhm 0.4 + cond_nonlocal true + berry_phase false + gdir 3 + towannier90 false + nnkpfile "seedname.nnkp" + wannier_spin "up" + for(int i0i<3i++){kspacing[i] = 0} + min_dist_coef 0.2 + dft_functional "default" + xc_temperature 0.0 + nspin 1 + nelec 0.0 + lmaxmax 2 + basis_type "pw" + ks_solver "default" + search_radius -1.0 + search_pbc true + symmetry "default" + init_vel false + ref_cell_factor 1.0 + symmetry_prec 1.0e-5 + cal_force 0 + force_thr 1.0e-3 + force_thr_ev2 0 + stress_thr 0.5 + press1 0.0 + press2 0.0 + press3 0.0 + cal_stress false + fixed_axes "None" + fixed_ibrav false + fixed_atoms false + relax_method "cg" + relax_cg_thr 0.5 + out_level "ie" + out_md_control false + relax_new true + relax_bfgs_w1 0.01 + relax_bfgs_w2 0.5 + relax_bfgs_rmax 0.8 + relax_bfgs_rmin 1e-5 + relax_bfgs_init 0.5 + relax_scale_force 0.5 + nbspline -1 + gamma_only false + gamma_only_local false + ecutwfc 50.0 + ecutrho 0.0 + ncx 0 + ncy 0 + ncz 0 + nx 0 + ny 0 + nz 0 + bx 0 + by 0 + bz 0 + diago_proc 0 + pw_diag_nmax 50 + diago_cg_prec 1 + pw_diag_ndim 4 + pw_diag_thr 1.0e-2 + nb2d 0 + nurse 0 + colour 0 + t_in_h 1 + vl_in_h 1 + vnl_in_h 1 + vh_in_h 1 + vion_in_h 1 + test_force 0 + test_stress 0 + scf_thr -1.0 + scf_thr_type -1 + scf_nmax 100 + relax_nmax 0 + out_stru 0 + occupations "smearing" + smearing_method "fixed" + smearing_sigma 0.01 + mixing_mode "pulay" + mixing_beta -10.0 + mixing_ndim 8 + mixing_gg0 0.00 + mixing_tau false + mixing_dftu false + init_wfc "atomic" + mem_saver 0 + printe 100 + init_chg "atomic" + chg_extrap "atomic" + out_freq_elec 0 + out_freq_ion 0 + out_chg 0 + out_dm 0 + out_dm1 0 + out_bandgap 0 + deepks_out_labels 0 + deepks_scf 0 + deepks_bandgap 0 + deepks_out_unittest 0 + out_pot 0 + out_wfc_pw 0 + out_wfc_r 0 + out_dos 0 + out_band 0 + out_proj_band 0 + out_mat_hs 0 + cal_syns 0 + dmax 0.01 + out_mat_hs2 0 + out_mat_t 0 + out_interval 1 + out_app_flag true + out_mat_r 0 + out_mat_dh 0 + out_wfc_lcao false + out_alllog false + dos_emin_ev -15 + dos_emax_ev 15 + dos_edelta_ev 0.01 + dos_scale 0.01 + dos_sigma 0.07 + out_element_info false + lcao_ecut 0 + lcao_dk 0.01 + lcao_dr 0.01 + lcao_rmax 30 + efield_flag false + dip_cor_flag false + efield_dir 2 + efield_pos_max 0.5 + efield_pos_dec 0.1 + efield_amp 0.0 + gate_flag false + zgate 0.5 + relax false + block false + block_down 0.45 + block_up 0.55 + block_height 0.1 + vdw_method "none" + vdw_s6 "default" + vdw_s8 "default" + vdw_a1 "default" + vdw_a2 "default" + vdw_d 20 + vdw_abc false + vdw_cutoff_radius "default" + vdw_radius_unit "Bohr" + vdw_cn_thr 40.0 + vdw_cn_thr_unit "Bohr" + vdw_C6_file "default" + vdw_C6_unit "Jnm6/mol" + vdw_R0_file "default" + vdw_R0_unit "A" + vdw_cutoff_type "radius" + vdw_cutoff_period {3, 3, 3} + exx_hybrid_alpha "default" + exx_hse_omega 0.11 + exx_separate_loop true + exx_hybrid_step 100 + exx_mixing_beta 1.0 + exx_lambda 0.3 + exx_real_number "default" + exx_pca_threshold 1E-4 + exx_c_threshold 1E-4 + exx_v_threshold 1E-1 + exx_dm_threshold 1E-4 + exx_schwarz_threshold 0 + exx_cauchy_threshold 1E-7 + exx_c_grad_threshold 1E-4 + exx_v_grad_threshold 1E-1 + exx_cauchy_force_threshold 1E-7 + exx_cauchy_stress_threshold 1E-7 + exx_ccp_threshold 1E-8 + exx_ccp_rmesh_times "default" + exx_distribute_type "htime" + exx_opt_orb_lmax 0 + exx_opt_orb_ecut 0.0 + exx_opt_orb_tolerence 0.0 + noncolin false + lspinorb false + soc_lambda 1.0 + input_error 0 + td_force_dt 0.02 + td_vext false + td_vext_dire "1" + propagator 0 + out_dipole false + out_efield false + td_print_eij -1.0 + td_edm 0 + td_stype 0 + td_ttype '0' + td_tstart 1 + td_tend 1000 + td_lcut1 0.05 + td_lcut2 0.95 + td_gauss_freq "22.13" + td_gauss_phase "0.0" + td_gauss_sigma "30.0" + td_gauss_t0 "100.0" + td_gauss_amp "0.25" + td_trape_freq "1.60" + td_trape_phase "0.0" + td_trape_t1 "1875" + td_trape_t2 "5625" + td_trape_t3 "7500" + td_trape_amp "2.74" + td_trigo_freq1 "1.164656" + td_trigo_freq2 "0.029116" + td_trigo_phase1 "0.0" + td_trigo_phase2 "0.0" + td_trigo_amp "2.74" + td_heavi_t0 "100" + td_heavi_amp "1.0" + cell_factor 1.2 + out_mul false + restart_save false + restart_load false + test_skip_ewald false + dft_plus_u false + yukawa_potential false + yukawa_lambda -1.0 + omc 0 + dft_plus_dmft false + rpa false + coulomb_type "full" + imp_sol 0 + eb_k 80.0 + tau 1.0798 * 1e-5 + sigma_k 0.6 + nc_k 0.00037 + of_kinetic "wt" + of_method "tn" + of_conv "energy" + of_tole 1e-6 + of_tolp 1e-5 + of_tf_weight 1. + of_vw_weight 1. + of_wt_alpha 5. / 6. + of_wt_beta 5. / 6. + of_wt_rho0 0. + of_hold_rho0 false + of_lkt_a 1.3 + of_full_pw true + of_full_pw_dim 0 + of_read_kernel false + of_kernel_file "WTkernel.txt" + bessel_nao_smooth true + bessel_nao_sigma 0.1 + bessel_nao_ecut "default" + bessel_nao_rcut 6.0 + bessel_nao_tolerence 1E-12 + bessel_descriptor_lmax 2 + bessel_descriptor_smooth true + bessel_descriptor_sigma 0.1 + bessel_descriptor_ecut "default" + bessel_descriptor_rcut 6.0 + bessel_descriptor_tolerence 1E-12 + device "cpu" + precision "double" \ No newline at end of file diff --git a/source/module_io/parameter_pool.cpp b/source/module_io/parameter_pool.cpp new file mode 100644 index 00000000000..8fa599524db --- /dev/null +++ b/source/module_io/parameter_pool.cpp @@ -0,0 +1,1605 @@ +#include "module_io/parameter_pool.h" + +#include +#include +#include +#include +#include + +#include "module_base/constants.h" +#include "module_base/global_file.h" +#include "module_base/global_function.h" +#include "module_base/global_variable.h" +#include "module_base/timer.h" +#include "module_base/vector3.h" +#include "module_io/input.h" +#include "module_md/md_para.h" + +/** + * @param input_parameters Save all input parameters + * @param default_parametes_type Save the names and types of all parameters + */ +namespace ModuleIO +{ + +std::map input_parameters; +std::map default_parametes_type; +std::map default_parametes_value; + +// Conut how many types of atoms are listed in STRU +int count_ntype(const std::string& fn) +{ + // Only RANK0 core can reach here, because this function is called during Input::Read. + assert(GlobalV::MY_RANK == 0); + + std::ifstream ifa(fn.c_str(), std::ios::in); + if (!ifa) + { + GlobalV::ofs_warning << fn; + ModuleBase::WARNING_QUIT("Input::count_ntype", "Can not find the file containing atom positions.!"); + } + + int ntype_stru = 0; + std::string temp; + if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ATOMIC_SPECIES")) + { + while (true) + { + ModuleBase::GlobalFunc::READ_VALUE(ifa, temp); + if (temp == "LATTICE_CONSTANT" || temp == "NUMERICAL_ORBITAL" || temp == "NUMERICAL_DESCRIPTOR" + || ifa.eof()) + { + break; + } + else if (isalpha(temp[0])) + { + ntype_stru += 1; + } + } + } + return ntype_stru; +} + +/** + * @brief New param init function. First, the default parameter types are read, + * then the default parameter values file is read and populated, + * and the values in the map are passed to input.h + * then do the same to input parameter values + * @param default_type_path parameter default type file path + * @param input_value_path parameter default value file path + * @param input_value_path parameter input value file path + */ +bool Init(const std::string& default_type_path, + const std::string& default_value_path, + const std::string& input_value_path) +{ + ModuleBase::timer::tick("Input", "Init"); + default_parametes_reader(default_type_path, default_parametes_type); + input_parameters_get(default_value_path, default_parametes_value); + input_parameters_set(default_parametes_value); + + input_parameters_get(input_value_path, input_parameters); + input_parameters_set(input_parameters); +} + +/** + * @brief Converts the string sa to a minor character and stores it in the string sb + * @param sa Pointer to the string to be converted + * @param sb Store a pointer to the converted string, which needs to be pre-allocated with enough space + */ +void strtolower(char* sa, char* sb) +{ + char c; + int len = strlen(sa); + for (int i = 0; i < len; i++) + { + c = sa[i]; + sb[i] = tolower(c); + } + sb[len] = '\0'; +} // namespace Modlevoid strtolower(char*sa,char*sb) + +/** + * @brief Reads the default parameters from the specified file and saves them to the global variable + * default_parametes_type + * @param fn Specifies the path to the file + * @return true Read successfully + * @return false Read failure + */ +bool default_parametes_reader(const std::string& fn, std::map& default_parametes_type) +{ + std::ifstream inputFile(fn.c_str()); + if (inputFile.is_open()) + { + std::string word1, word2; + while (inputFile >> word1 >> word2) + { + // default_parametes_type[word1] = word2.c_str(); + default_parametes_type.insert(std::pair(word1, word2)); + } + // Close file + inputFile.close(); + } + else + { + std::cout << "Cannot open file !" << std::endl; + } +} +/** + * @brief This function is used to read the input parameter file and store it as a key-value pair + * @param fn Enter the path to the parameter file + */ +bool input_parameters_get(const std::string& fn, std::map& input) +{ + // The module title information is displayed + ModuleBase::TITLE("Input", "Read"); + // If it is not the primary node, return false + if (GlobalV::MY_RANK != 0) + return false; + + // Open the input parameter file + std::ifstream ifs(fn.c_str(), std::ios::in); // "in_datas/input_parameters" + // If the opening fails, an error message is printed and false is returned + if (!ifs) + { + std::cout << " Can't find the INPUT file." << std::endl; + return false; + } + ifs.clear(); + ifs.seekg(0); + char word[80], word1[80]; + int ierr = 0; + + // Read file contents + ifs.rdstate(); + while (ifs.good()) + { + ifs >> word; + ifs.ignore(150, '\n'); // Ignore end of line + if (strcmp(word, "INPUT_PARAMETERS") == 0) + { + ierr = 1; + break; + } + ifs.rdstate(); + } + // If ierr is 0, the word "INPUT_PARAMETERS" is not found, and an error message is printed with false + if (ierr == 0) + { + std::cout << " Error parameter list." << std::endl; + return false; // return error : false + } + ifs.rdstate(); + + bool param_bool; + int param_int; + double param_double; + SimpleString param_string; + SimpleVector param_vector_int; + SimpleVector param_vector_double; + void* param_value; + + // Parameter values are read and stored as key-value pairs + while (ifs.good()) + { + ifs >> word1; + if (ifs.eof()) + break; + strtolower(word1, word); + + //---------------------------------------------------------- + // main parameters + //---------------------------------------------------------- + // The parameter values are read according to the parameter type and stored as key-value pairs + std::string param_type = default_parametes_type[word]; + InputParameter input_param; + if (strcmp(param_type.c_str(), "int") == 0) + { + INPUT.read_value(ifs, param_int); + input_param.type = INT; + input_param.set((void*)(¶m_int)); + } + else if (strcmp(param_type.c_str(), "bool") == 0) + { + + INPUT.read_bool(ifs, param_bool); + input_param.type = BOOL; + input_param.set((void*)(¶m_bool)); + } + else if (strcmp(param_type.c_str(), "double") == 0) + { + INPUT.read_value(ifs, param_double); + input_param.type = DOUBLE; + input_param.set((void*)(¶m_double)); + } + else if (strcmp(param_type.c_str(), "string") == 0) + { + std::string s; + INPUT.read_value(ifs, s); + param_string = s.c_str(); + input_param.type = STRING; + input_param.set((void*)(¶m_string)); + } + else if (strcmp(param_type.c_str(), "vector_int") == 0) + { + int tmp; + std::string s; + std::getline(ifs, s); + std::stringstream ss(s); + while ((ss >> tmp)) + { + param_vector_int.push_back(tmp); + } + input_param.type = VECTOR_I; + input_param.set((void*)(¶m_vector_int)); + } + else if (strcmp(param_type.c_str(), "vector_double") == 0) + { + double tmp; + std::string s; + std::getline(ifs, s); + std::stringstream ss(s); + while ((ss >> tmp)) + { + param_vector_double.push_back(tmp); + } + input_param.type = VECTOR_D; + input_param.set((void*)(¶m_vector_double)); + } + else + { + // xiaohui add 2015-09-15 + if (word[0] != '#' && word[0] != '/') + { + INPUT.input_error = 1; + std::cout << " THE PARAMETER NAME '" << word << "' IS NOT USED!" << std::endl; + } + // mohan screen this 2012-06-30 + // std::cout << " THE PARAMETER NAME '" << word + // << "' IS NOT USED!" << std::endl; + ifs.ignore(150, '\n'); + } + ifs.rdstate(); + + /*if(gamma_only == 1) + { + gamma_only_local = 1; //pengfei 2014-10-15 + gamma_only = 0; + std::cout << "gamma_only_local = " << gamma_only_local < input_parameters) +{ + if (input_parameters.count("nupdown") != 0) + { + INPUT.nupdown = *static_cast(input_parameters["nupdown"].get()); + } + else if (input_parameters.count("suffix") != 0) + { + INPUT.suffix = static_cast(input_parameters["suffix"].get())->c_str(); + } + else if (input_parameters.count("stru_file") != 0) + { + INPUT.stru_file = static_cast(input_parameters["stru_file"].get())->c_str(); + } + else if (input_parameters.count("pseudo_dir") != 0) + { + INPUT.pseudo_dir = static_cast(input_parameters["pseudo_dir"].get())->c_str(); + } + else if (input_parameters.count("orbital_dir") != 0) + { + INPUT.orbital_dir = static_cast(input_parameters["orbital_dir"].get())->c_str(); + } + else if (input_parameters.count("read_file_dir") != 0) + { + INPUT.read_file_dir = static_cast(input_parameters["read_file_dir"].get())->c_str(); + } + else if (input_parameters.count("kpoint_file") != 0) + { + INPUT.kpoint_file = static_cast(input_parameters["kpoint_file"].get())->c_str(); + } + else if (input_parameters.count("wannier_card") != 0) + { + INPUT.wannier_card = static_cast(input_parameters["wannier_card"].get())->c_str(); + } + else if (input_parameters.count("latname") != 0) + { + INPUT.latname = static_cast(input_parameters["latname"].get())->c_str(); + } + else if (input_parameters.count("calculation") != 0) + { + INPUT.calculation = static_cast(input_parameters["calculation"].get())->c_str(); + } + else if (input_parameters.count("esolver_type") != 0) + { + INPUT.esolver_type = static_cast(input_parameters["esolver_type"].get())->c_str(); + } + else if (input_parameters.count("pseudo_rcut") != 0) + { + INPUT.pseudo_rcut = *static_cast(input_parameters["pseudo_rcut"].get()); + } + else if (input_parameters.count("pseudo_mesh") != 0) + { + INPUT.pseudo_mesh = *static_cast(input_parameters["pseudo_mesh"].get()); + } + else if (input_parameters.count("ntype") != 0) + { + INPUT.ntype = *static_cast(input_parameters["ntype"].get()); + } + else if (input_parameters.count("nbands") != 0) + { + INPUT.nbands = *static_cast(input_parameters["nbands"].get()); + } + else if (input_parameters.count("nbands_istate") != 0) + { + INPUT.nbands_istate = *static_cast(input_parameters["nbands_istate"].get()); + } + else if (input_parameters.count("pw_seed") != 0) + { + INPUT.pw_seed = *static_cast(input_parameters["pw_seed"].get()); + } + else if (input_parameters.count("init_vel") != 0) + { + INPUT.init_vel = *static_cast(input_parameters["init_vel"].get()); + } + else if (input_parameters.count("ref_cell_factor") != 0) + { + INPUT.ref_cell_factor = *static_cast(input_parameters["ref_cell_factor"].get()); + } + else if (input_parameters.count("symmetry") != 0) + { + INPUT.symmetry = *static_cast(input_parameters["symmetry"].get()); + } + else if (input_parameters.count("symmetry_prec") != 0) + { + INPUT.symmetry_prec = *static_cast(input_parameters["symmetry_prec"].get()); + } + else if (input_parameters.count("kpar") != 0) + { + INPUT.kpar = *static_cast(input_parameters["kpar"].get()); + } + else if (input_parameters.count("berry_phase") != 0) + { + INPUT.berry_phase = *static_cast(input_parameters["berry_phase"].get()); + } + else if (input_parameters.count("gdir") != 0) + { + INPUT.gdir = *static_cast(input_parameters["gdir"].get()); + } + else if (input_parameters.count("kspacing") != 0) + { + SimpleVector vec_D = *static_cast*>(input_parameters["kspacing"].get()); + for (int i = 0; i <= vec_D.size(); i++) + { + INPUT.kspacing[i] = vec_D[i]; + } + if (vec_D.size() == 0 || vec_D.size() == 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 (vec_D.size() == 1) + { + INPUT.kspacing[1] = INPUT.kspacing[0]; + INPUT.kspacing[2] = INPUT.kspacing[0]; + } + } + else if (input_parameters.count("min_dist_coef") != 0) + { + INPUT.min_dist_coef = *static_cast(input_parameters["min_dist_coef"].get()); + } + else if (input_parameters.count("towannier90") != 0) + { + INPUT.towannier90 = *static_cast(input_parameters["towannier90"].get()); + } + else if (input_parameters.count("nnkpfile") != 0) + { + INPUT.nnkpfile = static_cast(input_parameters["nnkpfile"].get())->c_str(); + } + else if (input_parameters.count("wannier_spin") != 0) + { + INPUT.wannier_spin = static_cast(input_parameters["wannier_spin"].get())->c_str(); + } + else if (input_parameters.count("nche_sto") != 0) + { + INPUT.nche_sto = *static_cast(input_parameters["nche_sto"].get()); + } + else if (input_parameters.count("nbands_sto") != 0) + { + INPUT.nbands_sto = *static_cast(input_parameters["nbands_sto"].get()); + } + else if (input_parameters.count("nbndsto_str") != 0) + { + INPUT.nbndsto_str = static_cast(input_parameters["nbndsto_str"].get())->c_str(); + } + else if (input_parameters.count("seed_sto") != 0) + { + INPUT.seed_sto = *static_cast(input_parameters["seed_sto"].get()); + } + else if (input_parameters.count("emax_sto") != 0) + { + INPUT.emax_sto = *static_cast(input_parameters["emax_sto"].get()); + } + else if (input_parameters.count("emin_sto") != 0) + { + INPUT.emin_sto = *static_cast(input_parameters["emin_sto"].get()); + } + else if (input_parameters.count("bndpar") != 0) + { + INPUT.bndpar = *static_cast(input_parameters["bndpar"].get()); + } + else if (input_parameters.count("initsto_freq") != 0) + { + INPUT.initsto_freq = *static_cast(input_parameters["initsto_freq"].get()); + } + else if (input_parameters.count("method_sto") != 0) + { + INPUT.method_sto = *static_cast(input_parameters["method_sto"].get()); + } + else if (input_parameters.count("npart_sto") != 0) + { + INPUT.npart_sto = *static_cast(input_parameters["npart_sto"].get()); + } + else if (input_parameters.count("cal_cond") != 0) + { + INPUT.cal_cond = *static_cast(input_parameters["cal_cond"].get()); + } + else if (input_parameters.count("cond_nche") != 0) + { + INPUT.cond_nche = *static_cast(input_parameters["cond_nche"].get()); + } + else if (input_parameters.count("cond_dw") != 0) + { + INPUT.cond_dw = *static_cast(input_parameters["cond_dw"].get()); + } + else if (input_parameters.count("cond_wcut") != 0) + { + INPUT.cond_wcut = *static_cast(input_parameters["cond_wcut"].get()); + } + else if (input_parameters.count("cond_dt") != 0) + { + INPUT.cond_dt = *static_cast(input_parameters["cond_dt"].get()); + } + else if (input_parameters.count("cond_dtbatch") != 0) + { + INPUT.cond_dtbatch = *static_cast(input_parameters["cond_dtbatch"].get()); + } + else if (input_parameters.count("cond_fwhm") != 0) + { + INPUT.cond_fwhm = *static_cast(input_parameters["cond_fwhm"].get()); + } + else if (input_parameters.count("cond_nonlocal") != 0) + { + INPUT.cond_nonlocal = *static_cast(input_parameters["cond_nonlocal"].get()); + } + else if (input_parameters.count("dft_functional") != 0) + { + INPUT.dft_functional = static_cast(input_parameters["dft_functional"].get())->c_str(); + } + else if (input_parameters.count("xc_temperature") != 0) + { + INPUT.xc_temperature = *static_cast(input_parameters["xc_temperature"].get()); + } + else if (input_parameters.count("nspin") != 0) + { + INPUT.nspin = *static_cast(input_parameters["nspin"].get()); + } + else if (input_parameters.count("nupdown") != 0) + { + INPUT.nupdown = *static_cast(input_parameters["nupdown"].get()); + } + else if (input_parameters.count("nelec") != 0) + { + INPUT.nelec = *static_cast(input_parameters["nelec"].get()); + } + else if (input_parameters.count("lmaxmax") != 0) + { + INPUT.lmaxmax = *static_cast(input_parameters["lmaxmax"].get()); + } + else if (input_parameters.count("basis_type") != 0) + { + INPUT.basis_type = static_cast(input_parameters["basis_type"].get())->c_str(); + } + else if (input_parameters.count("ks_solver") != 0) + { + INPUT.ks_solver = static_cast(input_parameters["ks_solver"].get())->c_str(); + } + else if (input_parameters.count("cal_force") != 0) + { + INPUT.cal_force = *static_cast(input_parameters["cal_force"].get()); + } + else if (input_parameters.count("force_thr") != 0) + { + INPUT.force_thr = *static_cast(input_parameters["force_thr"].get()); + } + else if (input_parameters.count("force_thr_ev2") != 0) + { + INPUT.force_thr_ev2 = *static_cast(input_parameters["force_thr_ev2"].get()); + } + else if (input_parameters.count("stress_thr") != 0) + { + INPUT.stress_thr = *static_cast(input_parameters["stress_thr"].get()); + } + else if (input_parameters.count("press1") != 0) + { + INPUT.press1 = *static_cast(input_parameters["press1"].get()); + } + else if (input_parameters.count("press2") != 0) + { + INPUT.press2 = *static_cast(input_parameters["press2"].get()); + } + else if (input_parameters.count("press3") != 0) + { + INPUT.press3 = *static_cast(input_parameters["press3"].get()); + } + else if (input_parameters.count("cal_stress") != 0) + { + INPUT.cal_stress = *static_cast(input_parameters["cal_stress"].get()); + } + else if (input_parameters.count("fixed_axes") != 0) + { + INPUT.fixed_axes = static_cast(input_parameters["fixed_axes"].get())->c_str(); + } + else if (input_parameters.count("fixed_ibrav") != 0) + { + INPUT.fixed_ibrav = *static_cast(input_parameters["fixed_ibrav"].get()); + } + else if (input_parameters.count("fixed_atoms") != 0) + { + INPUT.fixed_atoms = *static_cast(input_parameters["fixed_atoms"].get()); + } + else if (input_parameters.count("relax_method") != 0) + { + INPUT.relax_method = static_cast(input_parameters["relax_method"].get())->c_str(); + } + else if (input_parameters.count("relax_new") != 0) + { + INPUT.relax_new = *static_cast(input_parameters["relax_new"].get()); + } + else if (input_parameters.count("relax_cg_thr") != 0) + { + INPUT.relax_cg_thr = *static_cast(input_parameters["relax_cg_thr"].get()); + } + else if (input_parameters.count("relax_bfgs_w1") != 0) + { + INPUT.relax_bfgs_w1 = *static_cast(input_parameters["relax_bfgs_w1"].get()); + } + else if (input_parameters.count("relax_bfgs_w2") != 0) + { + INPUT.relax_bfgs_w2 = *static_cast(input_parameters["relax_bfgs_w2"].get()); + } + else if (input_parameters.count("relax_bfgs_rmax") != 0) + { + INPUT.relax_bfgs_rmax = *static_cast(input_parameters["relax_bfgs_rmax"].get()); + } + else if (input_parameters.count("relax_bfgs_rmin") != 0) + { + INPUT.relax_bfgs_rmin = *static_cast(input_parameters["relax_bfgs_rmin"].get()); + } + else if (input_parameters.count("relax_bfgs_init") != 0) + { + INPUT.relax_bfgs_init = *static_cast(input_parameters["relax_bfgs_init"].get()); + } + else if (input_parameters.count("relax_scale_force") != 0) + { + INPUT.relax_scale_force = *static_cast(input_parameters["relax_scale_force"].get()); + } + else if (input_parameters.count("gamma_only") != 0) + { + INPUT.gamma_only = *static_cast(input_parameters["gamma_only"].get()); + } + else if (input_parameters.count("gamma_only_local") != 0) + { + INPUT.gamma_only_local = *static_cast(input_parameters["gamma_only_local"].get()); + } + else if (input_parameters.count("ecutwfc") != 0) + { + INPUT.ecutwfc = *static_cast(input_parameters["ecutwfc"].get()); + } + else if (input_parameters.count("ecutrho") != 0) + { + INPUT.ecutrho = *static_cast(input_parameters["ecutrho"].get()); + } + else if (input_parameters.count("ncx") != 0) + { + INPUT.ncx = *static_cast(input_parameters["ncx"].get()); + } + else if (input_parameters.count("ncy") != 0) + { + INPUT.ncy = *static_cast(input_parameters["ncy"].get()); + } + else if (input_parameters.count("ncz") != 0) + { + INPUT.ncz = *static_cast(input_parameters["ncz"].get()); + } + else if (input_parameters.count("nx") != 0) + { + INPUT.nx = *static_cast(input_parameters["nx"].get()); + } + else if (input_parameters.count("ny") != 0) + { + INPUT.ny = *static_cast(input_parameters["ny"].get()); + } + else if (input_parameters.count("nz") != 0) + { + INPUT.nz = *static_cast(input_parameters["nz"].get()); + } + else if (input_parameters.count("bx") != 0) + { + INPUT.bx = *static_cast(input_parameters["bx"].get()); + } + else if (input_parameters.count("by") != 0) + { + INPUT.by = *static_cast(input_parameters["by"].get()); + } + else if (input_parameters.count("bz") != 0) + { + INPUT.bz = *static_cast(input_parameters["bz"].get()); + } + else if (input_parameters.count("diago_proc") != 0) + { + INPUT.diago_proc = *static_cast(input_parameters["diago_proc"].get()); + } + else if (input_parameters.count("pw_diag_nmax") != 0) + { + INPUT.pw_diag_nmax = *static_cast(input_parameters["pw_diag_nmax"].get()); + } + else if (input_parameters.count("diago_cg_prec") != 0) + { + INPUT.diago_cg_prec = *static_cast(input_parameters["diago_cg_prec"].get()); + } + else if (input_parameters.count("pw_diag_ndim") != 0) + { + INPUT.pw_diag_ndim = *static_cast(input_parameters["pw_diag_ndim"].get()); + } + else if (input_parameters.count("pw_diag_thr") != 0) + { + INPUT.pw_diag_thr = *static_cast(input_parameters["pw_diag_thr"].get()); + } + else if (input_parameters.count("nb2d") != 0) + { + INPUT.nb2d = *static_cast(input_parameters["nb2d"].get()); + } + else if (input_parameters.count("nurse") != 0) + { + INPUT.nurse = *static_cast(input_parameters["nurse"].get()); + } + else if (input_parameters.count("nbspline") != 0) + { + INPUT.nbspline = *static_cast(input_parameters["nbspline"].get()); + } + else if (input_parameters.count("colour") != 0) + { + INPUT.colour = *static_cast(input_parameters["colour"].get()); + } + else if (input_parameters.count("t_in_h") != 0) + { + INPUT.t_in_h = *static_cast(input_parameters["t_in_h"].get()); + } + else if (input_parameters.count("vl_in_h") != 0) + { + INPUT.vl_in_h = *static_cast(input_parameters["vl_in_h"].get()); + } + else if (input_parameters.count("vnl_in_h") != 0) + { + INPUT.vnl_in_h = *static_cast(input_parameters["vnl_in_h"].get()); + } + else if (input_parameters.count("vh_in_h") != 0) + { + INPUT.vh_in_h = *static_cast(input_parameters["vh_in_h"].get()); + } + else if (input_parameters.count("vion_in_h") != 0) + { + INPUT.vion_in_h = *static_cast(input_parameters["vion_in_h"].get()); + } + else if (input_parameters.count("test_force") != 0) + { + INPUT.test_force = *static_cast(input_parameters["test_force"].get()); + } + else if (input_parameters.count("test_stress") != 0) + { + INPUT.test_stress = *static_cast(input_parameters["test_stress"].get()); + } + else if (input_parameters.count("scf_thr") != 0) + { + INPUT.scf_thr = *static_cast(input_parameters["scf_thr"].get()); + } + else if (input_parameters.count("scf_thr_type") != 0) + { + INPUT.scf_thr_type = *static_cast(input_parameters["scf_thr_type"].get()); + } + else if (input_parameters.count("scf_nmax") != 0) + { + INPUT.scf_nmax = *static_cast(input_parameters["scf_nmax"].get()); + } + else if (input_parameters.count("relax_nmax") != 0) + { + INPUT.relax_nmax = *static_cast(input_parameters["relax_nmax"].get()); + } + else if (input_parameters.count("out_stru") != 0) + { + INPUT.out_stru = *static_cast(input_parameters["out_stru"].get()); + } + else if (input_parameters.count("out_level") != 0) + { + INPUT.out_level = static_cast(input_parameters["out_level"].get())->c_str(); + } + else if (input_parameters.count("out_md_control") != 0) + { + INPUT.out_md_control = *static_cast(input_parameters["out_md_control"].get()); + } + else if (input_parameters.count("occupations") != 0) + { + INPUT.occupations = static_cast(input_parameters["occupations"].get())->c_str(); + } + else if (input_parameters.count("smearing_method") != 0) + { + INPUT.smearing_method = static_cast(input_parameters["smearing_method"].get())->c_str(); + } + else if (input_parameters.count("smearing_sigma") != 0) + { + INPUT.smearing_sigma = *static_cast(input_parameters["smearing_sigma"].get()); + } + else if (input_parameters.count("mixing_mode") != 0) + { + INPUT.mixing_mode = static_cast(input_parameters["mixing_mode"].get())->c_str(); + } + else if (input_parameters.count("mixing_beta") != 0) + { + INPUT.mixing_beta = *static_cast(input_parameters["mixing_beta"].get()); + } + else if (input_parameters.count("mixing_ndim") != 0) + { + INPUT.mixing_ndim = *static_cast(input_parameters["mixing_ndim"].get()); + } + else if (input_parameters.count("mixing_gg0") != 0) + { + INPUT.mixing_gg0 = *static_cast(input_parameters["mixing_gg0"].get()); + } + else if (input_parameters.count("mixing_tau") != 0) + { + INPUT.mixing_tau = *static_cast(input_parameters["mixing_tau"].get()); + } + else if (input_parameters.count("mixing_dftu") != 0) + { + INPUT.mixing_dftu = *static_cast(input_parameters["mixing_dftu"].get()); + } + else if (input_parameters.count("init_wfc") != 0) + { + INPUT.init_wfc = static_cast(input_parameters["init_wfc"].get())->c_str(); + } + else if (input_parameters.count("init_chg") != 0) + { + INPUT.init_chg = static_cast(input_parameters["init_chg"].get())->c_str(); + } + else if (input_parameters.count("chg_extrap") != 0) + { + INPUT.chg_extrap = static_cast(input_parameters["chg_extrap"].get())->c_str(); + } + else if (input_parameters.count("mem_saver") != 0) + { + INPUT.mem_saver = *static_cast(input_parameters["mem_saver"].get()); + } + else if (input_parameters.count("printe") != 0) + { + INPUT.printe = *static_cast(input_parameters["printe"].get()); + } + else if (input_parameters.count("out_freq_elec") != 0) + { + INPUT.out_freq_elec = *static_cast(input_parameters["out_freq_elec"].get()); + } + else if (input_parameters.count("out_freq_ion") != 0) + { + INPUT.out_freq_ion = *static_cast(input_parameters["out_freq_ion"].get()); + } + else if (input_parameters.count("out_chg") != 0) + { + INPUT.out_chg = *static_cast(input_parameters["out_chg"].get()); + } + else if (input_parameters.count("out_dm") != 0) + { + INPUT.out_dm = *static_cast(input_parameters["out_dm"].get()); + } + else if (input_parameters.count("out_dm1") != 0) + { + INPUT.out_dm1 = *static_cast(input_parameters["out_dm1"].get()); + } + else if (input_parameters.count("out_pot") != 0) + { + INPUT.out_pot = *static_cast(input_parameters["out_pot"].get()); + } + else if (input_parameters.count("out_wfc_pw") != 0) + { + INPUT.out_wfc_pw = *static_cast(input_parameters["out_wfc_pw"].get()); + } + else if (input_parameters.count("out_wfc_r") != 0) + { + INPUT.out_wfc_r = *static_cast(input_parameters["out_wfc_r"].get()); + } + else if (input_parameters.count("out_dos") != 0) + { + INPUT.out_dos = *static_cast(input_parameters["out_dos"].get()); + } + else if (input_parameters.count("out_band") != 0) + { + INPUT.out_band = *static_cast(input_parameters["out_band"].get()); + } + else if (input_parameters.count("out_proj_band") != 0) + { + INPUT.out_proj_band = *static_cast(input_parameters["out_proj_band"].get()); + } + else if (input_parameters.count("out_mat_hs") != 0) + { + INPUT.out_mat_hs = *static_cast(input_parameters["out_mat_hs"].get()); + } + else if (input_parameters.count("cal_syns") != 0) + { + INPUT.cal_syns = *static_cast(input_parameters["cal_syns"].get()); + } + else if (input_parameters.count("dmax") != 0) + { + INPUT.dmax = *static_cast(input_parameters["dmax"].get()); + } + else if (input_parameters.count("out_mat_hs2") != 0) + { + INPUT.out_mat_hs2 = *static_cast(input_parameters["out_mat_hs2"].get()); + } + else if (input_parameters.count("out_mat_dh") != 0) + { + INPUT.out_mat_dh = *static_cast(input_parameters["out_mat_dh"].get()); + } + else if (input_parameters.count("out_interval") != 0) + { + INPUT.out_interval = *static_cast(input_parameters["out_interval"].get()); + } + else if (input_parameters.count("out_app_flag") != 0) + { + INPUT.out_app_flag = *static_cast(input_parameters["out_app_flag"].get()); + } + else if (input_parameters.count("out_mat_t") != 0) + { + INPUT.out_mat_t = *static_cast(input_parameters["out_mat_t"].get()); + } + else if (input_parameters.count("out_mat_r") != 0) + { + INPUT.out_mat_r = *static_cast(input_parameters["out_mat_r"].get()); + } + else if (input_parameters.count("out_wfc_lcao") != 0) + { + INPUT.out_wfc_lcao = *static_cast(input_parameters["out_wfc_lcao"].get()); + } + else if (input_parameters.count("out_alllog") != 0) + { + INPUT.out_alllog = *static_cast(input_parameters["out_alllog"].get()); + } + else if (input_parameters.count("out_element_info") != 0) + { + INPUT.out_element_info = *static_cast(input_parameters["out_element_info"].get()); + } + else if (input_parameters.count("out_bandgap") != 0) + { + INPUT.out_bandgap = *static_cast(input_parameters["out_bandgap"].get()); + } + else if (input_parameters.count("dos_emin_ev") != 0) + { + INPUT.dos_emin_ev = *static_cast(input_parameters["dos_emin_ev"].get()); + } + else if (input_parameters.count("dos_emax_ev") != 0) + { + INPUT.dos_emax_ev = *static_cast(input_parameters["dos_emax_ev"].get()); + } + if (input_parameters.count("dos_edelta_ev") != 0) + { + INPUT.dos_edelta_ev = *static_cast(input_parameters["dos_edelta_ev"].get()); + } + else if (input_parameters.count("dos_scale") != 0) + { + INPUT.dos_scale = *static_cast(input_parameters["dos_scale"].get()); + } + else if (input_parameters.count("dos_nche") != 0) + { + INPUT.dos_nche = *static_cast(input_parameters["dos_nche"].get()); + } + else if (input_parameters.count("dos_setemin") != 0) + { + INPUT.dos_setemin = *static_cast(input_parameters["dos_setemin"].get()); + } + else if (input_parameters.count("dos_setemax") != 0) + { + INPUT.dos_setemax = *static_cast(input_parameters["dos_setemax"].get()); + } + else if (input_parameters.count("dos_sigma") != 0) + { + INPUT.dos_sigma = *static_cast(input_parameters["dos_sigma"].get()); + } + else if (input_parameters.count("lcao_ecut") != 0) + { + INPUT.lcao_ecut = *static_cast(input_parameters["lcao_ecut"].get()); + } + else if (input_parameters.count("lcao_dk") != 0) + { + INPUT.lcao_dk = *static_cast(input_parameters["lcao_dk"].get()); + } + else if (input_parameters.count("lcao_dr") != 0) + { + INPUT.lcao_dr = *static_cast(input_parameters["lcao_dr"].get()); + } + else if (input_parameters.count("lcao_rmax") != 0) + { + INPUT.lcao_rmax = *static_cast(input_parameters["lcao_rmax"].get()); + } + else if (input_parameters.count("search_radius") != 0) + { + INPUT.search_radius = *static_cast(input_parameters["search_radius"].get()); + } + else if (input_parameters.count("search_pbc") != 0) + { + INPUT.search_pbc = *static_cast(input_parameters["search_pbc"].get()); + } + else if (input_parameters.count("mdp") != 0) + { + // INPUT.mdp = static_cast(input_parameters["mdp"].get()); + } + else if (input_parameters.count("efield_flag") != 0) + { + INPUT.efield_flag = *static_cast(input_parameters["efield_flag"].get()); + } + else if (input_parameters.count("dip_cor_flag") != 0) + { + INPUT.dip_cor_flag = *static_cast(input_parameters["dip_cor_flag"].get()); + } + else if (input_parameters.count("efield_dir") != 0) + { + INPUT.efield_dir = *static_cast(input_parameters["efield_dir"].get()); + } + else if (input_parameters.count("efield_pos_max") != 0) + { + INPUT.efield_pos_max = *static_cast(input_parameters["efield_pos_max"].get()); + } + else if (input_parameters.count("efield_pos_dec") != 0) + { + INPUT.efield_pos_dec = *static_cast(input_parameters["efield_pos_dec"].get()); + } + else if (input_parameters.count("efield_amp") != 0) + { + INPUT.efield_amp = *static_cast(input_parameters["efield_amp"].get()); + } + else if (input_parameters.count("gate_flag") != 0) + { + INPUT.gate_flag = *static_cast(input_parameters["gate_flag"].get()); + } + else if (input_parameters.count("zgate") != 0) + { + INPUT.zgate = *static_cast(input_parameters["zgate"].get()); + } + else if (input_parameters.count("relax") != 0) + { + INPUT.relax = *static_cast(input_parameters["relax"].get()); + } + else if (input_parameters.count("block") != 0) + { + INPUT.block = *static_cast(input_parameters["block"].get()); + } + else if (input_parameters.count("block_down") != 0) + { + INPUT.block_down = *static_cast(input_parameters["block_down"].get()); + } + else if (input_parameters.count("block_up") != 0) + { + INPUT.block_up = *static_cast(input_parameters["block_up"].get()); + } + else if (input_parameters.count("block_height") != 0) + { + INPUT.block_height = *static_cast(input_parameters["block_height"].get()); + } + else if (input_parameters.count("vdw_method") != 0) + { + INPUT.vdw_method = static_cast(input_parameters["vdw_method"].get())->c_str(); + } + else if (input_parameters.count("vdw_s6") != 0) + { + INPUT.vdw_s6 = static_cast(input_parameters["vdw_s6"].get())->c_str(); + } + else if (input_parameters.count("vdw_s8") != 0) + { + INPUT.vdw_s8 = static_cast(input_parameters["vdw_s8"].get())->c_str(); + } + else if (input_parameters.count("vdw_a1") != 0) + { + INPUT.vdw_a1 = static_cast(input_parameters["vdw_a1"].get())->c_str(); + } + else if (input_parameters.count("vdw_a2") != 0) + { + INPUT.vdw_a2 = static_cast(input_parameters["vdw_a2"].get())->c_str(); + } + else if (input_parameters.count("vdw_d") != 0) + { + INPUT.vdw_d = *static_cast(input_parameters["vdw_d"].get()); + } + else if (input_parameters.count("vdw_abc") != 0) + { + INPUT.vdw_abc = *static_cast(input_parameters["vdw_abc"].get()); + } + else if (input_parameters.count("vdw_cutoff_radius") != 0) + { + INPUT.vdw_cutoff_radius = static_cast(input_parameters["vdw_cutoff_radius"].get())->c_str(); + } + else if (input_parameters.count("vdw_radius_unit") != 0) + { + INPUT.vdw_radius_unit = static_cast(input_parameters["vdw_radius_unit"].get())->c_str(); + } + else if (input_parameters.count("vdw_cn_thr") != 0) + { + INPUT.vdw_cn_thr = *static_cast(input_parameters["vdw_cn_thr"].get()); + } + else if (input_parameters.count("vdw_cn_thr_unit") != 0) + { + INPUT.vdw_cn_thr_unit = static_cast(input_parameters["vdw_cn_thr_unit"].get())->c_str(); + } + else if (input_parameters.count("vdw_C6_file") != 0) + { + INPUT.vdw_C6_file = static_cast(input_parameters["vdw_C6_file"].get())->c_str(); + } + else if (input_parameters.count("vdw_C6_unit") != 0) + { + INPUT.vdw_C6_unit = static_cast(input_parameters["vdw_C6_unit"].get())->c_str(); + } + else if (input_parameters.count("vdw_R0_file") != 0) + { + INPUT.vdw_R0_file = static_cast(input_parameters["vdw_R0_file"].get())->c_str(); + } + else if (input_parameters.count("vdw_R0_unit") != 0) + { + INPUT.vdw_R0_unit = static_cast(input_parameters["vdw_R0_unit"].get())->c_str(); + } + else if (input_parameters.count("vdw_cutoff_type") != 0) + { + INPUT.vdw_cutoff_type = static_cast(input_parameters["vdw_cutoff_type"].get())->c_str(); + } + else if (input_parameters.count("vdw_cutoff_period") != 0) + { + // INPUT.vdw_cutoff_period = static_cast>(input_parameters["vdw_cutoff_period"].get()); + } + else if (input_parameters.count("ocp") != 0) + { + INPUT.ocp = *static_cast(input_parameters["ocp"].get()); + } + else if (input_parameters.count("ocp_set") != 0) + { + INPUT.ocp_set = static_cast(input_parameters["ocp_set"].get())->c_str(); + } + else if (input_parameters.count("out_mul") != 0) + { + INPUT.out_mul = *static_cast(input_parameters["out_mul"].get()); + } + else if (input_parameters.count("noncolin") != 0) + { + INPUT.noncolin = *static_cast(input_parameters["noncolin"].get()); + } + else if (input_parameters.count("lspinorb") != 0) + { + INPUT.lspinorb = *static_cast(input_parameters["lspinorb"].get()); + } + else if (input_parameters.count("soc_lambda") != 0) + { + INPUT.soc_lambda = *static_cast(input_parameters["soc_lambda"].get()); + } + else if (input_parameters.count("exx_hybrid_alpha") != 0) + { + INPUT.exx_hybrid_alpha = static_cast(input_parameters["exx_hybrid_alpha"].get())->c_str(); + } + else if (input_parameters.count("exx_hse_omega") != 0) + { + INPUT.exx_hse_omega = *static_cast(input_parameters["exx_hse_omega"].get()); + } + else if (input_parameters.count("exx_separate_loop") != 0) + { + INPUT.exx_separate_loop = *static_cast(input_parameters["exx_separate_loop"].get()); + } + else if (input_parameters.count("exx_hybrid_step") != 0) + { + INPUT.exx_hybrid_step = *static_cast(input_parameters["exx_hybrid_step"].get()); + } + else if (input_parameters.count("exx_mixing_beta") != 0) + { + INPUT.exx_mixing_beta = *static_cast(input_parameters["exx_mixing_beta"].get()); + } + else if (input_parameters.count("exx_lambda") != 0) + { + INPUT.exx_lambda = *static_cast(input_parameters["exx_lambda"].get()); + } + else if (input_parameters.count("exx_real_number") != 0) + { + INPUT.exx_real_number = static_cast(input_parameters["exx_real_number"].get())->c_str(); + } + else if (input_parameters.count("exx_pca_threshold") != 0) + { + INPUT.exx_pca_threshold = *static_cast(input_parameters["exx_pca_threshold"].get()); + } + else if (input_parameters.count("exx_c_threshold") != 0) + { + INPUT.exx_c_threshold = *static_cast(input_parameters["exx_c_threshold"].get()); + } + else if (input_parameters.count("exx_v_threshold") != 0) + { + INPUT.exx_v_threshold = *static_cast(input_parameters["exx_v_threshold"].get()); + } + else if (input_parameters.count("exx_dm_threshold") != 0) + { + INPUT.exx_dm_threshold = *static_cast(input_parameters["exx_dm_threshold"].get()); + } + else if (input_parameters.count("exx_schwarz_threshold") != 0) + { + INPUT.exx_schwarz_threshold = *static_cast(input_parameters["exx_schwarz_threshold"].get()); + } + else if (input_parameters.count("exx_cauchy_threshold") != 0) + { + INPUT.exx_cauchy_threshold = *static_cast(input_parameters["exx_cauchy_threshold"].get()); + } + else if (input_parameters.count("exx_c_grad_threshold") != 0) + { + INPUT.exx_c_grad_threshold = *static_cast(input_parameters["exx_c_grad_threshold"].get()); + } + else if (input_parameters.count("exx_v_grad_threshold") != 0) + { + INPUT.exx_v_grad_threshold = *static_cast(input_parameters["exx_v_grad_threshold"].get()); + } + else if (input_parameters.count("exx_cauchy_force_threshold") != 0) + { + INPUT.exx_cauchy_force_threshold = *static_cast(input_parameters["exx_cauchy_force_threshold"].get()); + } + else if (input_parameters.count("exx_cauchy_stress_threshold") != 0) + { + INPUT.exx_cauchy_stress_threshold + = *static_cast(input_parameters["exx_cauchy_stress_threshold"].get()); + } + else if (input_parameters.count("exx_ccp_threshold") != 0) + { + INPUT.exx_ccp_threshold = *static_cast(input_parameters["exx_ccp_threshold"].get()); + } + else if (input_parameters.count("exx_ccp_rmesh_times") != 0) + { + INPUT.exx_ccp_rmesh_times = static_cast(input_parameters["exx_ccp_rmesh_times"].get())->c_str(); + } + else if (input_parameters.count("exx_distribute_type") != 0) + { + INPUT.exx_distribute_type = static_cast(input_parameters["exx_distribute_type"].get())->c_str(); + } + else if (input_parameters.count("exx_opt_orb_lmax") != 0) + { + INPUT.exx_opt_orb_lmax = *static_cast(input_parameters["exx_opt_orb_lmax"].get()); + } + else if (input_parameters.count("exx_opt_orb_ecut") != 0) + { + INPUT.exx_opt_orb_ecut = *static_cast(input_parameters["exx_opt_orb_ecut"].get()); + } + else if (input_parameters.count("exx_opt_orb_tolerence") != 0) + { + INPUT.exx_opt_orb_tolerence = *static_cast(input_parameters["exx_opt_orb_tolerence"].get()); + } + else if (input_parameters.count("td_force_dt") != 0) + { + INPUT.td_force_dt = *static_cast(input_parameters["td_force_dt"].get()); + } + else if (input_parameters.count("td_vext") != 0) + { + INPUT.td_vext = *static_cast(input_parameters["td_vext"].get()); + } + else if (input_parameters.count("td_vext_dire") != 0) + { + INPUT.td_vext_dire = static_cast(input_parameters["td_vext_dire"].get())->c_str(); + } + else if (input_parameters.count("out_dipole") != 0) + { + INPUT.out_dipole = *static_cast(input_parameters["out_dipole"].get()); + } + else if (input_parameters.count("out_efield") != 0) + { + INPUT.out_efield = *static_cast(input_parameters["out_efield"].get()); + } + else if (input_parameters.count("td_print_eij") != 0) + { + INPUT.td_print_eij = *static_cast(input_parameters["td_print_eij"].get()); + } + else if (input_parameters.count("td_edm") != 0) + { + INPUT.td_edm = *static_cast(input_parameters["td_edm"].get()); + } + else if (input_parameters.count("propagator") != 0) + { + INPUT.propagator = *static_cast(input_parameters["propagator"].get()); + } + else if (input_parameters.count("td_stype") != 0) + { + INPUT.td_stype = *static_cast(input_parameters["td_stype"].get()); + } + else if (input_parameters.count("td_ttype") != 0) + { + INPUT.td_ttype = static_cast(input_parameters["td_ttype"].get())->c_str(); + } + else if (input_parameters.count("td_tstart") != 0) + { + INPUT.td_tstart = *static_cast(input_parameters["td_tstart"].get()); + } + else if (input_parameters.count("td_tend") != 0) + { + INPUT.td_tend = *static_cast(input_parameters["td_tend"].get()); + } + else if (input_parameters.count("td_lcut1") != 0) + { + INPUT.td_lcut1 = *static_cast(input_parameters["td_lcut1"].get()); + } + else if (input_parameters.count("td_lcut2") != 0) + { + INPUT.td_lcut2 = *static_cast(input_parameters["td_lcut2"].get()); + } + else if (input_parameters.count("td_gauss_freq") != 0) + { + INPUT.td_gauss_freq = static_cast(input_parameters["td_gauss_freq"].get())->c_str(); + } + else if (input_parameters.count("td_gauss_phase") != 0) + { + INPUT.td_gauss_phase = static_cast(input_parameters["td_gauss_phase"].get())->c_str(); + } + else if (input_parameters.count("td_gauss_sigma") != 0) + { + INPUT.td_gauss_sigma = static_cast(input_parameters["td_gauss_sigma"].get())->c_str(); + } + else if (input_parameters.count("td_gauss_t0") != 0) + { + INPUT.td_gauss_t0 = static_cast(input_parameters["td_gauss_t0"].get())->c_str(); + } + else if (input_parameters.count("td_gauss_amp") != 0) + { + INPUT.td_gauss_amp = static_cast(input_parameters["td_gauss_amp"].get())->c_str(); + } + else if (input_parameters.count("td_trape_freq") != 0) + { + INPUT.td_trape_freq = static_cast(input_parameters["td_trape_freq"].get())->c_str(); + } + else if (input_parameters.count("td_trape_phase") != 0) + { + INPUT.td_trape_phase = static_cast(input_parameters["td_trape_phase"].get())->c_str(); + } + else if (input_parameters.count("td_trape_t1") != 0) + { + INPUT.td_trape_t1 = static_cast(input_parameters["td_trape_t1"].get())->c_str(); + } + else if (input_parameters.count("td_trape_t2") != 0) + { + INPUT.td_trape_t2 = static_cast(input_parameters["td_trape_t2"].get())->c_str(); + } + else if (input_parameters.count("td_trape_t3") != 0) + { + INPUT.td_trape_t3 = static_cast(input_parameters["td_trape_t3"].get())->c_str(); + } + else if (input_parameters.count("td_trape_amp") != 0) + { + INPUT.td_trape_amp = static_cast(input_parameters["td_trape_amp"].get())->c_str(); + } + else if (input_parameters.count("td_trigo_freq1") != 0) + { + INPUT.td_trigo_freq1 = static_cast(input_parameters["td_trigo_freq1"].get())->c_str(); + } + else if (input_parameters.count("td_trigo_freq2") != 0) + { + INPUT.td_trigo_freq2 = static_cast(input_parameters["td_trigo_freq2"].get())->c_str(); + } + else if (input_parameters.count("td_trigo_phase1") != 0) + { + INPUT.td_trigo_phase1 = static_cast(input_parameters["td_trigo_phase1"].get())->c_str(); + } + else if (input_parameters.count("td_trigo_phase2") != 0) + { + INPUT.td_trigo_phase2 = static_cast(input_parameters["td_trigo_phase2"].get())->c_str(); + } + else if (input_parameters.count("td_trigo_amp") != 0) + { + INPUT.td_trigo_amp = static_cast(input_parameters["td_trigo_amp"].get())->c_str(); + } + else if (input_parameters.count("td_heavi_t0") != 0) + { + INPUT.td_heavi_t0 = static_cast(input_parameters["td_heavi_t0"].get())->c_str(); + } + else if (input_parameters.count("td_heavi_amp") != 0) + { + INPUT.td_heavi_amp = static_cast(input_parameters["td_heavi_amp"].get())->c_str(); + } + else if (input_parameters.count("restart_save") != 0) + { + INPUT.restart_save = *static_cast(input_parameters["restart_save"].get()); + } + else if (input_parameters.count("restart_load") != 0) + { + INPUT.restart_load = *static_cast(input_parameters["restart_load"].get()); + } + else if (input_parameters.count("input_error") != 0) + { + INPUT.input_error = *static_cast(input_parameters["input_error"].get()); + } + else if (input_parameters.count("cell_factor") != 0) + { + INPUT.cell_factor = *static_cast(input_parameters["cell_factor"].get()); + } + else if (input_parameters.count("dft_plus_u") != 0) + { + INPUT.dft_plus_u = *static_cast(input_parameters["dft_plus_u"].get()); + } + else if (input_parameters.count("orbital_corr") != 0) + { + INPUT.dft_plus_u = 0; + bool dmft_flag = false; + SimpleVector vec_D = *static_cast*>(input_parameters["orbital_corr"].get()); + for (int i = 0; i < INPUT.ntype; i++) + { + INPUT.orbital_corr[i] = vec_D[i]; + if ((INPUT.orbital_corr[i] != -1) && (INPUT.orbital_corr[i] != 0) && (INPUT.orbital_corr[i] != 1) + && (INPUT.orbital_corr[i] != 2) && (INPUT.orbital_corr[i] != 3)) + { + std::cout << " WRONG ARGUMENTS OF orbital_corr " << std::endl; + exit(0); + } + if (INPUT.orbital_corr[i] != -1) + { + dmft_flag = true; + INPUT.dft_plus_u = 1; + } + } + if (!dmft_flag) + { + std::cout << "No atoms are correlated!!!" << std::endl; + exit(0); + } + + if (strcmp("lcao", INPUT.basis_type.c_str()) != 0) + { + std::cout << " WRONG ARGUMENTS OF basis_type, only lcao is support " << std::endl; + exit(0); + } + } + else if (input_parameters.count("hubbard_u") != 0) + { + SimpleVector vec_D = *static_cast*>(input_parameters["hubbard_u"].get()); + for (int i = 0; i < INPUT.ntype; i++) + { + INPUT.hubbard_u[i] = vec_D[i] / ModuleBase::Ry_to_eV; + if (INPUT.hubbard_u[i] < -1.0e-3) + { + std::cout << " WRONG ARGUMENTS OF hubbard_u " << std::endl; + exit(0); + } + } + } + else if (input_parameters.count("omc") != 0) + { + INPUT.omc = *static_cast(input_parameters["omc"].get()); + } + else if (input_parameters.count("yukawa_potential") != 0) + { + INPUT.yukawa_potential = *static_cast(input_parameters["yukawa_potential"].get()); + } + else if (input_parameters.count("yukawa_lambda") != 0) + { + INPUT.yukawa_lambda = *static_cast(input_parameters["yukawa_lambda"].get()); + } + else if (input_parameters.count("dft_plus_dmft") != 0) + { + INPUT.dft_plus_dmft = *static_cast(input_parameters["dft_plus_dmft"].get()); + } + else if (input_parameters.count("rpa") != 0) + { + INPUT.rpa = *static_cast(input_parameters["rpa"].get()); + } + else if (input_parameters.count("coulomb_type") != 0) + { + INPUT.coulomb_type = static_cast(input_parameters["coulomb_type"].get())->c_str(); + } + else if (input_parameters.count("deepks_out_labels") != 0) + { + INPUT.deepks_out_labels = *static_cast(input_parameters["deepks_out_labels"].get()); + } + else if (input_parameters.count("deepks_scf") != 0) + { + INPUT.deepks_scf = *static_cast(input_parameters["deepks_scf"].get()); + } + else if (input_parameters.count("deepks_bandgap") != 0) + { + INPUT.deepks_bandgap = *static_cast(input_parameters["deepks_bandgap"].get()); + } + else if (input_parameters.count("deepks_out_unittest") != 0) + { + INPUT.deepks_out_unittest = *static_cast(input_parameters["deepks_out_unittest"].get()); + } + else if (input_parameters.count("deepks_model") != 0) + { + INPUT.deepks_model = static_cast(input_parameters["deepks_model"].get())->c_str(); + } + else if (input_parameters.count("imp_sol") != 0) + { + INPUT.imp_sol = *static_cast(input_parameters["imp_sol"].get()); + } + else if (input_parameters.count("eb_k") != 0) + { + INPUT.eb_k = *static_cast(input_parameters["eb_k"].get()); + } + else if (input_parameters.count("tau") != 0) + { + INPUT.tau = *static_cast(input_parameters["tau"].get()); + } + else if (input_parameters.count("sigma_k") != 0) + { + INPUT.sigma_k = *static_cast(input_parameters["sigma_k"].get()); + } + else if (input_parameters.count("nc_k") != 0) + { + INPUT.nc_k = *static_cast(input_parameters["nc_k"].get()); + } + else if (input_parameters.count("of_kinetic") != 0) + { + INPUT.of_kinetic = static_cast(input_parameters["of_kinetic"].get())->c_str(); + } + else if (input_parameters.count("of_method") != 0) + { + INPUT.of_method = static_cast(input_parameters["of_method"].get())->c_str(); + } + else if (input_parameters.count("of_conv") != 0) + { + INPUT.of_conv = static_cast(input_parameters["of_conv"].get())->c_str(); + } + else if (input_parameters.count("of_tole") != 0) + { + INPUT.of_tole = *static_cast(input_parameters["of_tole"].get()); + } + else if (input_parameters.count("of_tolp") != 0) + { + INPUT.of_tolp = *static_cast(input_parameters["of_tolp"].get()); + } + else if (input_parameters.count("of_tf_weight") != 0) + { + INPUT.of_tf_weight = *static_cast(input_parameters["of_tf_weight"].get()); + } + else if (input_parameters.count("of_vw_weight") != 0) + { + INPUT.of_vw_weight = *static_cast(input_parameters["of_vw_weight"].get()); + } + else if (input_parameters.count("of_wt_alpha") != 0) + { + INPUT.of_wt_alpha = *static_cast(input_parameters["of_wt_alpha"].get()); + } + else if (input_parameters.count("of_wt_beta") != 0) + { + INPUT.of_wt_beta = *static_cast(input_parameters["of_wt_beta"].get()); + } + else if (input_parameters.count("of_wt_rho0") != 0) + { + INPUT.of_wt_rho0 = *static_cast(input_parameters["of_wt_rho0"].get()); + } + else if (input_parameters.count("of_hold_rho0") != 0) + { + INPUT.of_hold_rho0 = *static_cast(input_parameters["of_hold_rho0"].get()); + } + else if (input_parameters.count("of_lkt_a") != 0) + { + INPUT.of_lkt_a = *static_cast(input_parameters["of_lkt_a"].get()); + } + else if (input_parameters.count("of_full_pw") != 0) + { + INPUT.of_full_pw = *static_cast(input_parameters["of_full_pw"].get()); + } + else if (input_parameters.count("of_full_pw_dim") != 0) + { + INPUT.of_full_pw_dim = *static_cast(input_parameters["of_full_pw_dim"].get()); + } + else if (input_parameters.count("of_read_kernel") != 0) + { + INPUT.of_read_kernel = *static_cast(input_parameters["of_read_kernel"].get()); + } + else if (input_parameters.count("of_kernel_file") != 0) + { + INPUT.of_kernel_file = static_cast(input_parameters["of_kernel_file"].get())->c_str(); + } + else if (input_parameters.count("bessel_nao_smooth") != 0) + { + INPUT.bessel_nao_smooth = *static_cast(input_parameters["bessel_nao_smooth"].get()); + } + else if (input_parameters.count("bessel_nao_sigma") != 0) + { + INPUT.bessel_nao_sigma = *static_cast(input_parameters["bessel_nao_sigma"].get()); + } + else if (input_parameters.count("bessel_nao_ecut") != 0) + { + INPUT.bessel_nao_ecut = static_cast(input_parameters["bessel_nao_ecut"].get())->c_str(); + } + else if (input_parameters.count("bessel_nao_rcut") != 0) + { + INPUT.bessel_nao_rcut = *static_cast(input_parameters["bessel_nao_rcut"].get()); + } + else if (input_parameters.count("bessel_nao_tolerence") != 0) + { + INPUT.bessel_nao_tolerence = *static_cast(input_parameters["bessel_nao_tolerence"].get()); + } + else if (input_parameters.count("bessel_descriptor_lmax") != 0) + { + INPUT.bessel_descriptor_lmax = *static_cast(input_parameters["bessel_descriptor_lmax"].get()); + } + else if (input_parameters.count("bessel_descriptor_smooth") != 0) + { + INPUT.bessel_descriptor_smooth = *static_cast(input_parameters["bessel_descriptor_smooth"].get()); + } + else if (input_parameters.count("bessel_descriptor_sigma") != 0) + { + INPUT.bessel_descriptor_sigma = *static_cast(input_parameters["bessel_descriptor_sigma"].get()); + } + else if (input_parameters.count("bessel_descriptor_ecut") != 0) + { + INPUT.bessel_descriptor_ecut + = static_cast(input_parameters["bessel_descriptor_ecut"].get())->c_str(); + } + else if (input_parameters.count("bessel_descriptor_rcut") != 0) + { + INPUT.bessel_descriptor_rcut = *static_cast(input_parameters["bessel_descriptor_rcut"].get()); + } + else if (input_parameters.count("bessel_descriptor_tolerence") != 0) + { + INPUT.bessel_descriptor_tolerence + = *static_cast(input_parameters["bessel_descriptor_tolerence"].get()); + } + else if (input_parameters.count("device") != 0) + { + INPUT.device = static_cast(input_parameters["device"].get())->c_str(); + } + else if (input_parameters.count("precision") != 0) + { + INPUT.precision = static_cast(input_parameters["precision"].get())->c_str(); + } + else if (input_parameters.count("test_skip_ewald") != 0) + { + INPUT.test_skip_ewald = *static_cast(input_parameters["test_skip_ewald"].get()); + } +} + +// namespace ModuleIO +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/parameter_pool.h b/source/module_io/parameter_pool.h new file mode 100644 index 00000000000..83baedd0360 --- /dev/null +++ b/source/module_io/parameter_pool.h @@ -0,0 +1,257 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "module_base/constants.h" +#include "module_base/global_file.h" +#include "module_base/global_function.h" +#include "module_base/global_variable.h" +#include "module_base/parallel_common.h" +#include "module_base/timer.h" +#include "module_io/input.h" +#include "module_io/parameter_string.h" +#include "module_io/parameter_vector.h" +#include "version.h" +enum ParameterType +{ + BOOL, + INT, + DOUBLE, + STRING, + VECTOR_I, + VECTOR_D +}; +namespace ModuleIO +{ + +class InputParameter +{ + public: + ParameterType type; // Parameter Type Enumeration value + union param_value { // Parameter value association + bool b; + int i; + double d; + SimpleString s; // Simple string type value + SimpleVector vi; // Simple integer vector type value + SimpleVector vd; // Simple double precision floating-point vector type value + + param_value(){}; + ~param_value(){}; + + } value; + + InputParameter() + { + } + /** + * @brief Constructor to set parameter types and default parameter values + * + * @param t Parameter Type Enumeration value + */ + InputParameter(ParameterType t) + { + type = t; + switch (type) + { + case BOOL: + value.b = false; + break; + case INT: + value.i = 0; + break; + case DOUBLE: + value.d = 0.0; + break; + case STRING: + value.s = SimpleString(); + break; + case VECTOR_I: + value.vi = SimpleVector(); + break; + case VECTOR_D: + value.vd = SimpleVector(); + break; + default: + break; + } + } + /** + * @brief Overloads the assignment operator to copy the values of another InputParameter object to this object. + * + * @param other The InputParameter object to be copied. + * @return A reference to this InputParameter object. + */ + InputParameter& operator=(const InputParameter& other) + { + if (this != &other) + { + type = other.type; + switch (type) + { + case BOOL: + value.b = other.value.b; + break; + case INT: + value.i = other.value.i; + break; + case DOUBLE: + value.d = other.value.d; + break; + case STRING: + value.s = other.value.s; + break; + case VECTOR_I: + value.vi = other.value.vi; + break; + case VECTOR_D: + value.vd = other.value.vd; + break; + default: + break; + } + } + return *this; + } + /** + * @brief Copy constructor to create a new InputParameter object with the same values as another InputParameter + * object. + * + * @param other The InputParameter object to be copied. + */ + InputParameter(const InputParameter& other) + { + type = other.type; + switch (type) + { + case BOOL: + value.b = other.value.b; + break; + case INT: + value.i = other.value.i; + break; + case DOUBLE: + value.d = other.value.d; + break; + case STRING: + value.s = other.value.s; + break; + case VECTOR_I: + value.vi = other.value.vi; + break; + case VECTOR_D: + value.vd = other.value.vd; + break; + default: + break; + } + } + /** + * @brief to free any dynamically allocated memory and destroy the InputParameter object. + * If the parameter type is STRING, manually call the destructor of SimpleString. + * If the parameter type is VECTOR_I or VECTOR_D, manually call the destructor of SimpleVector. + * No need to do anything for BOOL, INT, and DOUBLE. + */ + ~InputParameter() + { + // If the parameter type is STRING, manually call the destructor of SimpleString + if (type == STRING) + { + value.s.~SimpleString(); + } + // If the parameter type is VECTOR_I or VECTOR_D, manually call the destructor of SimpleVector + else if (type == VECTOR_I) + { + value.vi.~SimpleVector(); + } + else if (type == VECTOR_D) + { + value.vd.~SimpleVector(); + } + // No need to do anything for BOOL, INT, and DOUBLE + } + + /** + * @brief Set parameter values + * + * @param v Parameter value pointer + */ + void set(void* v) + { + switch (type) + { + case BOOL: { + value.b = *(bool*)(v); + break; + } + case INT: { + value.i = *(int*)(v); + break; + } + case DOUBLE: { + value.d = *(double*)(v); + break; + } + case STRING: { + // if(value.s == NULL) value.s = new std::string; + value.s = *static_cast(v); + break; + } + case VECTOR_I: { + value.vi = *static_cast*>(v); + break; + } + case VECTOR_D: { + value.vd = *static_cast*>(v); + break; + } + default:; + } + } + /** + * @brief Gets a pointer to the parameter value + * + * @return void* pointer + */ + void* get() + { + switch (type) + { + case BOOL: + return (void*)(&value.b); + case INT: + return (void*)(&value.i); + case DOUBLE: + return (void*)(&value.d); + case STRING: + return (void*)(&value.s); + case VECTOR_I: + return (void*)(&value.vi); + case VECTOR_D: + return (void*)(&value.vd); + default: + return NULL; + } + } +}; +bool Init(const std::string& default_type_path, + const std::string& default_value_path, + const std::string& input_value_path); +bool default_parametes_reader(const std::string& fn, std::map& default_parametes_type); +bool input_parameters_get(const std::string& fn, std::map& input); +bool input_parameters_set(std::map input_parameters); + +extern std::map input_parameters; +extern std::map default_parametes_type; +extern std::map default_parametes_value; +} // namespace ModuleIO + +// std::string para_key = "lcao_ecut"; +// intpu_parameters["lcao_ecut"].get() \ No newline at end of file diff --git a/source/module_io/parameter_string.h b/source/module_io/parameter_string.h new file mode 100644 index 00000000000..a56ea88af7c --- /dev/null +++ b/source/module_io/parameter_string.h @@ -0,0 +1,61 @@ +#include +#include + +/** + * @brief This class is a simple string class that contains an array of characters and a variable that represents the + * length of the string. It has a default constructor, a copy constructor, and two public functions that return the + * length and content of the string, respectively. The assignment operator is also overridden to be able to copy one + * SimpleString object to another. + * + * @param m_data store the value of string + * @param m_length the length of string + */ +class SimpleString +{ + private: + char m_data[80]; + size_t m_length; + + public: + // Default constructor + SimpleString() : m_length(0) + { + } + + // constructor + SimpleString(const char* str) + { + m_length = std::strlen(str); + std::strcpy(m_data, str); + } + + // Copy constructor + SimpleString(const SimpleString& other) + { + m_length = other.m_length; + std::strcpy(m_data, other.m_data); + } + + // Get string length + size_t length() const + { + return m_length; + } + + // Get string content + const char* c_str() const + { + return m_data; + } + + // Overload the assignment operator + SimpleString& operator=(const SimpleString& other) + { + if (this != &other) + { + m_length = other.m_length; + std::strcpy(m_data, other.m_data); + } + return *this; + } +}; diff --git a/source/module_io/parameter_vector.h b/source/module_io/parameter_vector.h new file mode 100644 index 00000000000..5854aed5c69 --- /dev/null +++ b/source/module_io/parameter_vector.h @@ -0,0 +1,53 @@ +#include +#include + +/** + * @brief This code defines a template class, SimpleVector, which is a simple dynamic array that can store any type of + * data. It contains private members data_ and size_, which represent the data and size of the dynamic array, + * respectively. It provides a default constructor and a constructor with an initializer list. It also provides + * the push_back() function to add elements to dynamic arrays, and overrides the [] operator to fetch elements + * by index. The size() function returns the size of the dynamic array. + * + * @param data_ store the value of vetor + * @param size_ the size of vetor + */ +template +class SimpleVector +{ + private: + T data_[100]; + size_t size_; + + public: + SimpleVector() : size_(0) + { + } + + SimpleVector(std::initializer_list values) : size_(0) + { + for (auto it = values.begin(); it != values.end(); ++it) + { + push_back(*it); + } + } + void push_back(const T& value) + { + data_[size_] = value; + ++size_; + } + + T& operator[](size_t index) + { + return data_[index]; + } + + const T& operator[](size_t index) const + { + return data_[index]; + } + + size_t size() const + { + return size_; + } +}; diff --git a/source/module_io/test/CMakeLists.txt b/source/module_io/test/CMakeLists.txt index a43503c196b..5db23c16dc6 100644 --- a/source/module_io/test/CMakeLists.txt +++ b/source/module_io/test/CMakeLists.txt @@ -116,6 +116,12 @@ AddTest( SOURCES ../output_log.cpp outputlog_test.cpp ) +AddTest( + TARGET io_new_parse_set_test + LIBS ${math_libs} base device + SOURCES parameter_pool_set_test.cpp ../parameter_pool.cpp ../input.cpp +) + AddTest( TARGET io_sparse_matrix_test LIBS base ${math_libs} device @@ -132,4 +138,4 @@ AddTest( TARGET io_csr_reader_test LIBS base ${math_libs} device SOURCES csr_reader_test.cpp ../csr_reader.cpp ../file_reader.cpp ../sparse_matrix.cpp -) \ No newline at end of file +) diff --git a/source/module_io/test/parameter_pool_set_test.cpp b/source/module_io/test/parameter_pool_set_test.cpp new file mode 100644 index 00000000000..484f2b9390e --- /dev/null +++ b/source/module_io/test/parameter_pool_set_test.cpp @@ -0,0 +1,95 @@ +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "gtest/gtest.h" +#include "module_io/parameter_pool.h" + +/** + * @brief test func:input_parameters_get() and input_parameters_set() in parameter_pool.h + */ +TEST(InputParameterArgsTest, InputTest) +{ + + bool b1 = false; + ModuleIO::InputParameter inputparaBool; + inputparaBool.type = BOOL; + inputparaBool.set((void*)&b1); + ModuleIO::input_parameters["bool"] = inputparaBool; + bool b2 = *static_cast(ModuleIO::input_parameters["bool"].get()); + std::cout << "bool test:" << b2 << "\n"; + EXPECT_EQ(b2, b1); + + int i1 = 2023; + ModuleIO::InputParameter inputparaInt; + inputparaInt.type = INT; + inputparaInt.set((void*)&i1); + ModuleIO::input_parameters["int"] = inputparaInt; + int i2 = *static_cast(ModuleIO::input_parameters["int"].get()); + std::cout << "int test:" << i2 << "\n"; + EXPECT_EQ(i1, i2); + + SimpleString str = "Hello AISI"; + ModuleIO::InputParameter inputpara; + inputpara.type = STRING; + inputpara.set((void*)&str); + ModuleIO::input_parameters["string"] = inputpara; + // ModuleIO::input_parameters.insert(std::pair("nupdown", inputpara)); + std::string s = static_cast(ModuleIO::input_parameters["string"].get())->c_str(); + std::cout << "string test:" << s << "\n"; + EXPECT_EQ(str.c_str(), s); + + double d1 = 3.1415926; + ModuleIO::InputParameter inputpara2; + inputpara2.type = DOUBLE; + inputpara2.set((void*)&d1); + ModuleIO::input_parameters["double"] = inputpara2; + double d2 = *static_cast(ModuleIO::input_parameters["double"].get()); + std::cout << "double test:" << d2 << "\n"; + EXPECT_EQ(d1, d2); + + SimpleVector vecI; + for (int i = 0; i < 5; i++) + { + vecI.push_back(i); + } + ModuleIO::InputParameter inputpara3; + inputpara3.type = VECTOR_I; + inputpara3.set((void*)&vecI); + ModuleIO::input_parameters["vectorINT"] = inputpara3; + SimpleVector vecI2 = *static_cast*>(ModuleIO::input_parameters["vectorINT"].get()); + std::cout << "Vector_int test:"; + for (int i = 0; i < vecI2.size(); i++) + { + EXPECT_EQ(vecI[i], vecI2[i]); + std::cout << vecI2[i]; + } + std::cout << "\n"; + + SimpleVector vecD; + for (int i = 0; i < 5; i++) + { + double tmp = i + 0.01; + vecD.push_back(tmp); + } + ModuleIO::InputParameter inputpara4; + inputpara4.type = VECTOR_D; + inputpara4.set((void*)&vecD); + ModuleIO::input_parameters["vectorDOUBLE"] = inputpara4; + SimpleVector vecD2 = *static_cast*>(ModuleIO::input_parameters["vectorDOUBLE"].get()); + std::cout << "Vector_double test:"; + for (int i = 0; i < vecD2.size(); i++) + { + double value1=vecD[i],value2=vecD2[i]; + EXPECT_EQ(value1, value2); + std::cout << vecD2[i] << ","; + } +} \ No newline at end of file diff --git a/source/module_io/test/parameter_pool_test.cpp b/source/module_io/test/parameter_pool_test.cpp new file mode 100644 index 00000000000..e4de830c624 --- /dev/null +++ b/source/module_io/test/parameter_pool_test.cpp @@ -0,0 +1,396 @@ +// #include "gtest/gtest.h" +// #include "module_base/global_variable.h" +// #ifdef __MPI +// #include "mpi.h" +// #endif +// #include + +// /************************************************ +// * unit test of Input::bcast +// ***********************************************/ + +// /** +// * - Tested Functions: +// * - bcast() +// * - bcast input parameters to all processes +// */ + +// #define private public +// #include "module_io/input.h" +// #include "module_io/parameter_pool.h" + +// class InputParaTest : public ::testing::Test +// { +// protected: +// }; + +// #ifdef __MPI +// TEST_F(InputParaTest, Bcast) +// { +// if (GlobalV::MY_RANK == 0) +// { +// ModuleIO::input_parameters_get("./DEFAULT", ModuleIO::default_parametes_value); +// ModuleIO::input_parameters_set(ModuleIO::default_parametes_value); +// } +// INPUT.Bcast(); +// if (GlobalV::MY_RANK != 0) +// { +// EXPECT_EQ(INPUT.suffix, "ABACUS"); +// EXPECT_EQ(INPUT.stru_file, ""); +// EXPECT_EQ(INPUT.kpoint_file, ""); +// EXPECT_EQ(INPUT.pseudo_dir, ""); +// EXPECT_EQ(INPUT.orbital_dir, ""); +// EXPECT_EQ(INPUT.read_file_dir, "auto"); +// EXPECT_EQ(INPUT.wannier_card, "none"); +// EXPECT_EQ(INPUT.latname, "none"); +// EXPECT_EQ(INPUT.calculation, "scf"); +// EXPECT_EQ(INPUT.esolver_type, "ksdft"); +// EXPECT_DOUBLE_EQ(INPUT.pseudo_rcut, 15.0); +// EXPECT_FALSE(INPUT.pseudo_mesh); +// EXPECT_EQ(INPUT.ntype, 0); +// EXPECT_EQ(INPUT.nbands, 0); +// EXPECT_EQ(INPUT.nbands_sto, 256); +// EXPECT_EQ(INPUT.nbands_istate, 5); +// EXPECT_EQ(INPUT.pw_seed, 1); +// EXPECT_EQ(INPUT.emin_sto, 0.0); +// EXPECT_EQ(INPUT.emax_sto, 0.0); +// EXPECT_EQ(INPUT.nche_sto, 100); +// EXPECT_EQ(INPUT.seed_sto, 0); +// EXPECT_EQ(INPUT.bndpar, 1); +// EXPECT_EQ(INPUT.kpar, 1); +// EXPECT_EQ(INPUT.initsto_freq, 0); +// EXPECT_EQ(INPUT.method_sto, 2); +// EXPECT_EQ(INPUT.npart_sto, 1); +// EXPECT_FALSE(INPUT.cal_cond); +// EXPECT_EQ(INPUT.dos_nche, 100); +// EXPECT_EQ(INPUT.cond_nche, 20); +// EXPECT_DOUBLE_EQ(INPUT.cond_dw, 0.1); +// EXPECT_DOUBLE_EQ(INPUT.cond_wcut, 10); +// EXPECT_EQ(INPUT.cond_dt, 0.02); +// EXPECT_EQ(INPUT.cond_dtbatch, 4); +// EXPECT_DOUBLE_EQ(INPUT.cond_fwhm, 0.4); +// EXPECT_TRUE(INPUT.cond_nonlocal); +// EXPECT_FALSE(INPUT.berry_phase); +// EXPECT_EQ(INPUT.gdir, 3); +// EXPECT_FALSE(INPUT.towannier90); +// EXPECT_EQ(INPUT.nnkpfile, "seedname.nnkp"); +// EXPECT_EQ(INPUT.wannier_spin, "up"); +// EXPECT_DOUBLE_EQ(INPUT.kspacing[0], 0.0); +// EXPECT_DOUBLE_EQ(INPUT.kspacing[1], 0.0); +// EXPECT_DOUBLE_EQ(INPUT.kspacing[2], 0.0); +// EXPECT_DOUBLE_EQ(INPUT.min_dist_coef, 0.2); +// EXPECT_EQ(INPUT.dft_functional, "default"); +// EXPECT_DOUBLE_EQ(INPUT.xc_temperature, 0.0); +// EXPECT_EQ(INPUT.nspin, 1); +// EXPECT_DOUBLE_EQ(INPUT.nelec, 0.0); +// EXPECT_EQ(INPUT.lmaxmax, 2); +// EXPECT_EQ(INPUT.basis_type, "pw"); +// EXPECT_EQ(INPUT.ks_solver, "default"); +// EXPECT_DOUBLE_EQ(INPUT.search_radius, -1.0); +// EXPECT_TRUE(INPUT.search_pbc); +// //EXPECT_EQ(INPUT.symmetry, "default"); +// EXPECT_FALSE(INPUT.init_vel); +// EXPECT_DOUBLE_EQ(INPUT.symmetry_prec, 1.0e-5); +// EXPECT_EQ(INPUT.cal_force, 0); +// EXPECT_DOUBLE_EQ(INPUT.force_thr, 1.0e-3); +// EXPECT_DOUBLE_EQ(INPUT.force_thr_ev2, 0); +// EXPECT_DOUBLE_EQ(INPUT.stress_thr, 0.5); +// EXPECT_DOUBLE_EQ(INPUT.press1, 0.0); +// EXPECT_DOUBLE_EQ(INPUT.press2, 0.0); +// EXPECT_DOUBLE_EQ(INPUT.press3, 0.0); +// EXPECT_FALSE(INPUT.cal_stress); +// EXPECT_EQ(INPUT.fixed_axes, "None"); +// EXPECT_FALSE(INPUT.fixed_ibrav); +// EXPECT_FALSE(INPUT.fixed_atoms); +// EXPECT_EQ(INPUT.relax_method, "cg"); +// EXPECT_DOUBLE_EQ(INPUT.relax_cg_thr, 0.5); +// EXPECT_EQ(INPUT.out_level, "ie"); +// EXPECT_FALSE(INPUT.out_md_control); +// EXPECT_TRUE(INPUT.relax_new); +// EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_w1, 0.01); +// EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_w2, 0.5); +// EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_rmax, 0.8); +// EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_rmin, 1e-5); +// EXPECT_DOUBLE_EQ(INPUT.relax_bfgs_init, 0.5); +// EXPECT_DOUBLE_EQ(INPUT.relax_scale_force, 0.5); +// EXPECT_EQ(INPUT.nbspline, -1); +// EXPECT_FALSE(INPUT.gamma_only); +// EXPECT_FALSE(INPUT.gamma_only_local); +// EXPECT_DOUBLE_EQ(INPUT.ecutwfc, 50.0); +// EXPECT_EQ(INPUT.nx, 0); +// EXPECT_EQ(INPUT.ny, 0); +// EXPECT_EQ(INPUT.nz, 0); +// EXPECT_EQ(INPUT.bx, 0); +// EXPECT_EQ(INPUT.by, 0); +// EXPECT_EQ(INPUT.bz, 0); +// EXPECT_EQ(INPUT.diago_proc, 0); +// EXPECT_EQ(INPUT.pw_diag_nmax, 50); +// EXPECT_EQ(INPUT.diago_cg_prec, 1); +// EXPECT_EQ(INPUT.pw_diag_ndim, 4); +// EXPECT_DOUBLE_EQ(INPUT.pw_diag_thr, 1.0e-2); +// EXPECT_EQ(INPUT.nb2d, 0); +// EXPECT_EQ(INPUT.nurse, 0); +// EXPECT_EQ(INPUT.colour, 0); +// EXPECT_EQ(INPUT.t_in_h, 1); +// EXPECT_EQ(INPUT.vl_in_h, 1); +// EXPECT_EQ(INPUT.vnl_in_h, 1); +// EXPECT_EQ(INPUT.vh_in_h, 1); +// EXPECT_EQ(INPUT.vion_in_h, 1); +// EXPECT_EQ(INPUT.test_force, 0); +// EXPECT_EQ(INPUT.test_stress, 0); +// EXPECT_DOUBLE_EQ(INPUT.scf_thr, -1.0); +// EXPECT_EQ(INPUT.scf_thr_type, -1); +// EXPECT_EQ(INPUT.scf_nmax, 100); +// EXPECT_EQ(INPUT.relax_nmax, 0); +// EXPECT_EQ(INPUT.out_stru, 0); +// // EXPECT_EQ(INPUT.occupations,"smearing"); +// EXPECT_EQ(INPUT.smearing_method, "fixed"); +// EXPECT_DOUBLE_EQ(INPUT.smearing_sigma, 0.01); +// EXPECT_EQ(INPUT.mixing_mode, "pulay"); +// EXPECT_DOUBLE_EQ(INPUT.mixing_beta, -10.0); +// EXPECT_EQ(INPUT.mixing_ndim, 8); +// EXPECT_DOUBLE_EQ(INPUT.mixing_gg0, 0.00); +// EXPECT_EQ(INPUT.init_wfc, "atomic"); +// EXPECT_EQ(INPUT.mem_saver, 0); +// EXPECT_EQ(INPUT.printe, 100); +// EXPECT_EQ(INPUT.init_chg, "atomic"); +// EXPECT_EQ(INPUT.chg_extrap, "atomic"); +// EXPECT_EQ(INPUT.out_freq_elec, 0); +// EXPECT_EQ(INPUT.out_freq_ion, 0); +// EXPECT_EQ(INPUT.out_chg, 0); +// EXPECT_EQ(INPUT.out_dm, 0); +// EXPECT_EQ(INPUT.out_dm1, 0); +// EXPECT_EQ(INPUT.deepks_out_labels, 0); +// EXPECT_EQ(INPUT.deepks_scf, 0); +// EXPECT_EQ(INPUT.deepks_bandgap, 0); +// EXPECT_EQ(INPUT.deepks_out_unittest, 0); +// EXPECT_EQ(INPUT.out_pot, 0); +// EXPECT_EQ(INPUT.out_wfc_pw, 0); +// EXPECT_EQ(INPUT.out_wfc_r, 0); +// EXPECT_EQ(INPUT.out_dos, 0); +// EXPECT_EQ(INPUT.out_band, 0); +// EXPECT_EQ(INPUT.out_proj_band, 0); +// EXPECT_EQ(INPUT.out_mat_hs, 0); +// EXPECT_EQ(INPUT.out_mat_hs2, 0); +// EXPECT_EQ(INPUT.out_interval, 1); +// EXPECT_EQ(INPUT.out_app_flag, 1); +// EXPECT_EQ(INPUT.out_mat_r, 0); +// EXPECT_FALSE(INPUT.out_wfc_lcao); +// EXPECT_FALSE(INPUT.out_alllog); +// EXPECT_DOUBLE_EQ(INPUT.dos_emin_ev, -15); +// EXPECT_DOUBLE_EQ(INPUT.dos_emax_ev, 15); +// EXPECT_DOUBLE_EQ(INPUT.dos_edelta_ev, 0.01); +// EXPECT_DOUBLE_EQ(INPUT.dos_scale, 0.01); +// EXPECT_DOUBLE_EQ(INPUT.dos_sigma, 0.07); +// EXPECT_FALSE(INPUT.out_element_info); +// EXPECT_DOUBLE_EQ(INPUT.lcao_ecut, 0); +// EXPECT_DOUBLE_EQ(INPUT.lcao_dk, 0.01); +// EXPECT_DOUBLE_EQ(INPUT.lcao_dr, 0.01); +// EXPECT_DOUBLE_EQ(INPUT.lcao_rmax, 30); +// EXPECT_TRUE(INPUT.bessel_nao_smooth); +// EXPECT_DOUBLE_EQ(INPUT.bessel_nao_sigma, 0.1); +// EXPECT_EQ(INPUT.bessel_nao_ecut, "default"); +// EXPECT_DOUBLE_EQ(INPUT.bessel_nao_rcut, 6.0); +// EXPECT_DOUBLE_EQ(INPUT.bessel_nao_tolerence, 1E-12); +// EXPECT_EQ(INPUT.bessel_descriptor_lmax, 2); +// EXPECT_TRUE(INPUT.bessel_descriptor_smooth); +// EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_sigma, 0.1); +// EXPECT_EQ(INPUT.bessel_descriptor_ecut, "default"); +// EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_rcut, 6.0); +// EXPECT_DOUBLE_EQ(INPUT.bessel_descriptor_tolerence, 1E-12); + +// EXPECT_FALSE(INPUT.efield_flag); +// EXPECT_FALSE(INPUT.dip_cor_flag); +// EXPECT_EQ(INPUT.efield_dir, 2); +// EXPECT_DOUBLE_EQ(INPUT.efield_pos_max, 0.5); +// EXPECT_DOUBLE_EQ(INPUT.efield_pos_dec, 0.1); +// EXPECT_DOUBLE_EQ(INPUT.efield_amp, 0.0); +// EXPECT_FALSE(INPUT.gate_flag); +// EXPECT_DOUBLE_EQ(INPUT.zgate, 0.5); +// EXPECT_FALSE(INPUT.relax); +// EXPECT_FALSE(INPUT.block); +// EXPECT_DOUBLE_EQ(INPUT.block_down, 0.45); +// EXPECT_DOUBLE_EQ(INPUT.block_up, 0.55); +// EXPECT_DOUBLE_EQ(INPUT.block_height, 0.1); +// EXPECT_EQ(INPUT.vdw_method, "none"); +// EXPECT_EQ(INPUT.vdw_s6, "default"); +// EXPECT_EQ(INPUT.vdw_s8, "default"); +// EXPECT_EQ(INPUT.vdw_a1, "default"); +// EXPECT_EQ(INPUT.vdw_a2, "default"); +// EXPECT_DOUBLE_EQ(INPUT.vdw_d, 20); +// EXPECT_FALSE(INPUT.vdw_abc); +// EXPECT_EQ(INPUT.vdw_cutoff_radius, "default"); +// EXPECT_EQ(INPUT.vdw_radius_unit, "Bohr"); +// EXPECT_DOUBLE_EQ(INPUT.vdw_cn_thr, 40.0); +// EXPECT_EQ(INPUT.vdw_cn_thr_unit, "Bohr"); +// EXPECT_EQ(INPUT.vdw_C6_file, "default"); +// EXPECT_EQ(INPUT.vdw_C6_unit, "Jnm6/mol"); +// EXPECT_EQ(INPUT.vdw_R0_file, "default"); +// EXPECT_EQ(INPUT.vdw_R0_unit, "A"); +// EXPECT_EQ(INPUT.vdw_cutoff_type, "radius"); +// EXPECT_EQ(INPUT.vdw_cutoff_period[0], 3); +// EXPECT_EQ(INPUT.vdw_cutoff_period[1], 3); +// EXPECT_EQ(INPUT.vdw_cutoff_period[2], 3); +// EXPECT_EQ(INPUT.exx_hybrid_alpha, "default"); +// EXPECT_EQ(INPUT.exx_real_number, "default"); +// EXPECT_DOUBLE_EQ(INPUT.exx_hse_omega, 0.11); +// EXPECT_TRUE(INPUT.exx_separate_loop); +// EXPECT_EQ(INPUT.exx_hybrid_step, 100); +// EXPECT_DOUBLE_EQ(INPUT.exx_lambda, 0.3); +// EXPECT_DOUBLE_EQ(INPUT.exx_mixing_beta, 1.0); +// EXPECT_DOUBLE_EQ(INPUT.exx_pca_threshold, 1E-4); +// EXPECT_DOUBLE_EQ(INPUT.exx_c_threshold, 1E-4); +// EXPECT_DOUBLE_EQ(INPUT.exx_v_threshold, 1E-1); +// EXPECT_DOUBLE_EQ(INPUT.exx_dm_threshold, 1E-4); +// EXPECT_DOUBLE_EQ(INPUT.exx_schwarz_threshold, 0); +// EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_threshold, 1E-7); +// EXPECT_DOUBLE_EQ(INPUT.exx_c_grad_threshold, 1E-4); +// EXPECT_DOUBLE_EQ(INPUT.exx_v_grad_threshold, 1E-1); +// EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_force_threshold, 1E-7); +// EXPECT_DOUBLE_EQ(INPUT.exx_cauchy_stress_threshold, 1E-7); +// EXPECT_DOUBLE_EQ(INPUT.exx_ccp_threshold, 1E-8); +// EXPECT_EQ(INPUT.exx_ccp_rmesh_times, "default"); +// EXPECT_EQ(INPUT.exx_distribute_type, "htime"); +// EXPECT_EQ(INPUT.exx_opt_orb_lmax, 0); +// EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_ecut, 0.0); +// EXPECT_DOUBLE_EQ(INPUT.exx_opt_orb_tolerence, 0.0); +// EXPECT_FALSE(INPUT.noncolin); +// EXPECT_FALSE(INPUT.lspinorb); +// EXPECT_DOUBLE_EQ(INPUT.soc_lambda, 1.0); +// EXPECT_EQ(INPUT.input_error, 0); +// EXPECT_DOUBLE_EQ(INPUT.td_force_dt, 0.02); +// EXPECT_FALSE(INPUT.td_vext); +// EXPECT_EQ(INPUT.td_vext_dire, "1"); +// EXPECT_EQ(INPUT.propagator, 0); +// EXPECT_EQ(INPUT.td_stype, 0); +// EXPECT_EQ(INPUT.td_ttype, "0"); +// EXPECT_EQ(INPUT.td_tstart, 1); +// EXPECT_EQ(INPUT.td_tend, 1000); +// EXPECT_EQ(INPUT.td_lcut1, 0.05); +// EXPECT_EQ(INPUT.td_lcut2, 0.95); +// EXPECT_EQ(INPUT.td_gauss_amp, "0.25"); +// EXPECT_EQ(INPUT.td_gauss_freq, "22.13"); +// EXPECT_EQ(INPUT.td_gauss_phase, "0.0"); +// EXPECT_EQ(INPUT.td_gauss_t0, "100.0"); +// EXPECT_EQ(INPUT.td_gauss_sigma, "30.0"); +// EXPECT_EQ(INPUT.td_trape_amp, "2.74"); +// EXPECT_EQ(INPUT.td_trape_freq, "1.60"); +// EXPECT_EQ(INPUT.td_trape_phase, "0.0"); +// EXPECT_EQ(INPUT.td_trape_t1, "1875"); +// EXPECT_EQ(INPUT.td_trape_t2, "5625"); +// EXPECT_EQ(INPUT.td_trape_t3, "7500"); +// EXPECT_EQ(INPUT.td_trigo_freq1, "1.164656"); +// EXPECT_EQ(INPUT.td_trigo_freq2, "0.029116"); +// EXPECT_EQ(INPUT.td_trigo_phase1, "0.0"); +// EXPECT_EQ(INPUT.td_trigo_phase2, "0.0"); +// EXPECT_EQ(INPUT.td_trigo_amp, "2.74"); +// EXPECT_EQ(INPUT.td_heavi_t0, "100"); +// EXPECT_EQ(INPUT.td_heavi_amp, "1.0"); +// EXPECT_EQ(INPUT.out_dipole, 0); +// EXPECT_EQ(INPUT.out_efield, 0); +// EXPECT_EQ(INPUT.td_print_eij, -1.0); +// EXPECT_EQ(INPUT.td_edm, 0); +// EXPECT_DOUBLE_EQ(INPUT.cell_factor, 1.2); +// EXPECT_EQ(INPUT.out_mul, 0); +// EXPECT_FALSE(INPUT.restart_save); +// EXPECT_FALSE(INPUT.restart_load); +// EXPECT_FALSE(INPUT.test_skip_ewald); +// EXPECT_FALSE(INPUT.dft_plus_u); +// EXPECT_FALSE(INPUT.yukawa_potential); +// EXPECT_DOUBLE_EQ(INPUT.yukawa_lambda, -1.0); +// EXPECT_EQ(INPUT.omc, 0); +// EXPECT_FALSE(INPUT.dft_plus_dmft); +// EXPECT_FALSE(INPUT.rpa); +// // EXPECT_EQ(INPUT.coulomb_type,"full"); +// EXPECT_EQ(INPUT.imp_sol, 0); +// EXPECT_DOUBLE_EQ(INPUT.eb_k, 80.0); +// EXPECT_DOUBLE_EQ(INPUT.tau, 1.0798 * 1e-5); +// EXPECT_DOUBLE_EQ(INPUT.sigma_k, 0.6); +// EXPECT_DOUBLE_EQ(INPUT.nc_k, 0.00037); +// EXPECT_EQ(INPUT.of_kinetic, "wt"); +// EXPECT_EQ(INPUT.of_method, "tn"); +// EXPECT_EQ(INPUT.of_conv, "energy"); +// EXPECT_DOUBLE_EQ(INPUT.of_tole, 1e-6); +// EXPECT_DOUBLE_EQ(INPUT.of_tolp, 1e-5); +// EXPECT_DOUBLE_EQ(INPUT.of_tf_weight, 1.); +// EXPECT_DOUBLE_EQ(INPUT.of_vw_weight, 1.); +// EXPECT_DOUBLE_EQ(INPUT.of_wt_alpha, 5. / 6.); +// EXPECT_DOUBLE_EQ(INPUT.of_wt_beta, 5. / 6.); +// EXPECT_DOUBLE_EQ(INPUT.of_wt_rho0, 0.); +// EXPECT_FALSE(INPUT.of_hold_rho0); +// EXPECT_DOUBLE_EQ(INPUT.of_lkt_a, 1.3); +// EXPECT_TRUE(INPUT.of_full_pw); +// EXPECT_EQ(INPUT.of_full_pw_dim, 0); +// EXPECT_FALSE(INPUT.of_read_kernel); +// EXPECT_EQ(INPUT.of_kernel_file, "WTkernel.txt"); +// EXPECT_EQ(INPUT.device, "cpu"); +// EXPECT_DOUBLE_EQ(INPUT.ecutrho, 0.0); +// EXPECT_EQ(INPUT.ncx, 0); +// EXPECT_EQ(INPUT.ncy, 0); +// EXPECT_EQ(INPUT.ncz, 0); +// EXPECT_NEAR(INPUT.mdp.lj_epsilon, 0.01032, 1e-7); +// EXPECT_NEAR(INPUT.mdp.lj_rcut, 8.5, 1e-7); +// EXPECT_NEAR(INPUT.mdp.lj_sigma, 3.405, 1e-7); +// EXPECT_EQ(INPUT.mdp.md_damp, 1); +// EXPECT_EQ(INPUT.mdp.md_dt, 1); +// EXPECT_EQ(INPUT.mdp.md_dumpfreq, 1); +// EXPECT_EQ(INPUT.mdp.md_nraise, 1); +// EXPECT_EQ(INPUT.mdp.md_nstep, 10); +// EXPECT_EQ(INPUT.mdp.md_pchain, 1); +// EXPECT_EQ(INPUT.mdp.md_pcouple, "none"); +// EXPECT_DOUBLE_EQ(INPUT.mdp.md_pfirst, -1); +// EXPECT_DOUBLE_EQ(INPUT.mdp.md_pfreq, 0); +// EXPECT_DOUBLE_EQ(INPUT.mdp.md_plast, -1); +// EXPECT_EQ(INPUT.mdp.md_pmode, "iso"); +// EXPECT_EQ(INPUT.mdp.md_restart, 0); +// EXPECT_EQ(INPUT.mdp.md_restartfreq, 5); +// EXPECT_EQ(INPUT.mdp.md_seed, -1); +// EXPECT_EQ(INPUT.mdp.md_tchain, 1); +// EXPECT_DOUBLE_EQ(INPUT.mdp.md_tfirst, -1); +// EXPECT_DOUBLE_EQ(INPUT.mdp.md_tfreq, 0); +// EXPECT_EQ(INPUT.mdp.md_thermostat, "nhc"); +// EXPECT_DOUBLE_EQ(INPUT.mdp.md_tlast, -1); +// EXPECT_DOUBLE_EQ(INPUT.mdp.md_tolerance, 100); +// EXPECT_EQ(INPUT.mdp.md_type, "nvt"); +// EXPECT_EQ(INPUT.mdp.msst_direction, 2); +// EXPECT_DOUBLE_EQ(INPUT.mdp.msst_qmass, -1); +// EXPECT_DOUBLE_EQ(INPUT.mdp.msst_tscale, 0.01); +// EXPECT_DOUBLE_EQ(INPUT.mdp.msst_vel, 0); +// EXPECT_DOUBLE_EQ(INPUT.mdp.msst_vis, 0); +// EXPECT_EQ(INPUT.mdp.pot_file, "graph.pb"); +// EXPECT_TRUE(INPUT.mdp.dump_force); +// EXPECT_TRUE(INPUT.mdp.dump_vel); +// EXPECT_TRUE(INPUT.mdp.dump_virial); +// EXPECT_FALSE(INPUT.mixing_tau); +// EXPECT_FALSE(INPUT.mixing_dftu); +// EXPECT_EQ(INPUT.out_bandgap, 0); +// EXPECT_EQ(INPUT.out_mat_t, 0); +// } +// } + +// TEST_F(InputParaTest, Init) +// { +// std::string input_file = "./support/INPUT"; +// Input input_tmp; +// EXPECT_NO_THROW(input_tmp.Init(input_file)); +// if (GlobalV::MY_RANK == 0) +// { +// int status = system("rm -r ./OUT.autotest/"); +// EXPECT_EQ(status, 0); +// } +// } + +// int main(int argc, char** argv) +// { +// MPI_Init(&argc, &argv); +// testing::InitGoogleTest(&argc, argv); + +// MPI_Comm_size(MPI_COMM_WORLD, &GlobalV::NPROC); +// MPI_Comm_rank(MPI_COMM_WORLD, &GlobalV::MY_RANK); + +// int result = RUN_ALL_TESTS(); +// MPI_Finalize(); +// return result; +// } +// #endif +// #undef private