add a test for r-RESPA (only with newton on and for plain styles for now)

This commit is contained in:
Axel Kohlmeyer
2020-05-21 11:17:49 -04:00
parent 0788a8ee4f
commit 4f44159d56

View File

@ -581,6 +581,51 @@ TEST(PairStyle, plain) {
if (print_stats) if (print_stats)
std::cerr << "data_energy stats:" << stats << std::endl; std::cerr << "data_energy stats:" << stats << std::endl;
if (pair->respa_enable) {
if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp,test_config);
lmp = init_lammps(argc,argv,test_config,false);
lmp->input->one("run_style respa 2 1 inner 1 4.0 5.0 outer 2");
run_lammps(lmp);
if (!verbose) ::testing::internal::GetCapturedStdout();
// need to relax error by a large amount with tabulation, since
// coul/long styles do not use tabulation in compute_inner()
// and compute_middle() so we get a significant deviation.
if (pair->ncoultablebits) epsilon *= 1.0e6;
f = lmp->atom->f;
tag=lmp->atom->tag;
pair = lmp->force->pair;
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, 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;
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, r-RESPA:" << stats << std::endl;
}
if (!verbose) ::testing::internal::CaptureStdout(); if (!verbose) ::testing::internal::CaptureStdout();
cleanup_lammps(lmp,test_config); cleanup_lammps(lmp,test_config);
if (!verbose) ::testing::internal::GetCapturedStdout(); if (!verbose) ::testing::internal::GetCapturedStdout();