diff --git a/unittest/force-styles/test_angle_style.cpp b/unittest/force-styles/test_angle_style.cpp index 368ccb19ff..ca0573840e 100644 --- a/unittest/force-styles/test_angle_style.cpp +++ b/unittest/force-styles/test_angle_style.cpp @@ -300,6 +300,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config) return; } + TEST(AngleStyle, plain) { 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; auto angle = lmp->force->angle; - auto stress = angle->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); @@ -367,7 +360,6 @@ TEST(AngleStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = angle->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = angle->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, epsilon); stats.reset(); 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; angle = lmp->force->angle; - stress = angle->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress, 2*epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); @@ -435,7 +411,6 @@ TEST(AngleStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = angle->virial; stats.reset(); for (int i = 0; i < nlocal; ++i) { 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; - stress = angle->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); @@ -478,15 +445,7 @@ TEST(AngleStyle, plain) if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; angle = lmp->force->angle; - stress = angle->virial; - 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; + EXPECT_STRESS("restart_stress", angle->virial, test_config.init_stress, epsilon); stats.reset(); 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; angle = lmp->force->angle; - stress = angle->virial; - 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; + EXPECT_STRESS("data_stress", angle->virial, test_config.init_stress, epsilon); stats.reset(); 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; auto angle = lmp->force->angle; - auto stress = angle->virial; - - 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; + EXPECT_STRESS("init_stress (newton on)", angle->virial, test_config.init_stress, 10 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(angle->energy, test_config.init_energy, epsilon); @@ -598,7 +540,6 @@ TEST(AngleStyle, omp) f = lmp->atom->f; tag = lmp->atom->tag; - stress = angle->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = angle->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", angle->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; angle = lmp->force->angle; - stress = angle->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", angle->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; - stress = angle->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", angle->virial, test_config.run_stress, 10 * epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); diff --git a/unittest/force-styles/test_bond_style.cpp b/unittest/force-styles/test_bond_style.cpp index 6eed92082b..a8f5ba3044 100644 --- a/unittest/force-styles/test_bond_style.cpp +++ b/unittest/force-styles/test_bond_style.cpp @@ -347,15 +347,7 @@ TEST(BondStyle, plain) if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; auto bond = lmp->force->bond; - auto stress = bond->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", bond->virial, test_config.init_stress, epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); @@ -367,7 +359,6 @@ TEST(BondStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = bond->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = bond->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, epsilon); stats.reset(); 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; bond = lmp->force->bond; - stress = bond->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", bond->virial, test_config.init_stress, 2 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); @@ -435,7 +410,6 @@ TEST(BondStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = bond->virial; stats.reset(); for (int i = 0; i < nlocal; ++i) { 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; - stress = bond->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", bond->virial, test_config.run_stress, epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); @@ -478,15 +444,7 @@ TEST(BondStyle, plain) if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; bond = lmp->force->bond; - stress = bond->virial; - 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; + EXPECT_STRESS("restart_stress", bond->virial, test_config.init_stress, epsilon); stats.reset(); 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; bond = lmp->force->bond; - stress = bond->virial; - 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; + EXPECT_STRESS("data_stress", bond->virial, test_config.init_stress, epsilon); stats.reset(); 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; auto bond = lmp->force->bond; - auto stress = bond->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", bond->virial, test_config.init_stress, 10 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(bond->energy, test_config.init_energy, epsilon); @@ -597,7 +539,6 @@ TEST(BondStyle, omp) f = lmp->atom->f; tag = lmp->atom->tag; - stress = bond->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = bond->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", bond->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; bond = lmp->force->bond; - stress = bond->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", bond->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; - stress = bond->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", bond->virial, test_config.run_stress, 10 * epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); diff --git a/unittest/force-styles/test_dihedral_style.cpp b/unittest/force-styles/test_dihedral_style.cpp index a009f5f9a6..e26b066485 100644 --- a/unittest/force-styles/test_dihedral_style.cpp +++ b/unittest/force-styles/test_dihedral_style.cpp @@ -350,15 +350,7 @@ TEST(DihedralStyle, plain) if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; auto dihedral = lmp->force->dihedral; - auto stress = dihedral->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", dihedral->virial, test_config.init_stress, epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); @@ -370,7 +362,6 @@ TEST(DihedralStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = dihedral->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = dihedral->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, epsilon); stats.reset(); 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; dihedral = lmp->force->dihedral; - stress = dihedral->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", dihedral->virial, test_config.init_stress, epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); @@ -438,7 +413,6 @@ TEST(DihedralStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = dihedral->virial; stats.reset(); for (int i = 0; i < nlocal; ++i) { 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; - stress = dihedral->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", dihedral->virial, test_config.run_stress, epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); @@ -481,15 +447,7 @@ TEST(DihedralStyle, plain) if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; dihedral = lmp->force->dihedral; - stress = dihedral->virial; - 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; + EXPECT_STRESS("restart_stress", dihedral->virial, test_config.init_stress, epsilon); stats.reset(); 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; dihedral = lmp->force->dihedral; - stress = dihedral->virial; - 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; + EXPECT_STRESS("data_stress", dihedral->virial, test_config.init_stress, epsilon); stats.reset(); 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; auto dihedral = lmp->force->dihedral; - auto stress = dihedral->virial; - - 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; + EXPECT_STRESS("init_stress (newton on)", dihedral->virial, test_config.init_stress, 10 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(dihedral->energy, test_config.init_energy, epsilon); @@ -601,7 +542,6 @@ TEST(DihedralStyle, omp) f = lmp->atom->f; tag = lmp->atom->tag; - stress = dihedral->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = dihedral->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", dihedral->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; dihedral = lmp->force->dihedral; - stress = dihedral->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", dihedral->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; - stress = dihedral->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", dihedral->virial, test_config.run_stress, 10 * epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); diff --git a/unittest/force-styles/test_fix_timestep.cpp b/unittest/force-styles/test_fix_timestep.cpp index 27ad3ce203..8c6ffeb617 100644 --- a/unittest/force-styles/test_fix_timestep.cpp +++ b/unittest/force-styles/test_fix_timestep.cpp @@ -37,6 +37,7 @@ #include "universe.h" #include "utils.h" #include "variable.h" +#include "platform.h" #include #include @@ -311,15 +312,7 @@ TEST(FixTimestep, plain) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (normal run, verlet)", fix->virial, test_config.run_stress, epsilon); } stats.reset(); @@ -386,15 +379,7 @@ TEST(FixTimestep, plain) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (restart, verlet)", fix->virial, test_config.run_stress, epsilon); } stats.reset(); @@ -450,15 +435,7 @@ TEST(FixTimestep, plain) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (rmass, verlet)", fix->virial, test_config.run_stress, epsilon); } stats.reset(); @@ -528,16 +505,7 @@ TEST(FixTimestep, plain) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (normal run, respa)", fix->virial, test_config.run_stress, 1000 * epsilon); } stats.reset(); @@ -592,15 +560,7 @@ TEST(FixTimestep, plain) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (restart, respa)", fix->virial, test_config.run_stress, 1000 * epsilon); } stats.reset(); @@ -656,15 +616,7 @@ TEST(FixTimestep, plain) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (rmass, respa)", fix->virial, test_config.run_stress, 1000 * epsilon); } stats.reset(); @@ -763,15 +715,7 @@ TEST(FixTimestep, omp) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (normal run, verlet)", fix->virial, test_config.run_stress, epsilon); } stats.reset(); @@ -838,15 +782,7 @@ TEST(FixTimestep, omp) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (restart, verlet)", fix->virial, test_config.run_stress, epsilon); } stats.reset(); @@ -902,15 +838,7 @@ TEST(FixTimestep, omp) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (rmass, verlet)", fix->virial, test_config.run_stress, epsilon); } stats.reset(); @@ -980,16 +908,7 @@ TEST(FixTimestep, omp) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (normal run, respa)", fix->virial, test_config.run_stress, 1000 * epsilon); } stats.reset(); @@ -1044,15 +963,7 @@ TEST(FixTimestep, omp) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (restart, respa)", fix->virial, test_config.run_stress, 1000 * epsilon); } stats.reset(); @@ -1108,15 +1019,7 @@ TEST(FixTimestep, omp) } else { Fix *fix = lmp->modify->fix[ifix]; if (fix->thermo_virial) { - stats.reset(); - 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; + EXPECT_STRESS("run_stress (rmass, respa)", fix->virial, test_config.run_stress, 1000 * epsilon); } stats.reset(); diff --git a/unittest/force-styles/test_improper_style.cpp b/unittest/force-styles/test_improper_style.cpp index 4eebe8013e..749f8be53f 100644 --- a/unittest/force-styles/test_improper_style.cpp +++ b/unittest/force-styles/test_improper_style.cpp @@ -341,15 +341,7 @@ TEST(ImproperStyle, plain) if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; auto improper = lmp->force->improper; - auto stress = improper->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", improper->virial, test_config.init_stress, epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); @@ -361,7 +353,6 @@ TEST(ImproperStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = improper->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = improper->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, epsilon); stats.reset(); 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; improper = lmp->force->improper; - stress = improper->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", improper->virial, test_config.init_stress, 2 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); @@ -429,7 +404,6 @@ TEST(ImproperStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = improper->virial; stats.reset(); for (int i = 0; i < nlocal; ++i) { 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; - stress = improper->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", improper->virial, test_config.run_stress, epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); @@ -472,15 +438,7 @@ TEST(ImproperStyle, plain) if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; improper = lmp->force->improper; - stress = improper->virial; - 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; + EXPECT_STRESS("restart_stress", improper->virial, test_config.init_stress, epsilon); stats.reset(); 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; improper = lmp->force->improper; - stress = improper->virial; - 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; + EXPECT_STRESS("data_stress", improper->virial, test_config.init_stress, epsilon); stats.reset(); 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; auto improper = lmp->force->improper; - auto stress = improper->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", improper->virial, test_config.init_stress, 10 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(improper->energy, test_config.init_energy, epsilon); @@ -592,7 +534,6 @@ TEST(ImproperStyle, omp) f = lmp->atom->f; tag = lmp->atom->tag; - stress = improper->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = improper->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", improper->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; improper = lmp->force->improper; - stress = improper->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", improper->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; - stress = improper->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", improper->virial, test_config.run_stress, 10 * epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); diff --git a/unittest/force-styles/test_main.cpp b/unittest/force-styles/test_main.cpp index 1ad0b79455..cac385f844 100644 --- a/unittest/force-styles/test_main.cpp +++ b/unittest/force-styles/test_main.cpp @@ -15,10 +15,12 @@ #include "pointers.h" #include "test_config.h" #include "test_config_reader.h" +#include "error_stats.h" #include "utils.h" #include "yaml_writer.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "lammps.h" #include #include @@ -27,9 +29,22 @@ #include #include +using LAMMPS_NS::LAMMPS; using LAMMPS_NS::utils::split_words; 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 bool read_yaml_file(const char *infile, TestConfig &config) { diff --git a/unittest/force-styles/test_main.h b/unittest/force-styles/test_main.h index 3a9651e621..4fe0422318 100644 --- a/unittest/force-styles/test_main.h +++ b/unittest/force-styles/test_main.h @@ -34,6 +34,8 @@ void write_yaml_header(class YamlWriter *writer, TestConfig *cfg, const char *ve EXPECT_PRED_FORMAT2(::testing::DoubleLE, err, eps); \ } while (0); +void EXPECT_STRESS(const std::string & name, double * stress, const stress_t & expected_stress, double epsilon); + #if defined _WIN32 static const char PATH_SEP = '\\'; #else diff --git a/unittest/force-styles/test_pair_style.cpp b/unittest/force-styles/test_pair_style.cpp index 6e4a22152e..205f709c92 100644 --- a/unittest/force-styles/test_pair_style.cpp +++ b/unittest/force-styles/test_pair_style.cpp @@ -370,15 +370,7 @@ TEST(PairStyle, plain) if (print_stats) std::cerr << "init_forces stats, newton on: " << stats << std::endl; auto pair = lmp->force->pair; - auto stress = pair->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", pair->virial, test_config.init_stress, epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); @@ -391,7 +383,6 @@ TEST(PairStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = pair->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", pair->virial, test_config.run_stress, epsilon); stats.reset(); 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; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 3 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); @@ -463,7 +438,6 @@ TEST(PairStyle, plain) f = lmp->atom->f; tag = lmp->atom->tag; - stress = pair->virial; stats.reset(); for (int i = 0; i < nlocal; ++i) { 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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); @@ -509,15 +475,7 @@ TEST(PairStyle, plain) if (print_stats) std::cerr << "restart_forces stats:" << stats << std::endl; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("restart_stress", pair->virial, test_config.init_stress, epsilon); stats.reset(); 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; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, epsilon); stats.reset(); 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; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("data_stress", pair->virial, test_config.init_stress, epsilon); stats.reset(); 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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (r-RESPA)", pair->virial, test_config.run_stress, epsilon); stats.reset(); 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; auto pair = lmp->force->pair; - auto stress = pair->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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(); f = lmp->atom->f; - stress = pair->virial; tag = lmp->atom->tag; const std::vector &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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", pair->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, 10 * epsilon); stats.reset(); id = lmp->modify->find_compute("sum"); @@ -827,15 +728,7 @@ TEST(PairStyle, omp) if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; auto pair = lmp->force->pair; - auto stress = pair->virial; - 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; + EXPECT_STRESS("init_stress (newton on)", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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(); f = lmp->atom->f; - stress = pair->virial; tag = lmp->atom->tag; const std::vector &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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (newton on)", pair->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; auto pair = lmp->force->pair; - auto stress = pair->virial; - 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; + EXPECT_STRESS("init_stress (newton off)", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); 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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress (newton off)", pair->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; Pair *pair = lmp->force->pair; - double *stress = pair->virial; - 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; + EXPECT_STRESS("init_stress", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); @@ -1278,7 +1106,6 @@ TEST(PairStyle, intel) f = lmp->atom->f; tag = lmp->atom->tag; - stress = pair->virial; const std::vector &f_run = test_config.run_forces; 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; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress", pair->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; Pair *pair = lmp->force->pair; - double *stress = pair->virial; - 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; + EXPECT_STRESS("init_stress", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon); @@ -1391,7 +1202,6 @@ TEST(PairStyle, opt) f = lmp->atom->f; tag = lmp->atom->tag; - stress = pair->virial; const std::vector &f_run = test_config.run_forces; ASSERT_EQ(nlocal + 1, f_run.size()); stats.reset(); @@ -1402,15 +1212,7 @@ TEST(PairStyle, opt) } if (print_stats) std::cerr << "run_forces stats:" << stats << std::endl; - stress = pair->virial; - 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; + EXPECT_STRESS("run_stress", pair->virial, test_config.run_stress, 10 * epsilon); stats.reset(); 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; pair = lmp->force->pair; - stress = pair->virial; - 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; + EXPECT_STRESS("nofdotr_stress", pair->virial, test_config.init_stress, 10 * epsilon); stats.reset(); EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, 5 * epsilon);