skip over newton_pair == off tests if newton_pair is forced to be on

This commit is contained in:
Axel Kohlmeyer
2020-05-26 18:36:22 -04:00
parent dff78c19aa
commit 0f8ff07da2

View File

@ -449,69 +449,73 @@ TEST(PairStyle, plain) {
lmp = init_lammps(argc,argv,test_config,false);
if (!verbose) ::testing::internal::GetCapturedStdout();
f=lmp->atom->f;
tag=lmp->atom->tag;
stats.reset();
for (int i=0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
// skip over these tests if newton pair is forced to be on
if (lmp->force->newton_pair != 0) {
f=lmp->atom->f;
tag=lmp->atom->tag;
stats.reset();
for (int i=0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
}
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;
stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
if (print_stats)
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
if (!verbose) ::testing::internal::CaptureStdout();
run_lammps(lmp);
if (!verbose) ::testing::internal::GetCapturedStdout();
f = lmp->atom->f;
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);
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5*epsilon);
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5*epsilon);
}
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;
stats.reset();
id = lmp->modify->find_compute("sum");
energy = lmp->modify->compute[id]->compute_scalar();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl+pair->eng_coul),energy, epsilon);
if (print_stats)
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
}
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;
stats.reset();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
if (print_stats)
std::cerr << "init_energy stats, newton off:" << stats << std::endl;
if (!verbose) ::testing::internal::CaptureStdout();
run_lammps(lmp);
if (!verbose) ::testing::internal::GetCapturedStdout();
f = lmp->atom->f;
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);
EXPECT_FP_LE_WITH_EPS(f[i][1], f_run[tag[i]].y, 5*epsilon);
EXPECT_FP_LE_WITH_EPS(f[i][2], f_run[tag[i]].z, 5*epsilon);
}
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;
stats.reset();
id = lmp->modify->find_compute("sum");
energy = lmp->modify->compute[id]->compute_scalar();
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.run_vdwl, epsilon);
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.run_coul, epsilon);
EXPECT_FP_LE_WITH_EPS((pair->eng_vdwl+pair->eng_coul),energy, epsilon);
if (print_stats)
std::cerr << "run_energy stats, newton off:" << stats << std::endl;
if (!verbose) ::testing::internal::CaptureStdout();
restart_lammps(lmp, test_config);