flush tiny stresses to zero to avoid false positives when testing

This commit is contained in:
Axel Kohlmeyer
2021-08-17 15:10:46 -04:00
parent 4f9941e18d
commit 05bd545cd3
7 changed files with 22 additions and 18 deletions

View File

@ -278,6 +278,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// init_stress
auto stress = lmp->force->pair->virial;
// avoid false positives on tiny stresses. force to zero instead.
for (int i = 0; i < 6; ++i) if (fabs(stress[i]) < 1.0e-13) stress[i] = 0.0;
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e}", stress[0],
stress[1], stress[2], stress[3], stress[4], stress[5]);
writer.emit_block("init_stress", block);
@ -302,6 +304,8 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
// run_stress
stress = lmp->force->pair->virial;
// avoid false positives on tiny stresses. force to zero instead.
for (int i = 0; i < 6; ++i) if (fabs(stress[i]) < 1.0e-13) stress[i] = 0.0;
block = fmt::format("{:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e} {:23.16e}", stress[0],
stress[1], stress[2], stress[3], stress[4], stress[5]);
writer.emit_block("run_stress", block);