From: Sebastian Kehl Date: Wed, 22 Sep 2021 13:54:48 +0000 (+0200) Subject: Remove SoftcoreType::None. X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=236163204e50c9c80173bcfe31675e971f7b7c20;p=alexxy%2Fgromacs.git Remove SoftcoreType::None. --- diff --git a/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp b/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp index d51dc4e8d1..33e485d191 100644 --- a/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp +++ b/src/gromacs/gmxlib/nonbonded/nb_free_energy.cpp @@ -258,7 +258,7 @@ static inline RealType potSwitchPotentialMod(const RealType potentialInp, const //! Templated free-energy non-bonded kernel -template +template static void nb_free_energy_kernel(const t_nblist& nlist, const gmx::ArrayRefWithPadding& coords, const int ntype, @@ -528,8 +528,8 @@ static void nb_free_energy_kernel(const t_nblist& { 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]; @@ -549,8 +549,8 @@ static void nb_free_energy_kernel(const t_nblist& } } } - 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]; @@ -562,12 +562,12 @@ static void nb_free_energy_kernel(const t_nblist& } 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); @@ -646,12 +646,14 @@ static void nb_free_energy_kernel(const t_nblist& gmx::gatherLoadTranspose<2>(nbfp.data(), typeIndices[i], &c6[i], &c12[i]); qq[i] = gmx::load(preloadQq[i]); ljPmeC6Grid[i] = gmx::load(preloadLjPmeC6Grid[i]); - if constexpr (softcoreType == SoftcoreType::Beutler || softcoreType == SoftcoreType::Gapsys) + if constexpr (softcoreType == KernelSoftcoreType::Beutler + || softcoreType == KernelSoftcoreType::Gapsys) { sigma6[i] = gmx::load(preloadSigma6[i]); } } - if constexpr (softcoreType == SoftcoreType::Beutler || softcoreType == SoftcoreType::Gapsys) + if constexpr (softcoreType == KernelSoftcoreType::Beutler + || softcoreType == KernelSoftcoreType::Gapsys) { alphaVdwEff = gmx::load(preloadAlphaVdwEff); alphaCoulEff = gmx::load(preloadAlphaCoulEff); @@ -663,7 +665,7 @@ static void nb_free_energy_kernel(const t_nblist& 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 */ @@ -701,7 +703,7 @@ static void nb_free_energy_kernel(const t_nblist& && 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); @@ -755,7 +757,7 @@ static void nb_free_energy_kernel(const t_nblist& fScalC[i] = ewaldScalarForce(qq[i], rInvC); } - if constexpr (softcoreType == SoftcoreType::Gapsys) + if constexpr (softcoreType == KernelSoftcoreType::Gapsys) { ewaldQuadraticPotential(qq[i], facel, @@ -779,7 +781,7 @@ static void nb_free_energy_kernel(const t_nblist& fScalC[i] = reactionFieldScalarForce(qq[i], rInvC, rC, krf, two); } - if constexpr (softcoreType == SoftcoreType::Gapsys) + if constexpr (softcoreType == KernelSoftcoreType::Gapsys) { reactionFieldQuadraticPotential(qq[i], facel, @@ -822,7 +824,7 @@ static void nb_free_energy_kernel(const t_nblist& if (gmx::anyTrue(computeVdwInteraction)) { RealType rInv6; - if constexpr (softcoreType == SoftcoreType::Beutler) + if constexpr (softcoreType == KernelSoftcoreType::Beutler) { rInv6 = rPInvV; } @@ -846,7 +848,7 @@ static void nb_free_energy_kernel(const t_nblist& fScalV[i] = lennardJonesScalarForce(vVdw6, vVdw12); } - if constexpr (softcoreType == SoftcoreType::Gapsys) + if constexpr (softcoreType == KernelSoftcoreType::Gapsys) { lennardJonesQuadraticPotential(c6[i], c12[i], @@ -927,7 +929,7 @@ static void nb_free_energy_kernel(const t_nblist& 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]; @@ -1126,7 +1128,7 @@ typedef void (*KernelFunction)(const t_nblist& gmx::ArrayRef threadVv, gmx::ArrayRef threadDvdl); -template +template static KernelFunction dispatchKernelOnUseSimd(const bool useSimd) { if (useSimd) @@ -1143,7 +1145,7 @@ static KernelFunction dispatchKernelOnUseSimd(const bool useSimd) } } -template +template static KernelFunction dispatchKernelOnComputeForces(const bool computeForces, const bool useSimd) { if (computeForces) @@ -1158,7 +1160,7 @@ static KernelFunction dispatchKernelOnComputeForces(const bool computeForces, co } } -template +template static KernelFunction dispatchKernelOnVdwModifier(const bool vdwModifierIsPotSwitch, const bool computeForces, const bool useSimd) @@ -1175,7 +1177,7 @@ static KernelFunction dispatchKernelOnVdwModifier(const bool vdwModifierIsPotSwi } } -template +template static KernelFunction dispatchKernelOnElecInteractionType(const bool elecInteractionTypeIsEwald, const bool vdwModifierIsPotSwitch, const bool computeForces, @@ -1193,7 +1195,7 @@ static KernelFunction dispatchKernelOnElecInteractionType(const bool elecInterac } } -template +template static KernelFunction dispatchKernelOnVdwInteractionType(const bool vdwInteractionTypeIsEwald, const bool elecInteractionTypeIsEwald, const bool vdwModifierIsPotSwitch, @@ -1212,7 +1214,7 @@ static KernelFunction dispatchKernelOnVdwInteractionType(const bool vdwInteracti } } -template +template static KernelFunction dispatchKernelOnScLambdasOrAlphasDifference(const bool scLambdasOrAlphasDiffer, const bool vdwInteractionTypeIsEwald, const bool elecInteractionTypeIsEwald, @@ -1240,21 +1242,21 @@ static KernelFunction dispatchKernel(const bool scLambdasOrAlpha 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(scLambdasOrAlphasDiffer, - vdwInteractionTypeIsEwald, - elecInteractionTypeIsEwald, - vdwModifierIsPotSwitch, - computeForces, - useSimd)); + return (dispatchKernelOnScLambdasOrAlphasDifference( + scLambdasOrAlphasDiffer, + vdwInteractionTypeIsEwald, + elecInteractionTypeIsEwald, + vdwModifierIsPotSwitch, + computeForces, + useSimd)); } else { if (ic.softCoreParameters->softcoreType == SoftcoreType::Beutler) { - return (dispatchKernelOnScLambdasOrAlphasDifference( + return (dispatchKernelOnScLambdasOrAlphasDifference( scLambdasOrAlphasDiffer, vdwInteractionTypeIsEwald, elecInteractionTypeIsEwald, @@ -1264,7 +1266,7 @@ static KernelFunction dispatchKernel(const bool scLambdasOrAlpha } else { - return (dispatchKernelOnScLambdasOrAlphasDifference( + return (dispatchKernelOnScLambdasOrAlphasDifference( scLambdasOrAlphasDiffer, vdwInteractionTypeIsEwald, elecInteractionTypeIsEwald, diff --git a/src/gromacs/listed_forces/pairs.cpp b/src/gromacs/listed_forces/pairs.cpp index 99a4d3dd91..e8e4a02ced 100644 --- a/src/gromacs/listed_forces/pairs.cpp +++ b/src/gromacs/listed_forces/pairs.cpp @@ -169,7 +169,7 @@ static inline real sixthRoot(const real r) } /*! \brief Compute the energy and force for a single pair interaction under FEP */ -template +template static real free_energy_evaluate_single(real r2, real rCoulCutoff, const interaction_const_t::SoftCoreParameters& scParams, @@ -222,7 +222,7 @@ static real free_energy_evaluate_single(real /* 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)) { @@ -230,7 +230,7 @@ static real free_energy_evaluate_single(real * 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; } @@ -243,7 +243,7 @@ static real free_energy_evaluate_single(real } } - 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)) @@ -253,12 +253,12 @@ static real free_energy_evaluate_single(real } 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); @@ -282,7 +282,7 @@ static real free_energy_evaluate_single(real 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); @@ -293,7 +293,7 @@ static real free_energy_evaluate_single(real 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; @@ -305,7 +305,7 @@ static real free_energy_evaluate_single(real } } - if ((softcoreType == SoftcoreType::Gapsys) && (r < rQ)) + if ((softcoreType == KernelSoftcoreType::Gapsys) && (r < rQ)) { real rInvQ = one / rQ; real constFac = qq[i] * rInvQ; @@ -342,7 +342,7 @@ static real free_energy_evaluate_single(real } /* 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); @@ -353,7 +353,7 @@ static real free_energy_evaluate_single(real r_vdw = r; } - if (softcoreType == SoftcoreType::Gapsys) + if (softcoreType == KernelSoftcoreType::Gapsys) { constexpr real c_twentySixSeventh = 26.0_real / 7.0_real; @@ -361,7 +361,7 @@ static real free_energy_evaluate_single(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; @@ -446,14 +446,14 @@ static real free_energy_evaluate_single(real 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]; @@ -637,83 +637,87 @@ static real do_pairs_general(int ftype, 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(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( + 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(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( + 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(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( + 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 diff --git a/src/gromacs/mdtypes/md_enums.cpp b/src/gromacs/mdtypes/md_enums.cpp index 0c40e53857..98f873f69b 100644 --- a/src/gromacs/mdtypes/md_enums.cpp +++ b/src/gromacs/mdtypes/md_enums.cpp @@ -291,6 +291,14 @@ const char* enumValueToString(SeparateDhdlFile enumValue) const char* enumValueToString(SoftcoreType enumValue) { static constexpr gmx::EnumerationArray softcoreTypeNames = { + "beutler", "gapsys" + }; + return softcoreTypeNames[enumValue]; +} + +const char* enumValueToString(KernelSoftcoreType enumValue) +{ + static constexpr gmx::EnumerationArray softcoreTypeNames = { "beutler", "gapsys", "none" }; return softcoreTypeNames[enumValue]; diff --git a/src/gromacs/mdtypes/md_enums.h b/src/gromacs/mdtypes/md_enums.h index 0bfb497cc4..5f5c303b45 100644 --- a/src/gromacs/mdtypes/md_enums.h +++ b/src/gromacs/mdtypes/md_enums.h @@ -607,19 +607,34 @@ const char* enumValueToString(DhDlDerivativeCalculation enumValue); /*! \brief soft-core function \ * - * Distinguishes between soft-core functions. + * Distinguishes between soft-core functions in the input. */ enum class SoftcoreType : int { Beutler, Gapsys, - None, Count, Default = Beutler }; //! Strings for softcore function names const char* enumValueToString(SoftcoreType enumValue); +/*! \brief soft-core function as parameter to the nb-fep kernel/14-interaction.\ + * + * Distinguishes between soft-core functions internally. This is different + * from SoftcoreType in that it offers 'None' which is not exposed to the user. + */ +enum class KernelSoftcoreType : int +{ + Beutler, + Gapsys, + None, + Count, + Default = Beutler +}; +//! Strings for softcore function names +const char* enumValueToString(KernelSoftcoreType enumValue); + /*! \brief Solvent model * * Distinguishes classical water types with 3 or 4 particles