diff --git a/CMakeLists.txt b/CMakeLists.txt index 75e5f8ce67..99a6fc2650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,34 @@ option(DEBUG_INFO "Print message for developers to debug." OFF) option(ENABLE_NATIVE_OPTIMIZATION "Enable compilation optimization for the native machine's CPU type" OFF) option(COMMIT_INFO "Print commit information in log" ON) option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method." ON) +option(ENABLE_RAPIDJSON "Enable rapid-json usage." OFF) + + + +# enable json support +if(ENABLE_RAPIDJSON) + find_package(RapidJSON) + if(NOT RapidJSON_FOUND) + message(WARNING "Rapidjson is not found, trying downloading from github, or you can install Rapidjson first and reinstall abacus.") + include(FetchContent) + FetchContent_Declare( + rapidjson + GIT_REPOSITORY https://github.com/Tencent/rapidjson.git + GIT_TAG "origin/master" + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE + ) + set(RAPIDJSON_BUILD_TESTS OFF CACHE INTERNAL "") + set(RAPIDJSON_BUILD_EXAMPLES OFF CACHE INTERNAL "") + FetchContent_MakeAvailable(rapidjson) + set(RapidJSON_INCLUDE_PATH "${rapidjson_SOURCE_DIR}/include") + endif() + add_compile_definitions(__RAPIDJSON) + add_definitions(-DRAPIDJSON_HAS_CXX11_NOEXCEPT=0) + include_directories(${RapidJSON_INCLUDE_PATH}) +endif() + + if (USE_CUDA) set(USE_CUSOLVER_LCAO ON) else() diff --git a/docs/quick_start/easy_install.md b/docs/quick_start/easy_install.md index 957b9d3262..32ae5b87d3 100644 --- a/docs/quick_start/easy_install.md +++ b/docs/quick_start/easy_install.md @@ -229,7 +229,7 @@ conda create -n abacus_env abacus -c conda-forge conda activate abacus_env export CMAKE_PREFIX_PATH=$CONDA_PREFIX:$CMAKE_PREFIX_PATH -# By default OpenBLAS is used; run `conda install "blas=*=mkl" mkl_fft -c conda-forge` to switch implementation. +# By default OpenBLAS is used; run `conda install "blas=*=mkl" mkl_fft mkl-devel -c conda-forge` to switch implementation. export MKLROOT=$CONDA_PREFIX # If Intel MKL is required. export CMAKE_PREFIX_PATH=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'`:$CMAKE_PREFIX_PATH # If DEEPKS support is required; diff --git a/docs/quick_start/hands_on.md b/docs/quick_start/hands_on.md index d63c6b0232..2e0e768169 100644 --- a/docs/quick_start/hands_on.md +++ b/docs/quick_start/hands_on.md @@ -57,7 +57,7 @@ basis_type lcao calculation scf # this is the key parameter telling abacus to do a scf calculation ``` -The pseudopotential files of `Mg_ONCV_PBE-1.0.upf` and `O_ONCV_PBE-1.0.upf` should be provided under the directory of `pseudo_dir`, and the orbital files `Mg_gga_8au_100Ry_4s2p1d.orb` and `O_gga_8au_100Ry_2s2p1d.orb` under the directory of `orbital_dir`. The pseudopotential and orbital files can be downloaded from the [ABACUS website](http://abacus.ustc.edu.cn/pseudo/list.htm). +The pseudopotential files of `Mg_ONCV_PBE-1.0.upf` and `O_ONCV_PBE-1.0.upf` should be provided under the directory of `pseudo_dir` defined in `INPUT` (the default directory is "./"), and the orbital files `Mg_gga_8au_100Ry_4s2p1d.orb` and `O_gga_8au_100Ry_2s2p1d.orb` under the directory of `orbital_dir` also defined in `INPUT` (the default directory is "./"). The pseudopotential and orbital files can be downloaded from the [ABACUS website](http://abacus.ustc.edu.cn/pseudo/list.htm). The final mandatory input file is called `KPT`, which sets the reciprocal space k-mesh. Below is an example: diff --git a/source/module_base/para_json.cpp b/source/module_base/para_json.cpp new file mode 100644 index 0000000000..1f042271f8 --- /dev/null +++ b/source/module_base/para_json.cpp @@ -0,0 +1,977 @@ +#include "para_json.h" +#include "module_base/global_variable.h" + +#ifdef __RAPIDJSON + +namespace Para_Json +{ + int test=4; + // @param doc: the output json file + rapidjson::Document doc; + rapidjson::Value abacus(rapidjson::kObjectType); + + // @param general_info : + rapidjson::Value general_info(rapidjson::kObjectType); + rapidjson::Value version; + + rapidjson::Value commit; + rapidjson::Value begin_time; + rapidjson::Value begin_date; + rapidjson::Value device_g; + // @param general_info -- parallel: + rapidjson::Value parallel(rapidjson::kObjectType); + rapidjson::Value drank; + rapidjson::Value dsize; + rapidjson::Value dcolor ; + // @param general_info -- path + rapidjson::Value path(rapidjson::kObjectType); + rapidjson::Value global_out_dir; + rapidjson::Value global_in_card; + rapidjson::Value pseudo_dir_path ; + rapidjson::Value orbital_dir_path; + + + // @param reading_information: + rapidjson::Value readin_info(rapidjson::kObjectType); + // @param reading_information -- input_file: + rapidjson::Value input_file(rapidjson::kObjectType); + + + // @param reading_information -- input_file -- system_variables: + rapidjson::Value input_suffix; + rapidjson::Value ntype; + rapidjson::Value calculation; + rapidjson::Value esolver_type; + rapidjson::Value symmetry; + rapidjson::Value symmetry_precfield; + rapidjson::Value symmetry_autoclose; + rapidjson::Value kpar; + rapidjson::Value bndpar; + rapidjson::Value latname; + rapidjson::Value init_wfc; + rapidjson::Value init_chg; + rapidjson::Value init_vel; + rapidjson::Value nelec; + rapidjson::Value nupdown; + rapidjson::Value dft_functional; + rapidjson::Value xc_temperature; + rapidjson::Value pseudo_rcut(rapidjson::kNumberType ); + rapidjson::Value pseudo_mesh; + rapidjson::Value mem_saver; + rapidjson::Value diago_proc; + rapidjson::Value nbspline; + rapidjson::Value kspacing(rapidjson::kArrayType); + rapidjson::Value min_dist_coef(rapidjson::kNumberType); + rapidjson::Value device; + // @param reading_information -- input_file -- files_related + rapidjson::Value stru_file; + rapidjson::Value kpoint_file; + rapidjson::Value pseudo_dir; + rapidjson::Value orbital_dir; + rapidjson::Value read_file_dir; + rapidjson::Value wannier_card; + + // @param reading_information -- input_file -- planewave_related + rapidjson::Value ecutwfc; + rapidjson::Value nx; + rapidjson::Value ny; + rapidjson::Value nz; + rapidjson::Value pw_seed; + rapidjson::Value pw_diag_thr; + rapidjson::Value pw_diag_nmax; + rapidjson::Value pw_diag_ndim; + // @param reading_information -- input_file -- numerical_atomic_orbitals_related + rapidjson::Value nb2d; + rapidjson::Value lmaxmax; + rapidjson::Value lcao_ecut; + rapidjson::Value lcao_dk; + rapidjson::Value lcao_dr; + rapidjson::Value lcao_rmax; + rapidjson::Value search_radius; + rapidjson::Value search_pbc; + rapidjson::Value bx; + rapidjson::Value by; + rapidjson::Value bz; + // @param reading_information -- input_file -- electronic_structure + rapidjson::Value basis_type; + rapidjson::Value ks_solver; + rapidjson::Value nbands; + rapidjson::Value nbands_istate; + rapidjson::Value nspin; + rapidjson::Value smearing_method; + rapidjson::Value smearing_sigma; + rapidjson::Value smearing_sigma_temp; + rapidjson::Value mixing_type; + rapidjson::Value mixing_beta; + rapidjson::Value mixing_ndim; + rapidjson::Value mixing_gg0; + rapidjson::Value mixing_tau; + rapidjson::Value mixing_dftu; + rapidjson::Value gamma_only; + rapidjson::Value printe; + rapidjson::Value scf_nmax; + rapidjson::Value scf_thr; + rapidjson::Value scf_thr_type; + rapidjson::Value chg_extrap; + rapidjson::Value lspinorb; + rapidjson::Value noncolin; + rapidjson::Value soc_lambda; + // @param reading_information -- input_file -- electronic_structure_SDFT + rapidjson::Value method_sto; + rapidjson::Value nbands_sto; + rapidjson::Value nche_sto(rapidjson::kNumberType); + rapidjson::Value emin_sto; + rapidjson::Value emax_sto; + rapidjson::Value seed_sto; + rapidjson::Value initsto_freq; + rapidjson::Value npart_sto; + // @param reading_information -- input_file -- geometry_relaxation + rapidjson::Value relax_method; + rapidjson::Value relax_new; + rapidjson::Value relax_scale_force; + rapidjson::Value relax_nmax; + rapidjson::Value relax_cg_thr; + rapidjson::Value cal_force; + rapidjson::Value force_thr; + rapidjson::Value force_thr_ev; + rapidjson::Value force_thr_ev2; + rapidjson::Value relax_bfgs_w1; + rapidjson::Value relax_bfgs_w2; + rapidjson::Value relax_bfgs_rmax; + rapidjson::Value relax_bfgs_rmin; + rapidjson::Value relax_bfgs_init; + rapidjson::Value cal_stress; + rapidjson::Value stress_thr; + rapidjson::Value press1; + rapidjson::Value press2; + rapidjson::Value press3; + rapidjson::Value fixed_axes; + rapidjson::Value fixed_ibrav; + rapidjson::Value fixed_atoms; + rapidjson::Value cell_factor; + + // @param reading_information -- input_file -- output_information_related + rapidjson::Value out_mul; + rapidjson::Value out_freq_elec; + rapidjson::Value out_freq_ion; + rapidjson::Value out_chg; + rapidjson::Value out_pot; + rapidjson::Value out_dm; + rapidjson::Value out_dm1; + rapidjson::Value out_wfc_pw; + rapidjson::Value out_wfc_r; + rapidjson::Value out_wfc_lcao; + rapidjson::Value out_dos; + rapidjson::Value out_band; + rapidjson::Value out_proj_band; + rapidjson::Value out_stru; + rapidjson::Value out_bandgap; + rapidjson::Value out_level; + rapidjson::Value out_alllog; + rapidjson::Value out_mat_hs; + rapidjson::Value out_mat_r; + rapidjson::Value out_mat_hs2; + rapidjson::Value out_mat_t; + rapidjson::Value out_mat_dh; + rapidjson::Value out_app_flag; + rapidjson::Value out_interval; + rapidjson::Value out_element_info; + rapidjson::Value restart_save; + rapidjson::Value restart_load; + rapidjson::Value rpa; + + // @param reading_information -- input_file -- density_of_states + rapidjson::Value dos_edelta_ev; + rapidjson::Value dos_sigma; + rapidjson::Value dos_scale; + rapidjson::Value dos_emin_ev; + rapidjson::Value dos_emax_ev; + rapidjson::Value dos_nche; + // @param reading_information -- input_file -- naos + rapidjson::Value bessel_nao_ecut; + rapidjson::Value bessel_nao_tolerence; + rapidjson::Value bessel_nao_rcut; + rapidjson::Value bessel_nao_smooth; + rapidjson::Value bessel_nao_sigma; + // @param reading_information -- input_file -- deepks + rapidjson::Value input_file_out_labels; + rapidjson::Value input_file_scf; + rapidjson::Value input_file_model; + rapidjson::Value bessel_descriptor_lmax; + rapidjson::Value bessel_descriptor_ecut; + rapidjson::Value bessel_descriptor_tolerence; + rapidjson::Value bessel_descriptor_rcut; + rapidjson::Value bessel_descriptor_smooth; + rapidjson::Value bessel_descriptor_sigma; + rapidjson::Value input_file_bandgap; + rapidjson::Value input_file_out_unittest; + // @param reading_information -- input_file -- ofdft + rapidjson::Value of_kinetic; + rapidjson::Value of_method; + rapidjson::Value of_conv; + rapidjson::Value of_tole; + rapidjson::Value of_tolp; + rapidjson::Value of_tf_weight; + rapidjson::Value of_vw_weight; + rapidjson::Value of_wt_alpha; + rapidjson::Value of_wt_beta; + rapidjson::Value of_wt_rho0; + rapidjson::Value of_hold_rho0; + rapidjson::Value of_lkt_a; + rapidjson::Value of_read_kernel; + rapidjson::Value of_kernel_file; + rapidjson::Value of_full_pw; + rapidjson::Value of_full_pw_dim; + + // @param reading_information -- input_file -- electric_field_and_dipole_correction + rapidjson::Value efield_flag; + rapidjson::Value dip_cor_flag; + rapidjson::Value efield_dir; + rapidjson::Value efield_pos_max; + rapidjson::Value efield_pos_dec; + rapidjson::Value efield_amp; + // @param reading_information -- input_file -- gate_field + rapidjson::Value gate_flag; + rapidjson::Value zgate; + rapidjson::Value block; + rapidjson::Value block_down; + rapidjson::Value block_up; + rapidjson::Value block_height; + // @param reading_information -- input_file -- exact_exchange + rapidjson::Value exx_hybrid_alpha; + rapidjson::Value exx_hse_omega; + rapidjson::Value exx_separate_loop; + rapidjson::Value exx_hybrid_step; + rapidjson::Value exx_mixing_beta; + rapidjson::Value exx_lambda; + rapidjson::Value exx_pca_threshold; + rapidjson::Value exx_c_threshold; + rapidjson::Value exx_v_threshold; + rapidjson::Value exx_dm_threshold; + rapidjson::Value exx_c_grad_threshold; + rapidjson::Value exx_v_grad_threshold; + rapidjson::Value exx_schwarz_threshold; + rapidjson::Value exx_cauchy_threshold; + rapidjson::Value exx_cauchy_force_threshold; + rapidjson::Value exx_cauchy_stress_threshold; + rapidjson::Value exx_ccp_threshold; + rapidjson::Value exx_ccp_rmesh_times; + rapidjson::Value exx_distribute_type; + rapidjson::Value exx_opt_orb_lmax; + rapidjson::Value exx_opt_orb_ecut; + rapidjson::Value exx_opt_orb_tolerence; + rapidjson::Value exx_real_number; + + // @param reading_information -- input_file -- molecular_dynamics + rapidjson::Value md_type; + rapidjson::Value md_nstep; + rapidjson::Value md_dt; + rapidjson::Value md_thermostat; + rapidjson::Value md_tlast; + rapidjson::Value md_tfirst; + rapidjson::Value md_restart; + rapidjson::Value md_restartfreq; + rapidjson::Value md_dumpfreq; + rapidjson::Value dump_force; + rapidjson::Value dump_vel; + rapidjson::Value dump_virial; + rapidjson::Value md_seed; + rapidjson::Value md_tfreq; + rapidjson::Value md_tchain; + rapidjson::Value md_pmode; + rapidjson::Value md_prec_level; + rapidjson::Value ref_cell_factor; + rapidjson::Value md_pcouple; + rapidjson::Value md_pfirst; + rapidjson::Value md_plast; + rapidjson::Value md_pfreq; + rapidjson::Value md_pchain; + rapidjson::Value lj_rcut; + rapidjson::Value lj_epsilon; + rapidjson::Value lj_sigma; + rapidjson::Value pot_file; + rapidjson::Value msst_direction; + rapidjson::Value msst_vel; + rapidjson::Value msst_vis; + rapidjson::Value msst_tscale; + rapidjson::Value msst_qmass; + rapidjson::Value md_damp; + rapidjson::Value md_tolerance; + rapidjson::Value md_nraise; + rapidjson::Value cal_syns; + rapidjson::Value dmax; + + // @param reading_information -- input_file -- dft_plus_u + rapidjson::Value orbital_corr(rapidjson::kArrayType); + rapidjson::Value hubbard_u(rapidjson::kArrayType); + rapidjson::Value yukawa_potential; + rapidjson::Value yukawa_lambda; + rapidjson::Value omc; + + // @param reading_information -- input_file -- vdw_correction + rapidjson::Value vdw_method; + rapidjson::Value vdw_s6; + rapidjson::Value vdw_s8; + rapidjson::Value vdw_a1; + rapidjson::Value vdw_a2; + rapidjson::Value vdw_d; + rapidjson::Value vdw_abc; + rapidjson::Value vdw_C6_file; + rapidjson::Value vdw_C6_unit; + rapidjson::Value vdw_R0_file; + rapidjson::Value vdw_R0_unit; + rapidjson::Value vdw_cutoff_type; + rapidjson::Value vdw_cutoff_radius; + rapidjson::Value vdw_radius_unit; + rapidjson::Value vdw_cutoff_period(rapidjson::kArrayType); + rapidjson::Value vdw_cn_thr; + rapidjson::Value vdw_cn_thr_unit; + + // @param reading_information -- input_file -- berry_phase_and_wannier90_interface + rapidjson::Value berry_phase; + rapidjson::Value gdir; + rapidjson::Value towannier90; + rapidjson::Value nnkpfile; + rapidjson::Value wannier_spin; + + // @param reading_information -- input_file -- tddft + rapidjson::Value td_edm; + rapidjson::Value td_print_eij; + rapidjson::Value td_propagator; + rapidjson::Value td_vext; + rapidjson::Value td_vext_dire; + rapidjson::Value td_stype; + rapidjson::Value td_ttype; + rapidjson::Value td_tstart; + rapidjson::Value td_tend; + rapidjson::Value td_lcut1; + rapidjson::Value td_lcut2; + rapidjson::Value td_gauss_freq; + rapidjson::Value td_gauss_phase; + rapidjson::Value td_gauss_sigma; + rapidjson::Value td_gauss_t0; + rapidjson::Value td_gauss_amp; + rapidjson::Value td_trape_freq; + rapidjson::Value td_trape_phase; + rapidjson::Value td_trape_t1; + rapidjson::Value td_trape_t2; + rapidjson::Value td_trape_t3; + rapidjson::Value td_trape_amp; + rapidjson::Value td_trigo_freq1; + rapidjson::Value td_trigo_freq2; + rapidjson::Value td_trigo_phase1; + rapidjson::Value td_trigo_phase2; + rapidjson::Value td_trigo_amp; + rapidjson::Value td_heavi_t0; + rapidjson::Value td_heavi_amp; + rapidjson::Value td_out_dipole; + rapidjson::Value td_out_efield; + rapidjson::Value ocp; + rapidjson::Value ocp_set; + + // @param reading_information -- input_file -- debuging_related + rapidjson::Value t_in_h; + rapidjson::Value vl_in_h; + rapidjson::Value vnl_in_h; + rapidjson::Value vh_in_h; + rapidjson::Value vion_in_h; + rapidjson::Value test_force; + rapidjson::Value test_stress; + rapidjson::Value colour; + rapidjson::Value test_skip_ewald; + + // @param reading_information -- input_file -- electronic_conductivities + rapidjson::Value cal_cond; + rapidjson::Value cond_nche; + rapidjson::Value cond_dw; + rapidjson::Value cond_wcut; + rapidjson::Value cond_dt; + rapidjson::Value cond_dtbatch; + rapidjson::Value cond_fwhm; + rapidjson::Value cond_nonlocal; + // @param reading_information -- input_file -- implicit_solvation_model + rapidjson::Value imp_sol; + rapidjson::Value eb_k; + rapidjson::Value tau; + rapidjson::Value sigma_k; + rapidjson::Value nc_k; + + // @param reading_information -- stru_infos: + rapidjson::Value stru_infos(rapidjson::kObjectType); + // rapidjson::Value ATOMIC_SPECIES(rapidjson::kArrayType); + // rapidjson::Value NUMERICAL_ORBITAL; + // rapidjson::Value LATTICE_CONSTANT(rapidjson::kArrayType); + // rapidjson::Value ATOMIC_POSITIONS(rapidjson::kArrayType); + + // @param reading_information -- KPT_infos + rapidjson::Value KPT_infos(rapidjson::kObjectType); + // rapidjson::Value total_number; + // rapidjson::Value mode; + // rapidjson::Value vectors(rapidjson::kArrayType); + + // @param reading_information -- orb_infos + rapidjson::Value orb_infos(rapidjson::kObjectType); + + // @param reading_information -- pp + rapidjson::Value pp(rapidjson::kObjectType); + + // @param init + rapidjson::Value init(rapidjson::kObjectType); + // @param init -- general + // rapidjson::Value calculation; + // rapidjson::Value esolver_type; + // rapidjson::Value basis_type; + // rapidjson::Value gamma_only; + // rapidjson::Value ks_solver; + // rapidjson::Value ntype; + // rapidjson::Value nspin; + // rapidjson::Value ecutwfc; + // rapidjson::Value scf_thr; + // rapidjson::Value scf_nmax; + + // @param init -- symmetry + // rapidjson::Value symmetry(rapidjson::kObjectType); + // rapidjson::Value BRAVAIS_TYPE; + // rapidjson::Value BRAVAIS_LATTICE_NAME; + // rapidjson::Value IBRAV; + // rapidjson::Value LATTICE_CONSTANT_A; + // rapidjson::Value right_hand_lattice; + + // @param init -- Kpoints + rapidjson::Value kpoints(rapidjson::kObjectType); + rapidjson::Value nkstot; + rapidjson::Value nkstot_ibz; + rapidjson::Value coordinates(rapidjson::kArrayType); + rapidjson::Value weight(rapidjson::kArrayType); + + // @param init -- grid + rapidjson::Value grid(rapidjson::kObjectType); + rapidjson::Value energy_cutoff_for_wavefunc; + rapidjson::Value fft_grid_for_wave_functions(rapidjson::kArrayType); + rapidjson::Value number_of_plane_waves; + rapidjson::Value number_of_sticks; + + // @param init -- Smearing + // rapidjson::Value smearing_method; + // rapidjson::Value smearing_sigma; + + // @param init -- mixing + rapidjson::Value mixing; + + + // @param output + rapidjson::Value output(rapidjson::kArrayType); + + + + // @param final_stru + rapidjson::Value final_stru(rapidjson::kObjectType); + rapidjson::Value cell; + rapidjson::Value coordinate; + + + + /** + * The functions below initialize the json output parameter + * tree to connect the nodes of the module + */ + + /** + * @brief add Top stage:parameter in Abacus: + */ + void Init_json_abacus() + { + + + // add First stage:parameter in abcus: + + abacus.AddMember("general_info", general_info, doc.GetAllocator()); + + abacus.AddMember("readin_info", readin_info, doc.GetAllocator()); + + abacus.AddMember("init", init, doc.GetAllocator()); + + abacus.AddMember("output", output, doc.GetAllocator()); + + abacus.AddMember("final_stru", final_stru, doc.GetAllocator()); + + doc.SetObject(); + // abacus.SetObject(); + doc.AddMember("ABACUS", abacus, doc.GetAllocator()); + /** + * . + * . + * . + * . + * . + * . + * . + * */ + } + /** + * @brief add Second stage:parameter in Abacus - general_info: + */ + void Init_json_abacus_generalInfo(){ + general_info.AddMember("version", version, doc.GetAllocator()); + + general_info.AddMember("commit", commit, doc.GetAllocator()); + + general_info.AddMember("begin_time", begin_time, doc.GetAllocator()); + + general_info.AddMember("begin_date", begin_date, doc.GetAllocator()); + + general_info.AddMember("device", device_g, doc.GetAllocator()); + + + + parallel.AddMember("drank", drank, doc.GetAllocator()); + + parallel.AddMember("dsize", dsize, doc.GetAllocator()); + + parallel.AddMember("dcolor", dcolor, doc.GetAllocator()); + + + // add Third stage:parameter in parallel: + general_info.AddMember("parallel", parallel, doc.GetAllocator()); + + } + /** + * @brief delete null node + */ + void RemoveNullValues(rapidjson::Value& parent) { + if (parent.IsObject()) { + for (rapidjson::Value::MemberIterator itr = parent.MemberBegin(); itr != parent.MemberEnd(); ) { + if (itr->value.IsNull()) { + itr = parent.EraseMember(itr); + } else { + // delet son null node + RemoveNullValues(itr->value); + ++itr; + } + } + } else if (parent.IsArray()) { + for (int i = 0; i < parent.Size(); ) { + if (parent[i].IsNull()) { + parent.Erase(parent.Begin() + i); + } else { + // delet son null node + RemoveNullValues(parent[i]); + ++i; + } + } + } + } + + /** + * @brief add Second stage:parameter in Abacus - readin_info: + */ + void Init_json_abacus_readinInfo(){ + //add Third stage:parameter in system_variables: + input_file.AddMember("suffix", input_suffix, doc.GetAllocator()); + input_file.AddMember("ntype", ntype, doc.GetAllocator()); + input_file.AddMember("calculation", calculation, doc.GetAllocator()); + input_file.AddMember("esolver_type", esolver_type, doc.GetAllocator()); + input_file.AddMember("symmetry", symmetry, doc.GetAllocator()); + input_file.AddMember("symmetry_precfield", symmetry_precfield, doc.GetAllocator()); + input_file.AddMember("symmetry_autoclose", symmetry_autoclose, doc.GetAllocator()); + input_file.AddMember("kpar", kpar, doc.GetAllocator()); + input_file.AddMember("bndpar", bndpar, doc.GetAllocator()); + input_file.AddMember("latname", latname, doc.GetAllocator()); + input_file.AddMember("init_wfc", init_wfc, doc.GetAllocator()); + input_file.AddMember("init_chg", init_chg, doc.GetAllocator()); + input_file.AddMember("init_vel", init_vel, doc.GetAllocator()); + input_file.AddMember("nelec", nelec, doc.GetAllocator()); + input_file.AddMember("nupdown", nupdown, doc.GetAllocator()); + input_file.AddMember("dft_functional", dft_functional, doc.GetAllocator()); + input_file.AddMember("xc_temperature", xc_temperature, doc.GetAllocator()); + input_file.AddMember("pseudo_rcut", pseudo_rcut, doc.GetAllocator()); + input_file.AddMember("pseudo_mesh", pseudo_mesh, doc.GetAllocator()); + input_file.AddMember("mem_saver", mem_saver, doc.GetAllocator()); + input_file.AddMember("diago_proc", diago_proc, doc.GetAllocator()); + input_file.AddMember("nbspline", nbspline, doc.GetAllocator()); + input_file.AddMember("kspacing", kspacing, doc.GetAllocator()); + input_file.AddMember("min_dist_coef", min_dist_coef, doc.GetAllocator()); + input_file.AddMember("device", device, doc.GetAllocator()); + + //add Third stage:parameter in files_related: + input_file.AddMember("stru_file", stru_file, doc.GetAllocator()); + input_file.AddMember("kpoint_file", kpoint_file, doc.GetAllocator()); + input_file.AddMember("pseudo_dir", pseudo_dir, doc.GetAllocator()); + input_file.AddMember("orbital_dir", orbital_dir, doc.GetAllocator()); + input_file.AddMember("read_file_dir", read_file_dir, doc.GetAllocator()); + input_file.AddMember("wannier_card", wannier_card, doc.GetAllocator()); + + //add Third stage:parameter in planewave_related: + input_file.AddMember("ecutwfc", ecutwfc, doc.GetAllocator()); + input_file.AddMember("nx", nx, doc.GetAllocator()); + input_file.AddMember("ny", ny, doc.GetAllocator()); + input_file.AddMember("nz", nz, doc.GetAllocator()); + input_file.AddMember("pw_seed", pw_seed, doc.GetAllocator()); + input_file.AddMember("pw_diag_thr", pw_diag_thr, doc.GetAllocator()); + input_file.AddMember("pw_diag_nmax", pw_diag_nmax, doc.GetAllocator()); + input_file.AddMember("pw_diag_ndim", pw_diag_ndim, doc.GetAllocator()); + + + //add Third stage:parameter in numerical_atomic_orbitals_related: + input_file.AddMember("nb2d", nb2d, doc.GetAllocator()); + input_file.AddMember("lmaxmax", lmaxmax, doc.GetAllocator()); + input_file.AddMember("lcao_ecut", lcao_ecut, doc.GetAllocator()); + input_file.AddMember("lcao_dk", lcao_dk, doc.GetAllocator()); + input_file.AddMember("lcao_dr", lcao_dr, doc.GetAllocator()); + input_file.AddMember("lcao_rmax", lcao_rmax, doc.GetAllocator()); + input_file.AddMember("search_radius", search_radius, doc.GetAllocator()); + input_file.AddMember("search_pbc", search_pbc, doc.GetAllocator()); + input_file.AddMember("bx", bx, doc.GetAllocator()); + input_file.AddMember("by", by, doc.GetAllocator()); + input_file.AddMember("bz", bz, doc.GetAllocator()); + + //add Third stage:parameter in electronic_structure: + input_file.AddMember("basis_type", basis_type, doc.GetAllocator()); + input_file.AddMember("ks_solver", ks_solver, doc.GetAllocator()); + input_file.AddMember("nbands", nbands, doc.GetAllocator()); + input_file.AddMember("nbands_istate", nbands_istate, doc.GetAllocator()); + input_file.AddMember("nspin", nspin, doc.GetAllocator()); + input_file.AddMember("smearing_method", smearing_method, doc.GetAllocator()); + input_file.AddMember("smearing_sigma", smearing_sigma, doc.GetAllocator()); + input_file.AddMember("smearing_sigma_temp", smearing_sigma_temp, doc.GetAllocator()); + input_file.AddMember("mixing_type", mixing_type, doc.GetAllocator()); + input_file.AddMember("mixing_beta", mixing_beta, doc.GetAllocator()); + input_file.AddMember("mixing_ndim", mixing_ndim, doc.GetAllocator()); + input_file.AddMember("mixing_gg0", mixing_gg0, doc.GetAllocator()); + input_file.AddMember("mixing_tau", mixing_tau, doc.GetAllocator()); + input_file.AddMember("mixing_dftu", mixing_dftu, doc.GetAllocator()); + input_file.AddMember("gamma_only", gamma_only, doc.GetAllocator()); + input_file.AddMember("printe", printe, doc.GetAllocator()); + input_file.AddMember("scf_nmax", scf_nmax, doc.GetAllocator()); + input_file.AddMember("scf_thr", scf_thr, doc.GetAllocator()); + input_file.AddMember("scf_thr_type", scf_thr_type, doc.GetAllocator()); + input_file.AddMember("chg_extrap", chg_extrap, doc.GetAllocator()); + input_file.AddMember("lspinorb", lspinorb, doc.GetAllocator()); + input_file.AddMember("noncolin", noncolin, doc.GetAllocator()); + input_file.AddMember("soc_lambda", soc_lambda, doc.GetAllocator()); + + + //add Third stage:parameter in electronic_structure_SDFT: + input_file.AddMember("method_sto", method_sto, doc.GetAllocator()); + input_file.AddMember("nbands_sto", nbands_sto, doc.GetAllocator()); + input_file.AddMember("nche_sto", nche_sto, doc.GetAllocator()); + input_file.AddMember("emin_sto", emin_sto, doc.GetAllocator()); + input_file.AddMember("emax_sto", emax_sto, doc.GetAllocator()); + input_file.AddMember("seed_sto", seed_sto, doc.GetAllocator()); + input_file.AddMember("initsto_freq", initsto_freq, doc.GetAllocator()); + input_file.AddMember("npart_sto", npart_sto, doc.GetAllocator()); + + + //add Third stage:parameter in geometry_relaxation: + input_file.AddMember("relax_method", relax_method, doc.GetAllocator()); + input_file.AddMember("relax_new", relax_new, doc.GetAllocator()); + input_file.AddMember("relax_scale_force", relax_scale_force, doc.GetAllocator()); + input_file.AddMember("relax_nmax", relax_nmax, doc.GetAllocator()); + input_file.AddMember("relax_cg_thr", relax_cg_thr, doc.GetAllocator()); + input_file.AddMember("cal_force", cal_force, doc.GetAllocator()); + input_file.AddMember("force_thr", force_thr, doc.GetAllocator()); + input_file.AddMember("force_thr_ev", force_thr_ev, doc.GetAllocator()); + input_file.AddMember("force_thr_ev2", force_thr_ev2, doc.GetAllocator()); + input_file.AddMember("relax_bfgs_w1", relax_bfgs_w1, doc.GetAllocator()); + input_file.AddMember("relax_bfgs_w2", relax_bfgs_w2, doc.GetAllocator()); + input_file.AddMember("relax_bfgs_rmax", relax_bfgs_rmax, doc.GetAllocator()); + input_file.AddMember("relax_bfgs_rmin", relax_bfgs_rmin, doc.GetAllocator()); + input_file.AddMember("relax_bfgs_init", relax_bfgs_init, doc.GetAllocator()); + input_file.AddMember("cal_stress", cal_stress, doc.GetAllocator()); + input_file.AddMember("stress_thr", stress_thr, doc.GetAllocator()); + input_file.AddMember("press1", press1, doc.GetAllocator()); + input_file.AddMember("press2", press2, doc.GetAllocator()); + input_file.AddMember("press3", press3, doc.GetAllocator()); + input_file.AddMember("fixed_axes", fixed_axes, doc.GetAllocator()); + input_file.AddMember("fixed_ibrav", fixed_ibrav, doc.GetAllocator()); + input_file.AddMember("fixed_atoms", fixed_atoms, doc.GetAllocator()); + input_file.AddMember("cell_factor", cell_factor, doc.GetAllocator()); + + + //add Third stage:parameter in output_information_related: + input_file.AddMember("out_mul", out_mul, doc.GetAllocator()); + input_file.AddMember("out_freq_elec", out_freq_elec, doc.GetAllocator()); + input_file.AddMember("out_freq_ion", out_freq_ion, doc.GetAllocator()); + input_file.AddMember("out_chg", out_chg, doc.GetAllocator()); + input_file.AddMember("out_pot", out_pot, doc.GetAllocator()); + input_file.AddMember("out_dm", out_dm, doc.GetAllocator()); + input_file.AddMember("out_dm1", out_dm1, doc.GetAllocator()); + input_file.AddMember("out_wfc_pw", out_wfc_pw, doc.GetAllocator()); + input_file.AddMember("out_wfc_r", out_wfc_r, doc.GetAllocator()); + input_file.AddMember("out_wfc_lcao", out_wfc_lcao, doc.GetAllocator()); + input_file.AddMember("out_dos", out_dos, doc.GetAllocator()); + input_file.AddMember("out_band", out_band, doc.GetAllocator()); + input_file.AddMember("out_proj_band", out_proj_band, doc.GetAllocator()); + input_file.AddMember("out_stru", out_stru, doc.GetAllocator()); + input_file.AddMember("out_bandgap", out_bandgap, doc.GetAllocator()); + input_file.AddMember("out_level", out_level, doc.GetAllocator()); + input_file.AddMember("out_alllog", out_alllog, doc.GetAllocator()); + input_file.AddMember("out_mat_hs", out_mat_hs, doc.GetAllocator()); + input_file.AddMember("out_mat_r", out_mat_r, doc.GetAllocator()); + input_file.AddMember("out_mat_hs2", out_mat_hs2, doc.GetAllocator()); + input_file.AddMember("out_mat_t", out_mat_t, doc.GetAllocator()); + input_file.AddMember("out_mat_dh", out_mat_dh, doc.GetAllocator()); + input_file.AddMember("out_app_flag", out_app_flag, doc.GetAllocator()); + input_file.AddMember("out_interval", out_interval, doc.GetAllocator()); + input_file.AddMember("out_element_info", out_element_info, doc.GetAllocator()); + input_file.AddMember("restart_save", restart_save, doc.GetAllocator()); + input_file.AddMember("restart_load", restart_load, doc.GetAllocator()); + input_file.AddMember("rpa", rpa, doc.GetAllocator()); + + //add Third stage:parameter in density_of_states: + input_file.AddMember("dos_edelta_ev", dos_edelta_ev, doc.GetAllocator()); + input_file.AddMember("dos_sigma", dos_sigma, doc.GetAllocator()); + input_file.AddMember("dos_scale", dos_scale, doc.GetAllocator()); + input_file.AddMember("dos_emin_ev", dos_emin_ev, doc.GetAllocator()); + input_file.AddMember("dos_emax_ev", dos_emax_ev, doc.GetAllocator()); + input_file.AddMember("dos_nche", dos_nche, doc.GetAllocator()); + + //add Third stage:parameter in naos: + input_file.AddMember("bessel_nao_ecut", bessel_nao_ecut, doc.GetAllocator()); + input_file.AddMember("bessel_nao_tolerence", bessel_nao_tolerence, doc.GetAllocator()); + input_file.AddMember("bessel_nao_rcut", bessel_nao_rcut, doc.GetAllocator()); + input_file.AddMember("bessel_nao_smooth", bessel_nao_smooth, doc.GetAllocator()); + input_file.AddMember("bessel_nao_sigma", bessel_nao_sigma, doc.GetAllocator()); + + //add Third stage:parameter in deepks: + input_file.AddMember("input_file_out_labels", input_file_out_labels, doc.GetAllocator()); + input_file.AddMember("input_file_scf", input_file_scf, doc.GetAllocator()); + input_file.AddMember("input_file_model", input_file_model, doc.GetAllocator()); + input_file.AddMember("bessel_descriptor_lmax", bessel_descriptor_lmax, doc.GetAllocator()); + input_file.AddMember("bessel_descriptor_ecut", bessel_descriptor_ecut, doc.GetAllocator()); + input_file.AddMember("bessel_descriptor_tolerence", bessel_descriptor_tolerence, doc.GetAllocator()); + input_file.AddMember("bessel_descriptor_rcut", bessel_descriptor_rcut, doc.GetAllocator()); + input_file.AddMember("bessel_descriptor_smooth", bessel_descriptor_smooth, doc.GetAllocator()); + input_file.AddMember("bessel_descriptor_sigma", bessel_descriptor_sigma, doc.GetAllocator()); + input_file.AddMember("input_file_bandgap", input_file_bandgap, doc.GetAllocator()); + input_file.AddMember("input_file_out_unittest", input_file_out_unittest, doc.GetAllocator()); + + //add Third stage:parameter in ofdft: + input_file.AddMember("of_kinetic", of_kinetic, doc.GetAllocator()); + input_file.AddMember("of_method", of_method, doc.GetAllocator()); + input_file.AddMember("of_conv", of_conv, doc.GetAllocator()); + input_file.AddMember("of_tole", of_tole, doc.GetAllocator()); + input_file.AddMember("of_tolp", of_tolp, doc.GetAllocator()); + input_file.AddMember("of_tf_weight", of_tf_weight, doc.GetAllocator()); + input_file.AddMember("of_vw_weight", of_vw_weight, doc.GetAllocator()); + input_file.AddMember("of_wt_alpha", of_wt_alpha, doc.GetAllocator()); + input_file.AddMember("of_wt_beta", of_wt_beta, doc.GetAllocator()); + input_file.AddMember("of_wt_rho0", of_wt_rho0, doc.GetAllocator()); + input_file.AddMember("of_hold_rho0", of_hold_rho0, doc.GetAllocator()); + input_file.AddMember("of_lkt_a", of_lkt_a, doc.GetAllocator()); + input_file.AddMember("of_read_kernel", of_read_kernel, doc.GetAllocator()); + input_file.AddMember("of_kernel_file", of_kernel_file, doc.GetAllocator()); + input_file.AddMember("of_full_pw", of_full_pw, doc.GetAllocator()); + input_file.AddMember("of_full_pw_dim", of_full_pw_dim, doc.GetAllocator()); + + + //add Third stage:parameter in electric_field_and_dipole_correction: + input_file.AddMember("efield_flag", efield_flag, doc.GetAllocator()); + input_file.AddMember("dip_cor_flag", dip_cor_flag, doc.GetAllocator()); + input_file.AddMember("efield_dir", efield_dir, doc.GetAllocator()); + input_file.AddMember("efield_pos_max", efield_pos_max, doc.GetAllocator()); + input_file.AddMember("efield_pos_dec", efield_pos_dec, doc.GetAllocator()); + input_file.AddMember("efield_amp", efield_amp, doc.GetAllocator()); + + //add Third stage:parameter in gate_field: + input_file.AddMember("gate_flag", gate_flag, doc.GetAllocator()); + input_file.AddMember("zgate", zgate, doc.GetAllocator()); + input_file.AddMember("block", block, doc.GetAllocator()); + input_file.AddMember("block_down", block_down, doc.GetAllocator()); + input_file.AddMember("block_up", block_up, doc.GetAllocator()); + input_file.AddMember("block_height", block_height, doc.GetAllocator()); + + //add Third stage:parameter in exact_exchange: + input_file.AddMember("exx_hybrid_alpha", exx_hybrid_alpha, doc.GetAllocator()); + input_file.AddMember("exx_hse_omega", exx_hse_omega, doc.GetAllocator()); + input_file.AddMember("exx_separate_loop", exx_separate_loop, doc.GetAllocator()); + input_file.AddMember("exx_hybrid_step", exx_hybrid_step, doc.GetAllocator()); + input_file.AddMember("exx_mixing_beta", exx_mixing_beta, doc.GetAllocator()); + input_file.AddMember("exx_lambda", exx_lambda, doc.GetAllocator()); + input_file.AddMember("exx_pca_threshold", exx_pca_threshold, doc.GetAllocator()); + input_file.AddMember("exx_c_threshold", exx_c_threshold, doc.GetAllocator()); + input_file.AddMember("exx_v_threshold", exx_v_threshold, doc.GetAllocator()); + input_file.AddMember("exx_dm_threshold", exx_dm_threshold, doc.GetAllocator()); + input_file.AddMember("exx_c_grad_threshold", exx_c_grad_threshold, doc.GetAllocator()); + input_file.AddMember("exx_v_grad_threshold", exx_v_grad_threshold, doc.GetAllocator()); + input_file.AddMember("exx_schwarz_threshold", exx_schwarz_threshold, doc.GetAllocator()); + input_file.AddMember("exx_cauchy_threshold", exx_cauchy_threshold, doc.GetAllocator()); + input_file.AddMember("exx_cauchy_force_threshold", exx_cauchy_force_threshold, doc.GetAllocator()); + input_file.AddMember("exx_cauchy_stress_threshold", exx_cauchy_stress_threshold, doc.GetAllocator()); + input_file.AddMember("exx_ccp_threshold", exx_ccp_threshold, doc.GetAllocator()); + input_file.AddMember("exx_ccp_rmesh_times", exx_ccp_rmesh_times, doc.GetAllocator()); + input_file.AddMember("exx_distribute_type", exx_distribute_type, doc.GetAllocator()); + input_file.AddMember("exx_opt_orb_lmax", exx_opt_orb_lmax, doc.GetAllocator()); + input_file.AddMember("exx_opt_orb_ecut", exx_opt_orb_ecut, doc.GetAllocator()); + input_file.AddMember("exx_opt_orb_tolerence", exx_opt_orb_tolerence, doc.GetAllocator()); + input_file.AddMember("exx_real_number", exx_real_number, doc.GetAllocator()); + + + //add Third stage:parameter in molecular_dynamics: + input_file.AddMember("md_type", md_type, doc.GetAllocator()); + input_file.AddMember("md_nstep", md_nstep, doc.GetAllocator()); + input_file.AddMember("md_dt", md_dt, doc.GetAllocator()); + input_file.AddMember("md_thermostat", md_thermostat, doc.GetAllocator()); + input_file.AddMember("md_tlast", md_tlast, doc.GetAllocator()); + input_file.AddMember("md_tfirst", md_tfirst, doc.GetAllocator()); + input_file.AddMember("md_restart", md_restart, doc.GetAllocator()); + input_file.AddMember("md_restartfreq", md_restartfreq, doc.GetAllocator()); + input_file.AddMember("md_dumpfreq", md_dumpfreq, doc.GetAllocator()); + input_file.AddMember("dump_force", dump_force, doc.GetAllocator()); + input_file.AddMember("dump_vel", dump_vel, doc.GetAllocator()); + input_file.AddMember("dump_virial", dump_virial, doc.GetAllocator()); + input_file.AddMember("md_seed", md_seed, doc.GetAllocator()); + input_file.AddMember("md_tfreq", md_tfreq, doc.GetAllocator()); + input_file.AddMember("md_tchain", md_tchain, doc.GetAllocator()); + input_file.AddMember("md_pmode", md_pmode, doc.GetAllocator()); + input_file.AddMember("md_prec_level", md_prec_level, doc.GetAllocator()); + input_file.AddMember("ref_cell_factor", ref_cell_factor, doc.GetAllocator()); + input_file.AddMember("md_pcouple", md_pcouple, doc.GetAllocator()); + input_file.AddMember("md_pfirst", md_pfirst, doc.GetAllocator()); + input_file.AddMember("md_plast", md_plast, doc.GetAllocator()); + input_file.AddMember("md_pfreq", md_pfreq, doc.GetAllocator()); + input_file.AddMember("md_pchain", md_pchain, doc.GetAllocator()); + input_file.AddMember("lj_rcut", lj_rcut, doc.GetAllocator()); + input_file.AddMember("lj_epsilon", lj_epsilon, doc.GetAllocator()); + input_file.AddMember("lj_sigma", lj_sigma, doc.GetAllocator()); + input_file.AddMember("pot_file", pot_file, doc.GetAllocator()); + input_file.AddMember("msst_direction", msst_direction, doc.GetAllocator()); + input_file.AddMember("msst_vel", msst_vel, doc.GetAllocator()); + input_file.AddMember("msst_vis", msst_vis, doc.GetAllocator()); + input_file.AddMember("msst_tscale", msst_tscale, doc.GetAllocator()); + input_file.AddMember("msst_qmass", msst_qmass, doc.GetAllocator()); + input_file.AddMember("md_damp", md_damp, doc.GetAllocator()); + input_file.AddMember("md_tolerance", md_tolerance, doc.GetAllocator()); + input_file.AddMember("md_nraise", md_nraise, doc.GetAllocator()); + input_file.AddMember("cal_syns", cal_syns, doc.GetAllocator()); + input_file.AddMember("dmax", dmax, doc.GetAllocator()); + + //add Third stage:parameter in dft_plus_u: + input_file.AddMember("orbital_corr", orbital_corr, doc.GetAllocator()); + input_file.AddMember("hubbard_u", hubbard_u, doc.GetAllocator()); + input_file.AddMember("yukawa_potential", yukawa_potential, doc.GetAllocator()); + input_file.AddMember("yukawa_lambda", yukawa_lambda, doc.GetAllocator()); + input_file.AddMember("omc", omc, doc.GetAllocator()); + + //add Third stage:parameter in vdw_correction: + input_file.AddMember("vdw_method", vdw_method, doc.GetAllocator()); + input_file.AddMember("vdw_s6", vdw_s6, doc.GetAllocator()); + input_file.AddMember("vdw_s8", vdw_s8, doc.GetAllocator()); + input_file.AddMember("vdw_a1", vdw_a1, doc.GetAllocator()); + input_file.AddMember("vdw_a2", vdw_a2, doc.GetAllocator()); + input_file.AddMember("vdw_d", vdw_d, doc.GetAllocator()); + input_file.AddMember("vdw_abc", vdw_abc, doc.GetAllocator()); + input_file.AddMember("vdw_C6_file", vdw_C6_file, doc.GetAllocator()); + input_file.AddMember("vdw_C6_unit", vdw_C6_unit, doc.GetAllocator()); + input_file.AddMember("vdw_R0_file", vdw_R0_file, doc.GetAllocator()); + input_file.AddMember("vdw_R0_unit", vdw_R0_unit, doc.GetAllocator()); + input_file.AddMember("vdw_cutoff_type", vdw_cutoff_type, doc.GetAllocator()); + input_file.AddMember("vdw_cutoff_radius", vdw_cutoff_radius, doc.GetAllocator()); + input_file.AddMember("vdw_radius_unit", vdw_radius_unit, doc.GetAllocator()); + input_file.AddMember("vdw_cutoff_period", vdw_cutoff_period, doc.GetAllocator()); + input_file.AddMember("vdw_cn_thr", vdw_cn_thr, doc.GetAllocator()); + input_file.AddMember("vdw_cn_thr_unit", vdw_cn_thr_unit, doc.GetAllocator()); + + //add Third stage:parameter in berry_phase_and_wannier90_interface: + input_file.AddMember("berry_phase", berry_phase, doc.GetAllocator()); + input_file.AddMember("gdir", gdir, doc.GetAllocator()); + input_file.AddMember("towannier90", towannier90, doc.GetAllocator()); + input_file.AddMember("nnkpfile", nnkpfile, doc.GetAllocator()); + input_file.AddMember("wannier_spin", wannier_spin, doc.GetAllocator()); + + //add Third stage:parameter in tddft: + input_file.AddMember("td_edm", td_edm, doc.GetAllocator()); + input_file.AddMember("td_print_eij", td_print_eij, doc.GetAllocator()); + input_file.AddMember("td_propagator", td_propagator, doc.GetAllocator()); + input_file.AddMember("td_vext", td_vext, doc.GetAllocator()); + input_file.AddMember("td_vext_dire", td_vext_dire, doc.GetAllocator()); + input_file.AddMember("td_stype", td_stype, doc.GetAllocator()); + input_file.AddMember("td_ttype", td_ttype, doc.GetAllocator()); + input_file.AddMember("td_tstart", td_tstart, doc.GetAllocator()); + input_file.AddMember("td_tend", td_tend, doc.GetAllocator()); + input_file.AddMember("td_lcut1", td_lcut1, doc.GetAllocator()); + input_file.AddMember("td_lcut2", td_lcut2, doc.GetAllocator()); + input_file.AddMember("td_gauss_freq", td_gauss_freq, doc.GetAllocator()); + input_file.AddMember("td_gauss_phase", td_gauss_phase, doc.GetAllocator()); + input_file.AddMember("td_gauss_sigma", td_gauss_sigma, doc.GetAllocator()); + input_file.AddMember("td_gauss_t0", td_gauss_t0, doc.GetAllocator()); + input_file.AddMember("td_gauss_amp", td_gauss_amp, doc.GetAllocator()); + input_file.AddMember("td_trape_freq", td_trape_freq, doc.GetAllocator()); + input_file.AddMember("td_trape_phase", td_trape_phase, doc.GetAllocator()); + input_file.AddMember("td_trape_t1", td_trape_t1, doc.GetAllocator()); + input_file.AddMember("td_trape_t2", td_trape_t2, doc.GetAllocator()); + input_file.AddMember("td_trape_t3", td_trape_t3, doc.GetAllocator()); + input_file.AddMember("td_trape_amp", td_trape_amp, doc.GetAllocator()); + input_file.AddMember("td_trigo_freq1", td_trigo_freq1, doc.GetAllocator()); + input_file.AddMember("td_trigo_freq2", td_trigo_freq2, doc.GetAllocator()); + input_file.AddMember("td_trigo_phase1", td_trigo_phase1, doc.GetAllocator()); + input_file.AddMember("td_trigo_phase2", td_trigo_phase2, doc.GetAllocator()); + input_file.AddMember("td_trigo_amp", td_trigo_amp, doc.GetAllocator()); + input_file.AddMember("td_heavi_t0", td_heavi_t0, doc.GetAllocator()); + input_file.AddMember("td_heavi_amp", td_heavi_amp, doc.GetAllocator()); + input_file.AddMember("td_out_dipole", td_out_dipole, doc.GetAllocator()); + input_file.AddMember("td_out_efield", td_out_efield, doc.GetAllocator()); + input_file.AddMember("ocp", ocp, doc.GetAllocator()); + input_file.AddMember("ocp_set", ocp_set, doc.GetAllocator()); + + //add Third stage:parameter in debuging_related: + input_file.AddMember("t_in_h", t_in_h, doc.GetAllocator()); + input_file.AddMember("vl_in_h", vl_in_h, doc.GetAllocator()); + input_file.AddMember("vnl_in_h", vnl_in_h, doc.GetAllocator()); + input_file.AddMember("vh_in_h", vh_in_h, doc.GetAllocator()); + input_file.AddMember("vion_in_h", vion_in_h, doc.GetAllocator()); + input_file.AddMember("test_force", test_force, doc.GetAllocator()); + input_file.AddMember("test_stress", test_stress, doc.GetAllocator()); + input_file.AddMember("colour", colour, doc.GetAllocator()); + input_file.AddMember("test_skip_ewald", test_skip_ewald, doc.GetAllocator()); + + //add Third stage:parameter in electronic_conductivities: + input_file.AddMember("cal_cond", cal_cond, doc.GetAllocator()); + input_file.AddMember("cond_nche", cond_nche, doc.GetAllocator()); + input_file.AddMember("cond_dw", cond_dw, doc.GetAllocator()); + input_file.AddMember("cond_wcut", cond_wcut, doc.GetAllocator()); + input_file.AddMember("cond_dt", cond_dt, doc.GetAllocator()); + input_file.AddMember("cond_dtbatch", cond_dtbatch, doc.GetAllocator()); + input_file.AddMember("cond_fwhm", cond_fwhm, doc.GetAllocator()); + input_file.AddMember("cond_nonlocal", cond_nonlocal, doc.GetAllocator()); + + //add Third stage:parameter in implicit_solvation_model: + input_file.AddMember("imp_sol", imp_sol, doc.GetAllocator()); + input_file.AddMember("eb_k", eb_k, doc.GetAllocator()); + input_file.AddMember("tau", tau, doc.GetAllocator()); + input_file.AddMember("sigma_k", sigma_k, doc.GetAllocator()); + input_file.AddMember("nc_k", nc_k, doc.GetAllocator()); + + + RemoveNullValues(input_file); + + + // after add child_node's node in readin_info, add child node + // add parameters in readin_info: + readin_info.AddMember("input_file", input_file, doc.GetAllocator()); + + } + + + void Finish_json_tree(){ + // Converts a json object to a string + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + doc.Accept(writer); + + // Output the json string to a file + std::string json_path; + json_path.append("abacus.json"); + + std::ofstream ofs(json_path); + ofs << buffer.GetString() << std::endl; + ofs.close(); + } + + + + +} + + +#endif \ No newline at end of file diff --git a/source/module_base/para_json.h b/source/module_base/para_json.h new file mode 100644 index 0000000000..0e829dc80e --- /dev/null +++ b/source/module_base/para_json.h @@ -0,0 +1,560 @@ + +#include +#include +#include +#include +#include + +#ifdef __RAPIDJSON + +#include +#include +#include + + +/** + * @brief This namespace is used to store the json object of the + * abacus parameter and its handlers. Used to read the parameters + * at run time and finally organize them into json format files + * +*/ +namespace Para_Json +{ + + extern int test; + // @param doc: the output json file + extern rapidjson::Document doc; + extern rapidjson::Value abacus; + + // @param general_info : + extern rapidjson::Value general_info; + extern rapidjson::Value version; + extern rapidjson::Value commit; + extern rapidjson::Value begin_time; + extern rapidjson::Value begin_date; + extern rapidjson::Value device_g; + // @param general_info -- parallel: + extern rapidjson::Value parallel; + extern rapidjson::Value drank; + extern rapidjson::Value dsize; + extern rapidjson::Value dcolor ; + // @param general_info -- path + extern rapidjson::Value path; + extern rapidjson::Value global_out_dir; + extern rapidjson::Value global_in_card; + extern rapidjson::Value pseudo_dir_path ; + extern rapidjson::Value orbital_dir_path; + + + // @param reading_information: + extern rapidjson::Value readin_info; + // @param reading_information -- input_para: + + // @param reading_information -- input_para -- system_variables: + extern rapidjson::Value system_variables; + + extern rapidjson::Value input_file; + extern rapidjson::Value input_suffix; + extern rapidjson::Value ntype; + extern rapidjson::Value calculation; + extern rapidjson::Value esolver_type; + extern rapidjson::Value symmetry; + extern rapidjson::Value symmetry_precfield; + extern rapidjson::Value symmetry_autoclose; + extern rapidjson::Value kpar; + extern rapidjson::Value bndpar; + extern rapidjson::Value latname; + extern rapidjson::Value init_wfc; + extern rapidjson::Value init_chg; + extern rapidjson::Value init_vel; + extern rapidjson::Value nelec; + extern rapidjson::Value nupdown; + extern rapidjson::Value dft_functional; + extern rapidjson::Value xc_temperature; + extern rapidjson::Value pseudo_rcut; + extern rapidjson::Value pseudo_mesh; + extern rapidjson::Value mem_saver; + extern rapidjson::Value diago_proc; + extern rapidjson::Value nbspline; + extern rapidjson::Value kspacing; + extern rapidjson::Value min_dist_coef; + extern rapidjson::Value device; + // @param reading_information -- input_para -- files_related + + extern rapidjson::Value stru_file; + extern rapidjson::Value kpoint_file; + extern rapidjson::Value pseudo_dir; + extern rapidjson::Value orbital_dir; + extern rapidjson::Value read_file_dir; + extern rapidjson::Value wannier_card; + // @param reading_information -- input_para -- planewave_related + + extern rapidjson::Value ecutwfc; + extern rapidjson::Value nx; + extern rapidjson::Value ny; + extern rapidjson::Value nz; + extern rapidjson::Value pw_seed; + extern rapidjson::Value pw_diag_thr; + extern rapidjson::Value pw_diag_nmax; + extern rapidjson::Value pw_diag_ndim; + // @param reading_information -- input_para -- numerical_atomic_orbitals_related + + extern rapidjson::Value nb2d; + extern rapidjson::Value lmaxmax; + extern rapidjson::Value lcao_ecut; + extern rapidjson::Value lcao_dk; + extern rapidjson::Value lcao_dr; + extern rapidjson::Value lcao_rmax; + extern rapidjson::Value search_radius; + extern rapidjson::Value search_pbc; + extern rapidjson::Value bx; + extern rapidjson::Value by; + extern rapidjson::Value bz; + // @param reading_information -- input_para -- electronic_structure + + extern rapidjson::Value basis_type; + extern rapidjson::Value ks_solver; + extern rapidjson::Value nbands; + extern rapidjson::Value nbands_istate; + extern rapidjson::Value nspin; + extern rapidjson::Value smearing_method; + extern rapidjson::Value smearing_sigma; + extern rapidjson::Value smearing_sigma_temp; + extern rapidjson::Value mixing_type; + extern rapidjson::Value mixing_beta; + extern rapidjson::Value mixing_ndim; + extern rapidjson::Value mixing_gg0; + extern rapidjson::Value mixing_tau; + extern rapidjson::Value mixing_dftu; + extern rapidjson::Value gamma_only; + extern rapidjson::Value printe; + extern rapidjson::Value scf_nmax; + extern rapidjson::Value scf_thr; + extern rapidjson::Value scf_thr_type; + extern rapidjson::Value chg_extrap; + extern rapidjson::Value lspinorb; + extern rapidjson::Value noncolin; + extern rapidjson::Value soc_lambda; + // @param reading_information -- input_para -- electronic_structure_SDFT + + extern rapidjson::Value method_sto; + extern rapidjson::Value nbands_sto; + extern rapidjson::Value nche_sto; + extern rapidjson::Value emin_sto; + extern rapidjson::Value emax_sto; + extern rapidjson::Value seed_sto; + extern rapidjson::Value initsto_freq; + extern rapidjson::Value npart_sto; + // @param reading_information -- input_para -- geometry_relaxation + + extern rapidjson::Value relax_method; + extern rapidjson::Value relax_new; + extern rapidjson::Value relax_scale_force; + extern rapidjson::Value relax_nmax; + extern rapidjson::Value relax_cg_thr; + extern rapidjson::Value cal_force; + extern rapidjson::Value force_thr; + extern rapidjson::Value force_thr_ev; + extern rapidjson::Value force_thr_ev2; + extern rapidjson::Value relax_bfgs_w1; + extern rapidjson::Value relax_bfgs_w2; + extern rapidjson::Value relax_bfgs_rmax; + extern rapidjson::Value relax_bfgs_rmin; + extern rapidjson::Value relax_bfgs_init; + extern rapidjson::Value cal_stress; + extern rapidjson::Value stress_thr; + extern rapidjson::Value press1; + extern rapidjson::Value press2; + extern rapidjson::Value press3; + extern rapidjson::Value fixed_axes; + extern rapidjson::Value fixed_ibrav; + extern rapidjson::Value fixed_atoms; + extern rapidjson::Value cell_factor; + + // @param reading_information -- input_para -- output_information_related + + extern rapidjson::Value out_mul; + extern rapidjson::Value out_freq_elec; + extern rapidjson::Value out_freq_ion; + extern rapidjson::Value out_chg; + extern rapidjson::Value out_pot; + extern rapidjson::Value out_dm; + extern rapidjson::Value out_dm1; + extern rapidjson::Value out_wfc_pw; + extern rapidjson::Value out_wfc_r; + extern rapidjson::Value out_wfc_lcao; + extern rapidjson::Value out_dos; + extern rapidjson::Value out_band; + extern rapidjson::Value out_proj_band; + extern rapidjson::Value out_stru; + extern rapidjson::Value out_bandgap; + extern rapidjson::Value out_level; + extern rapidjson::Value out_alllog; + extern rapidjson::Value out_mat_hs; + extern rapidjson::Value out_mat_r; + extern rapidjson::Value out_mat_hs2; + extern rapidjson::Value out_mat_t; + extern rapidjson::Value out_mat_dh; + extern rapidjson::Value out_app_flag; + extern rapidjson::Value out_interval; + extern rapidjson::Value out_element_info; + extern rapidjson::Value restart_save; + extern rapidjson::Value restart_load; + extern rapidjson::Value rpa; + + // @param reading_information -- input_para -- density_of_states + + extern rapidjson::Value dos_edelta_ev; + extern rapidjson::Value dos_sigma; + extern rapidjson::Value dos_scale; + extern rapidjson::Value dos_emin_ev; + extern rapidjson::Value dos_emax_ev; + extern rapidjson::Value dos_nche; + // @param reading_information -- input_para -- naos + extern rapidjson::Value bessel_nao_ecut; + extern rapidjson::Value bessel_nao_tolerence; + extern rapidjson::Value bessel_nao_rcut; + extern rapidjson::Value bessel_nao_smooth; + extern rapidjson::Value bessel_nao_sigma; + // @param reading_information -- input_para -- deepks + + extern rapidjson::Value deepks_out_labels; + extern rapidjson::Value deepks_scf; + extern rapidjson::Value deepks_model; + extern rapidjson::Value bessel_descriptor_lmax; + extern rapidjson::Value bessel_descriptor_ecut; + extern rapidjson::Value bessel_descriptor_tolerence; + extern rapidjson::Value bessel_descriptor_rcut; + extern rapidjson::Value bessel_descriptor_smooth; + extern rapidjson::Value bessel_descriptor_sigma; + extern rapidjson::Value deepks_bandgap; + extern rapidjson::Value deepks_out_unittest; + // @param reading_information -- input_para -- ofdft + extern rapidjson::Value of_kinetic; + extern rapidjson::Value of_method; + extern rapidjson::Value of_conv; + extern rapidjson::Value of_tole; + extern rapidjson::Value of_tolp; + extern rapidjson::Value of_tf_weight; + extern rapidjson::Value of_vw_weight; + extern rapidjson::Value of_wt_alpha; + extern rapidjson::Value of_wt_beta; + extern rapidjson::Value of_wt_rho0; + extern rapidjson::Value of_hold_rho0; + extern rapidjson::Value of_lkt_a; + extern rapidjson::Value of_read_kernel; + extern rapidjson::Value of_kernel_file; + extern rapidjson::Value of_full_pw; + extern rapidjson::Value of_full_pw_dim; + + // @param reading_information -- input_para -- electric_field_and_dipole_correction + + extern rapidjson::Value efield_flag; + extern rapidjson::Value dip_cor_flag; + extern rapidjson::Value efield_dir; + extern rapidjson::Value efield_pos_max; + extern rapidjson::Value efield_pos_dec; + extern rapidjson::Value efield_amp; + // @param reading_information -- input_para -- gate_field + + extern rapidjson::Value gate_flag; + extern rapidjson::Value zgate; + extern rapidjson::Value block; + extern rapidjson::Value block_down; + extern rapidjson::Value block_up; + extern rapidjson::Value block_height; + // @param reading_information -- input_para -- exact_exchange + extern rapidjson::Value exx_hybrid_alpha; + extern rapidjson::Value exx_hse_omega; + extern rapidjson::Value exx_separate_loop; + extern rapidjson::Value exx_hybrid_step; + extern rapidjson::Value exx_mixing_beta; + extern rapidjson::Value exx_lambda; + extern rapidjson::Value exx_pca_threshold; + extern rapidjson::Value exx_c_threshold; + extern rapidjson::Value exx_v_threshold; + extern rapidjson::Value exx_dm_threshold; + extern rapidjson::Value exx_c_grad_threshold; + extern rapidjson::Value exx_v_grad_threshold; + extern rapidjson::Value exx_schwarz_threshold; + extern rapidjson::Value exx_cauchy_threshold; + extern rapidjson::Value exx_cauchy_force_threshold; + extern rapidjson::Value exx_cauchy_stress_threshold; + extern rapidjson::Value exx_ccp_threshold; + extern rapidjson::Value exx_ccp_rmesh_times; + extern rapidjson::Value exx_distribute_type; + extern rapidjson::Value exx_opt_orb_lmax; + extern rapidjson::Value exx_opt_orb_ecut; + extern rapidjson::Value exx_opt_orb_tolerence; + extern rapidjson::Value exx_real_number; + + // @param reading_information -- input_para -- molecular_dynamics + extern rapidjson::Value md_type; + extern rapidjson::Value md_nstep; + extern rapidjson::Value md_dt; + extern rapidjson::Value md_thermostat; + extern rapidjson::Value md_tlast; + extern rapidjson::Value md_tfirst; + extern rapidjson::Value md_restart; + extern rapidjson::Value md_restartfreq; + extern rapidjson::Value md_dumpfreq; + extern rapidjson::Value dump_force; + extern rapidjson::Value dump_vel; + extern rapidjson::Value dump_virial; + extern rapidjson::Value md_seed; + extern rapidjson::Value md_tfreq; + extern rapidjson::Value md_tchain; + extern rapidjson::Value md_pmode; + extern rapidjson::Value md_prec_level; + extern rapidjson::Value ref_cell_factor; + extern rapidjson::Value md_pcouple; + extern rapidjson::Value md_pfirst; + extern rapidjson::Value md_plast; + extern rapidjson::Value md_pfreq; + extern rapidjson::Value md_pchain; + extern rapidjson::Value lj_rcut; + extern rapidjson::Value lj_epsilon; + extern rapidjson::Value lj_sigma; + extern rapidjson::Value pot_file; + extern rapidjson::Value msst_direction; + extern rapidjson::Value msst_vel; + extern rapidjson::Value msst_vis; + extern rapidjson::Value msst_tscale; + extern rapidjson::Value msst_qmass; + extern rapidjson::Value md_damp; + extern rapidjson::Value md_tolerance; + extern rapidjson::Value md_nraise; + extern rapidjson::Value cal_syns; + extern rapidjson::Value dmax; + + // @param reading_information -- input_para -- dft_plus_u + extern rapidjson::Value orbital_corr; + extern rapidjson::Value hubbard_u; + extern rapidjson::Value yukawa_potential; + extern rapidjson::Value yukawa_lambda; + extern rapidjson::Value omc; + + // @param reading_information -- input_para -- vdw_correction + extern rapidjson::Value vdw_method; + extern rapidjson::Value vdw_s6; + extern rapidjson::Value vdw_s8; + extern rapidjson::Value vdw_a1; + extern rapidjson::Value vdw_a2; + extern rapidjson::Value vdw_d; + extern rapidjson::Value vdw_abc; + extern rapidjson::Value vdw_C6_file; + extern rapidjson::Value vdw_C6_unit; + extern rapidjson::Value vdw_R0_file; + extern rapidjson::Value vdw_R0_unit; + extern rapidjson::Value vdw_cutoff_type; + extern rapidjson::Value vdw_cutoff_radius; + extern rapidjson::Value vdw_radius_unit; + extern rapidjson::Value vdw_cutoff_period; + extern rapidjson::Value vdw_cn_thr; + extern rapidjson::Value vdw_cn_thr_unit; + + // @param reading_information -- input_para -- berry_phase_and_wannier90_interface + extern rapidjson::Value berry_phase; + extern rapidjson::Value gdir; + extern rapidjson::Value towannier90; + extern rapidjson::Value nnkpfile; + extern rapidjson::Value wannier_spin; + + // @param reading_information -- input_para -- tddft + extern rapidjson::Value td_edm; + extern rapidjson::Value td_print_eij; + extern rapidjson::Value td_propagator; + extern rapidjson::Value td_vext; + extern rapidjson::Value td_vext_dire; + extern rapidjson::Value td_stype; + extern rapidjson::Value td_ttype; + extern rapidjson::Value td_tstart; + extern rapidjson::Value td_tend; + extern rapidjson::Value td_lcut1; + extern rapidjson::Value td_lcut2; + extern rapidjson::Value td_gauss_freq; + extern rapidjson::Value td_gauss_phase; + extern rapidjson::Value td_gauss_sigma; + extern rapidjson::Value td_gauss_t0; + extern rapidjson::Value td_gauss_amp; + extern rapidjson::Value td_trape_freq; + extern rapidjson::Value td_trape_phase; + extern rapidjson::Value td_trape_t1; + extern rapidjson::Value td_trape_t2; + extern rapidjson::Value td_trape_t3; + extern rapidjson::Value td_trape_amp; + extern rapidjson::Value td_trigo_freq1; + extern rapidjson::Value td_trigo_freq2; + extern rapidjson::Value td_trigo_phase1; + extern rapidjson::Value td_trigo_phase2; + extern rapidjson::Value td_trigo_amp; + extern rapidjson::Value td_heavi_t0; + extern rapidjson::Value td_heavi_amp; + extern rapidjson::Value td_out_dipole; + extern rapidjson::Value td_out_efield; + extern rapidjson::Value ocp; + extern rapidjson::Value ocp_set; + + // @param reading_information -- input_para -- debuging_related + extern rapidjson::Value t_in_h; + extern rapidjson::Value vl_in_h; + extern rapidjson::Value vnl_in_h; + extern rapidjson::Value vh_in_h; + extern rapidjson::Value vion_in_h; + extern rapidjson::Value test_force; + extern rapidjson::Value test_stress; + extern rapidjson::Value colour; + extern rapidjson::Value test_skip_ewald; + + // @param reading_information -- input_para -- electronic_conductivities + extern rapidjson::Value cal_cond; + extern rapidjson::Value cond_nche; + extern rapidjson::Value cond_dw; + extern rapidjson::Value cond_wcut; + extern rapidjson::Value cond_dt; + extern rapidjson::Value cond_dtbatch; + extern rapidjson::Value cond_fwhm; + extern rapidjson::Value cond_nonlocal; + + // @param reading_information -- input_para -- implicit_solvation_model + extern rapidjson::Value imp_sol; + extern rapidjson::Value eb_k; + extern rapidjson::Value tau; + extern rapidjson::Value sigma_k; + extern rapidjson::Value nc_k; + + // @param reading_information -- stru_infos: + extern rapidjson::Value stru_infos; + // extern rapidjson::Value ATOMIC_SPECIES; + // extern rapidjson::Value NUMERICAL_ORBITAL; + // extern rapidjson::Value LATTICE_CONSTANT; + // extern rapidjson::Value ATOMIC_POSITIONS; + + // @param reading_information -- KPT_infos + extern rapidjson::Value KPT_infos; + // extern rapidjson::Value total_number; + // extern rapidjson::Value mode; + // extern rapidjson::Value vectors; + + // @param reading_information -- orb_infos + extern rapidjson::Value orb_infos; + + // @param reading_information -- pp + extern rapidjson::Value pp; + + // @param init + extern rapidjson::Value init; + // @param init -- general + // extern rapidjson::Value calculation; + // extern rapidjson::Value esolver_type; + // extern rapidjson::Value basis_type; + // extern rapidjson::Value gamma_only; + // extern rapidjson::Value ks_solver; + // extern rapidjson::Value ntype; + // extern rapidjson::Value nspin; + // extern rapidjson::Value ecutwfc; + // extern rapidjson::Value scf_thr; + // extern rapidjson::Value scf_nmax; + + // @param init -- symmetry + // extern rapidjson::Value symmetry; + // extern rapidjson::Value BRAVAIS_TYPE; + // extern rapidjson::Value BRAVAIS_LATTICE_NAME; + // extern rapidjson::Value IBRAV; + // extern rapidjson::Value LATTICE_CONSTANT_A; + // extern rapidjson::Value right_hand_lattice; + + // @param init -- Kpoints + extern rapidjson::Value kpoints; + extern rapidjson::Value nkstot; + extern rapidjson::Value nkstot_ibz; + extern rapidjson::Value coordinates; + extern rapidjson::Value weight; + + // @param init -- grid + extern rapidjson::Value grid; + extern rapidjson::Value energy_cutoff_for_wavefunc; + extern rapidjson::Value fft_grid_for_wave_functions; + extern rapidjson::Value number_of_plane_waves; + extern rapidjson::Value number_of_sticks; + + // @param init -- Smearing + // extern rapidjson::Value smearing_method; + // extern rapidjson::Value smearing_sigma; + + // @param init -- mixing + extern rapidjson::Value mixing; + + + // @param output + extern rapidjson::Value output; + + + + // @param final_stru + extern rapidjson::Value final_stru; + extern rapidjson::Value cell; + extern rapidjson::Value coordinate; + + + + + /** + * The functions below initialize the json output parameter + * tree to connect the nodes of the module + */ + + /** + * @brief add Top stage:parameter in Abacus: + */ + void Init_json_abacus(); + + + /** + * @brief add Second stage:parameter in Abacus - general_info: + */ + void Init_json_abacus_generalInfo(); + + + /** + * @brief add Second stage:parameter in Abacus - readin_info: + */ + void Init_json_abacus_readinInfo(); + + + /** + * @brief finish json tree build + */ + void Finish_json_tree(); + + + + /** + * @brief This function is used to populate the template type parameter + * values into rapidjson's Value object + */ + template + void set_json_value(rapidjson::Value &json_v,T *para){ + if(std::is_same::value) + { + json_v.SetInt(*reinterpret_cast(para)); + } + else if(std::is_same::value) + { + json_v.SetDouble(*reinterpret_cast(para)); + } + else if(std::is_same::value) + { + json_v.SetBool(*reinterpret_cast(para)); + } + else if(std::is_same::value) + { + // json_v.SetString(rapidjson::StringRef((*reinterpret_cast(para)).c_str())); + + json_v.SetString((*reinterpret_cast(para)).c_str(), std::strlen((*reinterpret_cast(para)).c_str()), doc.GetAllocator()); + //printf("exx_real_number = %s\n",(*reinterpret_cast(para)).c_str()); + } + } +} + +#endif \ No newline at end of file diff --git a/source/module_base/test/CMakeLists.txt b/source/module_base/test/CMakeLists.txt index 666152b476..185727ef93 100644 --- a/source/module_base/test/CMakeLists.txt +++ b/source/module_base/test/CMakeLists.txt @@ -217,3 +217,10 @@ AddTest( SOURCES assoc_laguerre_test.cpp ../assoc_laguerre.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp ../timer.cpp LIBS ${math_libs} formatter ) + +if(ENABLE_RAPIDJSON) + AddTest( + TARGET base_para_json_test + SOURCES para_json_test.cpp ../para_json.cpp + ) +endif() diff --git a/source/module_base/test/para_json_test.cpp b/source/module_base/test/para_json_test.cpp new file mode 100644 index 0000000000..3ce6ecce49 --- /dev/null +++ b/source/module_base/test/para_json_test.cpp @@ -0,0 +1,68 @@ +#include "module_base/para_json.h" +#include "gtest/gtest.h" +#ifdef __MPI +#include "mpi.h" +#endif + +#include +#include "rapidjson/document.h" +/************************************************ + * unit test of Input::ParaJson + ***********************************************/ + +/** + * - Tested Functions: + * - Init() + * - init json tree from input::Init and check if the json string is valid + */ + +class ParaJsonTest : public ::testing::Test +{ + protected: + std::string testString; +}; + +// check if a string is a valid JSON string +bool isValidJSON(const std::string& jsonString) +{ + rapidjson::Document document; + document.Parse(jsonString.c_str()); + + return !document.HasParseError(); +} + +TEST_F(ParaJsonTest, Init) +{ + //std::string input_file = "./support/INPUT"; + //Input input_tmp; + //EXPECT_NO_THROW(input_tmp.Init(input_file)); + + // int status = system("rm -r ./OUT.autotest/"); + // EXPECT_EQ(status,0); + // Para_Json::Init_json_abacus_readinInfo(); + Para_Json::Init_json_abacus_generalInfo(); + Para_Json::Init_json_abacus(); + Para_Json::Finish_json_tree(); + rapidjson::StringBuffer buffer; + rapidjson::Writer writer(buffer); + Para_Json::doc.Accept(writer); + std::string json = buffer.GetString(); + EXPECT_EQ(isValidJSON(json), true); +} + +int main(int argc, char** argv) +{ +#ifdef __MPI + MPI_Init(&argc, &argv); + MPI_Comm_size(MPI_COMM_WORLD, &GlobalV::NPROC); + MPI_Comm_rank(MPI_COMM_WORLD, &GlobalV::MY_RANK); +#endif + testing::InitGoogleTest(&argc, argv); + int result; + result = RUN_ALL_TESTS(); +#ifdef __MPI + MPI_Finalize(); +#endif + return result; +} + diff --git a/toolchain/README.md b/toolchain/README.md index 3e747006b7..a8ce2f711e 100644 --- a/toolchain/README.md +++ b/toolchain/README.md @@ -91,6 +91,7 @@ The needed dependencies version default: - `LibXC` 6.2.2 - `ELPA` 2023.05.001 - `CEREAL` 1.3.2 +- `RapidJSON` 1.1.0 And Intel-oneAPI need user or server manager to manually install from Intel. [Intel-oneAPI](https://www.intel.cn/content/www/cn/zh/developer/tools/oneapi/toolkits.html) @@ -102,12 +103,12 @@ Dependencies below are optional, which is NOT installed by default: Users can install them by using `--with-*=install` in toolchain*.sh, which is `no` in default. > Notice: LibRI, LibComm and Libnpy is on actively development, you should check-out the package version when using this toolchain. Also, LibRI and LibComm can be installed by github submodule, which is also work for libnpy, which is more recommended. -Notice: for `CEREAL`, `Libnpy`, `LibRI` and `LibComm`, +Notice: for `CEREAL`,`RapidJSON`, `Libnpy`, `LibRI` and `LibComm`, you need to download them from github.com, rename it as formatted, and put them in `build` directory at the same time e.g.: ```shell -# packages downloaded from github.com +# packages downloaded from github.com, RapidJSON is not supported now mv v1.3.2.tar.gz build/cereal-1.3.2.tar.gz ``` @@ -175,7 +176,7 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DCMAKE_CUDA_COMPILER=${path to cuda toolkit}/bin/nvcc \ ...... ``` -Notice: You CANNOT use `icpx` compiler for GPU version of ABACUS +Notice: You CANNOT use `icpx` compiler for GPU version of ABACUS for now ### shell problem If you encounter problem like: @@ -206,6 +207,8 @@ The default compiler for Intel-oneAPI is `icpx` and `icx`, which will cause prob The best way is to change `icpx` to `icpc`, `icx` to `icc`. user can manually change it in toolchain*.sh via `--with-intel-classic=yes` +Notice: `icc` and `icpc` from Intel Classic Compiler of Intel-oneAPI is not supported for 2024.0 and newer version. + ### LibRI and LibComm problem (There is some problem sometimes when compling with LibRI and LibComm, detailed information is needed) @@ -216,6 +219,9 @@ Sometimes Intel-oneAPI have problem to link `mpirun`, which will always show in 2023.2.0 version of MPI in Intel-oneAPI. Try `source /path/to/setvars.sh` or install another version of IntelMPI may help. +which is fixed in 2024.0.0 version of Intel-oneAPI, +And will not occur in Intel-MPI before 2021.10.0 (Intel-oneAPI before 2023.2.0) + More problem and possible solution can be accessed via [#2928](https://github.com/deepmodeling/abacus-develop/issues/2928) @@ -230,9 +236,6 @@ from ABACUS repo, make dependencies package more independent and flexible. 2. Users can manually change `pkg_install_dir` variable in `scripts/stage*/install*` to change the installation directory of each packages, which may let the installation more fiexible. -3. Users can manually change `INSTALL` variable in `scripts/common_vars.sh` -to change the installation directory of all packages, which may let the -installation more fiexible. ## More diff --git a/toolchain/install_abacus_toolchain.sh b/toolchain/install_abacus_toolchain.sh index be41687307..68c7959ce1 100755 --- a/toolchain/install_abacus_toolchain.sh +++ b/toolchain/install_abacus_toolchain.sh @@ -182,10 +182,12 @@ The --with-PKG options follow the rules: --with-scalapack Parallel linear algebra library, needed for parallel calculations. Default = install + --with-elpa Eigenvalue SoLvers for Petaflop-Applications library. + Fast library for large parallel jobs, Especially for ABACUS LCAO + Default = install --with-cereal Enable cereal for ABACUS LCAO Default = install - --with-elpa Eigenvalue SoLvers for Petaflop-Applications library. - Fast library for large parallel jobs. + --with-rapidjson Enable rapidjson for ABACUS to read/write json files Default = install --with-libtorch Enable libtorch the machine learning framework needed for DeePKS Default = no @@ -230,7 +232,7 @@ EOF tool_list="gcc intel cmake" mpi_list="mpich openmpi intelmpi" math_list="mkl acml openblas" -lib_list="fftw libxc scalapack elpa cereal libtorch libnpy libri libcomm" +lib_list="fftw libxc scalapack elpa cereal rapidjson libtorch libnpy libri libcomm" package_list="${tool_list} ${mpi_list} ${math_list} ${lib_list}" # ------------------------------------------------------------------------ @@ -264,7 +266,8 @@ with_acml="__SYSTEM__" with_openblas="__INSTALL__" with_elpa="__INSTALL__" with_cereal="__INSTALL__" -# with_libtorch="__DONTUSE__" +with_rapidjson="__INSTALL__" +# with_libtorch="__DONTUSE__" # default # with_libnpy="__DONTUSE__" # with_libri="__DONTUSE__" # with_libcomm="__DONTUSE__" @@ -549,6 +552,9 @@ while [ $# -ge 1 ]; do --with-cereal*) with_cereal=$(read_with "${1}") ;; + --with-rapidjson*) + with_rapidjson=$(read_with "${1}") + ;; --with-libnpy*) with_libnpy=$(read_with "${1}") ;; diff --git a/toolchain/scripts/common_vars.sh b/toolchain/scripts/common_vars.sh index d04d40fa39..51f941f6fe 100755 --- a/toolchain/scripts/common_vars.sh +++ b/toolchain/scripts/common_vars.sh @@ -7,8 +7,7 @@ # directories and files used by the installer ROOTDIR=${ROOTDIR:-"$(pwd -P)"} SCRIPTDIR=${SCRIPTDIR:-"${ROOTDIR}/scripts"} -INSTALLDIR=${INSTALLDIR:-"${ROOTDIR}/install"} -#INSTALLDIR=${INSTALLDIR:-"${HOME}/abacus_deps"} # advanced installation +INSTALLDIR=${INSTALLDIR:-"${ROOTDIR}/install"} # should not be changed BUILDDIR=${BUILDDIR:-"${ROOTDIR}/build"} SETUPFILE=${SETUPFILE:-"${INSTALLDIR}/setup"} ARCH_FILE_TEMPLATE=${ARCH_FILE_TEMPLATE:-"${SCRIPTDIR}/arch_base.tmpl"} diff --git a/toolchain/scripts/stage4/install_rapidjson.sh b/toolchain/scripts/stage4/install_rapidjson.sh new file mode 100755 index 0000000000..b63789ffff --- /dev/null +++ b/toolchain/scripts/stage4/install_rapidjson.sh @@ -0,0 +1,93 @@ +#!/bin/bash -e + +# TODO: Review and if possible fix shellcheck errors. +# shellcheck disable=all +# RAPIDJSON is not need any complex setting +# Only problem is the installation from github.com + +[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0 +SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)" + +rapidjson_ver="1.1.0" +rapidjson_sha256="bf7ced29704a1e696fbccf2a2b4ea068e7774fa37f6d7dd4039d0787f8bed98e" +source "${SCRIPT_DIR}"/common_vars.sh +source "${SCRIPT_DIR}"/tool_kit.sh +source "${SCRIPT_DIR}"/signal_trap.sh +source "${INSTALLDIR}"/toolchain.conf +source "${INSTALLDIR}"/toolchain.env + +[ -f "${BUILDDIR}/setup_rapidjson" ] && rm "${BUILDDIR}/setup_rapidjson" + +RAPIDJSON_CFLAGS="" +! [ -d "${BUILDDIR}" ] && mkdir -p "${BUILDDIR}" +cd "${BUILDDIR}" + +case "$with_rapidjson" in + __INSTALL__) + echo "==================== Installing RAPIDJSON ====================" + dirname="rapidjson-${rapidjson_ver}" + pkg_install_dir="${INSTALLDIR}/$dirname" + #pkg_install_dir="${HOME}/lib/rapidjson/${rapidjson_ver}" + install_lock_file="$pkg_install_dir/install_successful" + url="https://github.com/Tencent/rapidjson/archive/refs/tags/v${rapidjson_ver}.tar.gz" + filename="rapidjson-${rapidjson_ver}.tar.gz" + if verify_checksums "${install_lock_file}"; then + echo "$dirname is already installed, skipping it." + else + if [ -f $filename ]; then + echo "$filename is found" + else + # download from github.com and checksum + echo "wget --quiet $url -O $filename" + if ! wget --quiet $url -O $filename; then + report_error "failed to download $url" + recommend_offline_installation $filename $url + fi + # checksum + checksum "$filename" "$rapidjson_sha256" + fi + echo "Installing from scratch into ${pkg_install_dir}" + [ -d $dirname ] && rm -rf $dirname + tar -xzf $filename + mkdir -p "${pkg_install_dir}" + cp -r $dirname/* "${pkg_install_dir}/" + write_checksums "${install_lock_file}" "${SCRIPT_DIR}/stage4/$(basename ${SCRIPT_NAME})" + fi + ;; + __SYSTEM__) + echo "==================== CANNOT Finding RAPIDJSON from system paths NOW ====================" + recommend_offline_installation $filename $url + # How to do it in rapidjson? -- Zhaoqing in 2023/08/23 + # check_lib -lxcf03 "libxc" + # check_lib -lxc "libxc" + # add_include_from_paths LIBXC_CFLAGS "xc.h" $INCLUDE_PATHS + # add_lib_from_paths LIBXC_LDFLAGS "libxc.*" $LIB_PATHS + ;; + __DONTUSE__) ;; + + *) + echo "==================== Linking RAPIDJSON to user paths ====================" + check_dir "${pkg_install_dir}" + RAPIDJSON_CFLAGS="-I'${pkg_install_dir}'" + ;; +esac +if [ "$with_rapidjson" != "__DONTUSE__" ]; then + if [ "$with_rapidjson" != "__SYSTEM__" ]; then + # LibRI deps should find rapidjson include in CPATH + cat << EOF > "${BUILDDIR}/setup_rapidjson" +prepend_path CPATH "$pkg_install_dir/include" +export CPATH="${pkg_install_dir}/include:"${CPATH} +EOF + cat "${BUILDDIR}/setup_rapidjson" >> $SETUPFILE + fi + cat << EOF >> "${BUILDDIR}/setup_rapidjson" +export RAPIDJSON_CFLAGS="${RAPIDJSON_CFLAGS}" +export RAPIDJSON_ROOT="$pkg_install_dir" +EOF +fi + +load "${BUILDDIR}/setup_rapidjson" +write_toolchain_env "${INSTALLDIR}" + +cd "${ROOTDIR}" +report_timing "rapidjson" diff --git a/toolchain/scripts/stage4/install_stage4.sh b/toolchain/scripts/stage4/install_stage4.sh index ffe8f670c9..b5c7cf5eed 100755 --- a/toolchain/scripts/stage4/install_stage4.sh +++ b/toolchain/scripts/stage4/install_stage4.sh @@ -4,6 +4,7 @@ # shellcheck disable=all ./scripts/stage4/install_cereal.sh +./scripts/stage4/install_rapidjson.sh ./scripts/stage4/install_libtorch.sh ./scripts/stage4/install_libnpy.sh ./scripts/stage4/install_libri.sh diff --git a/toolchain/scripts/tool_kit.sh b/toolchain/scripts/tool_kit.sh index d07445089b..120b623fee 100755 --- a/toolchain/scripts/tool_kit.sh +++ b/toolchain/scripts/tool_kit.sh @@ -54,9 +54,12 @@ By download $__filename from $__url, Rename it as $__filename and put it into ${BUILDDIR}, And re-run toolchain installation script. -Instead of github.com. you can manually install requirements packages via: -1. Download from www.cp2k.org/static/downloads -2. wget https://bohrium-api.dp.tech/ds-dl/abacus-deps-93wi-v1 -O abacus-deps-v1.zip +You can manually install requirements packages via: +1. Download from www.cp2k.org/static/downloads (for OpenBLAS, OpenMPI and Others) +2. Download from github.com (for CEREAL, RapidJSON, libnpy, LibRI and others stage4 packages) +3. Use git submodule update --init --recursive (for LibRI) +4. wget https://bohrium-api.dp.tech/ds-dl/abacus-deps-93wi-v2 -O abacus-deps.zip +5. for Intel-oneAPI, please contact your server manager our visit Intel official website EOF } diff --git a/toolchain/toolchain_gnu.sh b/toolchain/toolchain_gnu.sh index 57105f601b..04635bb63d 100755 --- a/toolchain/toolchain_gnu.sh +++ b/toolchain/toolchain_gnu.sh @@ -18,6 +18,7 @@ --with-fftw=install \ --with-elpa=install \ --with-cereal=install \ +--with-rapidjson=install \ --with-libtorch=no \ --with-libnpy=no \ --with-libri=no \ diff --git a/toolchain/toolchain_intel-mpich.sh b/toolchain/toolchain_intel-mpich.sh index ffc2626670..fcf3cc41ee 100755 --- a/toolchain/toolchain_intel-mpich.sh +++ b/toolchain/toolchain_intel-mpich.sh @@ -21,6 +21,7 @@ --with-fftw=no \ --with-elpa=install \ --with-cereal=install \ +--with-rapidjson=install \ --with-libtorch=no \ --with-libnpy=no \ --with-libri=no \ diff --git a/toolchain/toolchain_intel.sh b/toolchain/toolchain_intel.sh index 8f391be008..e5298c570d 100755 --- a/toolchain/toolchain_intel.sh +++ b/toolchain/toolchain_intel.sh @@ -22,6 +22,7 @@ --with-fftw=no \ --with-elpa=install \ --with-cereal=install \ +--with-rapidjson=install \ --with-libtorch=no \ --with-libnpy=no \ --with-libri=no \