TEST(TopSortTest, WorksOnEmptyIdef)
{
- gmx_ffparams_t forcefieldParams;
- InteractionDefinitions idef(forcefieldParams);
- real* emptyChargeA = nullptr;
- real* emptyChargeB = nullptr;
+ gmx_ffparams_t forcefieldParams;
+ InteractionDefinitions idef(forcefieldParams);
+ ArrayRef<const int64_t> emptyAtomInfo;
- gmx_sort_ilist_fe(&idef, emptyChargeA, emptyChargeB);
+ gmx_sort_ilist_fe(&idef, emptyAtomInfo);
EXPECT_EQ(0, idef.numNonperturbedInteractions[F_BONDS]) << "empty idef has no perturbed bonds";
EXPECT_THAT(idef.il[F_BONDS].iatoms, IsEmpty());
// F_LJ14
forcefieldParams.iparams.push_back(makeUnperturbedLJ14Params(100, 10000));
idef.il[F_LJ14].push_back(forcefieldParams.iparams.size() - 1, bondAtoms);
- std::vector<real> chargeA{ -1, 2 };
- std::vector<real> chargeB{ -1, 2 };
+ std::vector<int64_t> atomInfo{ 0, 0 };
- gmx_sort_ilist_fe(&idef, chargeA.data(), chargeB.data());
+ gmx_sort_ilist_fe(&idef, atomInfo);
EXPECT_EQ(1, idef.numNonperturbedInteractions[F_BONDS] / (NRAL(F_BONDS) + 1))
<< "idef with no perturbed bonds has no perturbed bonds";
forcefieldParams.iparams.push_back(makePerturbedLJ14Params(100, 10000, 200, 20000));
idef.il[F_LJ14].push_back(forcefieldParams.iparams.size() - 1, perturbedBondAtoms);
// Perturb the charge of atom 2, affecting the non-perturbed LJ14 above
- std::vector<real> chargeA{ -1, 2, -2, 0 };
- std::vector<real> chargeB{ -1, 2, 4, 0 };
+ std::vector<int64_t> atomInfo{ 0, 0, sc_atomInfo_HasPerturbedChargeIn14Interaction, 0 };
- gmx_sort_ilist_fe(&idef, chargeA.data(), chargeB.data());
+ gmx_sort_ilist_fe(&idef, atomInfo);
EXPECT_EQ(1, idef.numNonperturbedInteractions[F_BONDS] / (NRAL(F_BONDS) + 1))
<< "idef with a perturbed bond has a perturbed bond";
forcefieldParams.iparams.push_back(makeUnperturbedLJ14Params(100, 10000));
idef.il[F_LJ14].push_back(forcefieldParams.iparams.size() - 1, bondAtoms);
// Perturb the charge of atom 2, affecting the non-perturbed LJ14 above
- std::vector<real> chargeA{ -1, 2, -2, 0 };
- std::vector<real> chargeB{ -1, 2, 4, 0 };
+ std::vector<int64_t> atomInfo{ 0, 0, sc_atomInfo_HasPerturbedChargeIn14Interaction, 0 };
- gmx_sort_ilist_fe(&idef, chargeA.data(), chargeB.data());
+ gmx_sort_ilist_fe(&idef, atomInfo);
EXPECT_EQ(1, idef.numNonperturbedInteractions[F_BONDS] / (NRAL(F_BONDS) + 1))
<< "idef with a perturbed bond has a perturbed bond";
forcefieldParams.iparams.push_back(makeUnperturbedLJ14Params(100, 10000));
idef.il[F_LJ14].push_back(forcefieldParams.iparams.size() - 1, moreBondAtoms);
// Perturb the charge of atom 2, affecting the non-perturbed LJ14 above
- std::vector<real> chargeA{ -1, 2, -2, 0, 1, -2, 3, -3 };
- std::vector<real> chargeB{ -1, 2, 4, 0, 1, -2, 3, -3 };
+ std::vector<int64_t> atomInfo{ 0, 0, sc_atomInfo_HasPerturbedChargeIn14Interaction, 0, 0, 0,
+ 0, 0 };
- gmx_sort_ilist_fe(&idef, chargeA.data(), chargeB.data());
+ gmx_sort_ilist_fe(&idef, atomInfo);
EXPECT_EQ(2, idef.numNonperturbedInteractions[F_BONDS] / (NRAL(F_BONDS) + 1))
<< "idef with some perturbed bonds has some perturbed bonds";