Ejemplo n.º 1
0
void compareFrames(const std::pair<TrajectoryFrame, TrajectoryFrame> &frames,
                   FloatingPointTolerance tolerance)
{
    auto &reference = frames.first;
    auto &test      = frames.second;

    // NB We checked earlier for both frames that bStep and bTime are set

    EXPECT_EQ(reference.frame_->step, test.frame_->step)
    << "step didn't match between reference run " << reference.getFrameName() << " and test run " << test.getFrameName();

    EXPECT_EQ(reference.frame_->time, test.frame_->time)
    << "time didn't match between reference run " << reference.getFrameName() << " and test run " << test.getFrameName();

    for (int i = 0; i < reference.frame_->natoms && i < test.frame_->natoms; ++i)
    {
        for (int d = 0; d < DIM; ++d)
        {
            if (reference.frame_->bX && test.frame_->bX)
            {
                EXPECT_REAL_EQ_TOL(reference.frame_->x[i][d], test.frame_->x[i][d], tolerance)
                << " x[" << i << "][" << d <<"] didn't match between reference run " << reference.getFrameName() << " and test run " << test.getFrameName();
            }
            if (reference.frame_->bV && test.frame_->bV)
            {
                EXPECT_REAL_EQ_TOL(reference.frame_->v[i][d], test.frame_->v[i][d], tolerance)
                << " v[" << i << "][" << d <<"] didn't match between reference run " << reference.getFrameName() << " and test run " << test.getFrameName();
            }
            if (reference.frame_->bF && test.frame_->bF)
            {
                EXPECT_REAL_EQ_TOL(reference.frame_->f[i][d], test.frame_->f[i][d], tolerance)
                << " f[" << i << "][" << d <<"] didn't match between reference run " << reference.getFrameName() << " and test run " << test.getFrameName();
            }
        }
    }
}
Ejemplo n.º 2
0
void compareFrames(const std::pair<EnergyFrame, EnergyFrame> &frames,
                   FloatingPointTolerance tolerance)
{
    auto &reference = frames.first;
    auto &test      = frames.second;

    for (auto referenceIt = reference.values_.begin(); referenceIt != reference.values_.end(); ++referenceIt)
    {
        auto testIt = test.values_.find(referenceIt->first);
        if (testIt != test.values_.end())
        {
            auto energyFieldInReference = referenceIt->second;
            auto energyFieldInTest      = testIt->second;
            EXPECT_REAL_EQ_TOL(energyFieldInReference, energyFieldInTest, tolerance)
            << referenceIt->first << " didn't match between reference run " << reference.getFrameName() << " and test run " << test.getFrameName();
        }
    }
}