Skip to content

Commit 5f0c35b

Browse files
committed
Improve md calculation stress output in running log
1 parent 3a842b0 commit 5f0c35b

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

source/source_io/output_log.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs,
285285
}
286286
else
287287
{
288-
title += " (KBAR)";
289-
unit = " KBAR";
288+
title += " (kbar)";
289+
unit = " kbar";
290290
unit_transform = ModuleBase::RYDBERG_SI / pow(ModuleBase::BOHR_RADIUS_SI, 3) * 1.0e-8;
291291
}
292292
std::vector<double> stress_x;
@@ -317,7 +317,7 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs,
317317
fmt << stress_x << stress_y << stress_z;
318318
table = fmt.str();
319319
ofs << table;
320-
if (name == "TOTAL-STRESS")
320+
if (name == "TOTAL-STRESS" && PARAM.inp.calculation != "md")
321321
{
322322
ofs << " #TOTAL-PRESSURE# (EXCLUDE KINETIC PART OF IONS): " << std::fixed
323323
<< std::setprecision(6) << pressure << unit

source/source_md/md_base.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ void MD_base::print_md(std::ofstream& ofs, const bool& cal_stress)
184184
<< std::endl;
185185

186186
// running_log output
187+
188+
if (cal_stress)
189+
{
190+
MD_func::print_stress(ofs, virial, stress);
191+
ofs << std::endl;
192+
}
193+
187194
ofs.unsetf(std::ios::fixed);
188195
ofs << std::setprecision(8);
189196
ofs << " ------------------------------------------------------------------------------------------------"
@@ -209,12 +216,7 @@ void MD_base::print_md(std::ofstream& ofs, const bool& cal_stress)
209216
ofs << std::endl;
210217
ofs << " ------------------------------------------------------------------------------------------------"
211218
<< std::endl;
212-
213-
if (cal_stress)
214-
{
215-
MD_func::print_stress(ofs, virial, stress);
216-
}
217-
219+
ofs << std::endl;
218220
return;
219221
}
220222

source/source_md/md_func.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,10 @@ void print_stress(std::ofstream& ofs, const ModuleBase::matrix& virial, const Mo
300300

301301
const double unit_transform = ModuleBase::HARTREE_SI / pow(ModuleBase::BOHR_RADIUS_SI, 3) * 1.0e-8;
302302

303-
ofs << " MD PRESSURE (ELECTRONS+IONS) : " << stress_scalar * unit_transform << " kbar" << std::endl;
303+
304304
ofs << " ELECTRONIC PART OF STRESS: " << virial_scalar * unit_transform << " kbar" << std::endl;
305305
ofs << " IONIC (KINETIC) PART OF STRESS: " << (stress_scalar - virial_scalar) * unit_transform << " kbar" << std::endl;
306+
ofs << " MD PRESSURE (ELECTRONS+IONS) : " << stress_scalar * unit_transform << " kbar" << std::endl;
306307

307308
// one should use 'print_stress' function in ../source/source_io/output_log.cpp
308309
/*

0 commit comments

Comments
 (0)