Skip to content

Commit

Permalink
Merge pull request #947 from YuLiu98/develop
Browse files Browse the repository at this point in the history
refactor : update the output format of MD
  • Loading branch information
dyzheng authored May 27, 2022
2 parents 6bfcb8d + 80732cf commit bd6ccec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
23 changes: 12 additions & 11 deletions source/module_md/MD_func.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,17 @@ void MD_func::outStress(const ModuleBase::matrix &virial, const ModuleBase::matr
GlobalV::ofs_running<<"Virial Term is "<<virial_scalar*unit_transform<<" Kbar "<<std::endl;
GlobalV::ofs_running<<"Kenetic Term is "<<(stress_scalar-virial_scalar)*unit_transform<<" Kbar "<<std::endl;

GlobalV::ofs_running << std::setprecision(6) << std::setiosflags(ios::showpos) << std::setiosflags(ios::fixed) << std::endl;
ModuleBase::GlobalFunc::NEW_PART("MD STRESS (KBAR)");
for (int i=0; i<3; i++)
{
GlobalV::ofs_running << " " << std::setw(15) << stress(i,0)*unit_transform
<< std::setw(15)<< stress(i,1)*unit_transform
<< std::setw(15) << stress(i,2)*unit_transform << std::endl;
GlobalV::ofs_running.unsetf(ios::fixed);
GlobalV::ofs_running << std::setprecision(8) << std::endl;
ModuleBase::GlobalFunc::NEW_PART("MD STRESS (KBAR)");
for (int i=0; i<3; i++)
{
GlobalV::ofs_running << std::setw(15) << stress(i,0)*unit_transform
<< std::setw(15) << stress(i,1)*unit_transform
<< std::setw(15) << stress(i,2)*unit_transform << std::endl;

}
GlobalV::ofs_running << std::setiosflags(ios::left);
}
GlobalV::ofs_running << std::setiosflags(ios::left);
}

void MD_func::MDdump(const int &step,
Expand Down Expand Up @@ -374,8 +375,8 @@ void MD_func::MDdump(const int &step,
{
for(int ia=0; ia<unit_in.atoms[it].na; ++ia)
{
ofs << std::setw(6) << index
<< std::setw(4) << unit_in.atom_label[it]
ofs << " " << index
<< " " << unit_in.atom_label[it]
<< " " << unit_in.atoms[it].tau[ia].x
<< " " << unit_in.atoms[it].tau[ia].y
<< " " << unit_in.atoms[it].tau[ia].z
Expand Down
3 changes: 2 additions & 1 deletion source/module_md/verlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ void Verlet::outputMD(std::ofstream &ofs)
<< std::left << std::setw(20) << press*unit_transform <<std::endl;
std::cout << " ------------------------------------------------------------------------------------------------" << std::endl;

ofs << std::endl;
ofs.unsetf(ios::fixed);
ofs << std::setprecision(8) << std::endl;
ofs << std::endl;
ofs << " ------------------------------------------------------------------------------------------------" << std::endl;
ofs << " " << std::left << std::setw(20) << "Energy"
Expand Down

0 comments on commit bd6ccec

Please sign in to comment.