add tests for all improper styles except hybrid
This commit is contained in:
@ -769,153 +769,3 @@ TEST(ImproperStyle, omp)
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
};
|
||||
|
||||
// TODO: Improper styles do not have single() routines
|
||||
/*
|
||||
TEST(ImproperStyle, single)
|
||||
{
|
||||
const char *args[] = {"ImproperStyle", "-log", "none", "-echo", "screen", "-nocite"};
|
||||
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// create a LAMMPS instance with standard settings to detect the number of atom types
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = init_lammps(argc, argv, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
if (!lmp) {
|
||||
std::cerr << "One or more prerequisite styles are not available "
|
||||
"in this LAMMPS configuration:\n";
|
||||
for (auto &prerequisite : test_config.prerequisites) {
|
||||
std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n";
|
||||
}
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
// gather some information and skip if unsupported
|
||||
int nimpropertypes = lmp->atom->nimpropertypes;
|
||||
int molecular = lmp->atom->molecular;
|
||||
if (molecular != 1) {
|
||||
std::cerr << "Only simple molecular atom styles are supported\n";
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
// utility lambda to improve readability
|
||||
auto command = [&](const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
};
|
||||
|
||||
// now start over
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("clear");
|
||||
command("variable newton_bond delete");
|
||||
command("variable newton_bond index on");
|
||||
|
||||
command("variable input_dir index " + INPUT_FOLDER);
|
||||
|
||||
for (auto &pre_command : test_config.pre_commands) {
|
||||
command(pre_command);
|
||||
}
|
||||
|
||||
command("atom_style molecular");
|
||||
command("units ${units}");
|
||||
command("boundary p p p");
|
||||
command("newton ${newton_pair} ${newton_bond}");
|
||||
command("special_bonds lj/coul "
|
||||
"${bond_factor} ${angle_factor} ${dihedral_factor}");
|
||||
|
||||
command("atom_modify map array");
|
||||
command("region box block -10.0 10.0 -10.0 10.0 -10.0 10.0 units box");
|
||||
|
||||
command(fmt::format("create_box 1 box improper/types {} "
|
||||
"extra/improper/per/atom 2 extra/special/per/atom 2",
|
||||
nimpropertypes));
|
||||
|
||||
command("pair_style zero 8.0");
|
||||
command("pair_coeff * *");
|
||||
|
||||
command("improper_style " + test_config.improper_style);
|
||||
Improper *improper = lmp->force->improper;
|
||||
|
||||
for (auto &improper_coeff : test_config.improper_coeff) {
|
||||
command("improper_coeff " + improper_coeff);
|
||||
}
|
||||
|
||||
// create (only) four atoms and one improper
|
||||
command("mass * 1.0");
|
||||
command("create_atoms 1 single 5.0 -0.75 0.4 units box");
|
||||
command("create_atoms 1 single 5.5 0.25 -0.1 units box");
|
||||
command("create_atoms 1 single 5.0 0.75 0.4 units box");
|
||||
command("create_atoms 1 single 5.5 1.25 -0.1 units box");
|
||||
command("create_bonds single/improper 1 1 2 3 4");
|
||||
|
||||
for (auto &post_command : test_config.post_commands) {
|
||||
command(post_command);
|
||||
}
|
||||
|
||||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
int idx1 = lmp->atom->map(1);
|
||||
int idx2 = lmp->atom->map(2);
|
||||
int idx3 = lmp->atom->map(3);
|
||||
double epsilon = test_config.epsilon;
|
||||
double eangle[4], esingle[4];
|
||||
// TODO: why are atoms displaced randomly?
|
||||
|
||||
eangle[0] = angle->energy;
|
||||
esingle[0] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("displace_atoms all random 0.5 0.5 0.5 23456");
|
||||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[1] = angle->energy;
|
||||
esingle[1] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("displace_atoms all random 0.5 0.5 0.5 456963");
|
||||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[2] = angle->energy;
|
||||
esingle[2] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("displace_atoms all random 0.5 0.5 0.5 9726532");
|
||||
command("run 0 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
idx1 = lmp->atom->map(1);
|
||||
idx2 = lmp->atom->map(2);
|
||||
idx3 = lmp->atom->map(3);
|
||||
eangle[3] = angle->energy;
|
||||
esingle[3] = angle->single(1, idx1, idx2, idx3);
|
||||
|
||||
ErrorStats stats;
|
||||
EXPECT_FP_LE_WITH_EPS(eangle[0], esingle[0], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(eangle[1], esingle[1], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(eangle[2], esingle[2], epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(eangle[3], esingle[3], epsilon);
|
||||
if (print_stats) std::cerr << "single_energy stats:" << stats << std::endl;
|
||||
|
||||
// int i = 0;
|
||||
// for (auto &dist : test_config.equilibrium)
|
||||
// EXPECT_NEAR(dist, angle->equilibrium_angle(++i), 0.00001);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user