static void gen_pairs(const InteractionTypeParameters &nbs, InteractionTypeParameters *pairs, real fudge, int comb)
{
real scaling;
- int ntp = nbs.nr;
+ int ntp = nbs.size();
int nnn = static_cast<int>(std::sqrt(static_cast<double>(ntp)));
GMX_ASSERT(nnn * nnn == ntp, "Number of pairs of generated non-bonded parameters should be a perfect square");
int nrfp = NRFP(F_LJ);
int nrfpA = interaction_function[F_LJ14].nrfpA;
int nrfpB = interaction_function[F_LJ14].nrfpB;
- pairs->nr = ntp;
if ((nrfp != nrfpA) || (nrfpA != nrfpB))
{
}
fprintf(stderr, "Generating 1-4 interactions: fudge = %g\n", fudge);
- snew(pairs->param, pairs->nr);
- for (int i = 0; (i < ntp); i++)
+ pairs->interactionTypes.clear();
+ int i = 0;
+ std::array<int, 2> atomNumbers;
+ std::array<real, MAXFORCEPARAM> forceParam = {NOTSET};
+ for (const auto &type : nbs.interactionTypes)
{
- /* Copy param.a */
- pairs->param[i].a[0] = i / nnn;
- pairs->param[i].a[1] = i % nnn;
+ /* Copy type.atoms */
+ atomNumbers = {i / nnn, i % nnn };
/* Copy normal and FEP parameters and multiply by fudge factor */
-
-
-
- for (int j = 0; (j < nrfp); j++)
+ gmx::ArrayRef<const real> existingParam = type.forceParam();
+ GMX_RELEASE_ASSERT(2*nrfp <= MAXFORCEPARAM, "Can't have more parameters than half of maximum p arameter number");
+ for (int j = 0; j < nrfp; j++)
{
/* If we are using sigma/epsilon values, only the epsilon values
* should be scaled, but not sigma.
scaling = fudge;
}
- pairs->param[i].c[j] = scaling*nbs.param[i].c[j];
- /* NOTE: this should be clear to the compiler, but some gcc 5.2 versions
- * issue false positive warnings for the pairs->param.c[] indexing below.
- */
- assert(2*nrfp <= MAXFORCEPARAM);
- pairs->param[i].c[nrfp+j] = scaling*nbs.param[i].c[j];
+ forceParam[j] = scaling*existingParam[j];
+ forceParam[nrfp+j] = scaling*existingParam[j];
}
+ pairs->interactionTypes.emplace_back(InteractionType(atomNumbers, forceParam));
+ i++;
}
}