From 49d6afa218e4759e61994420d58a58cc94b0b39e Mon Sep 17 00:00:00 2001 From: Yu Liu <77716030+YuLiu98@users.noreply.github.com> Date: Sat, 12 Oct 2024 13:54:25 +0800 Subject: [PATCH 1/3] Fix: md restart can not read STRU (#5215) * Refactor: rename conv_elec to conv_esolver * Refactor: move some print func to Module_IO * Fix: md restart can not read STRU * Fix: read STRU in md restart * [pre-commit.ci lite] apply automatic fixes * Tests: update tests --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- source/driver.cpp | 2 +- source/module_esolver/esolver.h | 7 +- source/module_esolver/esolver_fp.cpp | 13 +--- source/module_esolver/esolver_fp.h | 5 -- source/module_esolver/esolver_ks.cpp | 69 +++++-------------- source/module_esolver/esolver_ks.h | 14 +--- source/module_esolver/esolver_ks_lcao.cpp | 16 ++--- .../module_esolver/esolver_ks_lcao_tddft.cpp | 12 ++-- source/module_esolver/esolver_ks_lcaopw.cpp | 8 +-- source/module_esolver/esolver_ks_pw.cpp | 2 +- source/module_esolver/esolver_of.cpp | 10 +-- source/module_esolver/esolver_of_tool.cpp | 2 +- source/module_io/output_log.cpp | 13 +++- source/module_io/output_log.h | 11 ++- source/module_io/print_info.cpp | 36 +++++----- source/module_io/print_info.h | 26 +++---- source/module_io/read_input_item_system.cpp | 4 -- source/module_io/read_set_globalv.cpp | 13 +--- source/module_io/test/outputlog_test.cpp | 4 +- source/module_io/test/print_info_test.cpp | 43 +++++------- source/module_lr/esolver_lrtd_lcao.cpp | 2 +- source/module_md/md_base.cpp | 2 +- source/module_md/run_md.cpp | 2 +- source/module_relax/relax_driver.cpp | 4 +- tests/integrate/701_LJ_MD_NVE/INPUT | 5 +- tests/integrate/701_LJ_MD_NVE/Restart_md.dat | 2 + tests/integrate/701_LJ_MD_NVE/STRU | 49 ------------- tests/integrate/701_LJ_MD_NVE/STRU_MD_155 | 49 +++++++++++++ tests/integrate/701_LJ_MD_NVE/result.ref | 10 +-- tests/integrate/701_LJ_MD_rescale_v/INPUT | 4 +- .../OUT.autotest/Restart_md.dat | 2 + .../OUT.autotest/STRU/STRU_MD_10 | 49 +++++++++++++ tests/integrate/701_LJ_MD_rescale_v/STRU | 49 ------------- .../integrate/701_LJ_MD_rescale_v/result.ref | 11 +-- 34 files changed, 243 insertions(+), 307 deletions(-) create mode 100644 tests/integrate/701_LJ_MD_NVE/Restart_md.dat delete mode 100644 tests/integrate/701_LJ_MD_NVE/STRU create mode 100644 tests/integrate/701_LJ_MD_NVE/STRU_MD_155 create mode 100644 tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/Restart_md.dat create mode 100644 tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/STRU/STRU_MD_10 delete mode 100644 tests/integrate/701_LJ_MD_rescale_v/STRU diff --git a/source/driver.cpp b/source/driver.cpp index db5d642585..c4490da862 100644 --- a/source/driver.cpp +++ b/source/driver.cpp @@ -41,7 +41,7 @@ void Driver::init() // (3) output information time_t time_finish = std::time(nullptr); - Print_Info::print_time(time_start, time_finish); + ModuleIO::print_time(time_start, time_finish); // (4) close all of the running logs ModuleBase::Global_File::close_all_log(GlobalV::MY_RANK, PARAM.inp.out_alllog,PARAM.inp.calculation); diff --git a/source/module_esolver/esolver.h b/source/module_esolver/esolver.h index 2ffeb1372f..f17b59ac35 100644 --- a/source/module_esolver/esolver.h +++ b/source/module_esolver/esolver.h @@ -58,11 +58,8 @@ class ESolver return 0; } - // get conv_elec used in current scf - virtual bool get_conv_elec() - { - return true; - } + bool conv_esolver = true; // whether esolver is converged + std::string classname; }; diff --git a/source/module_esolver/esolver_fp.cpp b/source/module_esolver/esolver_fp.cpp index 7bbf7888c1..7bb5c83f26 100644 --- a/source/module_esolver/esolver_fp.cpp +++ b/source/module_esolver/esolver_fp.cpp @@ -119,23 +119,14 @@ void ESolver_FP::before_all_runners(const Input_para& inp, UnitCell& cell) return; } -//------------------------------------------------------------------------------ -//! the 12th function of ESolver_KS: get_conv_elec -//! tqzhao add 2024-05-15 -//------------------------------------------------------------------------------ -bool ESolver_FP::get_conv_elec() -{ - return this->conv_elec; -} - //! Something to do after SCF iterations when SCF is converged or comes to the max iter step. void ESolver_FP::after_scf(const int istep) { // 0) output convergence information - ModuleIO::output_convergence_after_scf(this->conv_elec, this->pelec->f_en.etot); + ModuleIO::output_convergence_after_scf(this->conv_esolver, this->pelec->f_en.etot); // 1) write fermi energy - ModuleIO::output_efermi(this->conv_elec, this->pelec->eferm.ef); + ModuleIO::output_efermi(this->conv_esolver, this->pelec->eferm.ef); // 2) update delta rho for charge extrapolation CE.update_delta_rho(GlobalC::ucell, &(this->chr), &(this->sf)); diff --git a/source/module_esolver/esolver_fp.h b/source/module_esolver/esolver_fp.h index 4e60fa0aa8..fc9a5d8dec 100644 --- a/source/module_esolver/esolver_fp.h +++ b/source/module_esolver/esolver_fp.h @@ -44,9 +44,6 @@ namespace ModuleESolver //! Initialize of the first-principels energy solver virtual void before_all_runners(const Input_para& inp, UnitCell& cell) override; - // get conv_elec used in current scf - virtual bool get_conv_elec() override; - virtual void init_after_vc(const Input_para& inp, UnitCell& cell); // liuyu add 2023-03-09 //! Electronic states @@ -64,8 +61,6 @@ namespace ModuleESolver //! K points in Brillouin zone K_Vectors kv; - bool conv_elec; // If electron density is converged in scf. - protected: //! Something to do after SCF iterations when SCF is converged or comes to the max iter step. virtual void after_scf(const int istep); diff --git a/source/module_esolver/esolver_ks.cpp b/source/module_esolver/esolver_ks.cpp index 6ae66c76f3..78163a9301 100644 --- a/source/module_esolver/esolver_ks.cpp +++ b/source/module_esolver/esolver_ks.cpp @@ -7,11 +7,12 @@ #include #endif #include "module_base/timer.h" +#include "module_cell/cal_atoms_info.h" #include "module_io/json_output/init_info.h" +#include "module_io/output_log.h" #include "module_io/print_info.h" #include "module_io/write_istate_info.h" #include "module_parameter/parameter.h" -#include "module_cell/cal_atoms_info.h" #include //--------------Temporary---------------- @@ -221,7 +222,7 @@ void ESolver_KS::before_all_runners(const Input_para& inp, UnitCell& ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); //! 7) print information - Print_Info::setup_parameters(ucell, this->kv); + ModuleIO::setup_parameters(ucell, this->kv); //! 8) new plane wave basis, fft grids, etc. #ifdef __MPI @@ -419,7 +420,7 @@ void ESolver_KS::runner(const int istep, UnitCell& ucell) ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT SCF"); bool firstscf = true; - this->conv_elec = false; + this->conv_esolver = false; this->niter = this->maxniter; // 4) SCF iterations @@ -429,7 +430,7 @@ void ESolver_KS::runner(const int istep, UnitCell& ucell) for (int iter = 1; iter <= this->maxniter; ++iter) { // 5) write head - this->write_head(GlobalV::ofs_running, istep, iter); + ModuleIO::write_head(GlobalV::ofs_running, istep, iter, this->basisname); #ifdef __MPI auto iterstart = MPI_Wtime(); @@ -496,9 +497,9 @@ void ESolver_KS::runner(const int istep, UnitCell& ucell) PARAM.inp.esolver_type, diag_ethr, PARAM.inp.nelec); - + // The error of HSolver is larger than drho, - // so a more precise HSolver should be excuconv_elected. + // so a more precise HSolver should be executed. if (hsolver_error > drho) { diag_ethr = hsolver::reset_diag_ethr(GlobalV::ofs_running, @@ -540,11 +541,11 @@ void ESolver_KS::runner(const int istep, UnitCell& ucell) } #endif - this->conv_elec = (drho < this->scf_thr && not_restart_step && is_U_converged); + this->conv_esolver = (drho < this->scf_thr && not_restart_step && is_U_converged); // If drho < hsolver_error in the first iter or drho < scf_thr, we // do not change rho. - if (drho < hsolver_error || this->conv_elec) + if (drho < hsolver_error || this->conv_esolver) { if (drho < hsolver_error) { @@ -577,13 +578,13 @@ void ESolver_KS::runner(const int istep, UnitCell& ucell) } #ifdef __MPI MPI_Bcast(&drho, 1, MPI_DOUBLE, 0, PARAPW_WORLD); - MPI_Bcast(&this->conv_elec, 1, MPI_DOUBLE, 0, PARAPW_WORLD); + MPI_Bcast(&this->conv_esolver, 1, MPI_DOUBLE, 0, PARAPW_WORLD); MPI_Bcast(pelec->charge->rho[0], this->pw_rhod->nrxx, MPI_DOUBLE, 0, PARAPW_WORLD); #endif // 9) update potential // Hamilt should be used after it is constructed. - // this->phamilt->update(conv_elec); + // this->phamilt->update(conv_esolver); this->update_pot(istep, iter); // 10) finish scf iterations @@ -617,7 +618,7 @@ void ESolver_KS::runner(const int istep, UnitCell& ucell) #endif //__RAPIDJSON // 13) check convergence - if (this->conv_elec) + if (this->conv_esolver) { this->niter = iter; break; @@ -632,7 +633,7 @@ void ESolver_KS::runner(const int istep, UnitCell& ucell) std::cout << " >> Leave SCF iteration.\n * * * * * *" << std::endl; #ifdef __RAPIDJSON // 14) add Json of efermi energy converge - Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_elec); + Json::add_output_efermi_converge(this->pelec->eferm.ef * ModuleBase::Ry_to_eV, this->conv_esolver); #endif //__RAPIDJSON // 15) after scf @@ -666,9 +667,9 @@ void ESolver_KS::iter_finish(int& iter) this->pelec->f_en.etot_old = this->pelec->f_en.etot; // add a energy threshold for SCF convergence - if (this->conv_elec == 0) // only check when density is not converged + if (this->conv_esolver == 0) // only check when density is not converged { - this->conv_elec + this->conv_esolver = (iter != 1 && std::abs(this->pelec->f_en.etot_delta * ModuleBase::Ry_to_eV) < this->scf_ene_thr); } } @@ -687,33 +688,6 @@ void ESolver_KS::after_scf(const int istep) } } -//------------------------------------------------------------------------------ -//! the 8th function of ESolver_KS: print_head -//! mohan add 2024-05-12 -//------------------------------------------------------------------------------ -template -void ESolver_KS::print_head() -{ - std::cout << " " << std::setw(7) << "ITER"; - - if (PARAM.inp.nspin == 2) - { - std::cout << std::setw(10) << "TMAG"; - std::cout << std::setw(10) << "AMAG"; - } - - std::cout << std::setw(15) << "ETOT(eV)"; - std::cout << std::setw(15) << "EDIFF(eV)"; - std::cout << std::setw(11) << "DRHO"; - - if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5) - { - std::cout << std::setw(11) << "DKIN"; - } - - std::cout << std::setw(11) << "TIME(s)" << std::endl; -} - //------------------------------------------------------------------------------ //! the 8th function of ESolver_KS: print_iter //! mohan add 2024-05-12 @@ -725,18 +699,7 @@ void ESolver_KS::print_iter(const int iter, const double duration, const double ethr) { - this->pelec->print_etot(this->conv_elec, iter, drho, dkin, duration, PARAM.inp.printe, ethr); -} - -//------------------------------------------------------------------------------ -//! the 9th function of ESolver_KS: write_head -//! mohan add 2024-05-12 -//------------------------------------------------------------------------------ -template -void ESolver_KS::write_head(std::ofstream& ofs_running, const int istep, const int iter) -{ - ofs_running << "\n " << this->basisname << " ALGORITHM --------------- ION=" << std::setw(4) << istep + 1 - << " ELEC=" << std::setw(4) << iter << "--------------------------------\n"; + this->pelec->print_etot(this->conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, ethr); } //------------------------------------------------------------------------------ diff --git a/source/module_esolver/esolver_ks.h b/source/module_esolver/esolver_ks.h index c541b5e074..db3f33ceb3 100644 --- a/source/module_esolver/esolver_ks.h +++ b/source/module_esolver/esolver_ks.h @@ -73,12 +73,7 @@ class ESolver_KS : public ESolver_FP virtual void update_pot(const int istep, const int iter) {}; protected: - - // Print the headline on the screen: - // ITER ETOT(eV) EDIFF(eV) DRHO TIME(s) - void print_head(); - - // Print inforamtion in each iter + // Print inforamtion in each iter // G1 -3.435545e+03 0.000000e+00 3.607e-01 2.862e-01 // for metaGGA // ITER ETOT(eV) EDIFF(eV) DRHO DKIN TIME(s) @@ -90,13 +85,6 @@ class ESolver_KS : public ESolver_FP const double duration, const double ethr); - // Write the headline in the running_log file - // "PW/LCAO" ALGORITHM --------------- ION= 1 ELEC= 1-------------------------------- - void write_head( - std::ofstream& ofs_running, - const int istep, - const int iter); - //! Hamiltonian hamilt::Hamilt* p_hamilt = nullptr; diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index 6ada51bfe2..e9ea986d7e 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -136,7 +136,7 @@ void ESolver_KS_LCAO::before_all_runners(const Input_para& inp, UnitCell this->kv.set(ucell.symm, PARAM.inp.kpoint_file, PARAM.inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); - Print_Info::setup_parameters(ucell, this->kv); + ModuleIO::setup_parameters(ucell, this->kv); } else { @@ -817,7 +817,7 @@ void ESolver_KS_LCAO::update_pot(const int istep, const int iter) ModuleBase::TITLE("ESolver_KS_LCAO", "update_pot"); // 1) print Hamiltonian and Overlap matrix - if (this->conv_elec || iter == PARAM.inp.scf_nmax) + if (this->conv_esolver || iter == PARAM.inp.scf_nmax) { if (!PARAM.globalv.gamma_only_local && (PARAM.inp.out_mat_hs[0] || PARAM.inp.deepks_v_delta)) { @@ -875,7 +875,7 @@ void ESolver_KS_LCAO::update_pot(const int istep, const int iter) } // 2) print wavefunctions - if (elecstate::ElecStateLCAO::out_wfc_lcao && (this->conv_elec || iter == PARAM.inp.scf_nmax) + if (elecstate::ElecStateLCAO::out_wfc_lcao && (this->conv_esolver || iter == PARAM.inp.scf_nmax) && (istep % PARAM.inp.out_interval == 0)) { ModuleIO::write_wfc_nao(elecstate::ElecStateLCAO::out_wfc_lcao, @@ -887,7 +887,7 @@ void ESolver_KS_LCAO::update_pot(const int istep, const int iter) istep); } - if (!this->conv_elec) + if (!this->conv_esolver) { if (PARAM.inp.nspin == 4) { @@ -977,7 +977,7 @@ void ESolver_KS_LCAO::iter_finish(int& iter) } } - if (GlobalC::exx_info.info_global.cal_exx && this->conv_elec) + if (GlobalC::exx_info.info_global.cal_exx && this->conv_esolver) { // Kerker mixing does not work for the density matrix. // In the separate loop case, it can still work in the subsequent inner loops where Hexx(DM) is fixed. @@ -989,7 +989,7 @@ void ESolver_KS_LCAO::iter_finish(int& iter) } if (GlobalC::exx_info.info_ri.real_number) { - this->conv_elec = this->exd->exx_after_converge( + this->conv_esolver = this->exd->exx_after_converge( *this->p_hamilt, *dynamic_cast*>(this->pelec)->get_DM(), this->kv, @@ -1000,7 +1000,7 @@ void ESolver_KS_LCAO::iter_finish(int& iter) } else { - this->conv_elec = this->exc->exx_after_converge( + this->conv_esolver = this->exc->exx_after_converge( *this->p_hamilt, *dynamic_cast*>(this->pelec)->get_DM(), this->kv, @@ -1080,7 +1080,7 @@ void ESolver_KS_LCAO::iter_finish(int& iter) } // 6) use the converged occupation matrix for next MD/Relax SCF calculation - if (PARAM.inp.dft_plus_u && this->conv_elec) + if (PARAM.inp.dft_plus_u && this->conv_esolver) { GlobalC::dftu.initialed_locale = true; } diff --git a/source/module_esolver/esolver_ks_lcao_tddft.cpp b/source/module_esolver/esolver_ks_lcao_tddft.cpp index 976501980b..dd32335ebf 100644 --- a/source/module_esolver/esolver_ks_lcao_tddft.cpp +++ b/source/module_esolver/esolver_ks_lcao_tddft.cpp @@ -233,7 +233,7 @@ void ESolver_KS_LCAO_TDDFT::hamilt2density(const int istep, const int iter, cons void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter) { // print Hamiltonian and Overlap matrix - if (this->conv_elec) + if (this->conv_esolver) { if (!PARAM.globalv.gamma_only_local) { @@ -282,8 +282,8 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter) } } - if (elecstate::ElecStateLCAO>::out_wfc_lcao && (this->conv_elec || iter == PARAM.inp.scf_nmax) - && (istep % PARAM.inp.out_interval == 0)) + if (elecstate::ElecStateLCAO>::out_wfc_lcao + && (this->conv_esolver || iter == PARAM.inp.scf_nmax) && (istep % PARAM.inp.out_interval == 0)) { ModuleIO::write_wfc_nao(elecstate::ElecStateLCAO>::out_wfc_lcao, this->psi[0], @@ -295,7 +295,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter) } // Calculate new potential according to new Charge Density - if (!this->conv_elec) + if (!this->conv_esolver) { if (PARAM.inp.nspin == 4) { @@ -316,7 +316,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter) const int nlocal = PARAM.globalv.nlocal; // store wfc and Hk laststep - if (istep >= (wf.init_wfc == "file" ? 0 : 1) && this->conv_elec) + if (istep >= (wf.init_wfc == "file" ? 0 : 1) && this->conv_esolver) { if (this->psi_laststep == nullptr) { @@ -378,7 +378,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter) } // print "eigen value" for tddft - if (this->conv_elec) + if (this->conv_esolver) { GlobalV::ofs_running << "---------------------------------------------------------------" "---------------------------------" diff --git a/source/module_esolver/esolver_ks_lcaopw.cpp b/source/module_esolver/esolver_ks_lcaopw.cpp index a5869c4a57..4bc9451941 100644 --- a/source/module_esolver/esolver_ks_lcaopw.cpp +++ b/source/module_esolver/esolver_ks_lcaopw.cpp @@ -197,7 +197,7 @@ namespace ModuleESolver ESolver_KS_PW::iter_finish(iter); #ifdef __EXX - if (GlobalC::exx_info.info_global.cal_exx && this->conv_elec) + if (GlobalC::exx_info.info_global.cal_exx && this->conv_esolver) { // no separate_loop case if (!GlobalC::exx_info.info_global.separate_loop) @@ -215,7 +215,7 @@ namespace ModuleESolver iter = 0; std::cout << " Entering 2nd SCF, where EXX is updated" << std::endl; this->two_level_step++; - this->conv_elec = false; + this->conv_esolver = false; } } // has separate_loop case @@ -223,7 +223,7 @@ namespace ModuleESolver else if (this->two_level_step == GlobalC::exx_info.info_global.hybrid_step || (iter == 1 && this->two_level_step != 0)) { - this->conv_elec = true; + this->conv_esolver = true; } else { @@ -247,7 +247,7 @@ namespace ModuleESolver << (double)(t_end.tv_sec - t_start.tv_sec) + (double)(t_end.tv_usec - t_start.tv_usec) / 1000000.0 << std::defaultfloat << " (s)" << std::endl; - this->conv_elec = false; + this->conv_esolver = false; } } #endif diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index 4deedeba39..31bd90d9dc 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -432,7 +432,7 @@ void ESolver_KS_PW::hamilt2density(const int istep, const int iter, c template void ESolver_KS_PW::update_pot(const int istep, const int iter) { - if (!this->conv_elec) + if (!this->conv_esolver) { if (PARAM.inp.nspin == 4) { diff --git a/source/module_esolver/esolver_of.cpp b/source/module_esolver/esolver_of.cpp index 8c7f54509c..a3bb656efd 100644 --- a/source/module_esolver/esolver_of.cpp +++ b/source/module_esolver/esolver_of.cpp @@ -92,7 +92,7 @@ void ESolver_OF::before_all_runners(const Input_para& inp, UnitCell& ucell) // print information // mohan add 2021-01-30 - Print_Info::setup_parameters(ucell, kv); + ModuleIO::setup_parameters(ucell, kv); // initialize the real-space uniform grid for FFT and parallel // distribution of plane waves @@ -455,7 +455,7 @@ void ESolver_OF::update_rho() */ bool ESolver_OF::check_exit() { - this->conv_elec = false; + this->conv_esolver = false; bool potConv = false; bool potHold = false; // if normdLdphi nearly remains unchanged bool energyConv = false; @@ -476,12 +476,12 @@ bool ESolver_OF::check_exit() energyConv = true; } - this->conv_elec = (this->of_conv_ == "energy" && energyConv) || (this->of_conv_ == "potential" && potConv) - || (this->of_conv_ == "both" && potConv && energyConv); + this->conv_esolver = (this->of_conv_ == "energy" && energyConv) || (this->of_conv_ == "potential" && potConv) + || (this->of_conv_ == "both" && potConv && energyConv); this->print_info(); - if (this->conv_elec || this->iter_ >= this->max_iter_) + if (this->conv_esolver || this->iter_ >= this->max_iter_) { return true; } diff --git a/source/module_esolver/esolver_of_tool.cpp b/source/module_esolver/esolver_of_tool.cpp index 5d307bff1f..6e81ad33a6 100644 --- a/source/module_esolver/esolver_of_tool.cpp +++ b/source/module_esolver/esolver_of_tool.cpp @@ -431,7 +431,7 @@ void ESolver_OF::print_info() std::vector energies_Ry; std::vector energies_eV; if (PARAM.inp.printe > 0 - && ((this->iter_ + 1) % PARAM.inp.printe == 0 || this->conv_elec || this->iter_ == PARAM.inp.scf_nmax)) + && ((this->iter_ + 1) % PARAM.inp.printe == 0 || this->conv_esolver || this->iter_ == PARAM.inp.scf_nmax)) { titles.push_back("E_Total"); energies_Ry.push_back(this->pelec->f_en.etot); diff --git a/source/module_io/output_log.cpp b/source/module_io/output_log.cpp index 9913f6ec89..191dc413a2 100644 --- a/source/module_io/output_log.cpp +++ b/source/module_io/output_log.cpp @@ -21,9 +21,9 @@ void output_convergence_after_scf(bool& convergence, double& energy, std::ofstre } } -void output_after_relax(bool conv_ion, bool conv_elec, std::ofstream& ofs_running) +void output_after_relax(bool conv_ion, bool conv_esolver, std::ofstream& ofs_running) { - if (conv_ion && !conv_elec) + if (conv_ion && !conv_esolver) { std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl; std::cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" << std::endl; @@ -246,7 +246,8 @@ void print_force(std::ofstream& ofs_running, fmt << atom_label << force_x << force_y << force_z; table = fmt.str(); ofs_running << table << std::endl; - if (PARAM.inp.test_force) std::cout << table << std::endl; + if (PARAM.inp.test_force) { std::cout << table << std::endl; +} } void print_stress(const std::string& name, const ModuleBase::matrix& scs, const bool screen, const bool ry) { @@ -304,4 +305,10 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs, const return; } +void write_head(std::ofstream& ofs_running, const int& istep, const int& iter, const std::string& basisname) +{ + ofs_running << "\n " << basisname << " ALGORITHM --------------- ION=" << std::setw(4) << istep + 1 + << " ELEC=" << std::setw(4) << iter << "--------------------------------\n"; +} + }// namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/output_log.h b/source/module_io/output_log.h index 5fb0c2227d..68c93ade9d 100644 --- a/source/module_io/output_log.h +++ b/source/module_io/output_log.h @@ -18,9 +18,9 @@ void output_convergence_after_scf(bool& convergence, double& energy, std::ofstre /// @brief output after relaxation /// @param conv_ion if is convergence for ions -/// @param conv_elec if is convergence for electrons +/// @param conv_esolver if is convergence for electrons /// @param ofs_running the output stream -void output_after_relax(bool conv_ion, bool conv_elec, std::ofstream& ofs_running = GlobalV::ofs_running); +void output_after_relax(bool conv_ion, bool conv_esolver, std::ofstream& ofs_running = GlobalV::ofs_running); /// @brief output the fermi energy /// @param convergence if is convergence @@ -66,6 +66,13 @@ void print_force(std::ofstream& ofs_running, /// @param ry true if the unit of force is a.u. void print_stress(const std::string& name, const ModuleBase::matrix& scs, const bool screen, const bool ry); +/// @brief write head for scf iteration +/// @param ofs_running output stream +/// @param istep the ion step +/// @param iter the scf iteration step +/// @param basisname basis set name +void write_head(std::ofstream& ofs_running, const int& istep, const int& iter, const std::string& basisname); + } // namespace ModuleIO #endif \ No newline at end of file diff --git a/source/module_io/print_info.cpp b/source/module_io/print_info.cpp index a89bf5d2d9..353782d95e 100644 --- a/source/module_io/print_info.cpp +++ b/source/module_io/print_info.cpp @@ -3,14 +3,12 @@ #include "module_base/global_variable.h" #include "module_parameter/parameter.h" -Print_Info::Print_Info(){} - -Print_Info::~Print_Info(){} - +namespace ModuleIO +{ -void Print_Info::setup_parameters(UnitCell &ucell, K_Vectors &kv) +void setup_parameters(UnitCell& ucell, K_Vectors& kv) { - ModuleBase::TITLE("Print_Info","setup_parameters"); + ModuleBase::TITLE("ModuleIO", "setup_parameters"); if(PARAM.inp.calculation=="scf" || PARAM.inp.calculation=="relax" || PARAM.inp.calculation=="cell-relax" || PARAM.inp.calculation=="nscf" || PARAM.inp.calculation=="get_pchg" || PARAM.inp.calculation=="get_wf" || PARAM.inp.calculation=="md") @@ -168,7 +166,7 @@ void Print_Info::setup_parameters(UnitCell &ucell, K_Vectors &kv) return; } -void Print_Info::print_time(time_t &time_start, time_t &time_finish) +void print_time(time_t& time_start, time_t& time_finish) { // print out information before ABACUS ends std::cout << "\n START Time : " << ctime(&time_start); @@ -189,7 +187,7 @@ void Print_Info::print_time(time_t &time_start, time_t &time_finish) } /* -void Print_Info::print_scf(const int &istep, const int &iter) +void ModuleIO::print_scf(const int &istep, const int &iter) { if(PARAM.inp.basis_type=="pw") { @@ -205,21 +203,21 @@ void Print_Info::print_scf(const int &istep, const int &iter) GlobalV::ofs_running << "ELEC = " << std::setw(4) << unsigned(iter); } else if(PARAM.inp.calculation=="relax" || PARAM.inp.calculation=="cell-relax") - { - GlobalV::ofs_running << "ION = " << std::setw(4) << unsigned(istep+1) - << " ELEC = " << std::setw(4) << unsigned(iter); - } - else if(PARAM.inp.calculation=="md") - { - GlobalV::ofs_running << "MD = " << std::setw(4) << unsigned(istep+1) - << " ELEC = " << std::setw(4) << unsigned(iter); - } + { + GlobalV::ofs_running << "ION = " << std::setw(4) << unsigned(istep+1) + << " ELEC = " << std::setw(4) << unsigned(iter); + } + else if(PARAM.inp.calculation=="md") + { + GlobalV::ofs_running << "MD = " << std::setw(4) << unsigned(istep+1) + << " ELEC = " << std::setw(4) << unsigned(iter); + } GlobalV::ofs_running << " --------------------------------\n"; } */ -void Print_Info::print_screen(const int &stress_step, const int &force_step, const int &istep) +void print_screen(const int& stress_step, const int& force_step, const int& istep) { std::cout << " -------------------------------------------" << std::endl; GlobalV::ofs_running << "\n -------------------------------------------" << std::endl; @@ -263,3 +261,5 @@ void Print_Info::print_screen(const int &stress_step, const int &force_step, con std::cout << " -------------------------------------------" << std::endl; GlobalV::ofs_running << " -------------------------------------------" << std::endl; } + +} // namespace ModuleIO \ No newline at end of file diff --git a/source/module_io/print_info.h b/source/module_io/print_info.h index e037e3533e..5a6683ff57 100644 --- a/source/module_io/print_info.h +++ b/source/module_io/print_info.h @@ -2,28 +2,22 @@ // AUTHOR : mohan // DATE : 2021-01-30 //========================================================== -#ifndef PRINT_INFO_H -#define PRINT_INFO_H +#ifndef PRINT_INFO +#define PRINT_INFO #include "module_base/timer.h" -#include "module_cell/unitcell.h" #include "module_cell/klist.h" -//#include "../module_cell/klist.h" +#include "module_cell/unitcell.h" -class Print_Info +namespace ModuleIO { - public: - - Print_Info(); - ~Print_Info(); - - // print out to screen about the readin parameters - static void setup_parameters(UnitCell &ucell, K_Vectors &kv); - static void print_time(time_t &time_start, time_t &time_finish); - static void print_scf(const int &istep, const int &iter); - static void print_screen(const int &stress_step, const int &force_step, const int &istep); +// print out to screen about the readin parameters +void setup_parameters(UnitCell& ucell, K_Vectors& kv); +void print_time(time_t& time_start, time_t& time_finish); +void print_scf(const int& istep, const int& iter); +void print_screen(const int& stress_step, const int& force_step, const int& istep); -}; +} // namespace ModuleIO #endif diff --git a/source/module_io/read_input_item_system.cpp b/source/module_io/read_input_item_system.cpp index cef9daa344..b701c2d80e 100644 --- a/source/module_io/read_input_item_system.cpp +++ b/source/module_io/read_input_item_system.cpp @@ -646,10 +646,6 @@ void ReadInput::item_system() { para.input.read_file_dir = "OUT." + para.input.suffix; } - else - { - para.input.read_file_dir = para.input.read_file_dir; - } para.input.read_file_dir = to_dir(para.input.read_file_dir); }; this->add_item(item); diff --git a/source/module_io/read_set_globalv.cpp b/source/module_io/read_set_globalv.cpp index 3579765add..b9a4dc00da 100644 --- a/source/module_io/read_set_globalv.cpp +++ b/source/module_io/read_set_globalv.cpp @@ -21,16 +21,9 @@ void ReadInput::set_globalv(Parameter& para) /// get the global output directory para.sys.global_matrix_dir = para.globalv.global_out_dir + "matrix/"; para.sys.global_matrix_dir = to_dir(para.sys.global_matrix_dir); - + /// get the global readin directory - if (para.inp.read_file_dir == "auto") - { - para.sys.global_readin_dir = para.globalv.global_out_dir; - } - else - { - para.sys.global_readin_dir = para.inp.read_file_dir + '/'; - } + para.sys.global_readin_dir = para.inp.read_file_dir + '/'; para.sys.global_readin_dir = to_dir(para.sys.global_readin_dir); /// get the stru file for md restart case @@ -38,7 +31,7 @@ void ReadInput::set_globalv(Parameter& para) { int istep = current_md_step(para.sys.global_readin_dir); - if (para.inp.read_file_dir == "auto") + if (para.inp.read_file_dir == to_dir("OUT." + para.input.suffix)) { para.sys.global_in_stru = para.sys.global_stru_dir + "STRU_MD_" + std::to_string(istep); } diff --git a/source/module_io/test/outputlog_test.cpp b/source/module_io/test/outputlog_test.cpp index 2e7a085f81..4dbb02e73e 100644 --- a/source/module_io/test/outputlog_test.cpp +++ b/source/module_io/test/outputlog_test.cpp @@ -90,9 +90,9 @@ TEST(OutputEfermiTest, TestConvergence) { TEST(OutputAfterRelaxTest, TestConvergence) { bool conv_ion = true; - bool conv_elec = false; + bool conv_esolver = false; std::ofstream ofs_running("test_output_after_relax.txt"); - ModuleIO::output_after_relax(conv_ion, conv_elec, ofs_running); + ModuleIO::output_after_relax(conv_ion, conv_esolver, ofs_running); ofs_running.close(); std::ifstream ifs_running("test_output_after_relax.txt"); diff --git a/source/module_io/test/print_info_test.cpp b/source/module_io/test/print_info_test.cpp index 7c2a255a8e..f4e96f2e16 100644 --- a/source/module_io/test/print_info_test.cpp +++ b/source/module_io/test/print_info_test.cpp @@ -60,11 +60,6 @@ class PrintInfoTest : public testing::Test } }; -TEST_F(PrintInfoTest, Constructor) -{ - EXPECT_NO_THROW(Print_Info pinfo); -} - TEST_F(PrintInfoTest, SetupParameters) { UcellTestPrepare utp = UcellTestLib["Si"]; @@ -83,8 +78,8 @@ TEST_F(PrintInfoTest, SetupParameters) PARAM.sys.gamma_only_local = false; PARAM.input.calculation = cal_type[i]; testing::internal::CaptureStdout(); - EXPECT_NO_THROW(Print_Info::setup_parameters(*ucell,*kv)); - output = testing::internal::GetCapturedStdout(); + EXPECT_NO_THROW(ModuleIO::setup_parameters(*ucell, *kv)); + output = testing::internal::GetCapturedStdout(); if(PARAM.input.calculation == "scf") { EXPECT_THAT(output,testing::HasSubstr("Self-consistent calculations")); @@ -106,7 +101,7 @@ TEST_F(PrintInfoTest, SetupParameters) { PARAM.input.mdp.md_type = md_types[j]; testing::internal::CaptureStdout(); - EXPECT_NO_THROW(Print_Info::setup_parameters(*ucell,*kv)); + EXPECT_NO_THROW(ModuleIO::setup_parameters(*ucell, *kv)); output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("Molecular Dynamics simulations")); if (PARAM.mdp.md_type == "fire") @@ -141,8 +136,8 @@ TEST_F(PrintInfoTest, SetupParameters) { PARAM.input.basis_type = basis_type[i]; testing::internal::CaptureStdout(); - EXPECT_NO_THROW(Print_Info::setup_parameters(*ucell,*kv)); - output = testing::internal::GetCapturedStdout(); + EXPECT_NO_THROW(ModuleIO::setup_parameters(*ucell, *kv)); + output = testing::internal::GetCapturedStdout(); if(PARAM.input.basis_type == "lcao") { EXPECT_THAT(output,testing::HasSubstr("Use Systematically Improvable Atomic bases")); @@ -170,22 +165,22 @@ TEST_F(PrintInfoTest, PrintScreen) if(PARAM.input.calculation=="scf") { testing::internal::CaptureStdout(); - Print_Info::print_screen(stress_step,force_step,istep); - output = testing::internal::GetCapturedStdout(); + ModuleIO::print_screen(stress_step, force_step, istep); + output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("SELF-CONSISTENT")); } else if(PARAM.input.calculation=="nscf") { testing::internal::CaptureStdout(); - Print_Info::print_screen(stress_step,force_step,istep); - output = testing::internal::GetCapturedStdout(); + ModuleIO::print_screen(stress_step, force_step, istep); + output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("NONSELF-CONSISTENT")); } else if(PARAM.input.calculation=="md") { testing::internal::CaptureStdout(); - Print_Info::print_screen(stress_step,force_step,istep); - output = testing::internal::GetCapturedStdout(); + ModuleIO::print_screen(stress_step, force_step, istep); + output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("STEP OF MOLECULAR DYNAMICS")); } else @@ -194,22 +189,22 @@ TEST_F(PrintInfoTest, PrintScreen) if(PARAM.input.calculation=="relax") { testing::internal::CaptureStdout(); - Print_Info::print_screen(stress_step,force_step,istep); - output = testing::internal::GetCapturedStdout(); + ModuleIO::print_screen(stress_step, force_step, istep); + output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("STEP OF ION RELAXATION")); } else if(PARAM.input.calculation=="cell-relax") { testing::internal::CaptureStdout(); - Print_Info::print_screen(stress_step,force_step,istep); - output = testing::internal::GetCapturedStdout(); + ModuleIO::print_screen(stress_step, force_step, istep); + output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("RELAX CELL")); EXPECT_THAT(output,testing::HasSubstr("RELAX IONS")); } PARAM.input.relax_new = true; testing::internal::CaptureStdout(); - Print_Info::print_screen(stress_step,force_step,istep); - output = testing::internal::GetCapturedStdout(); + ModuleIO::print_screen(stress_step, force_step, istep); + output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("STEP OF RELAXATION")); } } @@ -220,8 +215,8 @@ TEST_F(PrintInfoTest, PrintTime) time_t time_start = std::time(nullptr); time_t time_finish = std::time(nullptr); testing::internal::CaptureStdout(); - EXPECT_NO_THROW(Print_Info::print_time(time_start,time_finish)); - output = testing::internal::GetCapturedStdout(); + EXPECT_NO_THROW(ModuleIO::print_time(time_start, time_finish)); + output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output,testing::HasSubstr("START Time")); EXPECT_THAT(output,testing::HasSubstr("FINISH Time")); EXPECT_THAT(output,testing::HasSubstr("TOTAL Time")); diff --git a/source/module_lr/esolver_lrtd_lcao.cpp b/source/module_lr/esolver_lrtd_lcao.cpp index 4c87eadb40..806c0b628a 100644 --- a/source/module_lr/esolver_lrtd_lcao.cpp +++ b/source/module_lr/esolver_lrtd_lcao.cpp @@ -245,7 +245,7 @@ LR::ESolver_LR::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu } this->kv.set(ucell.symm, PARAM.inp.kpoint_file, PARAM.inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); - Print_Info::setup_parameters(ucell, this->kv); + ModuleIO::setup_parameters(ucell, this->kv); this->parameter_check(); diff --git a/source/module_md/md_base.cpp b/source/module_md/md_base.cpp index f7503db7d5..30e344dbe2 100644 --- a/source/module_md/md_base.cpp +++ b/source/module_md/md_base.cpp @@ -60,7 +60,7 @@ void MD_base::setup(ModuleESolver::ESolver* p_esolver, const std::string& global restart(global_readin_dir); } - Print_Info::print_screen(0, 0, step_ + step_rst_); + ModuleIO::print_screen(0, 0, step_ + step_rst_); MD_func::force_virial(p_esolver, step_, ucell, potential, force, cal_stress, virial); MD_func::compute_stress(ucell, vel, allmass, cal_stress, virial, stress); diff --git a/source/module_md/run_md.cpp b/source/module_md/run_md.cpp index 34f1f4152a..1f85525979 100644 --- a/source/module_md/run_md.cpp +++ b/source/module_md/run_md.cpp @@ -55,7 +55,7 @@ void md_line(UnitCell& unit_in, ModuleESolver::ESolver* p_esolver, const Paramet } else { - Print_Info::print_screen(0, 0, mdrun->step_ + mdrun->step_rst_); + ModuleIO::print_screen(0, 0, mdrun->step_ + mdrun->step_rst_); mdrun->first_half(GlobalV::ofs_running); /// update force and virial due to the update of atom positions diff --git a/source/module_relax/relax_driver.cpp b/source/module_relax/relax_driver.cpp index 43bc2f51b7..9806ea975c 100644 --- a/source/module_relax/relax_driver.cpp +++ b/source/module_relax/relax_driver.cpp @@ -40,7 +40,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver) || PARAM.inp.calculation == "nscf") && (PARAM.inp.esolver_type != "lr")) { - Print_Info::print_screen(stress_step, force_step, istep); + ModuleIO::print_screen(stress_step, force_step, istep); } #ifdef __RAPIDJSON @@ -129,7 +129,7 @@ void Relax_Driver::relax_driver(ModuleESolver::ESolver* p_esolver) "data_?"); } - ModuleIO::output_after_relax(stop, p_esolver->get_conv_elec(), GlobalV::ofs_running); + ModuleIO::output_after_relax(stop, p_esolver->conv_esolver, GlobalV::ofs_running); } #ifdef __RAPIDJSON diff --git a/tests/integrate/701_LJ_MD_NVE/INPUT b/tests/integrate/701_LJ_MD_NVE/INPUT index 619aa642be..9673def0f2 100644 --- a/tests/integrate/701_LJ_MD_NVE/INPUT +++ b/tests/integrate/701_LJ_MD_NVE/INPUT @@ -15,9 +15,12 @@ cal_force 1 cal_stress 1 #Parameters (MD) -md_nstep 5 +md_nstep 160 md_type nve md_dt 1 md_tfirst 300 init_vel 1 + +md_restart 1 +read_file_dir . diff --git a/tests/integrate/701_LJ_MD_NVE/Restart_md.dat b/tests/integrate/701_LJ_MD_NVE/Restart_md.dat new file mode 100644 index 0000000000..d00a745855 --- /dev/null +++ b/tests/integrate/701_LJ_MD_NVE/Restart_md.dat @@ -0,0 +1,2 @@ +155 +0.000950045 diff --git a/tests/integrate/701_LJ_MD_NVE/STRU b/tests/integrate/701_LJ_MD_NVE/STRU deleted file mode 100644 index f1c0576192..0000000000 --- a/tests/integrate/701_LJ_MD_NVE/STRU +++ /dev/null @@ -1,49 +0,0 @@ -ATOMIC_SPECIES -He 4.0026 auto auto - -LATTICE_CONSTANT -1.889727 - -LATTICE_VECTORS - 10.0000000000 0.0000000000 0.0000000000 #latvec1 - 0.0000000000 10.0000000000 0.0000000000 #latvec2 - 0.0000000000 0.0000000000 10.0000000000 #latvec3 - -ATOMIC_POSITIONS -Cartesian - -He #label -0 #magnetism -32 #number of atoms - 0.0000000000 0.0000000000 0.0000000000 m 1 1 1 v 0.0003051236 -0.0001506039 0.0002563783 - 0.0000000000 0.0000000000 5.0000000000 m 1 1 1 v 0.0001330836 -0.0002844927 0.0004575604 - 0.0000000000 5.0000000000 0.0000000000 m 1 1 1 v -0.0007284395 0.0001278596 -0.0001116420 - 0.0000000000 5.0000000000 5.0000000000 m 1 1 1 v 0.0007317461 -0.0008538537 0.0001165929 - 5.0000000000 0.0000000000 0.0000000000 m 1 1 1 v 0.0002153406 0.0004818484 -0.0003425506 - 5.0000000000 0.0000000000 5.0000000000 m 1 1 1 v 0.0000115849 -0.0001553058 0.0001440467 - 5.0000000000 5.0000000000 0.0000000000 m 1 1 1 v -0.0005075296 -0.0001418554 0.0000517226 - 5.0000000000 5.0000000000 5.0000000000 m 1 1 1 v 0.0003532731 0.0002838795 -0.0005240855 - 2.5000000000 2.5000000000 0.0000000000 m 1 1 1 v 0.0007110217 0.0001188223 0.0000320587 - 2.5000000000 2.5000000000 5.0000000000 m 1 1 1 v 0.0000716800 -0.0002982750 0.0003924065 - 2.5000000000 7.5000000000 0.0000000000 m 1 1 1 v -0.0000446191 0.0005436754 -0.0000488239 - 2.5000000000 7.5000000000 5.0000000000 m 1 1 1 v 0.0002256764 -0.0005094877 -0.0002958008 - 7.5000000000 2.5000000000 0.0000000000 m 1 1 1 v -0.0000811382 -0.0003395719 -0.0003533055 - 7.5000000000 2.5000000000 5.0000000000 m 1 1 1 v 0.0001046891 0.0002627214 -0.0000768329 - 7.5000000000 7.5000000000 0.0000000000 m 1 1 1 v -0.0001263117 -0.0002867947 -0.0005880112 - 7.5000000000 7.5000000000 5.0000000000 m 1 1 1 v 0.0000051377 -0.0002585502 0.0005224161 - 2.5000000000 0.0000000000 2.5000000000 m 1 1 1 v -0.0000441228 0.0007354340 0.0000484884 - 2.5000000000 0.0000000000 7.5000000000 m 1 1 1 v -0.0003062640 -0.0000630593 0.0003011308 - 2.5000000000 5.0000000000 2.5000000000 m 1 1 1 v 0.0000156182 0.0000352305 -0.0002909118 - 2.5000000000 5.0000000000 7.5000000000 m 1 1 1 v 0.0002588185 0.0004562910 -0.0004669455 - 7.5000000000 0.0000000000 2.5000000000 m 1 1 1 v 0.0000836607 -0.0003527362 -0.0000237714 - 7.5000000000 0.0000000000 7.5000000000 m 1 1 1 v 0.0002682220 0.0003310257 -0.0001488492 - 7.5000000000 5.0000000000 2.5000000000 m 1 1 1 v -0.0001893987 0.0001038739 -0.0003576744 - 7.5000000000 5.0000000000 7.5000000000 m 1 1 1 v 0.0003881776 0.0001685539 0.0000718978 - 0.0000000000 2.5000000000 2.5000000000 m 1 1 1 v 0.0000439981 0.0003058987 -0.0000061514 - 0.0000000000 2.5000000000 7.5000000000 m 1 1 1 v 0.0001835450 -0.0001686670 0.0004810819 - 0.0000000000 7.5000000000 2.5000000000 m 1 1 1 v -0.0000043640 0.0001908703 0.0000007071 - 0.0000000000 7.5000000000 7.5000000000 m 1 1 1 v -0.0006477776 0.0006839538 -0.0003073223 - 5.0000000000 2.5000000000 2.5000000000 m 1 1 1 v 0.0001909232 -0.0005588096 0.0004036625 - 5.0000000000 2.5000000000 7.5000000000 m 1 1 1 v -0.0003495156 -0.0001304327 -0.0005131768 - 5.0000000000 7.5000000000 2.5000000000 m 1 1 1 v -0.0004054115 -0.0002425928 0.0005518707 - 5.0000000000 7.5000000000 7.5000000000 m 1 1 1 v -0.0008664276 -0.0000348499 0.0006238335 diff --git a/tests/integrate/701_LJ_MD_NVE/STRU_MD_155 b/tests/integrate/701_LJ_MD_NVE/STRU_MD_155 new file mode 100644 index 0000000000..e268f33c16 --- /dev/null +++ b/tests/integrate/701_LJ_MD_NVE/STRU_MD_155 @@ -0,0 +1,49 @@ +ATOMIC_SPECIES +He 4.0026 auto auto + +LATTICE_CONSTANT +1.8897270000 + +LATTICE_VECTORS + 10.0000000000 0.0000000000 0.0000000000 + 0.0000000000 10.0000000000 0.0000000000 + 0.0000000000 0.0000000000 10.0000000000 + +ATOMIC_POSITIONS +Cartesian + +He #label +0.0000 #magnetism +32 #number of atoms + 0.2326403411 0.1805586531 9.8262424108 m 1 1 1 v -0.0000121378 -0.0002237088 -0.0000117252 + 0.1290011046 9.8675255727 5.1196032873 m 1 1 1 v -0.0001472165 -0.0001030776 0.0001218950 + 9.9328123711 4.7424879243 0.1127761048 m 1 1 1 v 0.0000533903 0.0000737924 -0.0001002520 + 0.0883359764 5.0466198180 4.9376340225 m 1 1 1 v 0.0000114005 0.0000308851 -0.0002758447 + 5.1567286276 9.6701708077 0.0720605175 m 1 1 1 v 0.0000797853 -0.0002910361 0.0002806497 + 4.9729770896 0.2523099247 4.8249429749 m 1 1 1 v -0.0000454343 -0.0002134570 0.0000906867 + 5.0259271309 5.0195597999 0.1284189796 m 1 1 1 v -0.0000736120 -0.0002625762 -0.0000325229 + 5.0845526566 4.9911110707 5.2224341707 m 1 1 1 v 0.0001394765 -0.0000715475 0.0002598028 + 2.3762114831 2.5329743364 0.0010311292 m 1 1 1 v 0.0001722709 0.0002976706 -0.0003480793 + 2.3308490267 2.5334843809 5.1084963341 m 1 1 1 v 0.0003107598 -0.0000490207 0.0000608596 + 2.6425636904 7.4014841094 9.6818561372 m 1 1 1 v -0.0000440260 0.0000306772 -0.0001045476 + 2.7555043799 7.4958096690 4.9663551309 m 1 1 1 v 0.0001676051 -0.0001407551 0.0000374823 + 7.5498978773 2.4019404441 9.9051437743 m 1 1 1 v -0.0000404775 -0.0004937666 -0.0002417073 + 7.0878872794 2.6398358481 5.2207704373 m 1 1 1 v 0.0000446631 -0.0001111729 0.0002772739 + 7.6306348110 7.2523052857 0.1879671715 m 1 1 1 v -0.0002650167 0.0000223905 0.0004208865 + 7.5019632892 7.7167191447 4.8113372067 m 1 1 1 v 0.0001431757 0.0001818078 -0.0004933417 + 2.4827381044 9.9093725459 2.3803925949 m 1 1 1 v 0.0004335723 0.0003136178 -0.0000374626 + 2.5667822143 0.1172638315 7.4599516344 m 1 1 1 v 0.0000840626 -0.0000288634 -0.0001960829 + 2.3506570501 5.2876910311 2.4783194446 m 1 1 1 v -0.0005280147 0.0005108524 -0.0002761533 + 2.4266156895 4.8469473963 7.4585069415 m 1 1 1 v -0.0002227251 0.0000553886 -0.0002414346 + 7.4978278440 0.2186955512 2.2854682214 m 1 1 1 v 0.0002061109 0.0000125043 -0.0001318463 + 7.4306464470 9.7982198196 7.5197935505 m 1 1 1 v -0.0001547693 0.0003731227 0.0002641078 + 7.5050495358 4.8100482242 2.7557225603 m 1 1 1 v 0.0005099203 -0.0001534080 -0.0002708300 + 7.5827553390 5.0825896221 7.6133407395 m 1 1 1 v -0.0002026006 -0.0004137035 -0.0000968275 + 0.0639279225 2.3314295584 2.8919146960 m 1 1 1 v -0.0003352759 -0.0002671850 0.0002228256 + 9.7059574272 2.4001848236 7.1843159676 m 1 1 1 v -0.0000842986 -0.0000802494 0.0002060414 + 0.1537051705 7.7328815133 2.2300281961 m 1 1 1 v 0.0000627880 0.0000878973 -0.0001059948 + 0.0336716230 7.5802323444 7.3828898964 m 1 1 1 v -0.0000501165 0.0000290086 0.0001592017 + 4.7535864052 2.6546520439 2.3575869556 m 1 1 1 v -0.0001280401 -0.0001046688 0.0001303011 + 4.9143288348 2.3613176229 7.4999150246 m 1 1 1 v -0.0000822629 0.0002548092 0.0001181581 + 4.9937745538 7.3933612435 2.7335288627 m 1 1 1 v 0.0001275830 0.0002930131 0.0000222267 + 5.0394893823 7.7302156995 7.6412539073 m 1 1 1 v -0.0001305395 0.0004407590 0.0002922533 diff --git a/tests/integrate/701_LJ_MD_NVE/result.ref b/tests/integrate/701_LJ_MD_NVE/result.ref index 22b6d660a1..1e4b22ae3c 100644 --- a/tests/integrate/701_LJ_MD_NVE/result.ref +++ b/tests/integrate/701_LJ_MD_NVE/result.ref @@ -1,5 +1,5 @@ -etotref -2.231664481084234 -etotperatomref -0.0697395150 -totalforceref 2.523373 -totalstressref 28.540803 -totaltimeref 0.03 +etotref -1.562635884297464 +etotperatomref -0.0488323714 +totalforceref 9.771882 +totalstressref 46.307098 +totaltimeref 0.02 diff --git a/tests/integrate/701_LJ_MD_rescale_v/INPUT b/tests/integrate/701_LJ_MD_rescale_v/INPUT index 1f42e75c39..41bcb07bcd 100644 --- a/tests/integrate/701_LJ_MD_rescale_v/INPUT +++ b/tests/integrate/701_LJ_MD_rescale_v/INPUT @@ -15,11 +15,11 @@ cal_force 1 cal_stress 1 #Parameters (MD) -md_nstep 5 +md_nstep 14 md_type nvt md_dt 1 md_tfirst 300 - +md_restart 1 init_vel 1 #Parameters (thermostat) diff --git a/tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/Restart_md.dat b/tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/Restart_md.dat new file mode 100644 index 0000000000..aaa07929f1 --- /dev/null +++ b/tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/Restart_md.dat @@ -0,0 +1,2 @@ +10 +0.000950045 diff --git a/tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/STRU/STRU_MD_10 b/tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/STRU/STRU_MD_10 new file mode 100644 index 0000000000..47e784dcef --- /dev/null +++ b/tests/integrate/701_LJ_MD_rescale_v/OUT.autotest/STRU/STRU_MD_10 @@ -0,0 +1,49 @@ +ATOMIC_SPECIES +He 4.0026 auto auto + +LATTICE_CONSTANT +1.8897270000 + +LATTICE_VECTORS + 10.0000000000 0.0000000000 0.0000000000 + 0.0000000000 10.0000000000 0.0000000000 + 0.0000000000 0.0000000000 10.0000000000 + +ATOMIC_POSITIONS +Cartesian + +He #label +0.0000 #magnetism +32 #number of atoms + 0.0655588081 9.9683119490 0.0573495702 m 1 1 1 v 0.0002950037 -0.0001359087 0.0002817142 + 0.0296020455 9.9394287800 5.0974576575 m 1 1 1 v 0.0001450707 -0.0002659284 0.0004288033 + 9.8437701902 5.0285548903 9.9750151927 m 1 1 1 v -0.0007044281 0.0001389467 -0.0001200141 + 0.1593199064 4.8142404625 5.0254534456 m 1 1 1 v 0.0007415303 -0.0008638378 0.0001205085 + 5.0478627152 0.1039334022 9.9257632192 m 1 1 1 v 0.0002314661 0.0004741028 -0.0003442097 + 5.0029102003 9.9636970071 5.0330422438 m 1 1 1 v 0.0000172209 -0.0001939876 0.0001700901 + 4.8903853112 4.9686490249 0.0111471151 m 1 1 1 v -0.0004991972 -0.0001467827 0.0000501866 + 5.0777210495 5.0598930691 4.8868119138 m 1 1 1 v 0.0003692795 0.0002563320 -0.0005158799 + 2.6540295807 2.5271295893 0.0063399217 m 1 1 1 v 0.0007084865 0.0001346339 0.0000232620 + 2.5161768072 2.4343319000 5.0855185376 m 1 1 1 v 0.0000798909 -0.0003153276 0.0003981596 + 2.4885226114 7.6183654890 9.9916893544 m 1 1 1 v -0.0000705801 0.0005501795 -0.0000119107 + 2.5472229404 7.3903651016 4.9353714563 m 1 1 1 v 0.0001986861 -0.0004975157 -0.0003020557 + 7.4815287957 2.4263888494 9.9233415484 m 1 1 1 v -0.0000920512 -0.0003376769 -0.0003536841 + 7.5241804124 2.5573040389 4.9833906701 m 1 1 1 v 0.0001258496 0.0002684644 -0.0000759589 + 7.4695431022 7.4394976591 9.8722710346 m 1 1 1 v -0.0001710906 -0.0002611367 -0.0005919685 + 7.5005490316 7.4428194462 5.1135787733 m 1 1 1 v -0.0000055483 -0.0002727539 0.0005241266 + 2.4904082317 0.1601904807 2.5115332253 m 1 1 1 v -0.0000457050 0.0007460947 0.0000629334 + 2.4331552911 9.9859414563 7.5652838492 m 1 1 1 v -0.0003120657 -0.0000668895 0.0003013885 + 2.5023759747 5.0062549748 2.4352866258 m 1 1 1 v -0.0000001888 0.0000162094 -0.0003142300 + 2.5546402518 5.0993060966 7.3995116538 m 1 1 1 v 0.0002383422 0.0004574823 -0.0004564841 + 7.5185693929 9.9213221538 2.4952978333 m 1 1 1 v 0.0000890360 -0.0003842210 -0.0000176632 + 7.5566224950 0.0732059047 7.4670019245 m 1 1 1 v 0.0002452208 0.0003541221 -0.0001600036 + 7.4586761755 5.0230751233 2.4212251455 m 1 1 1 v -0.0001945627 0.0001116452 -0.0003764660 + 7.5826720157 5.0347139511 7.5141572910 m 1 1 1 v 0.0003678149 0.0001399331 0.0000487214 + 0.0089573689 2.5662392942 2.4973462274 m 1 1 1 v 0.0000351825 0.0003053353 -0.0000266476 + 0.0417566390 2.4636651990 7.6067552685 m 1 1 1 v 0.0002120403 -0.0001648501 0.0005167711 + 9.9989679634 7.5404906965 2.5014145451 m 1 1 1 v -0.0000047379 0.0001780690 0.0000184666 + 9.8612024820 7.6473271727 7.4337306273 m 1 1 1 v -0.0006222054 0.0006675675 -0.0002959123 + 5.0432660960 2.3783889173 2.5889289401 m 1 1 1 v 0.0002188891 -0.0005654607 0.0004240516 + 4.9250307726 2.4734365320 7.3864959938 m 1 1 1 v -0.0003367943 -0.0001065234 -0.0005436354 + 4.9123907180 7.4499967239 2.6171837953 m 1 1 1 v -0.0003999327 -0.0002036017 0.0005137604 + 4.8124246568 7.4935346648 7.6353053219 m 1 1 1 v -0.0008599223 -0.0000167156 0.0006237795 diff --git a/tests/integrate/701_LJ_MD_rescale_v/STRU b/tests/integrate/701_LJ_MD_rescale_v/STRU deleted file mode 100644 index f1c0576192..0000000000 --- a/tests/integrate/701_LJ_MD_rescale_v/STRU +++ /dev/null @@ -1,49 +0,0 @@ -ATOMIC_SPECIES -He 4.0026 auto auto - -LATTICE_CONSTANT -1.889727 - -LATTICE_VECTORS - 10.0000000000 0.0000000000 0.0000000000 #latvec1 - 0.0000000000 10.0000000000 0.0000000000 #latvec2 - 0.0000000000 0.0000000000 10.0000000000 #latvec3 - -ATOMIC_POSITIONS -Cartesian - -He #label -0 #magnetism -32 #number of atoms - 0.0000000000 0.0000000000 0.0000000000 m 1 1 1 v 0.0003051236 -0.0001506039 0.0002563783 - 0.0000000000 0.0000000000 5.0000000000 m 1 1 1 v 0.0001330836 -0.0002844927 0.0004575604 - 0.0000000000 5.0000000000 0.0000000000 m 1 1 1 v -0.0007284395 0.0001278596 -0.0001116420 - 0.0000000000 5.0000000000 5.0000000000 m 1 1 1 v 0.0007317461 -0.0008538537 0.0001165929 - 5.0000000000 0.0000000000 0.0000000000 m 1 1 1 v 0.0002153406 0.0004818484 -0.0003425506 - 5.0000000000 0.0000000000 5.0000000000 m 1 1 1 v 0.0000115849 -0.0001553058 0.0001440467 - 5.0000000000 5.0000000000 0.0000000000 m 1 1 1 v -0.0005075296 -0.0001418554 0.0000517226 - 5.0000000000 5.0000000000 5.0000000000 m 1 1 1 v 0.0003532731 0.0002838795 -0.0005240855 - 2.5000000000 2.5000000000 0.0000000000 m 1 1 1 v 0.0007110217 0.0001188223 0.0000320587 - 2.5000000000 2.5000000000 5.0000000000 m 1 1 1 v 0.0000716800 -0.0002982750 0.0003924065 - 2.5000000000 7.5000000000 0.0000000000 m 1 1 1 v -0.0000446191 0.0005436754 -0.0000488239 - 2.5000000000 7.5000000000 5.0000000000 m 1 1 1 v 0.0002256764 -0.0005094877 -0.0002958008 - 7.5000000000 2.5000000000 0.0000000000 m 1 1 1 v -0.0000811382 -0.0003395719 -0.0003533055 - 7.5000000000 2.5000000000 5.0000000000 m 1 1 1 v 0.0001046891 0.0002627214 -0.0000768329 - 7.5000000000 7.5000000000 0.0000000000 m 1 1 1 v -0.0001263117 -0.0002867947 -0.0005880112 - 7.5000000000 7.5000000000 5.0000000000 m 1 1 1 v 0.0000051377 -0.0002585502 0.0005224161 - 2.5000000000 0.0000000000 2.5000000000 m 1 1 1 v -0.0000441228 0.0007354340 0.0000484884 - 2.5000000000 0.0000000000 7.5000000000 m 1 1 1 v -0.0003062640 -0.0000630593 0.0003011308 - 2.5000000000 5.0000000000 2.5000000000 m 1 1 1 v 0.0000156182 0.0000352305 -0.0002909118 - 2.5000000000 5.0000000000 7.5000000000 m 1 1 1 v 0.0002588185 0.0004562910 -0.0004669455 - 7.5000000000 0.0000000000 2.5000000000 m 1 1 1 v 0.0000836607 -0.0003527362 -0.0000237714 - 7.5000000000 0.0000000000 7.5000000000 m 1 1 1 v 0.0002682220 0.0003310257 -0.0001488492 - 7.5000000000 5.0000000000 2.5000000000 m 1 1 1 v -0.0001893987 0.0001038739 -0.0003576744 - 7.5000000000 5.0000000000 7.5000000000 m 1 1 1 v 0.0003881776 0.0001685539 0.0000718978 - 0.0000000000 2.5000000000 2.5000000000 m 1 1 1 v 0.0000439981 0.0003058987 -0.0000061514 - 0.0000000000 2.5000000000 7.5000000000 m 1 1 1 v 0.0001835450 -0.0001686670 0.0004810819 - 0.0000000000 7.5000000000 2.5000000000 m 1 1 1 v -0.0000043640 0.0001908703 0.0000007071 - 0.0000000000 7.5000000000 7.5000000000 m 1 1 1 v -0.0006477776 0.0006839538 -0.0003073223 - 5.0000000000 2.5000000000 2.5000000000 m 1 1 1 v 0.0001909232 -0.0005588096 0.0004036625 - 5.0000000000 2.5000000000 7.5000000000 m 1 1 1 v -0.0003495156 -0.0001304327 -0.0005131768 - 5.0000000000 7.5000000000 2.5000000000 m 1 1 1 v -0.0004054115 -0.0002425928 0.0005518707 - 5.0000000000 7.5000000000 7.5000000000 m 1 1 1 v -0.0008664276 -0.0000348499 0.0006238335 diff --git a/tests/integrate/701_LJ_MD_rescale_v/result.ref b/tests/integrate/701_LJ_MD_rescale_v/result.ref index 5e667336ed..cad88e73de 100644 --- a/tests/integrate/701_LJ_MD_rescale_v/result.ref +++ b/tests/integrate/701_LJ_MD_rescale_v/result.ref @@ -1,5 +1,8 @@ -etotref -2.231166224971229 -etotperatomref -0.0697239445 -totalforceref 2.535421 -totalstressref 28.554171 +etotref -1.834707034866914 +etotperatomref -0.0573345948 +totalforceref 8.470218 +totalstressref 39.004676 totaltimeref 0.03 +0.02 +0.02 +0.02 From cda8b24432c86c2990bc0ca3dcc557dc260e1527 Mon Sep 17 00:00:00 2001 From: Chun Cai Date: Sat, 12 Oct 2024 13:55:51 +0800 Subject: [PATCH 2/3] update docs regarding libm (#5218) --- docs/advanced/install.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/advanced/install.md b/docs/advanced/install.md index 6c31229070..4870483fa7 100644 --- a/docs/advanced/install.md +++ b/docs/advanced/install.md @@ -93,9 +93,9 @@ cmake -B build -DUSE_CUDA=1 -DCMAKE_CUDA_COMPILER=${path to cuda toolkit}/bin/nv ## Build math library from source -> Note: This flag is **enabled by default**. It will get better performance than the standard implementation on `gcc` and `clang`. But it **will be disabled** when using `Intel Compiler` since the math functions will get wrong results and the performance is also unexpectly poor. +> Note: We recommend using the latest available compiler sets, since they offer faster implementations of math functions. -To build math functions from source code, instead of using c++ standard implementation, define `USE_ABACUS_LIBM` flag. +This flag is disabled by default. To build math functions from source code, define `USE_ABACUS_LIBM` flag. It is expected to get a better performance on legacy versions of `gcc` and `clang`. Currently supported math functions: `sin`, `cos`, `sincos`, `exp`, `cexp` From 6b81902d45cfd74ca66ce16ab390772a140470b4 Mon Sep 17 00:00:00 2001 From: Chun Cai Date: Sat, 12 Oct 2024 13:56:19 +0800 Subject: [PATCH 3/3] Align test commands for coverage tests (#5219) --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 678012eef3..9131acd5ff 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -18,7 +18,7 @@ jobs: apt update && apt install -y lcov - name: Building run: | - cmake -B build -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DBUILD_TESTING=ON -DENABLE_COVERAGE=ON + cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON cmake --build build -j`nproc` cmake --install build - name: Testing