Remove PBC before generating TPR with group scheme
authorPaul Bauer <paul.bauer.q@gmail.com>
Mon, 11 Dec 2017 11:53:12 +0000 (12:53 +0100)
committerErik Lindahl <erik.lindahl@gmail.com>
Thu, 14 Dec 2017 08:38:15 +0000 (09:38 +0100)
Ensure that all molecules have been made whole before generating the
run input file when using the group scheme, to avoid error
messages for large charge groups when molecules are broken
over PBC boundaries.

Fixes #2339

Change-Id: Iecba013826cbe46e7f70bd674935f9946806ee2e

src/gromacs/gmxpreprocess/grompp.cpp

index dc5934f5ff9a852f4f7035dd85f378234aa6ba8e..001650d494176a853b54876f092c5f2f431dd081 100644 (file)
@@ -79,6 +79,7 @@
 #include "gromacs/mdlib/constr.h"
 #include "gromacs/mdlib/genborn.h"
 #include "gromacs/mdlib/perf_est.h"
+#include "gromacs/mdlib/sim_util.h"
 #include "gromacs/mdrunutility/mdmodules.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/mdtypes/md_enums.h"
@@ -657,6 +658,15 @@ new_status(const char *topfile, const char *topppfile, const char *confin,
         warning(wi, buf);
     }
 
+    /* If using the group scheme, make sure charge groups are made whole to avoid errors
+     * in calculating charge group size later on
+     */
+    if (ir->cutoff_scheme == ecutsGROUP && ir->ePBC != epbcNONE)
+    {
+        // Need temporary rvec for coordinates
+        do_pbc_first_mtop(nullptr, ir->ePBC, state->box, sys, as_rvec_array(state->x.data()));
+    }
+
     /* Do more checks, mostly related to constraints */
     if (bVerbose)
     {