Fix use of literals.
authorSebastian Kehl <sebastian.kehl@mpcdf.mpg.de>
Mon, 20 Sep 2021 14:57:41 +0000 (16:57 +0200)
committerMagnus Lundborg <magnus.lundborg@scilifelab.se>
Tue, 5 Oct 2021 11:38:46 +0000 (11:38 +0000)
src/gromacs/gmxlib/nonbonded/nb_softcore.h
src/gromacs/listed_forces/pairs.cpp

index c557c6ffb3b1761d8732a2a2eb0fb501bd4e5bf6..2fc4754cc24652ef6eec085eb6d49656290914d6 100644 (file)
@@ -59,12 +59,12 @@ static inline void quadraticApproximationCoulomb(const RealType qq,
     RealType quadrFac = linFac * r * rInvQ;
 
     /* Computing Coulomb force and potential energy */
-    *force = -2. * quadrFac + 3. * linFac;
+    *force = -2 * quadrFac + 3 * linFac;
 
-    *potential = quadrFac - 3. * (linFac - constFac);
+    *potential = quadrFac - 3 * (linFac - constFac);
 
     RealType lambdaFacRevInv = gmx::maskzInv(1.0 - lambdaFac, dvdlMask);
-    *dvdl = dLambdaFac * 0.5 * (lambdaFac * lambdaFacRevInv) * (quadrFac - 2. * linFac + constFac);
+    *dvdl = dLambdaFac * 0.5_real * (lambdaFac * lambdaFacRevInv) * (quadrFac - 2 * linFac + constFac);
 }
 
 /* reaction-field linearized electrostatics */
@@ -87,10 +87,10 @@ static inline void reactionFieldQuadraticPotential(const RealType qq,
     BoolType computeValues = mask && (lambdaFac < 1 && 0 < alphaEff);
     if (gmx::anyTrue(computeValues))
     {
-        RealType lambdaFacRev = gmx::selectByMask(1.0 - lambdaFac, computeValues);
+        RealType lambdaFacRev = gmx::selectByMask(1 - lambdaFac, computeValues);
 
         RealType rQ = gmx::cbrt(lambdaFacRev);
-        rQ          = gmx::sqrt(rQ) * (1.0 + gmx::abs(qq / facel));
+        rQ          = gmx::sqrt(rQ) * (1 + gmx::abs(qq / facel));
         rQ          = rQ * alphaEff;
 
         // ensure that the linearization point doesn't go beyond rCutoff
@@ -114,7 +114,7 @@ static inline void reactionFieldQuadraticPotential(const RealType qq,
                     qq, rInvQ, r, lambdaFac, dLambdaFac, &forceQuad, &potentialQuad, &dvdlQuad, computeValues);
 
             // rf modification
-            forceQuad     = forceQuad - qq * 2.0 * krf * r * r;
+            forceQuad     = forceQuad - qq * 2 * krf * r * r;
             potentialQuad = potentialQuad + qq * (krf * r * r - potentialShift);
 
             // update
@@ -145,10 +145,10 @@ static inline void ewaldQuadraticPotential(const RealType qq,
     BoolType computeValues = mask && (lambdaFac < 1 && 0 < alphaEff);
     if (gmx::anyTrue(computeValues))
     {
-        RealType lambdaFacRev = gmx::selectByMask(1.0 - lambdaFac, computeValues);
+        RealType lambdaFacRev = gmx::selectByMask(1 - lambdaFac, computeValues);
 
         RealType rQ = gmx::cbrt(lambdaFacRev);
-        rQ          = gmx::sqrt(rQ) * (1.0 + gmx::abs(qq / facel));
+        rQ          = gmx::sqrt(rQ) * (1 + gmx::abs(qq / facel));
         rQ          = rQ * alphaEff;
 
         // ensure that the linearization point doesn't go beyond rCutoff
@@ -199,16 +199,17 @@ static inline void lennardJonesQuadraticPotential(const RealType c6,
                                                   RealType*      dvdl,
                                                   BoolType       mask)
 {
-    constexpr real c_twentySixSeventh = 26.0 / 7.0;
-    constexpr real c_oneSixth         = 1.0 / 6.0;
-    constexpr real c_oneTwelth        = 1.0 / 12.0;
+    constexpr real c_twentySixSeventh = 26.0_real / 7.0_real;
+    constexpr real c_oneSixth         = 1.0_real / 6.0_real;
+    constexpr real c_oneTwelth        = 1.0_real / 12.0_real;
+    constexpr real c_half             = 1.0_real / 2.0_real;
 
     /* check if we have to use the hardcore values */
     BoolType computeValues = mask && (lambdaFac < 1 && 0 < alphaEff);
     if (gmx::anyTrue(computeValues))
     {
-        RealType lambdaFacRev    = gmx::selectByMask(1.0 - lambdaFac, computeValues);
-        RealType lambdaFacRevInv = gmx::maskzInv(1.0 - lambdaFac, computeValues);
+        RealType lambdaFacRev    = gmx::selectByMask(1 - lambdaFac, computeValues);
+        RealType lambdaFacRevInv = gmx::maskzInv(1 - lambdaFac, computeValues);
 
         RealType rQ = gmx::cbrt(c_twentySixSeventh * sigma6 * lambdaFacRev);
         rQ          = gmx::sqrt(rQ);
@@ -238,16 +239,16 @@ static inline void lennardJonesQuadraticPotential(const RealType c6,
 
             /* Temporary variables for A and B */
             RealType quadrFac, linearFac, constFac;
-            quadrFac  = 156. * rInv14C - 42. * rInv8C;
-            linearFac = 168. * rInv13C - 48. * rInv7C;
-            constFac  = 91. * rInv12C - 28. * rInv6C;
+            quadrFac  = 156 * rInv14C - 42 * rInv8C;
+            linearFac = 168 * rInv13C - 48 * rInv7C;
+            constFac  = 91 * rInv12C - 28 * rInv6C;
 
             /* Computing LJ force and potential energy */
             RealType forceQuad     = -quadrFac + linearFac;
-            RealType potentialQuad = 0.5 * quadrFac - linearFac + constFac;
-            RealType dvdlQuad      = dLambdaFac * 28. * (lambdaFac * lambdaFacRevInv)
-                                * ((6.5 * rInv14C - rInv8C) - (13. * rInv13C - 2. * rInv7C)
-                                   + (6.5 * rInv12C - rInv6C));
+            RealType potentialQuad = c_half * quadrFac - linearFac + constFac;
+            RealType dvdlQuad      = dLambdaFac * 28 * (lambdaFac * lambdaFacRevInv)
+                                * ((6.5_real * rInv14C - rInv8C) - (13 * rInv13C - 2. * rInv7C)
+                                   + (6.5_real * rInv12C - rInv6C));
 
             *potential = *potential
                          + gmx::selectByMask(((c12s * repulsionShift) - (c6s * dispersionShift)),
index 3bea5450e2df47fe9e87d88982d914a410034704..217b4ecce269643c99ee1c957e46af2bbc216047 100644 (file)
@@ -295,31 +295,31 @@ static real free_energy_evaluate_single(real
 
             if (softcoreType == SoftcoreType::Gapsys)
             {
-                rQ = gmx::sixthroot(1. - LFC[i]) * (1. + std::fabs(qq[i] / facel));
+                rQ = gmx::sixthroot(one - LFC[i]) * (one + std::fabs(qq[i] / facel));
                 rQ *= alpha_coul_eff;
-                scaleDvdlRCoul = 1.0;
+                scaleDvdlRCoul = 1;
                 if (rQ > rCoulCutoff)
                 {
                     rQ             = rCoulCutoff;
-                    scaleDvdlRCoul = 0.0;
+                    scaleDvdlRCoul = 0;
                 }
             }
 
             if ((softcoreType == SoftcoreType::Gapsys) && (r < rQ))
             {
-                real rInvQ    = 1.0 / rQ;
+                real rInvQ    = one / rQ;
                 real constFac = qq[i] * rInvQ;
                 real linFac   = constFac * r * rInvQ;
                 real quadrFac = linFac * r * rInvQ;
 
                 /* Computing Coulomb force and potential energy */
-                fscal_elec[i] = 2. * quadrFac - 3. * linFac;
+                fscal_elec[i] = 2 * quadrFac - 3 * linFac;
                 fscal_elec[i] *= rpinv;
 
-                velec[i] = quadrFac - 3. * (linFac - constFac);
+                velec[i] = quadrFac - 3 * (linFac - constFac);
 
-                dvdl_elec[i] += scaleDvdlRCoul * DLF[i] * 0.5 * (LFC[i] / (1. - LFC[i]))
-                                * (quadrFac - 2. * linFac + constFac);
+                dvdl_elec[i] += scaleDvdlRCoul * DLF[i] * half * (LFC[i] / (1 - LFC[i]))
+                                * (quadrFac - 2 * linFac + constFac);
             }
             else // Beutler, resp. hardcore
             {
@@ -355,9 +355,9 @@ static real free_energy_evaluate_single(real
 
             if (softcoreType == SoftcoreType::Gapsys)
             {
-                constexpr real c_twentySixSeventh = 26.0 / 7.0;
+                constexpr real c_twentySixSeventh = 26.0_real / 7.0_real;
 
-                rLJ = gmx::sixthroot(c_twentySixSeventh * sigma6[i] * (1. - LFV[i]));
+                rLJ = gmx::sixthroot(c_twentySixSeventh * sigma6[i] * (one - LFV[i]));
                 rLJ *= alpha_vdw_eff;
             }
 
@@ -365,11 +365,11 @@ static real free_energy_evaluate_single(real
             {
                 // scaled values for c6 and c12
                 real c6s, c12s;
-                c6s  = c6[i] / 6.0;
-                c12s = c12[i] / 12.0;
+                c6s  = c6[i] / 6.0_real;
+                c12s = c12[i] / 12.0_real;
 
                 /* Temporary variables for inverted values */
-                real rInvLJ = 1.0 / rLJ;
+                real rInvLJ = one / rLJ;
                 real rInv14, rInv13, rInv12;
                 real rInv8, rInv7, rInv6;
                 rInv6 = rInvLJ * rInvLJ * rInvLJ;
@@ -385,9 +385,9 @@ static real free_energy_evaluate_single(real
 
                 /* Temporary variables for A and B */
                 real quadrFac, linearFac, constFac;
-                quadrFac  = 156. * rInv14 - 42. * rInv8;
-                linearFac = 168. * rInv13 - 48. * rInv7;
-                constFac  = 91. * rInv12 - 28. * rInv6;
+                quadrFac  = 156 * rInv14 - 42 * rInv8;
+                linearFac = 168 * rInv13 - 48 * rInv7;
+                constFac  = 91 * rInv12 - 28 * rInv6;
 
                 /* Computing LJ force and potential energy*/
                 fscal_vdw[i] = quadrFac - linearFac;
@@ -395,9 +395,9 @@ static real free_energy_evaluate_single(real
 
                 vvdw[i] = 0.5 * quadrFac - linearFac + constFac;
 
-                dvdl_vdw[i] += DLF[i] * 28. * (LFV[i] / (1. - LFV[i]))
-                               * ((6.5 * rInv14 - rInv8) - (13. * rInv13 - 2. * rInv7)
-                                  + (6.5 * rInv12 - rInv6));
+                dvdl_vdw[i] += DLF[i] * 28 * (LFV[i] / (one - LFV[i]))
+                               * ((6.5_real * rInv14 - rInv8) - (13 * rInv13 - 2 * rInv7)
+                                  + (6.5_real * rInv12 - rInv6));
             }
             else // Beutler, resp. hardcore
             {