Intermolecular bonded interaction support added
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / convparm.c
index e3bac959634c99ccff527314da7705448b8453cc..93f1603c8e9ea4c9253656b953d0c6485e94eb10 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,2015, 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.
@@ -567,7 +567,8 @@ static void enter_function(t_params *p, t_functype ftype, int comb, real reppow,
 }
 
 void convert_params(int atnr, t_params nbtypes[],
-                    t_molinfo *mi, int comb, double reppow, real fudgeQQ,
+                    t_molinfo *mi, t_molinfo *intermolecular_interactions,
+                    int comb, double reppow, real fudgeQQ,
                     gmx_mtop_t *mtop)
 {
     int             i, j, maxtypes, mt;
@@ -611,6 +612,57 @@ void convert_params(int atnr, t_params nbtypes[],
             }
         }
     }
+
+    mtop->bIntermolecularInteractions = FALSE;
+    if (intermolecular_interactions != NULL)
+    {
+        /* Process the intermolecular interaction list */
+        snew(mtop->intermolecular_ilist, F_NRE);
+
+        for (i = 0; (i < F_NRE); i++)
+        {
+            mtop->intermolecular_ilist[i].nr     = 0;
+            mtop->intermolecular_ilist[i].iatoms = NULL;
+
+            plist = intermolecular_interactions->plist;
+
+            if (plist[i].nr > 0)
+            {
+                flags = interaction_function[i].flags;
+                /* For intermolecular interactions we (currently)
+                 * only support potentials.
+                 * Constraints and virtual sites would be possible,
+                 * but require a lot of extra (bug-prone) code.
+                 */
+                if (!(flags & IF_BOND))
+                {
+                    gmx_fatal(FARGS, "The intermolecular_interaction section may only contain bonded potentials");
+                }
+                else if (NRAL(i) == 1) /* e.g. position restraints */
+                {
+                    gmx_fatal(FARGS, "Single atom interactions don't make sense in the intermolecular_interaction section, you can put them in the moleculetype section");
+                }
+                else if (flags & IF_CHEMBOND)
+                {
+                    gmx_fatal(FARGS, "The intermolecular_interaction can not contain chemically bonding interactions");
+                }
+                else
+                {
+                    enter_function(&(plist[i]), (t_functype)i, comb, reppow,
+                                   ffp, &mtop->intermolecular_ilist[i],
+                                   &maxtypes, FALSE, FALSE);
+
+                    mtop->bIntermolecularInteractions = TRUE;
+                }
+            }
+        }
+
+        if (!mtop->bIntermolecularInteractions)
+        {
+            sfree(mtop->intermolecular_ilist);
+        }
+    }
+
     if (debug)
     {
         fprintf(debug, "%s, line %d: There are %d functypes in idef\n",