Removed generalized reaction-field
authorBerk Hess <hess@kth.se>
Fri, 26 Jul 2019 11:29:35 +0000 (13:29 +0200)
committerBerk Hess <hess@kth.se>
Sun, 28 Jul 2019 20:28:28 +0000 (22:28 +0200)
This only worked correctly with the group scheme and charge groups.
Although this could be implemented by using net charges of molecules,
having the interaction function depend on the system volume and
temperature complicates the code and correctness checking.

Change-Id: If29b28772cd83524c5984f64cfcd88cc4060ca36

14 files changed:
docs/reference-manual/functions/nonbonded-interactions.rst
docs/reference-manual/references.rst
docs/release-notes/2020/major/removed-functionality.rst
docs/user-guide/mdp-options.rst
src/gromacs/gmxpreprocess/readir.cpp
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/forcerec.h
src/gromacs/mdlib/rf_util.cpp
src/gromacs/mdlib/rf_util.h
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdtypes/forcerec.h
src/gromacs/mdtypes/md_enums.cpp
src/gromacs/mdtypes/md_enums.h
src/gromacs/tables/forcetable.cpp

index b0a891ec3b1f7bc227617138b231155a5a36f82c..693a0f93e2b171338b1a4ff471c5ea9aca096ffd 100644 (file)
@@ -204,37 +204,6 @@ The reaction-field correction should also be applied to all excluded
 atoms pairs, including self pairs, in which case the normal Coulomb term
 in :eq:`eqns. %s <eqnvcrf>` and :eq:`%s <eqnfcrf>` is absent.
 
-Tironi *et al.* have introduced a generalized reaction field in which
-the dielectric continuum beyond the cut-off :math:`r_c` also has an
-ionic strength :math:`I` :ref:`71 <refTironi95>`. In this case we can
-rewrite the constants :math:`k_{rf}` and :math:`c_{rf}` using the
-inverse Debye screening length :math:`\kappa`:
-
-.. math:: \begin{aligned}
-          \kappa^2  &=&     
-          \frac{2 I \,F^2}{\varepsilon_0 {\varepsilon_{rf}}RT}
-          = \frac{F^2}{\varepsilon_0 {\varepsilon_{rf}}RT}\sum_{i=1}^{K} c_i z_i^2     \\
-          k_{rf}  &=&     \frac{1}{r_c^3}\,
-          \frac{({\varepsilon_{rf}}-{\varepsilon_r})(1 + \kappa r_c) + {\frac{1}{2}}{\varepsilon_{rf}}(\kappa r_c)^2}
-          {(2{\varepsilon_{rf}}+ {\varepsilon_r})(1 + \kappa r_c) + {\varepsilon_{rf}}(\kappa r_c)^2}
-          \end{aligned}
-          :label: eqnkgrf
-
-.. math:: \begin{aligned}
-          c_{rf}  &=&     \frac{1}{r_c}\,
-          \frac{3{\varepsilon_{rf}}(1 + \kappa r_c + {\frac{1}{2}}(\kappa r_c)^2)}
-          {(2{\varepsilon_{rf}}+{\varepsilon_r})(1 + \kappa r_c) + {\varepsilon_{rf}}(\kappa r_c)^2}
-          \end{aligned}
-          :label: eqncgrf
-
-where :math:`F` is Faraday’s constant, :math:`R` is the ideal gas
-constant, :math:`T` the absolute temperature, :math:`c_i` the molar
-concentration for species :math:`i` and :math:`z_i` the charge number of
-species :math:`i` where we have :math:`K` different species. In the
-limit of zero ionic strength (:math:`\kappa=0`) :eq:`eqns. %s <eqnkgrf>` and
-:eq:`%s <eqncgrf>` reduce to the simple forms of :eq:`eqns. %s <eqnkrf>` and :eq:`%s <eqncrf>`
-respectively.
-
 .. _modnbint:
 
 Modified non-bonded interactions
index 23f28fae37596f00c80a850d48ba7f4459802c7a..ec95099ea587961130cdc416f1ad7b48bdf8bf4b 100644 (file)
@@ -992,20 +992,6 @@ simulations on distributed memory machines," *Comput. Phys. Commun.*,
 for parallelization of particle simulations," *J. Chem. Phys.*, **124**
 [18] 184109–184109 (2006).
 
-.. raw:: html
-
-   </div>
-
-.. raw:: html
-
-   <div id="ref-Tironi95">
-
-.. _refTironi95:
-
-:sup:`71` I.G. Tironi, R. Sperb, P.E. Smith, and W.F. van Gunsteren, "A
-generalized reaction field method for molecular dynamics simulations,"
-*J. Chem. Phys.*, **102** 5451–5459 (1995).
-
 .. raw:: html
 
    </div>
index 7ceca019d4080e6edc63fede12b9e3caad0e7ead..238de3afa4d82601e56453cc5a24ed90ae7595d0 100644 (file)
@@ -17,6 +17,13 @@ that depend on it no longer work.
 
 :issue:`1852`
 
+Generalized reaction-field
+""""""""""""""""""""""""""
+
+This only worked correctly with the group scheme. Note that generalized
+reaction-field simulations can still be performed using standard
+reaction field and computing the dielectric constant manually.
+       
 gmx anadock
 """""""""""
 The gmx anadock tool was removed since it does not belong in gromacs
index 3801cb8d331224c259404895f7b08a0bc319e320..15b8b8aaa988f2b0abd9c4f6a71797f6effbdc59 100644 (file)
@@ -622,16 +622,6 @@ Electrostatics
       :mdp:`epsilon-rf`. The dielectric constant can be set to
       infinity by setting :mdp:`epsilon-rf` =0.
 
-   .. mdp-value:: Generalized-Reaction-Field
-
-      Generalized reaction field with Coulomb cut-off
-      :mdp:`rcoulomb`, where :mdp:`rlist` >= :mdp:`rcoulomb`. The
-      dielectric constant beyond the cut-off is
-      :mdp:`epsilon-rf`. The ionic strength is computed from the
-      number of charged (*i.e.* with non zero charge) charge
-      groups. The temperature for the GRF potential is set with
-      :mdp:`ref-t`.
-
    .. mdp-value:: Reaction-Field-zero
 
       In |Gromacs|, normal reaction-field electrostatics with
index 2bdcc5a80972fa4f0794fa31a91480c1a07c5cdb..390d51454a1dfeb43630ce03c4401d1a0baccf0d 100644 (file)
@@ -4040,18 +4040,10 @@ void triple_check(const char *mdparin, t_inputrec *ir, gmx_mtop_t *sys,
     }
 
     /* Generalized reaction field */
-    if (ir->opts.ngtc == 0)
+    if (ir->coulombtype == eelGRF_NOTUSED)
     {
-        sprintf(err_buf, "No temperature coupling while using coulombtype %s",
-                eel_names[eelGRF]);
-        CHECK(ir->coulombtype == eelGRF);
-    }
-    else
-    {
-        sprintf(err_buf, "When using coulombtype = %s"
-                " ref-t for temperature coupling should be > 0",
-                eel_names[eelGRF]);
-        CHECK((ir->coulombtype == eelGRF) && (ir->opts.ref_t[0] <= 0));
+        warning_error(wi, "Generalized reaction-field electrostatics is no longer supported. "
+                      "You can use normal reaction-field instead and compute the reaction-field constant by hand.");
     }
 
     bAcc = FALSE;
index e83589fc48acd0fa9de36062cb30ede6a80e0ea1..8bf6e9768d9137cf7ee67efc8b40c1077f479d3e 100644 (file)
@@ -929,16 +929,6 @@ static bool set_chargesum(FILE *log, t_forcerec *fr, const gmx_mtop_t *mtop)
             std::abs(fr->qsum[1]) > 1e-4);
 }
 
-void update_forcerec(t_forcerec *fr, matrix box)
-{
-    if (fr->ic->eeltype == eelGRF)
-    {
-        calc_rffac(nullptr, fr->ic->eeltype, fr->ic->epsilon_r, fr->ic->epsilon_rf,
-                   fr->ic->rcoulomb, fr->temp, fr->zsquare, box,
-                   &fr->ic->k_rf, &fr->ic->c_rf);
-    }
-}
-
 static real calcBuckinghamBMax(FILE *fplog, const gmx_mtop_t *mtop)
 {
     const t_atoms *at1, *at2;
@@ -1424,14 +1414,12 @@ init_interaction_const(FILE                       *fp,
     /* Reaction-field */
     if (EEL_RF(ic->eeltype))
     {
+        GMX_RELEASE_ASSERT(ic->eeltype != eelGRF_NOTUSED, "GRF is no longer supported");
         ic->epsilon_rf = ir->epsilon_rf;
-        /* Generalized reaction field parameters are updated every step */
-        if (ic->eeltype != eelGRF)
-        {
-            calc_rffac(fp, ic->eeltype, ic->epsilon_r, ic->epsilon_rf,
-                       ic->rcoulomb, 0, 0, nullptr,
-                       &ic->k_rf, &ic->c_rf);
-        }
+
+        calc_rffac(fp, ic->epsilon_r, ic->epsilon_rf,
+                   ic->rcoulomb,
+                   &ic->k_rf, &ic->c_rf);
     }
     else
     {
@@ -1528,7 +1516,8 @@ void init_forcerec(FILE                             *fp,
         fr->n_tpi = 0;
     }
 
-    if (ir->coulombtype == eelRF_NEC_UNSUPPORTED)
+    if (ir->coulombtype == eelRF_NEC_UNSUPPORTED ||
+        ir->coulombtype == eelGRF_NOTUSED)
     {
         gmx_fatal(FARGS, "%s electrostatics is no longer supported",
                   eel_names[ir->coulombtype]);
@@ -1729,7 +1718,6 @@ void init_forcerec(FILE                             *fp,
             break;
 
         case eelRF:
-        case eelGRF:
             fr->nbkernel_elec_interaction = GMX_NBKERNEL_ELEC_REACTIONFIELD;
             break;
 
@@ -1810,15 +1798,6 @@ void init_forcerec(FILE                             *fp,
     /* 1-4 interaction electrostatics */
     fr->fudgeQQ = mtop->ffparams.fudgeQQ;
 
-    /* Parameters for generalized RF */
-    fr->zsquare = 0.0;
-    fr->temp    = 0.0;
-
-    if (ic->eeltype == eelGRF)
-    {
-        init_generalized_rf(fp, mtop, ir, fr);
-    }
-
     fr->haveDirectVirialContributions =
         (EEL_FULL(ic->eeltype) || EVDW_PME(ic->vdwtype) ||
          fr->forceProviders->hasForceProvider() ||
index 118aca2f08d2a7e700470fc1428e9879d753d490..f59ee29074b37924deaa2efd0b96388b8817e0e2 100644 (file)
@@ -142,14 +142,6 @@ void init_forcerec(FILE                             *fplog,
 void forcerec_set_excl_load(t_forcerec           *fr,
                             const gmx_localtop_t *top);
 
-/*! \brief Update parameters dependent on box
- *
- * Updates parameters in the forcerec that are time dependent
- * \param[out] fr  The force record
- * \param[in]  box The simulation box
- */
-void update_forcerec(t_forcerec *fr, matrix box);
-
 void free_gpu_resources(t_forcerec                          *fr,
                         const gmx::PhysicalNodeCommunicator &physicalNodeCommunicator,
                         const gmx_gpu_info_t                &gpu_info);
index 6d29a99c68addc5678c4766c5aeaf39400fe4206..deb1285a59f38f443cddf9a44c8873f7b33ae0e1 100644 (file)
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/pleasecite.h"
 
-void calc_rffac(FILE *fplog, int eel, real eps_r, real eps_rf, real Rc, real Temp,
-                real zsq, matrix box,
+void calc_rffac(FILE *fplog, real eps_r, real eps_rf, real Rc,
                 real *krf, real *crf)
 {
-    /* Compute constants for Generalized reaction field */
-    real   kappa, k1, k2, I, rmin;
-    real   vol = 0;
-
-    if (EEL_RF(eel))
-    {
-        if (eel == eelGRF)
-        {
-            /* Consistency check */
-            if (Temp <= 0.0)
-            {
-                gmx_fatal(FARGS, "Temperature is %f while using"
-                          " Generalized Reaction Field\n", Temp);
-            }
-            /* Ionic strength (only needed for eelGRF */
-            vol     = det(box);
-            I       = 0.5*zsq/vol;
-            kappa   = std::sqrt(2*I/(EPSILON0*eps_rf*BOLTZ*Temp));
-        }
-        else
-        {
-            I      = 0;
-            kappa  = 0;
-        }
-
-        /* eps == 0 signals infinite dielectric */
-        if (eps_rf == 0)
-        {
-            *krf = 1/(2*Rc*Rc*Rc);
-        }
-        else
-        {
-            k1   = 1 + kappa*Rc;
-            k2   = eps_rf*gmx::square(static_cast<real>(kappa*Rc));
-
-            *krf = ((eps_rf - eps_r)*k1 + 0.5*k2)/((2*eps_rf + eps_r)*k1 + k2)/(Rc*Rc*Rc);
-        }
-        *crf   = 1/Rc + *krf*Rc*Rc;
-        // Make sure we don't lose resolution in pow() by casting real arg to double
-        rmin   = gmx::invcbrt(static_cast<double>(*krf*2.0));
-
-        if (fplog)
-        {
-            if (eel == eelGRF)
-            {
-                please_cite(fplog, "Tironi95a");
-                fprintf(fplog, "%s:\n"
-                        "epsRF = %10g, I   = %10g, volume = %10g, kappa  = %10g\n"
-                        "rc    = %10g, krf = %10g, crf    = %10g, epsfac = %10g\n",
-                        eel_names[eel], eps_rf, I, vol, kappa, Rc, *krf, *crf,
-                        ONE_4PI_EPS0/eps_r);
-            }
-            else
-            {
-                fprintf(fplog, "%s:\n"
-                        "epsRF = %g, rc = %g, krf = %g, crf = %g, epsfac = %g\n",
-                        eel_names[eel], eps_rf, Rc, *krf, *crf, ONE_4PI_EPS0/eps_r);
-            }
-            fprintf(fplog,
-                    "The electrostatics potential has its minimum at r = %g\n",
-                    rmin);
-        }
-    }
-}
-
-void init_generalized_rf(FILE *fplog,
-                         const gmx_mtop_t *mtop, const t_inputrec *ir,
-                         t_forcerec *fr)
-{
-    int                  i, j;
-    real                 q, zsq, nrdf, T;
-    const gmx_moltype_t *molt;
-    const t_block       *cgs;
-
-    if (ir->efep != efepNO && fplog)
+    /* eps == 0 signals infinite dielectric */
+    if (eps_rf == 0)
     {
-        fprintf(fplog, "\nWARNING: the generalized reaction field constants are determined from topology A only\n\n");
+        *krf = 1/(2*Rc*Rc*Rc);
     }
-    zsq = 0.0;
-    for (const gmx_molblock_t &molb : mtop->molblock)
+    else
     {
-        molt = &mtop->moltype[molb.type];
-        cgs  = &molt->cgs;
-        for (i = 0; (i < cgs->nr); i++)
-        {
-            q = 0;
-            for (j = cgs->index[i]; (j < cgs->index[i+1]); j++)
-            {
-                q += molt->atoms.atom[j].q;
-            }
-            zsq += molb.nmol*q*q;
-        }
-        fr->zsquare = zsq;
+        *krf = (eps_rf - eps_r)/(2*eps_rf + eps_r)/(Rc*Rc*Rc);
     }
+    *crf   = 1/Rc + *krf*Rc*Rc;
 
-    T    = 0.0;
-    nrdf = 0.0;
-    for (i = 0; (i < ir->opts.ngtc); i++)
+    if (fplog)
     {
-        nrdf += ir->opts.nrdf[i];
-        T    += (ir->opts.nrdf[i] * ir->opts.ref_t[i]);
-    }
-    if (nrdf == 0)
-    {
-        gmx_fatal(FARGS, "No degrees of freedom!");
+        fprintf(fplog, "%s:\n"
+                "epsRF = %g, rc = %g, krf = %g, crf = %g, epsfac = %g\n",
+                eel_names[eelRF], eps_rf, Rc, *krf, *crf, ONE_4PI_EPS0/eps_r);
+        // Make sure we don't lose resolution in pow() by casting real arg to double
+        real rmin = gmx::invcbrt(static_cast<double>(*krf*2.0));
+        fprintf(fplog,
+                "The electrostatics potential has its minimum at r = %g\n",
+                rmin);
     }
-    fr->temp   = T/nrdf;
 }
index 416b6d4708193fc830ec09cd36e294d3f0a95e51..a27fc1600364761e9d18ba607d78a21b63ea7788 100644 (file)
@@ -44,16 +44,9 @@ struct gmx_mtop_t;
 struct t_forcerec;
 struct t_inputrec;
 
-void calc_rffac(FILE *fplog, int eel, real eps_r, real eps_rf,
-                real Rc, real Temp,
-                real zsq, matrix box,
+void calc_rffac(FILE *fplog, real eps_r, real eps_rf,
+                real Rc,
                 real *krf, real *crf);
 /* Determine the reaction-field constants */
 
-void init_generalized_rf(FILE *fplog,
-                         const gmx_mtop_t *mtop, const t_inputrec *ir,
-                         t_forcerec *fr);
-/* Initialize the generalized reaction field parameters */
-
-
 #endif
index 766816c4e78f50567699e3f9d93f60f2ca57b855..68335add00a00387cbe49d9395e6c0d00c150410 100644 (file)
@@ -887,8 +887,6 @@ void do_force(FILE                                     *fplog,
 
     if (bStateChanged)
     {
-        update_forcerec(fr, box);
-
         if (inputrecNeedMutot(inputrec))
         {
             /* Calculate total (local) dipole moment in a temporary common array.
index cbd4bb029c01af1276cad629dca3f488fa361ea2..102d9af77b7eab54b4ff7cd9c2672fd0184588f1 100644 (file)
@@ -156,10 +156,6 @@ struct t_forcerec { // NOLINT (clang-analyzer-optin.performance.Padding)
      */
     real rlist = 0;
 
-    /* Parameters for generalized reaction field */
-    real zsquare = 0;
-    real temp    = 0;
-
     /* Charge sum and dipole for topology A/B ([0]/[1]) for Ewald corrections */
     double qsum[2]   = { 0 };
     double q2sum[2]  = { 0 };
index 3b03645e3ff082c165a4ab37d0d16f38fa8a486f..71e4b5636ac683cd0ab9f6bb0f212525e7c66a19 100644 (file)
@@ -3,7 +3,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,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, 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.
@@ -75,7 +75,7 @@ const char *erefscaling_names[erscNR+1] = {
 };
 
 const char *eel_names[eelNR+1] = {
-    "Cut-off", "Reaction-Field", "Generalized-Reaction-Field",
+    "Cut-off", "Reaction-Field", "Generalized-Reaction-Field (unused)",
     "PME", "Ewald", "P3M-AD", "Poisson", "Switch", "Shift", "User",
     "Generalized-Born (unused)", "Reaction-Field-nec", "Encad-shift",
     "PME-User", "PME-Switch", "PME-User-Switch",
index f5cf68e68ebdc89a849f51a7800cbabf1762b126..27f2a6a9b387a281655a185d6e5f2d4e0eb4d167 100644 (file)
@@ -3,7 +3,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,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, 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.
@@ -161,7 +161,7 @@ extern const char *eintmod_names[eintmodNR+1];
 
 /*! \brief Cut-off treatment for Coulomb */
 enum {
-    eelCUT,     eelRF,     eelGRF,   eelPME,  eelEWALD,  eelP3M_AD,
+    eelCUT,     eelRF,     eelGRF_NOTUSED,   eelPME,  eelEWALD,  eelP3M_AD,
     eelPOISSON, eelSWITCH, eelSHIFT, eelUSER, eelGB_NOTUSED, eelRF_NEC_UNSUPPORTED, eelENCADSHIFT,
     eelPMEUSER, eelPMESWITCH, eelPMEUSERSWITCH, eelRF_ZERO, eelNR
 };
@@ -178,7 +178,7 @@ enum {
 extern const char *eewg_names[eewgNR+1];
 
 //! Macro telling us whether we use reaction field
-#define EEL_RF(e) ((e) == eelRF || (e) == eelGRF || (e) == eelRF_NEC_UNSUPPORTED || (e) == eelRF_ZERO )
+#define EEL_RF(e) ((e) == eelRF || (e) == eelGRF_NOTUSED || (e) == eelRF_NEC_UNSUPPORTED || (e) == eelRF_ZERO )
 
 //! Macro telling us whether we use PME
 #define EEL_PME(e)  ((e) == eelPME || (e) == eelPMESWITCH || (e) == eelPMEUSER || (e) == eelPMEUSERSWITCH || (e) == eelP3M_AD)
index d0f0c64d9b00f6c5286247984d47ddcc27ad11d3..7e10798ee3a549e4eea3d19fded1c8610d171fb2 100644 (file)
@@ -1226,7 +1226,6 @@ static void set_table_type(int tabsel[], const interaction_const_t *ic, gmx_bool
             tabsel[etiCOUL] = etabEwaldUserSwitch;
             break;
         case eelRF:
-        case eelGRF:
         case eelRF_ZERO:
             tabsel[etiCOUL] = etabRF_ZERO;
             break;