Move gmx_ffparams_t to forcefieldparameters
authorMagnus Lundborg <lundborg.magnus@gmail.com>
Mon, 15 Oct 2018 12:55:59 +0000 (14:55 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 16 Oct 2018 08:15:35 +0000 (10:15 +0200)
Change-Id: I4639211f419724bcf3282140c8291e0b1272abe5

src/gromacs/topology/CMakeLists.txt
src/gromacs/topology/forcefieldparameters.cpp [new file with mode: 0644]
src/gromacs/topology/forcefieldparameters.h [new file with mode: 0644]
src/gromacs/topology/idef.cpp
src/gromacs/topology/idef.h
src/gromacs/topology/topology.h

index 4c08f48425a0a644d25036816ea74bb60462d84a..14ac3201f0004ef315b891081615d95e142428ed 100644 (file)
@@ -39,6 +39,7 @@ gmx_install_headers(
     atomprop.h
     atoms.h
     block.h
+    forcefieldparameters.h
     idef.h
     ifunc.h
     index.h
diff --git a/src/gromacs/topology/forcefieldparameters.cpp b/src/gromacs/topology/forcefieldparameters.cpp
new file mode 100644 (file)
index 0000000..18dfcd2
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014,2015,2016,2018, 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.
+ */
+#include "gmxpre.h"
+
+#include "forcefieldparameters.h"
+
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/txtdump.h"
+
+static void pr_cmap(FILE *fp, int indent, const char *title,
+                    const gmx_cmap_t *cmap_grid, gmx_bool bShowNumbers)
+{
+    int  i, j, nelem;
+    real dx, idx;
+
+    dx    = 360.0 / cmap_grid->grid_spacing;
+    nelem = cmap_grid->grid_spacing*cmap_grid->grid_spacing;
+
+    if (available(fp, cmap_grid, indent, title))
+    {
+        fprintf(fp, "%s\n", title);
+
+        for (i = 0; i < static_cast<int>(cmap_grid->cmapdata.size()); i++)
+        {
+            idx = -180.0;
+            fprintf(fp, "%8s %8s %8s %8s\n", "V", "dVdx", "dVdy", "d2dV");
+
+            fprintf(fp, "grid[%3d]={\n", bShowNumbers ? i : -1);
+
+            for (j = 0; j < nelem; j++)
+            {
+                if ( (j%cmap_grid->grid_spacing) == 0)
+                {
+                    fprintf(fp, "%8.1f\n", idx);
+                    idx += dx;
+                }
+
+                fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4]);
+                fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+1]);
+                fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+2]);
+                fprintf(fp, "%8.3f\n", cmap_grid->cmapdata[i].cmap[j*4+3]);
+            }
+            fprintf(fp, "\n");
+        }
+    }
+
+}
+
+void pr_ffparams(FILE *fp, int indent, const char *title,
+                 const gmx_ffparams_t *ffparams,
+                 gmx_bool bShowNumbers)
+{
+    int i;
+
+    indent = pr_title(fp, indent, title);
+    pr_indent(fp, indent);
+    fprintf(fp, "atnr=%d\n", ffparams->atnr);
+    pr_indent(fp, indent);
+    fprintf(fp, "ntypes=%d\n", ffparams->numTypes());
+    for (i = 0; i < ffparams->numTypes(); i++)
+    {
+        pr_indent(fp, indent+INDENT);
+        fprintf(fp, "functype[%d]=%s, ",
+                bShowNumbers ? i : -1,
+                interaction_function[ffparams->functype[i]].name);
+        pr_iparams(fp, ffparams->functype[i], &ffparams->iparams[i]);
+    }
+    pr_double(fp, indent, "reppow", ffparams->reppow);
+    pr_real(fp, indent, "fudgeQQ", ffparams->fudgeQQ);
+    pr_cmap(fp, indent, "cmap", &ffparams->cmap_grid, bShowNumbers);
+}
diff --git a/src/gromacs/topology/forcefieldparameters.h b/src/gromacs/topology/forcefieldparameters.h
new file mode 100644 (file)
index 0000000..3f144d1
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014,2015,2016,2018, 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.
+ */
+#ifndef GMX_TOPOLOGY_FORCEFIELDPARAMETERS_H
+#define GMX_TOPOLOGY_FORCEFIELDPARAMETERS_H
+
+#include <cstdio>
+
+#include <vector>
+
+#include "gromacs/topology/idef.h"
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/gmxassert.h"
+#include "gromacs/utility/real.h"
+
+/*! \brief Struct that holds all force field parameters for the simulated system */
+struct gmx_ffparams_t
+{
+    /*! \brief Returns the number of function types, which matches the number of elements in iparams */
+    int numTypes() const
+    {
+        GMX_ASSERT(iparams.size() == functype.size(), "Parameters and function types go together");
+
+        return functype.size();
+    }
+
+    /* TODO: Consider merging functype and iparams, either by storing
+     *       the functype in t_iparams or by putting both in a single class.
+     */
+    int                     atnr = 0;    /**< The number of non-bonded atom types */
+    std::vector<t_functype> functype;    /**< The function type per type */
+    std::vector<t_iparams>  iparams;     /**< Force field parameters per type */
+    double                  reppow  = 0; /**< The repulsion power for VdW: C12*r^-reppow   */
+    real                    fudgeQQ = 0; /**< The scaling factor for Coulomb 1-4: f*q1*q2  */
+    gmx_cmap_t              cmap_grid;   /**< The dihedral correction maps                 */
+};
+
+void pr_ffparams(FILE *fp, int indent, const char *title,
+                 const gmx_ffparams_t *ffparams, gmx_bool bShowNumbers);
+
+#endif
index 1fde04c3ff996eca4e871041d33560e27850596f..800135002d94737831cbdf5b3d8a55ab75ff0639 100644 (file)
@@ -358,69 +358,6 @@ void pr_ilist(FILE *fp, int indent, const char *title,
                bShowNumbers, bShowParameters, iparams);
 }
 
-static void pr_cmap(FILE *fp, int indent, const char *title,
-                    const gmx_cmap_t *cmap_grid, gmx_bool bShowNumbers)
-{
-    int  i, j, nelem;
-    real dx, idx;
-
-    dx    = 360.0 / cmap_grid->grid_spacing;
-    nelem = cmap_grid->grid_spacing*cmap_grid->grid_spacing;
-
-    if (available(fp, cmap_grid, indent, title))
-    {
-        fprintf(fp, "%s\n", title);
-
-        for (i = 0; i < static_cast<int>(cmap_grid->cmapdata.size()); i++)
-        {
-            idx = -180.0;
-            fprintf(fp, "%8s %8s %8s %8s\n", "V", "dVdx", "dVdy", "d2dV");
-
-            fprintf(fp, "grid[%3d]={\n", bShowNumbers ? i : -1);
-
-            for (j = 0; j < nelem; j++)
-            {
-                if ( (j%cmap_grid->grid_spacing) == 0)
-                {
-                    fprintf(fp, "%8.1f\n", idx);
-                    idx += dx;
-                }
-
-                fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4]);
-                fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+1]);
-                fprintf(fp, "%8.3f ", cmap_grid->cmapdata[i].cmap[j*4+2]);
-                fprintf(fp, "%8.3f\n", cmap_grid->cmapdata[i].cmap[j*4+3]);
-            }
-            fprintf(fp, "\n");
-        }
-    }
-
-}
-
-void pr_ffparams(FILE *fp, int indent, const char *title,
-                 const gmx_ffparams_t *ffparams,
-                 gmx_bool bShowNumbers)
-{
-    int i;
-
-    indent = pr_title(fp, indent, title);
-    pr_indent(fp, indent);
-    fprintf(fp, "atnr=%d\n", ffparams->atnr);
-    pr_indent(fp, indent);
-    fprintf(fp, "ntypes=%d\n", ffparams->numTypes());
-    for (i = 0; i < ffparams->numTypes(); i++)
-    {
-        pr_indent(fp, indent+INDENT);
-        fprintf(fp, "functype[%d]=%s, ",
-                bShowNumbers ? i : -1,
-                interaction_function[ffparams->functype[i]].name);
-        pr_iparams(fp, ffparams->functype[i], &ffparams->iparams[i]);
-    }
-    pr_double(fp, indent, "reppow", ffparams->reppow);
-    pr_real(fp, indent, "fudgeQQ", ffparams->fudgeQQ);
-    pr_cmap(fp, indent, "cmap", &ffparams->cmap_grid, bShowNumbers);
-}
-
 void pr_idef(FILE *fp, int indent, const char *title, const t_idef *idef,
              gmx_bool bShowNumbers, gmx_bool bShowParameters)
 {
index df9b6ffd97cdfa898162a47b297d3120aa755b16..901df4f5559353b9db0ce6139f70af78a19d674b 100644 (file)
@@ -37,7 +37,7 @@
 #ifndef GMX_TOPOLOGY_IDEF_H
 #define GMX_TOPOLOGY_IDEF_H
 
-#include <stdio.h>
+#include <cstdio>
 
 #include <array>
 #include <vector>
@@ -45,7 +45,6 @@
 #include "gromacs/math/vectypes.h"
 #include "gromacs/topology/ifunc.h"
 #include "gromacs/utility/basedefinitions.h"
-#include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/real.h"
 
 typedef union t_iparams
@@ -293,28 +292,6 @@ struct gmx_cmap_t
 };
 
 
-/* Struct that holds all force field parameters for the simulated system */
-struct gmx_ffparams_t
-{
-    /* Returns the number of function types, which matches the number of elements in iparams */
-    int numTypes() const
-    {
-        GMX_ASSERT(iparams.size() == functype.size(), "Parameters and function types go together");
-
-        return functype.size();
-    }
-
-    /* TODO: Consider merging functype and iparams, either by storing
-     *       the functype in t_iparams or by putting both in a single class.
-     */
-    int                     atnr = 0;          /* The number of non-bonded atom types */
-    std::vector<t_functype> functype;          /* The function type per type */
-    std::vector<t_iparams>  iparams;           /* Force field parameters per type */
-    double                  reppow  = 0.0;     /* The repulsion power for VdW: C12*r^-reppow   */
-    real                    fudgeQQ = 0._real; /* The scaling factor for Coulomb 1-4: f*q1*q2  */
-    gmx_cmap_t              cmap_grid;         /* The dihedral correction maps                 */
-};
-
 enum {
     ilsortUNKNOWN, ilsortNO_FE, ilsortFE_UNSORTED, ilsortFE_SORTED
 };
@@ -373,8 +350,6 @@ void pr_ilist(FILE *fp, int indent, const char *title,
               const t_functype *functype, const InteractionList &ilist,
               gmx_bool bShowNumbers,
               gmx_bool bShowParameters, const t_iparams *iparams);
-void pr_ffparams(FILE *fp, int indent, const char *title,
-                 const gmx_ffparams_t *ffparams, gmx_bool bShowNumbers);
 void pr_idef(FILE *fp, int indent, const char *title, const t_idef *idef,
              gmx_bool bShowNumbers, gmx_bool bShowParameters);
 
index 4c7da94216bf16f47466c0198b7dbce4404273e9..d958ffe750cbbd38a812e58f33e3e548c81dd804 100644 (file)
@@ -44,6 +44,7 @@
 #include "gromacs/math/vectypes.h"
 #include "gromacs/topology/atoms.h"
 #include "gromacs/topology/block.h"
+#include "gromacs/topology/forcefieldparameters.h"
 #include "gromacs/topology/idef.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/unique_cptr.h"