Fix reading of bonded tables
authorMark Abraham <mark.j.abraham@gmail.com>
Thu, 3 Mar 2016 15:04:16 +0000 (16:04 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 27 May 2016 10:15:26 +0000 (12:15 +0200)
The old approach specified only a filename prefix, and init_forcerec
would expect to be able to append _b0 to generate the filename for the
zeroth bonded table, etc. This failed a check in early command-line
parsing when no file that matched just the prefix could be found.
Pairs are unaffected because there's only one table. Short-ranged
energy-group tables are not affected because they require that the
file with default name exists.

Command-line parsing now requires -tableb to name all tabulated bonded
interaction table files explicitly, and does the normal check that
they exist. init_forcerec will find any name in that list that matches
the required pattern. The concept of a default filename prefix for
tabulated bonded interactions no longer applies, but the old
'table_b0.xvg' naming still works. Added some comments and Doxygen to
explain what the old code was doing. Amended the user documentation
suitably.

One could add further checks e.g. that there are no table filenames
provided that are unused by the topology, but it is likely the need
for such checks will go away when the topology will name the files
directly.

Add some integration tests to show the functionality no longer
produces an error. Infrastructure to actually verify energies and
forces is waiting for review in Gerrit.

Expanded some string- and filename-handling infrastructure to meet
the new needs.

Improved the robustness of the check that the derivative column is
approximately the negative of the numerical derivative of the value
column.

Fixes #1913

Change-Id: If0a7cd69a40eb95fbda20eaaf4c3002782772f0e

16 files changed:
docs/manual/forcefield.tex
src/gromacs/fileio/filenm.c
src/gromacs/fileio/filenm.h
src/gromacs/legacyheaders/force.h
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/tables.c
src/gromacs/utility/stringutil.h
src/programs/mdrun/mdrun.cpp
src/programs/mdrun/runner.cpp
src/programs/mdrun/tests/CMakeLists.txt
src/programs/mdrun/tests/butane1.gro [new file with mode: 0644]
src/programs/mdrun/tests/butane1.ndx [new file with mode: 0644]
src/programs/mdrun/tests/butane_a0.xvg [new file with mode: 0644]
src/programs/mdrun/tests/butane_b0.xvg [new file with mode: 0644]
src/programs/mdrun/tests/butane_d0.xvg [new file with mode: 0644]
src/programs/mdrun/tests/tabulated_bonded_interactions.cpp [new file with mode: 0644]

index 4c32b09fd415bbc919d362686733960d77d0e430..b5659d1d34908438745c598cb687ab19c2f53231 100644 (file)
@@ -973,13 +973,13 @@ and one that does not (type 9).
 For details see \tabref{topfile2}.
 The table files are supplied to the {\tt mdrun} program.
 After the table file name an underscore, the letter ``b'' for bonds,
-``a'' for angles or ``d'' for dihedrals and the table number are appended.
-For example, for a bond with $n=0$ (and using the default table file name)
-the table is read from the file {\tt table_b0.xvg}.  Multiple tables can be
-supplied simply by using different values of $n$, and are applied to the appropriate
+``a'' for angles or ``d'' for dihedrals and the table number must be appended.
+For example, a tabulated bond with $n=0$ can be read from the file {\tt table_b0.xvg}.
+Multiple tables can be
+supplied simply by adding files with different values of $n$, and are applied to the appropriate
 bonds, as specified in the topology (\tabref{topfile2}).
-The format for the table files is three columns with $x$, $f(x)$, $-f'(x)$,
-where $x$ should be uniformly-spaced. Requirements for entries in the topology
+The format for the table files is three fixed-format columns of any suitable width. These columns must contain $x$, $f(x)$, $-f'(x)$,
+and the values of $x$ should be uniformly spaced. Requirements for entries in the topology
 are given in~\tabref{topfile2}. 
 The setup of the tables is as follows:
 \\{\bf bonds}:
index 782424df600a423c45856ff35feda0a4e24b246c..8d38968eaf2d3fddac5350f6daaebd6b98e80353 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2016, 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.
@@ -359,7 +359,7 @@ int fn2ftp(const char *fn)
     return i;
 }
 
-const char *opt2fn(const char *opt, int nfile, const t_filenm fnm[])
+const t_filenm *getFilenm(const char *opt, int nfile, const t_filenm fnm[])
 {
     int i;
 
@@ -367,10 +367,21 @@ const char *opt2fn(const char *opt, int nfile, const t_filenm fnm[])
     {
         if (strcmp(opt, fnm[i].opt) == 0)
         {
-            return fnm[i].fns[0];
+            return &fnm[i];
         }
     }
 
+    return NULL;
+}
+
+const char *opt2fn(const char *opt, int nfile, const t_filenm fnm[])
+{
+    const t_filenm *f = getFilenm(opt, nfile, fnm);
+    if (f != NULL)
+    {
+        return f->fns[0];
+    }
+
     fprintf(stderr, "No option %s\n", opt);
 
     return NULL;
index dbd2bf730b3d3c044736482b8a4e0ad28e57c7a0..1700eef32550b9ff55d20154adab2585df682609 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, 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.
@@ -137,6 +137,12 @@ int opt2fns(char **fns[], const char *opt, int nfile,
 /* Return the filenames belonging to cmd-line option opt, or NULL when
  * no such option. */
 
+/*! \brief
+ * Return a pointer to the t_filenm data structure of filenames belonging to
+ * command-line option opt, or NULL when no such option was used.
+ */
+const t_filenm *getFilenm(const char *opt, int nfile, const t_filenm fnm[]);
+
 #define opt2FILE(opt, nfile, fnm, mode) gmx_ffopen(opt2fn(opt, nfile, fnm), mode)
 /* Return a file pointer from the filename (see above) */
 
index 260cdc92999532942cfe310a0548a777266b4285..38385d833bdfa8c70d3697cd4949c2dd7dc3a20f 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, 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.
@@ -39,6 +39,7 @@
 #define _force_h
 
 
+#include "gromacs/fileio/filenm.h"
 #include "gromacs/legacyheaders/genborn.h"
 #include "gromacs/legacyheaders/network.h"
 #include "gromacs/legacyheaders/tgroup.h"
@@ -104,7 +105,7 @@ t_forcetable make_tables(FILE *fp, const output_env_t oenv,
  * to .xvg files
  */
 
-bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle);
+bondedtable_t make_bonded_table(FILE *fplog, const char *fn, int angle);
 /* Return a table for bonded interactions,
  * angle should be: bonds 0, angles 1, dihedrals 2
  */
@@ -177,7 +178,7 @@ void init_forcerec(FILE              *fplog,
                    const char        *tabfn,
                    const char        *tabafn,
                    const char        *tabpfn,
-                   const char        *tabbfn,
+                   const t_filenm    *tabbfnm,
                    const char        *nbpu_opt,
                    gmx_bool           bNoSolvOpt,
                    real               print_force);
index b019306d7c4cfbb031a2203b2ad6931af326050a..d5710ab84be444861abd26013fcb063f16a1c280 100644 (file)
@@ -47,6 +47,7 @@
 
 #include "gromacs/domdec/domdec.h"
 #include "gromacs/ewald/ewald.h"
+#include "gromacs/fileio/filenm.h"
 #include "gromacs/gmxlib/gpu_utils/gpu_utils.h"
 #include "gromacs/legacyheaders/copyrite.h"
 #include "gromacs/legacyheaders/force.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/simd/simd.h"
 #include "gromacs/topology/mtop_util.h"
+#include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/stringutil.h"
 
 #include "nbnxn_gpu_jit_support.h"
 
@@ -1339,6 +1342,19 @@ static void make_nbf_tables(FILE *fp, const output_env_t oenv,
     }
 }
 
+/*!\brief If there's bonded interactions of type \c ftype1 or \c
+ * ftype2 present in the topology, build an array of the number of
+ * interactions present for each bonded interaction index found in the
+ * topology.
+ *
+ * \c ftype1 or \c ftype2 may be set to -1 to disable seeking for a
+ * valid type with that parameter.
+ *
+ * \c count will be reallocated as necessary to fit the largest bonded
+ * interaction index found, and its current size will be returned in
+ * \c ncount. It will contain zero for every bonded interaction index
+ * for which no interactions are present in the topology.
+ */
 static void count_tables(int ftype1, int ftype2, const gmx_mtop_t *mtop,
                          int *ncount, int **count)
 {
@@ -1346,22 +1362,28 @@ static void count_tables(int ftype1, int ftype2, const gmx_mtop_t *mtop,
     const t_ilist       *il;
     int                  mt, ftype, stride, i, j, tabnr;
 
+    // Loop over all moleculetypes
     for (mt = 0; mt < mtop->nmoltype; mt++)
     {
         molt = &mtop->moltype[mt];
+        // Loop over all interaction types
         for (ftype = 0; ftype < F_NRE; ftype++)
         {
+            // If the current interaction type is one of the types whose tables we're trying to count...
             if (ftype == ftype1 || ftype == ftype2)
             {
                 il     = &molt->ilist[ftype];
                 stride = 1 + NRAL(ftype);
+                // ... and there are actually some interactions for this type
                 for (i = 0; i < il->nr; i += stride)
                 {
+                    // Find out which table index the user wanted
                     tabnr = mtop->ffparams.iparams[il->iatoms[i]].tab.table;
                     if (tabnr < 0)
                     {
                         gmx_fatal(FARGS, "A bonded table number is smaller than 0: %d\n", tabnr);
                     }
+                    // Make room for this index in the data structure
                     if (tabnr >= *ncount)
                     {
                         srenew(*count, tabnr+1);
@@ -1371,6 +1393,7 @@ static void count_tables(int ftype1, int ftype2, const gmx_mtop_t *mtop,
                         }
                         *ncount = tabnr+1;
                     }
+                    // Record that this table index is used and must have a valid file
                     (*count)[tabnr]++;
                 }
             }
@@ -1378,13 +1401,23 @@ static void count_tables(int ftype1, int ftype2, const gmx_mtop_t *mtop,
     }
 }
 
+/*!\brief If there's bonded interactions of flavour \c tabext and type
+ * \c ftype1 or \c ftype2 present in the topology, seek them in the
+ * list of filenames passed to mdrun, and make bonded tables from
+ * those files.
+ *
+ * \c ftype1 or \c ftype2 may be set to -1 to disable seeking for a
+ * valid type with that parameter.
+ *
+ * A fatal error occurs if no matching filename is found.
+ */
 static bondedtable_t *make_bonded_tables(FILE *fplog,
                                          int ftype1, int ftype2,
                                          const gmx_mtop_t *mtop,
-                                         const char *basefn, const char *tabext)
+                                         const t_filenm *tabbfnm,
+                                         const char *tabext)
 {
-    int            i, ncount, *count;
-    char           tabfn[STRLEN];
+    int            ncount, *count;
     bondedtable_t *tab;
 
     tab = NULL;
@@ -1393,17 +1426,41 @@ static bondedtable_t *make_bonded_tables(FILE *fplog,
     count  = NULL;
     count_tables(ftype1, ftype2, mtop, &ncount, &count);
 
+    // Are there any relevant tabulated bond interactions?
     if (ncount > 0)
     {
         snew(tab, ncount);
-        for (i = 0; i < ncount; i++)
+        for (int i = 0; i < ncount; i++)
         {
+            // Do any interactions exist that requires this table?
             if (count[i] > 0)
             {
-                sprintf(tabfn, "%s", basefn);
-                sprintf(tabfn + strlen(basefn) - strlen(ftp2ext(efXVG)) - 1, "_%s%d.%s",
-                        tabext, i, ftp2ext(efXVG));
-                tab[i] = make_bonded_table(fplog, tabfn, NRAL(ftype1)-2);
+                // This pattern enforces the current requirement that
+                // table filenames end in a characteristic sequence
+                // before the file type extension, and avoids table 13
+                // being recognized and used for table 1.
+                std::string patternToFind = gmx::formatString("_%s%d.%s", tabext, i, ftp2ext(efXVG));
+                bool        madeTable     = false;
+                for (int j = 0; j < tabbfnm->nfiles && !madeTable; ++j)
+                {
+                    std::string filename(tabbfnm->fns[j]);
+                    if (gmx::endsWith(filename, patternToFind))
+                    {
+                        // Finally read the table from the file found
+                        tab[i]    = make_bonded_table(fplog, tabbfnm->fns[j], NRAL(ftype1)-2);
+                        madeTable = true;
+                    }
+                }
+                if (!madeTable)
+                {
+                    bool isPlural = (ftype2 != -1);
+                    gmx_fatal(FARGS, "Tabulated interaction of type '%s%s%s' with index %d cannot be used because no table file whose name matched '%s' was passed via the gmx mdrun -tableb command-line option.",
+                              interaction_function[ftype1].longname,
+                              isPlural ? "' or '" : "",
+                              isPlural ? interaction_function[ftype2].longname : "",
+                              i,
+                              patternToFind.c_str());
+                }
             }
         }
         sfree(count);
@@ -2303,7 +2360,7 @@ void init_forcerec(FILE              *fp,
                    const char        *tabfn,
                    const char        *tabafn,
                    const char        *tabpfn,
-                   const char        *tabbfn,
+                   const t_filenm    *tabbfnm,
                    const char        *nbpu_opt,
                    gmx_bool           bNoSolvOpt,
                    real               print_force)
@@ -3159,17 +3216,23 @@ void init_forcerec(FILE              *fp,
         make_wall_tables(fp, oenv, ir, tabfn, &mtop->groups, fr);
     }
 
-    if (fcd && tabbfn)
+    if (fcd && tabbfnm)
     {
-        fcd->bondtab  = make_bonded_tables(fp,
-                                           F_TABBONDS, F_TABBONDSNC,
-                                           mtop, tabbfn, "b");
-        fcd->angletab = make_bonded_tables(fp,
-                                           F_TABANGLES, -1,
-                                           mtop, tabbfn, "a");
-        fcd->dihtab   = make_bonded_tables(fp,
-                                           F_TABDIHS, -1,
-                                           mtop, tabbfn, "d");
+        // Need to catch std::bad_alloc
+        // TODO Don't need to catch this here, when merging with master branch
+        try
+        {
+            fcd->bondtab  = make_bonded_tables(fp,
+                                               F_TABBONDS, F_TABBONDSNC,
+                                               mtop, tabbfnm, "b");
+            fcd->angletab = make_bonded_tables(fp,
+                                               F_TABANGLES, -1,
+                                               mtop, tabbfnm, "a");
+            fcd->dihtab   = make_bonded_tables(fp,
+                                               F_TABDIHS, -1,
+                                               mtop, tabbfnm, "d");
+        }
+        GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
     }
     else
     {
index ad8e473cf7cfd90f1824d07de242f0471556dc5f..5b6bfa3f4db8272b6383241349f1140e78673ed7 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, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, 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.
@@ -745,14 +745,17 @@ static void read_tables(FILE *fp, const char *fn,
                 {
                     /* Take the centered difference */
                     numf = -(vp - vm)*0.5*tabscale;
-                    ssd += fabs(2*(f - numf)/(f + numf));
+                    if (f + numf != 0)
+                    {
+                        ssd += fabs(2*(f - numf)/(f + numf));
+                    }
                     ns++;
                 }
             }
             if (ns > 0)
             {
                 ssd /= ns;
-                sprintf(buf, "For the %d non-zero entries for table %d in %s the forces deviate on average %d%% from minus the numerical derivative of the potential\n", ns, k, libfn, (int)(100*ssd+0.5));
+                sprintf(buf, "For the %d non-zero entries for table %d in %s the forces deviate on average %lld%% from minus the numerical derivative of the potential\n", ns, k, libfn, (long long int)(100*ssd+0.5));
                 if (debug)
                 {
                     fprintf(debug, "%s", buf);
@@ -1800,7 +1803,7 @@ t_forcetable make_atf_table(FILE *out, const output_env_t oenv,
     return table;
 }
 
-bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle)
+bondedtable_t make_bonded_table(FILE *fplog, const char *fn, int angle)
 {
     t_tabledata   td;
     double        start;
index e7e11a6d9ef5c9bf5d1d3a04a7a7dd22add7df77..b2b790e502c8afbde0c96056d3d084d6e588a33d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016, 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.
@@ -96,6 +96,31 @@ bool inline startsWith(const char *str, const char *prefix)
  */
 bool endsWith(const std::string &str, const char *suffix);
 
+//! \copydoc endsWith(const std::string &str, const char *suffix)
+static inline bool endsWith(const std::string &str, const std::string &suffix)
+{
+    return endsWith(str, suffix.c_str());
+}
+
+/*! \brief
+ * Tests whether a string contains another as a substring.
+ *
+ * \param[in] str    String to process.
+ * \param[in] substr Substring to find.
+ * \returns   true if \p str contains \p substr.
+ *
+ * Does not throw.
+ */
+static inline bool contains(const std::string &str, const char *substr)
+{
+    return str.find(substr) != std::string::npos;
+}
+//! \copydoc contains(const std::string &str, const char *substr)
+static inline bool contains(const std::string &str, const std::string &substr)
+{
+    return str.find(substr) != std::string::npos;
+}
+
 /*! \brief
  * Removes a suffix from a string.
  *
index 21e1c3a384c105319672bc3314836bbf055f8a42..fcdc36952adcd0d2e1ad0dcf25c5c997e1a2dd72 100644 (file)
@@ -134,10 +134,11 @@ int gmx_mdrun(int argc, char *argv[])
         "functions is read using the [TT]-tablep[tt] option.[PAR]",
         "When tabulated bonded functions are present in the topology,",
         "interaction functions are read using the [TT]-tableb[tt] option.",
-        "For each different tabulated interaction type the table file name is",
-        "modified in a different way: before the file extension an underscore is",
-        "appended, then a 'b' for bonds, an 'a' for angles or a 'd' for dihedrals",
-        "and finally the table number of the interaction type.[PAR]",
+        "For each different tabulated interaction type used, a table file name must",
+        "be given. For the topology to work, a file name given here must match a",
+        "character sequence before the file extension. That sequence is: an underscore,",
+        "then a 'b' for bonds, an 'a' for angles or a 'd' for dihedrals,",
+        "and finally the matching table number index used in the topology.[PAR]",
         "The options [TT]-px[tt] and [TT]-pf[tt] are used for writing pull COM",
         "coordinates and forces when pulling is selected",
         "in the [REF].mdp[ref] file.[PAR]",
@@ -239,7 +240,7 @@ int gmx_mdrun(int argc, char *argv[])
         { efXVG, "-table",  "table",    ffOPTRD },
         { efXVG, "-tabletf", "tabletf",    ffOPTRD },
         { efXVG, "-tablep", "tablep",   ffOPTRD },
-        { efXVG, "-tableb", "table",    ffOPTRD },
+        { efXVG, "-tableb", "table",    ffOPTRDMULT },
         { efTRX, "-rerun",  "rerun",    ffOPTRD },
         { efXVG, "-tpi",    "tpi",      ffOPTWR },
         { efXVG, "-tpid",   "tpidist",  ffOPTWR },
index ff2cd0c16243ee48be858880665e15ea6a1f14d0..7489b07dcbee6c6f730415ef166ed857afaffe4b 100644 (file)
@@ -1101,7 +1101,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt,
                       opt2fn("-table", nfile, fnm),
                       opt2fn("-tabletf", nfile, fnm),
                       opt2fn("-tablep", nfile, fnm),
-                      opt2fn("-tableb", nfile, fnm),
+                      getFilenm("-tableb", nfile, fnm),
                       nbpu_opt,
                       FALSE,
                       pforce);
index 5e47c91afe7343291cb8f99e181af95445ba4c06..22dc2532fc86f5bf7a036a6507117c733ce8fe91 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+# Copyright (c) 2013,2014,2015,2016, 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.
@@ -39,6 +39,7 @@ gmx_build_unit_test(
     ${testname}
     ${exename}
     # files with code for tests
+    tabulated_bonded_interactions.cpp
     grompp.cpp
     rerun.cpp
     trajectory_writing.cpp
diff --git a/src/programs/mdrun/tests/butane1.gro b/src/programs/mdrun/tests/butane1.gro
new file mode 100644 (file)
index 0000000..4a244a0
--- /dev/null
@@ -0,0 +1,7 @@
+A single butane
+  4
+    1BUT     C1    1   1.382   1.573   1.482
+    1BUT     C2    2   1.281   1.559   1.596
+    1BUT     C3    3   1.292   1.422   1.663
+    1BUT     C4    4   1.189   1.407   1.775
+   2.46298   2.46298   2.46298
diff --git a/src/programs/mdrun/tests/butane1.ndx b/src/programs/mdrun/tests/butane1.ndx
new file mode 100644 (file)
index 0000000..779e460
--- /dev/null
@@ -0,0 +1,2 @@
+[ System ]
+   1    2    3    4
diff --git a/src/programs/mdrun/tests/butane_a0.xvg b/src/programs/mdrun/tests/butane_a0.xvg
new file mode 100644 (file)
index 0000000..b31e3ba
--- /dev/null
@@ -0,0 +1,186 @@
+# Table was made with:
+#
+# seq 0 1 180 | awk '{print $1" "$1*3.14159265358979323846/180}' | awk '{printf "%20g %20g %20g\n", $1,
+#    0.5*460.2  *($1-111)^2,
+# -1*0.5*406.2*2*($1-111)}'
+                   0          2.83506e+06              45088.2
+                   1          2.78421e+06                44682
+                   2          2.73382e+06              44275.8
+                   3          2.68389e+06              43869.6
+                   4          2.63441e+06              43463.4
+                   5           2.5854e+06              43057.2
+                   6          2.53685e+06                42651
+                   7          2.48876e+06              42244.8
+                   8          2.44113e+06              41838.6
+                   9          2.39396e+06              41432.4
+                  10          2.34725e+06              41026.2
+                  11            2.301e+06                40620
+                  12          2.25521e+06              40213.8
+                  13          2.20988e+06              39807.6
+                  14          2.16501e+06              39401.4
+                  15           2.1206e+06              38995.2
+                  16          2.07665e+06                38589
+                  17          2.03316e+06              38182.8
+                  18          1.99013e+06              37776.6
+                  19          1.94757e+06              37370.4
+                  20          1.90546e+06              36964.2
+                  21          1.86381e+06                36558
+                  22          1.82262e+06              36151.8
+                  23          1.78189e+06              35745.6
+                  24          1.74163e+06              35339.4
+                  25          1.70182e+06              34933.2
+                  26          1.66247e+06                34527
+                  27          1.62359e+06              34120.8
+                  28          1.58516e+06              33714.6
+                  29          1.54719e+06              33308.4
+                  30          1.50969e+06              32902.2
+                  31          1.47264e+06                32496
+                  32          1.43605e+06              32089.8
+                  33          1.39993e+06              31683.6
+                  34          1.36426e+06              31277.4
+                  35          1.32906e+06              30871.2
+                  36          1.29431e+06                30465
+                  37          1.26003e+06              30058.8
+                  38           1.2262e+06              29652.6
+                  39          1.19284e+06              29246.4
+                  40          1.15993e+06              28840.2
+                  41          1.12749e+06                28434
+                  42          1.09551e+06              28027.8
+                  43          1.06398e+06              27621.6
+                  44          1.03292e+06              27215.4
+                  45          1.00232e+06              26809.2
+                  46               972172                26403
+                  47               942490              25996.8
+                  48               913267              25590.6
+                  49               884504              25184.4
+                  50               856202              24778.2
+                  51               828360                24372
+                  52               800978              23965.8
+                  53               774056              23559.6
+                  54               747595              23153.4
+                  55               721594              22747.2
+                  56               696052                22341
+                  57               670972              21934.8
+                  58               646351              21528.6
+                  59               622190              21122.4
+                  60               598490              20716.2
+                  61               575250                20310
+                  62               552470              19903.8
+                  63               530150              19497.6
+                  64               508291              19091.4
+                  65               486892              18685.2
+                  66               465952                18279
+                  67               445474              17872.8
+                  68               425455              17466.6
+                  69               405896              17060.4
+                  70               386798              16654.2
+                  71               368160                16248
+                  72               349982              15841.8
+                  73               332264              15435.6
+                  74               315007              15029.4
+                  75               298210              14623.2
+                  76               281872                14217
+                  77               265996              13810.8
+                  78               250579              13404.6
+                  79               235622              12998.4
+                  80               221126              12592.2
+                  81               207090                12186
+                  82               193514              11779.8
+                  83               180398              11373.6
+                  84               167743              10967.4
+                  85               155548              10561.2
+                  86               143812                10155
+                  87               132538               9748.8
+                  88               121723               9342.6
+                  89               111368               8936.4
+                  90               101474               8530.2
+                  91                92040                 8124
+                  92              83066.1               7717.8
+                  93              74552.4               7311.6
+                  94              66498.9               6905.4
+                  95              58905.6               6499.2
+                  96              51772.5                 6093
+                  97              45099.6               5686.8
+                  98              38886.9               5280.6
+                  99              33134.4               4874.4
+                 100              27842.1               4468.2
+                 101                23010                 4062
+                 102              18638.1               3655.8
+                 103              14726.4               3249.6
+                 104              11274.9               2843.4
+                 105               8283.6               2437.2
+                 106               5752.5                 2031
+                 107               3681.6               1624.8
+                 108               2070.9               1218.6
+                 109                920.4                812.4
+                 110                230.1                406.2
+                 111                    0                   -0
+                 112                230.1               -406.2
+                 113                920.4               -812.4
+                 114               2070.9              -1218.6
+                 115               3681.6              -1624.8
+                 116               5752.5                -2031
+                 117               8283.6              -2437.2
+                 118              11274.9              -2843.4
+                 119              14726.4              -3249.6
+                 120              18638.1              -3655.8
+                 121                23010                -4062
+                 122              27842.1              -4468.2
+                 123              33134.4              -4874.4
+                 124              38886.9              -5280.6
+                 125              45099.6              -5686.8
+                 126              51772.5                -6093
+                 127              58905.6              -6499.2
+                 128              66498.9              -6905.4
+                 129              74552.4              -7311.6
+                 130              83066.1              -7717.8
+                 131                92040                -8124
+                 132               101474              -8530.2
+                 133               111368              -8936.4
+                 134               121723              -9342.6
+                 135               132538              -9748.8
+                 136               143812               -10155
+                 137               155548             -10561.2
+                 138               167743             -10967.4
+                 139               180398             -11373.6
+                 140               193514             -11779.8
+                 141               207090               -12186
+                 142               221126             -12592.2
+                 143               235622             -12998.4
+                 144               250579             -13404.6
+                 145               265996             -13810.8
+                 146               281872               -14217
+                 147               298210             -14623.2
+                 148               315007             -15029.4
+                 149               332264             -15435.6
+                 150               349982             -15841.8
+                 151               368160               -16248
+                 152               386798             -16654.2
+                 153               405896             -17060.4
+                 154               425455             -17466.6
+                 155               445474             -17872.8
+                 156               465952               -18279
+                 157               486892             -18685.2
+                 158               508291             -19091.4
+                 159               530150             -19497.6
+                 160               552470             -19903.8
+                 161               575250               -20310
+                 162               598490             -20716.2
+                 163               622190             -21122.4
+                 164               646351             -21528.6
+                 165               670972             -21934.8
+                 166               696052               -22341
+                 167               721594             -22747.2
+                 168               747595             -23153.4
+                 169               774056             -23559.6
+                 170               800978             -23965.8
+                 171               828360               -24372
+                 172               856202             -24778.2
+                 173               884504             -25184.4
+                 174               913267             -25590.6
+                 175               942490             -25996.8
+                 176               972172               -26403
+                 177          1.00232e+06             -26809.2
+                 178          1.03292e+06             -27215.4
+                 179          1.06398e+06             -27621.6
+                 180          1.09551e+06             -28027.8
diff --git a/src/programs/mdrun/tests/butane_b0.xvg b/src/programs/mdrun/tests/butane_b0.xvg
new file mode 100644 (file)
index 0000000..2acfd98
--- /dev/null
@@ -0,0 +1,306 @@
+# Table was made with:
+#
+# seq 0 0.001 0.3 | awk '{print $1" "$1*atan2(0,-1)/180}' | awk '{printf "%20g %20g %20g\n", $1,
+#    0.5*334700  *($1-0.153)^2,
+#-1*(0.5*334700*2*($1-0.153))}'
+                   0               3917.5              51209.1
+               0.001              3866.45              50874.4
+               0.002              3815.75              50539.7
+               0.003              3765.38                50205
+               0.004              3715.34              49870.3
+               0.005              3665.63              49535.6
+               0.006              3616.27              49200.9
+               0.007              3567.23              48866.2
+               0.008              3518.53              48531.5
+               0.009              3470.17              48196.8
+                0.01              3422.14              47862.1
+               0.011              3374.45              47527.4
+               0.012              3327.09              47192.7
+               0.013              3280.06                46858
+               0.014              3233.37              46523.3
+               0.015              3187.01              46188.6
+               0.016              3140.99              45853.9
+               0.017              3095.31              45519.2
+               0.018              3049.95              45184.5
+               0.019              3004.94              44849.8
+                0.02              2960.25              44515.1
+               0.021              2915.91              44180.4
+               0.022              2871.89              43845.7
+               0.023              2828.22                43511
+               0.024              2784.87              43176.3
+               0.025              2741.86              42841.6
+               0.026              2699.19              42506.9
+               0.027              2656.85              42172.2
+               0.028              2614.84              41837.5
+               0.029              2573.17              41502.8
+                0.03              2531.84              41168.1
+               0.031              2490.84              40833.4
+               0.032              2450.17              40498.7
+               0.033              2409.84                40164
+               0.034              2369.84              39829.3
+               0.035              2330.18              39494.6
+               0.036              2290.85              39159.9
+               0.037              2251.86              38825.2
+               0.038               2213.2              38490.5
+               0.039              2174.88              38155.8
+                0.04              2136.89              37821.1
+               0.041              2099.24              37486.4
+               0.042              2061.92              37151.7
+               0.043              2024.93                36817
+               0.044              1988.29              36482.3
+               0.045              1951.97              36147.6
+               0.046              1915.99              35812.9
+               0.047              1880.34              35478.2
+               0.048              1845.03              35143.5
+               0.049              1810.06              34808.8
+                0.05              1775.42              34474.1
+               0.051              1741.11              34139.4
+               0.052              1707.14              33804.7
+               0.053               1673.5                33470
+               0.054               1640.2              33135.3
+               0.055              1607.23              32800.6
+               0.056               1574.6              32465.9
+               0.057               1542.3              32131.2
+               0.058              1510.33              31796.5
+               0.059               1478.7              31461.8
+                0.06              1447.41              31127.1
+               0.061              1416.45              30792.4
+               0.062              1385.83              30457.7
+               0.063              1355.53                30123
+               0.064              1325.58              29788.3
+               0.065              1295.96              29453.6
+               0.066              1266.67              29118.9
+               0.067              1237.72              28784.2
+               0.068               1209.1              28449.5
+               0.069              1180.82              28114.8
+                0.07              1152.87              27780.1
+               0.071              1125.26              27445.4
+               0.072              1097.98              27110.7
+               0.073              1071.04                26776
+               0.074              1044.43              26441.3
+               0.075              1018.16              26106.6
+               0.076              992.218              25771.9
+               0.077              966.614              25437.2
+               0.078              941.344              25102.5
+               0.079              916.409              24767.8
+                0.08              891.808              24433.1
+               0.081              867.542              24098.4
+               0.082              843.611              23763.7
+               0.083              820.015                23429
+               0.084              796.753              23094.3
+               0.085              773.826              22759.6
+               0.086              751.234              22424.9
+               0.087              728.977              22090.2
+               0.088              707.054              21755.5
+               0.089              685.466              21420.8
+                0.09              664.212              21086.1
+               0.091              643.293              20751.4
+               0.092              622.709              20416.7
+               0.093               602.46                20082
+               0.094              582.545              19747.3
+               0.095              562.965              19412.6
+               0.096               543.72              19077.9
+               0.097               524.81              18743.2
+               0.098              506.234              18408.5
+               0.099              487.993              18073.8
+                 0.1              470.086              17739.1
+               0.101              452.514              17404.4
+               0.102              435.277              17069.7
+               0.103              418.375                16735
+               0.104              401.807              16400.3
+               0.105              385.574              16065.6
+               0.106              369.676              15730.9
+               0.107              354.113              15396.2
+               0.108              338.884              15061.5
+               0.109               323.99              14726.8
+                0.11               309.43              14392.1
+               0.111              295.205              14057.4
+               0.112              281.315              13722.7
+               0.113               267.76                13388
+               0.114              254.539              13053.3
+               0.115              241.653              12718.6
+               0.116              229.102              12383.9
+               0.117              216.886              12049.2
+               0.118              205.004              11714.5
+               0.119              193.457              11379.8
+                0.12              182.244              11045.1
+               0.121              171.366              10710.4
+               0.122              160.823              10375.7
+               0.123              150.615                10041
+               0.124              140.741               9706.3
+               0.125              131.202               9371.6
+               0.126              121.998               9036.9
+               0.127              113.129               8702.2
+               0.128              104.594               8367.5
+               0.129              96.3936               8032.8
+                0.13              88.5281               7698.1
+               0.131              80.9974               7363.4
+               0.132              73.8013               7028.7
+               0.133                66.94                 6694
+               0.134              60.4133               6359.3
+               0.135              54.2214               6024.6
+               0.136              48.3641               5689.9
+               0.137              42.8416               5355.2
+               0.138              37.6537               5020.5
+               0.139              32.8006               4685.8
+                0.14              28.2821               4351.1
+               0.141              24.0984               4016.4
+               0.142              20.2494               3681.7
+               0.143               16.735                 3347
+               0.144              13.5554               3012.3
+               0.145              10.7104               2677.6
+               0.146              8.20015               2342.9
+               0.147               6.0246               2008.2
+               0.148              4.18375               1673.5
+               0.149               2.6776               1338.8
+                0.15              1.50615               1004.1
+               0.151               0.6694                669.4
+               0.152              0.16735                334.7
+               0.153                    0                   -0
+               0.154              0.16735               -334.7
+               0.155               0.6694               -669.4
+               0.156              1.50615              -1004.1
+               0.157               2.6776              -1338.8
+               0.158              4.18375              -1673.5
+               0.159               6.0246              -2008.2
+                0.16              8.20015              -2342.9
+               0.161              10.7104              -2677.6
+               0.162              13.5554              -3012.3
+               0.163               16.735                -3347
+               0.164              20.2494              -3681.7
+               0.165              24.0984              -4016.4
+               0.166              28.2822              -4351.1
+               0.167              32.8006              -4685.8
+               0.168              37.6538              -5020.5
+               0.169              42.8416              -5355.2
+                0.17              48.3642              -5689.9
+               0.171              54.2214              -6024.6
+               0.172              60.4133              -6359.3
+               0.173                66.94                -6694
+               0.174              73.8013              -7028.7
+               0.175              80.9974              -7363.4
+               0.176              88.5281              -7698.1
+               0.177              96.3936              -8032.8
+               0.178              104.594              -8367.5
+               0.179              113.129              -8702.2
+                0.18              121.998              -9036.9
+               0.181              131.202              -9371.6
+               0.182              140.741              -9706.3
+               0.183              150.615               -10041
+               0.184              160.823             -10375.7
+               0.185              171.366             -10710.4
+               0.186              182.244             -11045.1
+               0.187              193.457             -11379.8
+               0.188              205.004             -11714.5
+               0.189              216.886             -12049.2
+                0.19              229.102             -12383.9
+               0.191              241.653             -12718.6
+               0.192              254.539             -13053.3
+               0.193               267.76               -13388
+               0.194              281.315             -13722.7
+               0.195              295.205             -14057.4
+               0.196               309.43             -14392.1
+               0.197               323.99             -14726.8
+               0.198              338.884             -15061.5
+               0.199              354.113             -15396.2
+                 0.2              369.676             -15730.9
+               0.201              385.574             -16065.6
+               0.202              401.807             -16400.3
+               0.203              418.375               -16735
+               0.204              435.277             -17069.7
+               0.205              452.514             -17404.4
+               0.206              470.086             -17739.1
+               0.207              487.993             -18073.8
+               0.208              506.234             -18408.5
+               0.209               524.81             -18743.2
+                0.21               543.72             -19077.9
+               0.211              562.965             -19412.6
+               0.212              582.545             -19747.3
+               0.213               602.46               -20082
+               0.214              622.709             -20416.7
+               0.215              643.293             -20751.4
+               0.216              664.212             -21086.1
+               0.217              685.466             -21420.8
+               0.218              707.054             -21755.5
+               0.219              728.977             -22090.2
+                0.22              751.234             -22424.9
+               0.221              773.826             -22759.6
+               0.222              796.753             -23094.3
+               0.223              820.015               -23429
+               0.224              843.611             -23763.7
+               0.225              867.542             -24098.4
+               0.226              891.808             -24433.1
+               0.227              916.409             -24767.8
+               0.228              941.344             -25102.5
+               0.229              966.614             -25437.2
+                0.23              992.218             -25771.9
+               0.231              1018.16             -26106.6
+               0.232              1044.43             -26441.3
+               0.233              1071.04               -26776
+               0.234              1097.98             -27110.7
+               0.235              1125.26             -27445.4
+               0.236              1152.87             -27780.1
+               0.237              1180.82             -28114.8
+               0.238               1209.1             -28449.5
+               0.239              1237.72             -28784.2
+                0.24              1266.67             -29118.9
+               0.241              1295.96             -29453.6
+               0.242              1325.58             -29788.3
+               0.243              1355.53               -30123
+               0.244              1385.83             -30457.7
+               0.245              1416.45             -30792.4
+               0.246              1447.41             -31127.1
+               0.247               1478.7             -31461.8
+               0.248              1510.33             -31796.5
+               0.249               1542.3             -32131.2
+                0.25               1574.6             -32465.9
+               0.251              1607.23             -32800.6
+               0.252               1640.2             -33135.3
+               0.253               1673.5               -33470
+               0.254              1707.14             -33804.7
+               0.255              1741.11             -34139.4
+               0.256              1775.42             -34474.1
+               0.257              1810.06             -34808.8
+               0.258              1845.03             -35143.5
+               0.259              1880.34             -35478.2
+                0.26              1915.99             -35812.9
+               0.261              1951.97             -36147.6
+               0.262              1988.29             -36482.3
+               0.263              2024.94               -36817
+               0.264              2061.92             -37151.7
+               0.265              2099.24             -37486.4
+               0.266              2136.89             -37821.1
+               0.267              2174.88             -38155.8
+               0.268               2213.2             -38490.5
+               0.269              2251.86             -38825.2
+                0.27              2290.85             -39159.9
+               0.271              2330.18             -39494.6
+               0.272              2369.84             -39829.3
+               0.273              2409.84               -40164
+               0.274              2450.17             -40498.7
+               0.275              2490.84             -40833.4
+               0.276              2531.84             -41168.1
+               0.277              2573.17             -41502.8
+               0.278              2614.84             -41837.5
+               0.279              2656.85             -42172.2
+                0.28              2699.19             -42506.9
+               0.281              2741.86             -42841.6
+               0.282              2784.87             -43176.3
+               0.283              2828.21               -43511
+               0.284              2871.89             -43845.7
+               0.285              2915.91             -44180.4
+               0.286              2960.25             -44515.1
+               0.287              3004.94             -44849.8
+               0.288              3049.95             -45184.5
+               0.289              3095.31             -45519.2
+                0.29              3140.99             -45853.9
+               0.291              3187.01             -46188.6
+               0.292              3233.37             -46523.3
+               0.293              3280.06               -46858
+               0.294              3327.09             -47192.7
+               0.295              3374.45             -47527.4
+               0.296              3422.14             -47862.1
+               0.297              3470.17             -48196.8
+               0.298              3518.53             -48531.5
+               0.299              3567.23             -48866.2
+                 0.3              3616.27             -49200.9
diff --git a/src/programs/mdrun/tests/butane_d0.xvg b/src/programs/mdrun/tests/butane_d0.xvg
new file mode 100644 (file)
index 0000000..d814ecc
--- /dev/null
@@ -0,0 +1,366 @@
+# Table was made with:
+#
+# seq -180 1 180 | awk '{print $1" "$1*3.14159265358979323846/180}' | awk '{printf "%20g %20g %20g\n", $1,
+#     9.2789 -12.156*cos($2) -13.12  *cos($2)^2       +3.0597          *cos($2)^3 +26.24          *cos($2)^4 +31.495          *cos($2)^5,
+# -1*(0.0    +12.156*sin($2) +13.12*2*sin($2)*cos($2) -3.0597*3*sin($2)*cos($2)^2 -26.24*4*sin($2)*cos($2)^3 -31.495*5*sin($2)*cos($2)^4)*3.14159265358979323846/180}'
+                -180               0.0002         -3.50958e-06
+                -179            0.0117364           -0.0230646
+                -178            0.0462849           -0.0460188
+                -177             0.103725           -0.0687729
+                -176             0.183725           -0.0911958
+                -175             0.285942            -0.113198
+                -174             0.409982            -0.134691
+                -173             0.555133            -0.155555
+                -172             0.720796            -0.175708
+                -171             0.906328            -0.195073
+                -170              1.11068            -0.213546
+                -169              1.33302             -0.23106
+                -168              1.57251            -0.247553
+                -167               1.8278            -0.262942
+                -166              2.09791            -0.277178
+                -165              2.38182            -0.290217
+                -164              2.67798            -0.302002
+                -163              2.98528            -0.312505
+                -162              3.30261            -0.321703
+                -161               3.6283            -0.329565
+                -160              3.96117            -0.336087
+                -159              4.30009            -0.341266
+                -158              4.64332              -0.3451
+                -157              4.98972            -0.347605
+                -156              5.33816            -0.348799
+                -155              5.68696            -0.348709
+                -154              6.03503            -0.347368
+                -153              6.38136            -0.344815
+                -152              6.72434            -0.341099
+                -151              7.06305            -0.336269
+                -150              7.39659            -0.330381
+                -149              7.72355            -0.323501
+                -148              8.04316            -0.315694
+                -147              8.35471            -0.307022
+                -146              8.65701             -0.29757
+                -145               8.9495            -0.287406
+                -144              9.23166              -0.2766
+                -143              9.50258            -0.265244
+                -142              9.76189            -0.253409
+                -141              10.0093            -0.241165
+                -140              10.2442            -0.228604
+                -139              10.4663            -0.215795
+                -138              10.6757            -0.202803
+                -137               10.872            -0.189716
+                -136              11.0551            -0.176593
+                -135              11.2252            -0.163492
+                -134              11.3821            -0.150489
+                -133              11.5262            -0.137633
+                -132              11.6575            -0.124966
+                -131              11.7762            -0.112551
+                -130              11.8826            -0.100421
+                -129              11.9772            -0.088605
+                -128                12.06           -0.0771457
+                -127              12.1315           -0.0660604
+                -126              12.1922           -0.0553611
+                -125              12.2424           -0.0450721
+                -124              12.2825           -0.0351936
+                -123              12.3129           -0.0257211
+                -122              12.3341           -0.0166606
+                -121              12.3464           -0.0079967
+                -120              12.3502          0.000285479
+                -119              12.3459            0.0082098
+                -118              12.3339            0.0157908
+                -117              12.3145            0.0230605
+                -116              12.2879            0.0300535
+                -115              12.2544            0.0367953
+                -114              12.2144            0.0433255
+                -113              12.1678            0.0496852
+                -112               12.115            0.0559055
+                -111              12.0561            0.0620291
+                -110               11.991            0.0680983
+                -109              11.9199            0.0741442
+                -108              11.8427            0.0802072
+                -107              11.7594            0.0863256
+                -106                11.67            0.0925247
+                -105              11.5744            0.0988373
+                -104              11.4723             0.105293
+                -103              11.3637             0.111905
+                -102              11.2485             0.118694
+                -101              11.1262             0.125676
+                -100               10.997             0.132848
+                 -99              10.8605             0.140216
+                 -98              10.7165             0.147777
+                 -97              10.5649             0.155511
+                 -96              10.4055             0.163403
+                 -95               10.238             0.171431
+                 -94              10.0626             0.179554
+                 -93              9.87895             0.187737
+                 -92              9.68703              0.19594
+                 -91              9.48705             0.204099
+                 -90              9.27894             0.212161
+                 -89              9.06273             0.220064
+                 -88              8.83886             0.227729
+                 -87              8.60746             0.235085
+                 -86              8.36877             0.242053
+                 -85              8.12347              0.24854
+                 -84              7.87197              0.25446
+                 -83              7.61472             0.259724
+                 -82              7.35273             0.264231
+                 -81              7.08664             0.267886
+                 -80              6.81722             0.270593
+                 -79              6.54575              0.27225
+                 -78               6.2732             0.272762
+                 -77              6.00059             0.272031
+                 -76              5.72953             0.269964
+                 -75              5.46124              0.26647
+                 -74              5.19705             0.261459
+                 -73               4.9388             0.254855
+                 -72              4.68799             0.246579
+                 -71              4.44618             0.236556
+                 -70              4.21543             0.224734
+                 -69              3.99742             0.211054
+                 -68              3.79392             0.195462
+                 -67              3.60709              0.17794
+                 -66              3.43876             0.158455
+                 -65              3.29082             0.136979
+                 -64              3.16543             0.113534
+                 -63              3.06446            0.0881168
+                 -62              2.98984            0.0607332
+                 -61               2.9436            0.0314479
+                 -60              2.92758          0.000292252
+                 -59              2.94364           -0.0326936
+                 -58              2.99354           -0.0673993
+                 -57              3.07898            -0.103762
+                 -56              3.20158            -0.141684
+                 -55              3.36283            -0.181048
+                 -54              3.56411            -0.221732
+                 -53              3.80668            -0.263602
+                 -52              4.09167            -0.306512
+                 -51                 4.42              -0.3503
+                 -50              4.79249            -0.394799
+                 -49              5.20979            -0.439836
+                 -48              5.67229            -0.485217
+                 -47              6.18026            -0.530751
+                 -46              6.73379             -0.57624
+                 -45              7.33267            -0.621471
+                 -44              7.97655            -0.666233
+                 -43              8.66488            -0.710312
+                 -42               9.3969            -0.753491
+                 -41              10.1715            -0.795545
+                 -40              10.9875            -0.836257
+                 -39              11.8435             -0.87541
+                 -38              12.7378            -0.912784
+                 -37              13.6684            -0.948167
+                 -36              14.6333            -0.981352
+                 -35              15.6303             -1.01214
+                 -34              16.6568             -1.04033
+                 -33                17.71             -1.06575
+                 -32              18.7873             -1.08821
+                 -31              19.8854             -1.10755
+                 -30              21.0013             -1.12362
+                 -29              22.1315             -1.13628
+                 -28              23.2727              -1.1454
+                 -27              24.4211             -1.15088
+                 -26              25.5732             -1.15263
+                 -25              26.7251             -1.15055
+                 -24               27.873             -1.14461
+                 -23               29.013             -1.13474
+                 -22              30.1412             -1.12093
+                 -21              31.2536             -1.10317
+                 -20              32.3462             -1.08149
+                 -19              33.4152             -1.05589
+                 -18              34.4567             -1.02645
+                 -17              35.4669            -0.993229
+                 -16              36.4419            -0.956317
+                 -15              37.3783            -0.915818
+                 -14              38.2724            -0.871864
+                 -13              39.1209            -0.824594
+                 -12              39.9205            -0.774168
+                 -11              40.6683            -0.720759
+                 -10              41.3611            -0.664564
+                  -9              41.9965            -0.605784
+                  -8              42.5719            -0.544635
+                  -7              43.0851            -0.481355
+                  -6               43.534            -0.416182
+                  -5              43.9169            -0.349366
+                  -4              44.2323            -0.281169
+                  -3              44.4789            -0.211859
+                  -2              44.6557            -0.141708
+                  -1              44.7621           -0.0709953
+                   0              44.7976                   -0
+                   1              44.7621            0.0709953
+                   2              44.6557             0.141708
+                   3              44.4789             0.211859
+                   4              44.2323             0.281169
+                   5              43.9169             0.349366
+                   6               43.534             0.416182
+                   7              43.0851             0.481355
+                   8              42.5719             0.544635
+                   9              41.9965             0.605784
+                  10              41.3611             0.664564
+                  11              40.6683             0.720759
+                  12              39.9205             0.774168
+                  13              39.1209             0.824594
+                  14              38.2724             0.871864
+                  15              37.3783             0.915818
+                  16              36.4419             0.956317
+                  17              35.4669             0.993229
+                  18              34.4567              1.02645
+                  19              33.4152              1.05589
+                  20              32.3462              1.08149
+                  21              31.2536              1.10317
+                  22              30.1412              1.12093
+                  23               29.013              1.13474
+                  24               27.873              1.14461
+                  25              26.7251              1.15055
+                  26              25.5732              1.15263
+                  27              24.4211              1.15088
+                  28              23.2727               1.1454
+                  29              22.1315              1.13628
+                  30              21.0013              1.12362
+                  31              19.8854              1.10755
+                  32              18.7873              1.08821
+                  33                17.71              1.06575
+                  34              16.6568              1.04033
+                  35              15.6303              1.01214
+                  36              14.6333             0.981352
+                  37              13.6684             0.948167
+                  38              12.7378             0.912784
+                  39              11.8435              0.87541
+                  40              10.9875             0.836257
+                  41              10.1715             0.795545
+                  42               9.3969             0.753491
+                  43              8.66488             0.710312
+                  44              7.97655             0.666233
+                  45              7.33267             0.621471
+                  46              6.73379              0.57624
+                  47              6.18026             0.530751
+                  48              5.67229             0.485217
+                  49              5.20979             0.439836
+                  50              4.79249             0.394799
+                  51                 4.42               0.3503
+                  52              4.09167             0.306512
+                  53              3.80668             0.263602
+                  54              3.56411             0.221732
+                  55              3.36283             0.181048
+                  56              3.20158             0.141684
+                  57              3.07898             0.103762
+                  58              2.99354            0.0673993
+                  59              2.94364            0.0326936
+                  60              2.92758         -0.000292252
+                  61               2.9436           -0.0314479
+                  62              2.98984           -0.0607332
+                  63              3.06446           -0.0881168
+                  64              3.16543            -0.113534
+                  65              3.29082            -0.136979
+                  66              3.43876            -0.158455
+                  67              3.60709             -0.17794
+                  68              3.79392            -0.195462
+                  69              3.99742            -0.211054
+                  70              4.21543            -0.224734
+                  71              4.44618            -0.236556
+                  72              4.68799            -0.246579
+                  73               4.9388            -0.254855
+                  74              5.19705            -0.261459
+                  75              5.46124             -0.26647
+                  76              5.72953            -0.269964
+                  77              6.00059            -0.272031
+                  78               6.2732            -0.272762
+                  79              6.54575             -0.27225
+                  80              6.81722            -0.270593
+                  81              7.08664            -0.267886
+                  82              7.35273            -0.264231
+                  83              7.61472            -0.259724
+                  84              7.87197             -0.25446
+                  85              8.12347             -0.24854
+                  86              8.36877            -0.242053
+                  87              8.60746            -0.235085
+                  88              8.83886            -0.227729
+                  89              9.06273            -0.220064
+                  90              9.27894            -0.212161
+                  91              9.48705            -0.204099
+                  92              9.68703             -0.19594
+                  93              9.87895            -0.187737
+                  94              10.0626            -0.179554
+                  95               10.238            -0.171431
+                  96              10.4055            -0.163403
+                  97              10.5649            -0.155511
+                  98              10.7165            -0.147777
+                  99              10.8605            -0.140216
+                 100               10.997            -0.132848
+                 101              11.1262            -0.125676
+                 102              11.2485            -0.118694
+                 103              11.3637            -0.111905
+                 104              11.4723            -0.105293
+                 105              11.5744           -0.0988373
+                 106                11.67           -0.0925247
+                 107              11.7594           -0.0863256
+                 108              11.8427           -0.0802072
+                 109              11.9199           -0.0741442
+                 110               11.991           -0.0680983
+                 111              12.0561           -0.0620291
+                 112               12.115           -0.0559055
+                 113              12.1678           -0.0496852
+                 114              12.2144           -0.0433255
+                 115              12.2544           -0.0367953
+                 116              12.2879           -0.0300535
+                 117              12.3145           -0.0230605
+                 118              12.3339           -0.0157908
+                 119              12.3459           -0.0082098
+                 120              12.3502         -0.000285479
+                 121              12.3464            0.0079967
+                 122              12.3341            0.0166606
+                 123              12.3129            0.0257211
+                 124              12.2825            0.0351936
+                 125              12.2424            0.0450721
+                 126              12.1922            0.0553611
+                 127              12.1315            0.0660604
+                 128                12.06            0.0771457
+                 129              11.9772             0.088605
+                 130              11.8826             0.100421
+                 131              11.7762             0.112551
+                 132              11.6575             0.124966
+                 133              11.5262             0.137633
+                 134              11.3821             0.150489
+                 135              11.2252             0.163492
+                 136              11.0551             0.176593
+                 137               10.872             0.189716
+                 138              10.6757             0.202803
+                 139              10.4663             0.215795
+                 140              10.2442             0.228604
+                 141              10.0093             0.241165
+                 142              9.76189             0.253409
+                 143              9.50258             0.265244
+                 144              9.23166               0.2766
+                 145               8.9495             0.287406
+                 146              8.65701              0.29757
+                 147              8.35471             0.307022
+                 148              8.04316             0.315694
+                 149              7.72355             0.323501
+                 150              7.39659             0.330381
+                 151              7.06305             0.336269
+                 152              6.72434             0.341099
+                 153              6.38136             0.344815
+                 154              6.03503             0.347368
+                 155              5.68696             0.348709
+                 156              5.33816             0.348799
+                 157              4.98972             0.347605
+                 158              4.64332               0.3451
+                 159              4.30009             0.341266
+                 160              3.96117             0.336087
+                 161               3.6283             0.329565
+                 162              3.30261             0.321703
+                 163              2.98528             0.312505
+                 164              2.67798             0.302002
+                 165              2.38182             0.290217
+                 166              2.09791             0.277178
+                 167               1.8278             0.262942
+                 168              1.57251             0.247553
+                 169              1.33302              0.23106
+                 170              1.11068             0.213546
+                 171             0.906328             0.195073
+                 172             0.720796             0.175708
+                 173             0.555133             0.155555
+                 174             0.409982             0.134691
+                 175             0.285942             0.113198
+                 176             0.183725            0.0911958
+                 177             0.103725            0.0687729
+                 178            0.0462849            0.0460188
+                 179            0.0117364            0.0230646
+                 180               0.0002          3.50958e-06
diff --git a/src/programs/mdrun/tests/tabulated_bonded_interactions.cpp b/src/programs/mdrun/tests/tabulated_bonded_interactions.cpp
new file mode 100644 (file)
index 0000000..9a7f331
--- /dev/null
@@ -0,0 +1,209 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2016, 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+
+/*! \internal \file
+ * \brief
+ * Tests for tabulated bonded interactions
+ *
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ * \ingroup module_mdrun_integration_tests
+ */
+#include "gmxpre.h"
+
+#include <gtest/gtest.h>
+
+#include "gromacs/utility/file.h"
+#include "gromacs/utility/stringutil.h"
+
+#include "testutils/cmdlinetest.h"
+
+#include "moduletest.h"
+
+namespace gmx
+{
+namespace test
+{
+
+//! Format string for building a configurable .top file
+const char *g_butaneTopFileFormatString = "\
+[ defaults ]\n\
+; nbfunc       comb-rule       gen-pairs       fudgeLJ fudgeQQ\n\
+  1            1               no              1.0     1.0\n\
+\n\
+[ atomtypes ]\n\
+;name        mass      charge   ptype            c6           c12\n\
+  CH2    14.02700       0.000       A   0.90975E-02   0.35333E-04\n\
+  CH3    15.03500       0.000       A   0.88765E-02   0.26150E-04\n\
+\n\
+[ moleculetype ]\n\
+;             name    nrexcl\n\
+            butane   3\n\
+\n\
+[ atoms ]\n\
+;   nr    type   resnr  residu    atom    cgnr\n\
+     1     CH3       1     BUT      C1       1\n\
+     2     CH2       1     BUT      C2       2\n\
+     3     CH2       1     BUT      C3       3\n\
+     4     CH3       1     BUT      C4       4\n\
+\n\
+%s\n\
+\n\
+[ system ]\n\
+; The name of the system to be simulated\n\
+A single butane\n\
+\n\
+[ molecules ]\n\
+; Molname             Number\n\
+Butane                   1\n\
+";
+
+//! Test fixture for bonded interactions
+class BondedInteractionsTest : public gmx::test::MdrunTestFixture
+{
+    public:
+        //! Execute the trajectory writing test
+        void setupGrompp(const char *interaction)
+        {
+            runner_.topFileName_ = fileManager_.getTemporaryFilePath("butane1.top");
+            File::writeFileFromString(runner_.topFileName_, formatString(g_butaneTopFileFormatString, interaction));
+            runner_.groFileName_ = fileManager_.getInputFilePath("butane1.gro");
+            runner_.ndxFileName_ = fileManager_.getInputFilePath("butane1.ndx");
+            /* TODO Now that Verlet is the default, change the implementation
+               of useEmptyMdpFile() to do that. */
+            runner_.useStringAsMdpFile("");
+        }
+        //! Prepare an mdrun caller
+        CommandLine setupMdrun()
+        {
+            CommandLine rerunCaller;
+            rerunCaller.append("mdrun");
+            rerunCaller.addOption("-rerun", runner_.groFileName_);
+            return rerunCaller;
+        }
+        //! Check the output of mdrun
+        void checkMdrun()
+        {
+            // TODO verifying some energies and forces would be good,
+            // once other code in gerrit is reviewed
+        }
+};
+
+// This test ensures that a normal non-tabulated bond interaction works
+TEST_F(BondedInteractionsTest, NormalBondWorks)
+{
+    setupGrompp("[ bonds ]\n\
+;  ai    aj funct           c0           c1\n\
+    1     2     1 1.530000e-01 3.347000e+05");
+    EXPECT_EQ(0, runner_.callGrompp());
+
+    test::CommandLine rerunCaller = setupMdrun();
+    ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
+    checkMdrun();
+}
+
+// This test ensures that a normal abulated bond interaction works
+TEST_F(BondedInteractionsTest, TabulatedBondWorks)
+{
+    setupGrompp("[ bonds ]\n\
+;  ai    aj funct  n     k\n\
+    1     2     8  0  1000");
+    EXPECT_EQ(0, runner_.callGrompp());
+
+    test::CommandLine rerunCaller   = setupMdrun();
+    std::string       tableFileName = fileManager_.getInputFilePath("butane_b0.xvg");
+    rerunCaller.addOption("-tableb", tableFileName);
+    ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
+    checkMdrun();
+}
+
+// This test ensures that a normal non-tabulated angle interaction works
+TEST_F(BondedInteractionsTest, NormalAngleWorks)
+{
+    setupGrompp("[ angles ]\n\
+;  ai    aj    ak funct           c0           c1\n\
+    1     2     3     1 1.110000e+02 4.602000e+02");
+    EXPECT_EQ(0, runner_.callGrompp());
+
+    test::CommandLine rerunCaller = setupMdrun();
+    ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
+    checkMdrun();
+}
+
+// This test ensures that a tabulated angle interaction works
+TEST_F(BondedInteractionsTest, TabulatedAngleWorks)
+{
+    setupGrompp("[ angles ]\n\
+;  ai    aj    ak funct  n     k\n\
+    1     2     3     8  0  1000");
+    EXPECT_EQ(0, runner_.callGrompp());
+
+    test::CommandLine rerunCaller   = setupMdrun();
+    std::string       tableFileName = fileManager_.getInputFilePath("butane_a0.xvg");
+    rerunCaller.addOption("-tableb", tableFileName);
+    ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
+    checkMdrun();
+}
+
+// This test ensures that a normal non-tabulated dihedral interaction works
+TEST_F(BondedInteractionsTest, NormalDihedralWorks)
+{
+    setupGrompp("[ dihedrals ]\n \
+;  ai    aj    ak    al funct     c0     c1     c2      c3     c4      c5\n\
+    1     2     3     4     3 9.2789 12.156 -13.12 -3.0597  26.24 -31.495");
+    EXPECT_EQ(0, runner_.callGrompp());
+
+    test::CommandLine rerunCaller = setupMdrun();
+    ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
+    checkMdrun();
+}
+
+// This test ensures that a tabulated dihedral interaction works
+TEST_F(BondedInteractionsTest, TabulatedDihedralWorks)
+{
+    setupGrompp("[ dihedrals ]\n\
+;  ai    aj    ak    al funct   n     k\n\
+    1     2     3     4     8   0  1000");
+    EXPECT_EQ(0, runner_.callGrompp());
+
+    test::CommandLine rerunCaller   = setupMdrun();
+    std::string       tableFileName = fileManager_.getInputFilePath("butane_d0.xvg");
+    rerunCaller.addOption("-tableb", tableFileName);
+    ASSERT_EQ(0, runner_.callMdrun(rerunCaller));
+    checkMdrun();
+}
+
+} // namespace
+
+} // namespace