Add EXPECT_POSITIONS() and EXPECT_VELOCITIES() test utils

This commit is contained in:
Richard Berger
2021-11-23 12:21:27 -05:00
parent 32a53a1ae3
commit 073b586eee
3 changed files with 55 additions and 244 deletions

View File

@ -59,7 +59,35 @@ void EXPECT_FORCES(const std::string & name, Atom * atom, const std::vector<coor
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 << name << " stats, newton on: " << stats << std::endl;
if (print_stats) std::cerr << name << " stats" << stats << std::endl;
}
void EXPECT_POSITIONS(const std::string & name, Atom * atom, const std::vector<coord_t> & x_ref, double epsilon) {
double ** x = atom->x;
tagint * tag = atom->tag;
const int nlocal = atom->nlocal;
ASSERT_EQ(nlocal + 1, x_ref.size());
ErrorStats stats;
for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(x[i][0], x_ref[tag[i]].x, epsilon);
EXPECT_FP_LE_WITH_EPS(x[i][1], x_ref[tag[i]].y, epsilon);
EXPECT_FP_LE_WITH_EPS(x[i][2], x_ref[tag[i]].z, epsilon);
}
if (print_stats) std::cerr << name << " stats" << stats << std::endl;
}
void EXPECT_VELOCITIES(const std::string & name, Atom * atom, const std::vector<coord_t> & v_ref, double epsilon) {
double ** v = atom->v;
tagint * tag = atom->tag;
const int nlocal = atom->nlocal;
ASSERT_EQ(nlocal + 1, v_ref.size());
ErrorStats stats;
for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(v[i][0], v_ref[tag[i]].x, epsilon);
EXPECT_FP_LE_WITH_EPS(v[i][1], v_ref[tag[i]].y, epsilon);
EXPECT_FP_LE_WITH_EPS(v[i][2], v_ref[tag[i]].z, epsilon);
}
if (print_stats) std::cerr << name << " stats" << stats << std::endl;
}
// common read_yaml_file function