Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 2 additions & 36 deletions source/source_esolver/esolver_ks_lcao_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,8 @@ template <typename TR, typename Device>
void ESolver_KS_LCAO_TDDFT<TR, Device>::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 <typename TR, typename Device>
void ESolver_KS_LCAO_TDDFT<TR, Device>::hamilt2rho_single(UnitCell& ucell,
Expand Down Expand Up @@ -321,10 +318,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::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);
Expand All @@ -337,8 +331,6 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::iter_finish(
<< std::setw(12) << this->pelec->wg(ik, ib) << std::endl;
}
}
GlobalV::ofs_running << " ---------------------------------------------------------"
<< std::endl;
}

ESolver_KS_LCAO<std::complex<double>, TR>::iter_finish(ucell, istep, iter, conv_esolver);
Expand Down Expand Up @@ -471,32 +463,6 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::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=<psi_i|H|psi_i> " << 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 <typename TR, typename Device>
Expand Down Expand Up @@ -555,7 +521,7 @@ void ESolver_KS_LCAO_TDDFT<TR, Device>::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 <<std::endl;
std::cout << " Potential (Ry): " << std::setprecision(15) << this->pelec->f_en.etot <<std::endl;

// (4) output file for restart
if(istep % PARAM.inp.out_interval == 0)
Expand Down
4 changes: 2 additions & 2 deletions source/source_estate/elecstate_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ void print_etot(const Magnetism& magnet,
const int nrxx = elec.charge->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")
{
Expand Down
45 changes: 1 addition & 44 deletions source/source_estate/test/elecstate_print_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(ifs)), std::istreambuf_iterator<char>());
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"));
Expand All @@ -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<char>(ifs)), std::istreambuf_iterator<char>());
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;
Expand Down
34 changes: 17 additions & 17 deletions source/source_io/output_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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
4 changes: 3 additions & 1 deletion source/source_md/md_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)"
Expand Down
17 changes: 8 additions & 9 deletions source/source_md/md_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ void init_vel(const UnitCell& unit_in,
ModuleBase::Vector3<int>* ionmbl,
ModuleBase::Vector3<double>* vel)
{
std::cout << " ----------------------------------- INIT VEL ---------------------------------------" << std::endl;
ModuleBase::Vector3<int> frozen;
get_mass_mbl(unit_in, allmass, frozen, ionmbl);
frozen_freedom = frozen.x + frozen.y + frozen.z;
Expand All @@ -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,
Expand Down
Loading