From dfb59ed348228bc153afa0ca8cc88eb14247578f Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Fri, 25 Sep 2015 21:13:10 +0200 Subject: [PATCH] Clean up of tables code This commit is not intended to change any correct and useful functionality. Removed various debug code. This is what unit tests are for. If we want the ability for a user to dump the tables we've generated, we can do that, but not as part of the run setup code. We pass fewer rarely used parameters now. Removed bGenTab. If we've read tables in, then we already have the metadata for any tables that we will later need to generate. Only if we have read no tables do we need to set the metadata to the default. David introduced bReadTab and bGenTab in 4fd28a39ea32 to do this, but it was more complicated than it needed to be. Berk changed the logic in 8e6bc73800ab, and it doesn't seem right with respect to the overall behavior (or specifics of Ewald user table types). Renamed bReadTab to useUserTable to clarify. ETAB_USER is now used a few more times, where probably it should have been used all along. Made initialization of the x field of t_tabledata something done in the various code that fillins table rather than init_table, since it clarifies other things and the x field was in several cases being over-written anyway. Moved Buckingham handling code into the generation branch, which was the only one where it did anything. Eliminated unused scale_exp field of t_forcedata. Moved assignments to nx0 variables now that the role of bReadTab is more clear. Eliminated useless nx variables. Change-Id: Icdd88612b28ce278bebac6c138445d90145ef513 --- src/gromacs/legacyheaders/force.h | 2 +- src/gromacs/legacyheaders/types/forcerec.h | 1 - src/gromacs/mdlib/forcerec.cpp | 32 +++-- src/gromacs/mdlib/forcerec.h | 30 +++-- src/gromacs/mdlib/wall.cpp | 4 +- src/gromacs/tables/forcetable.cpp | 193 +++++++---------------------- src/gromacs/tables/forcetable.h | 14 +-- src/programs/mdrun/runner.cpp | 7 +- 8 files changed, 79 insertions(+), 204 deletions(-) diff --git a/src/gromacs/legacyheaders/force.h b/src/gromacs/legacyheaders/force.h index 0a1851d3be..c1672e9437 100644 --- a/src/gromacs/legacyheaders/force.h +++ b/src/gromacs/legacyheaders/force.h @@ -85,7 +85,7 @@ void init_generalized_rf(FILE *fplog, /* In wall.c */ -void make_wall_tables(FILE *fplog, const output_env_t oenv, +void make_wall_tables(FILE *fplog, const t_inputrec *ir, const char *tabfn, const gmx_groups_t *groups, t_forcerec *fr); diff --git a/src/gromacs/legacyheaders/types/forcerec.h b/src/gromacs/legacyheaders/types/forcerec.h index 3e5fa92a7b..d231e336c7 100644 --- a/src/gromacs/legacyheaders/types/forcerec.h +++ b/src/gromacs/legacyheaders/types/forcerec.h @@ -71,7 +71,6 @@ typedef struct real r; /* range of the table */ int n; /* n+1 is the number of table points */ real scale; /* distance (nm) between two table points */ - real scale_exp; /* distance for exponential part of VdW table, not always used */ real * data; /* the actual table data */ /* Some information about the table layout. This can also be derived from the interpolation diff --git a/src/gromacs/mdlib/forcerec.cpp b/src/gromacs/mdlib/forcerec.cpp index 799e5c6eb9..ad9d75f3e5 100644 --- a/src/gromacs/mdlib/forcerec.cpp +++ b/src/gromacs/mdlib/forcerec.cpp @@ -1277,9 +1277,8 @@ static void set_bham_b_max(FILE *fplog, t_forcerec *fr, } } -static void make_nbf_tables(FILE *fp, const output_env_t oenv, +static void make_nbf_tables(FILE *fp, t_forcerec *fr, real rtab, - const t_commrec *cr, const char *tabfn, char *eg1, char *eg2, t_nblists *nbl) { @@ -1302,7 +1301,7 @@ static void make_nbf_tables(FILE *fp, const output_env_t oenv, sprintf(buf + strlen(tabfn) - strlen(ftp2ext(efXVG)) - 1, "_%s_%s.%s", eg1, eg2, ftp2ext(efXVG)); } - nbl->table_elec_vdw = make_tables(fp, oenv, fr, MASTER(cr), buf, rtab, 0); + nbl->table_elec_vdw = make_tables(fp, fr, buf, rtab, 0); /* Copy the contents of the table to separate coulomb and LJ tables too, * to improve cache performance. */ @@ -1315,7 +1314,6 @@ static void make_nbf_tables(FILE *fp, const output_env_t oenv, nbl->table_elec.r = nbl->table_elec_vdw.r; nbl->table_elec.n = nbl->table_elec_vdw.n; nbl->table_elec.scale = nbl->table_elec_vdw.scale; - nbl->table_elec.scale_exp = nbl->table_elec_vdw.scale_exp; nbl->table_elec.formatsize = nbl->table_elec_vdw.formatsize; nbl->table_elec.ninteractions = 1; nbl->table_elec.stride = nbl->table_elec.formatsize * nbl->table_elec.ninteractions; @@ -1326,7 +1324,6 @@ static void make_nbf_tables(FILE *fp, const output_env_t oenv, nbl->table_vdw.r = nbl->table_elec_vdw.r; nbl->table_vdw.n = nbl->table_elec_vdw.n; nbl->table_vdw.scale = nbl->table_elec_vdw.scale; - nbl->table_vdw.scale_exp = nbl->table_elec_vdw.scale_exp; nbl->table_vdw.formatsize = nbl->table_elec_vdw.formatsize; nbl->table_vdw.ninteractions = 2; nbl->table_vdw.stride = nbl->table_vdw.formatsize * nbl->table_vdw.ninteractions; @@ -1468,7 +1465,7 @@ static real cutoff_inf(real cutoff) return cutoff; } -static void make_adress_tf_tables(FILE *fp, const output_env_t oenv, +static void make_adress_tf_tables(FILE *fp, t_forcerec *fr, const t_inputrec *ir, const char *tabfn, const gmx_mtop_t *mtop, matrix box) @@ -1494,7 +1491,7 @@ static void make_adress_tf_tables(FILE *fp, const output_env_t oenv, { fprintf(fp, "loading tf table for energygrp index %d from %s\n", ir->adress->tf_table_index[i], buf); } - fr->atf_tabs[i] = make_atf_table(fp, oenv, fr, buf, box); + fr->atf_tabs[i] = make_atf_table(fp, fr, buf, box); } } @@ -2280,7 +2277,6 @@ gmx_bool usingGpu(nonbonded_verlet_t *nbv) } void init_forcerec(FILE *fp, - const output_env_t oenv, t_forcerec *fr, t_fcdata *fcd, const t_inputrec *ir, @@ -2936,7 +2932,7 @@ void init_forcerec(FILE *fp, #endif fr->gbtabr = 100; - fr->gbtab = make_gb_table(oenv, fr); + fr->gbtab = make_gb_table(fr); init_gb(&fr->born, fr, ir, mtop, ir->gb_algorithm); @@ -3050,10 +3046,10 @@ void init_forcerec(FILE *fp, /* make tables for ordinary interactions */ if (bSomeNormalNbListsAreInUse) { - make_nbf_tables(fp, oenv, fr, rtab, cr, tabfn, NULL, NULL, &fr->nblists[0]); + make_nbf_tables(fp, fr, rtab, tabfn, NULL, NULL, &fr->nblists[0]); if (ir->adress) { - make_nbf_tables(fp, oenv, fr, rtab, cr, tabfn, NULL, NULL, &fr->nblists[fr->nnblists/2]); + make_nbf_tables(fp, fr, rtab, tabfn, NULL, NULL, &fr->nblists[fr->nnblists/2]); } if (!bMakeSeparate14Table) { @@ -3081,13 +3077,13 @@ void init_forcerec(FILE *fp, fr->gid2nblists[GID(egi, egj, ir->opts.ngener)] = m; } /* Read the table file with the two energy groups names appended */ - make_nbf_tables(fp, oenv, fr, rtab, cr, tabfn, + make_nbf_tables(fp, fr, rtab, tabfn, *mtop->groups.grpname[nm_ind[egi]], *mtop->groups.grpname[nm_ind[egj]], &fr->nblists[m]); if (ir->adress) { - make_nbf_tables(fp, oenv, fr, rtab, cr, tabfn, + make_nbf_tables(fp, fr, rtab, tabfn, *mtop->groups.grpname[nm_ind[egi]], *mtop->groups.grpname[nm_ind[egj]], &fr->nblists[fr->nnblists/2+m]); @@ -3110,13 +3106,13 @@ void init_forcerec(FILE *fp, /* Tables might not be used for the potential modifier interactions per se, but * we still need them to evaluate switch/shift dispersion corrections in this case. */ - make_nbf_tables(fp, oenv, fr, rtab, cr, tabfn, NULL, NULL, &fr->nblists[0]); + make_nbf_tables(fp, fr, rtab, tabfn, NULL, NULL, &fr->nblists[0]); } if (bMakeSeparate14Table) { /* generate extra tables with plain Coulomb for 1-4 interactions only */ - fr->tab14 = make_tables(fp, oenv, fr, MASTER(cr), tabpfn, rtab, + fr->tab14 = make_tables(fp, fr, tabpfn, rtab, GMX_MAKETABLES_14ONLY); } @@ -3127,14 +3123,14 @@ void init_forcerec(FILE *fp, if (ir->adress->n_tf_grps > 0) { - make_adress_tf_tables(fp, oenv, fr, ir, tabfn, mtop, box); + make_adress_tf_tables(fp, fr, ir, tabfn, mtop, box); } else { /* load the default table */ snew(fr->atf_tabs, 1); - fr->atf_tabs[DEFAULT_TF_TABLE] = make_atf_table(fp, oenv, fr, tabafn, box); + fr->atf_tabs[DEFAULT_TF_TABLE] = make_atf_table(fp, fr, tabafn, box); } } @@ -3142,7 +3138,7 @@ void init_forcerec(FILE *fp, fr->nwall = ir->nwall; if (ir->nwall && ir->wall_type == ewtTABLE) { - make_wall_tables(fp, oenv, ir, tabfn, &mtop->groups, fr); + make_wall_tables(fp, ir, tabfn, &mtop->groups, fr); } if (fcd && tabbfn) diff --git a/src/gromacs/mdlib/forcerec.h b/src/gromacs/mdlib/forcerec.h index 232fd26065..30ecf5961c 100644 --- a/src/gromacs/mdlib/forcerec.h +++ b/src/gromacs/mdlib/forcerec.h @@ -91,7 +91,6 @@ void init_interaction_const_tables(FILE *fp, * * The Force rec struct must be created with mk_forcerec. * \param[in] fplog File for printing - * \param[in] oenv Output environment structure * \param[out] fr The forcerec * \param[in] fcd Force constant data * \param[in] ir Inputrec structure @@ -106,21 +105,20 @@ void init_interaction_const_tables(FILE *fp, * \param[in] bNoSolvOpt Do not use solvent optimization * \param[in] print_force Print forces for atoms with force >= print_force */ -void init_forcerec(FILE *fplog, - const output_env_t oenv, - t_forcerec *fr, - struct t_fcdata *fcd, - const t_inputrec *ir, - const gmx_mtop_t *mtop, - const t_commrec *cr, - matrix box, - const char *tabfn, - const char *tabafn, - const char *tabpfn, - const char *tabbfn, - const char *nbpu_opt, - gmx_bool bNoSolvOpt, - real print_force); +void init_forcerec(FILE *fplog, + t_forcerec *fr, + t_fcdata *fcd, + const t_inputrec *ir, + const gmx_mtop_t *mtop, + const t_commrec *cr, + matrix box, + const char *tabfn, + const char *tabafn, + const char *tabpfn, + const char *tabbfn, + const char *nbpu_opt, + gmx_bool bNoSolvOpt, + real print_force); /*! \brief Divide exclusions over threads * diff --git a/src/gromacs/mdlib/wall.cpp b/src/gromacs/mdlib/wall.cpp index f37b505329..fa1a7e7299 100644 --- a/src/gromacs/mdlib/wall.cpp +++ b/src/gromacs/mdlib/wall.cpp @@ -52,7 +52,7 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/smalloc.h" -void make_wall_tables(FILE *fplog, const output_env_t oenv, +void make_wall_tables(FILE *fplog, const t_inputrec *ir, const char *tabfn, const gmx_groups_t *groups, t_forcerec *fr) @@ -86,7 +86,7 @@ void make_wall_tables(FILE *fplog, const output_env_t oenv, *groups->grpname[nm_ind[egp]], *groups->grpname[nm_ind[negp_pp+w]], ftp2ext(efXVG)); - *tab = make_tables(fplog, oenv, fr, FALSE, buf, 0, GMX_MAKETABLES_FORCEUSER); + *tab = make_tables(fplog, fr, buf, 0, GMX_MAKETABLES_FORCEUSER); /* Since wall have no charge, we can compress the table */ for (int i = 0; i <= tab->n; i++) { diff --git a/src/gromacs/tables/forcetable.cpp b/src/gromacs/tables/forcetable.cpp index 0fe35d91fa..018403e45a 100644 --- a/src/gromacs/tables/forcetable.cpp +++ b/src/gromacs/tables/forcetable.cpp @@ -460,8 +460,6 @@ static void copy2table(int n, int offset, int stride, static void init_table(int n, int nx0, double tabscale, t_tabledata *td, gmx_bool bAlloc) { - int i; - td->nx = n; td->nx0 = nx0; td->tabscale = tabscale; @@ -471,10 +469,6 @@ static void init_table(int n, int nx0, snew(td->v, td->nx); snew(td->f, td->nx); } - for (i = 0; (i < td->nx); i++) - { - td->x[i] = i/tabscale; - } } static void spline_forces(int nx, double h, double v[], gmx_bool bS3, gmx_bool bE3, @@ -812,9 +806,6 @@ static void fill_table(t_tabledata *td, int tp, const t_forcerec *fr, * we always use double precision to calculate them here, in order * to avoid unnecessary loss of precision. */ -#ifdef DEBUG_SWITCH - FILE *fp; -#endif int i; double reppow, p; double r1, rc, r12, r13; @@ -903,10 +894,6 @@ static void fill_table(t_tabledata *td, int tp, const t_forcerec *fr, fprintf(debug, "Setting up tables\n"); fflush(debug); } -#ifdef DEBUG_SWITCH - fp = xvgropen("switch.xvg", "switch", "r", "s"); -#endif - if (bPotentialShift) { rc2 = rc*rc; @@ -958,6 +945,10 @@ static void fill_table(t_tabledata *td, int tp, const t_forcerec *fr, } } + for (i = 0; (i < td->nx); i++) + { + td->x[i] = i/td->tabscale; + } for (i = td->nx0; (i < td->nx); i++) { r = td->x[i]; @@ -1004,9 +995,6 @@ static void fill_table(t_tabledata *td, int tp, const t_forcerec *fr, swi = 1.0; swi1 = 0.0; } -#ifdef DEBUG_SWITCH - fprintf(fp, "%10g %10g %10g %10g\n", r, swi, swi1, swi2); -#endif rc6 = rc*rc*rc; rc6 = 1.0/(rc6*rc6); @@ -1193,10 +1181,6 @@ static void fill_table(t_tabledata *td, int tp, const t_forcerec *fr, td->v[i] = td->v[i+1] + td->f[i+1]*(td->x[i+1] - td->x[i]); td->f[i] = td->f[i+1]; } - -#ifdef DEBUG_SWITCH - xvgrclose(fp); -#endif } static void set_table_type(int tabsel[], const t_forcerec *fr, gmx_bool b14only) @@ -1366,18 +1350,14 @@ static void set_table_type(int tabsel[], const t_forcerec *fr, gmx_bool b14only) } } -t_forcetable make_tables(FILE *out, const struct gmx_output_env_t *oenv, +t_forcetable make_tables(FILE *out, const t_forcerec *fr, - gmx_bool bVerbose, const char *fn, + const char *fn, real rtab, int flags) { - const char *fns[3] = { "ctab.xvg", "dtab.xvg", "rtab.xvg" }; - const char *fns14[3] = { "ctab14.xvg", "dtab14.xvg", "rtab14.xvg" }; - FILE *fp; t_tabledata *td; - gmx_bool b14only, bReadTab, bGenTab; - real x0, y0, yp; - int k, nx, nx0, tabsel[etiNR]; + gmx_bool b14only, useUserTable; + int nx0, tabsel[etiNR]; real scalefactor; t_forcetable table; @@ -1398,9 +1378,6 @@ t_forcetable make_tables(FILE *out, const struct gmx_output_env_t *oenv, table.r = rtab; table.scale = 0; table.n = 0; - table.scale_exp = 0; - nx0 = 10; - nx = 0; table.interaction = GMX_TABLE_INTERACTION_ELEC_VDWREP_VDWDISP; table.format = GMX_TABLE_FORMAT_CUBICSPLINE_YFGH; @@ -1409,27 +1386,20 @@ t_forcetable make_tables(FILE *out, const struct gmx_output_env_t *oenv, table.stride = table.formatsize*table.ninteractions; /* Check whether we have to read or generate */ - bReadTab = FALSE; - bGenTab = FALSE; + useUserTable = FALSE; for (unsigned int i = 0; (i < etiNR); i++) { if (ETAB_USER(tabsel[i])) { - bReadTab = TRUE; - } - if (tabsel[i] != etabUSER) - { - bGenTab = TRUE; + useUserTable = TRUE; } } - if (bReadTab) + if (useUserTable) { read_tables(out, fn, etiNR, 0, td); if (rtab == 0 || (flags & GMX_MAKETABLES_14ONLY)) { - rtab = td[0].x[td[0].nx-1]; table.n = td[0].nx; - nx = table.n; } else { @@ -1438,54 +1408,47 @@ t_forcetable make_tables(FILE *out, const struct gmx_output_env_t *oenv, gmx_fatal(FARGS, "Tables in file %s not long enough for cut-off:\n" "\tshould be at least %f nm\n", fn, rtab); } - nx = table.n = (int)(rtab*td[0].tabscale + 0.5); + table.n = (int)(rtab*td[0].tabscale + 0.5); } table.scale = td[0].tabscale; nx0 = td[0].nx0; } - if (bGenTab) + else { - if (!bReadTab) - { + // No tables are read #ifdef GMX_DOUBLE - table.scale = 2000.0; + table.scale = 2000.0; #else - table.scale = 500.0; + table.scale = 500.0; #endif - nx = table.n = static_cast(rtab*table.scale); - } - } - if (fr->bBHAM) - { - if (fr->bham_b_max != 0) - { - table.scale_exp = table.scale/fr->bham_b_max; - } - else - { - table.scale_exp = table.scale; - } + table.n = static_cast(rtab*table.scale); + nx0 = 10; } /* Each table type (e.g. coul,lj6,lj12) requires four - * numbers per nx+1 data points. For performance reasons we want + * numbers per table.n+1 data points. For performance reasons we want * the table data to be aligned to a 32-byte boundary. */ - snew_aligned(table.data, table.stride*(nx+1)*sizeof(real), 32); + snew_aligned(table.data, table.stride*(table.n+1)*sizeof(real), 32); - for (k = 0; (k < etiNR); k++) + for (int k = 0; (k < etiNR); k++) { - if (tabsel[k] != etabUSER) + /* Now fill data for tables that should not be read (perhaps + overwriting data that was read but should not be used) */ + if (!ETAB_USER(tabsel[k])) { - init_table(nx, nx0, - (tabsel[k] == etabEXPMIN) ? table.scale_exp : table.scale, - &(td[k]), !bReadTab); + real scale = table.scale; + if (fr->bBHAM && (fr->bham_b_max != 0) && tabsel[k] == etabEXPMIN) + { + scale /= fr->bham_b_max; + } + init_table(table.n, nx0, scale, &(td[k]), !useUserTable); + fill_table(&(td[k]), tabsel[k], fr, b14only); if (out) { - fprintf(out, "%s table with %d data points for %s%s.\n" + fprintf(out, "Generated table with %d data points for %s%s.\n" "Tabscale = %g points/nm\n", - ETAB_USER(tabsel[k]) ? "Modified" : "Generated", td[k].nx, b14only ? "1-4 " : "", tprops[tabsel[k]].name, td[k].tabscale); } @@ -1512,25 +1475,6 @@ t_forcetable make_tables(FILE *out, const struct gmx_output_env_t *oenv, copy2table(table.n, k*table.formatsize, table.stride, td[k].x, td[k].v, td[k].f, scalefactor, table.data); - if (bDebugMode() && bVerbose) - { - if (b14only) - { - fp = xvgropen(fns14[k], fns14[k], "r", "V", oenv); - } - else - { - fp = xvgropen(fns[k], fns[k], "r", "V", oenv); - } - /* plot the output 5 times denser than the table data */ - 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); - fprintf(fp, "%15.10e %15.10e %15.10e\n", x0, y0, yp); - } - xvgrclose(fp); - } done_tabledata(&(td[k])); } sfree(td); @@ -1538,15 +1482,10 @@ t_forcetable make_tables(FILE *out, const struct gmx_output_env_t *oenv, return table; } -t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, - const t_forcerec *fr) +t_forcetable make_gb_table(const t_forcerec *fr) { - const char *fns[3] = { "gbctab.xvg", "gbdtab.xvg", "gbrtab.xvg" }; - FILE *fp; t_tabledata *td; - gmx_bool bReadTab; - real x0, y0, yp; - int i, nx, nx0; + int nx0; double r, r2, Vtab, Ftab, expterm; t_forcetable table; @@ -1559,19 +1498,11 @@ t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, table.format = GMX_TABLE_FORMAT_CUBICSPLINE_YFGH; table.r = fr->gbtabr; table.scale = fr->gbtabscale; - table.scale_exp = 0; table.n = static_cast(table.scale*table.r); table.formatsize = 4; table.ninteractions = 1; table.stride = table.formatsize*table.ninteractions; nx0 = 0; - 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; /* Each table type (e.g. coul,lj6,lj12) requires four numbers per * datapoint. For performance reasons we want the table data to be @@ -1580,9 +1511,9 @@ t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, * to do this :-) */ - snew_aligned(table.data, table.stride*nx, 32); + snew_aligned(table.data, table.stride*table.n, 32); - init_table(nx, nx0, table.scale, &(td[0]), !bReadTab); + init_table(table.n, nx0, table.scale, &(td[0]), TRUE); /* Local implementation so we don't have to use the etabGB * enum above, which will cause problems later when @@ -1592,7 +1523,7 @@ t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, * be defined in fill_table and set_table_type */ - for (i = nx0; i < nx; i++) + for (int i = nx0; i < table.n; i++) { r = td->x[i]; r2 = r*r; @@ -1602,6 +1533,7 @@ t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, Ftab = (r-0.25*r*expterm)/((r2+expterm)*sqrt(r2+expterm)); /* Convert to single precision when we store to mem */ + td->x[i] = i/table.scale; td->v[i] = Vtab; td->f[i] = Ftab; @@ -1609,22 +1541,6 @@ t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, copy2table(table.n, 0, table.stride, td[0].x, td[0].v, td[0].f, 1.0, table.data); - if (bDebugMode()) - { - fp = xvgropen(fns[0], fns[0], "r", "V", oenv); - /* plot the output 5 times denser than the table data */ - /* for(i=5*nx0;i<5*table.n;i++) */ - for (i = nx0; i < table.n; i++) - { - /* x0=i*table.r/(5*table.n); */ - x0 = i*table.r/table.n; - evaluate_table(table.data, 0, table.stride, table.scale, x0, &y0, &yp); - fprintf(fp, "%15.10e %15.10e %15.10e\n", x0, y0, yp); - - } - xvgrclose(fp); - } - done_tabledata(&(td[0])); sfree(td); @@ -1633,16 +1549,13 @@ t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, } -t_forcetable make_atf_table(FILE *out, const struct gmx_output_env_t *oenv, +t_forcetable make_atf_table(FILE *out, const t_forcerec *fr, - const char *fn, - matrix box) + const char *fn, + matrix box) { - const char *fns[3] = { "tf_tab.xvg", "atfdtab.xvg", "atfrtab.xvg" }; - FILE *fp; t_tabledata *td; - real x0, y0, yp, rtab; - int i, nx, nx0; + real rtab; real rx, ry, rz, box_r; t_forcetable table; @@ -1670,7 +1583,6 @@ t_forcetable make_atf_table(FILE *out, const struct gmx_output_env_t *oenv, table.r = box_r; table.scale = 0; table.n = 0; - table.scale_exp = 0; read_tables(out, fn, 1, 0, td); rtab = td[0].x[td[0].nx-1]; @@ -1690,9 +1602,7 @@ t_forcetable make_atf_table(FILE *out, const struct gmx_output_env_t *oenv, table.n = td[0].nx; - nx = table.n; table.scale = td[0].tabscale; - nx0 = td[0].nx0; table.interaction = GMX_TABLE_INTERACTION_ELEC_VDWREP_VDWDISP; table.format = GMX_TABLE_FORMAT_CUBICSPLINE_YFGH; @@ -1707,27 +1617,10 @@ t_forcetable make_atf_table(FILE *out, const struct gmx_output_env_t *oenv, * to do this :-) */ - snew_aligned(table.data, table.stride*nx, 32); + snew_aligned(table.data, table.stride*table.n, 32); copy2table(table.n, 0, table.stride, td[0].x, td[0].v, td[0].f, 1.0, table.data); - if (bDebugMode()) - { - fp = xvgropen(fns[0], fns[0], "r", "V", oenv); - /* plot the output 5 times denser than the table data */ - /* for(i=5*nx0;i<5*table.n;i++) */ - - for (i = 5*((nx0+1)/2); i < 5*table.n; i++) - { - /* x0=i*table.r/(5*table.n); */ - x0 = i*table.r/(5*(table.n-1)); - evaluate_table(table.data, 0, table.stride, table.scale, x0, &y0, &yp); - fprintf(fp, "%15.10e %15.10e %15.10e\n", x0, y0, yp); - - } - xvgrclose(fp); - } - done_tabledata(&(td[0])); sfree(td); diff --git a/src/gromacs/tables/forcetable.h b/src/gromacs/tables/forcetable.h index 6fa8ed1a9f..24e29b2cf8 100644 --- a/src/gromacs/tables/forcetable.h +++ b/src/gromacs/tables/forcetable.h @@ -40,8 +40,6 @@ #include "gromacs/legacyheaders/types/interaction_const.h" #include "gromacs/legacyheaders/types/simple.h" -struct gmx_output_env_t; - /* Index in the tables that says which function to use */ enum { etiCOUL, etiLJ6, etiLJ12, etiNR @@ -76,12 +74,10 @@ double v_q_ewald_lr(double beta, double r); double v_lj_ewald_lr(double beta, double r); /* Return the real space grid contribution for LJ-Ewald*/ -t_forcetable make_tables(FILE *fp, const struct gmx_output_env_t *oenv, - const t_forcerec *fr, gmx_bool bVerbose, +t_forcetable make_tables(FILE *fp, + const t_forcerec *fr, const char *fn, real rtab, int flags); -/* Return tables for inner loops. When bVerbose the tables are printed - * to .xvg files - */ +/* Return tables for inner loops. */ bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle); /* Return a table for bonded interactions, @@ -89,12 +85,10 @@ bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle); */ /* Return a table for GB calculations */ -t_forcetable make_gb_table(const struct gmx_output_env_t *oenv, - const t_forcerec *fr); +t_forcetable make_gb_table(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); diff --git a/src/programs/mdrun/runner.cpp b/src/programs/mdrun/runner.cpp index 93fd059e13..3dc9752a95 100644 --- a/src/programs/mdrun/runner.cpp +++ b/src/programs/mdrun/runner.cpp @@ -1167,7 +1167,7 @@ int mdrunner(gmx_hw_opt_t *hw_opt, fr = mk_forcerec(); fr->hwinfo = hwinfo; fr->gpu_opt = &hw_opt->gpu_opt; - init_forcerec(fplog, oenv, fr, fcd, inputrec, mtop, cr, box, + init_forcerec(fplog, fr, fcd, inputrec, mtop, cr, box, opt2fn("-table", nfile, fnm), opt2fn("-tabletf", nfile, fnm), opt2fn("-tablep", nfile, fnm), @@ -1176,11 +1176,6 @@ int mdrunner(gmx_hw_opt_t *hw_opt, FALSE, pforce); - /* version for PCA_NOT_READ_NODE (see md.c) */ - /*init_forcerec(fplog,fr,fcd,inputrec,mtop,cr,box,FALSE, - "nofile","nofile","nofile","nofile",FALSE,pforce); - */ - /* Initialize QM-MM */ if (fr->bQMMM) { -- 2.11.4.GIT