diff --git a/source/source_esolver/esolver_ks_lcao_tddft.cpp b/source/source_esolver/esolver_ks_lcao_tddft.cpp index dbeb81dca9..907a8c3bb1 100644 --- a/source/source_esolver/esolver_ks_lcao_tddft.cpp +++ b/source/source_esolver/esolver_ks_lcao_tddft.cpp @@ -229,11 +229,8 @@ template void ESolver_KS_LCAO_TDDFT::print_step() { std::cout << " -------------------------------------------" << std::endl; - GlobalV::ofs_running << "\n -------------------------------------------" << std::endl; std::cout << " STEP OF ELECTRON EVOLVE : " << unsigned(totstep) << std::endl; - GlobalV::ofs_running << " STEP OF ELECTRON EVOLVE : " << unsigned(totstep) << std::endl; std::cout << " -------------------------------------------" << std::endl; - GlobalV::ofs_running << " -------------------------------------------" << std::endl; } template void ESolver_KS_LCAO_TDDFT::hamilt2rho_single(UnitCell& ucell, @@ -321,10 +318,7 @@ void ESolver_KS_LCAO_TDDFT::iter_finish( // print occupation of each band if (iter == 1 && istep <= 2) { - GlobalV::ofs_running << " ---------------------------------------------------------" - << std::endl; - GlobalV::ofs_running << " occupations of electrons" << std::endl; - GlobalV::ofs_running << " k-point state occupation" << std::endl; + GlobalV::ofs_running << " k-point State Occupations" << std::endl; GlobalV::ofs_running << std::setiosflags(std::ios::showpoint); GlobalV::ofs_running << std::left; std::setprecision(6); @@ -337,8 +331,6 @@ void ESolver_KS_LCAO_TDDFT::iter_finish( << std::setw(12) << this->pelec->wg(ik, ib) << std::endl; } } - GlobalV::ofs_running << " ---------------------------------------------------------" - << std::endl; } ESolver_KS_LCAO, TR>::iter_finish(ucell, istep, iter, conv_esolver); @@ -471,32 +463,6 @@ void ESolver_KS_LCAO_TDDFT::update_pot(UnitCell& ucell, } } - // print "eigen value" for tddft -// it seems uncessary to print out E_ii because the band energies are printed -/* - if (conv_esolver) - { - GlobalV::ofs_running << "----------------------------------------------------------" - << std::endl; - GlobalV::ofs_running << " Print E= " << std::endl; - GlobalV::ofs_running << " k-point state energy (eV)" << std::endl; - GlobalV::ofs_running << "----------------------------------------------------------" - << std::endl; - GlobalV::ofs_running << std::setprecision(6); - GlobalV::ofs_running << std::setiosflags(std::ios::showpoint); - - for (int ik = 0; ik < this->kv.get_nks(); ik++) - { - for (int ib = 0; ib < PARAM.inp.nbands; ib++) - { - GlobalV::ofs_running << " " << std::setw(7) << ik + 1 - << std::setw(7) << ib + 1 - << std::setw(10) << this->pelec->ekb(ik, ib) * ModuleBase::Ry_to_eV - << std::endl; - } - } - } -*/ } template @@ -555,7 +521,7 @@ void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int ist } } // (3) output energy for sub loop - std::cout << "Potential (Ry): " << std::setprecision(15) << this->pelec->f_en.etot <pelec->f_en.etot <nrxx; const int nxyz = elec.charge->nxyz; - GlobalV::ofs_running << std::setprecision(12); + GlobalV::ofs_running << std::setprecision(6); GlobalV::ofs_running << std::setiosflags(std::ios::right); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Electron density deviation",scf_thr); + GlobalV::ofs_running << " Electron density deviation " << scf_thr << std::endl; if (PARAM.inp.basis_type == "pw") { diff --git a/source/source_estate/test/elecstate_print_test.cpp b/source/source_estate/test/elecstate_print_test.cpp index 1a8b712cbe..0003ef2475 100644 --- a/source/source_estate/test/elecstate_print_test.cpp +++ b/source/source_estate/test/elecstate_print_test.cpp @@ -184,7 +184,7 @@ TEST_F(ElecStatePrintTest, PrintEtot) GlobalV::ofs_running.close(); ifs.open("test.dat", std::ios::in); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - EXPECT_THAT(str, testing::HasSubstr("Electron density deviation = 0.1")); + EXPECT_THAT(str, testing::HasSubstr("Electron density deviation 0.1")); EXPECT_THAT(str, testing::HasSubstr("Diago Threshold = 0.1")); EXPECT_THAT(str, testing::HasSubstr("E_KohnSham")); EXPECT_THAT(str, testing::HasSubstr("E_vdwD2")); @@ -198,49 +198,6 @@ TEST_F(ElecStatePrintTest, PrintEtot) std::remove("test.dat"); } -/* -TEST_F(ElecStatePrintTest, PrintEtot2) -{ - GlobalV::ofs_running.open("test.dat", std::ios::out); - bool converged = false; - int iter = 1; - double scf_thr = 0.1; - double scf_thr_kin = 0.0; - double duration = 2.0; - double pw_diag_thr = 0.1; - int avg_iter = 2; - bool print = true; - PARAM.input.out_freq_elec = 0; - elecstate.charge = new Charge; - elecstate.charge->nrxx = 100; - elecstate.charge->nxyz = 1000; - PARAM.input.imp_sol = true; - PARAM.input.efield_flag = true; - PARAM.input.gate_flag = true; - PARAM.sys.two_fermi = false; - PARAM.input.out_bandgap = true; - GlobalV::MY_RANK = 0; - PARAM.input.basis_type = "pw"; - PARAM.input.scf_nmax = 100; - - elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, - pw_diag_thr, avg_iter, print); - - GlobalV::ofs_running.close(); - ifs.open("test.dat", std::ios::in); - std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - EXPECT_THAT(str, testing::HasSubstr("Electron density deviation = 0.1")); - EXPECT_THAT(str, testing::HasSubstr("Diago Threshold = 0.1")); - EXPECT_THAT(str, testing::HasSubstr("E_KohnSham")); - EXPECT_THAT(str, testing::HasSubstr("E_Harris")); - EXPECT_THAT(str, testing::HasSubstr("E_Fermi")); - EXPECT_THAT(str, testing::HasSubstr("E_bandgap")); - ifs.close(); - delete elecstate.charge; - std::remove("test.dat"); -} -*/ - TEST_F(ElecStatePrintTest, PrintEtotColorS2) { bool converged = false; diff --git a/source/source_io/output_log.cpp b/source/source_io/output_log.cpp index dbc66a683a..4f73802e21 100644 --- a/source/source_io/output_log.cpp +++ b/source/source_io/output_log.cpp @@ -249,7 +249,6 @@ void print_force(std::ofstream& ofs_running, force_x.push_back(fx); force_y.push_back(fy); force_z.push_back(fz); - iat++; } } @@ -258,16 +257,17 @@ void print_force(std::ofstream& ofs_running, FmtTable fmt(/*titles=*/titles, /*nrows=*/atom_label.size(), /*formats=*/{"%8s", "%20.10f", "%20.10f", "%20.10f"}, - 0, + /*indent*/1, {FmtTable::Align::RIGHT,FmtTable::Align::RIGHT}); + fmt << atom_label << force_x << force_y << force_z; table = fmt.str(); - ofs_running << table << std::endl; + ofs_running << table; if (PARAM.inp.test_force) { - std::cout << table << std::endl; + std::cout << table; } } @@ -311,9 +311,11 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs, FmtTable fmt(/*titles=*/titles, /*nrows=*/3, - /*formats=*/{"%20.10f", "%20.10f", "%20.10f"}, 0, + /*formats=*/{"%20.10f", "%20.10f", "%20.10f"}, + /*indent*/1, {FmtTable::Align::RIGHT,FmtTable::Align::RIGHT}); + fmt << stress_x << stress_y << stress_z; table = fmt.str(); ofs << table; @@ -338,25 +340,23 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs, void write_head(std::ofstream& ofs, const int& istep, const int& iter, const std::string& basisname) { + ofs << std::right; ofs << "\n"; ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; - ofs << " --> IONIC RELAXATION STEP=" << std::setw(6) << istep+1 - << " ELECTRONIC ITERATION STEP=" << std::setw(6) << iter << "\n"; + ofs << " --> #ION MOVE#" << std::setw(10) << istep+1 + << " #ELEC ITER#" << std::setw(10) << iter << "\n"; ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; -// ofs << "\n " << basisname << " ALGORITHM --------------- ION=" << std::setw(4) << istep + 1 -// << " ELEC=" << std::setw(4) << iter << "--------------------------------\n"; } void write_head_td(std::ofstream& ofs, const int& istep, const int& estep, const int& iter, const std::string& basisname) { + ofs << std::right; ofs << "\n"; - ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; - ofs << " --> IONIC RELAXATION STEP=" << std::setw(6) << istep+1 - << " ELECTRON PROPAGATION STEP=" << std::setw(6) << estep - << " ELECTRONIC ITERATION STEP=" << std::setw(6) << iter << "\n"; - ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; - -// ofs << "\n " << basisname << " ALGORITHM --------------- ION=" << std::setw(4) << istep + 1 -// << " ELEC=" << std::setw(4) << estep << " iter=" << std::setw(4) << iter << "--------------------------------\n"; + ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; + ofs << " --> #ION MOVE#" << std::setw(10) << istep+1 + << " #ELEC PROP#" << std::setw(10) << estep+1 + << " #ELEC ITER#" << std::setw(10) << iter << "\n"; + ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; + } }// namespace ModuleIO diff --git a/source/source_md/md_base.cpp b/source/source_md/md_base.cpp index d1e4b67292..659dea7fe2 100644 --- a/source/source_md/md_base.cpp +++ b/source/source_md/md_base.cpp @@ -5,7 +5,8 @@ #endif #include "source_io/print_info.h" #include "source_cell/update_cell.h" -MD_base::MD_base(const Parameter& param_in, UnitCell& unit_in) : mdp(param_in.mdp), ucell(unit_in) +MD_base::MD_base(const Parameter& param_in, UnitCell& unit_in) +: mdp(param_in.mdp), ucell(unit_in) { my_rank = param_in.globalv.myrank; cal_stress = param_in.inp.cal_stress; @@ -159,6 +160,7 @@ void MD_base::print_md(std::ofstream& ofs, const bool& cal_stress) } // screen output + std::cout << std::setprecision(8); std::cout << " ------------------------------------------------------------------------------------------------" << std::endl; std::cout << " " << std::left << std::setw(20) << "Energy (Ry)" << std::left << std::setw(20) << "Potential (Ry)" diff --git a/source/source_md/md_func.cpp b/source/source_md/md_func.cpp index d6c09beafc..d3cb2f6aa0 100644 --- a/source/source_md/md_func.cpp +++ b/source/source_md/md_func.cpp @@ -192,7 +192,6 @@ void init_vel(const UnitCell& unit_in, ModuleBase::Vector3* ionmbl, ModuleBase::Vector3* vel) { - std::cout << " ----------------------------------- INIT VEL ---------------------------------------" << std::endl; ModuleBase::Vector3 frozen; get_mass_mbl(unit_in, allmass, frozen, ionmbl); frozen_freedom = frozen.x + frozen.y + frozen.z; @@ -211,38 +210,38 @@ void init_vel(const UnitCell& unit_in, if (unit_in.init_vel) { - std::cout << " READ VEL FROM STRU" << std::endl; + std::cout << " Reading velocities from STRU file" << std::endl; read_vel(unit_in, vel); double kinetic = 0.0; double t_current = MD_func::current_temp(kinetic, unit_in.nat, frozen_freedom, allmass, vel); if (restart) { - std::cout << " RESTART MD, CURRENT TEMPERATURE IS " << t_current * ModuleBase::Hartree_to_K << " K" + std::cout << " Restart MD, current temperature is " << t_current * ModuleBase::Hartree_to_K << " K" << std::endl; } else if (temperature < 0) { - std::cout << " UNSET INITIAL TEMPERATURE, AUTOSET TO " << t_current * ModuleBase::Hartree_to_K << " K" + std::cout << " Autoset the initial tempearture to " << t_current * ModuleBase::Hartree_to_K << " K" << std::endl; temperature = t_current; } else { - std::cout << " INITIAL TEMPERATURE IN INPUT = " << temperature * ModuleBase::Hartree_to_K << " K" + std::cout << " Initial temeprature from INPUT is " << temperature * ModuleBase::Hartree_to_K << " K" << std::endl; - std::cout << " READING TEMPERATURE FROM STRU = " << t_current * ModuleBase::Hartree_to_K << " K" + std::cout << " Reading temperature from STRU is " << t_current * ModuleBase::Hartree_to_K << " K" << std::endl; - std::cout << " RESCALE VEL TO INITIAL TEMPERATURE" << std::endl; + std::cout << " Rescale velocties to initial temperature" << std::endl; rescale_vel(unit_in.nat, temperature, allmass, frozen_freedom, vel); } } else { - std::cout << " RANDOM VEL ACCORDING TO INITIAL TEMPERATURE: " << temperature * ModuleBase::Hartree_to_K << " K" + std::cout << " Random velocities according to initial temperature " + << temperature * ModuleBase::Hartree_to_K << " K" << std::endl; rand_vel(unit_in.nat, temperature, allmass, frozen_freedom, frozen, ionmbl, my_rank, vel); } - std::cout << " ------------------------------------- DONE -----------------------------------------" << std::endl; } void force_virial(ModuleESolver::ESolver* p_esolver,