Skip to content

Commit bd6ccec

Browse files
authored
Merge pull request #947 from YuLiu98/develop
refactor : update the output format of MD
2 parents 6bfcb8d + 80732cf commit bd6ccec

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

source/module_md/MD_func.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,17 @@ void MD_func::outStress(const ModuleBase::matrix &virial, const ModuleBase::matr
316316
GlobalV::ofs_running<<"Virial Term is "<<virial_scalar*unit_transform<<" Kbar "<<std::endl;
317317
GlobalV::ofs_running<<"Kenetic Term is "<<(stress_scalar-virial_scalar)*unit_transform<<" Kbar "<<std::endl;
318318

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

327-
}
328-
GlobalV::ofs_running << std::setiosflags(ios::left);
328+
}
329+
GlobalV::ofs_running << std::setiosflags(ios::left);
329330
}
330331

331332
void MD_func::MDdump(const int &step,
@@ -374,8 +375,8 @@ void MD_func::MDdump(const int &step,
374375
{
375376
for(int ia=0; ia<unit_in.atoms[it].na; ++ia)
376377
{
377-
ofs << std::setw(6) << index
378-
<< std::setw(4) << unit_in.atom_label[it]
378+
ofs << " " << index
379+
<< " " << unit_in.atom_label[it]
379380
<< " " << unit_in.atoms[it].tau[ia].x
380381
<< " " << unit_in.atoms[it].tau[ia].y
381382
<< " " << unit_in.atoms[it].tau[ia].z

source/module_md/verlet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ void Verlet::outputMD(std::ofstream &ofs)
137137
<< std::left << std::setw(20) << press*unit_transform <<std::endl;
138138
std::cout << " ------------------------------------------------------------------------------------------------" << std::endl;
139139

140-
ofs << std::endl;
140+
ofs.unsetf(ios::fixed);
141+
ofs << std::setprecision(8) << std::endl;
141142
ofs << std::endl;
142143
ofs << " ------------------------------------------------------------------------------------------------" << std::endl;
143144
ofs << " " << std::left << std::setw(20) << "Energy"

0 commit comments

Comments
 (0)