diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 65f842b3c0..f2f67d2177 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -147,12 +147,12 @@ OBJS_BASE=abfs-vector3_order.o\ cubic_spline.o\ spherical_bessel_transformer.o\ mixing_data.o\ + para_json.o\ mixing.o\ plain_mixing.o\ pulay_mixing.o\ broyden_mixing.o\ - OBJS_CELL=atom_pseudo.o\ atom_spec.o\ pseudo.o\ diff --git a/source/module_base/CMakeLists.txt b/source/module_base/CMakeLists.txt index b6d362d5ec..4ec79b2d47 100644 --- a/source/module_base/CMakeLists.txt +++ b/source/module_base/CMakeLists.txt @@ -54,6 +54,7 @@ add_library( formatter_table.cpp formatter_contextfmt.cpp module_mixing/mixing_data.cpp + para_json.cpp module_mixing/mixing.cpp module_mixing/plain_mixing.cpp module_mixing/pulay_mixing.cpp diff --git a/source/module_base/para_json.cpp b/source/module_base/para_json.cpp new file mode 100644 index 0000000000..8fcbb85a32 --- /dev/null +++ b/source/module_base/para_json.cpp @@ -0,0 +1,974 @@ + +#include "para_json.h" +#include "module_base/global_variable.h" + + +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(); + } + + + + +} \ 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..b8a9be5b69 --- /dev/null +++ b/source/module_base/para_json.h @@ -0,0 +1,557 @@ + +#include +#include +#include +#include +#include + +#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()); + } + } +} + diff --git a/source/module_base/parallel_global.cpp b/source/module_base/parallel_global.cpp index 3361d4b7f1..7e437221c4 100644 --- a/source/module_base/parallel_global.cpp +++ b/source/module_base/parallel_global.cpp @@ -17,6 +17,7 @@ #include "module_base/global_function.h" #include "module_base/parallel_common.h" #include "module_base/parallel_reduce.h" +#include "module_base/para_json.h" #include "version.h" #if defined __MPI @@ -95,6 +96,11 @@ void Parallel_Global::split_diag_world(const int &diag_np) GlobalV::DRANK=0; GlobalV::DSIZE=1; #endif + + Para_Json::set_json_value(Para_Json::drank,&GlobalV::DRANK); + Para_Json::set_json_value(Para_Json::dsize,&GlobalV::DSIZE); + Para_Json::set_json_value(Para_Json::dcolor,&GlobalV::DCOLOR); + return; } diff --git a/source/module_base/test/CMakeLists.txt b/source/module_base/test/CMakeLists.txt index 9295972e79..37550d1c79 100644 --- a/source/module_base/test/CMakeLists.txt +++ b/source/module_base/test/CMakeLists.txt @@ -82,7 +82,7 @@ AddTest( TARGET base_ylmreal LIBS ${math_libs} device formatter SOURCES math_ylmreal_test.cpp ../math_ylmreal.cpp ../complexmatrix.cpp ../global_variable.cpp ../ylm.cpp ../realarray.cpp ../timer.cpp ../matrix.cpp ../vector3.h - ../parallel_reduce.cpp ../parallel_global.cpp ../parallel_common.cpp + ../parallel_reduce.cpp ../para_json.cpp ../parallel_global.cpp ../parallel_common.cpp ../memory.cpp ../libm/branred.cpp ../libm/sincos.cpp ) AddTest( @@ -207,7 +207,8 @@ AddTest( AddTest( TARGET clebsch_gordan_coeff_test SOURCES clebsch_gordan_coeff_test.cpp ../clebsch_gordan_coeff.cpp ../intarray.cpp ../realarray.cpp ../complexmatrix.cpp ../matrix.cpp ../timer.cpp - ../math_ylmreal.cpp ../global_variable.cpp ../ylm.cpp ../timer.cpp ../vector3.h ../parallel_reduce.cpp ../parallel_global.cpp ../parallel_common.cpp + ../math_ylmreal.cpp ../global_variable.cpp ../ylm.cpp ../timer.cpp ../vector3.h ../parallel_reduce.cpp ../para_json.cpp ../parallel_global.cpp ../parallel_common.cpp ../memory.cpp ../libm/branred.cpp ../libm/sincos.cpp ../inverse_matrix.cpp ../lapack_connector.h LIBS ${math_libs} formatter device -) \ No newline at end of file +) + diff --git a/source/module_base/test_parallel/CMakeLists.txt b/source/module_base/test_parallel/CMakeLists.txt index 3ef9779fa6..328bfd8d88 100644 --- a/source/module_base/test_parallel/CMakeLists.txt +++ b/source/module_base/test_parallel/CMakeLists.txt @@ -7,13 +7,13 @@ AddTest( AddTest( TARGET base_ParaGlobal LIBS MPI::MPI_CXX - SOURCES parallel_global_test.cpp ../global_variable.cpp ../parallel_global.cpp + SOURCES parallel_global_test.cpp ../global_variable.cpp ../para_json.cpp ../parallel_global.cpp ) AddTest( TARGET base_ParaReduce LIBS MPI::MPI_CXX - SOURCES parallel_reduce_test.cpp ../global_variable.cpp ../parallel_global.cpp ../parallel_common.cpp ../parallel_reduce.cpp + SOURCES parallel_reduce_test.cpp ../global_variable.cpp ../para_json.cpp ../parallel_global.cpp ../parallel_common.cpp ../parallel_reduce.cpp ) install(FILES parallel_common_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/source/module_basis/module_ao/test/CMakeLists.txt b/source/module_basis/module_ao/test/CMakeLists.txt index 86bed2bd7c..02fe6bed89 100644 --- a/source/module_basis/module_ao/test/CMakeLists.txt +++ b/source/module_basis/module_ao/test/CMakeLists.txt @@ -45,7 +45,7 @@ AddTest( TARGET orbital_equal_test LIBS ${math_libs} device numerical_atomic_orbitals container formatter SOURCES 1_snap_equal_test.cpp ORB_unittest.cpp - ../../../module_base/parallel_reduce.cpp ../../../module_base/parallel_global.cpp ../../../module_base/parallel_common.cpp + ../../../module_base/parallel_reduce.cpp ../../../module_base/para_json.cpp ../../../module_base/parallel_global.cpp ../../../module_base/parallel_common.cpp ${depend_files} ) install(DIRECTORY GaAs DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../../../tests) diff --git a/source/module_basis/module_pw/kernels/test/CMakeLists.txt b/source/module_basis/module_pw/kernels/test/CMakeLists.txt index ab9869eafa..8f5d9fb09b 100644 --- a/source/module_basis/module_pw/kernels/test/CMakeLists.txt +++ b/source/module_basis/module_pw/kernels/test/CMakeLists.txt @@ -5,6 +5,7 @@ AddTest( LIBS ${math_libs} psi device SOURCES pw_op_test.cpp ../../../../module_base/tool_quit.cpp ../../../../module_base/global_variable.cpp + ../../../../module_base/para_json.cpp ../../../../module_base/parallel_global.cpp ../../../../module_base/parallel_reduce.cpp ../../../../module_base/complexmatrix.cpp ../../../../module_base/matrix.cpp ../../../../module_base/memory.cpp ../../../../module_base/libm/branred.cpp ../../../../module_base/libm/sincos.cpp diff --git a/source/module_cell/test/CMakeLists.txt b/source/module_cell/test/CMakeLists.txt index 2b1d75ffae..01db09f684 100644 --- a/source/module_cell/test/CMakeLists.txt +++ b/source/module_cell/test/CMakeLists.txt @@ -76,7 +76,7 @@ add_test(NAME cell_klist_test_para4 AddTest( TARGET cell_ParaKpoints LIBS MPI::MPI_CXX - SOURCES parallel_kpoints_test.cpp ../../module_base/global_variable.cpp ../../module_base/parallel_global.cpp + SOURCES parallel_kpoints_test.cpp ../../module_base/global_variable.cpp ../../module_base/para_json.cpp ../../module_base/parallel_global.cpp ../../module_base/parallel_common.cpp ../parallel_kpoints.cpp ) diff --git a/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt b/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt index 3adf260d44..9ad923c170 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt +++ b/source/module_hamilt_pw/hamilt_pwdft/test/CMakeLists.txt @@ -15,6 +15,7 @@ AddTest( ../../../module_base/global_file.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp + ../../../module_base/para_json.cpp ../../../module_base/parallel_global.cpp ../../../module_base/parallel_common.cpp ../../../module_base/parallel_reduce.cpp diff --git a/source/module_io/input.cpp b/source/module_io/input.cpp index b1d01e8815..3ab3678a36 100644 --- a/source/module_io/input.cpp +++ b/source/module_io/input.cpp @@ -22,6 +22,8 @@ #include "module_base/global_variable.h" #include "module_base/parallel_common.h" #include "module_base/timer.h" +#include "module_base/para_json.h" + #include "version.h" Input INPUT; @@ -127,6 +129,24 @@ void Input::Init(const std::string &fn) // pseudo_type); // mohan add 2013-05-20 (xiaohui add 2013-06-23, GlobalV::global_pseudo_type -> pseudo_type) ModuleBase::timer::tick("Input", "Init"); + + std::string begin_time = ctime(&time_now); + if (!begin_time.empty() && begin_time.back() == '\n') { + begin_time.erase(begin_time.length() - 1); + } + std::string version_json = version; + std::string commit_json = commit; + std::string device_json = device; + printf("version = %s\n",device_json.c_str()); + Para_Json::set_json_value(Para_Json::version,&version_json); + Para_Json::set_json_value(Para_Json::commit,&commit_json); + Para_Json::set_json_value(Para_Json::device_g,&device_json); + Para_Json::set_json_value(Para_Json::begin_time,&begin_time); + + Para_Json::set_json_value(Para_Json::global_out_dir,&GlobalV::global_out_dir); + Para_Json::set_json_value(Para_Json::global_in_card,&GlobalV::global_in_card); + Para_Json::set_json_value(Para_Json::pseudo_dir_path,&GlobalV::global_pseudo_dir); + Para_Json::set_json_value(Para_Json::orbital_dir_path,&GlobalV::global_orbital_dir); return; } @@ -619,6 +639,12 @@ void Input::Default(void) return; } + + +/** +* guhongyaoxing modify 2023-11-16 +* Added code to convert the data read from the input file into a json object +*/ bool Input::Read(const std::string &fn) { ModuleBase::TITLE("Input", "Read"); @@ -675,14 +701,18 @@ bool Input::Read(const std::string &fn) if (strcmp("suffix", word) == 0) // out dir { read_value(ifs, suffix); + Para_Json::set_json_value(Para_Json::input_suffix,&suffix); + //Para_Json::set_json_value(Para_Json::suffix,&suffix); } else if (strcmp("stru_file", word) == 0) // xiaohui modify 2015-02-01 { read_value(ifs, stru_file); // xiaohui modify 2015-02-01 + Para_Json::set_json_value(Para_Json::stru_file,&stru_file); } else if (strcmp("pseudo_dir", word) == 0) { read_value(ifs, pseudo_dir); + Para_Json::set_json_value(Para_Json::pseudo_dir,&pseudo_dir); } // else if (strcmp("pseudo_type", word) == 0) // mohan add 2013-05-20 (xiaohui add 2013-06-23) // { @@ -691,63 +721,82 @@ bool Input::Read(const std::string &fn) else if (strcmp("orbital_dir", word) == 0) // liuyu add 2021-08-14 { read_value(ifs, orbital_dir); + Para_Json::set_json_value(Para_Json::orbital_dir,&orbital_dir); } else if (strcmp("kpoint_file", word) == 0) // xiaohui modify 2015-02-01 { read_value(ifs, kpoint_file); // xiaohui modify 2015-02-01 + Para_Json::set_json_value(Para_Json::kpoint_file,&kpoint_file); } else if (strcmp("wannier_card", word) == 0) // mohan add 2009-12-25 { read_value(ifs, wannier_card); + Para_Json::set_json_value(Para_Json::kpoint_file,&kpoint_file); } else if (strcmp("latname", word) == 0) // which material { read_value(ifs, latname); + Para_Json::set_json_value(Para_Json::latname,&latname); } else if (strcmp("pseudo_rcut", word) == 0) // { read_value(ifs, pseudo_rcut); + + Para_Json::set_json_value(Para_Json::pseudo_rcut,&pseudo_rcut); } else if (strcmp("pseudo_mesh", word) == 0) // { read_bool(ifs, pseudo_mesh); + Para_Json::set_json_value(Para_Json::pseudo_mesh,&pseudo_mesh); } else if (strcmp("calculation", word) == 0) // which type calculation { read_value(ifs, calculation); + Para_Json::set_json_value(Para_Json::calculation,&calculation); } else if (strcmp("esolver_type", word) == 0) { read_value(ifs, esolver_type); + Para_Json::set_json_value(Para_Json::esolver_type,&esolver_type); } else if (strcmp("ntype", word) == 0) // number of atom types { read_value(ifs, ntype); + Para_Json::set_json_value(Para_Json::ntype,&ntype); } else if (strcmp("nbands", word) == 0) // number of atom bands { read_value(ifs, nbands); + Para_Json::set_json_value(Para_Json::nbands,&nbands); } else if (strcmp("nbands_sto", word) == 0) // number of stochastic bands { std::string nbsto_str; read_value(ifs, nbndsto_str); + + if (nbndsto_str != "all") { nbands_sto = std::stoi(nbndsto_str); } + Para_Json::set_json_value(Para_Json::nbands_sto,&nbands_sto); } else if (strcmp("kspacing", word) == 0) { read_kspacing(ifs); + for(int i=0;i<3;i++){ + Para_Json::kspacing.PushBack(kspacing[i],Para_Json::doc.GetAllocator()); + } } else if (strcmp("min_dist_coef", word) == 0) { read_value(ifs, min_dist_coef); + Para_Json::set_json_value(Para_Json::min_dist_coef,&min_dist_coef); } else if (strcmp("nbands_istate", word) == 0) // number of atom bands { read_value(ifs, nbands_istate); + Para_Json::set_json_value(Para_Json::nbands_istate,&nbands_istate); // Originally disabled in line 2401. // if (nbands_istate < 0) // ModuleBase::WARNING_QUIT("Input", "NBANDS_ISTATE must > 0"); @@ -755,10 +804,12 @@ bool Input::Read(const std::string &fn) else if (strcmp("nche_sto", word) == 0) // Chebyshev expansion order { read_value(ifs, nche_sto); + Para_Json::set_json_value(Para_Json::nche_sto,&nche_sto); } else if (strcmp("seed_sto", word) == 0) { read_value(ifs, seed_sto); + Para_Json::set_json_value(Para_Json::seed_sto,&seed_sto); } else if (strcmp("initsto_ecut", word) == 0) { @@ -767,88 +818,109 @@ bool Input::Read(const std::string &fn) else if (strcmp("pw_seed", word) == 0) { read_value(ifs, pw_seed); + Para_Json::set_json_value(Para_Json::pw_seed,&pw_seed); } else if (strcmp("emax_sto", word) == 0) { read_value(ifs, emax_sto); + Para_Json::set_json_value(Para_Json::emax_sto,&emax_sto); } else if (strcmp("emin_sto", word) == 0) { read_value(ifs, emin_sto); + Para_Json::set_json_value(Para_Json::emin_sto,&emin_sto); } else if (strcmp("initsto_freq", word) == 0) { read_value(ifs, initsto_freq); + Para_Json::set_json_value(Para_Json::initsto_freq,&initsto_freq); } else if (strcmp("method_sto", word) == 0) { read_value(ifs, method_sto); + Para_Json::set_json_value(Para_Json::method_sto,&method_sto); } else if (strcmp("npart_sto", word) == 0) { read_value(ifs, npart_sto); + Para_Json::set_json_value(Para_Json::npart_sto,&npart_sto); } else if (strcmp("cal_cond", word) == 0) { read_bool(ifs, cal_cond); + Para_Json::set_json_value(Para_Json::cal_cond,&cal_cond); } else if (strcmp("cond_che_thr", word) == 0) { read_value(ifs, cond_che_thr); + Para_Json::set_json_value(Para_Json::cond_nche,&cond_che_thr); } else if (strcmp("cond_dw", word) == 0) { read_value(ifs, cond_dw); + Para_Json::set_json_value(Para_Json::cond_dw,&cond_dw); } else if (strcmp("cond_wcut", word) == 0) { read_value(ifs, cond_wcut); + Para_Json::set_json_value(Para_Json::cond_wcut,&cond_wcut); } else if (strcmp("cond_dt", word) == 0) { read_value(ifs, cond_dt); + Para_Json::set_json_value(Para_Json::cond_dt,&cond_dt); } else if (strcmp("cond_dtbatch", word) == 0) { read_value(ifs, cond_dtbatch); + Para_Json::set_json_value(Para_Json::cond_dtbatch,&cond_dtbatch); } else if (strcmp("cond_fwhm", word) == 0) { read_value(ifs, cond_fwhm); + Para_Json::set_json_value(Para_Json::cond_fwhm,&cond_fwhm); } else if (strcmp("cond_nonlocal", word) == 0) { read_bool(ifs, cond_nonlocal); + Para_Json::set_json_value(Para_Json::cond_nonlocal,&cond_nonlocal); } else if (strcmp("bndpar", word) == 0) { read_value(ifs, bndpar); + Para_Json::set_json_value(Para_Json::bndpar,&bndpar); } else if (strcmp("kpar", word) == 0) // number of pools { read_value(ifs, kpar); + Para_Json::set_json_value(Para_Json::kpar,&kpar); } else if (strcmp("berry_phase", word) == 0) // berry phase calculation { read_bool(ifs, berry_phase); + Para_Json::set_json_value(Para_Json::berry_phase,&berry_phase); } else if (strcmp("gdir", word) == 0) // berry phase calculation { read_value(ifs, gdir); + Para_Json::set_json_value(Para_Json::gdir,&gdir); } else if (strcmp("towannier90", word) == 0) // add by jingan for wannier90 { read_bool(ifs, towannier90); + Para_Json::set_json_value(Para_Json::towannier90,&towannier90); } else if (strcmp("nnkpfile", word) == 0) // add by jingan for wannier90 { read_value(ifs, nnkpfile); + Para_Json::set_json_value(Para_Json::nnkpfile,&nnkpfile); } else if (strcmp("wannier_spin", word) == 0) // add by jingan for wannier90 { read_value(ifs, wannier_spin); + Para_Json::set_json_value(Para_Json::wannier_spin,&wannier_spin); } - else if (strcmp("out_wannier_mmn", word) == 0) // add by renxi for wannier90 + else if (strcmp("out_wannier_mmn", word) == 0) // add by renxi for wannier90 { read_bool(ifs, out_wannier_mmn); } @@ -874,26 +946,32 @@ bool Input::Read(const std::string &fn) else if (strcmp("dft_functional", word) == 0) { read_value(ifs, dft_functional); + Para_Json::set_json_value(Para_Json::dft_functional,&dft_functional); } else if (strcmp("xc_temperature", word) == 0) { read_value(ifs, xc_temperature); + Para_Json::set_json_value(Para_Json::xc_temperature,&xc_temperature); } else if (strcmp("nspin", word) == 0) { read_value(ifs, nspin); + Para_Json::set_json_value(Para_Json::nspin,&nspin); } else if (strcmp("nelec", word) == 0) { read_value(ifs, nelec); + Para_Json::set_json_value(Para_Json::nelec,&nelec); } else if (strcmp("nupdown", word) == 0) { read_value(ifs, nupdown); + Para_Json::set_json_value(Para_Json::nupdown,&nupdown); } else if (strcmp("lmaxmax", word) == 0) { read_value(ifs, lmaxmax); + Para_Json::set_json_value(Para_Json::lmaxmax,&lmaxmax); } //---------------------------------------------------------- // new function @@ -901,34 +979,42 @@ bool Input::Read(const std::string &fn) else if (strcmp("basis_type", word) == 0) { read_value(ifs, basis_type); + Para_Json::set_json_value(Para_Json::basis_type,&basis_type); } // xiaohui add 2013-09-01 else if (strcmp("ks_solver", word) == 0) { read_value(ifs, ks_solver); + Para_Json::set_json_value(Para_Json::ks_solver,&ks_solver); } // xiaohui add 2013-09-01 else if (strcmp("search_radius", word) == 0) { read_value(ifs, search_radius); + Para_Json::set_json_value(Para_Json::search_radius,&search_radius); } else if (strcmp("search_pbc", word) == 0) { read_bool(ifs, search_pbc); + Para_Json::set_json_value(Para_Json::search_pbc,&search_pbc); } else if (strcmp("symmetry", word) == 0) { read_value(ifs, symmetry); + Para_Json::set_json_value(Para_Json::symmetry,&symmetry); } else if (strcmp("init_vel", word) == 0) { read_bool(ifs, init_vel); + Para_Json::set_json_value(Para_Json::init_vel,&init_vel); } else if (strcmp("ref_cell_factor", word) == 0) { read_value(ifs, ref_cell_factor); + Para_Json::set_json_value(Para_Json::ref_cell_factor,&ref_cell_factor); } else if (strcmp("symmetry_prec", word) == 0) // LiuXh add 2021-08-12, accuracy for symmetry { read_value(ifs, symmetry_prec); + Para_Json::set_json_value(Para_Json::symmetry_precfield,&symmetry_prec); } else if (strcmp("symmetry_autoclose", word) == 0) { @@ -937,92 +1023,114 @@ bool Input::Read(const std::string &fn) else if (strcmp("cal_force", word) == 0) { read_bool(ifs, cal_force); + Para_Json::set_json_value(Para_Json::cal_force,&cal_force); } else if (strcmp("force_thr", word) == 0) { read_value(ifs, force_thr); + Para_Json::set_json_value(Para_Json::force_thr,&force_thr); } else if (strcmp("force_thr_ev", word) == 0) { read_value(ifs, force_thr); + Para_Json::set_json_value(Para_Json::force_thr_ev,&force_thr); force_thr = force_thr / 13.6058 * 0.529177; } else if (strcmp("force_thr_ev2", word) == 0) { read_value(ifs, force_thr_ev2); + Para_Json::set_json_value(Para_Json::force_thr_ev2,&force_thr_ev2); } else if (strcmp("stress_thr", word) == 0) { read_value(ifs, stress_thr); + Para_Json::set_json_value(Para_Json::stress_thr,&stress_thr); } else if (strcmp("press1", word) == 0) { read_value(ifs, press1); + Para_Json::set_json_value(Para_Json::press1,&press1); } else if (strcmp("press2", word) == 0) { read_value(ifs, press2); + Para_Json::set_json_value(Para_Json::press2,&press2); } else if (strcmp("press3", word) == 0) { read_value(ifs, press3); + Para_Json::set_json_value(Para_Json::press3,&press3); } else if (strcmp("cal_stress", word) == 0) { read_bool(ifs, cal_stress); + Para_Json::set_json_value(Para_Json::cal_stress,&cal_stress); } else if (strcmp("fixed_axes", word) == 0) { read_value(ifs, fixed_axes); + Para_Json::set_json_value(Para_Json::fixed_axes,&fixed_axes); } else if (strcmp("fixed_ibrav", word) == 0) { read_bool(ifs, fixed_ibrav); + Para_Json::set_json_value(Para_Json::fixed_ibrav,&fixed_ibrav); } else if (strcmp("fixed_atoms", word) == 0) { read_bool(ifs, fixed_atoms); + Para_Json::set_json_value(Para_Json::fixed_atoms,&fixed_atoms); } else if (strcmp("relax_method", word) == 0) { read_value(ifs, relax_method); + Para_Json::set_json_value(Para_Json::relax_method,&relax_method); } else if (strcmp("relax_cg_thr", word) == 0) // pengfei add 2013-08-15 { read_value(ifs, relax_cg_thr); + Para_Json::set_json_value(Para_Json::relax_cg_thr,&relax_cg_thr); } else if (strcmp("out_level", word) == 0) { read_value(ifs, out_level); out_md_control = true; + Para_Json::set_json_value(Para_Json::out_level,&out_level); } else if (strcmp("relax_bfgs_w1", word) == 0) { read_value(ifs, relax_bfgs_w1); + Para_Json::set_json_value(Para_Json::relax_bfgs_w1,&relax_bfgs_w1); } else if (strcmp("relax_bfgs_w2", word) == 0) { read_value(ifs, relax_bfgs_w2); + Para_Json::set_json_value(Para_Json::relax_bfgs_w2,&relax_bfgs_w2); } else if (strcmp("relax_bfgs_rmax", word) == 0) { read_value(ifs, relax_bfgs_rmax); + Para_Json::set_json_value(Para_Json::relax_bfgs_rmax,&relax_bfgs_rmax); } else if (strcmp("relax_bfgs_rmin", word) == 0) { read_value(ifs, relax_bfgs_rmin); + Para_Json::set_json_value(Para_Json::relax_bfgs_rmin,&relax_bfgs_rmin); } else if (strcmp("relax_bfgs_init", word) == 0) { read_value(ifs, relax_bfgs_init); + Para_Json::set_json_value(Para_Json::relax_bfgs_init,&relax_bfgs_init); } else if (strcmp("relax_scale_force", word) == 0) { read_value(ifs, relax_scale_force); + Para_Json::set_json_value(Para_Json::relax_scale_force,&relax_scale_force); } else if (strcmp("relax_new", word) == 0) { read_bool(ifs, relax_new); + Para_Json::set_json_value(Para_Json::relax_new,&relax_new); } else if (strcmp("use_paw", word) == 0) { @@ -1034,6 +1142,8 @@ bool Input::Read(const std::string &fn) else if (strcmp("gamma_only", word) == 0) { read_bool(ifs, gamma_only); + + Para_Json::set_json_value(Para_Json::gamma_only,&gamma_only); } else if (strcmp("fft_mode", word) == 0) { @@ -1042,6 +1152,7 @@ bool Input::Read(const std::string &fn) else if (strcmp("ecutwfc", word) == 0) { read_value(ifs, ecutwfc); + Para_Json::set_json_value(Para_Json::ecutwfc,&ecutwfc); } else if (strcmp("ecutrho", word) == 0) { @@ -1050,29 +1161,36 @@ bool Input::Read(const std::string &fn) else if (strcmp("nx", word) == 0) { read_value(ifs, nx); + Para_Json::set_json_value(Para_Json::nx,&nx); + ncx = nx; } else if (strcmp("ny", word) == 0) { read_value(ifs, ny); + Para_Json::set_json_value(Para_Json::ny,&ny); ncy = ny; } else if (strcmp("nz", word) == 0) { read_value(ifs, nz); + Para_Json::set_json_value(Para_Json::nz,&nz); ncz = nz; } else if (strcmp("bx", word) == 0) { read_value(ifs, bx); + Para_Json::set_json_value(Para_Json::bx,&bx); } else if (strcmp("by", word) == 0) { read_value(ifs, by); + Para_Json::set_json_value(Para_Json::by,&by); } else if (strcmp("bz", word) == 0) { read_value(ifs, bz); + Para_Json::set_json_value(Para_Json::bz,&bz); } else if (strcmp("ndx", word) == 0) { @@ -1108,66 +1226,82 @@ bool Input::Read(const std::string &fn) else if (strcmp("diago_proc", word) == 0) { read_value(ifs, diago_proc); + Para_Json::set_json_value(Para_Json::diago_proc,&diago_proc); } else if (strcmp("pw_diag_nmax", word) == 0) { read_value(ifs, pw_diag_nmax); + Para_Json::set_json_value(Para_Json::pw_diag_nmax,&pw_diag_nmax); } else if (strcmp("diago_cg_prec", word) == 0) // mohan add 2012-03-31 { read_value(ifs, diago_cg_prec); + //Para_Json::set_json_value(Para_Json::diago_cg_prec,&diago_cg_prec); } else if (strcmp("pw_diag_ndim", word) == 0) { read_value(ifs, pw_diag_ndim); + Para_Json::set_json_value(Para_Json::pw_diag_ndim,&pw_diag_ndim); } else if (strcmp("pw_diag_thr", word) == 0) { read_value(ifs, pw_diag_thr); + Para_Json::set_json_value(Para_Json::pw_diag_thr,&pw_diag_thr); } else if (strcmp("nb2d", word) == 0) { read_value(ifs, nb2d); + Para_Json::set_json_value(Para_Json::nb2d,&nb2d); } else if (strcmp("nurse", word) == 0) { read_value(ifs, nurse); + //Para_Json::set_json_value(Para_Json::nurse,&nurse); } else if (strcmp("colour", word) == 0) { read_bool(ifs, colour); + Para_Json::set_json_value(Para_Json::colour,&colour); } else if (strcmp("nbspline", word) == 0) { read_value(ifs, nbspline); + Para_Json::set_json_value(Para_Json::nbspline, line); } else if (strcmp("t_in_h", word) == 0) { read_bool(ifs, t_in_h); + Para_Json::set_json_value(Para_Json::t_in_h,&t_in_h); } else if (strcmp("vl_in_h", word) == 0) { read_bool(ifs, vl_in_h); + Para_Json::set_json_value(Para_Json::vl_in_h,&vl_in_h); } else if (strcmp("vnl_in_h", word) == 0) { read_bool(ifs, vnl_in_h); + Para_Json::set_json_value(Para_Json::vnl_in_h,&vnl_in_h); } else if (strcmp("vh_in_h", word) == 0) { read_bool(ifs, vh_in_h); + Para_Json::set_json_value(Para_Json::vh_in_h,&vh_in_h); } else if (strcmp("vion_in_h", word) == 0) { read_bool(ifs, vion_in_h); + Para_Json::set_json_value(Para_Json::vion_in_h,&vion_in_h); } else if (strcmp("test_force", word) == 0) { read_bool(ifs, test_force); + Para_Json::set_json_value(Para_Json::test_force,&test_force); } else if (strcmp("test_stress", word) == 0) { read_bool(ifs, test_stress); + Para_Json::set_json_value(Para_Json::test_stress,&test_stress); } //---------------------------------------------------------- // iteration @@ -1175,22 +1309,27 @@ bool Input::Read(const std::string &fn) else if (strcmp("scf_thr", word) == 0) { read_value(ifs, scf_thr); + Para_Json::set_json_value(Para_Json::scf_thr,&scf_thr); } else if (strcmp("scf_thr_type", word) == 0) { read_value(ifs, scf_thr_type); + Para_Json::set_json_value(Para_Json::scf_thr_type,&scf_thr_type); } else if (strcmp("scf_nmax", word) == 0) { read_value(ifs, scf_nmax); + Para_Json::set_json_value(Para_Json::scf_nmax,&scf_nmax); } else if (strcmp("relax_nmax", word) == 0) { read_value(ifs, this->relax_nmax); + Para_Json::set_json_value(Para_Json::relax_nmax,&relax_nmax); } else if (strcmp("out_stru", word) == 0) { read_bool(ifs, out_stru); + Para_Json::set_json_value(Para_Json::out_stru,&out_stru); } //---------------------------------------------------------- // occupation @@ -1202,10 +1341,12 @@ bool Input::Read(const std::string &fn) else if (strcmp("smearing_method", word) == 0) { read_value(ifs, smearing_method); + Para_Json::set_json_value(Para_Json::smearing_method,&smearing_method); } else if (strcmp("smearing_sigma", word) == 0) { read_value(ifs, smearing_sigma); + Para_Json::set_json_value(Para_Json::smearing_sigma,&smearing_sigma); } else if (strcmp("smearing_sigma_temp", word) == 0) { @@ -1219,18 +1360,22 @@ bool Input::Read(const std::string &fn) else if (strcmp("mixing_type", word) == 0) { read_value(ifs, mixing_mode); + Para_Json::set_json_value(Para_Json::mixing_type,&mixing_mode); } else if (strcmp("mixing_beta", word) == 0) { read_value(ifs, mixing_beta); + Para_Json::set_json_value(Para_Json::mixing_beta,&mixing_beta); } else if (strcmp("mixing_ndim", word) == 0) { read_value(ifs, mixing_ndim); + Para_Json::set_json_value(Para_Json::mixing_ndim,&mixing_ndim); } else if (strcmp("mixing_gg0", word) == 0) // mohan add 2014-09-27 { read_value(ifs, mixing_gg0); + Para_Json::set_json_value(Para_Json::mixing_gg0,&mixing_gg0); } else if (strcmp("mixing_beta_mag", word) == 0) { @@ -1243,10 +1388,12 @@ bool Input::Read(const std::string &fn) else if (strcmp("mixing_tau", word) == 0) { read_bool(ifs, mixing_tau); + Para_Json::set_json_value(Para_Json::mixing_tau,&mixing_tau); } else if (strcmp("mixing_dftu", word) == 0) { read_bool(ifs, mixing_dftu); + Para_Json::set_json_value(Para_Json::mixing_dftu,&mixing_dftu); } //---------------------------------------------------------- // charge / potential / wavefunction @@ -1254,10 +1401,12 @@ bool Input::Read(const std::string &fn) else if (strcmp("read_file_dir", word) == 0) { read_value(ifs, read_file_dir); + Para_Json::set_json_value(Para_Json::read_file_dir,&read_file_dir); } else if (strcmp("init_wfc", word) == 0) { read_value(ifs, init_wfc); + Para_Json::set_json_value(Para_Json::init_wfc,&init_wfc); } else if (strcmp("psi_initializer", word) == 0) { @@ -1266,155 +1415,192 @@ bool Input::Read(const std::string &fn) else if (strcmp("mem_saver", word) == 0) { read_value(ifs, mem_saver); + Para_Json::set_json_value(Para_Json::mem_saver,&mem_saver); } else if (strcmp("printe", word) == 0) { read_value(ifs, printe); + Para_Json::set_json_value(Para_Json::printe,&printe); } else if (strcmp("init_chg", word) == 0) { read_value(ifs, init_chg); + Para_Json::set_json_value(Para_Json::init_chg,&init_chg); } else if (strcmp("chg_extrap", word) == 0) // xiaohui modify 2015-02-01 { read_value(ifs, chg_extrap); // xiaohui modify 2015-02-01 + Para_Json::set_json_value(Para_Json::chg_extrap,&chg_extrap); } else if (strcmp("out_freq_elec", word) == 0) { read_value(ifs, out_freq_elec); + Para_Json::set_json_value(Para_Json::out_freq_elec,&out_freq_elec); } else if (strcmp("out_freq_ion", word) == 0) { read_value(ifs, out_freq_ion); + Para_Json::set_json_value(Para_Json::out_freq_ion,&out_freq_ion); } else if (strcmp("out_chg", word) == 0) { read_bool(ifs, out_chg); + Para_Json::set_json_value(Para_Json::out_chg,&out_chg); } else if (strcmp("out_dm", word) == 0) { read_bool(ifs, out_dm); + Para_Json::set_json_value(Para_Json::out_dm,&out_dm); } else if (strcmp("out_dm1", word) == 0) { read_bool(ifs, out_dm1); + Para_Json::set_json_value(Para_Json::out_dm1,&out_dm1); } else if (strcmp("out_bandgap", word) == 0) // for bandgap printing { read_bool(ifs, out_bandgap); + Para_Json::set_json_value(Para_Json::out_bandgap,&out_bandgap); } else if (strcmp("deepks_out_labels", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03 { read_bool(ifs, deepks_out_labels); + //Para_Json::set_json_value(Para_Json::deepks_out_labels,&deepks_out_labels); } else if (strcmp("deepks_scf", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03 { read_bool(ifs, deepks_scf); + //Para_Json::set_json_value(Para_Json::deepks_scf,&deepks_scf); } else if (strcmp("deepks_bandgap", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03 { read_bool(ifs, deepks_bandgap); + //Para_Json::set_json_value(Para_Json::deepks_bandgap,&deepks_bandgap); } else if (strcmp("deepks_out_unittest", word) == 0) // mohan added 2021-01-03 { read_bool(ifs, deepks_out_unittest); + //Para_Json::set_json_value(Para_Json::deepks_out_unittest,&deepks_out_unittest); } else if (strcmp("deepks_model", word) == 0) // caoyu added 2021-06-03 { read_value(ifs, deepks_model); + //Para_Json::set_json_value(Para_Json::deepks_model,&deepks_model); } else if (strcmp("out_pot", word) == 0) { read_value(ifs, out_pot); + Para_Json::set_json_value(Para_Json::out_pot,&out_pot); } else if (strcmp("out_wfc_pw", word) == 0) { read_value(ifs, out_wfc_pw); + Para_Json::set_json_value(Para_Json::out_wfc_pw,&out_wfc_pw); } else if (strcmp("out_wfc_r", word) == 0) { read_bool(ifs, out_wfc_r); + Para_Json::set_json_value(Para_Json::out_wfc_r,&out_wfc_r); } // mohan add 20090909 else if (strcmp("out_dos", word) == 0) { read_value(ifs, out_dos); + Para_Json::set_json_value(Para_Json::out_dos,&out_dos); } else if (strcmp("out_band", word) == 0) { read_bool(ifs, out_band); + Para_Json::set_json_value(Para_Json::out_band,&out_band); } else if (strcmp("out_proj_band", word) == 0) { read_bool(ifs, out_proj_band); + Para_Json::set_json_value(Para_Json::out_proj_band,&out_proj_band); } else if (strcmp("out_mat_hs", word) == 0) { read_bool(ifs, out_mat_hs); + Para_Json::set_json_value(Para_Json::out_mat_hs,&out_mat_hs); } // LiuXh add 2019-07-15 else if (strcmp("out_mat_hs2", word) == 0) { read_bool(ifs, out_mat_hs2); + Para_Json::set_json_value(Para_Json::out_mat_hs2,&out_mat_hs2); } else if (strcmp("out_mat_t", word) == 0) { read_bool(ifs, out_mat_t); + Para_Json::set_json_value(Para_Json::out_mat_t,&out_mat_t); } else if (strcmp("out_mat_dh", word) == 0) { read_bool(ifs, out_mat_dh); + Para_Json::set_json_value(Para_Json::out_mat_dh,&out_mat_dh); } else if (strcmp("out_interval", word) == 0) { read_value(ifs, out_interval); + Para_Json::set_json_value(Para_Json::out_interval,&out_interval); } else if (strcmp("out_app_flag", word) == 0) { read_bool(ifs, out_app_flag); + Para_Json::set_json_value(Para_Json::out_app_flag,&out_app_flag); } else if (strcmp("out_mat_r", word) == 0) { read_bool(ifs, out_mat_r); + Para_Json::set_json_value(Para_Json::out_mat_r,&out_mat_r); } else if (strcmp("out_wfc_lcao", word) == 0) { read_value(ifs, out_wfc_lcao); + Para_Json::set_json_value(Para_Json::out_wfc_lcao,&out_wfc_lcao); } else if (strcmp("out_alllog", word) == 0) { read_bool(ifs, out_alllog); + Para_Json::set_json_value(Para_Json::out_alllog,&out_alllog); } else if (strcmp("out_element_info", word) == 0) { read_bool(ifs, out_element_info); + Para_Json::set_json_value(Para_Json::out_element_info,&out_element_info); } else if (strcmp("dos_emin_ev", word) == 0) { read_value(ifs, dos_emin_ev); dos_setemin = true; + Para_Json::set_json_value(Para_Json::dos_emin_ev,&dos_emin_ev); } else if (strcmp("dos_emax_ev", word) == 0) { read_value(ifs, dos_emax_ev); + Para_Json::set_json_value(Para_Json::dos_emax_ev,&dos_emax_ev); dos_setemax = true; } else if (strcmp("dos_edelta_ev", word) == 0) { read_value(ifs, dos_edelta_ev); + Para_Json::set_json_value(Para_Json::dos_edelta_ev,&dos_edelta_ev); } else if (strcmp("dos_scale", word) == 0) { read_value(ifs, dos_scale); + Para_Json::set_json_value(Para_Json::dos_scale,&dos_scale); } else if (strcmp("dos_sigma", word) == 0) { read_value(ifs, dos_sigma); + Para_Json::set_json_value(Para_Json::dos_sigma,&dos_sigma); } else if (strcmp("dos_nche", word) == 0) { read_value(ifs, dos_nche); + Para_Json::set_json_value(Para_Json::dos_nche,&dos_nche); } //---------------------------------------------------------- @@ -1424,18 +1610,22 @@ bool Input::Read(const std::string &fn) else if (strcmp("lcao_ecut", word) == 0) { read_value(ifs, lcao_ecut); + Para_Json::set_json_value(Para_Json::lcao_ecut,&lcao_ecut); } else if (strcmp("lcao_dk", word) == 0) { read_value(ifs, lcao_dk); + Para_Json::set_json_value(Para_Json::lcao_dk,&lcao_dk); } else if (strcmp("lcao_dr", word) == 0) { read_value(ifs, lcao_dr); + Para_Json::set_json_value(Para_Json::lcao_dr,&lcao_dr); } else if (strcmp("lcao_rmax", word) == 0) { read_value(ifs, lcao_rmax); + Para_Json::set_json_value(Para_Json::lcao_rmax,&lcao_rmax); } //---------------------------------------------------------- // Molecule Dynamics @@ -1444,146 +1634,183 @@ bool Input::Read(const std::string &fn) else if (strcmp("md_type", word) == 0) { read_value(ifs, mdp.md_type); + Para_Json::set_json_value(Para_Json::md_type,&mdp.md_type); + } else if (strcmp("md_thermostat", word) == 0) { read_value(ifs, mdp.md_thermostat); + Para_Json::set_json_value(Para_Json::md_thermostat,&mdp.md_thermostat); } else if (strcmp("md_nraise", word) == 0) { read_value(ifs, mdp.md_nraise); + Para_Json::set_json_value(Para_Json::md_nraise,&mdp.md_nraise); } else if (strcmp("cal_syns", word) == 0) { read_value(ifs, cal_syns); + Para_Json::set_json_value(Para_Json::cal_syns,&cal_syns); } else if (strcmp("dmax", word) == 0) { read_value(ifs, dmax); + Para_Json::set_json_value(Para_Json::dmax,&dmax); } else if (strcmp("md_tolerance", word) == 0) { read_value(ifs, mdp.md_tolerance); + Para_Json::set_json_value(Para_Json::md_tolerance,&mdp.md_tolerance); } else if (strcmp("md_nstep", word) == 0) { read_value(ifs, mdp.md_nstep); + Para_Json::set_json_value(Para_Json::md_nstep,&mdp.md_nstep); } else if (strcmp("md_dt", word) == 0) { read_value(ifs, mdp.md_dt); + Para_Json::set_json_value(Para_Json::md_dt,&mdp.md_dt); } else if (strcmp("md_tchain", word) == 0) { read_value(ifs, mdp.md_tchain); + Para_Json::set_json_value(Para_Json::md_tchain,&mdp.md_tchain); } else if (strcmp("md_tfirst", word) == 0) { read_value(ifs, mdp.md_tfirst); + Para_Json::set_json_value(Para_Json::md_tfirst,&mdp.md_tfirst); } else if (strcmp("md_tlast", word) == 0) { read_value(ifs, mdp.md_tlast); + Para_Json::set_json_value(Para_Json::md_tlast,&mdp.md_tlast); } else if (strcmp("md_dumpfreq", word) == 0) { read_value(ifs, mdp.md_dumpfreq); + Para_Json::set_json_value(Para_Json::md_dumpfreq,&mdp.md_dumpfreq); } else if (strcmp("md_restartfreq", word) == 0) { read_value(ifs, mdp.md_restartfreq); + Para_Json::set_json_value(Para_Json::md_restartfreq,&mdp.md_restartfreq); } else if (strcmp("md_seed", word) == 0) { read_value(ifs, mdp.md_seed); + Para_Json::set_json_value(Para_Json::md_seed,&mdp.md_seed); } else if (strcmp("md_prec_level", word) == 0) { read_value(ifs, mdp.md_prec_level); + Para_Json::set_json_value(Para_Json::md_prec_level,&mdp.md_prec_level); } else if (strcmp("md_restart", word) == 0) { read_bool(ifs, mdp.md_restart); + Para_Json::set_json_value(Para_Json::md_restart,&mdp.md_restart); } else if (strcmp("md_pmode", word) == 0) { read_value(ifs, mdp.md_pmode); + Para_Json::set_json_value(Para_Json::md_pmode,&mdp.md_pmode); } else if (strcmp("md_pcouple", word) == 0) { read_value(ifs, mdp.md_pcouple); + Para_Json::set_json_value(Para_Json::md_pcouple,&mdp.md_pcouple); } else if (strcmp("md_pchain", word) == 0) { read_value(ifs, mdp.md_pchain); + Para_Json::set_json_value(Para_Json::md_pchain,&mdp.md_pchain); } else if (strcmp("md_pfirst", word) == 0) { read_value(ifs, mdp.md_pfirst); + Para_Json::set_json_value(Para_Json::md_pfirst,&mdp.md_pfirst); } else if (strcmp("md_plast", word) == 0) { read_value(ifs, mdp.md_plast); + Para_Json::set_json_value(Para_Json::md_plast,&mdp.md_plast); } else if (strcmp("md_pfreq", word) == 0) { read_value(ifs, mdp.md_pfreq); + Para_Json::set_json_value(Para_Json::md_pfreq,&mdp.md_pfreq); } else if (strcmp("lj_rcut", word) == 0) { read_value(ifs, mdp.lj_rcut); + Para_Json::set_json_value(Para_Json::lj_rcut,&mdp.lj_rcut); } else if (strcmp("lj_epsilon", word) == 0) { read_value(ifs, mdp.lj_epsilon); + Para_Json::set_json_value(Para_Json::lj_epsilon,&mdp.lj_epsilon); } else if (strcmp("lj_sigma", word) == 0) { read_value(ifs, mdp.lj_sigma); + Para_Json::set_json_value(Para_Json::lj_sigma,&mdp.lj_sigma); } else if (strcmp("msst_direction", word) == 0) { read_value(ifs, mdp.msst_direction); + Para_Json::set_json_value(Para_Json::msst_direction,&mdp.msst_direction); } else if (strcmp("msst_vel", word) == 0) { read_value(ifs, mdp.msst_vel); + Para_Json::set_json_value(Para_Json::msst_vel,&mdp.msst_vel); } else if (strcmp("msst_vis", word) == 0) { read_value(ifs, mdp.msst_vis); + Para_Json::set_json_value(Para_Json::msst_vis,&mdp.msst_vis); } else if (strcmp("msst_tscale", word) == 0) { read_value(ifs, mdp.msst_tscale); + Para_Json::set_json_value(Para_Json::msst_tscale,&mdp.msst_tscale); } else if (strcmp("msst_qmass", word) == 0) { read_value(ifs, mdp.msst_qmass); + Para_Json::set_json_value(Para_Json::msst_qmass,&mdp.msst_qmass); } else if (strcmp("md_tfreq", word) == 0) { read_value(ifs, mdp.md_tfreq); + Para_Json::set_json_value(Para_Json::md_tfreq,&mdp.md_tfreq); } else if (strcmp("md_damp", word) == 0) { read_value(ifs, mdp.md_damp); + Para_Json::set_json_value(Para_Json::md_damp,&mdp.md_damp); } else if (strcmp("pot_file", word) == 0) { read_value(ifs, mdp.pot_file); + Para_Json::set_json_value(Para_Json::pot_file,&mdp.pot_file); } else if (strcmp("dump_force", word) == 0) { read_bool(ifs, mdp.dump_force); + Para_Json::set_json_value(Para_Json::dump_force,&mdp.dump_force); } else if (strcmp("dump_vel", word) == 0) { read_bool(ifs, mdp.dump_vel); + Para_Json::set_json_value(Para_Json::dump_vel,&mdp.dump_vel); } else if (strcmp("dump_virial", word) == 0) { read_bool(ifs, mdp.dump_virial); + Para_Json::set_json_value(Para_Json::dump_virial,&mdp.dump_virial); } //---------------------------------------------------------- // efield and dipole correction @@ -1592,26 +1819,32 @@ bool Input::Read(const std::string &fn) else if (strcmp("efield_flag", word) == 0) { read_bool(ifs, efield_flag); + Para_Json::set_json_value(Para_Json::efield_flag,&efield_flag); } else if (strcmp("dip_cor_flag", word) == 0) { read_bool(ifs, dip_cor_flag); + Para_Json::set_json_value(Para_Json::dip_cor_flag,&dip_cor_flag); } else if (strcmp("efield_dir", word) == 0) { read_value(ifs, efield_dir); + Para_Json::set_json_value(Para_Json::efield_dir,&efield_dir); } else if (strcmp("efield_pos_max", word) == 0) { read_value(ifs, efield_pos_max); + Para_Json::set_json_value(Para_Json::efield_pos_max,&efield_pos_max); } else if (strcmp("efield_pos_dec", word) == 0) { read_value(ifs, efield_pos_dec); + Para_Json::set_json_value(Para_Json::efield_pos_dec,&efield_pos_dec); } else if (strcmp("efield_amp", word) == 0) { read_value(ifs, efield_amp); + Para_Json::set_json_value(Para_Json::efield_amp,&efield_amp); } //---------------------------------------------------------- // gatefield (compensating charge) @@ -1620,30 +1853,37 @@ bool Input::Read(const std::string &fn) else if (strcmp("gate_flag", word) == 0) { read_bool(ifs, gate_flag); + Para_Json::set_json_value(Para_Json::gate_flag,&gate_flag); } else if (strcmp("zgate", word) == 0) { read_value(ifs, zgate); + Para_Json::set_json_value(Para_Json::zgate,&zgate); } else if (strcmp("relax", word) == 0) { read_bool(ifs, relax); + //Para_Json::set_json_value(Para_Json::relax,&relax); } else if (strcmp("block", word) == 0) { read_bool(ifs, block); + Para_Json::set_json_value(Para_Json::block,&block); } else if (strcmp("block_down", word) == 0) { read_value(ifs, block_down); + Para_Json::set_json_value(Para_Json::block_down,&block_down); } else if (strcmp("block_up", word) == 0) { read_value(ifs, block_up); + Para_Json::set_json_value(Para_Json::block_up,&block_up); } else if (strcmp("block_height", word) == 0) { read_value(ifs, block_height); + Para_Json::set_json_value(Para_Json::block_height,&block_height); } //---------------------------------------------------------- // tddft @@ -1652,130 +1892,162 @@ bool Input::Read(const std::string &fn) else if (strcmp("td_force_dt", word) == 0) { read_value(ifs, td_force_dt); + //Para_Json::set_json_value(Para_Json::td_force_dt,&td_force_dt); } else if (strcmp("td_vext", word) == 0) { read_value(ifs, td_vext); + Para_Json::set_json_value(Para_Json::td_vext,&td_vext); } else if (strcmp("td_vext_dire", word) == 0) { getline(ifs, td_vext_dire); + Para_Json::set_json_value(Para_Json::td_vext_dire,&td_vext_dire); } else if (strcmp("out_dipole", word) == 0) { read_value(ifs, out_dipole); + Para_Json::set_json_value(Para_Json::td_out_dipole,&out_dipole); } else if (strcmp("out_efield", word) == 0) { read_value(ifs, out_efield); + Para_Json::set_json_value(Para_Json::td_out_efield,&out_efield); } else if (strcmp("td_print_eij", word) == 0) { read_value(ifs, td_print_eij); + Para_Json::set_json_value(Para_Json::td_print_eij,&td_print_eij); } else if (strcmp("td_edm", word) == 0) { read_value(ifs, td_edm); + Para_Json::set_json_value(Para_Json::td_edm,&td_edm); } else if (strcmp("td_propagator", word) == 0) { read_value(ifs, propagator); + Para_Json::set_json_value(Para_Json::td_propagator,&propagator); } else if (strcmp("td_stype", word) == 0) { read_value(ifs, td_stype); + Para_Json::set_json_value(Para_Json::td_stype,&td_stype); } else if (strcmp("td_ttype", word) == 0) { getline(ifs, td_ttype); + Para_Json::set_json_value(Para_Json::td_ttype,&td_ttype); } else if (strcmp("td_tstart", word) == 0) { read_value(ifs, td_tstart); + Para_Json::set_json_value(Para_Json::td_tstart,&td_tstart); } else if (strcmp("td_tend", word) == 0) { read_value(ifs, td_tend); + Para_Json::set_json_value(Para_Json::td_tend,&td_tend); } else if (strcmp("td_lcut1", word) == 0) { read_value(ifs, td_lcut1); + Para_Json::set_json_value(Para_Json::td_lcut1,&td_lcut1); } else if (strcmp("td_lcut2", word) == 0) { read_value(ifs, td_lcut2); + Para_Json::set_json_value(Para_Json::td_lcut2,&td_lcut2); } else if (strcmp("td_gauss_freq", word) == 0) { getline(ifs, td_gauss_freq); + Para_Json::set_json_value(Para_Json::td_gauss_freq,&td_gauss_freq); } else if (strcmp("td_gauss_phase", word) == 0) { getline(ifs, td_gauss_phase); + Para_Json::set_json_value(Para_Json::td_gauss_phase,&td_gauss_phase); } else if (strcmp("td_gauss_sigma", word) == 0) { getline(ifs, td_gauss_sigma); + Para_Json::set_json_value(Para_Json::td_gauss_sigma,&td_gauss_sigma); } else if (strcmp("td_gauss_t0", word) == 0) { getline(ifs, td_gauss_t0); + Para_Json::set_json_value(Para_Json::td_gauss_t0,&td_gauss_t0); } else if (strcmp("td_gauss_amp", word) == 0) { getline(ifs, td_gauss_amp); + Para_Json::set_json_value(Para_Json::td_gauss_amp,&td_gauss_amp); } else if (strcmp("td_trape_freq", word) == 0) { getline(ifs, td_trape_freq); + Para_Json::set_json_value(Para_Json::td_trape_freq,&td_gauss_freq); } else if (strcmp("td_trape_phase", word) == 0) { getline(ifs, td_trape_phase); + Para_Json::set_json_value(Para_Json::td_trape_phase,&td_trape_phase); } else if (strcmp("td_trape_t1", word) == 0) { getline(ifs, td_trape_t1); + Para_Json::set_json_value(Para_Json::td_trape_t1,&td_trape_t1); } else if (strcmp("td_trape_t2", word) == 0) { getline(ifs, td_trape_t2); + Para_Json::set_json_value(Para_Json::td_trape_t2,&td_trape_t2); } else if (strcmp("td_trape_t3", word) == 0) { getline(ifs, td_trape_t3); + Para_Json::set_json_value(Para_Json::td_trape_t3,&td_trape_t3); } else if (strcmp("td_trape_amp", word) == 0) { getline(ifs, td_trape_amp); + Para_Json::set_json_value(Para_Json::td_trape_amp,&td_trape_amp); } else if (strcmp("td_trigo_freq1", word) == 0) { getline(ifs, td_trigo_freq1); + Para_Json::set_json_value(Para_Json::td_trigo_freq1,&td_trigo_freq1); } else if (strcmp("td_trigo_freq2", word) == 0) { getline(ifs, td_trigo_freq2); + Para_Json::set_json_value(Para_Json::td_trigo_freq2,&td_trigo_freq2); } else if (strcmp("td_trigo_phase1", word) == 0) { getline(ifs, td_trigo_phase1); + Para_Json::set_json_value(Para_Json::td_trigo_phase1,&td_trigo_phase1); } else if (strcmp("td_trigo_phase2", word) == 0) { getline(ifs, td_trigo_phase2); + Para_Json::set_json_value(Para_Json::td_trigo_phase2,&td_trigo_phase2); } else if (strcmp("td_trigo_amp", word) == 0) { getline(ifs, td_trigo_amp); + Para_Json::set_json_value(Para_Json::td_trigo_amp,&td_trigo_amp); } else if (strcmp("td_heavi_t0", word) == 0) { getline(ifs, td_heavi_t0); + Para_Json::set_json_value(Para_Json::td_heavi_t0,&td_heavi_t0); } else if (strcmp("td_heavi_amp", word) == 0) { getline(ifs, td_heavi_amp); + Para_Json::set_json_value(Para_Json::td_heavi_amp,&td_heavi_amp); } // else if (strcmp("td_hhg_amp1", word) == 0) // { @@ -1816,71 +2088,91 @@ bool Input::Read(const std::string &fn) else if (strcmp("vdw_method", word) == 0) { read_value(ifs, vdw_method); + Para_Json::set_json_value(Para_Json::vdw_method,&vdw_method); } else if (strcmp("vdw_s6", word) == 0) { read_value(ifs, vdw_s6); + Para_Json::set_json_value(Para_Json::vdw_s6,&vdw_s6); } else if (strcmp("vdw_s8", word) == 0) { read_value(ifs, vdw_s8); + Para_Json::set_json_value(Para_Json::vdw_s8,&vdw_s8); } else if (strcmp("vdw_a1", word) == 0) { read_value(ifs, vdw_a1); + Para_Json::set_json_value(Para_Json::vdw_a1,&vdw_a1); } else if (strcmp("vdw_a2", word) == 0) { read_value(ifs, vdw_a2); + Para_Json::set_json_value(Para_Json::vdw_a2,&vdw_a2); } else if (strcmp("vdw_d", word) == 0) { read_value(ifs, vdw_d); + Para_Json::set_json_value(Para_Json::vdw_d,&vdw_d); } else if (strcmp("vdw_abc", word) == 0) { read_bool(ifs, vdw_abc); + Para_Json::set_json_value(Para_Json::vdw_abc,&vdw_abc); } else if (strcmp("vdw_cutoff_radius", word) == 0) { read_value(ifs, vdw_cutoff_radius); + Para_Json::set_json_value(Para_Json::vdw_cutoff_radius,&vdw_cutoff_radius); } else if (strcmp("vdw_radius_unit", word) == 0) { read_value(ifs, vdw_radius_unit); + Para_Json::set_json_value(Para_Json::vdw_radius_unit,&vdw_radius_unit); } else if (strcmp("vdw_cn_thr", word) == 0) { read_value(ifs, vdw_cn_thr); + Para_Json::set_json_value(Para_Json::vdw_cn_thr,&vdw_cn_thr); } else if (strcmp("vdw_cn_thr_unit", word) == 0) { read_value(ifs, vdw_cn_thr_unit); + Para_Json::set_json_value(Para_Json::vdw_cn_thr_unit,&vdw_cn_thr_unit); } else if (strcmp("vdw_c6_file", word) == 0) { read_value(ifs, vdw_C6_file); + Para_Json::set_json_value(Para_Json::vdw_C6_file,&vdw_C6_file); } else if (strcmp("vdw_c6_unit", word) == 0) { read_value(ifs, vdw_C6_unit); + Para_Json::set_json_value(Para_Json::vdw_C6_unit,&vdw_C6_unit); } else if (strcmp("vdw_r0_file", word) == 0) { read_value(ifs, vdw_R0_file); + Para_Json::set_json_value(Para_Json::vdw_R0_file,&vdw_R0_file); } else if (strcmp("vdw_r0_unit", word) == 0) { read_value(ifs, vdw_R0_unit); + Para_Json::set_json_value(Para_Json::vdw_R0_unit,&vdw_R0_unit); } else if (strcmp("vdw_cutoff_type", word) == 0) { read_value(ifs, vdw_cutoff_type); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); } else if (strcmp("vdw_cutoff_period", word) == 0) { ifs >> vdw_cutoff_period.x >> vdw_cutoff_period.y; read_value(ifs, vdw_cutoff_period.z); + + Para_Json::vdw_cutoff_period.PushBack(vdw_cutoff_period.x,Para_Json::doc.GetAllocator()); + Para_Json::vdw_cutoff_period.PushBack(vdw_cutoff_period.y,Para_Json::doc.GetAllocator()); + Para_Json::vdw_cutoff_period.PushBack(vdw_cutoff_period.z,Para_Json::doc.GetAllocator()); } //-------------------------------------------------------- // restart Peize Lin 2020-04-04 @@ -1888,23 +2180,28 @@ bool Input::Read(const std::string &fn) else if (strcmp("restart_save", word) == 0) { read_bool(ifs, restart_save); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); } else if (strcmp("restart_load", word) == 0) { read_bool(ifs, restart_load); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); } else if (strcmp("ocp", word) == 0) { read_bool(ifs, ocp); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); } else if (strcmp("ocp_set", word) == 0) { getline(ifs, ocp_set); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); // ifs.ignore(150, '\n'); } else if (strcmp("out_mul", word) == 0) { read_bool(ifs, out_mul); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); } // qifeng add 2019/9/10 //---------------------------------------------------------- // exx @@ -1913,114 +2210,143 @@ bool Input::Read(const std::string &fn) else if (strcmp("exx_hybrid_alpha", word) == 0) { read_value(ifs, exx_hybrid_alpha); + Para_Json::set_json_value(Para_Json::exx_hybrid_alpha,&exx_hybrid_alpha); } else if (strcmp("exx_hse_omega", word) == 0) { read_value(ifs, exx_hse_omega); + Para_Json::set_json_value(Para_Json::exx_hse_omega,&exx_hse_omega); } else if (strcmp("exx_separate_loop", word) == 0) { read_bool(ifs, exx_separate_loop); + Para_Json::set_json_value(Para_Json::exx_separate_loop,&exx_separate_loop); } else if (strcmp("exx_hybrid_step", word) == 0) { read_value(ifs, exx_hybrid_step); + Para_Json::set_json_value(Para_Json::exx_hybrid_step,&exx_hybrid_step); } else if (strcmp("exx_mixing_beta", word) == 0) { read_value(ifs, exx_mixing_beta); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); } else if (strcmp("exx_lambda", word) == 0) { read_value(ifs, exx_lambda); + Para_Json::set_json_value(Para_Json::vdw_cutoff_type,&vdw_cutoff_type); } else if (strcmp("exx_real_number", word) == 0) { read_value(ifs, exx_real_number); + // printf("exx_real_number = %s\n",exx_real_number.c_str()); + Para_Json::set_json_value(Para_Json::exx_real_number,&exx_real_number); } else if (strcmp("exx_pca_threshold", word) == 0) { read_value(ifs, exx_pca_threshold); + Para_Json::set_json_value(Para_Json::exx_pca_threshold,&exx_pca_threshold); } else if (strcmp("exx_c_threshold", word) == 0) { read_value(ifs, exx_c_threshold); + Para_Json::set_json_value(Para_Json::exx_c_threshold,&exx_c_threshold); } else if (strcmp("exx_v_threshold", word) == 0) { read_value(ifs, exx_v_threshold); + Para_Json::set_json_value(Para_Json::exx_v_threshold,&exx_v_threshold); } else if (strcmp("exx_dm_threshold", word) == 0) { read_value(ifs, exx_dm_threshold); + Para_Json::set_json_value(Para_Json::exx_dm_threshold,&exx_dm_threshold); } else if (strcmp("exx_schwarz_threshold", word) == 0) { read_value(ifs, exx_schwarz_threshold); + Para_Json::set_json_value(Para_Json::exx_schwarz_threshold,&exx_schwarz_threshold); } else if (strcmp("exx_cauchy_threshold", word) == 0) { read_value(ifs, exx_cauchy_threshold); + Para_Json::set_json_value(Para_Json::exx_cauchy_threshold,&exx_cauchy_threshold); } else if (strcmp("exx_c_grad_threshold", word) == 0) { read_value(ifs, exx_c_grad_threshold); + Para_Json::set_json_value(Para_Json::exx_c_grad_threshold,&exx_c_grad_threshold); } else if (strcmp("exx_v_grad_threshold", word) == 0) { read_value(ifs, exx_v_grad_threshold); + Para_Json::set_json_value(Para_Json::exx_v_grad_threshold,&exx_v_grad_threshold); } else if (strcmp("exx_cauchy_force_threshold", word) == 0) { read_value(ifs, exx_cauchy_force_threshold); + Para_Json::set_json_value(Para_Json::exx_cauchy_force_threshold,&exx_cauchy_force_threshold); } else if (strcmp("exx_cauchy_stress_threshold", word) == 0) { read_value(ifs, exx_cauchy_stress_threshold); + Para_Json::set_json_value(Para_Json::exx_cauchy_stress_threshold,&exx_cauchy_stress_threshold); } else if (strcmp("exx_ccp_threshold", word) == 0) { read_value(ifs, exx_ccp_threshold); + Para_Json::set_json_value(Para_Json::exx_ccp_threshold,&exx_ccp_threshold); } else if (strcmp("exx_ccp_rmesh_times", word) == 0) { read_value(ifs, exx_ccp_rmesh_times); + Para_Json::set_json_value(Para_Json::exx_ccp_rmesh_times,&exx_ccp_rmesh_times); } else if (strcmp("exx_distribute_type", word) == 0) { read_value(ifs, exx_distribute_type); + Para_Json::set_json_value(Para_Json::exx_distribute_type,&exx_distribute_type); } else if (strcmp("exx_opt_orb_lmax", word) == 0) { read_value(ifs, exx_opt_orb_lmax); + Para_Json::set_json_value(Para_Json::exx_opt_orb_lmax,&exx_opt_orb_lmax); } else if (strcmp("exx_opt_orb_ecut", word) == 0) { read_value(ifs, exx_opt_orb_ecut); + Para_Json::set_json_value(Para_Json::exx_opt_orb_ecut,&exx_opt_orb_ecut); } else if (strcmp("exx_opt_orb_tolerence", word) == 0) { read_value(ifs, exx_opt_orb_tolerence); + Para_Json::set_json_value(Para_Json::exx_opt_orb_tolerence,&exx_opt_orb_tolerence); } else if (strcmp("noncolin", word) == 0) { read_bool(ifs, noncolin); + Para_Json::set_json_value(Para_Json::noncolin,&noncolin); } else if (strcmp("lspinorb", word) == 0) { read_bool(ifs, lspinorb); + Para_Json::set_json_value(Para_Json::lspinorb,&lspinorb); } else if (strcmp("soc_lambda", word) == 0) { read_value(ifs, soc_lambda); + Para_Json::set_json_value(Para_Json::soc_lambda,&soc_lambda); } else if (strcmp("cell_factor", word) == 0) { read_value(ifs, cell_factor); + Para_Json::set_json_value(Para_Json::cell_factor,&cell_factor); } else if (strcmp("test_skip_ewald", word) == 0) { read_bool(ifs, test_skip_ewald); + Para_Json::set_json_value(Para_Json::test_skip_ewald,&test_skip_ewald); } //-------------- //---------------------------------------------------------------------------------- @@ -2029,6 +2355,7 @@ bool Input::Read(const std::string &fn) else if (strcmp("dft_plus_u", word) == 0) { read_bool(ifs, dft_plus_u); + //Para_Json::set_json_value(Para_Json::dft_plus_u,&dft_plus_u); } else if (strcmp("yukawa_potential", word) == 0) ifs.ignore(150, '\n'); @@ -2046,6 +2373,7 @@ bool Input::Read(const std::string &fn) else if (strcmp("dft_plus_dmft", word) == 0) { read_bool(ifs, dft_plus_dmft); + //Para_Json::set_json_value(Para_Json::dft_plus_dmft,&dft_plus_dmft); } //---------------------------------------------------------------------------------- // Rong Shi added for RPA @@ -2053,6 +2381,7 @@ bool Input::Read(const std::string &fn) else if (strcmp("rpa", word) == 0) { read_bool(ifs, rpa); + Para_Json::set_json_value(Para_Json::rpa,&rpa); if (rpa) GlobalV::rpa_setorb = true; } @@ -2062,22 +2391,27 @@ bool Input::Read(const std::string &fn) else if (strcmp("imp_sol", word) == 0) { read_bool(ifs, imp_sol); + Para_Json::set_json_value(Para_Json::imp_sol,&imp_sol); } else if (strcmp("eb_k", word) == 0) { read_value(ifs, eb_k); + Para_Json::set_json_value(Para_Json::eb_k,&eb_k); } else if (strcmp("tau", word) == 0) { read_value(ifs, tau); + Para_Json::set_json_value(Para_Json::tau,&tau); } else if (strcmp("sigma_k", word) == 0) { read_value(ifs, sigma_k); + Para_Json::set_json_value(Para_Json::sigma_k,&sigma_k); } else if (strcmp("nc_k", word) == 0) { read_value(ifs, nc_k); + Para_Json::set_json_value(Para_Json::nc_k,&nc_k); } //---------------------------------------------------------------------------------- // OFDFT sunliang added on 2022-05-05 @@ -2085,110 +2419,137 @@ bool Input::Read(const std::string &fn) else if (strcmp("of_kinetic", word) == 0) { read_value(ifs, of_kinetic); + Para_Json::set_json_value(Para_Json::of_kinetic,&of_kinetic); } else if (strcmp("of_method", word) == 0) { read_value(ifs, of_method); + Para_Json::set_json_value(Para_Json::of_method,&of_method); } else if (strcmp("of_conv", word) == 0) { read_value(ifs, of_conv); + Para_Json::set_json_value(Para_Json::of_conv,&of_conv); } else if (strcmp("of_tole", word) == 0) { read_value(ifs, of_tole); + Para_Json::set_json_value(Para_Json::of_tole,&of_tole); } else if (strcmp("of_tolp", word) == 0) { read_value(ifs, of_tolp); + Para_Json::set_json_value(Para_Json::of_tolp,&of_tolp); } else if (strcmp("of_tf_weight", word) == 0) { read_value(ifs, of_tf_weight); + Para_Json::set_json_value(Para_Json::of_tf_weight,&of_tf_weight); } else if (strcmp("of_vw_weight", word) == 0) { read_value(ifs, of_vw_weight); + Para_Json::set_json_value(Para_Json::of_vw_weight,&of_vw_weight); } else if (strcmp("of_wt_alpha", word) == 0) { read_value(ifs, of_wt_alpha); + Para_Json::set_json_value(Para_Json::of_wt_alpha,&of_wt_alpha); } else if (strcmp("of_wt_beta", word) == 0) { read_value(ifs, of_wt_beta); + Para_Json::set_json_value(Para_Json::of_wt_beta,&of_wt_beta); } else if (strcmp("of_wt_rho0", word) == 0) { read_value(ifs, of_wt_rho0); + Para_Json::set_json_value(Para_Json::of_wt_rho0,&of_wt_rho0); } else if (strcmp("of_hold_rho0", word) == 0) { read_bool(ifs, of_hold_rho0); + Para_Json::set_json_value(Para_Json::of_hold_rho0,&of_hold_rho0); } else if (strcmp("of_lkt_a", word) == 0) { read_value(ifs, of_lkt_a); + Para_Json::set_json_value(Para_Json::of_lkt_a,&of_lkt_a); } else if (strcmp("of_full_pw", word) == 0) { read_bool(ifs, of_full_pw); + Para_Json::set_json_value(Para_Json::of_full_pw,&of_full_pw); } else if (strcmp("of_full_pw_dim", word) == 0) { read_value(ifs, of_full_pw_dim); + Para_Json::set_json_value(Para_Json::of_full_pw_dim,&of_full_pw_dim); } else if (strcmp("of_read_kernel", word) == 0) { read_bool(ifs, of_read_kernel); + Para_Json::set_json_value(Para_Json::of_read_kernel,&of_read_kernel); } else if (strcmp("of_kernel_file", word) == 0) { read_value(ifs, of_kernel_file); + Para_Json::set_json_value(Para_Json::of_kernel_file,&of_kernel_file); } else if (strcmp("bessel_nao_smooth", word) == 0) { read_value(ifs, bessel_nao_smooth); + Para_Json::set_json_value(Para_Json::bessel_nao_smooth,&bessel_nao_smooth); } else if (strcmp("bessel_nao_sigma", word) == 0) { read_value(ifs, bessel_nao_sigma); + Para_Json::set_json_value(Para_Json::bessel_nao_sigma,&bessel_nao_sigma); } else if (strcmp("bessel_nao_ecut", word) == 0) { read_value(ifs, bessel_nao_ecut); + Para_Json::set_json_value(Para_Json::bessel_nao_ecut,&bessel_nao_ecut); } else if (strcmp("bessel_nao_rcut", word) == 0) { read_value(ifs, bessel_nao_rcut); + Para_Json::set_json_value(Para_Json::bessel_nao_rcut,&bessel_nao_rcut); } else if (strcmp("bessel_nao_tolerence", word) == 0) { read_value(ifs, bessel_nao_tolerence); + Para_Json::set_json_value(Para_Json::bessel_nao_tolerence,&bessel_nao_tolerence); } else if (strcmp("bessel_descriptor_lmax", word) == 0) { read_value(ifs, bessel_descriptor_lmax); + Para_Json::set_json_value(Para_Json::bessel_descriptor_lmax,&bessel_descriptor_lmax); } else if (strcmp("bessel_descriptor_smooth", word) == 0) { read_value(ifs, bessel_descriptor_smooth); + Para_Json::set_json_value(Para_Json::bessel_descriptor_smooth,&bessel_descriptor_smooth); } else if (strcmp("bessel_descriptor_sigma", word) == 0) { read_value(ifs, bessel_descriptor_sigma); + Para_Json::set_json_value(Para_Json::bessel_descriptor_sigma,&bessel_descriptor_sigma); } else if (strcmp("bessel_descriptor_ecut", word) == 0) { read_value(ifs, bessel_descriptor_ecut); + Para_Json::set_json_value(Para_Json::bessel_descriptor_ecut,&bessel_descriptor_ecut); } else if (strcmp("bessel_descriptor_rcut", word) == 0) { read_value(ifs, bessel_descriptor_rcut); + Para_Json::set_json_value(Para_Json::bessel_descriptor_rcut,&bessel_descriptor_rcut); } else if (strcmp("bessel_descriptor_tolerence", word) == 0) { read_value(ifs, bessel_descriptor_tolerence); + Para_Json::set_json_value(Para_Json::bessel_descriptor_tolerence,&bessel_descriptor_tolerence); } //---------------------------------------------------------------------------------- // device control denghui added on 2022-11-05 @@ -2196,14 +2557,16 @@ bool Input::Read(const std::string &fn) else if (strcmp("device", word) == 0) { read_value(ifs, device); + Para_Json::set_json_value(Para_Json::device,&device); } //---------------------------------------------------------------------------------- // precision control denghui added on 2023-01-01 //---------------------------------------------------------------------------------- else if (strcmp("precision", word) == 0) { read_value(ifs, precision); + //Para_Json::set_json_value(Para_Json::precision,&precision); } - //---------------------------------------------------------------------------------- + //---------------------------------------------------------------------------------- // Deltaspin //---------------------------------------------------------------------------------- else if (strcmp("sc_mag_switch", word) == 0){ @@ -2324,16 +2687,19 @@ bool Input::Read(const std::string &fn) if (strcmp("yukawa_potential", word) == 0) { read_bool(ifs, yukawa_potential); + Para_Json::set_json_value(Para_Json::yukawa_potential,&yukawa_potential); } else if (strcmp("yukawa_lambda", word) == 0) { ifs >> yukawa_lambda; + Para_Json::set_json_value(Para_Json::yukawa_lambda,&yukawa_lambda); } else if (strcmp("hubbard_u", word) == 0) { for (int i = 0; i < ntype; i++) { ifs >> hubbard_u[i]; + Para_Json::hubbard_u.PushBack(hubbard_u[i],Para_Json::doc.GetAllocator()); hubbard_u[i] /= ModuleBase::Ry_to_eV; } } @@ -2342,6 +2708,7 @@ bool Input::Read(const std::string &fn) for (int i = 0; i < ntype; i++) { ifs >> orbital_corr[i]; + Para_Json::orbital_corr.PushBack(orbital_corr[i],Para_Json::doc.GetAllocator()); } } else if (strcmp("omc", word) == 0) @@ -2416,6 +2783,7 @@ bool Input::Read(const std::string &fn) for (int i = 0; i < ntype; i++) { ifs >> hubbard_u[i]; + Para_Json::hubbard_u.PushBack(hubbard_u[i],Para_Json::doc.GetAllocator()); hubbard_u[i] /= ModuleBase::Ry_to_eV; } } @@ -2424,6 +2792,7 @@ bool Input::Read(const std::string &fn) for (int i = 0; i < ntype; i++) { ifs >> orbital_corr[i]; + Para_Json::orbital_corr.PushBack(orbital_corr[i],Para_Json::doc.GetAllocator()); } } else @@ -2520,6 +2889,7 @@ bool Input::Read(const std::string &fn) return true; } // end read_parameters + void Input::Default_2(void) // jiyy add 2019-08-04 { if (GlobalV::MY_RANK != 0) diff --git a/source/module_io/test/CMakeLists.txt b/source/module_io/test/CMakeLists.txt index face26e88f..ad6afc24f6 100644 --- a/source/module_io/test/CMakeLists.txt +++ b/source/module_io/test/CMakeLists.txt @@ -86,6 +86,7 @@ AddTest( ../../module_base/global_variable.cpp ../../module_base/parallel_reduce.cpp ../../module_base/parallel_common.cpp + ../../module_base/para_json.cpp ../../module_base/parallel_global.cpp ) @@ -141,3 +142,9 @@ AddTest( LIBS base ${math_libs} device SOURCES csr_reader_test.cpp ../csr_reader.cpp ../file_reader.cpp ../sparse_matrix.cpp ) + +AddTest( + TARGET io_para_json_test + LIBS ${math_libs} base device + SOURCES para_json_test.cpp ../input.cpp +) \ No newline at end of file diff --git a/source/module_io/test/para_json_test.cpp b/source/module_io/test/para_json_test.cpp new file mode 100644 index 0000000000..cc36a18238 --- /dev/null +++ b/source/module_io/test/para_json_test.cpp @@ -0,0 +1,86 @@ +#include "gtest/gtest.h" +#include "module_base/global_variable.h" +#include "module_base/para_json.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 + */ + +#define private public +#include "module_io/input.h" + +class ParaJsonTest : public ::testing::Test +{ +protected: + std::string testString; +}; + +#ifdef __MPI + +// 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)); + + + if(GlobalV::MY_RANK==0) + { + + // 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(); + printf("%s\n",json.c_str()); + + EXPECT_EQ(isValidJSON(json),true); + + } +} + + + +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 diff --git a/source/module_md/test/CMakeLists.txt b/source/module_md/test/CMakeLists.txt index 6797bf63b5..b2e0bc9432 100644 --- a/source/module_md/test/CMakeLists.txt +++ b/source/module_md/test/CMakeLists.txt @@ -44,7 +44,9 @@ list(APPEND depend_files ../../module_io/print_info.cpp ../../module_esolver/esolver_lj.cpp ../../module_base/parallel_reduce.cpp + ../../module_base/para_json.cpp ../../module_base/parallel_global.cpp + ../../module_base/para_json.cpp ) AddTest( diff --git a/source/module_relax/relax_new/test/CMakeLists.txt b/source/module_relax/relax_new/test/CMakeLists.txt index 446d868f21..41593aec9b 100644 --- a/source/module_relax/relax_new/test/CMakeLists.txt +++ b/source/module_relax/relax_new/test/CMakeLists.txt @@ -15,7 +15,7 @@ AddTest( AddTest( TARGET relax_new_relax SOURCES relax_test.cpp ../relax.cpp ../line_search.cpp ../../../module_base/tool_quit.cpp ../../../module_base/global_variable.cpp ../../../module_base/global_file.cpp ../../../module_base/memory.cpp ../../../module_base/timer.cpp - ../../../module_base/matrix3.cpp ../../../module_base/intarray.cpp ../../../module_base/tool_title.cpp ../../../module_io/input.cpp + ../../../module_base/matrix3.cpp ../../../module_base/intarray.cpp ../../../module_base/tool_title.cpp ../../../module_base/para_json.cpp ../../../module_io/input.cpp ../../../module_base/global_function.cpp ../../../module_base/complexmatrix.cpp ../../../module_base/matrix.cpp ../../../module_base/complexarray.cpp ../../../module_base/tool_quit.cpp ../../../module_base/realarray.cpp LIBS ${math_libs} formatter