Add test utility method EXPECT_STRESS()

This commit is contained in:
Richard Berger
2021-11-22 15:24:31 -05:00
parent bb127603ff
commit 3d650a6bf7
8 changed files with 96 additions and 715 deletions

View File

@ -300,6 +300,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
return; return;
} }
TEST(AngleStyle, plain) TEST(AngleStyle, plain)
{ {
if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP(); if (test_config.skip_tests.count(test_info_->name())) GTEST_SKIP();
@ -347,15 +348,7 @@ TEST(AngleStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto angle = lmp->force->angle; auto angle = lmp->force->angle;
auto stress = angle->virial; EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
@ -367,7 +360,6 @@ TEST(AngleStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = angle->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -379,15 +371,7 @@ TEST(AngleStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = angle->virial; EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -415,15 +399,7 @@ TEST(AngleStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
angle = lmp->force->angle; angle = lmp->force->angle;
stress = angle->virial; EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress, 2*epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
@ -435,7 +411,6 @@ TEST(AngleStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = angle->virial;
stats.reset(); stats.reset();
for (int i = 0; i < nlocal; ++i) { for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon); EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
@ -444,15 +419,7 @@ TEST(AngleStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = angle->virial; EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -478,15 +445,7 @@ TEST(AngleStyle, plain)
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
angle = lmp->force->angle; angle = lmp->force->angle;
stress = angle->virial; EXPECT_STRESS("restart_stress", angle->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
@ -508,15 +467,7 @@ TEST(AngleStyle, plain)
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
angle = lmp->force->angle; angle = lmp->force->angle;
stress = angle->virial; EXPECT_STRESS("data_stress", angle->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
@ -577,16 +528,7 @@ TEST(AngleStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto angle = lmp->force->angle; auto angle = lmp->force->angle;
auto stress = angle->virial; EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
@ -598,7 +540,6 @@ TEST(AngleStyle, omp)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = angle->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -610,15 +551,7 @@ TEST(AngleStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = angle->virial; EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -649,15 +582,7 @@ TEST(AngleStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
angle = lmp->force->angle; angle = lmp->force->angle;
stress = angle->virial; EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon);
@ -677,15 +602,7 @@ TEST(AngleStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = angle->virial; EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");

View File

@ -347,15 +347,7 @@ TEST(BondStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto bond = lmp->force->bond; auto bond = lmp->force->bond;
auto stress = bond->virial; EXPECT_STRESS("init_stress (newton on)", bond->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
@ -367,7 +359,6 @@ TEST(BondStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = bond->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -379,15 +370,7 @@ TEST(BondStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = bond->virial; EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -415,15 +398,7 @@ TEST(BondStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
bond = lmp->force->bond; bond = lmp->force->bond;
stress = bond->virial; EXPECT_STRESS("init_stress (newton off)", bond->virial, test_config.init_stress, 2 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
@ -435,7 +410,6 @@ TEST(BondStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = bond->virial;
stats.reset(); stats.reset();
for (int i = 0; i < nlocal; ++i) { for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon); EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
@ -444,15 +418,7 @@ TEST(BondStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = bond->virial; EXPECT_STRESS("run_stress (newton off)", bond->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -478,15 +444,7 @@ TEST(BondStyle, plain)
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
bond = lmp->force->bond; bond = lmp->force->bond;
stress = bond->virial; EXPECT_STRESS("restart_stress", bond->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
@ -508,15 +466,7 @@ TEST(BondStyle, plain)
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
bond = lmp->force->bond; bond = lmp->force->bond;
stress = bond->virial; EXPECT_STRESS("data_stress", bond->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
@ -577,15 +527,7 @@ TEST(BondStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto bond = lmp->force->bond; auto bond = lmp->force->bond;
auto stress = bond->virial; EXPECT_STRESS("init_stress (newton on)", bond->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
@ -597,7 +539,6 @@ TEST(BondStyle, omp)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = bond->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -609,15 +550,7 @@ TEST(BondStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = bond->virial; EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -648,15 +581,7 @@ TEST(BondStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
bond = lmp->force->bond; bond = lmp->force->bond;
stress = bond->virial; EXPECT_STRESS("init_stress (newton off)", bond->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon);
@ -676,15 +601,7 @@ TEST(BondStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = bond->virial; EXPECT_STRESS("run_stress (newton off)", bond->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");

View File

@ -350,15 +350,7 @@ TEST(DihedralStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto dihedral = lmp->force->dihedral; auto dihedral = lmp->force->dihedral;
auto stress = dihedral->virial; EXPECT_STRESS("init_stress (newton on)", dihedral->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon);
@ -370,7 +362,6 @@ TEST(DihedralStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = dihedral->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -382,15 +373,7 @@ TEST(DihedralStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = dihedral->virial; EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -418,15 +401,7 @@ TEST(DihedralStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
dihedral = lmp->force->dihedral; dihedral = lmp->force->dihedral;
stress = dihedral->virial; EXPECT_STRESS("init_stress (newton off)", dihedral->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon);
@ -438,7 +413,6 @@ TEST(DihedralStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = dihedral->virial;
stats.reset(); stats.reset();
for (int i = 0; i < nlocal; ++i) { for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon); EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
@ -447,15 +421,7 @@ TEST(DihedralStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = dihedral->virial; EXPECT_STRESS("run_stress (newton off)", dihedral->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -481,15 +447,7 @@ TEST(DihedralStyle, plain)
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
dihedral = lmp->force->dihedral; dihedral = lmp->force->dihedral;
stress = dihedral->virial; EXPECT_STRESS("restart_stress", dihedral->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon);
@ -511,15 +469,7 @@ TEST(DihedralStyle, plain)
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
dihedral = lmp->force->dihedral; dihedral = lmp->force->dihedral;
stress = dihedral->virial; EXPECT_STRESS("data_stress", dihedral->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon);
@ -580,16 +530,7 @@ TEST(DihedralStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto dihedral = lmp->force->dihedral; auto dihedral = lmp->force->dihedral;
auto stress = dihedral->virial; EXPECT_STRESS("init_stress (newton on)", dihedral->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon);
@ -601,7 +542,6 @@ TEST(DihedralStyle, omp)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = dihedral->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -613,15 +553,7 @@ TEST(DihedralStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = dihedral->virial; EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -652,15 +584,7 @@ TEST(DihedralStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
dihedral = lmp->force->dihedral; dihedral = lmp->force->dihedral;
stress = dihedral->virial; EXPECT_STRESS("init_stress (newton off)", dihedral->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon);
@ -680,15 +604,7 @@ TEST(DihedralStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = dihedral->virial; EXPECT_STRESS("run_stress (newton off)", dihedral->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");

View File

@ -37,6 +37,7 @@
#include "universe.h" #include "universe.h"
#include "utils.h" #include "utils.h"
#include "variable.h" #include "variable.h"
#include "platform.h"
#include <cctype> #include <cctype>
#include <cstdio> #include <cstdio>
@ -311,15 +312,7 @@ TEST(FixTimestep, plain)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (normal run, verlet)", fix->virial, test_config.run_stress, epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress normal run, verlet: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -386,15 +379,7 @@ TEST(FixTimestep, plain)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (restart, verlet)", fix->virial, test_config.run_stress, epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress restart, verlet: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -450,15 +435,7 @@ TEST(FixTimestep, plain)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (rmass, verlet)", fix->virial, test_config.run_stress, epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress rmass, verlet: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -528,16 +505,7 @@ TEST(FixTimestep, plain)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (normal run, respa)", fix->virial, test_config.run_stress, 1000 * epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
if (print_stats)
std::cerr << "run_stress normal run, respa: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -592,15 +560,7 @@ TEST(FixTimestep, plain)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (restart, respa)", fix->virial, test_config.run_stress, 1000 * epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
if (print_stats) std::cerr << "run_stress restart, respa: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -656,15 +616,7 @@ TEST(FixTimestep, plain)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (rmass, respa)", fix->virial, test_config.run_stress, 1000 * epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
if (print_stats) std::cerr << "run_stress rmass, respa: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -763,15 +715,7 @@ TEST(FixTimestep, omp)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (normal run, verlet)", fix->virial, test_config.run_stress, epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress normal run, verlet: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -838,15 +782,7 @@ TEST(FixTimestep, omp)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (restart, verlet)", fix->virial, test_config.run_stress, epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress restart, verlet: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -902,15 +838,7 @@ TEST(FixTimestep, omp)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (rmass, verlet)", fix->virial, test_config.run_stress, epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress rmass, verlet: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -980,16 +908,7 @@ TEST(FixTimestep, omp)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (normal run, respa)", fix->virial, test_config.run_stress, 1000 * epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
if (print_stats)
std::cerr << "run_stress normal run, respa: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -1044,15 +963,7 @@ TEST(FixTimestep, omp)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (restart, respa)", fix->virial, test_config.run_stress, 1000 * epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
if (print_stats) std::cerr << "run_stress restart, respa: " << stats << std::endl;
} }
stats.reset(); stats.reset();
@ -1108,15 +1019,7 @@ TEST(FixTimestep, omp)
} else { } else {
Fix *fix = lmp->modify->fix[ifix]; Fix *fix = lmp->modify->fix[ifix];
if (fix->thermo_virial) { if (fix->thermo_virial) {
stats.reset(); EXPECT_STRESS("run_stress (rmass, respa)", fix->virial, test_config.run_stress, 1000 * epsilon);
auto stress = fix->virial;
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 1000 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 1000 * epsilon);
if (print_stats) std::cerr << "run_stress rmass, respa: " << stats << std::endl;
} }
stats.reset(); stats.reset();

View File

@ -341,15 +341,7 @@ TEST(ImproperStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto improper = lmp->force->improper; auto improper = lmp->force->improper;
auto stress = improper->virial; EXPECT_STRESS("init_stress (newton on)", improper->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon);
@ -361,7 +353,6 @@ TEST(ImproperStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = improper->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -373,15 +364,7 @@ TEST(ImproperStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = improper->virial; EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -409,15 +392,7 @@ TEST(ImproperStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
improper = lmp->force->improper; improper = lmp->force->improper;
stress = improper->virial; EXPECT_STRESS("init_stress (newton off)", improper->virial, test_config.init_stress, 2 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 2 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 2 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon);
@ -429,7 +404,6 @@ TEST(ImproperStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = improper->virial;
stats.reset(); stats.reset();
for (int i = 0; i < nlocal; ++i) { for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon); EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 10 * epsilon);
@ -438,15 +412,7 @@ TEST(ImproperStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = improper->virial; EXPECT_STRESS("run_stress (newton off)", improper->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -472,15 +438,7 @@ TEST(ImproperStyle, plain)
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
improper = lmp->force->improper; improper = lmp->force->improper;
stress = improper->virial; EXPECT_STRESS("restart_stress", improper->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon);
@ -502,15 +460,7 @@ TEST(ImproperStyle, plain)
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
improper = lmp->force->improper; improper = lmp->force->improper;
stress = improper->virial; EXPECT_STRESS("data_stress", improper->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon);
@ -571,16 +521,8 @@ TEST(ImproperStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto improper = lmp->force->improper; auto improper = lmp->force->improper;
auto stress = improper->virial;
stats.reset(); EXPECT_STRESS("init_stress (newton on)", improper->virial, test_config.init_stress, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon);
@ -592,7 +534,6 @@ TEST(ImproperStyle, omp)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = improper->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -604,15 +545,7 @@ TEST(ImproperStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = improper->virial; EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -643,15 +576,7 @@ TEST(ImproperStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
improper = lmp->force->improper; improper = lmp->force->improper;
stress = improper->virial; EXPECT_STRESS("init_stress (newton off)", improper->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon);
@ -671,15 +596,7 @@ TEST(ImproperStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = improper->virial; EXPECT_STRESS("run_stress (newton off)", improper->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");

View File

@ -15,10 +15,12 @@
#include "pointers.h" #include "pointers.h"
#include "test_config.h" #include "test_config.h"
#include "test_config_reader.h" #include "test_config_reader.h"
#include "error_stats.h"
#include "utils.h" #include "utils.h"
#include "yaml_writer.h" #include "yaml_writer.h"
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "lammps.h"
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -27,9 +29,22 @@
#include <mpi.h> #include <mpi.h>
#include <vector> #include <vector>
using LAMMPS_NS::LAMMPS;
using LAMMPS_NS::utils::split_words; using LAMMPS_NS::utils::split_words;
using LAMMPS_NS::utils::trim; using LAMMPS_NS::utils::trim;
void EXPECT_STRESS(const std::string & name, double * stress, const stress_t & expected_stress, double epsilon)
{
ErrorStats stats;
EXPECT_FP_LE_WITH_EPS(stress[0], expected_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], expected_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], expected_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], expected_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], expected_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], expected_stress.yz, epsilon);
if (print_stats) std::cerr << name << " stats" << stats << std::endl;
}
// common read_yaml_file function // common read_yaml_file function
bool read_yaml_file(const char *infile, TestConfig &config) bool read_yaml_file(const char *infile, TestConfig &config)
{ {

View File

@ -34,6 +34,8 @@ void write_yaml_header(class YamlWriter *writer, TestConfig *cfg, const char *ve
EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \ EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \
} while (0); } while (0);
void EXPECT_STRESS(const std::string & name, double * stress, const stress_t & expected_stress, double epsilon);
#if defined _WIN32 #if defined _WIN32
static const char PATH_SEP = '\\'; static const char PATH_SEP = '\\';
#else #else

View File

@ -370,15 +370,7 @@ TEST(PairStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto pair = lmp->force->pair; auto pair = lmp->force->pair;
auto stress = pair->virial; EXPECT_STRESS("init_stress (newton on)", pair->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -391,7 +383,6 @@ TEST(PairStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = pair->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -403,15 +394,7 @@ TEST(PairStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (newton on)", pair->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -442,15 +425,7 @@ TEST(PairStyle, plain)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 3 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 3 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 3 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 3 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 3 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 3 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 3 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -463,7 +438,6 @@ TEST(PairStyle, plain)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = pair->virial;
stats.reset(); stats.reset();
for (int i = 0; i < nlocal; ++i) { for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 5 * epsilon); EXPECT_FP_LE_WITH_EPS(f[i][0], f_run[tag[i]].x, 5 * epsilon);
@ -472,15 +446,7 @@ TEST(PairStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -509,15 +475,7 @@ TEST(PairStyle, plain)
if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("restart_stress", pair->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "restart_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -542,15 +500,7 @@ TEST(PairStyle, plain)
if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "nofdotr_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -574,15 +524,7 @@ TEST(PairStyle, plain)
if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "data_forces stats:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("data_stress", pair->virial, test_config.init_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
if (print_stats) std::cerr << "data_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -613,15 +555,7 @@ TEST(PairStyle, plain)
} }
if (print_stats) std::cerr << "run_forces stats, r-RESPA:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, r-RESPA:" << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (r-RESPA)", pair->virial, test_config.run_stress, epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, epsilon);
if (print_stats) std::cerr << "run_stress stats, r-RESPA:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -693,15 +627,7 @@ TEST(PairStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto pair = lmp->force->pair; auto pair = lmp->force->pair;
auto stress = pair->virial; EXPECT_STRESS("init_stress (newton on)", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -713,7 +639,6 @@ TEST(PairStyle, omp)
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();
f = lmp->atom->f; f = lmp->atom->f;
stress = pair->virial;
tag = lmp->atom->tag; tag = lmp->atom->tag;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
@ -726,15 +651,7 @@ TEST(PairStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (newton on)", pair->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -763,15 +680,7 @@ TEST(PairStyle, omp)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -792,15 +701,7 @@ TEST(PairStyle, omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -827,15 +728,7 @@ TEST(PairStyle, omp)
if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "nofdotr_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, 5 * epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, 5 * epsilon);
@ -905,15 +798,7 @@ TEST(PairStyle, kokkos_omp)
if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl;
auto pair = lmp->force->pair; auto pair = lmp->force->pair;
auto stress = pair->virial; EXPECT_STRESS("init_stress (newton on)", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -925,7 +810,6 @@ TEST(PairStyle, kokkos_omp)
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();
f = lmp->atom->f; f = lmp->atom->f;
stress = pair->virial;
tag = lmp->atom->tag; tag = lmp->atom->tag;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
@ -938,15 +822,7 @@ TEST(PairStyle, kokkos_omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton on: " << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (newton on)", pair->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton on: " << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -975,15 +851,7 @@ TEST(PairStyle, kokkos_omp)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -1004,15 +872,7 @@ TEST(PairStyle, kokkos_omp)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
id = lmp->modify->find_compute("sum"); id = lmp->modify->find_compute("sum");
@ -1039,15 +899,7 @@ TEST(PairStyle, kokkos_omp)
if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "nofdotr_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, 5 * epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, 5 * epsilon);
@ -1138,15 +990,7 @@ TEST(PairStyle, gpu)
if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats, newton off:" << stats << std::endl;
auto pair = lmp->force->pair; auto pair = lmp->force->pair;
auto stress = pair->virial; EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -1167,15 +1011,7 @@ TEST(PairStyle, gpu)
} }
if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats, newton off:" << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats, newton off:" << stats << std::endl;
stats.reset(); stats.reset();
auto id = lmp->modify->find_compute("sum"); auto id = lmp->modify->find_compute("sum");
@ -1257,15 +1093,7 @@ TEST(PairStyle, intel)
if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl;
Pair *pair = lmp->force->pair; Pair *pair = lmp->force->pair;
double *stress = pair->virial; EXPECT_STRESS("init_stress", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -1278,7 +1106,6 @@ TEST(PairStyle, intel)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = pair->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
@ -1290,15 +1117,7 @@ TEST(PairStyle, intel)
} }
if (print_stats) std::cerr << "run_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats:" << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress", pair->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -1370,15 +1189,7 @@ TEST(PairStyle, opt)
if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "init_forces stats:" << stats << std::endl;
Pair *pair = lmp->force->pair; Pair *pair = lmp->force->pair;
double *stress = pair->virial; EXPECT_STRESS("init_stress", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "init_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
@ -1391,7 +1202,6 @@ TEST(PairStyle, opt)
f = lmp->atom->f; f = lmp->atom->f;
tag = lmp->atom->tag; tag = lmp->atom->tag;
stress = pair->virial;
const std::vector<coord_t> &f_run = test_config.run_forces; const std::vector<coord_t> &f_run = test_config.run_forces;
ASSERT_EQ(nlocal + 1, f_run.size()); ASSERT_EQ(nlocal + 1, f_run.size());
stats.reset(); stats.reset();
@ -1402,15 +1212,7 @@ TEST(PairStyle, opt)
} }
if (print_stats) std::cerr << "run_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "run_forces stats:" << stats << std::endl;
stress = pair->virial; EXPECT_STRESS("run_stress", pair->virial, test_config.run_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.run_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.run_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.run_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.run_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.run_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.run_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "run_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
int id = lmp->modify->find_compute("sum"); int id = lmp->modify->find_compute("sum");
@ -1436,15 +1238,7 @@ TEST(PairStyle, opt)
if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl; if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl;
pair = lmp->force->pair; pair = lmp->force->pair;
stress = pair->virial; EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, 10 * epsilon);
stats.reset();
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, 10 * epsilon);
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, 10 * epsilon);
if (print_stats) std::cerr << "nofdotr_stress stats:" << stats << std::endl;
stats.reset(); stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, 5 * epsilon); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, 5 * epsilon);