Expose mk_nbfp and make_ljpme_c6grid.
authorSebastian Kehl <sebastian.kehl@mpcdf.mpg.de>
Mon, 15 Feb 2021 08:42:56 +0000 (09:42 +0100)
committerSebastian Kehl <sebastian.kehl@mpcdf.mpg.de>
Mon, 15 Feb 2021 08:42:56 +0000 (09:42 +0100)
Expose mk_nbfp and make_ljpme_c6grid from 'mdlib/forcerec.cpp'
in 'mdlib/forcerec.h'.

Thereby rename:
mk_nbfp           -> makeNonBondedParameterLists
make_ljpme_c6grid -> makeLJPmeC6GridCorrectionParameters

src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/forcerec.h

index e17946088e439e91e455611a201e705ac84a476b..780ecda83e6dd42b5f8789d5210f3f7d941b30a8 100644 (file)
@@ -116,13 +116,13 @@ void ForceHelperBuffers::resize(int numAtoms)
     }
 }
 
-static std::vector<real> mk_nbfp(const gmx_ffparams_t* idef, gmx_bool bBHAM)
+std::vector<real> makeNonBondedParameterLists(const gmx_ffparams_t& forceFieldParams, bool useBuckinghamPotential)
 {
     std::vector<real> nbfp;
     int               atnr;
 
-    atnr = idef->atnr;
-    if (bBHAM)
+    atnr = forceFieldParams.atnr;
+    if (useBuckinghamPotential)
     {
         nbfp.resize(3 * atnr * atnr);
         int k = 0;
@@ -130,10 +130,10 @@ static std::vector<real> mk_nbfp(const gmx_ffparams_t* idef, gmx_bool bBHAM)
         {
             for (int j = 0; (j < atnr); j++, k++)
             {
-                BHAMA(nbfp, atnr, i, j) = idef->iparams[k].bham.a;
-                BHAMB(nbfp, atnr, i, j) = idef->iparams[k].bham.b;
+                BHAMA(nbfp, atnr, i, j) = forceFieldParams.iparams[k].bham.a;
+                BHAMB(nbfp, atnr, i, j) = forceFieldParams.iparams[k].bham.b;
                 /* nbfp now includes the 6.0 derivative prefactor */
-                BHAMC(nbfp, atnr, i, j) = idef->iparams[k].bham.c * 6.0;
+                BHAMC(nbfp, atnr, i, j) = forceFieldParams.iparams[k].bham.c * 6.0;
             }
         }
     }
@@ -146,8 +146,8 @@ static std::vector<real> mk_nbfp(const gmx_ffparams_t* idef, gmx_bool bBHAM)
             for (int j = 0; (j < atnr); j++, k++)
             {
                 /* nbfp now includes the 6.0/12.0 derivative prefactors */
-                C6(nbfp, atnr, i, j)  = idef->iparams[k].lj.c6 * 6.0;
-                C12(nbfp, atnr, i, j) = idef->iparams[k].lj.c12 * 12.0;
+                C6(nbfp, atnr, i, j)  = forceFieldParams.iparams[k].lj.c6 * 6.0;
+                C12(nbfp, atnr, i, j) = forceFieldParams.iparams[k].lj.c12 * 12.0;
             }
         }
     }
@@ -155,7 +155,8 @@ static std::vector<real> mk_nbfp(const gmx_ffparams_t* idef, gmx_bool bBHAM)
     return nbfp;
 }
 
-static std::vector<real> make_ljpme_c6grid(const gmx_ffparams_t* idef, t_forcerec* fr)
+std::vector<real> makeLJPmeC6GridCorrectionParameters(const gmx_ffparams_t& forceFieldParams,
+                                                      const t_forcerec&     forceRec)
 {
     int  i, j, k, atnr;
     real c6, c6i, c6j, c12i, c12j, epsi, epsj, sigmai, sigmaj;
@@ -165,19 +166,19 @@ static std::vector<real> make_ljpme_c6grid(const gmx_ffparams_t* idef, t_forcere
      * access to the C6-values used on the reciprocal grid in pme.c
      */
 
-    atnr = idef->atnr;
+    atnr = forceFieldParams.atnr;
     std::vector<real> grid(2 * atnr * atnr, 0.0);
     for (i = k = 0; (i < atnr); i++)
     {
         for (j = 0; (j < atnr); j++, k++)
         {
-            c6i  = idef->iparams[i * (atnr + 1)].lj.c6;
-            c12i = idef->iparams[i * (atnr + 1)].lj.c12;
-            c6j  = idef->iparams[j * (atnr + 1)].lj.c6;
-            c12j = idef->iparams[j * (atnr + 1)].lj.c12;
+            c6i  = forceFieldParams.iparams[i * (atnr + 1)].lj.c6;
+            c12i = forceFieldParams.iparams[i * (atnr + 1)].lj.c12;
+            c6j  = forceFieldParams.iparams[j * (atnr + 1)].lj.c6;
+            c12j = forceFieldParams.iparams[j * (atnr + 1)].lj.c12;
             c6   = std::sqrt(c6i * c6j);
-            if (fr->ljpme_combination_rule == eljpmeLB && !gmx_numzero(c6) && !gmx_numzero(c12i)
-                && !gmx_numzero(c12j))
+            if (forceRec.ljpme_combination_rule == eljpmeLB && !gmx_numzero(c6)
+                && !gmx_numzero(c12i) && !gmx_numzero(c12j))
             {
                 sigmai = gmx::sixthroot(c12i / c6i);
                 sigmaj = gmx::sixthroot(c12j / c6j);
@@ -1195,10 +1196,10 @@ void init_forcerec(FILE*                            fp,
     if (fr->nbfp.empty())
     {
         fr->ntype = mtop->ffparams.atnr;
-        fr->nbfp  = mk_nbfp(&mtop->ffparams, fr->bBHAM);
+        fr->nbfp  = makeNonBondedParameterLists(mtop->ffparams, fr->bBHAM);
         if (EVDW_PME(ic->vdwtype))
         {
-            fr->ljpme_c6grid = make_ljpme_c6grid(&mtop->ffparams, fr);
+            fr->ljpme_c6grid = makeLJPmeC6GridCorrectionParameters(mtop->ffparams, *fr);
         }
     }
 
index 1a01ff141330ba927ce925138fa8a53c39e7d0fa..5455a0504a1ef76d8cfb988f2cc7da780cd45d77 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
  * Copyright (c) 2013,2014,2015,2016,2017 The GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -51,6 +51,7 @@ struct gmx_localtop_t;
 struct gmx_mtop_t;
 struct gmx_wallcycle;
 struct interaction_const_t;
+struct gmx_ffparams_t;
 
 namespace gmx
 {
@@ -58,6 +59,22 @@ class MDLogger;
 class PhysicalNodeCommunicator;
 } // namespace gmx
 
+/*! \brief Create nonbonded parameter lists
+ *
+ * \param[in] forceFieldParams       The forcefield parameters
+ * \param[in] useBuckinghamPotential Use Buckingham potential
+ */
+std::vector<real> makeNonBondedParameterLists(const gmx_ffparams_t& forceFieldParams,
+                                              bool                  useBuckinghamPotential);
+
+/*! \brief Calculate c6 parameters for grid correction
+ *
+ * \param[in] forceFieldParams The forcefield parameters
+ * \param[in] forceRec         The forcerec
+ */
+std::vector<real> makeLJPmeC6GridCorrectionParameters(const gmx_ffparams_t& forceFieldParams,
+                                                      const t_forcerec&     forceRec);
+
 /*! \brief Print the contents of the forcerec to a file
  *
  * \param[in] fplog The log file to print to