added run_torque and EXPECT_TORQUES

This commit is contained in:
alphataubio
2024-08-04 22:40:36 -04:00
parent c2e192e734
commit af203f7fc7
6 changed files with 51 additions and 0 deletions

View File

@ -101,6 +101,23 @@ void EXPECT_VELOCITIES(const std::string &name, Atom *atom, const std::vector<co
if (print_stats) std::cerr << name << " stats: " << stats << std::endl;
}
void EXPECT_TORQUES(const std::string &name, Atom *atom, const std::vector<coord_t> &t_ref,
double epsilon)
{
SCOPED_TRACE("EXPECT_TORQUES: " + name);
double **t = atom->torque;
tagint *tag = atom->tag;
const int nlocal = atom->nlocal;
ASSERT_EQ(nlocal + 1, t_ref.size());
ErrorStats stats;
for (int i = 0; i < nlocal; ++i) {
EXPECT_FP_LE_WITH_EPS(t[i][0], t_ref[tag[i]].x, epsilon);
EXPECT_FP_LE_WITH_EPS(t[i][1], t_ref[tag[i]].y, epsilon);
EXPECT_FP_LE_WITH_EPS(t[i][2], t_ref[tag[i]].z, 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)
{