Group scheme related cleanup
authorSzilárd Páll <pall.szilard@gmail.com>
Mon, 15 Apr 2019 19:02:17 +0000 (21:02 +0200)
committerBerk Hess <hess@kth.se>
Tue, 16 Apr 2019 11:50:35 +0000 (13:50 +0200)
Removed:
- SR force calculation invocation
- LR correction invocations
- SR free energy component accumulation

Minor cleanup.

Refs #1852

Change-Id: I4e22986279039a0f49a5a8be3c447f4115308492

src/gromacs/mdlib/force.cpp
src/gromacs/mdlib/force.h
src/gromacs/mdlib/sim_util.cpp

index bea3a6410e6e30e621a7456740ca023fe40ea4b2..a9e3486df79913cb9ebaa3633471c29048e52dd9 100644 (file)
@@ -52,7 +52,6 @@
 #include "gromacs/ewald/pme.h"
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/gmxlib/nrnb.h"
-#include "gromacs/gmxlib/nonbonded/nonbonded.h"
 #include "gromacs/listed_forces/listed_forces.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/math/vecdump.h"
@@ -67,6 +66,7 @@
 #include "gromacs/mdtypes/forcerec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
+#include "gromacs/mdtypes/mdatom.h"
 #include "gromacs/pbcutil/ishift.h"
 #include "gromacs/pbcutil/mshift.h"
 #include "gromacs/pbcutil/pbc.h"
@@ -116,7 +116,6 @@ void do_force_lowlevel(t_forcerec                   *fr,
                        gmx_enerdata_t               *enerd,
                        t_fcdata                     *fcd,
                        matrix                        box,
-                       t_lambda                     *fepvals,
                        real                         *lambda,
                        const t_graph                *graph,
                        const t_blocka               *excl,
@@ -124,22 +123,10 @@ void do_force_lowlevel(t_forcerec                   *fr,
                        int                           flags,
                        const DDBalanceRegionHandler &ddBalanceRegionHandler)
 {
-    int         i, j;
-    int         donb_flags;
-    int         pme_flags;
-    real        dvdl_dum[efptNR], dvdl_nb[efptNR];
-
 #if GMX_MPI
     double  t0 = 0.0, t1, t2, t3; /* time measurement for coarse load balancing */
 #endif
 
-    /* reset free energy components */
-    for (i = 0; i < efptNR; i++)
-    {
-        dvdl_nb[i]  = 0;
-        dvdl_dum[i] = 0;
-    }
-
     /* do QMMM first if requested */
     if (fr->bQMMM)
     {
@@ -167,58 +154,6 @@ void do_force_lowlevel(t_forcerec                   *fr,
         enerd->dvdl_lin[efptVDW] += dvdl_walls;
     }
 
-    /* We only do non-bonded calculation with group scheme here, the verlet
-     * calls are done from do_force_cutsVERLET(). */
-    if (fr->cutoff_scheme == ecutsGROUP && (flags & GMX_FORCE_NONBONDED))
-    {
-        donb_flags = 0;
-        /* Add short-range interactions */
-        donb_flags |= GMX_NONBONDED_DO_SR;
-
-        /* Currently all group scheme kernels always calculate (shift-)forces */
-        if (flags & GMX_FORCE_FORCES)
-        {
-            donb_flags |= GMX_NONBONDED_DO_FORCE;
-        }
-        if (flags & GMX_FORCE_VIRIAL)
-        {
-            donb_flags |= GMX_NONBONDED_DO_SHIFTFORCE;
-        }
-        if (flags & GMX_FORCE_ENERGY)
-        {
-            donb_flags |= GMX_NONBONDED_DO_POTENTIAL;
-        }
-
-        wallcycle_sub_start(wcycle, ewcsNONBONDED);
-        do_nonbonded(fr, x, forceForUseWithShiftForces, md, excl,
-                     &enerd->grpp, nrnb,
-                     lambda, dvdl_nb, -1, -1, donb_flags);
-
-        /* If we do foreign lambda and we have soft-core interactions
-         * we have to recalculate the (non-linear) energies contributions.
-         */
-        if (fepvals->n_lambda > 0 && (flags & GMX_FORCE_DHDL) && fepvals->sc_alpha != 0)
-        {
-            for (i = 0; i < enerd->n_lambda; i++)
-            {
-                real lam_i[efptNR];
-
-                for (j = 0; j < efptNR; j++)
-                {
-                    lam_i[j] = (i == 0 ? lambda[j] : fepvals->all_lambda[j][i-1]);
-                }
-                reset_foreign_enerdata(enerd);
-                do_nonbonded(fr, x, forceForUseWithShiftForces, md, excl,
-                             &(enerd->foreign_grpp), nrnb,
-                             lam_i, dvdl_dum, -1, -1,
-                             (donb_flags & ~GMX_NONBONDED_DO_FORCE) | GMX_NONBONDED_DO_FOREIGNLAMBDA);
-                sum_epot(&(enerd->foreign_grpp), enerd->foreign_term);
-                enerd->enerpart_lambda[i] += enerd->foreign_term[F_EPOT];
-            }
-        }
-        wallcycle_sub_stop(wcycle, ewcsNONBONDED);
-    }
-
 #if GMX_MPI
     if (TAKETIME)
     {
@@ -227,32 +162,6 @@ void do_force_lowlevel(t_forcerec                   *fr,
     }
 #endif
 
-    if (fepvals->sc_alpha != 0)
-    {
-        enerd->dvdl_nonlin[efptVDW] += dvdl_nb[efptVDW];
-    }
-    else
-    {
-        enerd->dvdl_lin[efptVDW] += dvdl_nb[efptVDW];
-    }
-
-    if (fepvals->sc_alpha != 0)
-
-    /* even though coulomb part is linear, we already added it, beacuse we
-       need to go through the vdw calculation anyway */
-    {
-        enerd->dvdl_nonlin[efptCOUL] += dvdl_nb[efptCOUL];
-    }
-    else
-    {
-        enerd->dvdl_lin[efptCOUL] += dvdl_nb[efptCOUL];
-    }
-
-    if (debug)
-    {
-        pr_rvecs(debug, 0, "fshift after SR", fr->fshift, SHIFTS);
-    }
-
     /* Shift the coordinates. Must be done before listed forces and PPPM,
      * but is also necessary for SHAKE and update, therefore it can NOT
      * go when no listed forces have to be evaluated.
@@ -280,14 +189,13 @@ void do_force_lowlevel(t_forcerec                   *fr,
         }
     }
 
-    t_pbc      pbc;
-    const bool useRfWithGroupScheme = (fr->cutoff_scheme == ecutsGROUP) && EEL_RF(fr->ic->eeltype);
-    /* Check whether we need to take into account PBC in the following force tasks:
-     * listed interactions or when correcting for exclusions (for the Group scheme with RF) */
-    if (fr->bMolPBC)
     {
-        const auto needPbcForListedForces = bool(flags & GMX_FORCE_LISTED) && haveCpuListedForces(*fr, *idef, *fcd);
-        if (needPbcForListedForces || useRfWithGroupScheme)
+        t_pbc      pbc;
+
+        /* Check whether we need to take into account PBC in the following force tasks:
+         * listed interactions. */
+        const auto needPbcForListedForces = fr->bMolPBC && bool(flags & GMX_FORCE_LISTED) && haveCpuListedForces(*fr, *idef, *fcd);
+        if (needPbcForListedForces)
         {
             /* Since all atoms are in the rectangular or triclinic unit-cell,
              * only single box vector shifts (2 in x) are required.
@@ -295,14 +203,14 @@ void do_force_lowlevel(t_forcerec                   *fr,
             set_pbc_dd(&pbc, fr->ePBC, DOMAINDECOMP(cr) ? cr->dd->nc : nullptr,
                        TRUE, box);
         }
-    }
 
-    do_force_listed(wcycle, box, ir->fepvals, cr, ms,
-                    idef, x, hist,
-                    forceForUseWithShiftForces, forceWithVirial,
-                    fr, &pbc, graph, enerd, nrnb, lambda, md, fcd,
-                    DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr,
-                    flags);
+        do_force_listed(wcycle, box, ir->fepvals, cr, ms,
+                        idef, x, hist,
+                        forceForUseWithShiftForces, forceWithVirial,
+                        fr, &pbc, graph, enerd, nrnb, lambda, md, fcd,
+                        DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr,
+                        flags);
+    }
 
 
     /* Do long-range electrostatics and/or LJ-PME, including related short-range
@@ -401,7 +309,7 @@ void do_force_lowlevel(t_forcerec                   *fr,
                 assert(fr->n_tpi >= 0);
                 if (fr->n_tpi == 0 || (flags & GMX_FORCE_STATECHANGED))
                 {
-                    pme_flags = GMX_PME_SPREAD | GMX_PME_SOLVE;
+                    int pme_flags = GMX_PME_SPREAD | GMX_PME_SOLVE;
 
                     if (flags & GMX_FORCE_FORCES)
                     {
@@ -504,23 +412,6 @@ void do_force_lowlevel(t_forcerec                   *fr,
             pr_rvecs(debug, 0, "vir_lj_recip after corr", ewaldOutput.vir_lj, DIM);
         }
     }
-    else
-    {
-        /* Is there a reaction-field exclusion correction needed?
-         * With the Verlet scheme, exclusion forces are calculated
-         * in the non-bonded kernel.
-         */
-        if (useRfWithGroupScheme)
-        {
-            real dvdl_rf_excl      = 0;
-            enerd->term[F_RF_EXCL] =
-                RF_excl_correction(fr, graph, md, excl, DOMAINDECOMP(cr),
-                                   x, forceForUseWithShiftForces,
-                                   fr->fshift, &pbc, lambda[efptCOUL], &dvdl_rf_excl);
-
-            enerd->dvdl_lin[efptCOUL] += dvdl_rf_excl;
-        }
-    }
 
     if (debug)
     {
index 622328befece6d5b6f6ef2c6475013cdd7e98380..ffaf0e2f30c450c126ed6c4e45acb96ec81d5260 100644 (file)
@@ -145,7 +145,6 @@ void do_force_lowlevel(t_forcerec   *fr,
                        gmx_enerdata_t *enerd,
                        t_fcdata     *fcd,
                        matrix       box,
-                       t_lambda     *fepvals,
                        real         *lambda,
                        const t_graph *graph,
                        const t_blocka *excl,
index 3627015193e2ee7194318e7d318af090c93860d0..8e088b40b818a43f35c43209c0d3cc9abe7db720 100644 (file)
@@ -1273,7 +1273,7 @@ void do_force(FILE                                     *fplog,
     do_force_lowlevel(fr, inputrec, &(top->idef),
                       cr, ms, nrnb, wcycle, mdatoms,
                       as_rvec_array(x.unpaddedArrayRef().data()), hist, forceOut.f, &forceOut.forceWithVirial, enerd, fcd,
-                      box, inputrec->fepvals, lambda.data(), graph, &(top->excls), fr->mu_tot,
+                      box, lambda.data(), graph, &(top->excls), fr->mu_tot,
                       flags,
                       ddBalanceRegionHandler);