Fix clang-tidy complaints
[alexxy/gromacs.git] / src / gromacs / listed_forces / pairs.cpp
index 8e267f23b7daf3103ca6888db3d5ce00bd30217e..064c837756c639b5c7da10f8d9c8566a9717cc69 100644 (file)
@@ -201,7 +201,7 @@ static real free_energy_evaluate_single(real
     real       fscal_vdw[2], fscal_elec[2];
     real       velec[2], vvdw[2];
     real       dvdl_elec[2], dvdl_vdw[2];
-    real       scaleLinpointCoulGapsys, scaleLinpointVdWGapsys, sigma6VdWGapsys[2];
+    real       gapsysScaleLinpointCoul, gapsysScaleLinpointVdW, gapsysSigma6VdW[2];
     real       rQ, rLJ;
     real       scaleDvdlRCoul;
     int        i, ntab;
@@ -242,6 +242,7 @@ static real free_energy_evaluate_single(real
             }
             sigma_pow[i] = sigma6[i];
         }
+        // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
         if constexpr (softcoreType == KernelSoftcoreType::Gapsys)
         {
             if ((c6[i] > 0) && (c12[i] > 0))
@@ -249,15 +250,16 @@ static real free_energy_evaluate_single(real
                 /* The c6 & c12 coefficients now contain the constants 6.0 and 12.0, respectively.
                  * Correct for this by multiplying with (1/12.0)/(1/6.0)=6.0/12.0=0.5.
                  */
-                sigma6VdWGapsys[i] = half * c12[i] / c6[i];
+                gapsysSigma6VdW[i] = half * c12[i] / c6[i];
             }
             else
             {
-                sigma6VdWGapsys[i] = scParams.sigma6VdWGapsys;
+                gapsysSigma6VdW[i] = scParams.gapsysSigma6VdW;
             }
         }
     }
 
+    // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
     if constexpr (softcoreType == KernelSoftcoreType::Beutler)
     {
         /* only use softcore if one of the states has a zero endstate - softcore is for avoiding infinities!*/
@@ -272,22 +274,24 @@ static real free_energy_evaluate_single(real
             alpha_coul_eff = scParams.alphaCoulomb;
         }
     }
+    // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
     if constexpr (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))
         {
-            scaleLinpointVdWGapsys  = 0;
-            scaleLinpointCoulGapsys = 0;
+            gapsysScaleLinpointVdW  = 0;
+            gapsysScaleLinpointCoul = 0;
         }
         else
         {
-            scaleLinpointVdWGapsys  = scParams.scaleLinpointVdWGapsys;
-            scaleLinpointCoulGapsys = scParams.scaleLinpointCoulGapsys;
+            gapsysScaleLinpointVdW  = scParams.gapsysScaleLinpointVdW;
+            gapsysScaleLinpointCoul = scParams.gapsysScaleLinpointCoul;
         }
     }
 
     /* Loop over A and B states again */
+    // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
     for (i = 0; i < 2; i++)
     {
         fscal_elec[i] = 0;
@@ -314,10 +318,18 @@ static real free_energy_evaluate_single(real
                 r_coul = r;
             }
 
+            // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
             if constexpr (softcoreType == KernelSoftcoreType::Gapsys)
             {
-                rQ = gmx::sixthroot(one - LFC[i]) * (one + std::fabs(qq[i] / facel));
-                rQ *= scaleLinpointCoulGapsys;
+                if ((facel != 0) && (LFC[i] < 1))
+                {
+                    rQ = gmx::sixthroot(one - LFC[i]) * (one + std::fabs(qq[i] / facel));
+                    rQ *= gapsysScaleLinpointCoul;
+                }
+                else
+                {
+                    rQ = 0;
+                }
                 scaleDvdlRCoul = 1;
                 if (rQ > rCoulCutoff)
                 {
@@ -326,6 +338,7 @@ static real free_energy_evaluate_single(real
                 }
             }
 
+            // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
             if ((softcoreType == KernelSoftcoreType::Gapsys) && (r < rQ))
             {
                 real rInvQ    = one / rQ;
@@ -378,10 +391,19 @@ static real free_energy_evaluate_single(real
             {
                 constexpr real c_twentySixSeventh = 26.0_real / 7.0_real;
 
-                rLJ = gmx::sixthroot(c_twentySixSeventh * sigma6VdWGapsys[i] * (one - LFV[i]));
-                rLJ *= scaleLinpointVdWGapsys;
+                if (LFV[i] < 1)
+                {
+
+                    rLJ = gmx::sixthroot(c_twentySixSeventh * gapsysSigma6VdW[i] * (one - LFV[i]));
+                    rLJ *= gapsysScaleLinpointVdW;
+                }
+                else
+                {
+                    rLJ = 0;
+                }
             }
 
+            // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
             if ((softcoreType == KernelSoftcoreType::Gapsys) && (r < rLJ))
             {
                 // scaled values for c6 and c12
@@ -414,7 +436,7 @@ static real free_energy_evaluate_single(real
                 fscal_vdw[i] = -quadrFac + linearFac;
                 fscal_vdw[i] *= rpinv;
 
-                vvdw[i] = 0.5 * quadrFac - linearFac + constFac;
+                vvdw[i] = 0.5_real * quadrFac - linearFac + constFac;
 
                 dvdl_vdw[i] += DLF[i] * 28 * (LFV[i] / (one - LFV[i]))
                                * ((6.5_real * rInv14 - rInv8) - (13 * rInv13 - 2 * rInv7)
@@ -472,6 +494,7 @@ static real free_energy_evaluate_single(real
             dvdl_coul_sum += dvdl_elec[i];
             dvdl_vdw_sum += dvdl_vdw[i];
         }
+        // NOLINTNEXTLINE(readability-misleading-indentation) remove when clang-tidy-13 is required
         dvdl_coul_sum += velec[i] * DLF[i];
         dvdl_vdw_sum += vvdw[i] * DLF[i];
         if constexpr (softcoreType == KernelSoftcoreType::Beutler)
@@ -718,7 +741,7 @@ static real do_pairs_general(int                           ftype,
             }
             else // Gapsys
             {
-                if (scParams.scaleLinpointCoulGapsys == 0 && scParams.scaleLinpointVdWGapsys == 0)
+                if (scParams.gapsysScaleLinpointCoul == 0 && scParams.gapsysScaleLinpointVdW == 0)
                 {
                     fscal = free_energy_evaluate_single<KernelSoftcoreType::None>(
                             r2,