Merge "Merge branch release-2018 into release-2019" into release-2019
authorMark Abraham <mark.j.abraham@gmail.com>
Fri, 26 Oct 2018 18:47:22 +0000 (20:47 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 26 Oct 2018 18:47:22 +0000 (20:47 +0200)
13 files changed:
docs/CMakeLists.txt
docs/release-notes/2018/2018.4.rst
docs/user-guide/index.rst
docs/user-guide/mdp-options.rst
docs/user-guide/security.rst [new file with mode: 0644]
src/gromacs/ewald/pme.cpp
src/gromacs/fileio/tpxio.cpp
src/gromacs/fileio/tpxio.h
src/gromacs/gmxana/gmx_helix.cpp
src/gromacs/gmxana/gmx_mindist.cpp
src/gromacs/mdlib/force.cpp
src/gromacs/mdlib/membed.cpp
src/gromacs/mdtypes/enerdata.h

index f7af04cd47dc5472fabfc29731e5457a0e562617..6b72f9d2999418b62a6f44c211e8f87f00619a6d 100644 (file)
@@ -372,6 +372,7 @@ if (SPHINX_FOUND)
         user-guide/mdrun-features.rst
         user-guide/mdrun-performance.rst
         user-guide/run-time-errors.rst
+        user-guide/security.rst
         user-guide/system-preparation.rst
         user-guide/terminology.rst
         )
index dd0c3345fcd19871a9658dbf9f123da692d8335b..e754d0b84a385719f31f6a6dda3a3aedc976b9f2 100644 (file)
@@ -9,11 +9,61 @@ earlier, which you can find described in the :ref:`release-notes`.
 Fixes where mdrun could behave incorrectly
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+Correct PME forces with free energy without perturbed charges/LJ
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+With free-energies calculations with lambda not set to zero and no
+actual perturbed charges or atom types for Lennard-Jones, the Coulomb
+or LJ PME mesh forces would be scaled with lambda. Note that this bug
+did not affect the, usual, setup where charges or atom types are actually
+perturbed.
+
+:issue: `2640`
+
+Add constraint contribution to foreign Hamiltonian differences
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+The contribution of perturbed constraints was missing from the foreign
+Hamiltonian values. This is important for free energy calculations,
+such as BAR.
+
+:issue: `2703`
+
+Add mass contribution to foreign Hamiltonian differences
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+For free energy calculations with perturbed masses, the kinetic energy
+contribution was missing from the foreign Hamiltonian values.
+
+:issue: `2703`
+
 Fixes for ``gmx`` tools
 ^^^^^^^^^^^^^^^^^^^^^^^
 
+Fix mindist output file checks
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+mindist would not check if the output file needed to print residue names and
+residue contacts over time was actually defined, leading to errors with
+empty file name strings.
+
+:issue:`2653`
+
+Fix helix segmentation fault
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+The .tpr file is now read correctly. 
+
+:issue:`2701`
+
+
 Fixes to improve portability
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 Miscellaneous
 ^^^^^^^^^^^^^
+
+Fixed an issue where the log file could sometimes report an incorrect
+initial dynamic load balancing state
+
+:issue:`2631`
index 9330890fb11b80f4fc2cbf6d756e6e6cb0129aee..ad509c9eca0c6fa015c42f549821bc8ea1e8f05c 100644 (file)
@@ -41,4 +41,5 @@ For background on algorithms and implementations, see the
    terminology
    environment-variables
    floating-point
+   security
    deprecation-policy
index 987004474942c146367c8a602086e029bd111a56..01c1a40d2598a8b5f72b5c3842fa71c558694eb2 100644 (file)
@@ -1112,7 +1112,7 @@ Pressure coupling
    .. mdp-value:: Berendsen
 
       Exponential relaxation pressure coupling with time constant
-      :mdp:`tau-p`. The box is scaled every timestep. It has been
+      :mdp:`tau-p`. The box is scaled every :mdp:`nstpcouple` steps. It has been
       argued that this does not yield a correct thermodynamic
       ensemble, but it is the most efficient way to scale a box at the
       beginning of a run.
diff --git a/docs/user-guide/security.rst b/docs/user-guide/security.rst
new file mode 100644 (file)
index 0000000..36b6d06
--- /dev/null
@@ -0,0 +1,19 @@
+Security when using |Gromacs|
+=============================
+
+.. _gmx-security:
+
+We advise the users of |Gromacs| to be careful when using |Gromacs|
+with files obtained from an unknown source (e.g. the Internet).
+
+We cannot guarantee that the program won't crash with serious errors
+that could cause execution of code with the same privileges as |Gromacs|
+and e.g. delete the contents of your home directory..
+
+Files that the user has created themselves don't carry those risks, but may
+still misbehave and crash or consume large amounts of resources upon
+malformed input.
+
+Run input files obtained from outside sources should be treated with the
+same caution as an executable file from the same source.
+
index 91675f18e92b9538f4bd0a56e3b821d19ed5ca7a..717eadbfad9453d3e300af6466410df170772e1c 100644 (file)
@@ -1129,6 +1129,16 @@ int gmx_pme_do(struct gmx_pme_t *pme,
     const gmx_bool       bBackFFT                = (flags & (GMX_PME_CALC_F | GMX_PME_CALC_POT)) != 0;
     const gmx_bool       bCalcF                  = (flags & GMX_PME_CALC_F) != 0;
 
+    /* We could be passing lambda!=1 while no q or LJ is actually perturbed */
+    if (!pme->bFEP_q)
+    {
+        lambda_q  = 1;
+    }
+    if (!pme->bFEP_lj)
+    {
+        lambda_lj = 1;
+    }
+
     assert(pme->nnodes > 0);
     assert(pme->nnodes == 1 || pme->ndecompdim > 0);
 
index 8ce2b60ec27b767ed385e3a0d028c8438c781177..2efb336f97fdba2b37c581a63fe62227f86e3cd5 100644 (file)
@@ -3003,7 +3003,10 @@ int read_tpx(const char *fn,
     fio     = open_tpx(fn, "r");
     ePBC    = do_tpx(fio, TRUE, ir, &state, x, v, mtop);
     close_tpx(fio);
-    *natoms = mtop->natoms;
+    if (mtop != nullptr && natoms != nullptr)
+    {
+        *natoms = mtop->natoms;
+    }
     if (box)
     {
         copy_mat(state.box, box);
index 071bcab760477c89ce320528fe2ca559d7a52b08..42ef1d83867788cf54774ed32717aac419824096 100644 (file)
@@ -97,13 +97,32 @@ void write_tpx_state(const char *fn,
 void read_tpx_state(const char *fn,
                     t_inputrec *ir, t_state *state,
                     gmx_mtop_t *mtop);
+
+/*! \brief
+ * Read a file and close it again.
+ *
+ * Reads a topology input file and populates the fields if the passed
+ * variables are valid. It is possible to pass \p ir, \p natoms,
+ * \p x, \p v or \p mtop as nullptr to the function. In those cases,
+ * the variables will not be populated from the input file. Passing both
+ * \p x and \p v as nullptr is not supported. If both \p natoms and
+ * \p mtop are passed as valid objects to the function, the total atom
+ * number from \p mtop will be set in \p natoms. Otherwise \p natoms
+ * will not be changed. If \p box is valid, the box will be set from
+ * the information read in from the file.
+ *
+ * \param[in] fn Input file name.
+ * \param[out] ir Input parameters to be set, or nullptr.
+ * \param[out] box Box matrix.
+ * \param[out] natoms Total atom numbers to be set, or nullptr.
+ * \param[out] x Positions to be filled from file, or nullptr.
+ * \param[out] v Velocities to be filled from file, or nullptr.
+ * \param[out] mtop Topology to be populated, or nullptr.
+ * \returns ir->ePBC if it was read from the file.
+ */
 int read_tpx(const char *fn,
              t_inputrec *ir, matrix box, int *natoms,
              rvec *x, rvec *v, gmx_mtop_t *mtop);
-/* Read a file, and close it again.
- * When step, t or lambda are NULL they will not be stored.
- * Returns ir->ePBC, if it could be read from the file.
- */
 
 int read_tpx_top(const char *fn,
                  t_inputrec *ir, matrix box, int *natoms,
index e5fd625218cbda19960c1613aefd3e344296841a..7f659c1e1530aa72b7269a009a45518bc4e31422 100644 (file)
@@ -207,7 +207,7 @@ int gmx_helix(int argc, char *argv[])
     /* Read reference frame from tpx file to compute helix length */
     snew(xref, top->atoms.nr);
     read_tpx(ftp2fn(efTPR, NFILE, fnm),
-             nullptr, nullptr, &natoms, xref, nullptr, nullptr);
+             nullptr, nullptr, nullptr, xref, nullptr, nullptr);
     calc_hxprops(nres, bb, xref);
     do_start_end(nres, bb, &nbb, bbindex, &nca, caindex, bRange, rStart, rEnd);
     sfree(xref);
index 43c1331a00e24ded52eae9ac0fdb2c5c547ba0b6..9ce1732513998f81d27c582046e1bf5767c00a1c 100644 (file)
@@ -800,6 +800,10 @@ int gmx_mindist(int argc, char *argv[])
             dump_res(debug, nres, residues, index[0]);
         }
     }
+    else if (bEachResEachTime || bPrintResName)
+    {
+        gmx_fatal(FARGS, "Option -or needs to be set to print residues");
+    }
 
     if (bPI)
     {
index 93e623f128bb288eb15ed3188c998fb9bc2e591f..5e089e79f65563ddc4611c45fc82f4becd5f49be 100644 (file)
@@ -696,7 +696,6 @@ void sum_epot(gmx_grppairener_t *grpp, real *epot)
 void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda *fepvals)
 {
     int    index;
-    double dlam;
 
     enerd->dvdl_lin[efptVDW] += enerd->term[F_DVDL_VDW];  /* include dispersion correction */
     enerd->term[F_DVDL]       = 0.0;
@@ -744,13 +743,6 @@ void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda
         }
     }
 
-    /* Notes on the foreign lambda free energy difference evaluation:
-     * Adding the potential and ekin terms that depend linearly on lambda
-     * as delta lam * dvdl to the energy differences is exact.
-     * For the constraints this is not exact, but we have no other option
-     * without literally changing the lengths and reevaluating the energies at each step.
-     * (try to remedy this post 4.6 - MRS)
-     */
     if (fepvals->separate_dvdl[efptBONDED])
     {
         enerd->term[F_DVDL_BONDED] += enerd->term[F_DVDL_CONSTR];
@@ -759,7 +751,6 @@ void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda
     {
         enerd->term[F_DVDL] += enerd->term[F_DVDL_CONSTR];
     }
-    enerd->term[F_DVDL_CONSTR] = 0;
 
     for (int i = 0; i < fepvals->n_lambda; i++)
     {
@@ -772,20 +763,42 @@ void sum_dhdl(gmx_enerdata_t *enerd, gmx::ArrayRef<const real> lambda, t_lambda
            current lambda, because the contributions to the current
            lambda are automatically zeroed */
 
+        double &enerpart_lambda = enerd->enerpart_lambda[i + 1];
+
         for (gmx::index j = 0; j < lambda.size(); j++)
         {
             /* Note that this loop is over all dhdl components, not just the separated ones */
-            dlam = (fepvals->all_lambda[j][i] - lambda[j]);
-            enerd->enerpart_lambda[i+1] += dlam*enerd->dvdl_lin[j];
+            const double dlam  = fepvals->all_lambda[j][i] - lambda[j];
+
+            enerpart_lambda   += dlam*enerd->dvdl_lin[j];
+
+            /* Constraints can not be evaluated at foreign lambdas, so we add
+             * a linear extrapolation. This is an approximation, but usually
+             * quite accurate since constraints change little between lambdas.
+             */
+            if ((j == efptBONDED && fepvals->separate_dvdl[efptBONDED]) ||
+                (j == efptFEP && !fepvals->separate_dvdl[efptBONDED]))
+            {
+                enerpart_lambda += dlam*enerd->term[F_DVDL_CONSTR];
+            }
+
+            if (j == efptMASS)
+            {
+                enerpart_lambda += dlam*enerd->term[F_DKDL];
+            }
+
             if (debug)
             {
                 fprintf(debug, "enerdiff lam %g: (%15s), non-linear %f linear %f*%f\n",
                         fepvals->all_lambda[j][i], efpt_names[j],
-                        (enerd->enerpart_lambda[i+1] - enerd->enerpart_lambda[0]),
+                        enerpart_lambda - enerd->enerpart_lambda[0],
                         dlam, enerd->dvdl_lin[j]);
             }
         }
     }
+
+    /* The constrain contribution is now included in other terms, so clear it */
+    enerd->term[F_DVDL_CONSTR] = 0;
 }
 
 
index ee1b0c3b714969cba03b24da23496840cdce44ac..c5647569662da57914c28b51ca99521c33820c4d 100644 (file)
@@ -700,7 +700,7 @@ static void rm_group(gmx_groups_t *groups, gmx_mtop_t *mtop, rm_t *rm_p, t_state
     }
 
     mtop->natoms    -= n;
-    state->natoms   -= n;
+    state_change_natoms(state, state->natoms - n);
     snew(x_tmp, state->natoms);
     snew(v_tmp, state->natoms);
 
index eccbe71c9410931168c533fa50823f75b602cf76..2087c8b44a1759efd4837ea1494cd130b464d8bc 100644 (file)
@@ -56,9 +56,14 @@ struct gmx_enerdata_t
     struct gmx_grppairener_t grpp;
     double                   dvdl_lin[efptNR];    /* Contributions to dvdl with linear lam-dependence */
     double                   dvdl_nonlin[efptNR]; /* Idem, but non-linear dependence                  */
+    /* The idea is that dvdl terms with linear lambda dependence will be added
+     * automatically to enerpart_lambda. Terms with non-linear lambda dependence
+     * should explicitly determine the energies at foreign lambda points
+     * when n_lambda > 0. */
+
     int                      n_lambda;
     int                      fep_state;           /*current fep state -- just for printing */
-    double                  *enerpart_lambda;     /* Partial energy for lambda and flambda[] */
+    double                  *enerpart_lambda;     /* Partial Hamiltonian for lambda and flambda[], includes at least all perturbed terms */
     real                     foreign_term[F_NRE]; /* alternate array for storing foreign lambda energies */
     struct gmx_grppairener_t foreign_grpp;        /* alternate array for storing foreign lambda energies */
 };