From 3ccedc2d4136ed955854297f2f399deb727d9529 Mon Sep 17 00:00:00 2001 From: Erik Lindahl Date: Sun, 21 Jun 2015 15:49:03 +0200 Subject: [PATCH] Removed buggy -smooth hack in hbond module As discussed in redmine #1553, this was a hack added a while ago, but apparently it leads to segfaults. We should avoid hacks in the first place, and since nobody has been interested in fixing it for the last year it's time to kill it. Fixes #1553. Change-Id: I94faa3c543bcca4c729753c8b5cdaf5a5775d0ff --- src/gromacs/gmxana/gmx_analyze.c | 15 ++++++------- src/gromacs/gmxana/gmx_hbond.c | 46 +++++----------------------------------- src/gromacs/gmxana/gstat.h | 5 ++--- 3 files changed, 13 insertions(+), 53 deletions(-) diff --git a/src/gromacs/gmxana/gmx_analyze.c b/src/gromacs/gmxana/gmx_analyze.c index 480c1c67b2..d3510b6898 100644 --- a/src/gromacs/gmxana/gmx_analyze.c +++ b/src/gromacs/gmxana/gmx_analyze.c @@ -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. @@ -696,8 +696,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n, } static void luzar_correl(int nn, real *time, int nset, real **val, real temp, - gmx_bool bError, real fit_start, real smooth_tail_start, - const output_env_t oenv) + gmx_bool bError, real fit_start) { const real tol = 1e-8; real *kt; @@ -725,13 +724,13 @@ static void luzar_correl(int nn, real *time, int nset, real **val, real temp, fprintf(debug, "RMS difference in derivatives is %g\n", sqrt(d2/nn)); } analyse_corr(nn, time, val[0], val[2], kt, NULL, NULL, NULL, fit_start, - temp, smooth_tail_start, oenv); + temp); sfree(kt); } else if (nset == 6) { analyse_corr(nn, time, val[0], val[2], val[4], - val[1], val[3], val[5], fit_start, temp, smooth_tail_start, oenv); + val[1], val[3], val[5], fit_start, temp); } else { @@ -1097,7 +1096,7 @@ int gmx_analyze(int argc, char *argv[]) static gmx_bool bEESEF = FALSE, bEENLC = FALSE, bEeFitAc = FALSE, bPower = FALSE; static gmx_bool bIntegrate = FALSE, bRegression = FALSE, bLuzar = FALSE, bLuzarError = FALSE; static int nsets_in = 1, d = 1, nb_min = 4, resol = 10, nBalExp = 4, nFitPoints = 100; - static real temp = 298.15, fit_start = 1, fit_end = 60, smooth_tail_start = -1, balTime = 0.2, diffusion = 5e-5, rcut = 0.35; + static real temp = 298.15, fit_start = 1, fit_end = 60, balTime = 0.2, diffusion = 5e-5, rcut = 0.35; /* must correspond to enum avbar* declared at beginning of file */ static const char *avbar_opt[avbarNR+1] = { @@ -1140,8 +1139,6 @@ int gmx_analyze(int argc, char *argv[]) "Time (ps) from which to start fitting the correlation functions in order to obtain the forward and backward rate constants for HB breaking and formation" }, { "-fitend", FALSE, etREAL, {&fit_end}, "Time (ps) where to stop fitting the correlation functions in order to obtain the forward and backward rate constants for HB breaking and formation. Only with [TT]-gem[tt]" }, - { "-smooth", FALSE, etREAL, {&smooth_tail_start}, - "If this value is >= 0, the tail of the ACF will be smoothed by fitting it to an exponential function: [MATH]y = A [EXP]-x/[GRK]tau[grk][exp][math]" }, { "-nbmin", FALSE, etINT, {&nb_min}, "HIDDENMinimum number of blocks for block averaging" }, { "-resol", FALSE, etINT, {&resol}, @@ -1418,7 +1415,7 @@ int gmx_analyze(int argc, char *argv[]) if (bLuzar) { - luzar_correl(n, t, nset, val, temp, bXYdy, fit_start, smooth_tail_start, oenv); + luzar_correl(n, t, nset, val, temp, bXYdy, fit_start); } view_all(oenv, NFILE, fnm); diff --git a/src/gromacs/gmxana/gmx_hbond.c b/src/gromacs/gmxana/gmx_hbond.c index d02c9c1116..1d1ca6f0aa 100644 --- a/src/gromacs/gmxana/gmx_hbond.c +++ b/src/gromacs/gmxana/gmx_hbond.c @@ -2384,37 +2384,9 @@ static real compute_weighted_rates(int n, real t[], real ct[], real nt[], return chi2; } -static void smooth_tail(int n, real t[], real c[], real sigma_c[], real start, - const output_env_t oenv) -{ - FILE *fp; - real e_1, fitparm[4]; - int i; - - e_1 = exp(-1); - for (i = 0; (i < n); i++) - { - if (c[i] < e_1) - { - break; - } - } - if (i < n) - { - fitparm[0] = t[i]; - } - else - { - fitparm[0] = 10; - } - fitparm[1] = 0.95; - do_lmfit(n, c, sigma_c, 0, t, start, t[n-1], oenv, bDebugMode(), effnEXP2, fitparm, 0); -} - void analyse_corr(int n, real t[], real ct[], real nt[], real kt[], real sigma_ct[], real sigma_nt[], real sigma_kt[], - real fit_start, real temp, real smooth_tail_start, - const output_env_t oenv) + real fit_start, real temp) { int i0, i; real k = 1, kp = 1, kow = 1; @@ -2422,12 +2394,6 @@ void analyse_corr(int n, real t[], real ct[], real nt[], real kt[], double tmp, sn2 = 0, sc2 = 0, sk2 = 0, scn = 0, sck = 0, snk = 0; gmx_bool bError = (sigma_ct != NULL) && (sigma_nt != NULL) && (sigma_kt != NULL); - if (smooth_tail_start >= 0) - { - smooth_tail(n, t, ct, sigma_ct, smooth_tail_start, oenv); - smooth_tail(n, t, nt, sigma_nt, smooth_tail_start, oenv); - smooth_tail(n, t, kt, sigma_kt, smooth_tail_start, oenv); - } for (i0 = 0; (i0 < n-2) && ((t[i0]-t[0]) < fit_start); i0++) { ; @@ -2583,7 +2549,7 @@ static void normalizeACF(real *ct, real *gt, int nhb, int len) */ static void do_hbac(const char *fn, t_hbdata *hb, int nDump, gmx_bool bMerge, gmx_bool bContact, real fit_start, - real temp, gmx_bool R2, real smooth_tail_start, const output_env_t oenv, + real temp, gmx_bool R2, const output_env_t oenv, const char *gemType, int nThreads, const int NN, const gmx_bool bBallistic, const gmx_bool bGemFit) { @@ -3280,7 +3246,7 @@ static void do_hbac(const char *fn, t_hbdata *hb, gmx_ffclose(fp); analyse_corr(nn, hb->time, ct, ght, kt, NULL, NULL, NULL, - fit_start, temp, smooth_tail_start, oenv); + fit_start, temp); do_view(oenv, fn, NULL); sfree(rhbex); @@ -3589,7 +3555,7 @@ int gmx_hbond(int argc, char *argv[]) }; static real acut = 30, abin = 1, rcut = 0.35, r2cut = 0, rbin = 0.005, rshell = -1; - static real maxnhb = 0, fit_start = 1, fit_end = 60, temp = 298.15, smooth_tail_start = -1, D = -1; + static real maxnhb = 0, fit_start = 1, fit_end = 60, temp = 298.15, D = -1; static gmx_bool bNitAcc = TRUE, bDA = TRUE, bMerge = TRUE; static int nDump = 0, nFitPoints = 100; static int nThreads = 0, nBalExp = 4; @@ -3625,8 +3591,6 @@ int gmx_hbond(int argc, char *argv[]) "Time (ps) to which to stop fitting the correlation functions in order to obtain the forward and backward rate constants for HB breaking and formation (only with [TT]-gemfit[tt])" }, { "-temp", FALSE, etREAL, {&temp}, "Temperature (K) for computing the Gibbs energy corresponding to HB breaking and reforming" }, - { "-smooth", FALSE, etREAL, {&smooth_tail_start}, - "If >= 0, the tail of the ACF will be smoothed by fitting it to an exponential function: y = A exp(-x/[GRK]tau[grk])" }, { "-dump", FALSE, etINT, {&nDump}, "Dump the first N hydrogen bond ACFs in a single [TT].xvg[tt] file for debugging" }, { "-max_hb", FALSE, etREAL, {&maxnhb}, @@ -4619,7 +4583,7 @@ int gmx_hbond(int argc, char *argv[]) } gemstring = strdup(gemType[hb->per->gemtype]); do_hbac(opt2fn("-ac", NFILE, fnm), hb, nDump, - bMerge, bContact, fit_start, temp, r2cut > 0, smooth_tail_start, oenv, + bMerge, bContact, fit_start, temp, r2cut > 0, oenv, gemstring, nThreads, NN, bBallistic, bGemFit); } if (opt2bSet("-life", NFILE, fnm)) diff --git a/src/gromacs/gmxana/gstat.h b/src/gromacs/gmxana/gstat.h index e12adf55d1..a664e1397d 100644 --- a/src/gromacs/gmxana/gstat.h +++ b/src/gromacs/gmxana/gstat.h @@ -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. @@ -427,8 +427,7 @@ void print_one (const output_env_t oenv, const char *base, /* Routines from g_hbond */ void analyse_corr(int n, real t[], real ct[], real nt[], real kt[], real sigma_ct[], real sigma_nt[], real sigma_kt[], - real fit_start, real temp, real smooth_tail_start, - const output_env_t oenv); + real fit_start, real temp); void compute_derivative(int nn, real x[], real y[], real dydx[]); -- 2.11.4.GIT