From: Magnus Lundborg Date: Mon, 15 Oct 2018 12:55:59 +0000 (+0200) Subject: Move gmx_ffparams_t to forcefieldparameters X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=f3729f9d017f9988212ca9be0a5b026f53cc8378;p=alexxy%2Fgromacs.git Move gmx_ffparams_t to forcefieldparameters Change-Id: I4639211f419724bcf3282140c8291e0b1272abe5 --- diff --git a/src/gromacs/topology/CMakeLists.txt b/src/gromacs/topology/CMakeLists.txt index 4c08f48425..14ac3201f0 100644 --- a/src/gromacs/topology/CMakeLists.txt +++ b/src/gromacs/topology/CMakeLists.txt @@ -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 index 0000000000..18dfcd21d0 --- /dev/null +++ b/src/gromacs/topology/forcefieldparameters.cpp @@ -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(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 index 0000000000..3f144d19f1 --- /dev/null +++ b/src/gromacs/topology/forcefieldparameters.h @@ -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 + +#include + +#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 functype; /**< The function type per type */ + std::vector 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 diff --git a/src/gromacs/topology/idef.cpp b/src/gromacs/topology/idef.cpp index 1fde04c3ff..800135002d 100644 --- a/src/gromacs/topology/idef.cpp +++ b/src/gromacs/topology/idef.cpp @@ -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(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) { diff --git a/src/gromacs/topology/idef.h b/src/gromacs/topology/idef.h index df9b6ffd97..901df4f555 100644 --- a/src/gromacs/topology/idef.h +++ b/src/gromacs/topology/idef.h @@ -37,7 +37,7 @@ #ifndef GMX_TOPOLOGY_IDEF_H #define GMX_TOPOLOGY_IDEF_H -#include +#include #include #include @@ -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 functype; /* The function type per type */ - std::vector 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); diff --git a/src/gromacs/topology/topology.h b/src/gromacs/topology/topology.h index 4c7da94216..d958ffe750 100644 --- a/src/gromacs/topology/topology.h +++ b/src/gromacs/topology/topology.h @@ -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"