//! Templated free-energy non-bonded kernel
-template<typename DataTypes, SoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald, bool vdwModifierIsPotSwitch, bool computeForce>
+template<typename DataTypes, KernelSoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald, bool vdwModifierIsPotSwitch, bool computeForces>
static void nb_free_energy_kernel(const t_nblist& nlist,
const gmx::ArrayRefWithPadding<const gmx::RVec>& coords,
const int ntype,
{
preloadLjPmeC6Grid[i][s] = 0;
}
- if constexpr (softcoreType == SoftcoreType::Beutler
- || softcoreType == SoftcoreType::Gapsys)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler
+ || softcoreType == KernelSoftcoreType::Gapsys)
{
const real c6 = nbfp[2 * typeIndices[i][s]];
const real c12 = nbfp[2 * typeIndices[i][s] + 1];
}
}
}
- if constexpr (softcoreType == SoftcoreType::Beutler
- || softcoreType == SoftcoreType::Gapsys)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler
+ || softcoreType == KernelSoftcoreType::Gapsys)
{
/* only use softcore if one of the states has a zero endstate - softcore is for avoiding infinities!*/
const real c12A = nbfp[2 * typeIndices[STATE_A][s] + 1];
}
else
{
- if constexpr (softcoreType == SoftcoreType::Beutler)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler)
{
preloadAlphaVdwEff[s] = alpha_vdw;
preloadAlphaCoulEff[s] = alpha_coul;
}
- else if constexpr (softcoreType == SoftcoreType::Gapsys)
+ else if constexpr (softcoreType == KernelSoftcoreType::Gapsys)
{
preloadAlphaVdwEff[s] = alpha_vdw;
preloadAlphaCoulEff[s] = gmx::sixthroot(sigma6_def);
gmx::gatherLoadTranspose<2>(nbfp.data(), typeIndices[i], &c6[i], &c12[i]);
qq[i] = gmx::load<RealType>(preloadQq[i]);
ljPmeC6Grid[i] = gmx::load<RealType>(preloadLjPmeC6Grid[i]);
- if constexpr (softcoreType == SoftcoreType::Beutler || softcoreType == SoftcoreType::Gapsys)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler
+ || softcoreType == KernelSoftcoreType::Gapsys)
{
sigma6[i] = gmx::load<RealType>(preloadSigma6[i]);
}
}
- if constexpr (softcoreType == SoftcoreType::Beutler || softcoreType == SoftcoreType::Gapsys)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler
+ || softcoreType == KernelSoftcoreType::Gapsys)
{
alphaVdwEff = gmx::load<RealType>(preloadAlphaVdwEff);
alphaCoulEff = gmx::load<RealType>(preloadAlphaCoulEff);
r = rSq * rInv;
RealType gmx_unused rp, rpm2;
- if constexpr (softcoreType == SoftcoreType::Beutler)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler)
{
rpm2 = rSq * rSq; /* r4 */
rp = rpm2 * rSq; /* r6 */
&& bPairIncluded && withinCutoffMask);
if (gmx::anyTrue(nonZeroState))
{
- if constexpr (softcoreType == SoftcoreType::Beutler)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler)
{
RealType divisor = (alphaCoulEff * lFacCoul[i] * sigma6[i] + rp);
rPInvC = gmx::inv(divisor);
fScalC[i] = ewaldScalarForce(qq[i], rInvC);
}
- if constexpr (softcoreType == SoftcoreType::Gapsys)
+ if constexpr (softcoreType == KernelSoftcoreType::Gapsys)
{
ewaldQuadraticPotential(qq[i],
facel,
fScalC[i] = reactionFieldScalarForce(qq[i], rInvC, rC, krf, two);
}
- if constexpr (softcoreType == SoftcoreType::Gapsys)
+ if constexpr (softcoreType == KernelSoftcoreType::Gapsys)
{
reactionFieldQuadraticPotential(qq[i],
facel,
if (gmx::anyTrue(computeVdwInteraction))
{
RealType rInv6;
- if constexpr (softcoreType == SoftcoreType::Beutler)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler)
{
rInv6 = rPInvV;
}
fScalV[i] = lennardJonesScalarForce(vVdw6, vVdw12);
}
- if constexpr (softcoreType == SoftcoreType::Gapsys)
+ if constexpr (softcoreType == KernelSoftcoreType::Gapsys)
{
lennardJonesQuadraticPotential(c6[i],
c12[i],
fScal = fScal + LFV[i] * fScalV[i] * rpm2;
}
- if constexpr (softcoreType == SoftcoreType::Beutler)
+ if constexpr (softcoreType == KernelSoftcoreType::Beutler)
{
dvdlCoul = dvdlCoul + vCoul[i] * DLF[i]
+ LFC[i] * alphaCoulEff * dlFacCoul[i] * fScalC[i] * sigma6[i];
gmx::ArrayRef<real> threadVv,
gmx::ArrayRef<real> threadDvdl);
-template<SoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald, bool vdwModifierIsPotSwitch, bool computeForces>
+template<KernelSoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald, bool vdwModifierIsPotSwitch, bool computeForces>
static KernelFunction dispatchKernelOnUseSimd(const bool useSimd)
{
if (useSimd)
}
}
-template<SoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald, bool vdwModifierIsPotSwitch>
+template<KernelSoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald, bool vdwModifierIsPotSwitch>
static KernelFunction dispatchKernelOnComputeForces(const bool computeForces, const bool useSimd)
{
if (computeForces)
}
}
-template<SoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald>
+template<KernelSoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald, bool elecInteractionTypeIsEwald>
static KernelFunction dispatchKernelOnVdwModifier(const bool vdwModifierIsPotSwitch,
const bool computeForces,
const bool useSimd)
}
}
-template<SoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald>
+template<KernelSoftcoreType softcoreType, bool scLambdasOrAlphasDiffer, bool vdwInteractionTypeIsEwald>
static KernelFunction dispatchKernelOnElecInteractionType(const bool elecInteractionTypeIsEwald,
const bool vdwModifierIsPotSwitch,
const bool computeForces,
}
}
-template<SoftcoreType softcoreType, bool scLambdasOrAlphasDiffer>
+template<KernelSoftcoreType softcoreType, bool scLambdasOrAlphasDiffer>
static KernelFunction dispatchKernelOnVdwInteractionType(const bool vdwInteractionTypeIsEwald,
const bool elecInteractionTypeIsEwald,
const bool vdwModifierIsPotSwitch,
}
}
-template<SoftcoreType softcoreType>
+template<KernelSoftcoreType softcoreType>
static KernelFunction dispatchKernelOnScLambdasOrAlphasDifference(const bool scLambdasOrAlphasDiffer,
const bool vdwInteractionTypeIsEwald,
const bool elecInteractionTypeIsEwald,
const bool useSimd,
const interaction_const_t& ic)
{
- if ((ic.softCoreParameters->alphaCoulomb == 0 && ic.softCoreParameters->alphaVdw == 0)
- || ic.softCoreParameters->softcoreType == SoftcoreType::None)
+ if (ic.softCoreParameters->alphaCoulomb == 0 && ic.softCoreParameters->alphaVdw == 0)
{
- return (dispatchKernelOnScLambdasOrAlphasDifference<SoftcoreType::None>(scLambdasOrAlphasDiffer,
- vdwInteractionTypeIsEwald,
- elecInteractionTypeIsEwald,
- vdwModifierIsPotSwitch,
- computeForces,
- useSimd));
+ return (dispatchKernelOnScLambdasOrAlphasDifference<KernelSoftcoreType::None>(
+ scLambdasOrAlphasDiffer,
+ vdwInteractionTypeIsEwald,
+ elecInteractionTypeIsEwald,
+ vdwModifierIsPotSwitch,
+ computeForces,
+ useSimd));
}
else
{
if (ic.softCoreParameters->softcoreType == SoftcoreType::Beutler)
{
- return (dispatchKernelOnScLambdasOrAlphasDifference<SoftcoreType::Beutler>(
+ return (dispatchKernelOnScLambdasOrAlphasDifference<KernelSoftcoreType::Beutler>(
scLambdasOrAlphasDiffer,
vdwInteractionTypeIsEwald,
elecInteractionTypeIsEwald,
}
else
{
- return (dispatchKernelOnScLambdasOrAlphasDifference<SoftcoreType::Gapsys>(
+ return (dispatchKernelOnScLambdasOrAlphasDifference<KernelSoftcoreType::Gapsys>(
scLambdasOrAlphasDiffer,
vdwInteractionTypeIsEwald,
elecInteractionTypeIsEwald,
}
/*! \brief Compute the energy and force for a single pair interaction under FEP */
-template<SoftcoreType softcoreType>
+template<KernelSoftcoreType softcoreType>
static real free_energy_evaluate_single(real r2,
real rCoulCutoff,
const interaction_const_t::SoftCoreParameters& scParams,
/* Loop over state A(0) and B(1) */
for (i = 0; i < 2; i++)
{
- if (softcoreType == SoftcoreType::Beutler || softcoreType == SoftcoreType::Gapsys)
+ if (softcoreType == KernelSoftcoreType::Beutler || softcoreType == KernelSoftcoreType::Gapsys)
{
if ((c6[i] > 0) && (c12[i] > 0))
{
* Correct for this by multiplying with (1/12.0)/(1/6.0)=6.0/12.0=0.5.
*/
sigma6[i] = half * c12[i] / c6[i];
- if (softcoreType == SoftcoreType::Beutler && (sigma6[i] < scParams.sigma6Minimum)) /* for disappearing coul and vdw with soft core at the same time */
+ if (softcoreType == KernelSoftcoreType::Beutler && (sigma6[i] < scParams.sigma6Minimum)) /* for disappearing coul and vdw with soft core at the same time */
{
sigma6[i] = scParams.sigma6Minimum;
}
}
}
- if (softcoreType == SoftcoreType::Beutler || softcoreType == SoftcoreType::Gapsys)
+ if (softcoreType == KernelSoftcoreType::Beutler || softcoreType == KernelSoftcoreType::Gapsys)
{
/* only use softcore if one of the states has a zero endstate - softcore is for avoiding infinities!*/
if ((c12[0] > 0) && (c12[1] > 0))
}
else
{
- if (softcoreType == SoftcoreType::Beutler)
+ if (softcoreType == KernelSoftcoreType::Beutler)
{
alpha_vdw_eff = scParams.alphaVdw;
alpha_coul_eff = scParams.alphaCoulomb;
}
- else if (softcoreType == SoftcoreType::Gapsys)
+ else if (softcoreType == KernelSoftcoreType::Gapsys)
{
alpha_vdw_eff = scParams.alphaVdw;
alpha_coul_eff = gmx::sixthroot(scParams.sigma6WithInvalidSigma);
if ((qq[i] != 0) || (c6[i] != 0) || (c12[i] != 0))
{
/* Coulomb */
- if (softcoreType == SoftcoreType::Beutler)
+ if (softcoreType == KernelSoftcoreType::Beutler)
{
rpinv = one / (alpha_coul_eff * lfac_coul[i] * sigma_pow[i] + rp);
r_coul = sixthRoot(rpinv);
r_coul = r;
}
- if (softcoreType == SoftcoreType::Gapsys)
+ if (softcoreType == KernelSoftcoreType::Gapsys)
{
rQ = gmx::sixthroot(one - LFC[i]) * (one + std::fabs(qq[i] / facel));
rQ *= alpha_coul_eff;
}
}
- if ((softcoreType == SoftcoreType::Gapsys) && (r < rQ))
+ if ((softcoreType == KernelSoftcoreType::Gapsys) && (r < rQ))
{
real rInvQ = one / rQ;
real constFac = qq[i] * rInvQ;
}
/* Vdw */
- if (softcoreType == SoftcoreType::Beutler)
+ if (softcoreType == KernelSoftcoreType::Beutler)
{
rpinv = one / (alpha_vdw_eff * lfac_vdw[i] * sigma_pow[i] + rp);
r_vdw = sixthRoot(rpinv);
r_vdw = r;
}
- if (softcoreType == SoftcoreType::Gapsys)
+ if (softcoreType == KernelSoftcoreType::Gapsys)
{
constexpr real c_twentySixSeventh = 26.0_real / 7.0_real;
rLJ *= alpha_vdw_eff;
}
- if ((softcoreType == SoftcoreType::Gapsys) && (r < rLJ))
+ if ((softcoreType == KernelSoftcoreType::Gapsys) && (r < rLJ))
{
// scaled values for c6 and c12
real c6s, c12s;
fscal += (LFC[i] * fscal_elec[i] + LFV[i] * fscal_vdw[i]) * rpm2;
- if (softcoreType == SoftcoreType::Gapsys)
+ if (softcoreType == KernelSoftcoreType::Gapsys)
{
dvdl_coul_sum += dvdl_elec[i];
dvdl_vdw_sum += dvdl_vdw[i];
}
dvdl_coul_sum += velec[i] * DLF[i];
dvdl_vdw_sum += vvdw[i] * DLF[i];
- if (softcoreType == SoftcoreType::Beutler)
+ if (softcoreType == KernelSoftcoreType::Beutler)
{
dvdl_coul_sum += LFC[i] * alpha_coul_eff * dlfac_coul[i] * fscal_elec[i] * sigma_pow[i];
dvdl_vdw_sum += LFV[i] * alpha_vdw_eff * dlfac_vdw[i] * fscal_vdw[i] * sigma_pow[i];
c6B = iparams[itype].lj14.c6B * 6.0;
c12B = iparams[itype].lj14.c12B * 12.0;
- if (fr->ic->softCoreParameters->softcoreType == SoftcoreType::Gapsys)
+ const auto& scParams = *fr->ic->softCoreParameters;
+ if (scParams.softcoreType == SoftcoreType::Gapsys)
{
- fscal = free_energy_evaluate_single<SoftcoreType::Gapsys>(r2,
- fr->ic->rcoulomb,
- *fr->ic->softCoreParameters,
- fr->pairsTable->scale,
- fr->pairsTable->data.data(),
- fr->pairsTable->stride,
- qq,
- c6,
- c12,
- qqB,
- c6B,
- c12B,
- epsfac,
- LFC,
- LFV,
- DLF,
- lfac_coul,
- lfac_vdw,
- dlfac_coul,
- dlfac_vdw,
- &velec,
- &vvdw,
- dvdl);
+ fscal = free_energy_evaluate_single<KernelSoftcoreType::Gapsys>(
+ r2,
+ fr->ic->rcoulomb,
+ *fr->ic->softCoreParameters,
+ fr->pairsTable->scale,
+ fr->pairsTable->data.data(),
+ fr->pairsTable->stride,
+ qq,
+ c6,
+ c12,
+ qqB,
+ c6B,
+ c12B,
+ epsfac,
+ LFC,
+ LFV,
+ DLF,
+ lfac_coul,
+ lfac_vdw,
+ dlfac_coul,
+ dlfac_vdw,
+ &velec,
+ &vvdw,
+ dvdl);
}
- else if (fr->ic->softCoreParameters->softcoreType == SoftcoreType::Beutler)
+ else if (scParams.softcoreType == SoftcoreType::Beutler)
{
- fscal = free_energy_evaluate_single<SoftcoreType::Beutler>(r2,
- fr->ic->rcoulomb,
- *fr->ic->softCoreParameters,
- fr->pairsTable->scale,
- fr->pairsTable->data.data(),
- fr->pairsTable->stride,
- qq,
- c6,
- c12,
- qqB,
- c6B,
- c12B,
- epsfac,
- LFC,
- LFV,
- DLF,
- lfac_coul,
- lfac_vdw,
- dlfac_coul,
- dlfac_vdw,
- &velec,
- &vvdw,
- dvdl);
+ fscal = free_energy_evaluate_single<KernelSoftcoreType::Beutler>(
+ r2,
+ fr->ic->rcoulomb,
+ *fr->ic->softCoreParameters,
+ fr->pairsTable->scale,
+ fr->pairsTable->data.data(),
+ fr->pairsTable->stride,
+ qq,
+ c6,
+ c12,
+ qqB,
+ c6B,
+ c12B,
+ epsfac,
+ LFC,
+ LFV,
+ DLF,
+ lfac_coul,
+ lfac_vdw,
+ dlfac_coul,
+ dlfac_vdw,
+ &velec,
+ &vvdw,
+ dvdl);
}
else
{
- fscal = free_energy_evaluate_single<SoftcoreType::None>(r2,
- fr->ic->rcoulomb,
- *fr->ic->softCoreParameters,
- fr->pairsTable->scale,
- fr->pairsTable->data.data(),
- fr->pairsTable->stride,
- qq,
- c6,
- c12,
- qqB,
- c6B,
- c12B,
- epsfac,
- LFC,
- LFV,
- DLF,
- lfac_coul,
- lfac_vdw,
- dlfac_coul,
- dlfac_vdw,
- &velec,
- &vvdw,
- dvdl);
+ fscal = free_energy_evaluate_single<KernelSoftcoreType::None>(
+ r2,
+ fr->ic->rcoulomb,
+ *fr->ic->softCoreParameters,
+ fr->pairsTable->scale,
+ fr->pairsTable->data.data(),
+ fr->pairsTable->stride,
+ qq,
+ c6,
+ c12,
+ qqB,
+ c6B,
+ c12B,
+ epsfac,
+ LFC,
+ LFV,
+ DLF,
+ lfac_coul,
+ lfac_vdw,
+ dlfac_coul,
+ dlfac_vdw,
+ &velec,
+ &vvdw,
+ dvdl);
}
}
else