add_subdirectory(onlinehelp)
add_subdirectory(options)
add_subdirectory(pbcutil)
+add_subdirectory(tables)
add_subdirectory(timing)
add_subdirectory(topology)
add_subdirectory(utility)
#include "gromacs/domdec/domdec_network.h"
#include "gromacs/gmxlib/calcgrid.h"
#include "gromacs/gmxlib/md_logging.h"
-#include "gromacs/legacyheaders/force.h"
#include "gromacs/legacyheaders/network.h"
#include "gromacs/legacyheaders/sim_util.h"
#include "gromacs/legacyheaders/types/commrec.h"
#include "gromacs/legacyheaders/names.h"
#include "gromacs/legacyheaders/nrnb.h"
#include "gromacs/legacyheaders/ns.h"
-#include "gromacs/legacyheaders/tables.h"
#include "gromacs/legacyheaders/txtdump.h"
#include "gromacs/legacyheaders/types/forcerec.h"
#include "gromacs/legacyheaders/types/mdatom.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/pbcutil/mshift.h"
#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/tables/forcetable.h"
#include "gromacs/utility/arraysize.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/cstringutil.h"
#define GMX_MAKETABLES_FORCEUSER (1<<0)
#define GMX_MAKETABLES_14ONLY (1<<1)
-t_forcetable make_tables(FILE *fp, const output_env_t oenv,
- const t_forcerec *fr, gmx_bool bVerbose,
- const char *fn, real rtab, int flags);
-/* Return tables for inner loops. When bVerbose the tables are printed
- * to .xvg files
- */
-
-bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle);
-/* Fill a table for bonded interactions,
- * angle should be: bonds 0, angles 1, dihedrals 2
- */
-
-/* Return a table for GB calculations */
-t_forcetable make_gb_table(const output_env_t oenv,
- const t_forcerec *fr);
-
-/* Read a table for AdResS Thermo Force calculations */
-t_forcetable make_atf_table(FILE *out, const output_env_t oenv,
- const t_forcerec *fr,
- const char *fn,
- matrix box);
-
gmx_bool can_use_allvsall(const t_inputrec *ir,
gmx_bool bPrintNote, struct t_commrec *cr, FILE *fp);
/* Returns if we can use all-vs-all loops.
#include <cmath>
-#include "gromacs/legacyheaders/tables.h"
#include "gromacs/legacyheaders/types/group.h"
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/pbcutil/mshift.h"
#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/tables/forcetable.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/legacyheaders/network.h"
#include "gromacs/legacyheaders/nonbonded.h"
#include "gromacs/legacyheaders/ns.h"
-#include "gromacs/legacyheaders/tables.h"
#include "gromacs/legacyheaders/txtdump.h"
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/legacyheaders/types/commrec.h"
#include "gromacs/pbcutil/ishift.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/simd/simd.h"
+#include "gromacs/tables/forcetable.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
+#include "gromacs/tables/forcetable.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 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.
+#
+# 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.
+
+file(GLOB TABLE_SOURCES *.cpp)
+set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${TABLE_SOURCES} PARENT_SCOPE)
+
+if (BUILD_TESTING)
+# add_subdirectory(tests)
+endif()
*/
#include "gmxpre.h"
-#include "gromacs/legacyheaders/tables.h"
+#include "forcetable.h"
-#include <math.h>
+#include <cmath>
+
+#include <algorithm>
#include "gromacs/fileio/xvgr.h"
#include "gromacs/legacyheaders/force.h"
-#include "gromacs/legacyheaders/macros.h"
#include "gromacs/legacyheaders/names.h"
#include "gromacs/legacyheaders/network.h"
#include "gromacs/legacyheaders/typedefs.h"
sc_deriv = sqrt(third_deriv_max/(6*4*deriv_tol*x_scale))*x_scale;
/* Don't try to be more accurate on energy than the precision */
- func_tol = max(func_tol, GMX_REAL_EPS);
+ func_tol = std::max(func_tol, static_cast<double>(GMX_REAL_EPS));
sc_func = pow(third_deriv_max/(6*12*sqrt(3)*func_tol), 1.0/3.0)*x_scale;
- return max(sc_deriv, sc_func);
+ return std::max(sc_deriv, sc_func);
}
/* The scale (1/spacing) for third order spline interpolation
fprintf(debug, "Ewald Coulomb quadratic spline table spacing: %f 1/nm\n", 1/sc_q);
}
- sc = max(sc, sc_q);
+ sc = std::max(sc, sc_q);
}
if (EVDW_PME(ic->vdwtype))
fprintf(debug, "Ewald LJ quadratic spline table spacing: %f 1/nm\n", 1/sc_lj);
}
- sc = max(sc, sc_lj);
+ sc = std::max(sc, sc_lj);
}
return sc;
/* To make life easy we initially set the spacing to 1
* and correct for this at the end.
*/
- beta = 2;
if (bS3)
{
/* Fit V''' at the start */
static void done_tabledata(t_tabledata *td)
{
- int i;
-
if (!td)
{
return;
}
else
{
- rc12 = pow(rc, -reppow);
+ rc12 = std::pow(rc, -reppow);
}
switch (tp)
}
else
{
- r12 = pow(r, -reppow);
+ r12 = std::pow(r, -reppow);
}
Vtab = 0.0;
Ftab = 0.0;
}
}
-t_forcetable make_tables(FILE *out, const output_env_t oenv,
+t_forcetable make_tables(FILE *out, const struct gmx_output_env_t *oenv,
const t_forcerec *fr,
gmx_bool bVerbose, const char *fn,
real rtab, int flags)
t_tabledata *td;
gmx_bool b14only, bReadTab, bGenTab;
real x0, y0, yp;
- int i, j, k, nx, nx0, tabsel[etiNR];
+ int k, nx, nx0, tabsel[etiNR];
real scalefactor;
t_forcetable table;
/* Check whether we have to read or generate */
bReadTab = FALSE;
bGenTab = FALSE;
- for (i = 0; (i < etiNR); i++)
+ for (unsigned int i = 0; (i < etiNR); i++)
{
if (ETAB_USER(tabsel[i]))
{
#else
table.scale = 500.0;
#endif
- nx = table.n = rtab*table.scale;
+ nx = table.n = static_cast<int>(rtab*table.scale);
}
}
if (fr->bBHAM)
fp = xvgropen(fns[k], fns[k], "r", "V", oenv);
}
/* plot the output 5 times denser than the table data */
- for (i = 5*((nx0+1)/2); i < 5*table.n; i++)
+ for (int i = 5*((nx0+1)/2); i < 5*table.n; i++)
{
x0 = i*table.r/(5*(table.n-1));
evaluate_table(table.data, k*table.formatsize, table.stride, table.scale, x0, &y0, &yp);
return table;
}
-t_forcetable make_gb_table(const output_env_t oenv,
- const t_forcerec *fr)
+t_forcetable make_gb_table(const struct gmx_output_env_t *oenv,
+ const t_forcerec *fr)
{
const char *fns[3] = { "gbctab.xvg", "gbdtab.xvg", "gbrtab.xvg" };
- const char *fns14[3] = { "gbctab14.xvg", "gbdtab14.xvg", "gbrtab14.xvg" };
FILE *fp;
t_tabledata *td;
- gmx_bool bReadTab, bGenTab;
+ gmx_bool bReadTab;
real x0, y0, yp;
- int i, j, k, nx, nx0, tabsel[etiNR];
+ int i, nx, nx0;
double r, r2, Vtab, Ftab, expterm;
t_forcetable table;
- double abs_error_r, abs_error_r2;
- double rel_error_r, rel_error_r2;
- double rel_error_r_old = 0, rel_error_r2_old = 0;
- double x0_r_error, x0_r2_error;
-
-
- /* Only set a Coulomb table for GB */
- /*
- tabsel[0]=etabGB;
- tabsel[1]=-1;
- tabsel[2]=-1;
- */
-
/* Set the table dimensions for GB, not really necessary to
* use etiNR (since we only have one table, but ...)
*/
table.r = fr->gbtabr;
table.scale = fr->gbtabscale;
table.scale_exp = 0;
- table.n = table.scale*table.r;
+ table.n = static_cast<int>(table.scale*table.r);
table.formatsize = 4;
table.ninteractions = 1;
table.stride = table.formatsize*table.ninteractions;
nx0 = 0;
- nx = table.scale*table.r;
+ nx = table.n;
/* Check whether we have to read or generate
* We will always generate a table, so remove the read code
* (Compare with original make_table function
*/
bReadTab = FALSE;
- bGenTab = TRUE;
/* Each table type (e.g. coul,lj6,lj12) requires four numbers per
* datapoint. For performance reasons we want the table data to be
xvgrclose(fp);
}
- /*
- for(i=100*nx0;i<99.81*table.n;i++)
- {
- r = i*table.r/(100*table.n);
- r2 = r*r;
- expterm = exp(-0.25*r2);
-
- Vtab = 1/sqrt(r2+expterm);
- Ftab = (r-0.25*r*expterm)/((r2+expterm)*sqrt(r2+expterm));
-
-
- evaluate_table(table.data,0,4,table.scale,r,&y0,&yp);
- printf("gb: i=%d, x0=%g, y0=%15.15f, Vtab=%15.15f, yp=%15.15f, Ftab=%15.15f\n",i,r, y0, Vtab, yp, Ftab);
-
- abs_error_r=fabs(y0-Vtab);
- abs_error_r2=fabs(yp-(-1)*Ftab);
-
- rel_error_r=abs_error_r/y0;
- rel_error_r2=fabs(abs_error_r2/yp);
-
-
- if(rel_error_r>rel_error_r_old)
- {
- rel_error_r_old=rel_error_r;
- x0_r_error=x0;
- }
-
- if(rel_error_r2>rel_error_r2_old)
- {
- rel_error_r2_old=rel_error_r2;
- x0_r2_error=x0;
- }
- }
-
- printf("gb: MAX REL ERROR IN R=%15.15f, MAX REL ERROR IN R2=%15.15f\n",rel_error_r_old, rel_error_r2_old);
- printf("gb: XO_R=%g, X0_R2=%g\n",x0_r_error, x0_r2_error);
-
- exit(1); */
done_tabledata(&(td[0]));
sfree(td);
}
-t_forcetable make_atf_table(FILE *out, const output_env_t oenv,
+t_forcetable make_atf_table(FILE *out, const struct gmx_output_env_t *oenv,
const t_forcerec *fr,
const char *fn,
matrix box)
table.scale = 0;
table.n = 0;
table.scale_exp = 0;
- nx0 = 10;
- nx = 0;
read_tables(out, fn, 1, 0, td);
rtab = td[0].x[td[0].nx-1];
bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle)
{
t_tabledata td;
- double start;
int i;
bondedtable_t tab;
int stride = 4;
- if (angle < 2)
- {
- start = 0;
- }
- else
- {
- start = -180.0;
- }
read_tables(fplog, fn, 1, angle, &td);
if (angle > 0)
{
* 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_TABLES_FORCETABLE_H
+#define GMX_TABLES_FORCETABLE_H
-#ifndef _tables_h
-#define _tables_h
+#include "gromacs/legacyheaders/types/fcdata.h"
+#include "gromacs/legacyheaders/types/forcerec.h"
#include "gromacs/legacyheaders/types/interaction_const.h"
#include "gromacs/legacyheaders/types/simple.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-#if 0
-}
-#endif
+struct gmx_output_env_t;
/* Index in the tables that says which function to use */
enum {
double v_lj_ewald_lr(double beta, double r);
/* Return the real space grid contribution for LJ-Ewald*/
-#ifdef __cplusplus
-}
-#endif
+t_forcetable make_tables(FILE *fp, const struct gmx_output_env_t *oenv,
+ const t_forcerec *fr, gmx_bool bVerbose,
+ const char *fn, real rtab, int flags);
+/* Return tables for inner loops. When bVerbose the tables are printed
+ * to .xvg files
+ */
+
+bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle);
+/* Return a table for bonded interactions,
+ * angle should be: bonds 0, angles 1, dihedrals 2
+ */
+
+/* Return a table for GB calculations */
+t_forcetable make_gb_table(const struct gmx_output_env_t *oenv,
+ const t_forcerec *fr);
+
+/* Read a table for AdResS Thermo Force calculations */
+t_forcetable make_atf_table(FILE *out,
+ const struct gmx_output_env_t *oenv,
+ const t_forcerec *fr,
+ const char *fn,
+ matrix box);
-#endif /* _tables\_h */
+#endif /* GMX_TABLES_FORCETABLE_H */