From 106ca9e645d05a79a01fdd27446794439e197685 Mon Sep 17 00:00:00 2001 From: David van der Spoel Date: Wed, 21 May 2014 16:38:25 +0200 Subject: [PATCH] Reorganizing analysis of correlation functions. Moved routines computing correlation functions and fitting to those in a special subdirectory not dependent on gmxana. The autocorrelation now functions as it should (previously there were issues with long time correlations). Replaced Levenberg-Marquardt algorithm by another implementation from http://apps.jcns.fz-juelich.de/doku/sc/lmfit, under a FreeBSD license. This code is in src/external/lmfit. Added Doxygen comments to all headers. Fixed wordcount algorithm in xvgr.c The routines many_auto_correl and many_cross_correl are optimized using OpenMP. Change-Id: Ifbe003437db36e35d606cd942bb38deeef86ea64 --- COPYING | 34 + cmake/legacy_and_external.supp | 9 +- src/external/lmfit/README | 5 + src/external/lmfit/lmcurve.c | 52 + src/external/lmfit/lmcurve.h | 38 + src/external/lmfit/lmmin.c | 1389 ++++++++++++++++++++ src/external/lmfit/lmmin.h | 79 ++ src/external/lmfit/lmstruct.h | 81 ++ src/gromacs/CMakeLists.txt | 1 + src/gromacs/correlationfunctions/CMakeLists.txt | 41 + .../{gmxana => correlationfunctions}/autocorr.c | 388 +----- src/gromacs/correlationfunctions/autocorr.h | 187 +++ src/gromacs/correlationfunctions/crosscorr.c | 169 +++ .../correl.h => correlationfunctions/crosscorr.h} | 60 +- src/gromacs/correlationfunctions/expfit.c | 698 ++++++++++ src/gromacs/correlationfunctions/expfit.h | 145 ++ src/gromacs/correlationfunctions/integrate.c | 147 +++ .../integrate.h} | 85 +- .../correlationfunctions/manyautocorrelation.c | 115 ++ .../manyautocorrelation.h} | 53 +- .../{gmxana => correlationfunctions}/polynomials.c | 32 +- .../polynomials.h} | 45 +- .../correlationfunctions/tests/CMakeLists.txt | 39 + .../correlationfunctions/tests/autocorr.cpp | 231 ++++ .../tests/correlationdataset.cpp} | 79 +- .../tests/correlationdataset.h | 111 ++ src/gromacs/correlationfunctions/tests/expfit.cpp | 206 +++ .../tests/refdata/AutocorrTest_EacCos.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacNormal.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacP0.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacP1.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacP2.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacP3.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacP4.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacRcross.xml | 509 +++++++ .../tests/refdata/AutocorrTest_EacVector.xml | 509 +++++++ .../tests/refdata/ExpfitTest_EffnERF.xml | 11 + .../tests/refdata/ExpfitTest_EffnERREST.xml | 10 + .../tests/refdata/ExpfitTest_EffnEXP1.xml | 8 + .../tests/refdata/ExpfitTest_EffnEXP2.xml | 9 + .../tests/refdata/ExpfitTest_EffnEXP3.xml | 10 + .../tests/refdata/ExpfitTest_EffnEXP5.xml | 12 + .../tests/refdata/ExpfitTest_EffnEXP7.xml | 14 + .../tests/refdata/ExpfitTest_EffnEXP9.xml | 16 + .../tests/refdata/ExpfitTest_EffnPRES.xml | 13 + .../tests/refdata/ExpfitTest_EffnVAC.xml | 9 + .../correlationfunctions/tests/testCOS3.xvg | 501 +++++++ src/gromacs/correlationfunctions/tests/testEXP.xvg | 501 +++++++ .../correlationfunctions/tests/testINVEXP.xvg | 501 +++++++ .../correlationfunctions/tests/testPRES.xvg | 501 +++++++ src/gromacs/fileio/xvgr.cpp | 27 +- src/gromacs/gmxana/correl.c | 203 --- src/gromacs/gmxana/expfit.c | 722 ---------- src/gromacs/gmxana/gmx_analyze.c | 23 +- src/gromacs/gmxana/gmx_angle.c | 2 +- src/gromacs/gmxana/gmx_chi.c | 2 + src/gromacs/gmxana/gmx_densorder.cpp | 32 +- src/gromacs/gmxana/gmx_dielectric.c | 35 +- src/gromacs/gmxana/gmx_dipoles.cpp | 2 +- src/gromacs/gmxana/gmx_dos.c | 5 +- src/gromacs/gmxana/gmx_energy.c | 1 + src/gromacs/gmxana/gmx_gyrate.c | 2 + src/gromacs/gmxana/gmx_hbond.c | 18 +- src/gromacs/gmxana/gmx_rdf.c | 1 + src/gromacs/gmxana/gmx_rotacf.c | 2 +- src/gromacs/gmxana/gmx_tcaf.c | 7 +- src/gromacs/gmxana/gmx_velacc.c | 2 + src/gromacs/gmxana/gstat.h | 173 --- src/gromacs/gmxana/levenmar.c | 768 ----------- 69 files changed, 10855 insertions(+), 2388 deletions(-) create mode 100644 src/external/lmfit/README create mode 100644 src/external/lmfit/lmcurve.c create mode 100644 src/external/lmfit/lmcurve.h create mode 100644 src/external/lmfit/lmmin.c create mode 100644 src/external/lmfit/lmmin.h create mode 100644 src/external/lmfit/lmstruct.h create mode 100644 src/gromacs/correlationfunctions/CMakeLists.txt rename src/gromacs/{gmxana => correlationfunctions}/autocorr.c (72%) create mode 100644 src/gromacs/correlationfunctions/autocorr.h create mode 100644 src/gromacs/correlationfunctions/crosscorr.c copy src/gromacs/{gmxana/correl.h => correlationfunctions/crosscorr.h} (55%) create mode 100644 src/gromacs/correlationfunctions/expfit.c create mode 100644 src/gromacs/correlationfunctions/expfit.h create mode 100644 src/gromacs/correlationfunctions/integrate.c copy src/gromacs/{gmxana/polynomials.c => correlationfunctions/integrate.h} (50%) create mode 100644 src/gromacs/correlationfunctions/manyautocorrelation.c copy src/gromacs/{gmxana/correl.h => correlationfunctions/manyautocorrelation.h} (54%) copy src/gromacs/{gmxana => correlationfunctions}/polynomials.c (79%) rename src/gromacs/{gmxana/correl.h => correlationfunctions/polynomials.h} (70%) create mode 100644 src/gromacs/correlationfunctions/tests/CMakeLists.txt create mode 100644 src/gromacs/correlationfunctions/tests/autocorr.cpp rename src/gromacs/{gmxana/polynomials.c => correlationfunctions/tests/correlationdataset.cpp} (56%) create mode 100644 src/gromacs/correlationfunctions/tests/correlationdataset.h create mode 100755 src/gromacs/correlationfunctions/tests/expfit.cpp create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacCos.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacNormal.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP0.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP1.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP2.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP3.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP4.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacRcross.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacVector.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERF.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERREST.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP1.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP2.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP3.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP5.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP7.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP9.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnPRES.xml create mode 100644 src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnVAC.xml create mode 100644 src/gromacs/correlationfunctions/tests/testCOS3.xvg create mode 100644 src/gromacs/correlationfunctions/tests/testEXP.xvg create mode 100755 src/gromacs/correlationfunctions/tests/testINVEXP.xvg create mode 100644 src/gromacs/correlationfunctions/tests/testPRES.xvg delete mode 100644 src/gromacs/gmxana/correl.c delete mode 100644 src/gromacs/gmxana/expfit.c delete mode 100644 src/gromacs/gmxana/levenmar.c diff --git a/COPYING b/COPYING index dddffe127d..e2737f3198 100644 --- a/COPYING +++ b/COPYING @@ -20,6 +20,7 @@ This file contains the licenses for the following bodies of code: 10. Sun FDLIBM (Freely Distributable Maths Library) 11. Random123 12. md5 +13. lmfit Our chosen method for packaging distributions (CPack) only permits a package to have a single license file, so we are unfortunately forced @@ -1215,3 +1216,36 @@ freely, subject to the following restrictions: L. Peter Deutsch ghost@aladdin.com + +13. lmfit +============================================ +The package lmfit is distributed under the FreeBSD License: + +-- + Copyright (c) 1980-1999 University of Chicago, + as operator of Argonne National Laboratory + Copyright (c) 2004-2013 Joachim Wuttke, Forschungszentrum Juelich GmbH + + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + - Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + This software is provided by the copyright holders and contributors "as is" + and any express or implied warranties, including, but not limited to, the + implied warranties of merchantability and fitness for a particular purpose + are disclaimed. In no event shall the copyright holder or contributors + be liable for any direct, indirect, incidental, special, exemplary, or + consequential damages (including, but not limited to, procurement of + substitute goods or services; loss of use, data, or profits; or business + interruption) however caused and on any theory of liability, whether in + contract, strict liability, or tort (including negligence or otherwise) + arising in any way out of the use of this software, even if advised of the + possibility of such damage. +-- diff --git a/cmake/legacy_and_external.supp b/cmake/legacy_and_external.supp index 082fcc14ae..9a3166352d 100644 --- a/cmake/legacy_and_external.supp +++ b/cmake/legacy_and_external.supp @@ -14,14 +14,18 @@ fun:make_unsp fun:nsc_dclm_pbc } - +{ + libgomp + Memcheck:Leak + ... + obj:*/libgomp.so* +} { ctime_r Memcheck:Leak ... fun:ctime_r } - { libz Memcheck:Cond @@ -272,3 +276,4 @@ ... fun:__kmpc_global_thread_num } + diff --git a/src/external/lmfit/README b/src/external/lmfit/README new file mode 100644 index 0000000000..618129e14a --- /dev/null +++ b/src/external/lmfit/README @@ -0,0 +1,5 @@ +This directory contains only the barebone version of the +lmfit package, version 5.1. Full version is available from +http://apps.jcns.fz-juelich.de/doku/sc/lmfit + +License in gromacs root directory in file COPYING diff --git a/src/external/lmfit/lmcurve.c b/src/external/lmfit/lmcurve.c new file mode 100644 index 0000000000..838f884bb6 --- /dev/null +++ b/src/external/lmfit/lmcurve.c @@ -0,0 +1,52 @@ +/* + * Library: lmfit (Levenberg-Marquardt least squares fitting) + * + * File: lmcurve.c + * + * Contents: Levenberg-Marquardt curve-fitting + * + * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) + * + * License: see ../COPYING (FreeBSD) + * + * Homepage: apps.jcns.fz-juelich.de/lmfit + */ + +#include "lmmin.h" +#include "gromacs/utility/basedefinitions.h" + +typedef struct { + const double *t; + const double *y; + double (*f)(double t, const double *par); +} lmcurve_data_struct; + + +void lmcurve_evaluate( const double *par, int m_dat, const void *data, + double *fvec, gmx_unused int *info ) +{ + int i; + for (i = 0; i < m_dat; i++) + { + fvec[i] = + ((lmcurve_data_struct*)data)->y[i] - + ((lmcurve_data_struct*)data)->f( + ((lmcurve_data_struct*)data)->t[i], par ); + } +} + + +void lmcurve( int n_par, double *par, int m_dat, + const double *t, const double *y, + double (*f)( double t, const double *par ), + const lm_control_struct *control, + lm_status_struct *status ) +{ + lmcurve_data_struct data; + data.t = t; + data.y = y; + data.f = f; + + lmmin( n_par, par, m_dat, (const void*) &data, + lmcurve_evaluate, control, status ); +} diff --git a/src/external/lmfit/lmcurve.h b/src/external/lmfit/lmcurve.h new file mode 100644 index 0000000000..d74114caaf --- /dev/null +++ b/src/external/lmfit/lmcurve.h @@ -0,0 +1,38 @@ +/* + * Library: lmfit (Levenberg-Marquardt least squares fitting) + * + * File: lmcurve.h + * + * Contents: Declarations for Levenberg-Marquardt curve fitting. + * + * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) + * + * License: see ../COPYING (FreeBSD) + * + * Homepage: apps.jcns.fz-juelich.de/lmfit + */ + +#ifndef LMCURVE_H +#define LMCURVE_H +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +#include "lmstruct.h" + +__BEGIN_DECLS + +void lmcurve( int n_par, double *par, int m_dat, + const double *t, const double *y, + double (*f)( double t, const double *par ), + const lm_control_struct *control, + lm_status_struct *status ); + +__END_DECLS +#endif /* LMCURVE_H */ diff --git a/src/external/lmfit/lmmin.c b/src/external/lmfit/lmmin.c new file mode 100644 index 0000000000..b6b8dfc3a4 --- /dev/null +++ b/src/external/lmfit/lmmin.c @@ -0,0 +1,1389 @@ +/* + * Library: lmfit (Levenberg-Marquardt least squares fitting) + * + * File: lmmin.c + * + * Contents: Levenberg-Marquardt minimization. + * + * Copyright: MINPACK authors, The University of Chikago (1980-1999) + * Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) + * + * License: see ../COPYING (FreeBSD) + * + * Homepage: apps.jcns.fz-juelich.de/lmfit + */ + +#include +#include +#include +#include +#include "lmmin.h" + +#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) +#define MAX(a, b) (((a) >= (b)) ? (a) : (b)) +#define SQR(x) (x)*(x) + +/* function declarations (implemented below). */ +void lm_lmpar( int n, double *r, int ldr, int *ipvt, double *diag, + double *qtb, double delta, double *par, double *x, + double *sdiag, double *aux, double *xdi ); +void lm_qrfac( int m, int n, double *a, int *ipvt, + double *rdiag, double *acnorm, double *wa ); +void lm_qrsolv( int n, double *r, int ldr, int *ipvt, double *diag, + double *qtb, double *x, double *sdiag, double *wa ); + + +/*****************************************************************************/ +/* Numeric constants */ +/*****************************************************************************/ + +/* machine-dependent constants from float.h */ +#define LM_MACHEP DBL_EPSILON /* resolution of arithmetic */ +#define LM_DWARF DBL_MIN /* smallest nonzero number */ +#define LM_SQRT_DWARF sqrt(DBL_MIN) /* square should not underflow */ +#define LM_SQRT_GIANT sqrt(DBL_MAX) /* square should not overflow */ +#define LM_USERTOL 30*LM_MACHEP /* users are recommended to require this */ + +/* If the above values do not work, the following seem good for an x86: + LM_MACHEP .555e-16 + LM_DWARF 9.9e-324 + LM_SQRT_DWARF 1.e-160 + LM_SQRT_GIANT 1.e150 + LM_USER_TOL 1.e-14 + The following values should work on any machine: + LM_MACHEP 1.2e-16 + LM_DWARF 1.0e-38 + LM_SQRT_DWARF 3.834e-20 + LM_SQRT_GIANT 1.304e19 + LM_USER_TOL 1.e-14 + */ + +const lm_control_struct lm_control_double = { + LM_USERTOL, LM_USERTOL, LM_USERTOL, LM_USERTOL, 100., 100, 1, + NULL, 0, -1, -1 +}; +const lm_control_struct lm_control_float = { + 1.e-7, 1.e-7, 1.e-7, 1.e-7, 100., 100, 1, + NULL, 0, -1, -1 +}; + + +/*****************************************************************************/ +/* Message texts (indexed by status.info) */ +/*****************************************************************************/ + +const char *lm_infmsg[] = { + "found zero (sum of squares below underflow limit)", + "converged (the relative error in the sum of squares is at most tol)", + "converged (the relative error of the parameter vector is at most tol)", + "converged (both errors are at most tol)", + "trapped (by degeneracy; increasing epsilon might help)", + "exhausted (number of function calls exceeding preset patience)", + "failed (ftol %18.11g\n", fnorm ); +} + + +/*****************************************************************************/ +/* lmmin (main minimization routine) */ +/*****************************************************************************/ + +void lmmin( int n, double *x, int m, const void *data, + void (*evaluate) (const double *par, int m_dat, const void *data, + double *fvec, int *userbreak), + const lm_control_struct *C, lm_status_struct *S ) +{ + double *fvec, *diag, *fjac, *qtf, *wa1, *wa2, *wa3, *wf; + int *ipvt; + int j, i; + double actred, dirder, fnorm, fnorm1, gnorm, pnorm, + prered, ratio, step, sum, temp, temp1, temp2, temp3; + static double p0001 = 1.0e-4; + + int maxfev = C->patience * (n+1); + + int outer, inner; /* loop counters, for monitoring */ + int inner_success; /* flag for loop control */ + double lmpar = 0; /* Levenberg-Marquardt parameter */ + double delta = 0; + double xnorm = 0; + double eps = sqrt(MAX(C->epsilon, LM_MACHEP)); /* for forward differences */ + + int nout = C->n_maxpri == -1 ? n : MIN( C->n_maxpri, n ); + + /* The workaround msgfile=NULL is needed for default initialization */ + FILE* msgfile = C->msgfile ? C->msgfile : stdout; + + /* Default status info; must be set ahead of first return statements */ + S->outcome = 0; /* status code */ + S->userbreak = 0; + S->nfev = 0; /* function evaluation counter */ + +/*** Check input parameters for errors. ***/ + + if (n <= 0) + { + fprintf( stderr, "lmmin: invalid number of parameters %i\n", n ); + S->outcome = 10; /* invalid parameter */ + return; + } + if (m < n) + { + fprintf( stderr, "lmmin: number of data points (%i) " + "smaller than number of parameters (%i)\n", m, n ); + S->outcome = 10; + return; + } + if (C->ftol < 0. || C->xtol < 0. || C->gtol < 0.) + { + fprintf( stderr, + "lmmin: negative tolerance (at least one of %g %g %g)\n", + C->ftol, C->xtol, C->gtol ); + S->outcome = 10; + return; + } + if (maxfev <= 0) + { + fprintf( stderr, "lmmin: nonpositive function evaluations limit %i\n", + maxfev ); + S->outcome = 10; + return; + } + if (C->stepbound <= 0.) + { + fprintf( stderr, "lmmin: nonpositive stepbound %g\n", C->stepbound ); + S->outcome = 10; + return; + } + if (C->scale_diag != 0 && C->scale_diag != 1) + { + fprintf( stderr, "lmmin: logical variable scale_diag=%i, " + "should be 0 or 1\n", C->scale_diag ); + S->outcome = 10; + return; + } + +/*** Allocate work space. ***/ + fvec = diag = fjac = qtf = wa1 = wa2 = wa3 = wf = NULL; + ipvt = NULL; + if ( (fvec = (double *) malloc(m * sizeof(double))) == NULL || + (diag = (double *) malloc(n * sizeof(double))) == NULL || + (qtf = (double *) malloc(n * sizeof(double))) == NULL || + (fjac = (double *) malloc(n*m*sizeof(double))) == NULL || + (wa1 = (double *) malloc(n * sizeof(double))) == NULL || + (wa2 = (double *) malloc(n * sizeof(double))) == NULL || + (wa3 = (double *) malloc(n * sizeof(double))) == NULL || + (wf = (double *) malloc(m * sizeof(double))) == NULL || + (ipvt = (int *) malloc(n * sizeof(int) )) == NULL) + { + S->outcome = 9; + if (NULL != fvec) + { + free(fvec); + } + if (NULL != diag) + { + free(diag); + } + if (NULL != qtf) + { + free(qtf); + } + if (NULL != fjac) + { + free(fjac); + } + if (NULL != wa1) + { + free(wa1); + } + if (NULL != wa2) + { + free(wa2); + } + if (NULL != wa3) + { + free(wa3); + } + if (NULL != wf) + { + free(wf); + } + if (NULL != ipvt) + { + free(ipvt); + } + return; + } + + if (!C->scale_diag) + { + for (j = 0; j < n; j++) + { + diag[j] = 1.; + } + } + +/*** Evaluate function at starting point and calculate norm. ***/ + + (*evaluate)( x, m, data, fvec, &(S->userbreak) ); + S->nfev = 1; + if (S->userbreak) + { + goto terminate; + } + fnorm = lm_enorm(m, fvec); + if (C->verbosity) + { + fprintf( msgfile, "lmmin start " ); + lm_print_pars( nout, x, fnorm, msgfile ); + } + if (fnorm <= LM_DWARF) + { + S->outcome = 0; /* sum of squares almost zero, nothing to do */ + goto terminate; + } + +/*** The outer loop: compute gradient, then descend. ***/ + + for (outer = 0;; ++outer) + { + +/*** [outer] Calculate the Jacobian. ***/ + + for (j = 0; j < n; j++) + { + temp = x[j]; + step = MAX(eps*eps, eps * fabs(temp)); + x[j] += step; /* replace temporarily */ + (*evaluate)( x, m, data, wf, &(S->userbreak) ); + ++(S->nfev); + if (S->userbreak) + { + goto terminate; + } + for (i = 0; i < m; i++) + { + fjac[j*m+i] = (wf[i] - fvec[i]) / step; + } + x[j] = temp; /* restore */ + } + if (C->verbosity >= 10) + { + /* print the entire matrix */ + printf("\nlmmin Jacobian\n"); + for (i = 0; i < m; i++) + { + printf(" "); + for (j = 0; j < n; j++) + { + printf("%.5e ", fjac[j*m+i]); + } + printf("\n"); + } + } + +/*** [outer] Compute the QR factorization of the Jacobian. ***/ + +/* fjac is an m by n array. The upper n by n submatrix of fjac + * is made to contain an upper triangular matrix r with diagonal + * elements of nonincreasing magnitude such that + * + * p^T*(jac^T*jac)*p = r^T*r + * + * (NOTE: ^T stands for matrix transposition), + * + * where p is a permutation matrix and jac is the final calculated + * Jacobian. Column j of p is column ipvt(j) of the identity matrix. + * The lower trapezoidal part of fjac contains information generated + * during the computation of r. + * + * ipvt is an integer array of length n. It defines a permutation + * matrix p such that jac*p = q*r, where jac is the final calculated + * Jacobian, q is orthogonal (not stored), and r is upper triangular + * with diagonal elements of nonincreasing magnitude. Column j of p + * is column ipvt(j) of the identity matrix. + */ + + lm_qrfac(m, n, fjac, ipvt, wa1, wa2, wa3); + /* return values are ipvt, wa1=rdiag, wa2=acnorm */ + +/*** [outer] Form q^T * fvec and store first n components in qtf. ***/ + + for (i = 0; i < m; i++) + { + wf[i] = fvec[i]; + } + + for (j = 0; j < n; j++) + { + temp3 = fjac[j*m+j]; + if (temp3 != 0.) + { + sum = 0; + for (i = j; i < m; i++) + { + sum += fjac[j*m+i] * wf[i]; + } + temp = -sum / temp3; + for (i = j; i < m; i++) + { + wf[i] += fjac[j*m+i] * temp; + } + } + fjac[j*m+j] = wa1[j]; + qtf[j] = wf[j]; + } + +/*** [outer] Compute norm of scaled gradient and detect degeneracy. ***/ + + gnorm = 0; + for (j = 0; j < n; j++) + { + if (wa2[ipvt[j]] == 0) + { + continue; + } + sum = 0.; + for (i = 0; i <= j; i++) + { + sum += fjac[j*m+i] * qtf[i]; + } + gnorm = MAX( gnorm, fabs( sum / wa2[ipvt[j]] / fnorm ) ); + } + + if (gnorm <= C->gtol) + { + S->outcome = 4; + goto terminate; + } + +/*** [outer] Initialize / update diag and delta. ***/ + + if (!outer) + { + /* first iteration only */ + if (C->scale_diag) + { + /* diag := norms of the columns of the initial Jacobian */ + for (j = 0; j < n; j++) + { + diag[j] = wa2[j] ? wa2[j] : 1; + } + /* xnorm := || D x || */ + for (j = 0; j < n; j++) + { + wa3[j] = diag[j] * x[j]; + } + xnorm = lm_enorm(n, wa3); + if (C->verbosity >= 2) + { + fprintf( msgfile, "lmmin diag " ); + lm_print_pars( nout, x, xnorm, msgfile ); + } + /* only now print the header for the loop table */ + if (C->verbosity >= 3) + { + fprintf( msgfile, " o i lmpar prered" + " ratio dirder delta" + " pnorm fnorm" ); + for (i = 0; i < nout; ++i) + { + fprintf( msgfile, " p%i", i ); + } + fprintf( msgfile, "\n" ); + } + } + else + { + xnorm = lm_enorm(n, x); + } + /* initialize the step bound delta. */ + if (xnorm) + { + delta = C->stepbound * xnorm; + } + else + { + delta = C->stepbound; + } + } + else + { + if (C->scale_diag) + { + for (j = 0; j < n; j++) + { + diag[j] = MAX( diag[j], wa2[j] ); + } + } + } + +/*** The inner loop. ***/ + inner = 0; + do + { + +/*** [inner] Determine the Levenberg-Marquardt parameter. ***/ + + lm_lmpar( n, fjac, m, ipvt, diag, qtf, delta, &lmpar, + wa1, wa2, wf, wa3 ); + /* used return values are fjac (partly), lmpar, wa1=x, wa3=diag*x */ + + /* predict scaled reduction */ + pnorm = lm_enorm(n, wa3); + temp2 = lmpar * SQR( pnorm / fnorm ); + for (j = 0; j < n; j++) + { + wa3[j] = 0; + for (i = 0; i <= j; i++) + { + wa3[i] -= fjac[j*m+i] * wa1[ipvt[j]]; + } + } + temp1 = SQR( lm_enorm(n, wa3) / fnorm ); + prered = temp1 + 2 * temp2; + dirder = -temp1 + temp2; /* scaled directional derivative */ + + /* at first call, adjust the initial step bound. */ + if (!outer && pnorm < delta) + { + delta = pnorm; + } + +/*** [inner] Evaluate the function at x + p. ***/ + + for (j = 0; j < n; j++) + { + wa2[j] = x[j] - wa1[j]; + } + + (*evaluate)( wa2, m, data, wf, &(S->userbreak) ); + ++(S->nfev); + if (S->userbreak) + { + goto terminate; + } + fnorm1 = lm_enorm(m, wf); + +/*** [inner] Evaluate the scaled reduction. ***/ + + /* actual scaled reduction */ + actred = 1 - SQR(fnorm1/fnorm); + + /* ratio of actual to predicted reduction */ + ratio = prered ? actred/prered : 0; + + if (C->verbosity == 2) + { + fprintf( msgfile, "lmmin (%i:%i) ", outer, inner ); + lm_print_pars( nout, wa2, fnorm1, msgfile ); + } + else if (C->verbosity >= 3) + { + printf( "%3i %2i %9.2g %9.2g %14.6g" + " %9.2g %10.3e %10.3e %21.15e", + outer, inner, lmpar, prered, ratio, + dirder, delta, pnorm, fnorm1 ); + for (i = 0; i < nout; ++i) + { + fprintf( msgfile, " %16.9g", wa2[i] ); + } + fprintf( msgfile, "\n" ); + } + + /* update the step bound */ + if (ratio <= 0.25) + { + if (actred >= 0) + { + temp = 0.5; + } + else if (actred > -99) /* -99 = 1-1/0.1^2 */ + { + temp = MAX( dirder / (2*dirder + actred), 0.1 ); + } + else + { + temp = 0.1; + } + delta = temp * MIN(delta, pnorm / 0.1); + lmpar /= temp; + } + else if (ratio >= 0.75) + { + delta = 2*pnorm; + lmpar *= 0.5; + } + else if (!lmpar) + { + delta = 2*pnorm; + } + +/*** [inner] On success, update solution, and test for convergence. ***/ + + inner_success = ratio >= p0001; + if (inner_success) + { + + /* update x, fvec, and their norms */ + if (C->scale_diag) + { + for (j = 0; j < n; j++) + { + x[j] = wa2[j]; + wa2[j] = diag[j] * x[j]; + } + } + else + { + for (j = 0; j < n; j++) + { + x[j] = wa2[j]; + } + } + for (i = 0; i < m; i++) + { + fvec[i] = wf[i]; + } + xnorm = lm_enorm(n, wa2); + fnorm = fnorm1; + } + + /* convergence tests */ + S->outcome = 0; + if (fnorm <= LM_DWARF) + { + goto terminate; /* success: sum of squares almost zero */ + } + /* test two criteria (both may be fulfilled) */ + if (fabs(actred) <= C->ftol && prered <= C->ftol && ratio <= 2) + { + S->outcome = 1; /* success: x almost stable */ + } + if (delta <= C->xtol * xnorm) + { + S->outcome += 2; /* success: sum of squares almost stable */ + } + if (S->outcome != 0) + { + goto terminate; + } + +/*** [inner] Tests for termination and stringent tolerances. ***/ + + if (S->nfev >= maxfev) + { + S->outcome = 5; + goto terminate; + } + if (fabs(actred) <= LM_MACHEP && + prered <= LM_MACHEP && ratio <= 2) + { + S->outcome = 6; + goto terminate; + } + if (delta <= LM_MACHEP*xnorm) + { + S->outcome = 7; + goto terminate; + } + if (gnorm <= LM_MACHEP) + { + S->outcome = 8; + goto terminate; + } + +/*** [inner] End of the loop. Repeat if iteration unsuccessful. ***/ + + ++inner; + } + while (!inner_success); + +/*** [outer] End of the loop. ***/ + + } + ; + +terminate: + S->fnorm = lm_enorm(m, fvec); + if (C->verbosity >= 2) + { + printf("lmmin outcome (%i) xnorm %g ftol %g xtol %g\n", + S->outcome, xnorm, C->ftol, C->xtol ); + } + if (C->verbosity & 1) + { + fprintf( msgfile, "lmmin final " ); + lm_print_pars( nout, x, S->fnorm, msgfile ); + } + if (S->userbreak) /* user-requested break */ + { + S->outcome = 11; + } + +/*** Deallocate the workspace. ***/ + free(fvec); + free(diag); + free(qtf); + free(fjac); + free(wa1); + free(wa2); + free(wa3); + free(wf); + free(ipvt); + +} /*** lmmin. ***/ + + +/*****************************************************************************/ +/* lm_lmpar (determine Levenberg-Marquardt parameter) */ +/*****************************************************************************/ + +void lm_lmpar(int n, double *r, int ldr, int *ipvt, double *diag, + double *qtb, double delta, double *par, double *x, + double *sdiag, double *aux, double *xdi) +{ +/* Given an m by n matrix a, an n by n nonsingular diagonal + * matrix d, an m-vector b, and a positive number delta, + * the problem is to determine a value for the parameter + * par such that if x solves the system + * + * a*x = b and sqrt(par)*d*x = 0 + * + * in the least squares sense, and dxnorm is the euclidean + * norm of d*x, then either par=0 and (dxnorm-delta) < 0.1*delta, + * or par>0 and abs(dxnorm-delta) < 0.1*delta. + * + * Using lm_qrsolv, this subroutine completes the solution of the problem + * if it is provided with the necessary information from the + * qr factorization, with column pivoting, of a. That is, if + * a*p = q*r, where p is a permutation matrix, q has orthogonal + * columns, and r is an upper triangular matrix with diagonal + * elements of nonincreasing magnitude, then lmpar expects + * the full upper triangle of r, the permutation matrix p, + * and the first n components of qT*b. On output + * lmpar also provides an upper triangular matrix s such that + * + * p^T*(a^T*a + par*d*d)*p = s^T*s. + * + * s is employed within lmpar and may be of separate interest. + * + * Only a few iterations are generally needed for convergence + * of the algorithm. If, however, the limit of 10 iterations + * is reached, then the output par will contain the best + * value obtained so far. + * + * parameters: + * + * n is a positive integer input variable set to the order of r. + * + * r is an n by n array. on input the full upper triangle + * must contain the full upper triangle of the matrix r. + * on OUTPUT the full upper triangle is unaltered, and the + * strict lower triangle contains the strict upper triangle + * (transposed) of the upper triangular matrix s. + * + * ldr is a positive integer input variable not less than n + * which specifies the leading dimension of the array r. + * + * ipvt is an integer input array of length n which defines the + * permutation matrix p such that a*p = q*r. column j of p + * is column ipvt(j) of the identity matrix. + * + * diag is an input array of length n which must contain the + * diagonal elements of the matrix d. + * + * qtb is an input array of length n which must contain the first + * n elements of the vector (q transpose)*b. + * + * delta is a positive input variable which specifies an upper + * bound on the euclidean norm of d*x. + * + * par is a nonnegative variable. on input par contains an + * initial estimate of the levenberg-marquardt parameter. + * on OUTPUT par contains the final estimate. + * + * x is an OUTPUT array of length n which contains the least + * squares solution of the system a*x = b, sqrt(par)*d*x = 0, + * for the output par. + * + * sdiag is an array of length n needed as workspace; on OUTPUT + * it contains the diagonal elements of the upper triangular matrix s. + * + * aux is a multi-purpose work array of length n. + * + * xdi is a work array of length n. On OUTPUT: diag[j] * x[j]. + * + */ + int i, iter, j, nsing; + double dxnorm, fp, fp_old, gnorm, parc, parl, paru; + double sum, temp; + static double p1 = 0.1; + +/*** lmpar: compute and store in x the gauss-newton direction. if the + jacobian is rank-deficient, obtain a least squares solution. ***/ + + nsing = n; + for (j = 0; j < n; j++) + { + aux[j] = qtb[j]; + if (r[j * ldr + j] == 0 && nsing == n) + { + nsing = j; + } + if (nsing < n) + { + aux[j] = 0; + } + } + for (j = nsing - 1; j >= 0; j--) + { + aux[j] = aux[j] / r[j + ldr * j]; + temp = aux[j]; + for (i = 0; i < j; i++) + { + aux[i] -= r[j * ldr + i] * temp; + } + } + + for (j = 0; j < n; j++) + { + x[ipvt[j]] = aux[j]; + } + +/*** lmpar: initialize the iteration counter, evaluate the function at the + origin, and test for acceptance of the gauss-newton direction. ***/ + + for (j = 0; j < n; j++) + { + xdi[j] = diag[j] * x[j]; + } + dxnorm = lm_enorm(n, xdi); + fp = dxnorm - delta; + if (fp <= p1 * delta) + { +#ifdef LMFIT_DEBUG_MESSAGES + printf("debug lmpar nsing %d n %d, terminate (fp= n) + { + for (j = 0; j < n; j++) + { + aux[j] = diag[ipvt[j]] * xdi[ipvt[j]] / dxnorm; + } + + for (j = 0; j < n; j++) + { + sum = 0.; + for (i = 0; i < j; i++) + { + sum += r[j * ldr + i] * aux[i]; + } + aux[j] = (aux[j] - sum) / r[j + ldr * j]; + } + temp = lm_enorm(n, aux); + parl = fp / delta / temp / temp; + } + +/*** lmpar: calculate an upper bound, paru, for the 0. of the function. ***/ + + for (j = 0; j < n; j++) + { + sum = 0; + for (i = 0; i <= j; i++) + { + sum += r[j * ldr + i] * qtb[i]; + } + aux[j] = sum / diag[ipvt[j]]; + } + gnorm = lm_enorm(n, aux); + paru = gnorm / delta; + if (paru == 0.) + { + paru = LM_DWARF / MIN(delta, p1); + } + +/*** lmpar: if the input par lies outside of the interval (parl,paru), + set par to the closer endpoint. ***/ + + *par = MAX(*par, parl); + *par = MIN(*par, paru); + if (*par == 0.) + { + *par = gnorm / dxnorm; + } + +/*** lmpar: iterate. ***/ + + for (iter = 0;; iter++) + { + + /** evaluate the function at the current value of par. **/ + + if (*par == 0.) + { + *par = MAX(LM_DWARF, 0.001 * paru); + } + temp = sqrt(*par); + for (j = 0; j < n; j++) + { + aux[j] = temp * diag[j]; + } + + lm_qrsolv( n, r, ldr, ipvt, aux, qtb, x, sdiag, xdi ); + /* return values are r, x, sdiag */ + + for (j = 0; j < n; j++) + { + xdi[j] = diag[j] * x[j]; /* used as output */ + } + dxnorm = lm_enorm(n, xdi); + fp_old = fp; + fp = dxnorm - delta; + + /** if the function is small enough, accept the current value + of par. Also test for the exceptional cases where parl + is zero or the number of iterations has reached 10. **/ + + if (fabs(fp) <= p1 * delta + || (parl == 0. && fp <= fp_old && fp_old < 0.) + || iter == 10) + { +#ifdef LMFIT_DEBUG_MESSAGES + printf("debug lmpar nsing %d iter %d " + "par %.4e [%.4e %.4e] delta %.4e fp %.4e\n", + nsing, iter, *par, parl, paru, delta, fp); +#endif + break; /* the only exit from the iteration. */ + } + + /** compute the Newton correction. **/ + + for (j = 0; j < n; j++) + { + aux[j] = diag[ipvt[j]] * xdi[ipvt[j]] / dxnorm; + } + + for (j = 0; j < n; j++) + { + aux[j] = aux[j] / sdiag[j]; + for (i = j + 1; i < n; i++) + { + aux[i] -= r[j * ldr + i] * aux[j]; + } + } + temp = lm_enorm(n, aux); + parc = fp / delta / temp / temp; + + /** depending on the sign of the function, update parl or paru. **/ + + if (fp > 0) + { + parl = MAX(parl, *par); + } + else if (fp < 0) + { + paru = MIN(paru, *par); + } + /* the case fp==0 is precluded by the break condition */ + + /** compute an improved estimate for par. **/ + + *par = MAX(parl, *par + parc); + + } + +} /*** lm_lmpar. ***/ + +/*****************************************************************************/ +/* lm_qrfac (QR factorization, from lapack) */ +/*****************************************************************************/ + +void lm_qrfac(int m, int n, double *a, int *ipvt, + double *rdiag, double *acnorm, double *wa) +{ +/* + * This subroutine uses Householder transformations with column + * pivoting (optional) to compute a qr factorization of the + * m by n matrix a. That is, qrfac determines an orthogonal + * matrix q, a permutation matrix p, and an upper trapezoidal + * matrix r with diagonal elements of nonincreasing magnitude, + * such that a*p = q*r. The Householder transformation for + * column k, k = 1,2,...,min(m,n), is of the form + * + * i - (1/u(k))*u*uT + * + * where u has zeroes in the first k-1 positions. The form of + * this transformation and the method of pivoting first + * appeared in the corresponding linpack subroutine. + * + * Parameters: + * + * m is a positive integer input variable set to the number + * of rows of a. + * + * n is a positive integer input variable set to the number + * of columns of a. + * + * a is an m by n array. On input a contains the matrix for + * which the qr factorization is to be computed. On OUTPUT + * the strict upper trapezoidal part of a contains the strict + * upper trapezoidal part of r, and the lower trapezoidal + * part of a contains a factored form of q (the non-trivial + * elements of the u vectors described above). + * + * ipvt is an integer OUTPUT array of length lipvt. This array + * defines the permutation matrix p such that a*p = q*r. + * Column j of p is column ipvt(j) of the identity matrix. + * + * rdiag is an OUTPUT array of length n which contains the + * diagonal elements of r. + * + * acnorm is an OUTPUT array of length n which contains the + * norms of the corresponding columns of the input matrix a. + * If this information is not needed, then acnorm can coincide + * with rdiag. + * + * wa is a work array of length n. + * + */ + int i, j, k, kmax, minmn; + double ajnorm, sum, temp; + +/*** qrfac: compute initial column norms and initialize several arrays. ***/ + + for (j = 0; j < n; j++) + { + acnorm[j] = lm_enorm(m, &a[j*m]); + rdiag[j] = acnorm[j]; + wa[j] = rdiag[j]; + ipvt[j] = j; + } +#ifdef LMFIT_DEBUG_MESSAGES + printf("debug qrfac\n"); +#endif + +/*** qrfac: reduce a to r with Householder transformations. ***/ + + minmn = MIN(m, n); + for (j = 0; j < minmn; j++) + { + + /** bring the column of largest norm into the pivot position. **/ + + kmax = j; + for (k = j + 1; k < n; k++) + { + if (rdiag[k] > rdiag[kmax]) + { + kmax = k; + } + } + if (kmax == j) + { + goto pivot_ok; + } + + for (i = 0; i < m; i++) + { + temp = a[j*m+i]; + a[j*m+i] = a[kmax*m+i]; + a[kmax*m+i] = temp; + } + rdiag[kmax] = rdiag[j]; + wa[kmax] = wa[j]; + k = ipvt[j]; + ipvt[j] = ipvt[kmax]; + ipvt[kmax] = k; + +pivot_ok: + /** compute the Householder transformation to reduce the + j-th column of a to a multiple of the j-th unit vector. **/ + + ajnorm = lm_enorm(m-j, &a[j*m+j]); + if (ajnorm == 0.) + { + rdiag[j] = 0; + continue; + } + + if (a[j*m+j] < 0.) + { + ajnorm = -ajnorm; + } + for (i = j; i < m; i++) + { + a[j*m+i] /= ajnorm; + } + a[j*m+j] += 1; + + /** apply the transformation to the remaining columns + and update the norms. **/ + + for (k = j + 1; k < n; k++) + { + sum = 0; + + for (i = j; i < m; i++) + { + sum += a[j*m+i] * a[k*m+i]; + } + + temp = sum / a[j + m * j]; + + for (i = j; i < m; i++) + { + a[k*m+i] -= temp * a[j*m+i]; + } + + if (rdiag[k] != 0.) + { + temp = a[m * k + j] / rdiag[k]; + temp = MAX(0., 1 - temp * temp); + rdiag[k] *= sqrt(temp); + temp = rdiag[k] / wa[k]; + if (0.05 * SQR(temp) <= LM_MACHEP) + { + rdiag[k] = lm_enorm(m-j-1, &a[m*k+j+1]); + wa[k] = rdiag[k]; + } + } + } + + rdiag[j] = -ajnorm; + } +} /*** lm_qrfac. ***/ + + +/*****************************************************************************/ +/* lm_qrsolv (linear least-squares) */ +/*****************************************************************************/ + +void lm_qrsolv(int n, double *r, int ldr, int *ipvt, double *diag, + double *qtb, double *x, double *sdiag, double *wa) +{ +/* + * Given an m by n matrix a, an n by n diagonal matrix d, + * and an m-vector b, the problem is to determine an x which + * solves the system + * + * a*x = b and d*x = 0 + * + * in the least squares sense. + * + * This subroutine completes the solution of the problem + * if it is provided with the necessary information from the + * qr factorization, with column pivoting, of a. That is, if + * a*p = q*r, where p is a permutation matrix, q has orthogonal + * columns, and r is an upper triangular matrix with diagonal + * elements of nonincreasing magnitude, then qrsolv expects + * the full upper triangle of r, the permutation matrix p, + * and the first n components of (q transpose)*b. The system + * a*x = b, d*x = 0, is then equivalent to + * + * r*z = q^T*b, p^T*d*p*z = 0, + * + * where x = p*z. If this system does not have full rank, + * then a least squares solution is obtained. On output qrsolv + * also provides an upper triangular matrix s such that + * + * p^T *(a^T *a + d*d)*p = s^T *s. + * + * s is computed within qrsolv and may be of separate interest. + * + * Parameters + * + * n is a positive integer input variable set to the order of r. + * + * r is an n by n array. On input the full upper triangle + * must contain the full upper triangle of the matrix r. + * On OUTPUT the full upper triangle is unaltered, and the + * strict lower triangle contains the strict upper triangle + * (transposed) of the upper triangular matrix s. + * + * ldr is a positive integer input variable not less than n + * which specifies the leading dimension of the array r. + * + * ipvt is an integer input array of length n which defines the + * permutation matrix p such that a*p = q*r. Column j of p + * is column ipvt(j) of the identity matrix. + * + * diag is an input array of length n which must contain the + * diagonal elements of the matrix d. + * + * qtb is an input array of length n which must contain the first + * n elements of the vector (q transpose)*b. + * + * x is an OUTPUT array of length n which contains the least + * squares solution of the system a*x = b, d*x = 0. + * + * sdiag is an OUTPUT array of length n which contains the + * diagonal elements of the upper triangular matrix s. + * + * wa is a work array of length n. + * + */ + int i, kk, j, k, nsing; + double qtbpj, sum, temp; + double _sin, _cos, _tan, _cot; /* local variables, not functions */ + +/*** qrsolv: copy r and q^T*b to preserve input and initialize s. + in particular, save the diagonal elements of r in x. ***/ + + for (j = 0; j < n; j++) + { + for (i = j; i < n; i++) + { + r[j * ldr + i] = r[i * ldr + j]; + } + x[j] = r[j * ldr + j]; + wa[j] = qtb[j]; + } +/*** qrsolv: eliminate the diagonal matrix d using a Givens rotation. ***/ + + for (j = 0; j < n; j++) + { + +/*** qrsolv: prepare the row of d to be eliminated, locating the + diagonal element using p from the qr factorization. ***/ + + if (diag[ipvt[j]] == 0.) + { + goto L90; + } + for (k = j; k < n; k++) + { + sdiag[k] = 0.; + } + sdiag[j] = diag[ipvt[j]]; + +/*** qrsolv: the transformations to eliminate the row of d modify only + a single element of qT*b beyond the first n, which is initially 0. ***/ + + qtbpj = 0.; + for (k = j; k < n; k++) + { + + /** determine a Givens rotation which eliminates the + appropriate element in the current row of d. **/ + + if (sdiag[k] == 0.) + { + continue; + } + kk = k + ldr * k; + if (fabs(r[kk]) < fabs(sdiag[k])) + { + _cot = r[kk] / sdiag[k]; + _sin = 1 / sqrt(1 + SQR(_cot)); + _cos = _sin * _cot; + } + else + { + _tan = sdiag[k] / r[kk]; + _cos = 1 / sqrt(1 + SQR(_tan)); + _sin = _cos * _tan; + } + + /** compute the modified diagonal element of r and + the modified element of ((q^T)*b,0). **/ + + r[kk] = _cos * r[kk] + _sin * sdiag[k]; + temp = _cos * wa[k] + _sin * qtbpj; + qtbpj = -_sin * wa[k] + _cos * qtbpj; + wa[k] = temp; + + /** accumulate the tranformation in the row of s. **/ + + for (i = k + 1; i < n; i++) + { + temp = _cos * r[k * ldr + i] + _sin * sdiag[i]; + sdiag[i] = -_sin * r[k * ldr + i] + _cos * sdiag[i]; + r[k * ldr + i] = temp; + } + } + +L90: + /** store the diagonal element of s and restore + the corresponding diagonal element of r. **/ + + sdiag[j] = r[j * ldr + j]; + r[j * ldr + j] = x[j]; + } + +/*** qrsolv: solve the triangular system for z. if the system is + singular, then obtain a least squares solution. ***/ + + nsing = n; + for (j = 0; j < n; j++) + { + if (sdiag[j] == 0. && nsing == n) + { + nsing = j; + } + if (nsing < n) + { + wa[j] = 0; + } + } + + for (j = nsing - 1; j >= 0; j--) + { + sum = 0; + for (i = j + 1; i < nsing; i++) + { + sum += r[j * ldr + i] * wa[i]; + } + wa[j] = (wa[j] - sum) / sdiag[j]; + } + +/*** qrsolv: permute the components of z back to components of x. ***/ + + for (j = 0; j < n; j++) + { + x[ipvt[j]] = wa[j]; + } + +} /*** lm_qrsolv. ***/ + + +/*****************************************************************************/ +/* lm_enorm (Euclidean norm) */ +/*****************************************************************************/ + +double lm_enorm(int n, const double *x) +{ +/* Given an n-vector x, this function calculates the + * euclidean norm of x. + * + * The euclidean norm is computed by accumulating the sum of + * squares in three different sums. The sums of squares for the + * small and large components are scaled so that no overflows + * occur. Non-destructive underflows are permitted. Underflows + * and overflows do not occur in the computation of the unscaled + * sum of squares for the intermediate components. + * The definitions of small, intermediate and large components + * depend on two constants, LM_SQRT_DWARF and LM_SQRT_GIANT. The main + * restrictions on these constants are that LM_SQRT_DWARF**2 not + * underflow and LM_SQRT_GIANT**2 not overflow. + * + * Parameters + * + * n is a positive integer input variable. + * + * x is an input array of length n. + */ + int i; + double agiant, s1, s2, s3, xabs, x1max, x3max, temp; + + s1 = 0; + s2 = 0; + s3 = 0; + x1max = 0; + x3max = 0; + agiant = LM_SQRT_GIANT / n; + + /** sum squares. **/ + + for (i = 0; i < n; i++) + { + xabs = fabs(x[i]); + if (xabs > LM_SQRT_DWARF) + { + if (xabs < agiant) + { + s2 += xabs * xabs; + } + else if (xabs > x1max) + { + temp = x1max / xabs; + s1 = 1 + s1 * SQR(temp); + x1max = xabs; + } + else + { + temp = xabs / x1max; + s1 += SQR(temp); + } + } + else if (xabs > x3max) + { + temp = x3max / xabs; + s3 = 1 + s3 * SQR(temp); + x3max = xabs; + } + else if (xabs != 0.) + { + temp = xabs / x3max; + s3 += SQR(temp); + } + } + + /** calculation of norm. **/ + + if (s1 != 0) + { + return x1max * sqrt(s1 + (s2 / x1max) / x1max); + } + else if (s2 != 0) + { + if (s2 >= x3max) + { + return sqrt(s2 * (1 + (x3max / s2) * (x3max * s3))); + } + else + { + return sqrt(x3max * ((s2 / x3max) + (x3max * s3))); + } + } + else + { + return x3max * sqrt(s3); + } + +} /*** lm_enorm. ***/ diff --git a/src/external/lmfit/lmmin.h b/src/external/lmfit/lmmin.h new file mode 100644 index 0000000000..3c8aa71243 --- /dev/null +++ b/src/external/lmfit/lmmin.h @@ -0,0 +1,79 @@ +/* + * Library: lmfit (Levenberg-Marquardt least squares fitting) + * + * File: lmmin.h + * + * Contents: Declarations for Levenberg-Marquardt minimization. + * + * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) + * + * License: see ../COPYING (FreeBSD) + * + * Homepage: apps.jcns.fz-juelich.de/lmfit + */ + +#ifndef LMMIN_H +#define LMMIN_H +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif + +#include "lmstruct.h" + +__BEGIN_DECLS + +/*! \brief + * Levenberg-Marquardt minimization. + * + * This routine contains the core algorithm of our library. + * + * It minimizes the sum of the squares of m nonlinear functions + * in n variables by a modified Levenberg-Marquardt algorithm. + * The function evaluation is done by the user-provided routine 'evaluate'. + * The Jacobian is then calculated by a forward-difference approximation. + * + * Parameters: + * + * \param[in] n_par The number of variables (INPUT, positive integer). + * \param par The parameters to be fitted + * x is the solution vector (INPUT/OUTPUT, array of length n). + * On input it must be set to an estimated solution. + * On output it yields the final estimate of the solution. + * + * m is the number of functions to be minimized (INPUT, positive integer). + * It must fulfill m>=n. + * + * data is a pointer that is ignored by lmmin; it is however forwarded + * to the user-supplied functions evaluate and printout. + * In a typical application, it contains experimental data to be fitted. + * + * evaluate is a user-supplied function that calculates the m functions. + * Parameters: + * n, x, m, data as above. + * fvec is an array of length m; on OUTPUT, it must contain the + * m function values for the parameter vector x. + * userbreak is an integer pointer. When *userbreak is set to a + * nonzero value, lmmin will terminate. + * + * control contains INPUT variables that control the fit algorithm, + * as declared and explained in lmstruct.h + * + * status contains OUTPUT variables that inform about the fit result, + * as declared and explained in lmstruct.h + */ +void lmmin( int n_par, double *par, int m_dat, const void *data, + void (*evaluate) (const double *par, int m_dat, const void *data, + double *fvec, int *userbreak), + const lm_control_struct *control, lm_status_struct *status ); + +/* Refined calculation of Eucledian norm. */ +double lm_enorm( int, const double * ); + +__END_DECLS +#endif /* LMMIN_H */ diff --git a/src/external/lmfit/lmstruct.h b/src/external/lmfit/lmstruct.h new file mode 100644 index 0000000000..9a220e4a50 --- /dev/null +++ b/src/external/lmfit/lmstruct.h @@ -0,0 +1,81 @@ +/* + * Library: lmfit (Levenberg-Marquardt least squares fitting) + * + * File: lmstruct.h + * + * Contents: Declarations of parameter records, used in lmmin.h and lmcurve.h + * + * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) + * + * License: see ../COPYING (FreeBSD) + * + * Homepage: apps.jcns.fz-juelich.de/lmfit + */ + +#ifndef LMSTRUCT_H +#define LMSTRUCT_H +#undef __BEGIN_DECLS +#undef __END_DECLS +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS /* empty */ +# define __END_DECLS /* empty */ +#endif +__BEGIN_DECLS + +#include + +/* Collection of input parameters for fit control. */ +typedef struct { + double ftol; /* Relative error desired in the sum of squares. + Termination occurs when both the actual and + predicted relative reductions in the sum of squares + are at most ftol. */ + double xtol; /* Relative error between last two approximations. + Termination occurs when the relative error between + two consecutive iterates is at most xtol. */ + double gtol; /* Orthogonality desired between fvec and its derivs. + Termination occurs when the cosine of the angle + between fvec and any column of the Jacobian is at + most gtol in absolute value. */ + double epsilon; /* Step used to calculate the Jacobian, should be + slightly larger than the relative error in the + user-supplied functions. */ + double stepbound; /* Used in determining the initial step bound. This + bound is set to the product of stepbound and the + Euclidean norm of diag*x if nonzero, or else to + stepbound itself. In most cases stepbound should lie + in the interval (0.1,100.0). Generally, the value + 100.0 is recommended. */ + int patience; /* Used to set the maximum number of function evaluations + to patience*(number_of_parameters+1). */ + int scale_diag; /* If 1, the variables will be rescaled internally. + Recommended value is 1. */ + FILE* msgfile; /* Progress messages will be written to this file. */ + int verbosity; /* OR'ed: 1: print some messages; 2: print Jacobian. */ + int n_maxpri; /* -1, or max number of parameters to print. */ + int m_maxpri; /* -1, or max number of residuals to print. */ +} lm_control_struct; + +/* Collection of output parameters for status info. */ +typedef struct { + double fnorm; /* norm of the residue vector fvec. */ + int nfev; /* actual number of iterations. */ + int outcome; /* Status indicator. Nonnegative values are used as index + for the message text lm_infmsg, set in lmmin.c. */ + int userbreak; /* Set when function evaluation requests termination. */ +} lm_status_struct; + +/* Preset (and recommended) control parameter settings. */ +extern const lm_control_struct lm_control_double; +extern const lm_control_struct lm_control_float; + +/* Preset message texts. */ + +extern const char *lm_infmsg[]; +extern const char *lm_shortmsg[]; + +__END_DECLS +#endif /* LMSTRUCT_H */ diff --git a/src/gromacs/CMakeLists.txt b/src/gromacs/CMakeLists.txt index deeca78c58..bd597d68d8 100644 --- a/src/gromacs/CMakeLists.txt +++ b/src/gromacs/CMakeLists.txt @@ -113,6 +113,7 @@ add_subdirectory(imd) if (NOT GMX_BUILD_MDRUN_ONLY) add_subdirectory(legacyheaders) add_subdirectory(gmxana) + add_subdirectory(correlationfunctions) add_subdirectory(statistics) add_subdirectory(analysisdata) add_subdirectory(selection) diff --git a/src/gromacs/correlationfunctions/CMakeLists.txt b/src/gromacs/correlationfunctions/CMakeLists.txt new file mode 100644 index 0000000000..6c6718af5d --- /dev/null +++ b/src/gromacs/correlationfunctions/CMakeLists.txt @@ -0,0 +1,41 @@ +# +# This file is part of the GROMACS molecular simulation package. +# +# Copyright (c) 2014, 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 GMXCORRFUNC_SOURCES *.c *.cpp) +file(GLOB LMFIT_SOURCES ${CMAKE_SOURCE_DIR}/src/external/lmfit/*.c) + +set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${GMXCORRFUNC_SOURCES} ${LMFIT_SOURCES} PARENT_SCOPE) +if (BUILD_TESTING) + add_subdirectory(tests) +endif() diff --git a/src/gromacs/gmxana/autocorr.c b/src/gromacs/correlationfunctions/autocorr.c similarity index 72% rename from src/gromacs/gmxana/autocorr.c rename to src/gromacs/correlationfunctions/autocorr.c index 9b0a13b691..159790811f 100644 --- a/src/gromacs/gmxana/autocorr.c +++ b/src/gromacs/correlationfunctions/autocorr.c @@ -34,23 +34,35 @@ * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ +/*! \internal \file + * \brief + * Implements function to compute many autocorrelation functions + * + * \author David van der Spoel + * \ingroup module_correlationfunctions + */ #include "gmxpre.h" +#include "autocorr.h" + #include #include #include +#include "gromacs/correlationfunctions/expfit.h" +#include "gromacs/correlationfunctions/integrate.h" +#include "gromacs/correlationfunctions/manyautocorrelation.h" +#include "gromacs/correlationfunctions/polynomials.h" #include "gromacs/fileio/xvgr.h" -#include "gromacs/gmxana/correl.h" -#include "gromacs/gmxana/gstat.h" #include "gromacs/legacyheaders/macros.h" #include "gromacs/legacyheaders/names.h" -#include "gromacs/legacyheaders/typedefs.h" #include "gromacs/math/vec.h" #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" +#include "gromacs/utility/real.h" #include "gromacs/utility/smalloc.h" +/*! \brief Shortcut macro to select modes. */ #define MODE(x) ((mode & (x)) == (x)) typedef struct { @@ -60,33 +72,22 @@ typedef struct { real tbeginfit, tendfit; } t_acf; +/*! \brief Global variable set true if initialization routines are called. */ static gmx_bool bACFinit = FALSE; + +/*! \brief Data structure for storing command line variables. */ static t_acf acf; enum { enNorm, enCos, enSin }; -int sffn2effn(const char **sffn) -{ - int eFitFn, i; - - eFitFn = 0; - for (i = 0; i < effnNR; i++) - { - if (sffn[i+1] && strcmp(sffn[0], sffn[i+1]) == 0) - { - eFitFn = i; - } - } - - return eFitFn; -} - +/*! \brief Routine to compute ACF using FFT. */ static void low_do_four_core(int nfour, int nframes, real c1[], real cfour[], - int nCos, gmx_bool bPadding) + int nCos) { int i = 0; + int fftcode; real aver, *ans; aver = 0.0; @@ -114,49 +115,18 @@ static void low_do_four_core(int nfour, int nframes, real c1[], real cfour[], default: gmx_fatal(FARGS, "nCos = %d, %s %d", nCos, __FILE__, __LINE__); } - for (; (i < nfour); i++) - { - cfour[i] = 0.0; - } - - if (bPadding) - { - aver /= nframes; - /* printf("aver = %g\n",aver); */ - for (i = 0; (i < nframes); i++) - { - cfour[i] -= aver; - } - } - - snew(ans, 2*nfour); - correl(cfour-1, cfour-1, nfour, ans-1); - if (bPadding) - { - for (i = 0; (i < nfour); i++) - { - cfour[i] = ans[i]+sqr(aver); - } - } - else - { - for (i = 0; (i < nfour); i++) - { - cfour[i] = ans[i]; - } - } - - sfree(ans); + fftcode = many_auto_correl(1, nframes, nfour, &cfour); } +/*! \brief Routine to comput ACF without FFT. */ static void do_ac_core(int nframes, int nout, real corr[], real c1[], int nrestart, unsigned long mode) { int j, k, j3, jk3, m, n; real ccc, cth; - rvec xj, xk, rr; + rvec xj, xk; if (nrestart < 1) { @@ -205,6 +175,8 @@ static void do_ac_core(int nframes, int nout, } else if (MODE(eacP1) || MODE(eacP2) || MODE(eacP3)) { + unsigned int mmm; + for (m = 0; (m < DIM); m++) { xj[m] = c1[j3+m]; @@ -217,11 +189,20 @@ static void do_ac_core(int nframes, int nout, printf("j: %d, k: %d, xj:(%g,%g,%g), xk:(%g,%g,%g)\n", j, k, xj[XX], xj[YY], xj[ZZ], xk[XX], xk[YY], xk[ZZ]); } - - corr[k] += LegendreP(cth, mode); /* 1.5*cth*cth-0.5; */ + mmm = 1; + if (MODE(eacP2)) + { + mmm = 2; + } + else if (MODE(eacP3)) + { + mmm = 3; + } + corr[k] += LegendreP(cth, mmm); /* 1.5*cth*cth-0.5; */ } else if (MODE(eacRcross)) { + rvec xj, xk, rr; for (m = 0; (m < DIM); m++) { xj[m] = c1[j3+m]; @@ -256,10 +237,11 @@ static void do_ac_core(int nframes, int nout, } } +/*! \brief Routine to normalize ACF, dividing by corr[0]. */ void normalize_acf(int nout, real corr[]) { - int j; - real c0; + int j; + double c0; if (debug) { @@ -273,7 +255,7 @@ void normalize_acf(int nout, real corr[]) /* Normalisation makes that c[0] = 1.0 and that other points are scaled * accordingly. */ - if (corr[0] == 0.0) + if (fabs(corr[0]) < 1e-5) { c0 = 1.0; } @@ -296,6 +278,7 @@ void normalize_acf(int nout, real corr[]) } } +/*! \brief Routine that averages ACFs. */ void average_acf(gmx_bool bVerbose, int n, int nitem, real **c1) { real c0; @@ -317,6 +300,7 @@ void average_acf(gmx_bool bVerbose, int n, int nitem, real **c1) } } +/*! \brief Normalize ACFs. */ void norm_and_scale_vectors(int nframes, real c1[], real scale) { int j, m; @@ -333,7 +317,8 @@ void norm_and_scale_vectors(int nframes, real c1[], real scale) } } -void dump_tmp(char *s, int n, real c[]) +/*! \brief Debugging */ +static void dump_tmp(char *s, int n, real c[]) { FILE *fp; int i; @@ -346,99 +331,7 @@ void dump_tmp(char *s, int n, real c[]) gmx_ffclose(fp); } -real print_and_integrate(FILE *fp, int n, real dt, real c[], real *fit, int nskip) -{ - real c0, sum; - int j; - - /* Use trapezoidal rule for calculating integral */ - sum = 0.0; - for (j = 0; (j < n); j++) - { - c0 = c[j]; - if (fp && (nskip == 0 || j % nskip == 0)) - { - fprintf(fp, "%10.3f %10.5f\n", j*dt, c0); - } - if (j > 0) - { - sum += dt*(c0+c[j-1]); - } - } - if (fp) - { - fprintf(fp, "&\n"); - if (fit) - { - for (j = 0; (j < n); j++) - { - if (nskip == 0 || j % nskip == 0) - { - fprintf(fp, "%10.3f %10.5f\n", j*dt, fit[j]); - } - } - fprintf(fp, "&\n"); - } - } - return sum*0.5; -} - -real evaluate_integral(int n, real x[], real y[], real dy[], real aver_start, - real *stddev) -{ - double sum, sum_var, w; - double sum_tail = 0, sum2_tail = 0; - int j, nsum_tail = 0; - - /* Use trapezoidal rule for calculating integral */ - if (n <= 0) - { - gmx_fatal(FARGS, "Evaluating integral: n = %d (file %s, line %d)", - n, __FILE__, __LINE__); - } - - sum = 0; - sum_var = 0; - for (j = 0; (j < n); j++) - { - w = 0; - if (j > 0) - { - w += 0.5*(x[j] - x[j-1]); - } - if (j < n-1) - { - w += 0.5*(x[j+1] - x[j]); - } - sum += w*y[j]; - if (dy) - { - /* Assume all errors are uncorrelated */ - sum_var += sqr(w*dy[j]); - } - - if ((aver_start > 0) && (x[j] >= aver_start)) - { - sum_tail += sum; - sum2_tail += sqrt(sum_var); - nsum_tail += 1; - } - } - - if (nsum_tail > 0) - { - sum = sum_tail/nsum_tail; - /* This is a worst case estimate, assuming all stddev's are correlated. */ - *stddev = sum2_tail/nsum_tail; - } - else - { - *stddev = sqrt(sum_var); - } - - return sum; -} - +/*! \brief High level ACF routine. */ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes, real c1[], real csum[], real ctmp[]) { @@ -454,7 +347,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes, /******************************************** * N O R M A L ********************************************/ - low_do_four_core(nfour, nf2, c1, csum, enNorm, FALSE); + low_do_four_core(nfour, nf2, c1, csum, enNorm); } else if (MODE(eacCos)) { @@ -470,14 +363,14 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes, } /* Cosine term of AC function */ - low_do_four_core(nfour, nf2, ctmp, cfour, enCos, FALSE); + low_do_four_core(nfour, nf2, ctmp, cfour, enCos); for (j = 0; (j < nf2); j++) { c1[j] = cfour[j]; } /* Sine term of AC function */ - low_do_four_core(nfour, nf2, ctmp, cfour, enSin, FALSE); + low_do_four_core(nfour, nf2, ctmp, cfour, enSin); for (j = 0; (j < nf2); j++) { c1[j] += cfour[j]; @@ -544,7 +437,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes, dump_tmp(buf, nf2, ctmp); } - low_do_four_core(nfour, nf2, ctmp, cfour, enNorm, FALSE); + low_do_four_core(nfour, nf2, ctmp, cfour, enNorm); if (debug) { @@ -572,7 +465,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes, sprintf(buf, "c1off%d.xvg", m); dump_tmp(buf, nf2, ctmp); } - low_do_four_core(nfour, nf2, ctmp, cfour, enNorm, FALSE); + low_do_four_core(nfour, nf2, ctmp, cfour, enNorm); if (debug) { sprintf(buf, "c1ofout%d.xvg", m); @@ -611,7 +504,7 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes, { ctmp[j] = c1[DIM*j+m]; } - low_do_four_core(nfour, nf2, ctmp, cfour, enNorm, FALSE); + low_do_four_core(nfour, nf2, ctmp, cfour, enNorm); for (j = 0; (j < nf2); j++) { csum[j] += cfour[j]; @@ -630,146 +523,6 @@ void do_four_core(unsigned long mode, int nfour, int nf2, int nframes, } } -real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose, - real tbeginfit, real tendfit, real dt, real c1[], real *fit) -{ - real fitparm[3]; - real tStart, tail_corr, sum, sumtot = 0, c_start, ct_estimate, *sig; - int i, j, jmax, nf_int; - gmx_bool bPrint; - - bPrint = bVerbose || bDebugMode(); - - if (bPrint) - { - printf("COR:\n"); - } - - if (tendfit <= 0) - { - tendfit = ncorr*dt; - } - nf_int = min(ncorr, (int)(tendfit/dt)); - sum = print_and_integrate(debug, nf_int, dt, c1, NULL, 1); - - /* Estimate the correlation time for better fitting */ - ct_estimate = 0.5*c1[0]; - for (i = 1; (i < ncorr) && (c1[i] > 0); i++) - { - ct_estimate += c1[i]; - } - ct_estimate *= dt/c1[0]; - - if (bPrint) - { - printf("COR: Correlation time (plain integral from %6.3f to %6.3f ps) = %8.5f ps\n", - 0.0, dt*nf_int, sum); - printf("COR: Relaxation times are computed as fit to an exponential:\n"); - printf("COR: %s\n", longs_ffn[fitfn]); - printf("COR: Fit to correlation function from %6.3f ps to %6.3f ps, results in a\n", tbeginfit, min(ncorr*dt, tendfit)); - } - - tStart = 0; - if (bPrint) - { - printf("COR:%11s%11s%11s%11s%11s%11s%11s\n", - "Fit from", "Integral", "Tail Value", "Sum (ps)", " a1 (ps)", - (nfp_ffn[fitfn] >= 2) ? " a2 ()" : "", - (nfp_ffn[fitfn] >= 3) ? " a3 (ps)" : ""); - } - - snew(sig, ncorr); - - if (tbeginfit > 0) - { - jmax = 3; - } - else - { - jmax = 1; - } - for (j = 0; ((j < jmax) && (tStart < tendfit) && (tStart < ncorr*dt)); j++) - { - /* Estimate the correlation time for better fitting */ - c_start = -1; - ct_estimate = 0; - for (i = 0; (i < ncorr) && (dt*i < tStart || c1[i] > 0); i++) - { - if (c_start < 0) - { - if (dt*i >= tStart) - { - c_start = c1[i]; - ct_estimate = 0.5*c1[i]; - } - } - else - { - ct_estimate += c1[i]; - } - } - if (c_start > 0) - { - ct_estimate *= dt/c_start; - } - else - { - /* The data is strange, so we need to choose somehting */ - ct_estimate = tendfit; - } - if (debug) - { - fprintf(debug, "tStart %g ct_estimate: %g\n", tStart, ct_estimate); - } - - if (fitfn == effnEXP3) - { - fitparm[0] = 0.002*ncorr*dt; - fitparm[1] = 0.95; - fitparm[2] = 0.2*ncorr*dt; - } - else - { - /* Good initial guess, this increases the probability of convergence */ - fitparm[0] = ct_estimate; - fitparm[1] = 1.0; - fitparm[2] = 1.0; - } - - /* Generate more or less appropriate sigma's */ - for (i = 0; i < ncorr; i++) - { - sig[i] = sqrt(ct_estimate+dt*i); - } - - nf_int = min(ncorr, (int)((tStart+1e-4)/dt)); - sum = print_and_integrate(debug, nf_int, dt, c1, NULL, 1); - tail_corr = do_lmfit(ncorr, c1, sig, dt, NULL, tStart, tendfit, oenv, - bDebugMode(), fitfn, fitparm, 0); - sumtot = sum+tail_corr; - if (fit && ((jmax == 1) || (j == 1))) - { - for (i = 0; (i < ncorr); i++) - { - fit[i] = fit_function(fitfn, fitparm, i*dt); - } - } - if (bPrint) - { - printf("COR:%11.4e%11.4e%11.4e%11.4e", tStart, sum, tail_corr, sumtot); - for (i = 0; (i < nfp_ffn[fitfn]); i++) - { - printf(" %11.4e", fitparm[i]); - } - printf("\n"); - } - tStart += tbeginfit; - } - sfree(sig); - - return sumtot; -} - void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, int nframes, int nitem, int nout, real **c1, real dt, unsigned long mode, int nrestart, @@ -802,7 +555,10 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, } if ((MODE(eacP3) || MODE(eacRcross)) && bFour) { - fprintf(stderr, "Can't combine mode %lu with FFT, turning off FFT\n", mode); + if (bVerbose) + { + fprintf(stderr, "Can't combine mode %lu with FFT, turning off FFT\n", mode); + } bFour = FALSE; } if (MODE(eacNormal) && MODE(eacVector)) @@ -966,6 +722,7 @@ void low_do_autocorr(const char *fn, const output_env_t oenv, const char *title, sfree(fit); } +/*! \brief Legend for selecting Legendre polynomials. */ static const char *Leg[] = { NULL, "0", "1", "2", "3", NULL }; t_pargs *add_acf_pargs(int *npargs, t_pargs *pa) @@ -988,20 +745,20 @@ t_pargs *add_acf_pargs(int *npargs, t_pargs *pa) { "-endfit", FALSE, etREAL, {&acf.tendfit}, "Time where to end the exponential fit of the correlation function, -1 is until the end" }, }; -#define NPA asize(acfpa) t_pargs *ppa; - int i; + int i, npa; - snew(ppa, *npargs+NPA); + npa = asize(pa); + snew(ppa, *npargs+npa); for (i = 0; (i < *npargs); i++) { ppa[i] = pa[i]; } - for (i = 0; (i < NPA); i++) + for (i = 0; (i < npa); i++) { ppa[*npargs+i] = acfpa[i]; } - (*npargs) += NPA; + (*npargs) += npa; acf.mode = 0; acf.nrestart = 1; @@ -1071,24 +828,3 @@ int get_acffitfn(void) return sffn2effn(s_ffn); } - -void cross_corr(int n, real f[], real g[], real corr[]) -{ - int i, j; - - if (acf.bFour) - { - correl(f-1, g-1, n, corr-1); - } - else - { - for (i = 0; (i < n); i++) - { - for (j = i; (j < n); j++) - { - corr[j-i] += f[i]*g[j]; - } - corr[i] /= (real)(n-i); - } - } -} diff --git a/src/gromacs/correlationfunctions/autocorr.h b/src/gromacs/correlationfunctions/autocorr.h new file mode 100644 index 0000000000..e408b67076 --- /dev/null +++ b/src/gromacs/correlationfunctions/autocorr.h @@ -0,0 +1,187 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2014, 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. + */ +/*! \libinternal + * \defgroup module_correlationfunctions Correlation functions + * \ingroup group_analysismodules + * \brief + * Compute correlation functions and fit analytical functions to the result. + */ +/*! \libinternal + * \file + * \brief + * Declares routine for computing autocorrelation functions + * + * \author David van der Spoel + * \inlibraryapi + * \ingroup module_correlationfunctions + */ +#ifndef GMX_AUTOCORR_H +#define GMX_AUTOCORR_H + +#include "gromacs/commandline/pargs.h" +#include "gromacs/utility/real.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \brief Normal correlation f(t)*f(t+dt) */ +#define eacNormal (1<<0) +/*! \brief Cosine correlation cos(f(t)-f(t+dt)) */ +#define eacCos (1<<1) +/*! \brief Vector correlation f(t).f(t+dt) */ +#define eacVector (1<<2) +/*! \brief Norm of cross product |f(t) (x) f(t+dt)| */ +#define eacRcross (1<<3 | eacVector) +/*! \brief Vector with Legendre polynomial of order 0 (same as vector) */ +#define eacP0 (1<<4 | eacVector) +/*! \brief Vector with Legendre polynomial of order P_1(f(t).f(t+dt)) */ +#define eacP1 (1<<5 | eacVector) +/*! \brief Vector with Legendre polynomial of order P_2(f(t).f(t+dt)) */ +#define eacP2 (1<<6 | eacVector) +/*! \brief Vector with Legendre polynomial of order P_3(f(t).f(t+dt)) */ +#define eacP3 (1<<7 | eacVector) +/*! \brief Vector with Legendre polynomial of order P_4(f(t).f(t+dt)) */ +#define eacP4 (1<<8 | eacVector) +/*! \brief Binary identy correlation (f(t) == f(t+dt)) */ +#define eacIden (1<<9) //Not supported for multiple cores + +/*! \brief + * Add commandline arguments related to autocorrelations to the existing array. + * *npargs must be initialised to the number of elements in pa, + * it will be incremented appropriately. + * + * \param npargs The number of arguments before and after (is changed in this function) + * \param[in] pa The initial argument list + * \return the new array + */ +t_pargs *add_acf_pargs(int *npargs, t_pargs *pa); + +/*! \brief + * Returns the number of points to output from a correlation function. + * Works only AFTER do_auto_corr has been called! + * \return the output length for the correlation function + */ +int get_acfnout(void); + +/*! \brief + * Returns the fitting function selected. + * Works only AFTER do_auto_corr has been called! + * \return the fit function type. + */ +int get_acffitfn(void); + +/*! \brief + * Calls low_do_autocorr (see below). add_acf_pargs has to be called before this + * can be used. + * \param[in] fn File name for xvg output (may this be NULL)? + * \param[in] oenv The output environment information + * \param[in] title is the title in the output file + * \param[in] nframes is the number of frames in the time series + * \param[in] nitem is the number of items + * \param[inout] c1 is an array of dimension [ 0 .. nitem-1 ] [ 0 .. nframes-1 ] + * on output, this array is filled with the correlation function + * to reduce storage + * \param[in] dt is the time between frames + * \param[in] mode Different types of ACF can be done, see above + * \param[in] bAver If set, all ndih C(t) functions are averaged into a single + * C(t) + */ +void do_autocorr(const char *fn, const output_env_t oenv, + const char *title, + int nframes, int nitem, real **c1, + real dt, unsigned long mode, gmx_bool bAver); + +/*! \brief + * Low level computation of autocorrelation functions + * + * do_autocorr calculates autocorrelation functions for many things. + * It takes a 2 d array containing nitem arrays of length nframes + * for each item the ACF is calculated. + * + * A number of "modes" exist for computation of the ACF controlled + * by variable mode, with the following meaning. + * + * Mode | Function + * -----------|------------ + * eacNormal | C(t) = < X (tau) * X (tau+t) > + * eacCos | C(t) = < cos (X(tau) - X(tau+t)) > + * eacIden | C(t) = < (X(tau) == X(tau+t)) > (not fully supported yet) + * eacVector | C(t) = < X(tau) * X(tau+t) + * eacP1 | C(t) = < cos (X(tau) * X(tau+t) > + * eacP2 | C(t) = 1/2 * < 3 cos (X(tau) * X(tau+t) - 1 > + * eacRcross | C(t) = < ( X(tau) * X(tau+t) )^2 > + * + * For modes eacVector, eacP1, eacP2 and eacRcross the input should be + * 3 x nframes long, where each triplet is taken as a 3D vector + * + * For mode eacCos inputdata must be in radians, not degrees! + * + * Other parameters are: + * + * \param[in] fn is output filename (.xvg) where the correlation function(s) are printed + * \param[in] oenv controls output file properties + * \param[in] title is the title in the output file + * \param[in] nframes is the number of frames in the time series + * \param[in] nitem is the number of items + * \param[in] nout + * \param[inout] c1 is an array of dimension [ 0 .. nitem-1 ] [ 0 .. nframes-1 ] + * on output, this array is filled with the correlation function + * to reduce storage + * \param[in] dt is the time between frames + * \param[in] mode Different types of ACF can be done, see above + * \param[in] nrestart is the number of steps between restarts for direct ACFs + * (i.e. without FFT) When set to 1 all points are used as + * time origin for averaging + * \param[in] bAver If set, all ndih C(t) functions are averaged into a single + * C(t) + * \param[in] bNormalize If set, all ACFs will be normalized to start at 0 + * \param[in] bVerbose If set output to console will be generated + * \param[in] tbeginfit Time to start fitting to the ACF + * \param[in] tendfit Time to end fitting to the ACF + * \param[in] nfitparm Number of fitting parameters in a multi-exponential fit + */ +void low_do_autocorr(const char *fn, const output_env_t oenv, + const char *title, int nframes, int nitem, + int nout, real **c1, real dt, unsigned long mode, + int nrestart, gmx_bool bAver, gmx_bool bNormalize, + gmx_bool bVerbose, real tbeginfit, real tendfit, + int nfitparm); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/gromacs/correlationfunctions/crosscorr.c b/src/gromacs/correlationfunctions/crosscorr.c new file mode 100644 index 0000000000..1911b5b41e --- /dev/null +++ b/src/gromacs/correlationfunctions/crosscorr.c @@ -0,0 +1,169 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2014, 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. + */ +/*! \internal + * \file + * \brief + * Implements routine for computing a cross correlation between two data sets + * + * \author David van der Spoel + * \ingroup module_correlationfunctions + */ +#include "gmxpre.h" + +#include "crosscorr.h" + +#include "gromacs/fft/fft.h" +#include "gromacs/legacyheaders/macros.h" +#include "gromacs/utility/smalloc.h" + +/*! \brief + * return the size witch the array should be after zero padding + * + * \param[in] n Factor to multiply by 2 + * \return zeroPaddingSize + */ +static int zeroPaddingSize(int n) +{ + return 2*n; +} + +/*! \brief + * Compute complex conjugate. Output in the first input variable. + * + * \param[in] in1 first complex number + * \param[in] in2 second complex number + */ +static void complexConjugatMult(double in1[], double in2[]) +{ + double res[2]; + res[0] = in1[0] * in2[0] + in1[1] * in2[1]; + res[1] = in1[0] * -in2[1] + in1[1] * in2[0]; + in1[0] = res[0]; + in1[1] = res[1]; +} + +/*! \brief + * Compute one cross correlation corr = f x g using FFT. + * + * \param[in] n number of data point + * \param[in] f first function + * \param[in] g second function + * \param[out] corr output correlation + * \param[in] fft FFT data structure + */ +static void cross_corr_low(int n, real f[], real g[], real corr[], gmx_fft_t fft) +{ + int i; + const int size = zeroPaddingSize(n); + double ** in1, ** in2; + snew(in1, size); + snew(in2, size); + + for (i = 0; i < size; i++) + { + snew(in1[i], 2); + snew(in2[i], 2); + } + + for (i = 0; i < n; i++) + { + in1[i][0] = (double)f[i]; + in1[i][1] = 0; + in2[i][0] = (double)g[i]; + in2[i][1] = 0; + } + for (; i < size; i++) + { + in1[i][0] = 0; + in1[i][1] = 0; + in2[i][0] = 0; + in2[i][1] = 0; + } + + + gmx_fft_1d(fft, GMX_FFT_FORWARD, in1, in1); + gmx_fft_1d(fft, GMX_FFT_FORWARD, in2, in2); + + for (i = 0; i < size; i++) + { + complexConjugatMult(in1[i], in2[i]); + in1[i][0] /= size; + } + gmx_fft_1d(fft, GMX_FFT_BACKWARD, in1, in1); + + for (i = 0; i < n; i++) + { + corr[i] = (real)(in1[i][0]); + } + + for (i = 0; i < size; i++) + { + sfree(in1[i]); + sfree(in2[i]); + } + + sfree(in1); + sfree(in2); + +} + +void cross_corr(int n, real f[], real g[], real corr[]) +{ + gmx_fft_t fft; + gmx_fft_init_1d(&fft, zeroPaddingSize(n), GMX_FFT_FLAG_CONSERVATIVE); + cross_corr_low( n, f, g, corr, fft); + gmx_fft_destroy(fft); + gmx_fft_cleanup(); +} + +void many_cross_corr(int nFunc, int * nData, real ** f, real ** g, real ** corr) +{ +#pragma omp parallel + //gmx_fft_t is not thread safe, so structure are allocated per thread. + { + int i; + +#pragma omp for + for (i = 0; i < nFunc; i++) + { + gmx_fft_t fft; + gmx_fft_init_1d(&fft, zeroPaddingSize(nData[i]), GMX_FFT_FLAG_CONSERVATIVE); + cross_corr_low( nData[i], f[i], g[i], corr[i], fft); + gmx_fft_destroy(fft); + } + } + gmx_fft_cleanup(); + +} diff --git a/src/gromacs/gmxana/correl.h b/src/gromacs/correlationfunctions/crosscorr.h similarity index 55% copy from src/gromacs/gmxana/correl.h copy to src/gromacs/correlationfunctions/crosscorr.h index 5851d6c28c..232e50ff0a 100644 --- a/src/gromacs/gmxana/correl.h +++ b/src/gromacs/correlationfunctions/crosscorr.h @@ -1,9 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 1991-2000, University of Groningen, The Netherlands. - * Copyright (c) 2001-2008, The GROMACS development team. - * Copyright (c) 2013,2014, by the GROMACS development team, led by + * Copyright (c) 2014, 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. @@ -34,24 +32,52 @@ * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ +/*! \libinternal + * \file + * \brief + * Declares routine for computing a cross correlation between two data sets + * + * \author David van der Spoel + * \inlibraryapi + * \ingroup module_correlationfunctions + */ +#ifndef GMX_CROSSCORR_H +#define GMX_CROSSCORR_H +#include "gromacs/utility/real.h" -#ifndef _correl_h -#define _correl_h - -#include "gromacs/fft/fft.h" -#include "gromacs/legacyheaders/typedefs.h" +#ifdef __cplusplus +extern "C" { +#endif -typedef struct { - int n; - gmx_fft_t fft_setup; - real *buf1, *buf2, *abuf; -} correl_t; +/*! \brief + * fft cross correlation algorithm. + * Computes corr = f (.) g + * + * \param[in] n number of data point + * \param[in] f First function + * \param[in] g Second function + * \param[out] corr The cross correlation + */ +void cross_corr(int n, real f[], real g[], real corr[]); -extern correl_t *init_correl(int n); -extern void done_correl(correl_t *c); +/*! \brief + * fft cross correlation algorithm. + * + * Computes corr[n] = f[n][i] (.) g[n][i], that is for nFunc + * pairs of arrays n the cross correlation is computed in parallel + * using OpenMP. + * + * \param[in] nFunc nuber of function to crosscorrelate + * \param[in] nData number of data point in eatch function + * \param[in] f 2D array of first function to crosscorrelate + * \param[in] g 2D array of second function to crosscorrelate + * \param[out] corr 2D array of the cross correlations + */ +void many_cross_corr(int nFunc, int * nData, real ** f, real ** g, real ** corr); -extern void correl(real data1[], real data2[], int n, real ans[]); -extern void four1(real data[], int nn, int isign); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/gromacs/correlationfunctions/expfit.c b/src/gromacs/correlationfunctions/expfit.c new file mode 100644 index 0000000000..704943c327 --- /dev/null +++ b/src/gromacs/correlationfunctions/expfit.c @@ -0,0 +1,698 @@ +/* + * 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, 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. + */ +/*! \internal + * \file + * \brief + * Implements routine for fitting a data set to a curve + * + * \author David van der Spoel + * \ingroup module_correlationfunctions + */ +#include "gmxpre.h" + +#include "expfit.h" + +#include +#include + +#include "external/lmfit/lmcurve.h" + +#include "gromacs/correlationfunctions/integrate.h" +#include "gromacs/fileio/xvgr.h" +#include "gromacs/legacyheaders/macros.h" +#include "gromacs/math/vec.h" +#include "gromacs/utility/fatalerror.h" +#include "gromacs/utility/futil.h" +#include "gromacs/utility/real.h" +#include "gromacs/utility/smalloc.h" + +/*! \brief Number of parameters for each fitting function */ +static const int nfp_ffn[effnNR] = { 0, 1, 2, 3, 2, 5, 7, 9, 4, 3, 6}; + +const char *s_ffn[effnNR+2] = { + NULL, "none", "exp", "aexp", "exp_exp", "vac", + "exp5", "exp7", "exp9", "erffit", "effnPRES", NULL, NULL +}; +/* We don't allow errest as a choice on the command line */ + +/*! \brief Long description for each fitting function type */ +static const char *longs_ffn[effnNR] = { + "no fit", + "y = exp(-x/a1)", + "y = a2 exp(-x/a1)", + "y = a2 exp(-x/a1) + (1-a2) exp(-x/a3)", + "y = exp(-v) (cosh(wv) + 1/w sinh(wv)), v = x/(2 a1), w = sqrt(1 - a2)", + "y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5", + "y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7", + "y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7 exp(-x/a8) + a9", + "y = 1/2*(a1+a2) - 1/2*(a1-a2)*erf( (x-a3) /a4^2)", + "y = a2 *2*a1*((exp(-x/a1)-1)*(a1/x)+1)+(1-a2)*2*a3*((exp(-x/a3)-1)*(a3/x)+1)", + "y = (1-a1) * exp(-(x/a3)^a4)*cos(x*a2) + a1*exp(-(x/a5)^a6)" +}; + +int effnNparams(int effn) +{ + if ((0 <= effn) && (effn < effnNR)) + { + return nfp_ffn[effn]; + } + else + { + return -1; + } +} + +const char *effnDescription(int effn) +{ + if ((0 <= effn) && (effn < effnNR)) + { + return longs_ffn[effn]; + } + else + { + return NULL; + } +} + +int sffn2effn(const char **sffn) +{ + int eFitFn, i; + + eFitFn = 0; + for (i = 0; i < effnNR; i++) + { + if (sffn[i+1] && strcmp(sffn[0], sffn[i+1]) == 0) + { + eFitFn = i; + } + } + + return eFitFn; +} + +/*! \brief Compute exponential function A exp(-x/tau) */ +static double myexp(double x, double A, double tau) +{ + if ((A == 0) || (tau == 0)) + { + return 0; + } + return A*exp(-x/tau); +} + +/*! \brief Compute y=(a0+a1)/2-(a0-a1)/2*erf((x-a2)/a3^2) */ +static double lmc_erffit (double x, const double *a) +{ + double erfarg; + + erfarg = (x-a[2])/(a[3]*a[3]); + return (a[0]+a[1])/2-(a[0]-a[1])*gmx_erf(erfarg); +} + +/*! \brief Compute y = exp(-x/a0) */ +static double lmc_exp_one_parm(double x, const double *a) +{ + return exp(-x/a[0]); +} + +/*! \brief Compute y = a1 exp(-x/a0) */ +static double lmc_exp_two_parm(double x, const double *a) +{ + return a[1]*exp(-x/a[0]); +} + +/*! \brief Compute y = a1 exp(-x/a0) + (1-a1) exp(-x/a2) */ +static double lmc_exp_3_parm(double x, const double *a) +{ + double e1, e2; + + e1 = exp(-x/a[0]); + e2 = exp(-x/a[2]); + return a[1]*e1 + (1-a[1])*e2; +} + +/*! \brief Compute y = a0 exp(-x/a1) + a2 exp(-x/a3) + a4 */ +static double lmc_exp_5_parm(double x, const double *a) +{ + double e1, e2; + + e1 = exp(-x/a[1]); + e2 = exp(-x/a[3]); + return a[0]*e1 + a[2]*e2 + a[4]; +} + +/*! \brief Compute y = a0 exp(-x/a1) + a2 exp(-x/a3) + a4 exp(-x/a5) + a6 */ +static double lmc_exp_7_parm(double x, const double *a) +{ + double e1, e2, e3; + + e1 = exp(-x/a[1]); + e2 = exp(-x/a[3]); + e3 = exp(-x/a[5]); + return a[0]*e1 + a[2]*e2 + a[4]*e3 + a[6]; +} + +/*! \brief Compute y = a0 exp(-x/a1) + a2 exp(-x/a3) + a4 exp(-x/a5) + a6 exp(-x/a7) + a8 */ +static double lmc_exp_9_parm(double x, const double *a) +{ + double e1, e2, e3, e4; + + e1 = exp(-x/a[1]); + e2 = exp(-x/a[3]); + e3 = exp(-x/a[5]); + e4 = exp(-x/a[7]); + return a[0]*e1 + a[2]*e2 + a[4]*e3 + a[6]*e4 + a[8]; +} + +/*! \brief Compute y = (1-a1) * exp(-(x/a3)^a4)*cos(x*a2) + a1*exp(-(x/a5)^a6) */ +static double effnPRES_fun(double x, const double *a) +{ + double term1, term2, term3; + + if (a[0] != 0) + { + term3 = a[0] * exp(-pow((x/a[4]), a[5])); + } + else + { + term3 = 0; + } + + term1 = 1-a[0]; + if (term1 != 0) + { + term2 = exp(-pow((x/a[2]), a[3])) * cos(x*a[1]); + } + else + { + term2 = 0; + } + + return term1*term2 + term3; +} + +/*! \brief Compute vac function */ +static double lmc_vac_2_parm(double x, const double *a) +{ + /* Fit to function + * + * y = 1/2 (1 - 1/w) exp(-(1+w)v) + 1/2 (1 + 1/w) exp(-(1-w)v) + * + * = exp(-v) (cosh(wv) + 1/w sinh(wv)) + * + * v = x/(2 a1) + * w = sqrt(1 - a2) + * + * For tranverse current autocorrelation functions: + * a1 = tau + * a2 = 4 tau (eta/rho) k^2 + * + */ + + double y, v, det, omega, omega2, em, ec, es; + + v = x/(2*a[0]); + det = 1 - a[1]; + em = exp(-v); + if (det != 0) + { + omega2 = fabs(det); + omega = sqrt(omega2); + if (det > 0) + { + ec = em*0.5*(exp(omega*v)+exp(-omega*v)); + es = em*0.5*(exp(omega*v)-exp(-omega*v))/omega; + } + else + { + ec = em*cos(omega*v); + es = em*sin(omega*v)/omega; + } + y = ec + es; + } + else + { + y = (1+v)*em; + } + return y; +} + +/*! \brief Compute error estimate */ +static double lmc_errest_3_parm(double x, const double *a) +{ + /* + e1 = (exp(-x/a1) - 1) + e2 = (exp(-x/a3) - 1) + v1= 2*a1 * (e1*a1/x + 1) + v2 = 2*a3 * (e2*a3/x + 1) + fun = a2*v1 + (1 - a2) * v2 + */ + double e1, e2, v1, v2; + + if (a[0] != 0) + { + e1 = exp(-x/a[0]) - 1; + } + else + { + e1 = 0; + } + if (a[2] != 0) + { + e2 = exp(-x/a[2]) - 1; + } + else + { + e2 = 0; + } + + if (x > 0) + { + v1 = 2*a[0]*(e1*a[0]/x + 1); + v2 = 2*a[2]*(e2*a[2]/x + 1); + return a[1]*v1 + (1-a[1])*v2; + } + else + { + return 0; + } +} + +/*! \brief function type for passing to fitting routine */ +typedef double (*t_lmcurve)(double x, const double *a); + +/*! \brief array of fitting functions corresponding to the pre-defined types */ +t_lmcurve lmcurves[effnNR] = { + lmc_exp_one_parm, lmc_exp_one_parm, lmc_exp_two_parm, + lmc_exp_3_parm, lmc_vac_2_parm, + lmc_exp_5_parm, lmc_exp_7_parm, + lmc_exp_9_parm, lmc_erffit, lmc_errest_3_parm, effnPRES_fun +}; + +double fit_function(int eFitFn, double *parm, double x) +{ + // TODO: check that eFitFn is within bounds + return lmcurves[eFitFn](x, parm); +} + +/*! \brief lmfit_exp supports up to 3 parameter fitting of exponential functions */ +static gmx_bool lmfit_exp(int nfit, double x[], double y[], + real ftol, int maxiter, + double parm[], gmx_bool bVerbose, + int eFitFn) +{ + double chisq, ochisq; + gmx_bool bCont; + int i, j; + lm_control_struct *control; + lm_status_struct *status; + + if ((eFitFn < 0) || (eFitFn >= effnNR)) + { + gmx_fatal(FARGS, "fitfn = %d, should be in 0..%d (%s,%d)", + effnNR-1, eFitFn, __FILE__, __LINE__); + } + + snew(control, 1); + control->ftol = ftol; + control->xtol = ftol; + control->gtol = ftol; + control->epsilon = 0.1; + control->stepbound = 100; + control->patience = maxiter; + control->scale_diag = 1; + control->msgfile = stdout; + control->verbosity = (bVerbose ? 1 : 0); + control->n_maxpri = nfp_ffn[eFitFn]; + control->m_maxpri = 0; + snew(status, 1); + /* Initial params */ + chisq = 1e12; + j = 0; + if (bVerbose) + { + fprintf(stderr, "%4s %10s Parameters\n", + "Step", "chi^2"); + } + do + { + ochisq = chisq; + + lmcurve(nfp_ffn[eFitFn], parm, nfit, x, y, + lmcurves[eFitFn], control, status); + chisq = sqr(status->fnorm); + if (bVerbose) + { + int mmm; + fprintf(stderr, "%4d %10.5e", j, chisq); + for (mmm = 0; (mmm < nfp_ffn[eFitFn]); mmm++) + { + fprintf(stderr, " %10.5e", parm[mmm]); + } + fprintf(stderr, "\n"); + } + j++; + bCont = ((fabs(ochisq - chisq) > fabs(ftol*chisq)) || + ((ochisq == chisq))); + } + while (bCont && (j < maxiter)); + if (bVerbose) + { + fprintf(stderr, "\n"); + } + + sfree(control); + sfree(status); + + return TRUE; +} + +/*! \brief See description in header file. */ +real do_lmfit(int ndata, real c1[], real sig[], real dt, real x0[], + real begintimefit, real endtimefit, const output_env_t oenv, + gmx_bool bVerbose, int eFitFn, double fitparms[], int fix) +{ + FILE *fp; + char buf[32]; + + int i, j, nparm, nfitpnts; + double integral, ttt; + double *parm, *dparm; + double *x, *y, *dy; +#ifdef GMX_DOUBLE + real ftol = 1e-16; +#else + real ftol = 1e-8; +#endif + int maxiter = 50; + + if (0 != fix) + { + fprintf(stderr, "Using fixed parameters in curve fitting is not working anymore\n"); + } + nparm = nfp_ffn[eFitFn]; + if (debug) + { + fprintf(debug, "There are %d points to fit %d vars!\n", ndata, nparm); + fprintf(debug, "Fit to function %d from %g through %g, dt=%g\n", + eFitFn, begintimefit, endtimefit, dt); + } + + snew(x, ndata); + snew(y, ndata); + snew(dy, ndata); + + j = 0; + for (i = 0; i < ndata; i++) + { + ttt = x0 ? x0[i] : dt*i; + if (ttt >= begintimefit && ttt <= endtimefit) + { + x[j] = ttt; + y[j] = c1[i]; + + /* mrqmin does not like sig to be zero */ + if (sig[i] < 1.0e-7) + { + dy[j] = 1.0e-7; + } + else + { + dy[j] = sig[i]; + } + if (debug) + { + fprintf(debug, "j= %d, i= %d, x= %g, y= %g, dy= %g\n", + j, i, x[j], y[j], dy[j]); + } + j++; + } + } + nfitpnts = j; + integral = 0; + if (nfitpnts < nparm) + { + fprintf(stderr, "Not enough data points for fitting!\n"); + } + else + { + snew(parm, nparm); + snew(dparm, nparm); + if (fitparms) + { + for (i = 0; (i < nparm); i++) + { + parm[i] = fitparms[i]; + } + } + + if (!lmfit_exp(nfitpnts, x, y, ftol, maxiter, parm, bVerbose, eFitFn)) + { + fprintf(stderr, "Fit failed!\n"); + } + else if (nparm <= 3) + { + /* Compute the integral from begintimefit */ + if (nparm == 3) + { + integral = (parm[0]*myexp(begintimefit, parm[1], parm[0]) + + parm[2]*myexp(begintimefit, 1-parm[1], parm[2])); + } + else if (nparm == 2) + { + integral = parm[0]*myexp(begintimefit, parm[1], parm[0]); + } + else if (nparm == 1) + { + integral = parm[0]*myexp(begintimefit, 1, parm[0]); + } + else + { + gmx_fatal(FARGS, "nparm = %d in file %s, line %d", + nparm, __FILE__, __LINE__); + } + + /* Generate THE output */ + if (bVerbose) + { + fprintf(stderr, "FIT: # points used in fit is: %d\n", nfitpnts); + fprintf(stderr, "FIT: %21s%21s%21s\n", + "parm0 ", "parm1 (ps) ", "parm2 (ps) "); + fprintf(stderr, "FIT: ------------------------------------------------------------\n"); + fprintf(stderr, "FIT: %8.3g +/- %8.3g%9.4g +/- %8.3g%8.3g +/- %8.3g\n", + parm[0], dparm[0], parm[1], dparm[1], parm[2], dparm[2]); + fprintf(stderr, "FIT: Integral (calc with fitted function) from %g ps to inf. is: %g\n", + begintimefit, integral); + + sprintf(buf, "test%d.xvg", nfitpnts); + fp = xvgropen(buf, "C(t) + Fit to C(t)", "Time (ps)", "C(t)", oenv); + fprintf(fp, "# parm0 = %g, parm1 = %g, parm2 = %g\n", + parm[0], parm[1], parm[2]); + for (j = 0; (j < nfitpnts); j++) + { + ttt = x0 ? x0[j] : dt*j; + fprintf(fp, "%10.5e %10.5e %10.5e\n", + ttt, c1[j], + lmcurves[eFitFn](ttt, parm)); + } + xvgrclose(fp); + } + } + if (fitparms) + { + for (i = 0; (i < nparm); i++) + { + fitparms[i] = parm[i]; + } + } + sfree(parm); + sfree(dparm); + } + + sfree(x); + sfree(y); + sfree(dy); + + return integral; +} + +/*! See description in header file. */ +real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose, + real tbeginfit, real tendfit, real dt, real c1[], real *fit) +{ + double fitparm[3]; + double tStart, tail_corr, sum, sumtot = 0, c_start, ct_estimate; + real *sig; + int i, j, jmax, nf_int; + gmx_bool bPrint; + + bPrint = bVerbose || bDebugMode(); + + if (bPrint) + { + printf("COR:\n"); + } + + if (tendfit <= 0) + { + tendfit = ncorr*dt; + } + nf_int = min(ncorr, (int)(tendfit/dt)); + sum = print_and_integrate(debug, nf_int, dt, c1, NULL, 1); + + /* Estimate the correlation time for better fitting */ + ct_estimate = 0.5*c1[0]; + for (i = 1; (i < ncorr) && (c1[i] > 0); i++) + { + ct_estimate += c1[i]; + } + ct_estimate *= dt/c1[0]; + + if (bPrint) + { + printf("COR: Correlation time (plain integral from %6.3f to %6.3f ps) = %8.5f ps\n", + 0.0, dt*nf_int, sum); + printf("COR: Relaxation times are computed as fit to an exponential:\n"); + printf("COR: %s\n", longs_ffn[fitfn]); + printf("COR: Fit to correlation function from %6.3f ps to %6.3f ps, results in a\n", tbeginfit, min(ncorr*dt, tendfit)); + } + + tStart = 0; + if (bPrint) + { + printf("COR:%11s%11s%11s%11s%11s%11s%11s\n", + "Fit from", "Integral", "Tail Value", "Sum (ps)", " a1 (ps)", + (nfp_ffn[fitfn] >= 2) ? " a2 ()" : "", + (nfp_ffn[fitfn] >= 3) ? " a3 (ps)" : ""); + } + + snew(sig, ncorr); + + if (tbeginfit > 0) + { + jmax = 3; + } + else + { + jmax = 1; + } + for (j = 0; ((j < jmax) && (tStart < tendfit) && (tStart < ncorr*dt)); j++) + { + /* Estimate the correlation time for better fitting */ + c_start = -1; + ct_estimate = 0; + for (i = 0; (i < ncorr) && (dt*i < tStart || c1[i] > 0); i++) + { + if (c_start < 0) + { + if (dt*i >= tStart) + { + c_start = c1[i]; + ct_estimate = 0.5*c1[i]; + } + } + else + { + ct_estimate += c1[i]; + } + } + if (c_start > 0) + { + ct_estimate *= dt/c_start; + } + else + { + /* The data is strange, so we need to choose somehting */ + ct_estimate = tendfit; + } + if (debug) + { + fprintf(debug, "tStart %g ct_estimate: %g\n", tStart, ct_estimate); + } + + if (fitfn == effnEXP3) + { + fitparm[0] = 0.002*ncorr*dt; + fitparm[1] = 0.95; + fitparm[2] = 0.2*ncorr*dt; + } + else + { + /* Good initial guess, this increases the probability of convergence */ + fitparm[0] = ct_estimate; + fitparm[1] = 1.0; + fitparm[2] = 1.0; + } + + /* Generate more or less appropriate sigma's */ + for (i = 0; i < ncorr; i++) + { + sig[i] = sqrt(ct_estimate+dt*i); + } + + nf_int = min(ncorr, (int)((tStart+1e-4)/dt)); + sum = print_and_integrate(debug, nf_int, dt, c1, NULL, 1); + tail_corr = do_lmfit(ncorr, c1, sig, dt, NULL, tStart, tendfit, oenv, + bDebugMode(), fitfn, fitparm, 0); + sumtot = sum+tail_corr; + if (fit && ((jmax == 1) || (j == 1))) + { + double mfp[3]; + for (i = 0; (i < 3); i++) + { + mfp[i] = fitparm[i]; + } + for (i = 0; (i < ncorr); i++) + { + fit[i] = lmcurves[fitfn](i*dt, mfp); + } + } + if (bPrint) + { + printf("COR:%11.4e%11.4e%11.4e%11.4e", tStart, sum, tail_corr, sumtot); + for (i = 0; (i < nfp_ffn[fitfn]); i++) + { + printf(" %11.4e", fitparm[i]); + } + printf("\n"); + } + tStart += tbeginfit; + } + sfree(sig); + + return sumtot; +} diff --git a/src/gromacs/correlationfunctions/expfit.h b/src/gromacs/correlationfunctions/expfit.h new file mode 100644 index 0000000000..ee75f8d711 --- /dev/null +++ b/src/gromacs/correlationfunctions/expfit.h @@ -0,0 +1,145 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2014, 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. + */ +/*! \libinternal + * \file + * \brief + * Declares routine for fitting a data set to a curve + * + * \author David van der Spoel + * \inlibraryapi + * \ingroup module_correlationfunctions + */ +#ifndef GMX_EXPFIT_H +#define GMX_EXPFIT_H + +#include "gromacs/legacyheaders/oenv.h" +#include "gromacs/utility/real.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \brief + * Enum to select fitting functions + */ +enum { + effnNONE, effnEXP1, effnEXP2, effnEXP3, effnVAC, + effnEXP5, effnEXP7, effnEXP9, effnERF, effnERREST, effnPRES, effnNR +}; + +/*! \brief + * Short name of each function type. + * This is exported for now in order to use when + * calling parse_common_args. + */ +extern const char *s_ffn[effnNR+2]; + +/*! \brief + * Returns description corresponding to the enum above, or NULL if out of range + * \param[in] effn Index + * \return Description or NULL + */ +const char *effnDescription(int effn); + +/*! \brief + * Returns number of function parameters associated with a fitting function. + * \param[in] effn Index + * \return number or -1 if index out of range + */ +int effnNparams(int effn); + +/*! \brief + * Returns corresponding to the selected enum option in sffn + * \param[in] sffn Two dimensional string array coming from parse_common_args + * \return the ffn enum + */ +int sffn2effn(const char **sffn); + +/*! \brief + * Returns the value of fit function eFitFn at x + * \param[in] eFitFn the index to the fitting function (0 .. effnNR) + * \param[in] parm Array of parameters, the length of which depends on eFitFn + * \param[in] x The value of x + * \return the value of the fit + */ +double fit_function(int eFitFn, double *parm, double x); + +/*! \brief + * Use Levenberg-Marquardt method to fit to a nfitparm parameter exponential + * or to a transverse current autocorrelation function. + * + * If x == NULL, the timestep dt will be used to create a time axis. + * \param[in] ndata Number of data points + * \param[in] c1 The data points + * \param[in] sig The standard deviation in the points + * \param[in] dt The time step + * \param[in] x The X-axis (may be NULL, see above) + * \param[in] begintimefit Starting time for fitting + * \param[in] endtimefit Ending time for fitting + * \param[in] oenv Output formatting information + * \param[in] bVerbose Should the routine write to console? + * \param[in] eFitFn Fitting function (0 .. effnNR) + * \param[out] fitparms[] + * \param[in] fix Constrains fit parameter i at it's starting value, when the i'th bit + * of fix is set. + * \return integral. + */ +real do_lmfit(int ndata, real c1[], real sig[], real dt, real *x, + real begintimefit, real endtimefit, const output_env_t oenv, + gmx_bool bVerbose, int eFitFn, double fitparms[], int fix); + +/*! \brief + * Fit an autocorrelation function to a pre-defined functional form + * + * \todo check parameters + * \param[in] ncorr + * \param[in] fitfn Fitting function (0 .. effnNR) + * \param[in] oenv Output formatting information + * \param[in] bVerbose Should the routine write to console? + * \param[in] tbeginfit Starting time for fitting + * \param[in] tendfit Ending time for fitting + * \param[in] dt The time step + * \param[in] c1 The data points + * \param[out] fit The fitting parameters + * \return the integral over the autocorrelation function? + */ +real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose, + real tbeginfit, real tendfit, real dt, real c1[], real *fit); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/gromacs/correlationfunctions/integrate.c b/src/gromacs/correlationfunctions/integrate.c new file mode 100644 index 0000000000..dc0a7ae083 --- /dev/null +++ b/src/gromacs/correlationfunctions/integrate.c @@ -0,0 +1,147 @@ +/* + * 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, 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. + */ +/*! \brief + * Implement routines for integrating a data set + * + * \author David van der Spoel + */ +#include "gmxpre.h" + +#include "integrate.h" + +#include +#include + +#include "gromacs/math/vec.h" +#include "gromacs/utility/fatalerror.h" + +/*! \brief Integrate a function and printe the integral value. */ +real print_and_integrate(FILE *fp, int n, real dt, const real c[], + const real *fit, int nskip) +{ + real c0, sum; + int j; + + /* Use trapezoidal rule for calculating integral */ + sum = 0.0; + for (j = 0; (j < n); j++) + { + c0 = c[j]; + if (fp && (nskip == 0 || j % nskip == 0)) + { + fprintf(fp, "%10.3f %10.5f\n", j*dt, c0); + } + if (j > 0) + { + sum += dt*(c0+c[j-1]); + } + } + if (fp) + { + fprintf(fp, "&\n"); + if (fit) + { + for (j = 0; (j < n); j++) + { + if (nskip == 0 || j % nskip == 0) + { + fprintf(fp, "%10.3f %10.5f\n", j*dt, fit[j]); + } + } + fprintf(fp, "&\n"); + } + } + return sum*0.5; +} + +/*! \brief Compute and return the integral of a function. */ +real evaluate_integral(int n, const real x[], const real y[], + const real dy[], real aver_start, + real *stddev) +{ + double sum, sum_var, w; + double sum_tail = 0, sum2_tail = 0; + int j, nsum_tail = 0; + + /* Use trapezoidal rule for calculating integral */ + if (n <= 0) + { + gmx_fatal(FARGS, "Evaluating integral: n = %d (file %s, line %d)", + n, __FILE__, __LINE__); + } + + sum = 0; + sum_var = 0; + for (j = 0; (j < n); j++) + { + w = 0; + if (j > 0) + { + w += 0.5*(x[j] - x[j-1]); + } + if (j < n-1) + { + w += 0.5*(x[j+1] - x[j]); + } + sum += w*y[j]; + if (dy) + { + /* Assume all errors are uncorrelated */ + sum_var += sqr(w*dy[j]); + } + + if ((aver_start > 0) && (x[j] >= aver_start)) + { + sum_tail += sum; + sum2_tail += sqrt(sum_var); + nsum_tail += 1; + } + } + + if (nsum_tail > 0) + { + sum = sum_tail/nsum_tail; + /* This is a worst case estimate, assuming all stddev's are correlated. */ + *stddev = sum2_tail/nsum_tail; + } + else + { + *stddev = sqrt(sum_var); + } + + return sum; +} diff --git a/src/gromacs/gmxana/polynomials.c b/src/gromacs/correlationfunctions/integrate.h similarity index 50% copy from src/gromacs/gmxana/polynomials.c copy to src/gromacs/correlationfunctions/integrate.h index 9f6257bfbe..2159cb9140 100644 --- a/src/gromacs/gmxana/polynomials.c +++ b/src/gromacs/correlationfunctions/integrate.h @@ -1,9 +1,7 @@ /* * 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, by the GROMACS development team, led by + * Copyright (c) 2014, 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. @@ -34,44 +32,57 @@ * 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" +/*! \libinternal + * \file + * \brief + * Declares routines for integrating a data set + * + * \author David van der Spoel + * \inlibraryapi + * \ingroup module_correlationfunctions + */ +#ifndef GMX_INTEGRATE_H +#define GMX_INTEGRATE_H -#include #include -#include "gromacs/gmxana/gstat.h" -#include "gromacs/legacyheaders/typedefs.h" -#include "gromacs/utility/fatalerror.h" +#include "gromacs/utility/real.h" -real LegendreP(real x, unsigned long m) +#ifdef __cplusplus +extern "C" { +#endif -{ - real polynomial = 0, x2, x3; +/*! \brief + * Integrate the equispaced data in c[] from 0 to n using trapezium rule. + * If fit != NULL the fit is written as well. + * \param[in] fp File pointer to write to (maybe NULL) + * \param[in] n Number of data points + * \param[in] dt The time step between data points + * \param[in] c The data set + * \param[in] fit Fit to the function that is printed too if not a NULL pointer is passed. + * \param[in] nskip Determines whether all elements are written to the output file + * (written when i % nskip == 0) + * \return The integral + */ +real print_and_integrate(FILE *fp, int n, real dt, const real c[], const real *fit, int nskip); - switch (m) - { - case eacP0: - polynomial = 1.0; - break; - case eacP1: - polynomial = x; - break; - case eacP2: - x2 = x*x; - polynomial = 1.5*x2 - 0.5; - break; - case eacP3: - x2 = x*x; - polynomial = (35*x2*x2 - 30*x2 + 3)/8; - break; - case eacP4: - x2 = x*x; - x3 = x2*x; - polynomial = (63*x3*x2 - 70*x3 + 15*x)/8; - break; - default: - gmx_fatal(FARGS, "Legendre polynomials of order %d are not supported, %s %d", - m, __FILE__, __LINE__); - } - return (polynomial); +/*! \brief + * Integrate data in y using the trapezium rule, and, if given, use dy as weighting + * + * \param[in] n The number of data points + * \param[in] x The x coordinate + * \param[in] y The y data (function values) + * \param[in] dy The uncertainties (can be NULL) + * \param[in] aver_start should be set to a value where the function has + * converged to 0. + * \param[out] stddev The standard deviation in the integral + * \return the integral + */ +real evaluate_integral(int n, const real x[], const real y[], const real dy[], real aver_start, + real *stddev); + +#ifdef __cplusplus } +#endif + +#endif diff --git a/src/gromacs/correlationfunctions/manyautocorrelation.c b/src/gromacs/correlationfunctions/manyautocorrelation.c new file mode 100644 index 0000000000..c4fb7db465 --- /dev/null +++ b/src/gromacs/correlationfunctions/manyautocorrelation.c @@ -0,0 +1,115 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2014, 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. + */ +/*! \internal \file + * \brief + * Implements function to compute many autocorrelation functions + * + * \author David van der Spoel + * \ingroup module_correlationfunctions + */ +#include "gmxpre.h" + +#include "manyautocorrelation.h" + +#include +#include +#include + +#include "gromacs/fft/fft.h" +#include "gromacs/legacyheaders/macros.h" +#include "gromacs/utility/gmxomp.h" +#include "gromacs/utility/smalloc.h" + +int many_auto_correl(int nfunc, int ndata, int nfft, real **c) +{ + #pragma omp parallel + { + typedef real complex[2]; + int i, t, j, fftcode; + gmx_fft_t fft1; + complex *in, *out; + int i0, i1; + int nthreads, thread_id; + + nthreads = gmx_omp_get_max_threads(); + thread_id = gmx_omp_get_thread_num(); + if ((0 == thread_id)) + { + // fprintf(stderr, "There are %d threads for correlation functions\n", nthreads); + } + i0 = thread_id*nfunc/nthreads; + i1 = min(nfunc, (thread_id+1)*nfunc/nthreads); + + fftcode = gmx_fft_init_1d(&fft1, nfft, GMX_FFT_FLAG_CONSERVATIVE); + /* Allocate temporary arrays */ + snew(in, nfft); + snew(out, nfft); + for (i = i0; (i < i1); i++) + { + for (j = 0; j < ndata; j++) + { + in[j][0] = c[i][j]; + in[j][1] = 0; + } + for (; (j < nfft); j++) + { + in[j][0] = in[j][1] = 0; + } + + fftcode = gmx_fft_1d(fft1, GMX_FFT_BACKWARD, (void *)in, (void *)out); + for (j = 0; j < nfft; j++) + { + in[j][0] = (out[j][0]*out[j][0] + out[j][1]*out[j][1])/nfft; + in[j][1] = 0; + } + for (; (j < nfft); j++) + { + in[j][0] = in[j][1] = 0; + } + + fftcode = gmx_fft_1d(fft1, GMX_FFT_FORWARD, (void *)in, (void *)out); + for (j = 0; (j < nfft); j++) + { + c[i][j] = out[j][0]/ndata; + } + } + /* Free the memory */ + gmx_fft_destroy(fft1); + sfree(in); + sfree(out); + } + // gmx_fft_cleanup(); + return 0; +} diff --git a/src/gromacs/gmxana/correl.h b/src/gromacs/correlationfunctions/manyautocorrelation.h similarity index 54% copy from src/gromacs/gmxana/correl.h copy to src/gromacs/correlationfunctions/manyautocorrelation.h index 5851d6c28c..160f2da71a 100644 --- a/src/gromacs/gmxana/correl.h +++ b/src/gromacs/correlationfunctions/manyautocorrelation.h @@ -1,9 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 1991-2000, University of Groningen, The Netherlands. - * Copyright (c) 2001-2008, The GROMACS development team. - * Copyright (c) 2013,2014, by the GROMACS development team, led by + * Copyright (c) 2014, 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. @@ -34,24 +32,45 @@ * 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 _correl_h -#define _correl_h +/*! \libinternal + * \file + * \brief + * Declares routine for computing many correlation functions using OpenMP + * + * \author David van der Spoel + * \inlibraryapi + * \ingroup module_correlationfunctions + */ +#ifndef GMX_MANYAUTOCORRELATION_H +#define GMX_MANYAUTOCORRELATION_H #include "gromacs/fft/fft.h" -#include "gromacs/legacyheaders/typedefs.h" +#include "gromacs/utility/real.h" -typedef struct { - int n; - gmx_fft_t fft_setup; - real *buf1, *buf2, *abuf; -} correl_t; +#ifdef __cplusplus +extern "C" { +#endif -extern correl_t *init_correl(int n); -extern void done_correl(correl_t *c); +/*! \brief + * Perform many autocorrelation calculations. + * + * This routine performs many autocorrelation function calculations using FFTs. + * The GROMACS FFT library wrapper is employed. On return the c[] arrays contain + * a symmetric function that is useful for further FFT:ing, for instance in order to + * compute spectra. + * + * The functions uses OpenMP parallellization. + * + * \param[in] nfunc Number of data functions to autocorrelate + * \param[in] ndata Number of valid data points in the data + * \param[in] nfft Length of the data arrays, this should at least be 50% larger than ndata. The c arrays will filled with zero beyond ndata before computing the correlation. + * \param[inout] c Data array of size nfunc x nfft, will also be used for output + * \return fft error code, or zero if everything went fine (see fft/fft.h) + */ +int many_auto_correl(int nfunc, int ndata, int nfft, real **c); -extern void correl(real data1[], real data2[], int n, real ans[]); -extern void four1(real data[], int nn, int isign); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/gromacs/gmxana/polynomials.c b/src/gromacs/correlationfunctions/polynomials.c similarity index 79% copy from src/gromacs/gmxana/polynomials.c copy to src/gromacs/correlationfunctions/polynomials.c index 9f6257bfbe..c5f499a17d 100644 --- a/src/gromacs/gmxana/polynomials.c +++ b/src/gromacs/correlationfunctions/polynomials.c @@ -34,44 +34,52 @@ * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ +/*! \internal \file + * \brief + * Implements help function to compute Legendre polynomials + * + * \author David van der Spoel + * \author Anders Gärdenäs + * \ingroup module_correlationfunctions + */ #include "gmxpre.h" -#include -#include +#include "polynomials.h" -#include "gromacs/gmxana/gstat.h" -#include "gromacs/legacyheaders/typedefs.h" #include "gromacs/utility/fatalerror.h" -real LegendreP(real x, unsigned long m) +real LegendreP(real x, unsigned int m) { real polynomial = 0, x2, x3; switch (m) { - case eacP0: + case 0: polynomial = 1.0; break; - case eacP1: + case 1: polynomial = x; break; - case eacP2: + case 2: x2 = x*x; polynomial = 1.5*x2 - 0.5; break; - case eacP3: + case 3: + x2 = x*x; + polynomial = (5*x2*x - 3*x )* 0.5; + break; + case 4: x2 = x*x; polynomial = (35*x2*x2 - 30*x2 + 3)/8; break; - case eacP4: + case 5: x2 = x*x; x3 = x2*x; polynomial = (63*x3*x2 - 70*x3 + 15*x)/8; break; default: - gmx_fatal(FARGS, "Legendre polynomials of order %d are not supported, %s %d", - m, __FILE__, __LINE__); + gmx_fatal(FARGS, "Legendre polynomials of order %u are not supported", m); } return (polynomial); } diff --git a/src/gromacs/gmxana/correl.h b/src/gromacs/correlationfunctions/polynomials.h similarity index 70% rename from src/gromacs/gmxana/correl.h rename to src/gromacs/correlationfunctions/polynomials.h index 5851d6c28c..5bb494e1a5 100644 --- a/src/gromacs/gmxana/correl.h +++ b/src/gromacs/correlationfunctions/polynomials.h @@ -1,9 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 1991-2000, University of Groningen, The Netherlands. - * Copyright (c) 2001-2008, The GROMACS development team. - * Copyright (c) 2013,2014, by the GROMACS development team, led by + * Copyright (c) 2014, 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. @@ -34,24 +32,35 @@ * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ +/*! \libinternal + * \file + * \brief + * Declares routine for computing a Legendre polynomial + * + * \author David van der Spoel + * \inlibraryapi + * \ingroup module_correlationfunctions + */ +#ifndef GMX_POLYNOMIALS_H +#define GMX_POLYNOMIALS_H +#include "gromacs/utility/real.h" -#ifndef _correl_h -#define _correl_h - -#include "gromacs/fft/fft.h" -#include "gromacs/legacyheaders/typedefs.h" - -typedef struct { - int n; - gmx_fft_t fft_setup; - real *buf1, *buf2, *abuf; -} correl_t; +#ifdef __cplusplus +extern "C" { +#endif -extern correl_t *init_correl(int n); -extern void done_correl(correl_t *c); +/*! \brief + * Return Legendre polynomial value Pm(x) + * http://en.wikipedia.org/wiki/Legendre_polynomials + * \param[in] x The value + * \param[in] m The order of the polynomial (0-4 are supported) + * \return Pm(x) + */ +real LegendreP(real x, unsigned int m); -extern void correl(real data1[], real data2[], int n, real ans[]); -extern void four1(real data[], int nn, int isign); +#ifdef __cplusplus +} +#endif #endif diff --git a/src/gromacs/correlationfunctions/tests/CMakeLists.txt b/src/gromacs/correlationfunctions/tests/CMakeLists.txt new file mode 100644 index 0000000000..5bb3ad4fef --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/CMakeLists.txt @@ -0,0 +1,39 @@ +# +# This file is part of the GROMACS molecular simulation package. +# +# Copyright (c) 2014, 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. + +gmx_add_unit_test(CorrelationsTest correlations-test + autocorr.cpp + correlationdataset.cpp + expfit.cpp) + diff --git a/src/gromacs/correlationfunctions/tests/autocorr.cpp b/src/gromacs/correlationfunctions/tests/autocorr.cpp new file mode 100644 index 0000000000..0bc95b38c1 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/autocorr.cpp @@ -0,0 +1,231 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2014, 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. + */ +/*! \internal \file + * \brief + * Implements test of autocorrelation function routines + * + * \author Anders Gärdenäs + * \author David van der Spoel + * \ingroup module_correlationfunctions + */ +#include "gmxpre.h" + +#include "gromacs/correlationfunctions/autocorr.h" + +#include + +#include + +#include "gromacs/correlationfunctions/expfit.h" +#include "gromacs/fft/fft.h" +#include "gromacs/legacyheaders/oenv.h" +#include "gromacs/utility/gmxassert.h" +#include "gromacs/utility/smalloc.h" +#include "gromacs/utility/uniqueptr.h" + +#include "testutils/refdata.h" +#include "testutils/testasserts.h" +#include "testutils/testfilemanager.h" + +#include "correlationdataset.h" + +namespace gmx +{ +namespace +{ + +//! Definition of pointer to class containing test data. +typedef gmx_unique_ptr::type CorrelationDataSetPointer; + +class AutocorrTest : public ::testing::Test +{ + protected: + + static int nrFrames_; + static CorrelationDataSetPointer data_; + // Need raw pointer for passing this to C routines + static t_pargs * tempArgs_; + + test::TestReferenceData refData_; + test::TestReferenceChecker checker_; + + // Use erefdataCreateMissing for creating new files + AutocorrTest( ) + : checker_(refData_.rootChecker()) + { +#ifdef GMX_DOUBLE + checker_.setDefaultTolerance(test::relativeToleranceAsFloatingPoint(1, 1e-6)); +#else + checker_.setDefaultTolerance(test::relativeToleranceAsFloatingPoint(1, 1e-3)); +#endif + } + + // Static initiation, only run once every test. + static void SetUpTestCase() + { + int n = 0; + std::string fileName = "testCOS3.xvg"; + data_ = CorrelationDataSetPointer(new CorrelationDataSet(fileName)); + nrFrames_ = data_->getNrLines(); + tempArgs_ = add_acf_pargs(&n, NULL); + } + + static void TearDownTestCase() + { + + sfree(tempArgs_); + tempArgs_ = NULL; + gmx_fft_cleanup(); + } + + void test(unsigned long mode) + { + bool bAverage = false; + bool bNormalize = true; + bool bVerbose = false; + int nrRestart = 1; + int dim = getDim(mode); + std::vector result; + + for (int i = 0; i < nrFrames_; i++) + { + for (int m = 0; m < dim; m++) + { + result.push_back(data_->getValue(m, i)); + } + } + real *ptr = static_cast(&(result[0])); + low_do_autocorr(0, 0, 0, nrFrames_, 1, + get_acfnout(), &ptr, data_->getDt(), mode, + nrRestart, bAverage, bNormalize, + bVerbose, data_->getStartTime(), data_->getEndTime(), + effnNONE); + + double testResult = 0; + for (int i = 0; i < nrFrames_; i++) + { + testResult += result[i]; + } + checker_.checkSequenceArray(nrFrames_, ptr, + "AutocorrelationFunction"); + checker_.checkReal(testResult, "Integral"); + } + + int getDim(unsigned long type) + { + switch (type) + { + case eacNormal: + return 1; + case eacVector: + return 3; + case eacCos: + return 1; + case eacRcross: + return 3; + case eacP0: + return 3; + case eacP1: + return 3; + case eacP2: + return 3; + case eacP3: + return 3; + case eacP4: + return 3; + case eacIden: + return 1; + default: + GMX_RELEASE_ASSERT(false, "Invalid auto correlation option"); + return -1; + } + + } + +}; + +int AutocorrTest::nrFrames_; +CorrelationDataSetPointer AutocorrTest::data_; +t_pargs * AutocorrTest::tempArgs_; + +TEST_F (AutocorrTest, EacNormal) +{ + test(eacNormal); +} + +TEST_F (AutocorrTest, EacCos) +{ + test(eacCos); +} + +TEST_F (AutocorrTest, EacVector) +{ + test(eacVector); +} + +TEST_F (AutocorrTest, EacRcross) +{ + test(eacRcross); +} + +TEST_F (AutocorrTest, EacP0) +{ + test(eacP0); +} + +TEST_F (AutocorrTest, EacP1) +{ + test(eacP1); +} + +TEST_F (AutocorrTest, EacP2) +{ + test(eacP2); +} + +TEST_F (AutocorrTest, EacP3) +{ + test(eacP3); +} + +TEST_F (AutocorrTest, EacP4) +{ + test(eacP4); +} + + +} + +} diff --git a/src/gromacs/gmxana/polynomials.c b/src/gromacs/correlationfunctions/tests/correlationdataset.cpp similarity index 56% rename from src/gromacs/gmxana/polynomials.c rename to src/gromacs/correlationfunctions/tests/correlationdataset.cpp index 9f6257bfbe..371ba0e9e2 100644 --- a/src/gromacs/gmxana/polynomials.c +++ b/src/gromacs/correlationfunctions/tests/correlationdataset.cpp @@ -1,9 +1,7 @@ /* * 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, by the GROMACS development team, led by + * Copyright (c) 2014, 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. @@ -34,44 +32,57 @@ * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ +/*! \internal \file + * \brief + * Implements helper class for autocorrelation tests + * + * \author Anders Gärdenäs + * \ingroup module_correlationfunctions + */ #include "gmxpre.h" -#include -#include +#include "correlationdataset.h" + +#include + +#include -#include "gromacs/gmxana/gstat.h" -#include "gromacs/legacyheaders/typedefs.h" -#include "gromacs/utility/fatalerror.h" +#include "gromacs/fileio/xvgr.h" +#include "gromacs/legacyheaders/oenv.h" +#include "gromacs/utility/smalloc.h" + +#include "testutils/testfilemanager.h" + +CorrelationDataSet::CorrelationDataSet(const std::string &fileName) +{ + std::string fileNm = gmx::test::TestFileManager::getInputFilePath(fileName.c_str()); + nrLines_ = read_xvg(fileNm.c_str(), &tempValues_, &nrColumns_); -real LegendreP(real x, unsigned long m) + dt_ = tempValues_[0][1] - tempValues_[0][0]; + startTime_ = tempValues_[0][0]; + endTime_ = tempValues_[0][nrLines_-1]; +} +CorrelationDataSet::~CorrelationDataSet() { - real polynomial = 0, x2, x3; + // Allocated in read_xvg, destroyed here. + for (int i = 0; i < nrColumns_; i++) + { + sfree(tempValues_[i]); + tempValues_[i] = NULL; + } + sfree(tempValues_); + tempValues_ = NULL; +} - switch (m) +real CorrelationDataSet::getValue(int set, int time) const +{ + if (set+1 < nrColumns_) + { + return tempValues_[set+1][time]; + } + else { - case eacP0: - polynomial = 1.0; - break; - case eacP1: - polynomial = x; - break; - case eacP2: - x2 = x*x; - polynomial = 1.5*x2 - 0.5; - break; - case eacP3: - x2 = x*x; - polynomial = (35*x2*x2 - 30*x2 + 3)/8; - break; - case eacP4: - x2 = x*x; - x3 = x2*x; - polynomial = (63*x3*x2 - 70*x3 + 15*x)/8; - break; - default: - gmx_fatal(FARGS, "Legendre polynomials of order %d are not supported, %s %d", - m, __FILE__, __LINE__); + return 0; } - return (polynomial); } diff --git a/src/gromacs/correlationfunctions/tests/correlationdataset.h b/src/gromacs/correlationfunctions/tests/correlationdataset.h new file mode 100644 index 0000000000..25af934076 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/correlationdataset.h @@ -0,0 +1,111 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2014, 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. + */ +/*! \internal \file + * \brief + * Declares helper class for autocorrelation tests + * + * \author Anders Gärdenäs + * \ingroup module_correlationfunctions + */ +#ifndef GMX_CORRELATIONDATASET_H +#define GMX_CORRELATIONDATASET_H + +#include +#include + +#include "gromacs/utility/common.h" +#include "gromacs/utility/real.h" + +class CorrelationDataSet +{ + double ** tempValues_; + + int nrLines_; + int nrColumns_; + double startTime_; + double endTime_; + double dt_; + + public: + + /*! \brief + * Constructor + * \param[in] fileName containing function to test. *.xvg + */ + explicit CorrelationDataSet(const std::string &fileName); + + /*! \brief + * Return a value at an index + * \param[in] set the set number + * \param[in] t the time index of the value + */ + real getValue(int set, int t) const; + + /*! \brief + * Return the nummber of columns + */ + int getNrColumns() const { return nrColumns_; } + + /*! \brief + * Return the nummber of Lines + */ + int getNrLines() const { return nrLines_; } + + /*! \brief + * Return the time witch the function starts at + */ + real getStartTime() const { return startTime_; } + + /*! \brief + * Return the time the function ends at + */ + real getEndTime() const { return endTime_; } + + /*! \brief + * return delta time + */ + real getDt() const { return dt_; } + + /*! \brief + * Destructor + */ + ~CorrelationDataSet(); + + private: + //! This class should not be copyable or assignable + GMX_DISALLOW_COPY_AND_ASSIGN(CorrelationDataSet); +}; + +#endif diff --git a/src/gromacs/correlationfunctions/tests/expfit.cpp b/src/gromacs/correlationfunctions/tests/expfit.cpp new file mode 100755 index 0000000000..4da434691d --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/expfit.cpp @@ -0,0 +1,206 @@ +/* + * This file is part of the GROMACS molecular simulation package. + * + * Copyright (c) 2014, 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. + */ +/*! \internal \file + * \brief + * Implements test of exponential fitting routines + * + * \author Anders Gärdenäs + * \author David van der Spoel + * \ingroup module_correlationfunctions + */ +#include "gmxpre.h" + +#include "gromacs/correlationfunctions/expfit.h" + +#include + +#include + +#include "gromacs/fileio/xvgr.h" +#include "gromacs/utility/smalloc.h" + +#include "testutils/refdata.h" +#include "testutils/testasserts.h" +#include "testutils/testfilemanager.h" + +//! Number of data files for testing. +#define expTestNrTypes 3 + +namespace gmx +{ + +namespace +{ + +class ExpfitTest : public ::testing::Test +{ + + protected: + static int nrLines_; + static std::vector values_[expTestNrTypes]; + static int nrColumns_; + static std::vector standardDev_; + static real startTime_; + static real endTime_; + static real timeDeriv_; + test::TestReferenceData refData_; + test::TestReferenceChecker checker_; + ExpfitTest( ) + : checker_(refData_.rootChecker()) + { + } + + // Static initiation, only run once every test. + static void SetUpTestCase() + { + double ** tempValues; + std::string fileName[expTestNrTypes]; + fileName[0] = test::TestFileManager::getInputFilePath("testINVEXP.xvg"); + fileName[1] = test::TestFileManager::getInputFilePath("testPRES.xvg"); + fileName[2] = test::TestFileManager::getInputFilePath("testEXP.xvg"); + for (int i = 0; i < expTestNrTypes; i++) + { + const char * name = fileName[i].c_str(); + // TODO: this assumes all files have the same length. + nrLines_ = read_xvg(name, &tempValues, &nrColumns_); + + // Generating standard deviation + if (i == 0) + { + double fac = 1.0/nrLines_; + for (int j = 0; j < nrLines_; j++) + { + standardDev_.push_back(fac); + } + timeDeriv_ = tempValues[0][1] - tempValues[0][0]; + startTime_ = tempValues[0][0]; + endTime_ = tempValues[0][nrLines_-1]; + } + + for (int j = 0; j < nrLines_; j++) + { + values_[i].push_back((real)tempValues[1][j]); + } + + // Free memory that was allocated in read_xvg + for (int i = 0; i < nrColumns_; i++) + { + sfree(tempValues[i]); + tempValues[i] = NULL; + } + sfree(tempValues); + tempValues = NULL; + } + } + + static void TearDownTestCase() + { + } + + void test(int type, double result[], double tolerance, int testType) + { + int nfitparm = effnNparams(type); + + do_lmfit(nrLines_, &values_[testType][0], &standardDev_[0], timeDeriv_, + NULL, startTime_, endTime_, NULL, false, type, result, 0); + + checker_.setDefaultTolerance(test::relativeToleranceAsFloatingPoint(1, tolerance)); + checker_.checkSequenceArray(nfitparm, result, "result"); + } +}; + + +//static var +int ExpfitTest::nrLines_; +std::vector ExpfitTest::values_[expTestNrTypes]; +int ExpfitTest::nrColumns_; +std::vector ExpfitTest::standardDev_; +real ExpfitTest::startTime_; +real ExpfitTest::endTime_; +real ExpfitTest::timeDeriv_; + +TEST_F (ExpfitTest, EffnEXP1) { + double param[] = {25}; + test(effnEXP1, param, 1e-6, 0); +} + +TEST_F (ExpfitTest, EffnEXP2) { + double param[] = {35, 0.5}; + test(effnEXP2, param, 1e-6, 0); +} + +TEST_F (ExpfitTest, EffnEXP3) { + double param[] = {45, 0.5, 5}; + test(effnEXP3, param, 1e-4, 0); +} + +TEST_F (ExpfitTest, EffnEXP5) { + double param[] = {0.5, 5, 0.5, 50, 0.002}; + test(effnEXP5, param, 1e-4, 0); +} + +TEST_F (ExpfitTest, EffnEXP7) { + double param[] = {0.5, 5, -0.02, 0.5, 0.5, 50, -0.002}; + test(effnEXP7, param, 1e-4, 0); +} + +TEST_F (ExpfitTest, EffnEXP9) { + double param[] = {2, 1200, -1, 300, 0.7, 70, 0.5, 6, -0.5}; + test(effnEXP9, param, 4e-2, 0); +} + +TEST_F (ExpfitTest, EffnERF) { + double param[] = {0.5, 0.5, 0.5, 1}; + test(effnERF, param, 1e-2, 0); +} + +TEST_F (ExpfitTest, EffnERREST) { + double param[] = {0.5, 0.7, 0.3}; + test(effnERREST, param, 1e-4, 2); +} + +TEST_F (ExpfitTest, EffnVAC) { + double param[] = {0.5, 0.05}; + test(effnVAC, param, 1e-4, 0); +} + +TEST_F (ExpfitTest, EffnPRES) { + double param[] = {0, 10, 4, 1, 0.5, 1}; + test(effnPRES, param, 1e-4, 1); +} + +} + +} diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacCos.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacCos.xml new file mode 100644 index 0000000000..34cba4032b --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacCos.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 0.99659538 + 0.99595559 + 0.9944247 + 0.99254024 + 0.99074072 + 0.98782086 + 0.98476714 + 0.98145622 + 0.97775453 + 0.97388524 + 0.96959651 + 0.96521682 + 0.96071005 + 0.95656222 + 0.95218587 + 0.94799894 + 0.94426513 + 0.94049501 + 0.93681264 + 0.93319356 + 0.93034834 + 0.92801505 + 0.92570525 + 0.92359954 + 0.92197412 + 0.92073542 + 0.92040521 + 0.91959125 + 0.91971552 + 0.91937882 + 0.92004192 + 0.92134565 + 0.92249507 + 0.92415452 + 0.92598462 + 0.92835307 + 0.93056071 + 0.93232888 + 0.93553138 + 0.93841678 + 0.94149232 + 0.9445464 + 0.94751155 + 0.95099658 + 0.95437491 + 0.95766789 + 0.96085715 + 0.96405703 + 0.96722084 + 0.97044915 + 0.97360796 + 0.97608888 + 0.97839665 + 0.98092067 + 0.98309362 + 0.9850989 + 0.98661345 + 0.98806572 + 0.98921531 + 0.989797 + 0.99024576 + 0.99059737 + 0.99045819 + 0.99015921 + 0.98907006 + 0.98829621 + 0.98710001 + 0.98538107 + 0.98345906 + 0.98124063 + 0.97880316 + 0.97668463 + 0.97459376 + 0.97177458 + 0.9690451 + 0.96629435 + 0.96378684 + 0.96081358 + 0.95825708 + 0.95578271 + 0.95307195 + 0.95074266 + 0.94830912 + 0.94601887 + 0.94421709 + 0.94242907 + 0.94094354 + 0.93951678 + 0.93832368 + 0.93808126 + 0.93739355 + 0.93729556 + 0.93707997 + 0.93724543 + 0.93773413 + 0.93849856 + 0.93898928 + 0.94032645 + 0.94162965 + 0.94294119 + 0.94477904 + 0.94679701 + 0.94860345 + 0.95079654 + 0.95264018 + 0.95462155 + 0.95684212 + 0.95912236 + 0.96142673 + 0.96361393 + 0.96516949 + 0.96719009 + 0.96904653 + 0.97105813 + 0.97231489 + 0.97363442 + 0.9752683 + 0.97622961 + 0.97773701 + 0.9781059 + 0.97861946 + 0.97946876 + 0.97965133 + 0.98004115 + 0.97992533 + 0.97962075 + 0.97891223 + 0.97828108 + 0.97720605 + 0.97623944 + 0.97527778 + 0.97370166 + 0.97211659 + 0.97065586 + 0.96862853 + 0.96749282 + 0.96519589 + 0.96352464 + 0.96173507 + 0.9598251 + 0.9585008 + 0.95661891 + 0.95462286 + 0.95305181 + 0.951231 + 0.95024604 + 0.94892341 + 0.94788772 + 0.94696826 + 0.94605809 + 0.94519788 + 0.94469965 + 0.94453776 + 0.94388711 + 0.94351792 + 0.94364196 + 0.94375587 + 0.94424397 + 0.94460499 + 0.94499773 + 0.94563341 + 0.94637001 + 0.94729853 + 0.94789016 + 0.9492957 + 0.95013034 + 0.95128489 + 0.95289272 + 0.9538911 + 0.95517474 + 0.95651346 + 0.95739591 + 0.95905453 + 0.95995909 + 0.96129471 + 0.96225822 + 0.96320486 + 0.96370006 + 0.96436906 + 0.96505266 + 0.96569002 + 0.96630496 + 0.96670491 + 0.96745616 + 0.96741182 + 0.96750134 + 0.96715963 + 0.96682173 + 0.96666759 + 0.96608764 + 0.96583378 + 0.96554524 + 0.9645654 + 0.96389264 + 0.96256238 + 0.96151811 + 0.96107018 + 0.96008974 + 0.95841819 + 0.95736814 + 0.95627117 + 0.95525789 + 0.95427847 + 0.9530521 + 0.95182502 + 0.95049888 + 0.94935501 + 0.94850504 + 0.9477604 + 0.94666183 + 0.9459089 + 0.94507974 + 0.94467252 + 0.94344991 + 0.9432252 + 0.94265378 + 0.94217145 + 0.94254112 + 0.94218564 + 0.94258451 + 0.94247329 + 0.94219875 + 0.94211328 + 0.94299912 + 0.94275576 + 0.94383633 + 0.94452924 + 0.94524854 + 0.94583327 + 0.9464516 + 0.94671708 + 0.94742924 + 0.94788718 + 0.94856435 + 0.94880164 + 0.94944811 + 0.94974619 + 0.95041901 + 0.95081389 + 0.95117909 + 0.95128679 + 0.95191312 + 0.95196861 + 0.95284516 + 0.95309955 + 0.9532634 + 0.95333052 + 0.95380241 + 0.95404249 + 0.9541797 + 0.0019043376 + 0.0019041657 + 0.0019034834 + 0.00190268 + 0.0019021333 + 0.0019006877 + 0.0018999804 + 0.0018984226 + 0.0018965704 + 0.0018964604 + 0.0018947892 + 0.0018918787 + 0.0018907072 + 0.0018881153 + 0.0018871488 + 0.0018849894 + 0.0018837301 + 0.0018808114 + 0.0018789673 + 0.0018766357 + 0.0018757449 + 0.0018735129 + 0.0018722961 + 0.0018701779 + 0.001869004 + 0.0018674148 + 0.0018670724 + 0.0018658802 + 0.0018650054 + 0.0018644506 + 0.0018642544 + 0.0018643636 + 0.0018631493 + 0.0018632679 + 0.0018620805 + 0.0018617192 + 0.0018613907 + 0.0018620746 + 0.0018608437 + 0.0018616359 + 0.0018607891 + 0.001861356 + 0.0018617494 + 0.001862596 + 0.0018628497 + 0.0018639539 + 0.0018633736 + 0.0018630736 + 0.0018636734 + 0.001863839 + 0.0018648139 + 0.0018641106 + 0.0018644318 + 0.0018650938 + 0.0018654467 + 0.0018659889 + 0.0018662841 + 0.0018667069 + 0.0018669292 + 0.0018671628 + 0.0018675444 + 0.0018667035 + 0.0018655404 + 0.0018652284 + 0.0018667565 + 0.0018661944 + 0.0018663721 + 0.0018655302 + 0.0018643311 + 0.0018638286 + 0.0018621223 + 0.0018611329 + 0.0018599476 + 0.0018590478 + 0.0018587873 + 0.0018562102 + 0.0018557633 + 0.0018540745 + 0.001852081 + 0.0018499735 + 0.0018468326 + 0.0018452632 + 0.0018442717 + 0.0018425027 + 0.001839547 + 0.0018376643 + 0.001836191 + 0.0018344159 + 0.0018318044 + 0.0018301884 + 0.0018287364 + 0.0018269665 + 0.0018269968 + 0.0018270178 + 0.001825763 + 0.001825764 + 0.0018249867 + 0.0018219111 + 0.0018208193 + 0.0018213706 + 0.0018203714 + 0.0018217162 + 0.0018197326 + 0.0018210115 + 0.0018215602 + 0.0018208514 + 0.0018214376 + 0.0018191702 + 0.0018200848 + 0.0018206243 + 0.0018204382 + 0.001820185 + 0.0018186562 + 0.001817708 + 0.0018170066 + 0.0018171553 + 0.0018157695 + 0.0018159969 + 0.0018166977 + 0.0018168332 + 0.0018161659 + 0.0018163385 + 0.0018147173 + 0.0018156185 + 0.0018148925 + 0.0018124133 + 0.0018126937 + 0.0018113267 + 0.0018111287 + 0.0018093445 + 0.0018067171 + 0.0018067758 + 0.0018042427 + 0.0018018567 + 0.0017997391 + 0.0017981781 + 0.0017945498 + 0.001792311 + 0.0017904965 + 0.0017866502 + 0.0017860316 + 0.0017839982 + 0.0017814568 + 0.0017791466 + 0.0017781249 + 0.0017757714 + 0.0017761824 + 0.0017732615 + 0.0017709045 + 0.001768977 + 0.0017683667 + 0.0017667006 + 0.0017635585 + 0.0017620071 + 0.0017606486 + 0.0017580282 + 0.0017592428 + 0.0017556297 + 0.0017555061 + 0.001757534 + 0.0017574723 + 0.0017552145 + 0.0017545033 + 0.0017526622 + 0.0017496244 + 0.0017489279 + 0.0017457242 + 0.0017463452 + 0.0017450341 + 0.0017423715 + 0.001740228 + 0.0017355961 + 0.0017338913 + 0.0017318379 + 0.0017262439 + 0.0017226909 + 0.0017175399 + 0.0017158915 + 0.0017132005 + 0.0017120165 + 0.0017087469 + 0.0017068728 + 0.0017077745 + 0.0017095149 + 0.0017067558 + 0.0017066813 + 0.0017082159 + 0.0017052331 + 0.0017099206 + 0.0017054603 + 0.0017075579 + 0.001708627 + 0.0017047788 + 0.0017065253 + 0.0017045407 + 0.0017063328 + 0.001704243 + 0.001700534 + 0.0016963967 + 0.0016906861 + 0.0016869787 + 0.0016800896 + 0.001670838 + 0.0016614879 + 0.001651187 + 0.0016429743 + 0.0016380887 + 0.0016310038 + 0.0016253163 + 0.0016181563 + 0.0016086341 + 0.0016025983 + 0.0016049559 + 0.0016046603 + 0.0016040681 + 0.0016056809 + 0.0016082647 + 0.0016130897 + 0.0016240891 + 0.0016315721 + 0.0016403538 + 0.0016394467 + 0.0016503835 + 0.001656802 + 0.0016618307 + 0.0016678922 + 0.0016689304 + 0.0016764619 + 0.0016659491 + 0.0016657002 + 0.0016543285 + 0.0016382602 + 0.001622049 + 0.0015983427 + 0.00157369 + 0.0015392378 + 0.0014979994 + 0.0014626513 + 0.0014293678 + 0.0013948255 + 0.001376386 + 0.0013290521 + 0.0013200026 + 0.0012772934 + 0.0012205912 + 0.0011777489 + 0.0011112116 + 0.0010400851 + 0.00094952446 + 0.00096428557 + + 240.60057076136582 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacNormal.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacNormal.xml new file mode 100644 index 0000000000..415cf1f556 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacNormal.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 0.92333996 + 0.89544791 + 0.85506064 + 0.80770195 + 0.76355565 + 0.70085573 + 0.63575351 + 0.56621635 + 0.49021092 + 0.41346616 + 0.32695487 + 0.23947404 + 0.15114491 + 0.068911292 + -0.018343732 + -0.10222372 + -0.17851034 + -0.2556752 + -0.33233142 + -0.40906069 + -0.47129509 + -0.52546626 + -0.577564 + -0.62862134 + -0.66793829 + -0.70031446 + -0.71649045 + -0.73871797 + -0.74570811 + -0.75775838 + -0.75111836 + -0.73185968 + -0.71327382 + -0.68468153 + -0.65119308 + -0.60643828 + -0.56428039 + -0.52878588 + -0.46647781 + -0.40880191 + -0.34746397 + -0.28559166 + -0.22607948 + -0.15521984 + -0.087527938 + -0.021420239 + 0.042880654 + 0.10628833 + 0.169659 + 0.23284768 + 0.29287171 + 0.33996987 + 0.3846795 + 0.4326345 + 0.47152123 + 0.50605392 + 0.53039247 + 0.552634 + 0.57193202 + 0.57857972 + 0.58289105 + 0.5867179 + 0.57858908 + 0.57083881 + 0.54604369 + 0.52723479 + 0.50264382 + 0.4660213 + 0.42628899 + 0.38307241 + 0.33706102 + 0.29605037 + 0.25652972 + 0.20322086 + 0.15179904 + 0.1005994 + 0.053715136 + -0.0024519849 + -0.051181242 + -0.098006107 + -0.15021549 + -0.19438037 + -0.2419212 + -0.28681141 + -0.32269096 + -0.35785615 + -0.38878986 + -0.41733515 + -0.44138661 + -0.44811302 + -0.46269119 + -0.46645734 + -0.47144547 + -0.47026828 + -0.46132591 + -0.44804862 + -0.43905067 + -0.41386977 + -0.38871932 + -0.36298344 + -0.32728449 + -0.28807318 + -0.25138158 + -0.20809993 + -0.17095725 + -0.13121751 + -0.086369112 + -0.040557165 + 0.0057886061 + 0.050152354 + 0.082554683 + 0.12262377 + 0.15991174 + 0.19901413 + 0.22433081 + 0.25093538 + 0.28274411 + 0.30066779 + 0.33021459 + 0.33629516 + 0.34645689 + 0.3629137 + 0.36620525 + 0.37430125 + 0.37234989 + 0.36795545 + 0.35466814 + 0.34249428 + 0.32283241 + 0.30485228 + 0.28708842 + 0.25817123 + 0.22833388 + 0.20199309 + 0.16451561 + 0.14491151 + 0.10192882 + 0.071294688 + 0.03886297 + 0.0038909942 + -0.020299936 + -0.055376183 + -0.092676423 + -0.12172776 + -0.15591128 + -0.17435807 + -0.19855703 + -0.21759604 + -0.2342567 + -0.2501609 + -0.26639262 + -0.27480033 + -0.2769354 + -0.28888217 + -0.29434624 + -0.29110822 + -0.28738263 + -0.27644756 + -0.26865044 + -0.26017156 + -0.24633232 + -0.22993366 + -0.21036342 + -0.19680807 + -0.16794714 + -0.14982072 + -0.1253354 + -0.091874786 + -0.070614971 + -0.043464452 + -0.01496042 + 0.0054097059 + 0.039536409 + 0.058995754 + 0.087431222 + 0.10856776 + 0.12864889 + 0.14001396 + 0.15372792 + 0.16890197 + 0.1832682 + 0.19547278 + 0.20601526 + 0.22224233 + 0.22276327 + 0.22658545 + 0.22071175 + 0.21529464 + 0.21472976 + 0.20628634 + 0.2043854 + 0.20099047 + 0.18452412 + 0.17380331 + 0.15045828 + 0.13115592 + 0.1251017 + 0.10887553 + 0.079097189 + 0.061385516 + 0.043582208 + 0.026112026 + 0.01028904 + -0.011082372 + -0.031485982 + -0.055357713 + -0.075118855 + -0.088119961 + -0.098915316 + -0.11735611 + -0.12887773 + -0.14123638 + -0.1465044 + -0.16701357 + -0.16918446 + -0.17741001 + -0.18355082 + -0.17439707 + -0.17841232 + -0.16846335 + -0.16889346 + -0.17227842 + -0.17070685 + -0.15092036 + -0.15334848 + -0.12954405 + -0.11295433 + -0.09564729 + -0.080270432 + -0.06479656 + -0.055495787 + -0.03828676 + -0.026680976 + -0.0092150476 + -0.0018779703 + 0.014258126 + 0.023644734 + 0.040185757 + 0.050761189 + 0.060287103 + 0.065608293 + 0.080362737 + 0.083356142 + 0.10414003 + 0.11332227 + 0.12000805 + 0.12286837 + 0.13463314 + 0.14336015 + 0.15017572 + 1.6947948e-05 + 1.720169e-05 + 1.6974916e-05 + 1.6350099e-05 + 1.6009559e-05 + 1.4935715e-05 + 1.4739877e-05 + 1.3568673e-05 + 1.1884022e-05 + 1.2356072e-05 + 1.0829273e-05 + 8.1364569e-06 + 7.3827168e-06 + 5.0695448e-06 + 4.5629454e-06 + 2.6695732e-06 + 1.858061e-06 + -7.2692512e-07 + -2.3541625e-06 + -4.3265563e-06 + -4.8195097e-06 + -6.7002338e-06 + -7.7089944e-06 + -9.5448968e-06 + -1.0355448e-05 + -1.1747778e-05 + -1.1522758e-05 + -1.2354542e-05 + -1.2857619e-05 + -1.2877535e-05 + -1.2482141e-05 + -1.186068e-05 + -1.2711519e-05 + -1.2115619e-05 + -1.2809192e-05 + -1.266307e-05 + -1.2433168e-05 + -1.1129104e-05 + -1.1863392e-05 + -1.0522874e-05 + -1.081662e-05 + -9.6362273e-06 + -8.5478041e-06 + -7.0708343e-06 + -6.063261e-06 + -4.2370298e-06 + -4.242017e-06 + -3.9379211e-06 + -2.6455057e-06 + -1.8623408e-06 + -1.7964911e-07 + -3.1073461e-07 + 7.3710947e-07 + 2.2396036e-06 + 3.2355663e-06 + 4.1354356e-06 + 4.9965174e-06 + 6.2143517e-06 + 7.0087376e-06 + 7.9398487e-06 + 9.170898e-06 + 8.7619237e-06 + 8.1867083e-06 + 8.5060901e-06 + 1.0517992e-05 + 1.0658181e-05 + 1.1446352e-05 + 1.1257342e-05 + 1.0835259e-05 + 1.072865e-05 + 9.7357661e-06 + 9.4389143e-06 + 8.8261058e-06 + 8.7821072e-06 + 9.2549853e-06 + 7.5013804e-06 + 7.9371293e-06 + 6.941314e-06 + 5.6119507e-06 + 4.2042116e-06 + 1.5770001e-06 + 7.5386652e-07 + 8.054601e-07 + -3.8413035e-07 + -2.7380775e-06 + -3.8733256e-06 + -4.4854164e-06 + -5.4874358e-06 + -7.7627155e-06 + -8.8810702e-06 + -9.6242529e-06 + -1.0713777e-05 + -9.7594111e-06 + -9.1061747e-06 + -9.9740464e-06 + -9.1629045e-06 + -9.3594572e-06 + -1.1867382e-05 + -1.2593795e-05 + -1.108304e-05 + -1.1341308e-05 + -9.0508356e-06 + -1.0283045e-05 + -7.9569845e-06 + -6.1125238e-06 + -5.6901622e-06 + -3.8499225e-06 + -5.0997382e-06 + -2.6763032e-06 + -6.1861641e-07 + 5.3073882e-07 + 1.6471934e-06 + 1.2461007e-06 + 1.3127881e-06 + 1.6117941e-06 + 3.1619384e-06 + 2.479977e-06 + 3.9845995e-06 + 5.5477849e-06 + 6.7357323e-06 + 6.96196e-06 + 8.1697226e-06 + 7.3396232e-06 + 9.1672227e-06 + 9.2835489e-06 + 7.8686735e-06 + 9.2934297e-06 + 9.3312292e-06 + 1.0179395e-05 + 9.534755e-06 + 7.9119627e-06 + 8.8005272e-06 + 7.683404e-06 + 6.0959087e-06 + 5.5420546e-06 + 5.3878371e-06 + 3.0048875e-06 + 2.3013924e-06 + 2.1645042e-06 + -1.686885e-07 + 1.1400354e-06 + 8.5925473e-07 + -9.5177079e-08 + -4.9476733e-07 + 1.9566522e-07 + -5.2322918e-07 + 1.5911113e-06 + -2.2981799e-07 + -1.546277e-06 + -2.5809338e-06 + -2.1874198e-06 + -2.8447707e-06 + -6.003168e-06 + -7.5685598e-06 + -7.4805835e-06 + -9.8007476e-06 + -7.5790431e-06 + -1.0517209e-05 + -9.3698382e-06 + -6.0820844e-06 + -4.513266e-06 + -6.1426217e-06 + -6.0664988e-06 + -5.9408303e-06 + -7.6888364e-06 + -5.7454145e-06 + -6.4514843e-06 + -2.5307936e-06 + -7.7979479e-07 + -4.4557851e-07 + 5.4281566e-07 + -1.0177969e-06 + 6.5963206e-07 + 2.0811055e-06 + -2.8522754e-07 + -6.4073208e-07 + -2.8998365e-06 + -1.901788e-06 + -1.4455151e-06 + -2.8910372e-07 + -1.1323684e-06 + -1.4292134e-06 + 5.0386113e-08 + 1.6381324e-06 + -2.2276123e-07 + -2.6079434e-07 + 8.866005e-07 + -6.5319233e-07 + 3.4602701e-06 + -1.2270907e-07 + 2.7422018e-06 + 4.2824836e-06 + 2.1185413e-06 + 4.1770027e-06 + 2.8447578e-06 + 6.3908592e-06 + 7.3948709e-06 + 8.2409342e-06 + 9.704383e-06 + 8.35023e-06 + 9.6003869e-06 + 9.2930559e-06 + 6.1146638e-06 + 3.3621252e-06 + -9.8457065e-07 + -1.8718846e-06 + 3.0094341e-07 + 4.6674396e-07 + 4.4797812e-07 + -1.0786407e-06 + -7.5938456e-06 + -1.1059399e-05 + -8.3233581e-06 + -3.8355511e-06 + -2.1474427e-06 + -5.2963392e-06 + -7.1621521e-06 + -6.4974288e-06 + -2.2986844e-06 + -1.416352e-06 + -2.1892388e-06 + -7.1828599e-06 + -2.4088042e-06 + 3.2049647e-06 + 7.2408707e-06 + 7.6889664e-06 + 8.6848986e-06 + 2.0444573e-05 + 1.4390439e-05 + 2.2760736e-05 + 2.4064513e-05 + 2.2546323e-05 + 2.7139242e-05 + 2.466367e-05 + 2.6582289e-05 + 1.9750434e-05 + 9.4496218e-06 + 6.6170951e-06 + 1.0806426e-05 + 7.6765937e-06 + 1.8425069e-05 + 1.2401573e-05 + 3.9162929e-05 + 2.2949267e-05 + -6.7865421e-06 + -1.1479357e-05 + -5.3619879e-05 + -0.00011380042 + -0.00016269117 + -0.00016905692 + + 0.049695708357404555 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP0.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP0.xml new file mode 100644 index 0000000000..d318d513c0 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP0.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 0.91440845 + 0.89127165 + 0.85387266 + 0.81370103 + 0.7681002 + 0.70884496 + 0.65127754 + 0.58396322 + 0.50845456 + 0.43051061 + 0.35105249 + 0.26587203 + 0.18143819 + 0.097567506 + 0.015512385 + -0.068423927 + -0.1456465 + -0.22284648 + -0.29907748 + -0.37475094 + -0.4380517 + -0.49662268 + -0.55154026 + -0.60047692 + -0.64397019 + -0.67695993 + -0.69747227 + -0.71946371 + -0.73064023 + -0.73969084 + -0.73910058 + -0.72273451 + -0.70480442 + -0.68460542 + -0.65121585 + -0.61127657 + -0.56959647 + -0.53186774 + -0.47233477 + -0.42289308 + -0.36013916 + -0.30238953 + -0.23851043 + -0.17228492 + -0.10760929 + -0.038677685 + 0.023924842 + 0.085734844 + 0.14554502 + 0.21178007 + 0.26366264 + 0.31547186 + 0.36479235 + 0.41372058 + 0.45014268 + 0.48719069 + 0.51477271 + 0.54144377 + 0.55743951 + 0.56827539 + 0.57417756 + 0.57521474 + 0.57242984 + 0.56181103 + 0.54661202 + 0.5273785 + 0.49807823 + 0.46791199 + 0.43094185 + 0.39116937 + 0.34865311 + 0.30475527 + 0.26447845 + 0.20973703 + 0.16015707 + 0.10805874 + 0.059454329 + 0.0076480238 + -0.045675594 + -0.089126058 + -0.14246953 + -0.18825532 + -0.22974341 + -0.27582318 + -0.30692092 + -0.34222001 + -0.37205994 + -0.39867413 + -0.42049485 + -0.43268493 + -0.446363 + -0.45471677 + -0.45743033 + -0.45754004 + -0.44663361 + -0.43691492 + -0.42143744 + -0.39964595 + -0.37948313 + -0.35078076 + -0.32291207 + -0.28617722 + -0.25431877 + -0.21413048 + -0.17472994 + -0.13722105 + -0.0940689 + -0.050582096 + -0.011372223 + 0.033095215 + 0.064681761 + 0.10605592 + 0.13676096 + 0.17619975 + 0.20634755 + 0.23424256 + 0.26192936 + 0.28315401 + 0.31159228 + 0.32296148 + 0.3337082 + 0.3472271 + 0.35520938 + 0.35884556 + 0.35598138 + 0.36070585 + 0.34978899 + 0.33616209 + 0.32133636 + 0.30463791 + 0.28434399 + 0.26060301 + 0.23513913 + 0.21211421 + 0.18200785 + 0.15506685 + 0.11292174 + 0.08485233 + 0.048554849 + 0.015430034 + -0.0053237719 + -0.043886948 + -0.069251105 + -0.099874027 + -0.1318848 + -0.15587749 + -0.18213047 + -0.19872877 + -0.22116253 + -0.23839074 + -0.24964274 + -0.25999296 + -0.26915544 + -0.28208914 + -0.28375041 + -0.2840305 + -0.28654379 + -0.27391881 + -0.26717883 + -0.25783545 + -0.24391536 + -0.23143035 + -0.21355876 + -0.19516303 + -0.17305651 + -0.14851433 + -0.13391782 + -0.10106573 + -0.079669952 + -0.054322001 + -0.022567146 + -0.0082916291 + 0.028239559 + 0.044842608 + 0.066723041 + 0.086818486 + 0.11206019 + 0.13034853 + 0.14292336 + 0.16384037 + 0.17437287 + 0.19422586 + 0.19642359 + 0.20773162 + 0.21621291 + 0.22017281 + 0.21870746 + 0.22144818 + 0.21968257 + 0.21284904 + 0.20909898 + 0.20217142 + 0.19360588 + 0.18018678 + 0.16507152 + 0.14102207 + 0.13159586 + 0.11218439 + 0.090035476 + 0.069503993 + 0.054288179 + 0.034861948 + 0.013234816 + -0.0047988398 + -0.024740862 + -0.042112309 + -0.057106286 + -0.079133794 + -0.08531253 + -0.10183473 + -0.11679 + -0.13124378 + -0.13978031 + -0.15192363 + -0.15962306 + -0.16721499 + -0.17583407 + -0.17053062 + -0.17783985 + -0.17420124 + -0.16439037 + -0.16967009 + -0.16545986 + -0.15178227 + -0.1513456 + -0.13972749 + -0.12844835 + -0.11278458 + -0.10008006 + -0.084673822 + -0.071988769 + -0.055301242 + -0.044846795 + -0.024612129 + -0.012670649 + 0.0064235702 + 0.017517105 + 0.032193232 + 0.05088919 + 0.059888519 + 0.073218867 + 0.084005043 + 0.097417012 + 0.11064502 + 0.11908618 + 0.12669091 + 0.12785465 + 0.13891017 + 0.14016822 + 0.15007298 + 4.4267403e-05 + 4.3514352e-05 + 4.3138727e-05 + 4.1891646e-05 + 4.0179297e-05 + 3.8032213e-05 + 3.7556416e-05 + 3.5218971e-05 + 3.1478037e-05 + 3.0895699e-05 + 2.615025e-05 + 2.0906495e-05 + 1.7488654e-05 + 1.3209424e-05 + 9.7491848e-06 + 6.3581501e-06 + 5.6303825e-06 + -5.1143962e-07 + -4.6430905e-06 + -8.4661779e-06 + -1.0448402e-05 + -1.6193704e-05 + -1.857411e-05 + -2.250258e-05 + -2.3523124e-05 + -2.7104035e-05 + -2.8832133e-05 + -2.9649824e-05 + -3.12257e-05 + -3.2669741e-05 + -3.3304954e-05 + -3.3183347e-05 + -3.4332639e-05 + -3.3677767e-05 + -3.4504159e-05 + -3.454684e-05 + -3.2467542e-05 + -2.9868665e-05 + -2.9505636e-05 + -2.6500937e-05 + -2.6333106e-05 + -2.3109949e-05 + -2.140675e-05 + -1.6538143e-05 + -1.4951454e-05 + -1.0329346e-05 + -8.6922209e-06 + -6.4748251e-06 + -2.4234089e-06 + 2.1927521e-07 + 2.7016404e-06 + 3.5660794e-06 + 6.7710325e-06 + 1.154716e-05 + 1.27539e-05 + 1.4957743e-05 + 1.8768704e-05 + 1.983804e-05 + 2.258397e-05 + 2.3245073e-05 + 2.5949555e-05 + 2.7714603e-05 + 2.4125953e-05 + 2.7313827e-05 + 2.6500267e-05 + 2.8872726e-05 + 2.8494722e-05 + 2.8652294e-05 + 2.6291838e-05 + 2.3836281e-05 + 2.2856551e-05 + 2.24215e-05 + 2.2928167e-05 + 2.0600462e-05 + 2.1569322e-05 + 1.8669114e-05 + 1.6274531e-05 + 1.3573073e-05 + 1.2755655e-05 + 9.1842421e-06 + 4.9424475e-06 + 1.9999163e-06 + 1.2401867e-06 + -3.0244464e-06 + -7.6198962e-06 + -9.8329774e-06 + -8.8280267e-06 + -1.377236e-05 + -1.6982995e-05 + -1.9108473e-05 + -2.0853575e-05 + -2.3638708e-05 + -2.4330864e-05 + -2.3607576e-05 + -2.3350785e-05 + -2.4861311e-05 + -2.4024377e-05 + -2.7649214e-05 + -3.0116586e-05 + -2.7083521e-05 + -2.6461454e-05 + -2.5706378e-05 + -2.3319637e-05 + -2.2089596e-05 + -1.7878658e-05 + -1.7124203e-05 + -1.5375375e-05 + -1.5521959e-05 + -1.172509e-05 + -9.1009997e-06 + -5.6435597e-06 + -2.9174676e-06 + -5.4268908e-06 + -1.5508874e-06 + -3.7975212e-07 + 3.1173399e-06 + 1.9381382e-06 + 5.5445184e-06 + 6.774098e-06 + 8.9054111e-06 + 1.0997211e-05 + 1.4307585e-05 + 1.3101091e-05 + 1.5396869e-05 + 1.3836742e-05 + 1.4298585e-05 + 1.65646e-05 + 1.5446933e-05 + 1.9028628e-05 + 2.0577343e-05 + 1.6241767e-05 + 1.6588914e-05 + 1.6793663e-05 + 1.5231977e-05 + 1.3574629e-05 + 1.3824551e-05 + 1.3580589e-05 + 8.8718243e-06 + 8.9766982e-06 + 4.874571e-06 + 6.1740734e-06 + 4.3778728e-06 + 3.0633016e-06 + 2.650128e-06 + 4.4499197e-06 + 5.2487553e-07 + 3.844505e-06 + 8.3970571e-07 + -4.0378814e-06 + -4.2863321e-06 + -3.9477163e-06 + -5.5808941e-06 + -8.159157e-06 + -1.07823e-05 + -1.0445928e-05 + -1.4758529e-05 + -1.5891597e-05 + -1.6962238e-05 + -1.6818865e-05 + -1.3153352e-05 + -1.3562746e-05 + -1.536158e-05 + -1.6916658e-05 + -1.5912401e-05 + -1.9311357e-05 + -1.3812277e-05 + -1.7308477e-05 + -1.1393254e-05 + -6.9415369e-06 + -8.5329793e-06 + -7.3732735e-06 + -8.2779943e-06 + -4.1989624e-06 + -4.0598088e-06 + -6.2781332e-06 + -6.1900923e-06 + -9.3725657e-06 + -9.9827339e-06 + -9.6235508e-06 + -4.7038488e-06 + -3.4777854e-06 + -2.7908015e-06 + 1.7161137e-06 + 2.1103369e-06 + 1.6298396e-06 + 5.1353272e-06 + 9.7297398e-06 + 7.9292831e-06 + 1.0491432e-05 + 8.7098369e-06 + 1.1306504e-05 + 1.2767204e-05 + 1.0523996e-05 + 1.5876185e-05 + 1.8240517e-05 + 1.7410239e-05 + 1.8709565e-05 + 2.0682788e-05 + 2.2414559e-05 + 2.3641453e-05 + 2.9956356e-05 + 3.1942258e-05 + 3.2165972e-05 + 2.3073231e-05 + 2.1864589e-05 + 2.3307522e-05 + 2.6105658e-05 + 3.0764437e-05 + 2.5258372e-05 + 2.4398061e-05 + 1.5440721e-05 + 7.2866023e-06 + 4.1072926e-06 + 1.3465999e-05 + 9.5875193e-06 + 3.303629e-06 + -9.6435542e-06 + -1.4834303e-05 + -1.3345806e-05 + -1.2496928e-05 + -1.2373329e-05 + -1.9174164e-05 + -2.2750348e-05 + -1.0412362e-05 + -7.1453283e-06 + -5.0996732e-06 + -1.4278352e-06 + 1.091708e-05 + 6.6890452e-06 + 2.0174368e-05 + 1.0472003e-05 + 4.7418193e-06 + 9.2978889e-06 + 4.5979341e-06 + 1.164395e-05 + -1.1824308e-05 + -1.2670253e-05 + -7.1008421e-06 + 4.0426371e-06 + 9.691882e-06 + 3.4888384e-05 + 2.3447481e-05 + 6.0634087e-05 + 4.6600537e-05 + 3.8806083e-05 + 4.0546623e-05 + 5.6960853e-05 + 1.7836719e-05 + -8.4526189e-05 + -0.00019142308 + + 0.54968381075777017 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP1.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP1.xml new file mode 100644 index 0000000000..f02426b8fc --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP1.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 0.47994247 + 0.48478529 + 0.42015755 + 0.43633738 + 0.40917483 + 0.36798882 + 0.33975855 + 0.33914748 + 0.24553728 + 0.23165418 + 0.19017372 + 0.15800953 + 0.12168649 + 0.059838008 + 0.035983752 + -0.0061296029 + -0.027875844 + -0.091517158 + -0.13541557 + -0.19742206 + -0.22613534 + -0.25163805 + -0.28906253 + -0.34219807 + -0.39520577 + -0.40806535 + -0.38800871 + -0.41812003 + -0.39130437 + -0.47249088 + -0.50039351 + -0.47069913 + -0.44109708 + -0.44801748 + -0.44286934 + -0.40633747 + -0.38159758 + -0.38471025 + -0.28739071 + -0.2954666 + -0.22040513 + -0.20538236 + -0.17562716 + -0.12331922 + -0.10807745 + -0.050659552 + -0.016248262 + 0.025591634 + 0.048248891 + 0.14176746 + 0.1492541 + 0.19401339 + 0.2210024 + 0.27532429 + 0.30570927 + 0.3446942 + 0.39302194 + 0.42873836 + 0.42809039 + 0.43389183 + 0.45135197 + 0.46419406 + 0.4460637 + 0.45233327 + 0.42144969 + 0.45315924 + 0.39301997 + 0.40853813 + 0.34201711 + 0.3340483 + 0.28035039 + 0.23896335 + 0.28436226 + 0.17808978 + 0.14499563 + 0.06180751 + 0.092647187 + 0.027190113 + -0.0080625331 + -0.064187385 + -0.10907344 + -0.15446156 + -0.16533569 + -0.23526125 + -0.2398034 + -0.28330675 + -0.30476564 + -0.35689712 + -0.38892877 + -0.3612541 + -0.39185265 + -0.43028882 + -0.45067519 + -0.4342128 + -0.41821808 + -0.4186511 + -0.40667656 + -0.41434187 + -0.40649354 + -0.33379188 + -0.33737326 + -0.29176438 + -0.26665944 + -0.24745244 + -0.20352092 + -0.1578752 + -0.086990885 + -0.066635042 + -0.042743091 + 0.00078681594 + -0.0067911739 + 0.085896254 + 0.071024999 + 0.17950583 + 0.17651561 + 0.20058732 + 0.21677521 + 0.28812888 + 0.33220929 + 0.33306259 + 0.33927098 + 0.37198529 + 0.417128 + 0.4154191 + 0.39847392 + 0.44730949 + 0.4173483 + 0.37803513 + 0.37619099 + 0.3639302 + 0.33892557 + 0.32587534 + 0.28599876 + 0.27454555 + 0.24336377 + 0.198433 + 0.14513154 + 0.13489601 + 0.062797137 + 0.037670311 + 0.050498053 + -0.033388019 + -0.030411391 + -0.084634274 + -0.12620553 + -0.15148365 + -0.19281019 + -0.18538459 + -0.24954344 + -0.26109678 + -0.28819132 + -0.29661107 + -0.32724535 + -0.35866067 + -0.37147668 + -0.38001916 + -0.41183418 + -0.39546514 + -0.38687271 + -0.34134433 + -0.34561017 + -0.34194723 + -0.31308424 + -0.27242407 + -0.24386796 + -0.20921478 + -0.21119194 + -0.17974477 + -0.15848035 + -0.12469824 + -0.086453475 + -0.080984168 + 0.005651589 + 0.003682811 + 0.018001949 + 0.05915371 + 0.12276107 + 0.13476479 + 0.16121536 + 0.2092976 + 0.22431286 + 0.27541709 + 0.24461982 + 0.29393646 + 0.3234759 + 0.31976876 + 0.31485754 + 0.32111084 + 0.35145399 + 0.32975963 + 0.30248013 + 0.33686966 + 0.31571227 + 0.31266999 + 0.25339827 + 0.25347894 + 0.23968148 + 0.18691608 + 0.17482249 + 0.14749897 + 0.12377977 + 0.1089068 + 0.063197732 + 0.026660295 + -0.010755541 + -0.037944749 + -0.037892897 + -0.10014877 + -0.095640317 + -0.13707285 + -0.16875705 + -0.18712473 + -0.19054933 + -0.20765278 + -0.23237705 + -0.25386557 + -0.27768761 + -0.25717878 + -0.28340849 + -0.27809283 + -0.238038 + -0.26776999 + -0.27595633 + -0.25788331 + -0.2742697 + -0.2293901 + -0.25884274 + -0.19792171 + -0.17900355 + -0.15930815 + -0.17125751 + -0.13059393 + -0.10386769 + -0.075353824 + -0.065707266 + -0.018131474 + -0.014584285 + 0.0061852229 + 0.042538356 + 0.050294321 + 0.078784354 + 0.087153688 + 0.12855974 + 0.15673861 + 0.16491783 + 0.18010868 + 0.19055982 + 0.2284265 + 0.23438752 + 0.26127139 + 0.00051779405 + 0.00046002973 + 0.00049159979 + 0.00046070319 + 0.0005150768 + 0.00043054938 + 0.00045350095 + 0.00040957739 + 0.00034215208 + 0.00035906222 + 0.00033953731 + 0.00028457298 + 0.00030721581 + 0.00016524141 + 0.00017076859 + 0.00012973398 + 0.00016397034 + 4.7663285e-05 + 1.358061e-05 + -2.7169301e-05 + -2.7898577e-06 + -0.00013654496 + -9.7739423e-05 + -0.0001642635 + -0.00019529846 + -0.00024131176 + -0.00029883318 + -0.0003162272 + -0.00032828687 + -0.00038343482 + -0.00040526892 + -0.00039040067 + -0.0004144444 + -0.00033617931 + -0.00042994847 + -0.00042565534 + -0.0004040171 + -0.00035610452 + -0.00031678245 + -0.00029163092 + -0.00032491583 + -0.00024466871 + -0.00026350768 + -0.00022657856 + -0.00023745382 + -0.00017040815 + -0.00015178781 + -0.00013567225 + -0.00012801227 + -5.3487096e-05 + -3.4211818e-05 + -6.9752728e-06 + 3.0836691e-05 + 5.3444957e-05 + 8.0782404e-05 + 0.00013846572 + 0.00016730832 + 0.00019705876 + 0.00022988698 + 0.00026496977 + 0.00027594061 + 0.00030931641 + 0.00025910389 + 0.0002923141 + 0.00027058041 + 0.00036504987 + 0.00032267233 + 0.00032371024 + 0.00030552977 + 0.00027583545 + 0.00025386945 + 0.00024303515 + 0.00026581573 + 0.0002071358 + 0.00023383345 + 0.00017728444 + 0.00017414079 + 0.00018484636 + 0.00018264132 + 0.00017436035 + 0.00010066917 + 6.8966023e-05 + 5.8083904e-05 + 1.8432511e-05 + -5.5161676e-05 + -7.3635965e-05 + -5.5789766e-05 + -9.8511002e-05 + -0.00016468731 + -0.00016649776 + -0.0001994113 + -0.00021746985 + -0.00025234316 + -0.00026447431 + -0.00023566742 + -0.0002863394 + -0.00027145303 + -0.00027926482 + -0.00031412177 + -0.00025063011 + -0.00026088688 + -0.00022227927 + -0.00019989176 + -0.00019884146 + -0.00015387453 + -0.00015428696 + -0.00014001745 + -0.00013479896 + -0.00013827824 + -0.00010479951 + -9.2000962e-05 + -6.305665e-05 + -8.5287145e-05 + -2.2435448e-05 + -4.9504943e-05 + 7.0504911e-06 + -3.8556545e-06 + 2.0939458e-05 + 4.0444185e-05 + 6.2464758e-05 + 8.4932581e-05 + 0.0001249061 + 0.00012059854 + 0.00016844175 + 0.00010705311 + 0.00012287036 + 0.00014456037 + 0.00010299935 + 0.00014447783 + 0.00016631189 + 0.00011951655 + 9.2054914e-05 + 7.7397526e-05 + 6.8027111e-05 + 4.7603451e-05 + 4.6011894e-05 + 8.9196699e-05 + 1.9264202e-05 + 5.8760601e-05 + 1.4962246e-05 + 5.5923185e-05 + 3.973005e-05 + 5.7783513e-05 + 7.4290845e-05 + 6.0946517e-05 + 3.0873391e-05 + 5.5158758e-05 + 3.5803965e-05 + -2.1067415e-05 + 3.8682715e-06 + -2.0667258e-06 + -1.2632422e-05 + -4.2208379e-05 + -9.5042917e-05 + -0.00010922949 + -0.00013174933 + -0.00014768293 + -0.00012974846 + -0.00013042323 + -9.965428e-05 + -8.2405808e-05 + -9.2953065e-05 + -7.6099925e-05 + -6.2735577e-05 + -7.770439e-05 + -2.9663626e-05 + -5.4733122e-05 + -4.6981109e-05 + 1.8356723e-05 + -4.4312477e-05 + -2.5209471e-05 + -6.2572442e-05 + -2.3840879e-05 + -6.1076091e-05 + -9.3741124e-05 + -7.945695e-05 + -0.00011390245 + -0.00013043737 + -0.00012991235 + -6.5812135e-05 + -3.477887e-05 + -2.9716135e-05 + -7.4908535e-06 + 2.3869186e-05 + 4.6370671e-05 + 7.6261058e-05 + 7.8259094e-05 + 6.4048887e-05 + 7.6222859e-05 + 8.3034451e-05 + 6.315564e-05 + 6.9539514e-05 + 4.724467e-05 + 7.0027898e-05 + 7.6666351e-05 + 8.6733067e-05 + 8.0106831e-05 + 0.00010918936 + 0.00014464188 + 0.00017181516 + 0.0002254135 + 0.00024767048 + 0.00026707022 + 0.00019277025 + 0.00023908055 + 0.00024568432 + 0.00023091928 + 0.00029483382 + 0.00025279995 + 0.00024932221 + 0.00016185141 + 0.00012187717 + 8.6983739e-05 + 9.7002376e-05 + 1.2475208e-05 + -6.0953054e-05 + -0.00012379354 + -0.00016237446 + -0.00012646648 + -0.00010655529 + -6.7753019e-05 + -7.6096891e-05 + -6.1317194e-05 + 4.2310683e-05 + 7.8446574e-05 + 0.00011693679 + 0.00011118068 + 0.00019630734 + 0.00013006449 + 0.00020328228 + 9.4708485e-05 + 2.4244946e-05 + 2.0031335e-05 + 8.7780099e-06 + 8.5161257e-05 + -3.2001142e-05 + 5.0963968e-06 + 5.9037811e-05 + 0.00016131309 + 0.00018575686 + 0.00038959685 + 0.00030655556 + 0.00055750855 + 0.00041609086 + 0.00041038837 + 0.00024904971 + 0.00032858923 + -0.00012124365 + -0.00067634159 + -0.0014037765 + + -0.13156737015469844 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP2.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP2.xml new file mode 100644 index 0000000000..e61b5e32d2 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP2.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 1.0026263 + 1.002813 + 1.0028353 + 1.00298 + 1.0031264 + 1.0033009 + 1.0034248 + 1.0034949 + 1.0036868 + 1.0038811 + 1.0039461 + 1.0039393 + 1.0039014 + 1.0041367 + 1.0040401 + 1.0039788 + 1.0041522 + 1.004038 + 1.00398 + 1.0038664 + 1.0038596 + 1.00374 + 1.0035481 + 1.0035183 + 1.003296 + 1.0031067 + 1.0031048 + 1.0029247 + 1.0029281 + 1.0027844 + 1.0024828 + 1.0026224 + 1.0028158 + 1.0028605 + 1.0029123 + 1.0031923 + 1.0032749 + 1.0033575 + 1.0034987 + 1.0035222 + 1.0038122 + 1.0038934 + 1.0038835 + 1.003985 + 1.0040591 + 1.0040226 + 1.004043 + 1.0039675 + 1.0040811 + 1.0039179 + 1.003891 + 1.0038245 + 1.0036744 + 1.0038064 + 1.0035872 + 1.003276 + 1.0033685 + 1.0032185 + 1.0030403 + 1.0028248 + 1.0028371 + 1.0028143 + 1.00263 + 1.002896 + 1.0029092 + 1.0029544 + 1.0030841 + 1.0033208 + 1.0033398 + 1.0034574 + 1.003602 + 1.0037988 + 1.0038297 + 1.0040625 + 1.0039389 + 1.0040179 + 1.0039594 + 1.0039961 + 1.0039948 + 1.0040424 + 1.0039783 + 1.0039077 + 1.003881 + 1.003885 + 1.0038402 + 1.0036588 + 1.0035746 + 1.0034667 + 1.0033582 + 1.0032606 + 1.0031298 + 1.0029531 + 1.0029762 + 1.0028747 + 1.0028256 + 1.0029508 + 1.0031258 + 1.0032694 + 1.0033274 + 1.0034236 + 1.0035467 + 1.0037386 + 1.0037678 + 1.0038179 + 1.003939 + 1.003979 + 1.00396 + 1.0039968 + 1.0040765 + 1.0039867 + 1.0040717 + 1.0039583 + 1.0038927 + 1.0039638 + 1.0038794 + 1.003749 + 1.0036877 + 1.0035897 + 1.0034268 + 1.0034192 + 1.0032343 + 1.0033185 + 1.0029762 + 1.0031357 + 1.003207 + 1.0029137 + 1.0030683 + 1.0031815 + 1.0033453 + 1.0033225 + 1.0034435 + 1.0035906 + 1.0036092 + 1.0037911 + 1.0038091 + 1.0039287 + 1.0040594 + 1.003963 + 1.0039438 + 1.004236 + 1.0041121 + 1.0039667 + 1.0039054 + 1.0039448 + 1.0038875 + 1.0039566 + 1.0037364 + 1.0038453 + 1.0036628 + 1.0036311 + 1.0035908 + 1.0035497 + 1.0035697 + 1.0033984 + 1.0034442 + 1.0033016 + 1.0032938 + 1.0032138 + 1.0033556 + 1.0033462 + 1.0034832 + 1.0035497 + 1.0036097 + 1.003722 + 1.003818 + 1.0037833 + 1.0038013 + 1.0039788 + 1.0039507 + 1.0040078 + 1.0040756 + 1.0040264 + 1.0038471 + 1.0039368 + 1.0040127 + 1.0038276 + 1.0038612 + 1.0038606 + 1.0038905 + 1.0039259 + 1.0036864 + 1.0036433 + 1.0036565 + 1.0036999 + 1.003649 + 1.0035149 + 1.0035567 + 1.0035112 + 1.003474 + 1.0034895 + 1.003518 + 1.0036062 + 1.0036708 + 1.0038066 + 1.0037796 + 1.0038444 + 1.0038437 + 1.0038533 + 1.0040073 + 1.0039427 + 1.0040594 + 1.0040133 + 1.0039896 + 1.0041509 + 1.0040509 + 1.0040835 + 1.0039433 + 1.0039626 + 1.0039417 + 1.0039464 + 1.0039327 + 1.0038795 + 1.0038284 + 1.0037864 + 1.0037988 + 1.0038092 + 1.0038675 + 1.0038058 + 1.0036768 + 1.0036308 + 1.0037299 + 1.003732 + 1.0038123 + 1.0038664 + 1.0037434 + 1.0037843 + 1.0037801 + 1.0039681 + 1.003965 + 1.0039586 + 1.0040132 + 1.0040785 + 1.004027 + 1.0039933 + 1.0040841 + 1.0040706 + 1.0040671 + 1.0040392 + 1.003906 + 1.0039387 + 1.0039802 + 1.0039933 + 1.0039399 + 1.0039351 + 1.0039452 + 1.0038861 + 1.0039293 + 1.0039737 + 1.0039887 + 1.0038258 + -0.49893174 + -0.49886957 + -0.49892607 + -0.49890354 + -0.49890825 + -0.49895376 + -0.49898374 + -0.4989509 + -0.49897298 + -0.49903247 + -0.49904075 + -0.49909836 + -0.49908444 + -0.49908859 + -0.49905875 + -0.49902666 + -0.49906376 + -0.49897763 + -0.49900699 + -0.49899176 + -0.49896324 + -0.4990257 + -0.49898669 + -0.49898905 + -0.4989301 + -0.49899307 + -0.4989734 + -0.49900821 + -0.49903369 + -0.49896592 + -0.49899274 + -0.49897274 + -0.49891421 + -0.49898604 + -0.49893531 + -0.49889025 + -0.49898291 + -0.49900803 + -0.4990274 + -0.49901819 + -0.49902931 + -0.49899384 + -0.49903008 + -0.49902987 + -0.49906373 + -0.49897286 + -0.49903256 + -0.4990426 + -0.49899024 + -0.49900568 + -0.49897072 + -0.49898463 + -0.49899572 + -0.49897897 + -0.49897388 + -0.498952 + -0.49896869 + -0.49902186 + -0.49899849 + -0.49902734 + -0.49899837 + -0.49893278 + -0.49898127 + -0.4989706 + -0.49897298 + -0.49895722 + -0.49895576 + -0.49900338 + -0.49902055 + -0.49900922 + -0.49902984 + -0.49903873 + -0.49901998 + -0.49906427 + -0.49905005 + -0.49904937 + -0.49903309 + -0.49906269 + -0.49902761 + -0.4989495 + -0.49903408 + -0.49898002 + -0.49901122 + -0.49896607 + -0.49895996 + -0.49893692 + -0.49901545 + -0.49897414 + -0.49899518 + -0.49900544 + -0.49900562 + -0.49902061 + -0.49900696 + -0.49901411 + -0.49897903 + -0.49896753 + -0.49898955 + -0.49894136 + -0.49890041 + -0.49896589 + -0.49905798 + -0.49901095 + -0.49903458 + -0.49901229 + -0.49897078 + -0.49899077 + -0.49903148 + -0.49900115 + -0.49903333 + -0.49893701 + -0.49894023 + -0.49889353 + -0.49892846 + -0.49893394 + -0.49893048 + -0.49895993 + -0.49895453 + -0.49897233 + -0.49901488 + -0.49897596 + -0.49901453 + -0.49898061 + -0.49898961 + -0.49896201 + -0.49900386 + -0.49896801 + -0.49894783 + -0.49898973 + -0.49900243 + -0.49898016 + -0.4990072 + -0.49901175 + -0.49905095 + -0.49902296 + -0.49905404 + -0.49907574 + -0.49903113 + -0.49899417 + -0.49898854 + -0.49898151 + -0.49896878 + -0.4989523 + -0.49892372 + -0.49893865 + -0.49890816 + -0.49890837 + -0.49892312 + -0.49893406 + -0.49898854 + -0.49900332 + -0.49896649 + -0.49897844 + -0.49897742 + -0.49898747 + -0.49901125 + -0.49901617 + -0.49903822 + -0.49900663 + -0.49901626 + -0.49898303 + -0.49894875 + -0.49897355 + -0.49900821 + -0.49900267 + -0.49894786 + -0.49896383 + -0.49899969 + -0.49897408 + -0.49899754 + -0.49899074 + -0.4989655 + -0.4989244 + -0.49888101 + -0.4989126 + -0.49887562 + -0.49887267 + -0.4989208 + -0.49892566 + -0.49888468 + -0.49895188 + -0.49898317 + -0.49898994 + -0.499053 + -0.49904776 + -0.49901441 + -0.49905989 + -0.49906784 + -0.49904436 + -0.49905097 + -0.49906713 + -0.49905431 + -0.49900526 + -0.49893859 + -0.49897069 + -0.49897757 + -0.49898547 + -0.4989692 + -0.49900842 + -0.49897486 + -0.49885672 + -0.49891347 + -0.49889705 + -0.49882984 + -0.49888229 + -0.49882868 + -0.49875924 + -0.49873927 + -0.49876097 + -0.49878752 + -0.4987694 + -0.49884218 + -0.49889925 + -0.49895036 + -0.4989852 + -0.49903667 + -0.49907553 + -0.49912426 + -0.49908084 + -0.49905947 + -0.49900791 + -0.49891245 + -0.49886835 + -0.49882156 + -0.49881804 + -0.49885982 + -0.4988803 + -0.49897206 + -0.49903926 + -0.49898836 + -0.49902949 + -0.49892426 + -0.49893805 + -0.49871096 + -0.49875355 + -0.49870211 + -0.49881226 + -0.49883336 + -0.49881047 + -0.4987531 + -0.49864075 + -0.49877453 + -0.49885714 + -0.49892786 + -0.49911681 + -0.49893573 + -0.49896306 + -0.49876678 + -0.4990873 + -0.49923372 + -0.49851903 + + 127.17098122835159 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP3.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP3.xml new file mode 100644 index 0000000000..ff8df50e25 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP3.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 0.24916932 + 0.26282433 + 0.21642341 + 0.15372278 + 0.11979742 + 0.092738658 + 0.050859306 + 0.074621499 + 0.037549708 + 0.022125257 + 0.01304414 + 0.0044885995 + 0.033661574 + 0.021974018 + 0.003042046 + 0.02771442 + -0.024294494 + -0.0089511611 + -0.01425425 + -0.018068291 + -0.032646321 + -0.020490842 + -0.029507939 + -0.053334761 + -0.081523851 + -0.11181895 + -0.11998858 + -0.19702718 + -0.23862125 + -0.23100108 + -0.28396863 + -0.25871417 + -0.25871655 + -0.23469536 + -0.16978902 + -0.11634055 + -0.088878788 + -0.090839922 + -0.042584907 + -0.049209379 + -0.044580866 + -0.061672501 + -0.036852069 + -0.060182665 + -0.037425138 + -0.023032969 + -0.008587338 + -0.0097123208 + 0.0093123093 + 0.0089723812 + 0.015222463 + 0.017061882 + 0.026156943 + 0.025765847 + 0.054910339 + 0.10248004 + 0.08782912 + 0.10213599 + 0.15908866 + 0.16958259 + 0.21099328 + 0.25954089 + 0.24664715 + 0.21735786 + 0.20271333 + 0.14929497 + 0.099971056 + 0.078323275 + 0.086109914 + 0.088238128 + 0.033936426 + 0.060482882 + 0.024708128 + 0.014221126 + 0.017057929 + 0.023793744 + 0.020157645 + 0.028095469 + -0.0011269932 + -0.0087106731 + -0.015682038 + -0.031383019 + -0.040354021 + -0.022688888 + -0.029115962 + -0.044007879 + -0.047760032 + -0.075893126 + -0.081340298 + -0.12698907 + -0.12668371 + -0.16949433 + -0.17001522 + -0.21445785 + -0.19745404 + -0.14944276 + -0.15087374 + -0.11744924 + -0.095149398 + -0.06332425 + -0.036039084 + -0.0081931204 + -0.032258861 + -0.051029101 + -0.010478755 + -0.046378605 + -0.012759867 + -0.045964837 + -0.012755739 + -0.0030502961 + 0.012351047 + -0.0011214457 + 0.0090411613 + 0.032239337 + 0.03779193 + 0.023959428 + 0.024747973 + 0.024610961 + 0.061804209 + 0.062422201 + 0.073981203 + 0.11293139 + 0.13641046 + 0.14514221 + 0.1661052 + 0.16901226 + 0.13682093 + 0.14968935 + 0.096671052 + 0.091609098 + 0.038700294 + 0.050378289 + 0.0071525229 + 0.026320271 + 0.004891546 + -0.0075392947 + 0.039158821 + 0.022921503 + 0.030754266 + 0.022782188 + 0.009197413 + 0.011712298 + 0.00042203636 + 0.0034940925 + -0.034436598 + -0.032315563 + -0.016871653 + -0.035277113 + 0.0017015081 + 0.0049509918 + -0.057147924 + -0.064407878 + -0.045245171 + -0.089002214 + -0.071642399 + -0.11470717 + -0.11126412 + -0.090277366 + -0.094315536 + -0.079579718 + -0.047357906 + -0.024927292 + -0.034104288 + -0.0096314782 + -0.01172656 + -0.0056364429 + -0.040535823 + -0.016774358 + -0.014503113 + -0.039290171 + -0.014833414 + -0.013736404 + -0.012063603 + -0.028713237 + -0.015571943 + 0.0072697252 + 0.014094685 + 0.032336745 + 0.026830338 + 0.0048128823 + -0.012038751 + 0.016595189 + 0.023860943 + 0.039478075 + 0.050808214 + 0.072448984 + 0.03044604 + 0.049967185 + 0.048776053 + 0.01749002 + 0.045520712 + 0.021682752 + 0.030495429 + -0.009275022 + 0.0020285225 + -0.0010389222 + 0.030749684 + 0.030424479 + 0.017310664 + 0.021767529 + 0.01571149 + 0.029586872 + 0.013801512 + 0.04165978 + -0.0018744577 + 0.01699499 + -0.0014720967 + 0.0059610172 + -0.0066657215 + -0.0048435708 + -0.014292663 + 0.024748452 + 0.0096782139 + 0.0025369956 + -0.020823359 + 0.017876782 + -0.015183195 + -0.015656698 + -0.0028440207 + 0.014280689 + -0.026562925 + -0.014578264 + -0.03152569 + -0.0090835607 + 0.01867128 + -0.024373746 + 0.02396073 + 0.023200441 + 0.017668812 + -0.0162716 + -0.0095616225 + -0.0094661694 + -0.006648181 + 0.009075908 + 0.0092385337 + 0.0098444149 + -0.01935043 + -0.0044980175 + -0.024686264 + 0.00012611978 + -0.0078650564 + -0.025699897 + -0.019722866 + -0.003895215 + -0.015588136 + -0.014491427 + -0.016194995 + -0.0062554618 + -0.010720518 + 0.0040345192 + -0.294002 + -0.177398 + -0.39839 + -0.48773 + -0.172094 + -0.41209301 + -0.408075 + -0.30323401 + -0.31504101 + -0.36764601 + -0.22680099 + -0.362151 + -0.37852699 + -0.41337499 + -0.42870599 + -0.370096 + -0.39703399 + -0.43473601 + -0.35783899 + -0.31582201 + -0.398561 + -0.209665 + -0.403451 + -0.45481399 + -0.29749301 + -0.32480201 + -0.386527 + -0.19479001 + -0.36277401 + -0.33375701 + -0.28211099 + -0.394546 + -0.406385 + -0.114484 + -0.42001301 + -0.403752 + -0.20651101 + -0.30948099 + -0.34128401 + -0.120096 + -0.45341599 + -0.31077701 + -0.119248 + -0.43382999 + -0.175929 + 0.033982199 + -0.33926401 + -0.195425 + -0.071849696 + -0.37102601 + -0.21621799 + 0.0139881 + -0.35108399 + -0.138989 + 0.052345399 + -0.32499999 + -0.14821599 + 0.042676602 + -0.28181201 + -0.126936 + 0.0222029 + -0.287808 + -0.071663201 + 0.13822199 + -0.185139 + -0.0152797 + 0.230471 + -0.22155701 + 0.0130399 + 0.208427 + -0.127197 + 0.0064887698 + 0.236035 + -0.140938 + 0.192555 + 0.148371 + -0.121454 + 0.073920898 + 0.32382101 + -0.075303599 + 0.187121 + 0.197079 + 0.088469401 + 0.14371 + 0.346057 + 0.072195202 + 0.120678 + 0.37142599 + 0.134703 + 0.161566 + 0.34491301 + 0.110235 + 0.223032 + 0.215381 + 0.15115701 + 0.337161 + 0.34478301 + 0.154284 + 0.217981 + 0.31849399 + 0.27069601 + 0.32320201 + 0.201975 + 0.13255 + 0.19012199 + 0.22415 + 0.33738399 + 0.24033999 + 0.292528 + 0.231969 + 0.26378 + 0.30350101 + 0.23063 + 0.299878 + 0.15784501 + 0.276788 + 0.36825699 + 0.193731 + 0.21615 + 0.207757 + 0.136564 + 0.26222599 + 0.210265 + 0.13002799 + 0.20605899 + 0.152711 + 0.195077 + 0.29734299 + 0.237324 + 0.118121 + 0.29328901 + 0.22663499 + 0.075010903 + 0.26577801 + 0.119711 + 0.106759 + 0.27516001 + 0.105753 + 0.093085699 + 0.25944301 + 0.195959 + 0.0504844 + 0.237343 + 0.142589 + -0.089643501 + 0.282426 + 0.148966 + -0.0323091 + 0.160483 + 0.035948101 + -0.078566097 + 0.21877199 + 0.129273 + -0.15982699 + 0.0853457 + 0.116802 + -0.041748598 + 0.20506001 + 0.082346298 + -0.033599202 + 0.094616003 + 0.019920699 + -0.046248399 + 0.024650799 + -0.0416026 + -0.098334201 + 0.063990101 + -0.13928699 + -0.242319 + 0.024995901 + -0.18093801 + -0.249294 + 0.032946199 + -0.159826 + -0.23584101 + 0.016282201 + -0.196504 + -0.23710801 + -0.0406349 + -0.11625 + -0.115526 + 0.035594702 + -0.100031 + -0.131438 + -0.148066 + -0.246914 + -0.228278 + -0.128664 + -0.151379 + -0.120204 + -0.20564 + -0.19493499 + -0.223316 + -0.20992599 + -0.293475 + -0.181631 + -0.15154199 + -0.18523701 + -0.277973 + -0.212514 + -0.25714999 + -0.106606 + -0.17149 + -0.28705299 + -0.17783999 + -0.288715 + -0.13793799 + -0.15577 + -0.101648 + -0.29286501 + -0.15349799 + -0.196582 + -0.151655 + -0.105669 + -0.233206 + -0.205688 + -0.120301 + -0.30407101 + -0.27380499 + -0.0567232 + -0.26257399 + -0.213572 + -0.188062 + -0.234014 + -0.147396 + -0.130597 + -0.127922 + -0.16339099 + -0.141241 + -0.14472499 + -0.10392 + -0.0510807 + -0.247492 + -0.058272298 + -0.0082769198 + -0.25879499 + -0.19123399 + 0.077861302 + -0.074387997 + -0.142011 + 0.081611998 + -0.12735599 + -0.153745 + 0.078688301 + -0.12088 + -0.122613 + 0.067525104 + -0.13781101 + 0.023367999 + 0.057603098 + + -13.63323055645742 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP4.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP4.xml new file mode 100644 index 0000000000..d318d513c0 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacP4.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 0.91440845 + 0.89127165 + 0.85387266 + 0.81370103 + 0.7681002 + 0.70884496 + 0.65127754 + 0.58396322 + 0.50845456 + 0.43051061 + 0.35105249 + 0.26587203 + 0.18143819 + 0.097567506 + 0.015512385 + -0.068423927 + -0.1456465 + -0.22284648 + -0.29907748 + -0.37475094 + -0.4380517 + -0.49662268 + -0.55154026 + -0.60047692 + -0.64397019 + -0.67695993 + -0.69747227 + -0.71946371 + -0.73064023 + -0.73969084 + -0.73910058 + -0.72273451 + -0.70480442 + -0.68460542 + -0.65121585 + -0.61127657 + -0.56959647 + -0.53186774 + -0.47233477 + -0.42289308 + -0.36013916 + -0.30238953 + -0.23851043 + -0.17228492 + -0.10760929 + -0.038677685 + 0.023924842 + 0.085734844 + 0.14554502 + 0.21178007 + 0.26366264 + 0.31547186 + 0.36479235 + 0.41372058 + 0.45014268 + 0.48719069 + 0.51477271 + 0.54144377 + 0.55743951 + 0.56827539 + 0.57417756 + 0.57521474 + 0.57242984 + 0.56181103 + 0.54661202 + 0.5273785 + 0.49807823 + 0.46791199 + 0.43094185 + 0.39116937 + 0.34865311 + 0.30475527 + 0.26447845 + 0.20973703 + 0.16015707 + 0.10805874 + 0.059454329 + 0.0076480238 + -0.045675594 + -0.089126058 + -0.14246953 + -0.18825532 + -0.22974341 + -0.27582318 + -0.30692092 + -0.34222001 + -0.37205994 + -0.39867413 + -0.42049485 + -0.43268493 + -0.446363 + -0.45471677 + -0.45743033 + -0.45754004 + -0.44663361 + -0.43691492 + -0.42143744 + -0.39964595 + -0.37948313 + -0.35078076 + -0.32291207 + -0.28617722 + -0.25431877 + -0.21413048 + -0.17472994 + -0.13722105 + -0.0940689 + -0.050582096 + -0.011372223 + 0.033095215 + 0.064681761 + 0.10605592 + 0.13676096 + 0.17619975 + 0.20634755 + 0.23424256 + 0.26192936 + 0.28315401 + 0.31159228 + 0.32296148 + 0.3337082 + 0.3472271 + 0.35520938 + 0.35884556 + 0.35598138 + 0.36070585 + 0.34978899 + 0.33616209 + 0.32133636 + 0.30463791 + 0.28434399 + 0.26060301 + 0.23513913 + 0.21211421 + 0.18200785 + 0.15506685 + 0.11292174 + 0.08485233 + 0.048554849 + 0.015430034 + -0.0053237719 + -0.043886948 + -0.069251105 + -0.099874027 + -0.1318848 + -0.15587749 + -0.18213047 + -0.19872877 + -0.22116253 + -0.23839074 + -0.24964274 + -0.25999296 + -0.26915544 + -0.28208914 + -0.28375041 + -0.2840305 + -0.28654379 + -0.27391881 + -0.26717883 + -0.25783545 + -0.24391536 + -0.23143035 + -0.21355876 + -0.19516303 + -0.17305651 + -0.14851433 + -0.13391782 + -0.10106573 + -0.079669952 + -0.054322001 + -0.022567146 + -0.0082916291 + 0.028239559 + 0.044842608 + 0.066723041 + 0.086818486 + 0.11206019 + 0.13034853 + 0.14292336 + 0.16384037 + 0.17437287 + 0.19422586 + 0.19642359 + 0.20773162 + 0.21621291 + 0.22017281 + 0.21870746 + 0.22144818 + 0.21968257 + 0.21284904 + 0.20909898 + 0.20217142 + 0.19360588 + 0.18018678 + 0.16507152 + 0.14102207 + 0.13159586 + 0.11218439 + 0.090035476 + 0.069503993 + 0.054288179 + 0.034861948 + 0.013234816 + -0.0047988398 + -0.024740862 + -0.042112309 + -0.057106286 + -0.079133794 + -0.08531253 + -0.10183473 + -0.11679 + -0.13124378 + -0.13978031 + -0.15192363 + -0.15962306 + -0.16721499 + -0.17583407 + -0.17053062 + -0.17783985 + -0.17420124 + -0.16439037 + -0.16967009 + -0.16545986 + -0.15178227 + -0.1513456 + -0.13972749 + -0.12844835 + -0.11278458 + -0.10008006 + -0.084673822 + -0.071988769 + -0.055301242 + -0.044846795 + -0.024612129 + -0.012670649 + 0.0064235702 + 0.017517105 + 0.032193232 + 0.05088919 + 0.059888519 + 0.073218867 + 0.084005043 + 0.097417012 + 0.11064502 + 0.11908618 + 0.12669091 + 0.12785465 + 0.13891017 + 0.14016822 + 0.15007298 + 4.4267403e-05 + 4.3514352e-05 + 4.3138727e-05 + 4.1891646e-05 + 4.0179297e-05 + 3.8032213e-05 + 3.7556416e-05 + 3.5218971e-05 + 3.1478037e-05 + 3.0895699e-05 + 2.615025e-05 + 2.0906495e-05 + 1.7488654e-05 + 1.3209424e-05 + 9.7491848e-06 + 6.3581501e-06 + 5.6303825e-06 + -5.1143962e-07 + -4.6430905e-06 + -8.4661779e-06 + -1.0448402e-05 + -1.6193704e-05 + -1.857411e-05 + -2.250258e-05 + -2.3523124e-05 + -2.7104035e-05 + -2.8832133e-05 + -2.9649824e-05 + -3.12257e-05 + -3.2669741e-05 + -3.3304954e-05 + -3.3183347e-05 + -3.4332639e-05 + -3.3677767e-05 + -3.4504159e-05 + -3.454684e-05 + -3.2467542e-05 + -2.9868665e-05 + -2.9505636e-05 + -2.6500937e-05 + -2.6333106e-05 + -2.3109949e-05 + -2.140675e-05 + -1.6538143e-05 + -1.4951454e-05 + -1.0329346e-05 + -8.6922209e-06 + -6.4748251e-06 + -2.4234089e-06 + 2.1927521e-07 + 2.7016404e-06 + 3.5660794e-06 + 6.7710325e-06 + 1.154716e-05 + 1.27539e-05 + 1.4957743e-05 + 1.8768704e-05 + 1.983804e-05 + 2.258397e-05 + 2.3245073e-05 + 2.5949555e-05 + 2.7714603e-05 + 2.4125953e-05 + 2.7313827e-05 + 2.6500267e-05 + 2.8872726e-05 + 2.8494722e-05 + 2.8652294e-05 + 2.6291838e-05 + 2.3836281e-05 + 2.2856551e-05 + 2.24215e-05 + 2.2928167e-05 + 2.0600462e-05 + 2.1569322e-05 + 1.8669114e-05 + 1.6274531e-05 + 1.3573073e-05 + 1.2755655e-05 + 9.1842421e-06 + 4.9424475e-06 + 1.9999163e-06 + 1.2401867e-06 + -3.0244464e-06 + -7.6198962e-06 + -9.8329774e-06 + -8.8280267e-06 + -1.377236e-05 + -1.6982995e-05 + -1.9108473e-05 + -2.0853575e-05 + -2.3638708e-05 + -2.4330864e-05 + -2.3607576e-05 + -2.3350785e-05 + -2.4861311e-05 + -2.4024377e-05 + -2.7649214e-05 + -3.0116586e-05 + -2.7083521e-05 + -2.6461454e-05 + -2.5706378e-05 + -2.3319637e-05 + -2.2089596e-05 + -1.7878658e-05 + -1.7124203e-05 + -1.5375375e-05 + -1.5521959e-05 + -1.172509e-05 + -9.1009997e-06 + -5.6435597e-06 + -2.9174676e-06 + -5.4268908e-06 + -1.5508874e-06 + -3.7975212e-07 + 3.1173399e-06 + 1.9381382e-06 + 5.5445184e-06 + 6.774098e-06 + 8.9054111e-06 + 1.0997211e-05 + 1.4307585e-05 + 1.3101091e-05 + 1.5396869e-05 + 1.3836742e-05 + 1.4298585e-05 + 1.65646e-05 + 1.5446933e-05 + 1.9028628e-05 + 2.0577343e-05 + 1.6241767e-05 + 1.6588914e-05 + 1.6793663e-05 + 1.5231977e-05 + 1.3574629e-05 + 1.3824551e-05 + 1.3580589e-05 + 8.8718243e-06 + 8.9766982e-06 + 4.874571e-06 + 6.1740734e-06 + 4.3778728e-06 + 3.0633016e-06 + 2.650128e-06 + 4.4499197e-06 + 5.2487553e-07 + 3.844505e-06 + 8.3970571e-07 + -4.0378814e-06 + -4.2863321e-06 + -3.9477163e-06 + -5.5808941e-06 + -8.159157e-06 + -1.07823e-05 + -1.0445928e-05 + -1.4758529e-05 + -1.5891597e-05 + -1.6962238e-05 + -1.6818865e-05 + -1.3153352e-05 + -1.3562746e-05 + -1.536158e-05 + -1.6916658e-05 + -1.5912401e-05 + -1.9311357e-05 + -1.3812277e-05 + -1.7308477e-05 + -1.1393254e-05 + -6.9415369e-06 + -8.5329793e-06 + -7.3732735e-06 + -8.2779943e-06 + -4.1989624e-06 + -4.0598088e-06 + -6.2781332e-06 + -6.1900923e-06 + -9.3725657e-06 + -9.9827339e-06 + -9.6235508e-06 + -4.7038488e-06 + -3.4777854e-06 + -2.7908015e-06 + 1.7161137e-06 + 2.1103369e-06 + 1.6298396e-06 + 5.1353272e-06 + 9.7297398e-06 + 7.9292831e-06 + 1.0491432e-05 + 8.7098369e-06 + 1.1306504e-05 + 1.2767204e-05 + 1.0523996e-05 + 1.5876185e-05 + 1.8240517e-05 + 1.7410239e-05 + 1.8709565e-05 + 2.0682788e-05 + 2.2414559e-05 + 2.3641453e-05 + 2.9956356e-05 + 3.1942258e-05 + 3.2165972e-05 + 2.3073231e-05 + 2.1864589e-05 + 2.3307522e-05 + 2.6105658e-05 + 3.0764437e-05 + 2.5258372e-05 + 2.4398061e-05 + 1.5440721e-05 + 7.2866023e-06 + 4.1072926e-06 + 1.3465999e-05 + 9.5875193e-06 + 3.303629e-06 + -9.6435542e-06 + -1.4834303e-05 + -1.3345806e-05 + -1.2496928e-05 + -1.2373329e-05 + -1.9174164e-05 + -2.2750348e-05 + -1.0412362e-05 + -7.1453283e-06 + -5.0996732e-06 + -1.4278352e-06 + 1.091708e-05 + 6.6890452e-06 + 2.0174368e-05 + 1.0472003e-05 + 4.7418193e-06 + 9.2978889e-06 + 4.5979341e-06 + 1.164395e-05 + -1.1824308e-05 + -1.2670253e-05 + -7.1008421e-06 + 4.0426371e-06 + 9.691882e-06 + 3.4888384e-05 + 2.3447481e-05 + 6.0634087e-05 + 4.6600537e-05 + 3.8806083e-05 + 4.0546623e-05 + 5.6960853e-05 + 1.7836719e-05 + -8.4526189e-05 + -0.00019142308 + + 0.54968381075777017 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacRcross.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacRcross.xml new file mode 100644 index 0000000000..a08bdabff6 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacRcross.xml @@ -0,0 +1,509 @@ + + + + + 501 + 0 + 0.0022387446 + 0.0035028025 + 0.0056085354 + 0.0086741624 + 0.011819702 + 0.015920334 + 0.020022845 + 0.024242017 + 0.028022908 + 0.032008588 + 0.034803107 + 0.037513334 + 0.039289925 + 0.039613295 + 0.040232945 + 0.039999284 + 0.038773619 + 0.037022036 + 0.03395154 + 0.030716933 + 0.027687127 + 0.024219509 + 0.020108201 + 0.01619355 + 0.013057033 + 0.0098494859 + 0.0073886877 + 0.0050956123 + 0.0031476091 + 0.0022303942 + 0.0014421673 + 0.0015605417 + 0.0023478915 + 0.0032595003 + 0.0048598177 + 0.0068661571 + 0.0093070166 + 0.01151516 + 0.014135026 + 0.015877407 + 0.017582361 + 0.020061353 + 0.021256194 + 0.022746835 + 0.023190113 + 0.023767922 + 0.023968713 + 0.023062855 + 0.022064622 + 0.020306958 + 0.019000532 + 0.017193301 + 0.014820882 + 0.012806546 + 0.01087003 + 0.0087013068 + 0.006995955 + 0.0053816945 + 0.0039921342 + 0.0027184775 + 0.0019667295 + 0.0015231621 + 0.0012839382 + 0.0015572251 + 0.0018984043 + 0.0027348096 + 0.0038960488 + 0.0049909945 + 0.0061516701 + 0.0075028935 + 0.0090615265 + 0.010369415 + 0.011767319 + 0.012683169 + 0.013795277 + 0.014282157 + 0.014870015 + 0.014935284 + 0.01447196 + 0.014191067 + 0.013750138 + 0.012850181 + 0.011913967 + 0.010623846 + 0.0090860547 + 0.0075213881 + 0.0063633667 + 0.0050101974 + 0.0040042601 + 0.0031182179 + 0.0022295942 + 0.0017177914 + 0.0013426655 + 0.0011556742 + 0.0012329743 + 0.0015336524 + 0.0020214748 + 0.002688495 + 0.003164774 + 0.0040248022 + 0.0049421801 + 0.0056449943 + 0.0064900178 + 0.0073318691 + 0.0079388851 + 0.008348099 + 0.0085937753 + 0.0088053253 + 0.0089643188 + 0.008462159 + 0.0081677679 + 0.0077010952 + 0.0069283829 + 0.006470554 + 0.005889717 + 0.0050404803 + 0.0043520979 + 0.0038374509 + 0.0031289412 + 0.0025550255 + 0.0020456621 + 0.001599103 + 0.0014034451 + 0.0012568776 + 0.0012050986 + 0.0012863051 + 0.0015274084 + 0.0017116911 + 0.0021996475 + 0.0025582563 + 0.0031697224 + 0.0036516772 + 0.0039112582 + 0.004503814 + 0.0045496449 + 0.0050086039 + 0.0053778985 + 0.0057354039 + 0.0060177911 + 0.0058440645 + 0.0055686114 + 0.0052352445 + 0.0049270913 + 0.0048669502 + 0.0044287615 + 0.0041116709 + 0.0037526242 + 0.0034778048 + 0.0031402872 + 0.0026885001 + 0.0022954869 + 0.0020505243 + 0.0017681995 + 0.001462435 + 0.0014559019 + 0.0014701682 + 0.0013319635 + 0.0015024599 + 0.0015520391 + 0.0018194491 + 0.0021310409 + 0.0023092343 + 0.0024470286 + 0.0026841904 + 0.0029517743 + 0.0030204616 + 0.0031903982 + 0.0035431373 + 0.0036453719 + 0.0038470726 + 0.003884491 + 0.003770831 + 0.0036215147 + 0.0034913709 + 0.0032639375 + 0.0030114818 + 0.0029031846 + 0.0027138728 + 0.0025935557 + 0.0024792887 + 0.0023132155 + 0.0020489933 + 0.0017954031 + 0.0016809653 + 0.0016296633 + 0.0015161918 + 0.0015554987 + 0.0015267093 + 0.0014726454 + 0.0015520853 + 0.0015158142 + 0.0017054193 + 0.0017699038 + 0.0020224431 + 0.0020263321 + 0.0022970943 + 0.0024474261 + 0.0025665488 + 0.002722204 + 0.0026923788 + 0.0027975827 + 0.0029700601 + 0.0029943788 + 0.0029474057 + 0.0027856492 + 0.002572892 + 0.0024962148 + 0.0024007454 + 0.0024167555 + 0.0022556121 + 0.0022061216 + 0.0021027932 + 0.0019645824 + 0.001897946 + 0.0017563587 + 0.0016798339 + 0.0016300865 + 0.0016609513 + 0.0016948835 + 0.0016175172 + 0.0016812063 + 0.0017271228 + 0.00175084 + 0.0019140517 + 0.0019397533 + 0.0018281466 + 0.0019714897 + 0.0020356507 + 0.0018801339 + 0.0020357326 + 0.0021443837 + 0.0021825135 + 0.0021718931 + 0.0022797454 + 0.0023199783 + 0.0023760132 + 0.002417963 + 0.0024605121 + 0.0024108223 + 0.0024090286 + 0.0024217165 + 0.0023988171 + 0.0022688324 + 0.0023057433 + 0.0022299876 + 0.0021526574 + 0.0022378063 + 0.0020277784 + 0.002016233 + 0.0020046735 + -0.294002 + -0.177398 + -0.39839 + -0.48773 + -0.172094 + -0.41209301 + -0.408075 + -0.30323401 + -0.31504101 + -0.36764601 + -0.22680099 + -0.362151 + -0.37852699 + -0.41337499 + -0.42870599 + -0.370096 + -0.39703399 + -0.43473601 + -0.35783899 + -0.31582201 + -0.398561 + -0.209665 + -0.403451 + -0.45481399 + -0.29749301 + -0.32480201 + -0.386527 + -0.19479001 + -0.36277401 + -0.33375701 + -0.28211099 + -0.394546 + -0.406385 + -0.114484 + -0.42001301 + -0.403752 + -0.20651101 + -0.30948099 + -0.34128401 + -0.120096 + -0.45341599 + -0.31077701 + -0.119248 + -0.43382999 + -0.175929 + 0.033982199 + -0.33926401 + -0.195425 + -0.071849696 + -0.37102601 + -0.21621799 + 0.0139881 + -0.35108399 + -0.138989 + 0.052345399 + -0.32499999 + -0.14821599 + 0.042676602 + -0.28181201 + -0.126936 + 0.0222029 + -0.287808 + -0.071663201 + 0.13822199 + -0.185139 + -0.0152797 + 0.230471 + -0.22155701 + 0.0130399 + 0.208427 + -0.127197 + 0.0064887698 + 0.236035 + -0.140938 + 0.192555 + 0.148371 + -0.121454 + 0.073920898 + 0.32382101 + -0.075303599 + 0.187121 + 0.197079 + 0.088469401 + 0.14371 + 0.346057 + 0.072195202 + 0.120678 + 0.37142599 + 0.134703 + 0.161566 + 0.34491301 + 0.110235 + 0.223032 + 0.215381 + 0.15115701 + 0.337161 + 0.34478301 + 0.154284 + 0.217981 + 0.31849399 + 0.27069601 + 0.32320201 + 0.201975 + 0.13255 + 0.19012199 + 0.22415 + 0.33738399 + 0.24033999 + 0.292528 + 0.231969 + 0.26378 + 0.30350101 + 0.23063 + 0.299878 + 0.15784501 + 0.276788 + 0.36825699 + 0.193731 + 0.21615 + 0.207757 + 0.136564 + 0.26222599 + 0.210265 + 0.13002799 + 0.20605899 + 0.152711 + 0.195077 + 0.29734299 + 0.237324 + 0.118121 + 0.29328901 + 0.22663499 + 0.075010903 + 0.26577801 + 0.119711 + 0.106759 + 0.27516001 + 0.105753 + 0.093085699 + 0.25944301 + 0.195959 + 0.0504844 + 0.237343 + 0.142589 + -0.089643501 + 0.282426 + 0.148966 + -0.0323091 + 0.160483 + 0.035948101 + -0.078566097 + 0.21877199 + 0.129273 + -0.15982699 + 0.0853457 + 0.116802 + -0.041748598 + 0.20506001 + 0.082346298 + -0.033599202 + 0.094616003 + 0.019920699 + -0.046248399 + 0.024650799 + -0.0416026 + -0.098334201 + 0.063990101 + -0.13928699 + -0.242319 + 0.024995901 + -0.18093801 + -0.249294 + 0.032946199 + -0.159826 + -0.23584101 + 0.016282201 + -0.196504 + -0.23710801 + -0.0406349 + -0.11625 + -0.115526 + 0.035594702 + -0.100031 + -0.131438 + -0.148066 + -0.246914 + -0.228278 + -0.128664 + -0.151379 + -0.120204 + -0.20564 + -0.19493499 + -0.223316 + -0.20992599 + -0.293475 + -0.181631 + -0.15154199 + -0.18523701 + -0.277973 + -0.212514 + -0.25714999 + -0.106606 + -0.17149 + -0.28705299 + -0.17783999 + -0.288715 + -0.13793799 + -0.15577 + -0.101648 + -0.29286501 + -0.15349799 + -0.196582 + -0.151655 + -0.105669 + -0.233206 + -0.205688 + -0.120301 + -0.30407101 + -0.27380499 + -0.0567232 + -0.26257399 + -0.213572 + -0.188062 + -0.234014 + -0.147396 + -0.130597 + -0.127922 + -0.16339099 + -0.141241 + -0.14472499 + -0.10392 + -0.0510807 + -0.247492 + -0.058272298 + -0.0082769198 + -0.25879499 + -0.19123399 + 0.077861302 + -0.074387997 + -0.142011 + 0.081611998 + -0.12735599 + -0.153745 + 0.078688301 + -0.12088 + -0.122613 + 0.067525104 + -0.13781101 + 0.023367999 + 0.057603098 + + -12.673485642531887 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacVector.xml b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacVector.xml new file mode 100644 index 0000000000..d318d513c0 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/AutocorrTest_EacVector.xml @@ -0,0 +1,509 @@ + + + + + 501 + 1 + 0.91440845 + 0.89127165 + 0.85387266 + 0.81370103 + 0.7681002 + 0.70884496 + 0.65127754 + 0.58396322 + 0.50845456 + 0.43051061 + 0.35105249 + 0.26587203 + 0.18143819 + 0.097567506 + 0.015512385 + -0.068423927 + -0.1456465 + -0.22284648 + -0.29907748 + -0.37475094 + -0.4380517 + -0.49662268 + -0.55154026 + -0.60047692 + -0.64397019 + -0.67695993 + -0.69747227 + -0.71946371 + -0.73064023 + -0.73969084 + -0.73910058 + -0.72273451 + -0.70480442 + -0.68460542 + -0.65121585 + -0.61127657 + -0.56959647 + -0.53186774 + -0.47233477 + -0.42289308 + -0.36013916 + -0.30238953 + -0.23851043 + -0.17228492 + -0.10760929 + -0.038677685 + 0.023924842 + 0.085734844 + 0.14554502 + 0.21178007 + 0.26366264 + 0.31547186 + 0.36479235 + 0.41372058 + 0.45014268 + 0.48719069 + 0.51477271 + 0.54144377 + 0.55743951 + 0.56827539 + 0.57417756 + 0.57521474 + 0.57242984 + 0.56181103 + 0.54661202 + 0.5273785 + 0.49807823 + 0.46791199 + 0.43094185 + 0.39116937 + 0.34865311 + 0.30475527 + 0.26447845 + 0.20973703 + 0.16015707 + 0.10805874 + 0.059454329 + 0.0076480238 + -0.045675594 + -0.089126058 + -0.14246953 + -0.18825532 + -0.22974341 + -0.27582318 + -0.30692092 + -0.34222001 + -0.37205994 + -0.39867413 + -0.42049485 + -0.43268493 + -0.446363 + -0.45471677 + -0.45743033 + -0.45754004 + -0.44663361 + -0.43691492 + -0.42143744 + -0.39964595 + -0.37948313 + -0.35078076 + -0.32291207 + -0.28617722 + -0.25431877 + -0.21413048 + -0.17472994 + -0.13722105 + -0.0940689 + -0.050582096 + -0.011372223 + 0.033095215 + 0.064681761 + 0.10605592 + 0.13676096 + 0.17619975 + 0.20634755 + 0.23424256 + 0.26192936 + 0.28315401 + 0.31159228 + 0.32296148 + 0.3337082 + 0.3472271 + 0.35520938 + 0.35884556 + 0.35598138 + 0.36070585 + 0.34978899 + 0.33616209 + 0.32133636 + 0.30463791 + 0.28434399 + 0.26060301 + 0.23513913 + 0.21211421 + 0.18200785 + 0.15506685 + 0.11292174 + 0.08485233 + 0.048554849 + 0.015430034 + -0.0053237719 + -0.043886948 + -0.069251105 + -0.099874027 + -0.1318848 + -0.15587749 + -0.18213047 + -0.19872877 + -0.22116253 + -0.23839074 + -0.24964274 + -0.25999296 + -0.26915544 + -0.28208914 + -0.28375041 + -0.2840305 + -0.28654379 + -0.27391881 + -0.26717883 + -0.25783545 + -0.24391536 + -0.23143035 + -0.21355876 + -0.19516303 + -0.17305651 + -0.14851433 + -0.13391782 + -0.10106573 + -0.079669952 + -0.054322001 + -0.022567146 + -0.0082916291 + 0.028239559 + 0.044842608 + 0.066723041 + 0.086818486 + 0.11206019 + 0.13034853 + 0.14292336 + 0.16384037 + 0.17437287 + 0.19422586 + 0.19642359 + 0.20773162 + 0.21621291 + 0.22017281 + 0.21870746 + 0.22144818 + 0.21968257 + 0.21284904 + 0.20909898 + 0.20217142 + 0.19360588 + 0.18018678 + 0.16507152 + 0.14102207 + 0.13159586 + 0.11218439 + 0.090035476 + 0.069503993 + 0.054288179 + 0.034861948 + 0.013234816 + -0.0047988398 + -0.024740862 + -0.042112309 + -0.057106286 + -0.079133794 + -0.08531253 + -0.10183473 + -0.11679 + -0.13124378 + -0.13978031 + -0.15192363 + -0.15962306 + -0.16721499 + -0.17583407 + -0.17053062 + -0.17783985 + -0.17420124 + -0.16439037 + -0.16967009 + -0.16545986 + -0.15178227 + -0.1513456 + -0.13972749 + -0.12844835 + -0.11278458 + -0.10008006 + -0.084673822 + -0.071988769 + -0.055301242 + -0.044846795 + -0.024612129 + -0.012670649 + 0.0064235702 + 0.017517105 + 0.032193232 + 0.05088919 + 0.059888519 + 0.073218867 + 0.084005043 + 0.097417012 + 0.11064502 + 0.11908618 + 0.12669091 + 0.12785465 + 0.13891017 + 0.14016822 + 0.15007298 + 4.4267403e-05 + 4.3514352e-05 + 4.3138727e-05 + 4.1891646e-05 + 4.0179297e-05 + 3.8032213e-05 + 3.7556416e-05 + 3.5218971e-05 + 3.1478037e-05 + 3.0895699e-05 + 2.615025e-05 + 2.0906495e-05 + 1.7488654e-05 + 1.3209424e-05 + 9.7491848e-06 + 6.3581501e-06 + 5.6303825e-06 + -5.1143962e-07 + -4.6430905e-06 + -8.4661779e-06 + -1.0448402e-05 + -1.6193704e-05 + -1.857411e-05 + -2.250258e-05 + -2.3523124e-05 + -2.7104035e-05 + -2.8832133e-05 + -2.9649824e-05 + -3.12257e-05 + -3.2669741e-05 + -3.3304954e-05 + -3.3183347e-05 + -3.4332639e-05 + -3.3677767e-05 + -3.4504159e-05 + -3.454684e-05 + -3.2467542e-05 + -2.9868665e-05 + -2.9505636e-05 + -2.6500937e-05 + -2.6333106e-05 + -2.3109949e-05 + -2.140675e-05 + -1.6538143e-05 + -1.4951454e-05 + -1.0329346e-05 + -8.6922209e-06 + -6.4748251e-06 + -2.4234089e-06 + 2.1927521e-07 + 2.7016404e-06 + 3.5660794e-06 + 6.7710325e-06 + 1.154716e-05 + 1.27539e-05 + 1.4957743e-05 + 1.8768704e-05 + 1.983804e-05 + 2.258397e-05 + 2.3245073e-05 + 2.5949555e-05 + 2.7714603e-05 + 2.4125953e-05 + 2.7313827e-05 + 2.6500267e-05 + 2.8872726e-05 + 2.8494722e-05 + 2.8652294e-05 + 2.6291838e-05 + 2.3836281e-05 + 2.2856551e-05 + 2.24215e-05 + 2.2928167e-05 + 2.0600462e-05 + 2.1569322e-05 + 1.8669114e-05 + 1.6274531e-05 + 1.3573073e-05 + 1.2755655e-05 + 9.1842421e-06 + 4.9424475e-06 + 1.9999163e-06 + 1.2401867e-06 + -3.0244464e-06 + -7.6198962e-06 + -9.8329774e-06 + -8.8280267e-06 + -1.377236e-05 + -1.6982995e-05 + -1.9108473e-05 + -2.0853575e-05 + -2.3638708e-05 + -2.4330864e-05 + -2.3607576e-05 + -2.3350785e-05 + -2.4861311e-05 + -2.4024377e-05 + -2.7649214e-05 + -3.0116586e-05 + -2.7083521e-05 + -2.6461454e-05 + -2.5706378e-05 + -2.3319637e-05 + -2.2089596e-05 + -1.7878658e-05 + -1.7124203e-05 + -1.5375375e-05 + -1.5521959e-05 + -1.172509e-05 + -9.1009997e-06 + -5.6435597e-06 + -2.9174676e-06 + -5.4268908e-06 + -1.5508874e-06 + -3.7975212e-07 + 3.1173399e-06 + 1.9381382e-06 + 5.5445184e-06 + 6.774098e-06 + 8.9054111e-06 + 1.0997211e-05 + 1.4307585e-05 + 1.3101091e-05 + 1.5396869e-05 + 1.3836742e-05 + 1.4298585e-05 + 1.65646e-05 + 1.5446933e-05 + 1.9028628e-05 + 2.0577343e-05 + 1.6241767e-05 + 1.6588914e-05 + 1.6793663e-05 + 1.5231977e-05 + 1.3574629e-05 + 1.3824551e-05 + 1.3580589e-05 + 8.8718243e-06 + 8.9766982e-06 + 4.874571e-06 + 6.1740734e-06 + 4.3778728e-06 + 3.0633016e-06 + 2.650128e-06 + 4.4499197e-06 + 5.2487553e-07 + 3.844505e-06 + 8.3970571e-07 + -4.0378814e-06 + -4.2863321e-06 + -3.9477163e-06 + -5.5808941e-06 + -8.159157e-06 + -1.07823e-05 + -1.0445928e-05 + -1.4758529e-05 + -1.5891597e-05 + -1.6962238e-05 + -1.6818865e-05 + -1.3153352e-05 + -1.3562746e-05 + -1.536158e-05 + -1.6916658e-05 + -1.5912401e-05 + -1.9311357e-05 + -1.3812277e-05 + -1.7308477e-05 + -1.1393254e-05 + -6.9415369e-06 + -8.5329793e-06 + -7.3732735e-06 + -8.2779943e-06 + -4.1989624e-06 + -4.0598088e-06 + -6.2781332e-06 + -6.1900923e-06 + -9.3725657e-06 + -9.9827339e-06 + -9.6235508e-06 + -4.7038488e-06 + -3.4777854e-06 + -2.7908015e-06 + 1.7161137e-06 + 2.1103369e-06 + 1.6298396e-06 + 5.1353272e-06 + 9.7297398e-06 + 7.9292831e-06 + 1.0491432e-05 + 8.7098369e-06 + 1.1306504e-05 + 1.2767204e-05 + 1.0523996e-05 + 1.5876185e-05 + 1.8240517e-05 + 1.7410239e-05 + 1.8709565e-05 + 2.0682788e-05 + 2.2414559e-05 + 2.3641453e-05 + 2.9956356e-05 + 3.1942258e-05 + 3.2165972e-05 + 2.3073231e-05 + 2.1864589e-05 + 2.3307522e-05 + 2.6105658e-05 + 3.0764437e-05 + 2.5258372e-05 + 2.4398061e-05 + 1.5440721e-05 + 7.2866023e-06 + 4.1072926e-06 + 1.3465999e-05 + 9.5875193e-06 + 3.303629e-06 + -9.6435542e-06 + -1.4834303e-05 + -1.3345806e-05 + -1.2496928e-05 + -1.2373329e-05 + -1.9174164e-05 + -2.2750348e-05 + -1.0412362e-05 + -7.1453283e-06 + -5.0996732e-06 + -1.4278352e-06 + 1.091708e-05 + 6.6890452e-06 + 2.0174368e-05 + 1.0472003e-05 + 4.7418193e-06 + 9.2978889e-06 + 4.5979341e-06 + 1.164395e-05 + -1.1824308e-05 + -1.2670253e-05 + -7.1008421e-06 + 4.0426371e-06 + 9.691882e-06 + 3.4888384e-05 + 2.3447481e-05 + 6.0634087e-05 + 4.6600537e-05 + 3.8806083e-05 + 4.0546623e-05 + 5.6960853e-05 + 1.7836719e-05 + -8.4526189e-05 + -0.00019142308 + + 0.54968381075777017 + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERF.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERF.xml new file mode 100644 index 0000000000..f968c0c25e --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERF.xml @@ -0,0 +1,11 @@ + + + + + 4 + 7.8450705641969325 + 2.6181457557146546 + -124.26093946666471 + 10.991394787222672 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERREST.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERREST.xml new file mode 100644 index 0000000000..05f9939df8 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnERREST.xml @@ -0,0 +1,10 @@ + + + + + 3 + 3.7998256591705597 + 0.82432886141340755 + 1.5224332184919882 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP1.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP1.xml new file mode 100644 index 0000000000..b39c37344a --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP1.xml @@ -0,0 +1,8 @@ + + + + + 1 + 28.790295709638542 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP2.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP2.xml new file mode 100644 index 0000000000..e30564ea47 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP2.xml @@ -0,0 +1,9 @@ + + + + + 2 + 38.159752015476776 + 0.7956683286568571 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP3.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP3.xml new file mode 100644 index 0000000000..74d4d3acb1 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP3.xml @@ -0,0 +1,10 @@ + + + + + 3 + 49.669368440495347 + 0.58492964998546348 + 6.4814246273214478 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP5.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP5.xml new file mode 100644 index 0000000000..9dd9a8bc4a --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP5.xml @@ -0,0 +1,12 @@ + + + + + 5 + 0.4874505859136089 + 5.593512789216291 + 0.5859548866294173 + 50.639858390563305 + -0.002429583757534859 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP7.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP7.xml new file mode 100644 index 0000000000..20c587183b --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP7.xml @@ -0,0 +1,14 @@ + + + + + 7 + 0.5512395081799536 + 6.5183422896301373 + -0.67296121974350642 + 31.927951035981206 + 1.186708933085455 + 42.008654192804514 + -0.0015455112108527936 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP9.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP9.xml new file mode 100644 index 0000000000..e9ecccc216 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnEXP9.xml @@ -0,0 +1,16 @@ + + + + + 9 + 15.957817686967116 + 221006.78653735726 + 114.88630569000553 + -33734.142061366547 + 7.6914607460936715 + 1876.2303193471271 + 0.75265207702909753 + 24.572552704802391 + -138.40801944191745 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnPRES.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnPRES.xml new file mode 100644 index 0000000000..fe3d48e213 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnPRES.xml @@ -0,0 +1,13 @@ + + + + + 6 + 0.2214172263311579 + 10.066519430470473 + 3.7707829256907712 + 0.72109681793857272 + 0.49886880345093437 + 1.000154618776814 + + diff --git a/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnVAC.xml b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnVAC.xml new file mode 100644 index 0000000000..35f0f01323 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/refdata/ExpfitTest_EffnVAC.xml @@ -0,0 +1,9 @@ + + + + + 2 + 1.3759034165632673 + 0.20054113811854915 + + diff --git a/src/gromacs/correlationfunctions/tests/testCOS3.xvg b/src/gromacs/correlationfunctions/tests/testCOS3.xvg new file mode 100644 index 0000000000..6f41600019 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/testCOS3.xvg @@ -0,0 +1,501 @@ +0 0.980215 0.84786 0.55111 +1 1.00563 0.766732 0.345733 +2 0.901045 0.646807 0.342314 +3 0.911231 0.637477 0.183936 +4 0.849712 0.50242 0.0810423 +5 0.77696 0.493325 0.0698848 +6 0.755667 0.444941 0.00746138 +7 0.724674 0.250751 -0.0151029 +8 0.663689 0.319373 -0.210542 +9 0.515147 0.109105 -0.192153 +10 0.579059 0.151557 -0.32202 +11 0.486462 0.0196987 -0.367642 +12 0.306271 -0.117139 -0.533263 +13 0.286981 -0.262968 -0.578647 +14 0.128506 -0.288335 -0.520779 +15 0.106801 -0.336168 -0.54033 +16 -0.0342238 -0.438876 -0.690429 +17 -0.189242 -0.517065 -0.733008 +18 -0.102822 -0.533843 -0.761297 +19 -0.286696 -0.492504 -0.764118 +20 -0.312994 -0.626441 -0.694044 +21 -0.433176 -0.582163 -0.738222 +22 -0.473521 -0.753763 -0.794075 +23 -0.514416 -0.784329 -0.710094 +24 -0.602884 -0.627913 -0.693283 +25 -0.701922 -0.788765 -0.697599 +26 -0.624715 -0.803903 -0.603359 +27 -0.633136 -0.62592 -0.542414 +28 -0.748294 -0.610642 -0.525884 +29 -0.681519 -0.726425 -0.554219 +30 -0.818801 -0.736255 -0.477194 +31 -0.779091 -0.683083 -0.439122 +32 -0.799431 -0.537976 -0.386361 +33 -0.74211 -0.458832 -0.25837 +34 -0.734999 -0.586292 -0.291565 +35 -0.752422 -0.409693 -0.224274 +36 -0.567355 -0.318048 -0.042563 +37 -0.48962 -0.259037 0.0429618 +38 -0.631321 -0.218146 -0.0215977 +39 -0.510246 -0.104216 0.203877 +40 -0.467046 -0.120795 0.271951 +41 -0.354142 -0.147802 0.153328 +42 -0.35987 0.0901972 0.278751 +43 -0.218068 0.0617962 0.315153 +44 -0.251885 0.0498296 0.449551 +45 -0.0739778 0.10528 0.330027 +46 -0.158898 0.306042 0.352122 +47 -0.0354126 0.365281 0.461546 +48 0.0111098 0.344993 0.553061 +49 0.0293386 0.465325 0.51471 +50 0.263435 0.412229 0.581141 +51 0.26077 0.489539 0.532995 +52 0.191436 0.406404 0.59817 +53 0.239305 0.500526 0.455499 +54 0.393089 0.560054 0.428476 +55 0.459268 0.625471 0.586418 +56 0.506983 0.521062 0.464051 +57 0.548327 0.567689 0.40065 +58 0.409701 0.619339 0.369207 +59 0.532969 0.56424 0.353377 +60 0.52379 0.565401 0.446169 +61 0.448233 0.514478 0.350512 +62 0.596133 0.396408 0.225304 +63 0.437427 0.400799 0.245919 +64 0.566243 0.388444 0.133041 +65 0.549138 0.427644 0.253539 +66 0.44934 0.344726 0.191529 +67 0.562821 0.276727 0.122273 +68 0.521943 0.253548 -0.0264084 +69 0.43181 0.298105 0.00961045 +70 0.319108 0.0887345 -0.123015 +71 0.366678 0.19142 -0.058703 +72 0.233041 0.111129 -0.126821 +73 0.29502 -0.0515529 -0.179635 +74 0.190305 0.0720675 -0.211369 +75 0.0935705 -0.146145 -0.316849 +76 0.0717608 -0.0630276 -0.268758 +77 0.0181038 -0.0806319 -0.393499 +78 0.0992837 -0.160283 -0.363726 +79 -0.075659 -0.169269 -0.390363 +80 -0.0234965 -0.246341 -0.275014 +81 -0.110975 -0.346189 -0.364672 +82 -0.0849593 -0.408301 -0.351602 +83 -0.0912708 -0.434549 -0.294002 +84 -0.177398 -0.39839 -0.48773 +85 -0.172094 -0.412093 -0.408075 +86 -0.303234 -0.315041 -0.367646 +87 -0.226801 -0.362151 -0.378527 +88 -0.413375 -0.428706 -0.370096 +89 -0.397034 -0.434736 -0.357839 +90 -0.315822 -0.398561 -0.209665 +91 -0.403451 -0.454814 -0.297493 +92 -0.324802 -0.386527 -0.19479 +93 -0.362774 -0.333757 -0.282111 +94 -0.394546 -0.406385 -0.114484 +95 -0.420013 -0.403752 -0.206511 +96 -0.309481 -0.341284 -0.120096 +97 -0.453416 -0.310777 -0.119248 +98 -0.43383 -0.175929 0.0339822 +99 -0.339264 -0.195425 -0.0718497 +100 -0.371026 -0.216218 0.0139881 +101 -0.351084 -0.138989 0.0523454 +102 -0.325 -0.148216 0.0426766 +103 -0.281812 -0.126936 0.0222029 +104 -0.287808 -0.0716632 0.138222 +105 -0.185139 -0.0152797 0.230471 +106 -0.221557 0.0130399 0.208427 +107 -0.127197 0.00648877 0.236035 +108 -0.140938 0.192555 0.148371 +109 -0.121454 0.0739209 0.323821 +110 -0.0753036 0.187121 0.197079 +111 0.0884694 0.14371 0.346057 +112 0.0721952 0.120678 0.371426 +113 0.134703 0.161566 0.344913 +114 0.110235 0.223032 0.215381 +115 0.151157 0.337161 0.344783 +116 0.154284 0.217981 0.318494 +117 0.270696 0.323202 0.201975 +118 0.13255 0.190122 0.22415 +119 0.337384 0.24034 0.292528 +120 0.231969 0.26378 0.303501 +121 0.23063 0.299878 0.157845 +122 0.276788 0.368257 0.193731 +123 0.21615 0.207757 0.136564 +124 0.262226 0.210265 0.130028 +125 0.206059 0.152711 0.195077 +126 0.297343 0.237324 0.118121 +127 0.293289 0.226635 0.0750109 +128 0.265778 0.119711 0.106759 +129 0.27516 0.105753 0.0930857 +130 0.259443 0.195959 0.0504844 +131 0.237343 0.142589 -0.0896435 +132 0.282426 0.148966 -0.0323091 +133 0.160483 0.0359481 -0.0785661 +134 0.218772 0.129273 -0.159827 +135 0.0853457 0.116802 -0.0417486 +136 0.20506 0.0823463 -0.0335992 +137 0.094616 0.0199207 -0.0462484 +138 0.0246508 -0.0416026 -0.0983342 +139 0.0639901 -0.139287 -0.242319 +140 0.0249959 -0.180938 -0.249294 +141 0.0329462 -0.159826 -0.235841 +142 0.0162822 -0.196504 -0.237108 +143 -0.0406349 -0.11625 -0.115526 +144 0.0355947 -0.100031 -0.131438 +145 -0.148066 -0.246914 -0.228278 +146 -0.128664 -0.151379 -0.120204 +147 -0.20564 -0.194935 -0.223316 +148 -0.209926 -0.293475 -0.181631 +149 -0.151542 -0.185237 -0.277973 +150 -0.212514 -0.25715 -0.106606 +151 -0.17149 -0.287053 -0.17784 +152 -0.288715 -0.137938 -0.15577 +153 -0.101648 -0.292865 -0.153498 +154 -0.196582 -0.151655 -0.105669 +155 -0.233206 -0.205688 -0.120301 +156 -0.304071 -0.273805 -0.0567232 +157 -0.262574 -0.213572 -0.188062 +158 -0.234014 -0.147396 -0.130597 +159 -0.127922 -0.163391 -0.141241 +160 -0.144725 -0.10392 -0.0510807 +161 -0.247492 -0.0582723 -0.00827692 +162 -0.258795 -0.191234 0.0778613 +163 -0.074388 -0.142011 0.081612 +164 -0.127356 -0.153745 0.0786883 +165 -0.12088 -0.122613 0.0675251 +166 -0.137811 0.023368 0.0576031 +167 -0.189745 -0.0722396 0.018102 +168 -0.0595371 -0.0306057 0.0829234 +169 -0.078322 0.0656503 0.0512902 +170 -0.132692 -0.0462057 0.0294912 +171 -0.0740977 0.073898 0.19823 +172 -0.0558499 0.0752766 0.142552 +173 0.0759637 0.123402 0.232148 +174 -0.0360002 0.145455 0.160842 +175 0.0436169 0.160745 0.162525 +176 0.0858365 0.100668 0.179054 +177 0.13627 0.0892889 0.0655269 +178 0.161949 0.17863 0.197206 +179 0.106877 0.177517 0.0546804 +180 0.0593105 0.149241 0.142748 +181 0.214126 0.0766684 0.0810017 +182 0.0547008 0.21327 0.177475 +183 0.0717283 0.0736023 0.154865 +184 0.191727 0.172906 0.119034 +185 0.14478 0.087557 0.0742026 +186 0.23908 0.132729 0.0355024 +187 0.203703 0.073267 0.0143013 +188 0.122586 0.213276 0.0651469 +189 0.0835698 0.0487019 0.133766 +190 0.0917354 0.169554 -0.041977 +191 0.113556 0.110627 0.110535 +192 0.183147 0.0180818 -0.0115564 +193 0.128454 0.100595 0.0386712 +194 0.163301 0.132653 -0.0680352 +195 0.196114 0.152816 0.0859278 +196 0.0286079 0.0400758 -0.0260642 +197 0.0880536 0.0830662 -0.0696107 +198 0.0915375 0.0893299 -0.0358353 +199 0.0509963 -0.0207323 -0.143666 +200 0.0416355 -0.092149 -0.0664544 +201 0.0468225 0.0383251 -0.0613309 +202 0.0107274 0.0410744 -0.0949562 +203 0.00933228 -0.0911049 -0.160811 +204 0.0217787 -0.144363 -0.101096 +205 0.0698741 -0.16287 -0.175699 +206 -0.0222541 -0.0185677 -0.0613003 +207 -0.10017 -0.0874568 -0.183911 +208 -0.124739 -0.176242 -0.0730185 +209 0.00860095 -0.158835 -0.0638301 +210 -0.0753048 -0.0403158 -0.0791765 +211 -0.121974 -0.0898573 -0.160381 +212 -0.0300112 -0.161479 -0.106232 +213 -0.0072594 -0.118346 -0.013073 +214 -0.140189 -0.123004 -0.1696 +215 -0.0339676 -0.0278884 -0.147712 +216 -0.110571 -0.120261 -0.0271705 +217 -0.137256 -0.0305097 -0.0102887 +218 -0.104694 -0.0970638 -0.0492807 +219 -0.15725 -0.0387797 -0.0991524 +220 -0.0535873 -0.189848 -0.0629756 +221 -0.0447722 -0.113558 0.00994687 +222 -0.0972935 -0.0299721 -0.118869 +223 -0.143216 -0.150272 -0.0945565 +224 -0.0342238 0.0223487 0.0838931 +225 -0.189588 0.0427961 0.0480686 +226 -0.150381 -0.0581302 -0.00364323 +227 -0.138787 0.0093412 -0.0574481 +228 -0.153102 -0.0615975 0.116143 +229 -0.060412 -0.0513939 -0.0577417 +230 0.0202902 -0.0246957 0.0801256 +231 -0.0200033 0.0275668 -0.0043169 +232 0.0293085 0.0427626 0.15295 +233 -0.0519639 -0.0702145 -0.0396086 +234 0.0761017 0.0374428 0.051298 +235 -0.0159578 0.0792842 0.0497498 +236 0.034143 0.0416644 -0.00292247 +237 0.0390065 0.144795 0.0173019 +238 0.0785221 -0.0182246 0.0322779 +239 0.08855 0.049747 0.094665 +240 0.0907667 0.00867691 0.0256048 +241 0.0713141 0.0126793 0.121408 +242 0.130155 0.131182 0.162077 +243 -0.0251589 0.0344113 0.061318 +244 0.00263686 0.116403 0.0435752 +245 0.0601417 0.0605919 0.122334 +246 0.140309 0.115836 0.0823734 +247 0.016011 0.0486162 0.148154 +248 0.00262091 0.0737306 0.072526 +249 0.0104423 0.122525 0.0314302 +250 -0.0121604 0.0365901 -0.00125785 +251 0.057694 0.0796572 0.0780739 +252 0.0105251 0.0256032 0.0185461 +253 0.176984 -0.0236614 0.0373487 +254 0.130621 0.0946323 0.0871696 +255 0.0184087 -0.0344569 -0.0683991 +256 -0.0285362 0.0517099 -0.0466689 +257 0.0359978 -0.0290421 -0.00906326 +258 0.139413 0.0805375 0.0462067 +259 -0.0417211 0.0459312 0.0709178 +260 0.131659 0.0797177 0.069449 +261 0.12139 -0.0308921 0.0236481 +262 -0.0473358 0.0443106 -0.072358 +263 0.084628 -0.0945129 0.0475128 +264 -0.071014 -0.0498558 0.0574321 +265 0.0737743 -0.0154591 -0.137914 +266 -0.0568069 -0.124133 -0.124654 +267 0.0666604 0.0191854 -0.119743 +268 0.041571 -0.0896298 -0.136019 +269 0.0326789 0.0194811 -0.137027 +270 -0.0600132 -0.0246257 -0.103282 +271 0.0021657 -0.0392893 0.0165702 +272 -0.0265276 0.0358137 -0.109032 +273 -0.00980905 -0.126957 0.0070903 +274 -0.112373 -0.142977 -0.0603599 +275 -0.0156997 -0.0061422 -0.0778784 +276 -0.141867 -0.0276022 -0.10555 +277 -0.0537075 -0.118422 -0.0688021 +278 -0.021912 0.0395811 -0.122468 +279 -0.142235 0.0242776 -0.131142 +280 -0.153856 -0.0539371 0.0487173 +281 -0.150066 0.0260706 -0.0484171 +282 0.0276874 -0.126691 -0.034534 +283 -0.0827422 -0.0664515 0.0509452 +284 -0.0961105 0.00643995 -0.0932914 +285 -0.0274402 -0.0195262 -0.0658101 +286 -0.134431 -0.0642967 -0.0574195 +287 0.00743148 -0.0152639 -0.0931265 +288 -0.00423643 0.0615726 -0.0341869 +289 -0.00121529 -0.0691136 0.0208955 +290 -0.0341773 0.00765812 0.0634719 +291 -0.0623566 -0.0894382 0.0760852 +292 -0.0612666 0.0517529 -0.0649392 +293 -0.101927 -0.0570001 -0.059353 +294 -0.0932661 -0.0140564 0.0587881 +295 -0.0342204 0.05115 -0.0077483 +296 0.00962707 0.0205178 -0.00930554 +297 0.086751 0.0407356 -0.0366705 +298 -0.0619837 0.0756976 -0.0100863 +299 0.0570416 0.0740328 -0.00593619 +300 0.0302965 0.121386 0.0437065 +301 0.0361282 -0.0495037 0.123276 +302 -0.062523 0.075657 -0.0168684 +303 -0.0562189 0.00751898 0.00902153 +304 0.0530975 0.0861497 0.0635998 +305 0.123772 0.103072 0.0125279 +306 0.046479 -0.0338678 0.135673 +307 -0.0563367 0.0694053 0.0863605 +308 -0.00974361 0.0449466 -0.00726647 +309 0.0645008 0.130862 -0.0300805 +310 -0.0102122 0.0417346 -0.0178576 +311 0.112372 -0.0570851 0.0815094 +312 0.0688116 0.0848637 0.0273649 +313 -0.0419733 0.085479 -0.0461803 +314 0.0577574 0.113394 0.0193587 +315 -0.0251148 0.00416879 0.0452759 +316 0.0129669 0.0516217 0.063999 +317 0.12351 0.0856708 0.0512581 +318 0.00205911 0.0124627 0.106923 +319 0.0915276 0.050777 0.0746293 +320 0.0447759 0.0116996 -0.061127 +321 -0.0109667 -0.0846675 -0.0540089 +322 0.0618661 -0.0517726 -0.0919522 +323 -0.0485281 -0.0735097 0.0261627 +324 0.0108828 0.00799162 -0.00281248 +325 0.00692862 -0.0243732 -0.07108 +326 -0.0159341 0.0429378 0.000305988 +327 0.0612861 0.0363946 0.0751722 +328 0.0682336 -0.0468204 -0.113224 +329 0.074241 0.0751501 -0.0933165 +330 0.0640157 -0.0512504 -0.119017 +331 0.00823924 0.0518188 -0.0208047 +332 -0.0522299 0.0381819 -0.00512094 +333 0.0609206 -0.0391507 0.0530922 +334 0.0448167 -0.0484483 0.000356115 +335 0.0603005 -0.0881785 -0.059333 +336 -0.0634416 -0.100544 -0.0499614 +337 0.0555596 0.0650417 -0.00739016 +338 0.0521511 -0.0904961 -0.015789 +339 0.0345315 0.0335526 -0.0157579 +340 0.0218467 -0.0659198 0.0542071 +341 0.00794727 0.00734579 -0.071046 +342 -0.115605 -0.059259 0.0317368 +343 -0.125382 -0.111452 0.00489641 +344 -0.00661221 -0.0946826 0.0502072 +345 -0.0828954 0.0533706 -0.106901 +346 0.0468269 0.0559098 -0.103946 +347 0.0627571 0.0246041 -0.00290758 +348 0.0430174 -0.0919724 0.0707788 +349 -0.0701459 -0.0746821 0.0259014 +350 -0.0659695 -0.0228015 0.0433118 +351 0.021503 -0.101376 0.0464046 +352 -0.00511543 -0.0885198 -0.0413994 +353 -0.115176 0.08576 -0.0920088 +354 -0.107332 0.0558678 -0.0642828 +355 -0.00758383 -0.0829995 0.0157428 +356 -0.0203309 0.0498391 0.0397182 +357 0.0759063 -0.000820063 0.0646244 +358 -0.0988938 0.0139485 -0.040957 +359 -0.100375 -0.0142476 0.0607591 +360 -0.0127385 -0.0447691 0.0204786 +361 -0.00720208 0.012704 0.101364 +362 0.0933342 0.0210504 0.103063 +363 0.0914453 -0.0212247 -0.00537845 +364 0.0222687 -0.0733793 0.0519698 +365 0.00887453 0.105965 0.0476493 +366 0.0393766 -0.0381711 0.0627169 +367 0.00992684 0.0120678 0.0319012 +368 -0.00524682 0.0858477 0.0545543 +369 -0.0276856 0.030261 0.0137738 +370 0.027146 0.0506496 -0.0606836 +371 -0.0409651 -0.0656822 0.0750463 +372 0.0261079 0.110611 0.0537327 +373 0.0683191 0.00103924 0.101136 +374 0.0223146 0.0638174 0.0372899 +375 0.0538864 0.026447 -0.0256291 +376 -0.0199266 0.0578314 -0.0205107 +377 -0.0287525 0.00897231 0.0789033 +378 0.011206 -0.0477837 -0.0527743 +379 0.0471543 -0.0419562 0.0626134 +380 0.0566571 0.0389111 0.10356 +381 0.0175098 0.0792653 0.0697493 +382 0.0516203 -0.00647098 -0.0733728 +383 0.0899533 0.0374349 0.0162332 +384 0.0490273 0.00456911 0.00870165 +385 -0.0153788 0.0137572 0.0249342 +386 0.109505 0.0779426 -0.0960305 +387 0.0230987 0.0716719 -0.034583 +388 -0.0308869 0.0992023 -0.076132 +389 0.049703 -0.00463838 0.0507225 +390 -0.0160384 -0.0116619 0.0794113 +391 -0.0251558 0.0270421 0.0103171 +392 0.0273061 -0.00456061 -0.0610323 +393 -0.0278667 -0.00932626 -0.0554114 +394 -0.0954355 -0.0612679 0.038761 +395 0.0116837 0.0508276 0.00879948 +396 -0.0921252 -0.00449076 -0.100855 +397 0.0595651 0.0473238 0.0656456 +398 0.00559781 0.0358737 0.0698283 +399 0.0325561 0.0287903 -0.103249 +400 -0.0611306 0.0483602 -0.0651726 +401 0.0530863 -0.0870683 -0.0114436 +402 0.0706962 0.000487238 -0.0722344 +403 0.0812003 -0.0450292 0.0609868 +404 -0.0902842 0.0756444 -0.0795868 +405 0.0342166 -0.0107851 0.0474598 +406 -0.0755312 -0.0418849 0.06597 +407 0.0782342 -0.0275304 -0.00841178 +408 -0.0404713 0.00561785 0.0787162 +409 -0.0985844 -0.0632749 -0.0258086 +410 -0.102143 0.0257031 0.0809771 +411 0.0299029 -0.00559649 0.0390066 +412 0.034459 -0.00404783 0.014188 +413 -0.016108 -0.0565063 0.0656708 +414 0.0809532 -0.0208452 -0.0651575 +415 -0.0251259 -0.0314543 -0.0551357 +416 -0.0949532 0.0830507 0.016536 +417 -0.0878092 -0.0828968 0.0055337 +418 -0.0826239 -0.101344 -0.0400788 +419 -0.0111641 0.0395108 0.016706 +420 0.028367 0.0597103 -0.0745472 +421 0.0141354 -0.0712234 0.0260366 +422 0.00158414 0.0215662 -0.0662277 +423 0.0182286 -0.032185 0.0981183 +424 0.0403989 0.0722646 0.0815234 +425 0.0763858 -0.0237108 0.0734619 +426 0.0749794 0.0654159 -0.0269555 +427 -0.01714 0.0617229 0.028065 +428 0.0490571 -0.0055667 -0.0504239 +429 -0.0592585 0.00800895 -0.0364137 +430 0.0356458 -0.0462567 -0.0565739 +431 0.0304146 0.0883306 -0.0221918 +432 -0.032884 -0.0858759 -0.0727408 +433 -0.0157107 0.103217 -0.0525016 +434 0.0840815 -0.0678038 0.0487336 +435 -0.0136451 -0.0254523 -0.0494127 +436 0.0481152 0.0318921 -0.0711827 +437 0.0669082 -0.00405252 0.1008 +438 -0.0756365 0.107987 0.0485059 +439 0.0971897 -0.0468521 0.0878878 +440 -0.0395712 0.0705408 -0.0558674 +441 -0.0188154 -0.00529399 0.0839984 +442 0.0746482 -0.00178176 0.0844743 +443 -0.0253263 -0.0826901 -0.0344131 +444 0.0200462 -0.0762975 0.045179 +445 -0.0194727 0.0442604 0.066079 +446 -0.0425051 0.00700625 0.0682874 +447 0.00871708 -0.0705593 0.0118328 +448 -0.0118458 0.000796106 -0.027898 +449 0.0226526 -0.0742575 -0.041394 +450 0.0307982 -0.0477487 -0.0859615 +451 0.00750597 -0.00622766 -0.076102 +452 0.0841357 -0.0354635 0.0520188 +453 0.0884507 0.0470198 0.0603375 +454 0.0726154 -0.0256462 -0.0204797 +455 0.0588101 0.00135376 -0.0994888 +456 -0.0512545 -0.102458 0.0550721 +457 0.0207424 -0.0420637 -0.0171892 +458 -0.0167934 0.0343817 0.0216211 +459 0.0853327 0.0416083 -0.104239 +460 0.0685533 0.00330597 0.0908588 +461 0.0831542 0.0777739 -0.0795082 +462 -0.0525808 -0.0390724 0.057681 +463 -0.0777708 -0.0555692 -0.0935927 +464 0.0156546 0.055027 0.00757796 +465 0.0352357 0.0601726 -0.0158123 +466 0.0892271 0.0551928 0.0615953 +467 -0.00601811 -0.034404 0.051511 +468 -0.0875655 -0.00102833 0.0364426 +469 0.0343225 -0.0193016 -0.0429046 +470 0.0237604 -0.105861 -0.0114598 +471 0.0624156 -0.102361 0.0263063 +472 -0.032 0.0271664 -0.0176814 +473 -0.0547783 -0.0769611 -0.0828618 +474 -0.00660219 -0.0272973 -0.0851916 +475 -0.00607989 -0.0831763 0.00508346 +476 -0.00919653 -0.0785865 0.0022782 +477 -0.0873774 -0.00788886 -0.0605173 +478 0.0831451 -0.0517538 -0.029326 +479 -0.0775978 -0.0502973 -0.0660945 +480 0.022881 0.0856377 0.0377766 +481 0.0346714 -0.00127431 0.0261189 +482 0.0132186 0.0532034 -0.0723848 +483 0.0200223 -0.0577082 0.0559004 +484 -0.00117771 -0.0906531 0.0213202 +485 0.085207 0.0652701 0.0662271 +486 0.0669462 -0.0557815 -0.0583366 +487 0.0196271 -0.0298252 -0.0782588 +488 -0.0372764 0.00892936 -0.0904771 +489 0.041935 -0.00854382 -0.0927152 +490 -0.0598391 -0.0137204 -0.0609897 +491 0.034607 0.0648553 -0.0128075 +492 -0.0934921 -0.0226216 -0.00705076 +493 0.0728948 0.0116726 -0.00765632 +494 0.101406 0.0161229 -0.0828996 +495 0.00169226 0.0232688 0.0290798 +496 0.072528 -0.0770499 -0.0124139 +497 0.0578824 0.0609395 0.00790179 +498 -0.0153936 0.0875941 0.104917 +499 -0.0776594 0.0832574 0.0209262 +500 -0.0864071 0.0137418 -0.0414727 diff --git a/src/gromacs/correlationfunctions/tests/testEXP.xvg b/src/gromacs/correlationfunctions/tests/testEXP.xvg new file mode 100644 index 0000000000..a192c51c80 --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/testEXP.xvg @@ -0,0 +1,501 @@ +0 0 +1 0.933793 +2 1.64413 +3 2.26881 +4 2.69732 +5 3.18609 +6 3.5633 +7 3.77591 +8 4.083 +9 4.27165 +10 4.50143 +11 4.68664 +12 4.84612 +13 4.93256 +14 5.0487 +15 5.21257 +16 5.29916 +17 5.32257 +18 5.43037 +19 5.50601 +20 5.60239 +21 5.62398 +22 5.72622 +23 5.77308 +24 5.7562 +25 5.84888 +26 5.81699 +27 5.86178 +28 5.94235 +29 5.95981 +30 5.98369 +31 5.95674 +32 6.06792 +33 6.07991 +34 6.11024 +35 6.12377 +36 6.06567 +37 6.16848 +38 6.15328 +39 6.16295 +40 6.16469 +41 6.22697 +42 6.1776 +43 6.27148 +44 6.23865 +45 6.2744 +46 6.27211 +47 6.29498 +48 6.31175 +49 6.28439 +50 6.34758 +51 6.26659 +52 6.29551 +53 6.31016 +54 6.31924 +55 6.32594 +56 6.39353 +57 6.37555 +58 6.4125 +59 6.34882 +60 6.34253 +61 6.37401 +62 6.42251 +63 6.44891 +64 6.41029 +65 6.36925 +66 6.45488 +67 6.47461 +68 6.39323 +69 6.41703 +70 6.47664 +71 6.47864 +72 6.40653 +73 6.4444 +74 6.4901 +75 6.49016 +76 6.43924 +77 6.50607 +78 6.48499 +79 6.4465 +80 6.51673 +81 6.44586 +82 6.53225 +83 6.51432 +84 6.52803 +85 6.49069 +86 6.51123 +87 6.54134 +88 6.50065 +89 6.49403 +90 6.54445 +91 6.56578 +92 6.54692 +93 6.58151 +94 6.5848 +95 6.5796 +96 6.53327 +97 6.57402 +98 6.51995 +99 6.59609 +100 6.59545 +101 6.51956 +102 6.54083 +103 6.53558 +104 6.51182 +105 6.5347 +106 6.55378 +107 6.58284 +108 6.56471 +109 6.57831 +110 6.59092 +111 6.62654 +112 6.54307 +113 6.57412 +114 6.60729 +115 6.59664 +116 6.63216 +117 6.59422 +118 6.61469 +119 6.62636 +120 6.57808 +121 6.57356 +122 6.63797 +123 6.58006 +124 6.62347 +125 6.56521 +126 6.63422 +127 6.57666 +128 6.56846 +129 6.57003 +130 6.56552 +131 6.56682 +132 6.58905 +133 6.59197 +134 6.58329 +135 6.57486 +136 6.6287 +137 6.62418 +138 6.57194 +139 6.62585 +140 6.59216 +141 6.66186 +142 6.61182 +143 6.64493 +144 6.60235 +145 6.64946 +146 6.58789 +147 6.636 +148 6.60824 +149 6.59174 +150 6.67204 +151 6.63844 +152 6.64634 +153 6.61669 +154 6.60086 +155 6.68471 +156 6.6902 +157 6.65257 +158 6.61755 +159 6.67101 +160 6.6674 +161 6.63823 +162 6.63133 +163 6.6367 +164 6.66352 +165 6.696 +166 6.60881 +167 6.67253 +168 6.66735 +169 6.66583 +170 6.66259 +171 6.63691 +172 6.6766 +173 6.6913 +174 6.65969 +175 6.61821 +176 6.6796 +177 6.70715 +178 6.67694 +179 6.69653 +180 6.64676 +181 6.65935 +182 6.6781 +183 6.71181 +184 6.70878 +185 6.67739 +186 6.64651 +187 6.66021 +188 6.71047 +189 6.65987 +190 6.6511 +191 6.71258 +192 6.71689 +193 6.65441 +194 6.65054 +195 6.66806 +196 6.70738 +197 6.64787 +198 6.69967 +199 6.6331 +200 6.63513 +201 6.69851 +202 6.64237 +203 6.70702 +204 6.70229 +205 6.66568 +206 6.6818 +207 6.68629 +208 6.71863 +209 6.73129 +210 6.66952 +211 6.69274 +212 6.67642 +213 6.6782 +214 6.65372 +215 6.7269 +216 6.70297 +217 6.64193 +218 6.65786 +219 6.73524 +220 6.70002 +221 6.6906 +222 6.70867 +223 6.7153 +224 6.66604 +225 6.70376 +226 6.70701 +227 6.71955 +228 6.73206 +229 6.71019 +230 6.70016 +231 6.72956 +232 6.64624 +233 6.73931 +234 6.70839 +235 6.67605 +236 6.67944 +237 6.7271 +238 6.72234 +239 6.66538 +240 6.71936 +241 6.66755 +242 6.68937 +243 6.724 +244 6.68827 +245 6.69197 +246 6.66415 +247 6.69317 +248 6.69017 +249 6.70377 +250 6.70761 +251 6.74691 +252 6.7327 +253 6.66325 +254 6.67565 +255 6.68625 +256 6.71185 +257 6.65938 +258 6.66814 +259 6.69835 +260 6.71306 +261 6.68137 +262 6.68514 +263 6.69503 +264 6.70687 +265 6.70667 +266 6.71226 +267 6.74293 +268 6.6743 +269 6.70273 +270 6.68393 +271 6.71818 +272 6.72623 +273 6.73187 +274 6.73242 +275 6.70873 +276 6.70823 +277 6.69239 +278 6.75188 +279 6.71371 +280 6.7502 +281 6.69877 +282 6.6998 +283 6.66478 +284 6.70866 +285 6.73126 +286 6.73144 +287 6.70046 +288 6.70388 +289 6.6847 +290 6.75264 +291 6.73971 +292 6.70705 +293 6.7407 +294 6.67035 +295 6.72357 +296 6.73306 +297 6.73084 +298 6.68237 +299 6.76651 +300 6.72838 +301 6.76579 +302 6.744 +303 6.6963 +304 6.76216 +305 6.66966 +306 6.67184 +307 6.67226 +308 6.67163 +309 6.68679 +310 6.73726 +311 6.68492 +312 6.73491 +313 6.75372 +314 6.68562 +315 6.73127 +316 6.73742 +317 6.74772 +318 6.71254 +319 6.67357 +320 6.72034 +321 6.71205 +322 6.68542 +323 6.76568 +324 6.69664 +325 6.7009 +326 6.71605 +327 6.73142 +328 6.7524 +329 6.70307 +330 6.7459 +331 6.70831 +332 6.71814 +333 6.76659 +334 6.67721 +335 6.70581 +336 6.75936 +337 6.71626 +338 6.77537 +339 6.73916 +340 6.75086 +341 6.69825 +342 6.73784 +343 6.68206 +344 6.73098 +345 6.69878 +346 6.70428 +347 6.76935 +348 6.68665 +349 6.72539 +350 6.70694 +351 6.683 +352 6.76606 +353 6.74774 +354 6.69002 +355 6.77377 +356 6.71343 +357 6.71858 +358 6.77459 +359 6.72939 +360 6.74046 +361 6.71403 +362 6.70104 +363 6.7676 +364 6.70533 +365 6.68404 +366 6.73426 +367 6.74651 +368 6.73703 +369 6.7093 +370 6.68535 +371 6.78054 +372 6.68628 +373 6.74885 +374 6.75663 +375 6.78102 +376 6.78231 +377 6.69437 +378 6.69903 +379 6.70758 +380 6.74678 +381 6.7422 +382 6.72993 +383 6.68776 +384 6.74261 +385 6.75407 +386 6.76879 +387 6.70534 +388 6.6894 +389 6.71274 +390 6.73197 +391 6.75648 +392 6.74171 +393 6.73153 +394 6.68943 +395 6.75898 +396 6.72838 +397 6.74778 +398 6.72736 +399 6.77489 +400 6.77639 +401 6.70282 +402 6.71161 +403 6.76628 +404 6.77065 +405 6.77603 +406 6.68948 +407 6.76621 +408 6.72207 +409 6.72234 +410 6.75854 +411 6.77273 +412 6.76151 +413 6.74252 +414 6.73153 +415 6.69708 +416 6.74061 +417 6.75818 +418 6.72091 +419 6.74424 +420 6.78673 +421 6.74145 +422 6.69344 +423 6.72471 +424 6.72518 +425 6.76767 +426 6.71893 +427 6.78251 +428 6.78466 +429 6.78094 +430 6.77212 +431 6.74085 +432 6.74283 +433 6.73333 +434 6.78714 +435 6.77238 +436 6.73692 +437 6.73205 +438 6.70148 +439 6.77486 +440 6.76451 +441 6.79155 +442 6.73363 +443 6.69988 +444 6.77442 +445 6.78397 +446 6.7856 +447 6.73778 +448 6.70429 +449 6.7378 +450 6.74829 +451 6.69527 +452 6.75622 +453 6.7867 +454 6.76332 +455 6.72525 +456 6.72494 +457 6.78544 +458 6.7868 +459 6.73629 +460 6.75375 +461 6.71361 +462 6.73621 +463 6.74825 +464 6.70532 +465 6.78782 +466 6.73666 +467 6.79325 +468 6.69962 +469 6.71673 +470 6.72258 +471 6.72758 +472 6.70651 +473 6.70794 +474 6.77938 +475 6.71007 +476 6.7414 +477 6.77997 +478 6.71039 +479 6.77047 +480 6.71826 +481 6.73399 +482 6.69929 +483 6.7929 +484 6.77405 +485 6.79742 +486 6.76882 +487 6.74596 +488 6.71524 +489 6.7947 +490 6.75326 +491 6.72172 +492 6.71176 +493 6.71697 +494 6.74455 +495 6.78932 +496 6.70312 +497 6.72368 +498 6.70806 +499 6.70917 +500 6.79967 diff --git a/src/gromacs/correlationfunctions/tests/testINVEXP.xvg b/src/gromacs/correlationfunctions/tests/testINVEXP.xvg new file mode 100755 index 0000000000..a36eac59de --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/testINVEXP.xvg @@ -0,0 +1,501 @@ +0 1.0681 +1 0.943394 +2 0.940582 +3 0.876908 +4 0.772058 +5 0.717467 +6 0.62021 +7 0.637288 +8 0.612462 +9 0.660404 +10 0.587782 +11 0.604724 +12 0.414682 +13 0.485151 +14 0.437477 +15 0.400413 +16 0.492272 +17 0.485068 +18 0.524471 +19 0.331468 +20 0.466912 +21 0.478988 +22 0.409751 +23 0.290041 +24 0.278663 +25 0.327049 +26 0.342437 +27 0.303842 +28 0.439109 +29 0.296164 +30 0.343069 +31 0.248582 +32 0.307399 +33 0.2247 +34 0.210569 +35 0.36623 +36 0.311727 +37 0.281739 +38 0.297556 +39 0.322846 +40 0.323614 +41 0.238788 +42 0.208327 +43 0.34916 +44 0.303368 +45 0.258602 +46 0.304515 +47 0.190447 +48 0.308091 +49 0.160807 +50 0.181371 +51 0.192209 +52 0.181283 +53 0.201928 +54 0.105623 +55 0.246128 +56 0.128467 +57 0.186709 +58 0.195287 +59 0.131209 +60 0.123502 +61 0.21343 +62 0.265214 +63 0.198079 +64 0.0875281 +65 0.148709 +66 0.162407 +67 0.165434 +68 0.235861 +69 0.225641 +70 0.0716764 +71 0.224192 +72 0.0976416 +73 0.164153 +74 0.0848313 +75 0.0779902 +76 0.0789197 +77 0.123511 +78 0.095581 +79 0.187898 +80 0.0618937 +81 0.214364 +82 0.207497 +83 0.134731 +84 0.211358 +85 0.0212662 +86 0.123847 +87 0.0641108 +88 0.09398 +89 0.0165856 +90 0.0257984 +91 0.0374152 +92 0.00685148 +93 0.0827592 +94 0.0394362 +95 0.176037 +96 0.0588189 +97 0.00230256 +98 0.14224 +99 0.15686 +100 0.0514332 +101 0.123575 +102 0.0661031 +103 0.0936242 +104 0.165916 +105 0.065199 +106 0.0166701 +107 0.121875 +108 0.0783671 +109 0.0831681 +110 0.0477346 +111 0.0944206 +112 -0.00249231 +113 -0.00795285 +114 0.104603 +115 0.0897528 +116 0.0475694 +117 0.105319 +118 0.0818006 +119 0.137639 +120 0.00351689 +121 0.139798 +122 0.128182 +123 0.0740928 +124 0.0266052 +125 0.01518 +126 0.0764528 +127 -0.0478048 +128 0.145348 +129 -0.0278405 +130 0.0743014 +131 -0.0442497 +132 -0.019708 +133 0.0312048 +134 0.0508013 +135 0.0895047 +136 0.0205578 +137 0.11894 +138 -0.0355846 +139 0.0526809 +140 0.0259417 +141 0.000229281 +142 0.0478984 +143 0.0418232 +144 0.0504251 +145 0.0714415 +146 0.0905807 +147 -0.0255317 +148 -0.0387278 +149 0.0939955 +150 -0.020037 +151 -0.0230931 +152 -0.0375384 +153 0.0771837 +154 0.0622474 +155 -0.0626867 +156 0.122018 +157 -0.0446062 +158 -0.0246245 +159 0.0897752 +160 0.0498833 +161 0.0472345 +162 0.0583388 +163 -0.0347339 +164 0.0762762 +165 -0.0672939 +166 0.046974 +167 0.0223582 +168 -0.0599178 +169 -0.0605643 +170 -0.0708522 +171 0.0534838 +172 0.112608 +173 0.0901323 +174 -0.0488154 +175 0.0518089 +176 0.0541252 +177 -0.0691998 +178 0.0425829 +179 0.0192925 +180 -0.0710574 +181 -0.0671212 +182 -0.0424854 +183 -0.00173892 +184 -0.0106879 +185 -0.0576365 +186 0.0192927 +187 0.016837 +188 -0.0206993 +189 0.0350927 +190 0.0979423 +191 0.0528159 +192 0.106826 +193 -0.0702302 +194 -0.0487975 +195 -0.0589017 +196 -0.0146245 +197 0.0089213 +198 -0.0842674 +199 -0.0234645 +200 0.0565023 +201 0.00287557 +202 -0.0520075 +203 -0.00293986 +204 -0.0299982 +205 0.102979 +206 -0.0167894 +207 -0.0287721 +208 0.0207559 +209 0.0876499 +210 0.106049 +211 -0.0401939 +212 0.0195434 +213 -0.0314981 +214 0.108024 +215 -0.0271984 +216 -0.090313 +217 0.0936537 +218 0.0444229 +219 0.101328 +220 0.0322305 +221 -0.018528 +222 -0.00257325 +223 -0.0320265 +224 -0.0105935 +225 0.000379694 +226 0.00231763 +227 0.00982889 +228 -0.040522 +229 -0.0410073 +230 0.000112217 +231 -0.0148902 +232 0.0756062 +233 -0.0742674 +234 -0.0573473 +235 -0.0227042 +236 0.0972166 +237 -0.0418052 +238 -0.00486911 +239 0.0599813 +240 0.074408 +241 0.0899329 +242 -0.0437813 +243 0.0811337 +244 0.0342668 +245 0.0959573 +246 -0.0525791 +247 -0.0727846 +248 0.102521 +249 0.0381233 +250 -0.089035 +251 -0.0643688 +252 -0.0852113 +253 -0.0222789 +254 0.099484 +255 0.0382242 +256 0.0687417 +257 -0.0650391 +258 -0.0590526 +259 -0.0609537 +260 -0.0781632 +261 -0.0263208 +262 0.0187378 +263 -0.0436076 +264 0.048821 +265 -0.00552439 +266 0.0194677 +267 0.0920907 +268 -0.0609475 +269 0.0306231 +270 -0.0299242 +271 0.0303031 +272 0.0357398 +273 -0.041525 +274 -0.0890632 +275 -0.086406 +276 -0.00247411 +277 -0.0422722 +278 -0.0668341 +279 0.0957862 +280 0.0974149 +281 -0.0132207 +282 0.0459918 +283 0.0291298 +284 -0.0351444 +285 -0.0254443 +286 0.0340195 +287 0.00756723 +288 0.0238715 +289 -0.0274353 +290 -0.0856008 +291 0.0583847 +292 -0.0165585 +293 -0.0404389 +294 0.0103612 +295 0.0513012 +296 -0.00408748 +297 -0.0539004 +298 0.0202747 +299 0.0770502 +300 0.0150383 +301 0.0873767 +302 -0.0196684 +303 -0.0632305 +304 0.0573153 +305 0.0801514 +306 0.0941519 +307 -0.0209786 +308 0.0986031 +309 -0.00683724 +310 0.0340542 +311 -0.0769762 +312 0.0225878 +313 0.0603486 +314 -0.093571 +315 -0.0853193 +316 -0.0215317 +317 0.0523009 +318 0.0175962 +319 0.0762564 +320 -0.0976852 +321 0.0337763 +322 0.0767278 +323 0.0310502 +324 0.00986905 +325 0.0137131 +326 -0.0711432 +327 -0.0888209 +328 -0.0218738 +329 -0.000910774 +330 -0.0763064 +331 -0.0104076 +332 0.0988596 +333 0.0750879 +334 -0.00508757 +335 -0.0833086 +336 -0.0906822 +337 -0.0485789 +338 0.0497686 +339 -0.0125583 +340 0.0836466 +341 -0.0617063 +342 -0.0496492 +343 -0.08338 +344 -0.0968441 +345 -0.054627 +346 0.00546937 +347 0.0578465 +348 0.0143735 +349 0.0332627 +350 0.0861252 +351 0.0663102 +352 0.0308983 +353 0.0893619 +354 0.0277007 +355 0.075605 +356 0.0383847 +357 -0.0513761 +358 0.0884597 +359 -0.0641501 +360 0.0215607 +361 -0.0653902 +362 0.0966357 +363 -0.0567258 +364 0.0480028 +365 -0.0426312 +366 -0.0626624 +367 -0.0192904 +368 -0.0845387 +369 -0.0279446 +370 0.00569403 +371 0.0839343 +372 0.0978487 +373 -0.02417 +374 -0.0158972 +375 -0.0494234 +376 0.00957538 +377 0.000469922 +378 -0.0108498 +379 0.0162894 +380 0.0487372 +381 -0.0557467 +382 -0.0222935 +383 0.0371676 +384 -0.0232714 +385 -0.0209432 +386 -0.0980981 +387 0.0378866 +388 -0.0548227 +389 0.0672464 +390 0.0591308 +391 0.0117988 +392 0.0906635 +393 0.0278184 +394 -0.00406985 +395 0.0922327 +396 0.0835114 +397 0.00238354 +398 -0.00648136 +399 0.0534958 +400 -0.0609925 +401 0.0889696 +402 -0.0120165 +403 -0.0544075 +404 -0.0222787 +405 -0.0647516 +406 -0.0404564 +407 0.0184243 +408 0.056176 +409 0.0126803 +410 -0.0369847 +411 0.0492475 +412 0.0799349 +413 -0.0708037 +414 0.0655493 +415 -0.048577 +416 -0.0417596 +417 0.0804274 +418 -0.0920922 +419 -0.0870022 +420 -0.0373363 +421 -0.0118833 +422 0.0119897 +423 0.0904194 +424 -0.0882078 +425 0.0292385 +426 -0.0799874 +427 0.0656876 +428 -0.0801976 +429 -0.0795223 +430 -0.0302974 +431 0.0645107 +432 0.0188364 +433 0.0901072 +434 -0.014961 +435 -0.0714636 +436 -0.00657822 +437 -0.0570667 +438 -0.00645351 +439 0.03649 +440 0.0497419 +441 0.00386253 +442 0.0688225 +443 -0.022944 +444 0.0833869 +445 0.011775 +446 -0.0590674 +447 -0.00939986 +448 -0.0937156 +449 0.0277734 +450 -0.0824969 +451 0.0173356 +452 0.0468303 +453 -0.0794911 +454 -0.085217 +455 0.0162948 +456 0.046809 +457 -0.00383156 +458 0.0106462 +459 0.0524757 +460 -0.0554865 +461 0.0518396 +462 -0.0995535 +463 0.0887906 +464 0.0555471 +465 -0.0516458 +466 -0.0381637 +467 0.0649521 +468 0.0411061 +469 -0.077658 +470 -0.0838968 +471 0.0971887 +472 -0.0118835 +473 0.087111 +474 -0.088725 +475 0.0906914 +476 0.016415 +477 -0.091898 +478 0.0461889 +479 -0.079051 +480 -0.0247629 +481 0.0810491 +482 -0.095085 +483 0.0106392 +484 0.0945944 +485 -0.0103912 +486 -0.0226289 +487 0.00549821 +488 0.0166932 +489 -0.0258937 +490 -0.0953396 +491 -0.0643975 +492 0.0483682 +493 0.0041773 +494 -0.0933927 +495 -0.062249 +496 -0.0524264 +497 0.0154673 +498 -0.0758339 +499 -0.0898537 +500 0.0852957 diff --git a/src/gromacs/correlationfunctions/tests/testPRES.xvg b/src/gromacs/correlationfunctions/tests/testPRES.xvg new file mode 100644 index 0000000000..1a7c43923e --- /dev/null +++ b/src/gromacs/correlationfunctions/tests/testPRES.xvg @@ -0,0 +1,501 @@ +0 1 +1 -0.36916866 +2 0.014760643 +3 0.13679177 +4 -0.30409385 +5 0.29211639 +6 -0.091300702 +7 -0.039725083 +8 0.11034297 +9 -0.14710173 +10 0.10112144 +11 -0.010410828 +12 -0.032484227 +13 0.061104037 +14 -0.062734083 +15 0.025088122 +16 0.0090911273 +17 -0.017547903 +18 0.028334545 +19 -0.019187307 +20 0.0034395636 +21 0.0048080537 +22 -0.011152624 +23 0.01468337 +24 -0.0030113453 +25 -0.001243929 +26 0.0026129168 +27 -0.0026818807 +28 0.00064227781 +29 0.0074954932 +30 -0.0080780674 +31 0.00097865747 +32 -0.005031499 +33 -0.0052062969 +34 0.015055237 +35 -0.0095560328 +36 -0.0012146344 +37 0.010541719 +38 -0.012150134 +39 0.010456563 +40 0.0036188245 +41 -0.010936702 +42 0.010207533 +43 -0.012300312 +44 0.0095503834 +45 0.006544511 +46 -0.0066008741 +47 0.010029187 +48 -0.0071012281 +49 0.0031570678 +50 0.0012269821 +51 -0.0035287761 +52 0.0092208671 +53 -0.0050034278 +54 -0.0028083487 +55 0.0099907991 +56 -0.011213547 +57 0.0090618645 +58 0.00031212197 +59 -0.0078672003 +60 0.010691127 +61 -0.0142263 +62 0.0058443876 +63 0.009818197 +64 -0.015058958 +65 0.010990055 +66 -0.0046160689 +67 -0.00587247 +68 0.0080246324 +69 -0.013475108 +70 0.009457794 +71 0.0047824004 +72 -0.007228957 +73 0.0056784217 +74 -0.0053565642 +75 -0.0023129048 +76 0.0029403305 +77 0.0033938085 +78 -0.0027952122 +79 0.0049366451 +80 -0.0028004289 +81 -0.0050486784 +82 0.010090499 +83 -0.0066157412 +84 0.002647089 +85 0.004144073 +86 -0.0087895271 +87 0.0071204964 +88 -0.00012740103 +89 -0.0050871728 +90 0.0071564119 +91 -0.0033754525 +92 1.2455157e-05 +93 0.0030776314 +94 0.0017022748 +95 -0.001404079 +96 -0.00045972626 +97 0.002904963 +98 -0.00059061365 +99 0.0034982589 +100 -0.0040645105 +101 0.001922386 +102 -0.0048760292 +103 0.0036464155 +104 -0.0036342766 +105 -0.0017862264 +106 0.0059070168 +107 -0.0091214493 +108 0.0045011193 +109 -0.0060048408 +110 0.0060602812 +111 -0.0060052815 +112 -0.00020469623 +113 0.0065917101 +114 -0.0099221852 +115 0.014778086 +116 -0.0070540206 +117 -0.00076770342 +118 0.0079772927 +119 -0.0085905236 +120 -0.00062513836 +121 0.0039284039 +122 -0.0039490427 +123 0.0094788591 +124 -0.0089938099 +125 -0.00032447391 +126 0.012605208 +127 -0.012399453 +128 0.013065264 +129 -0.0065310037 +130 -0.0039457333 +131 0.0067739115 +132 -0.0068084074 +133 0.0013759999 +134 -0.00063317348 +135 -0.0021762489 +136 0.0030220418 +137 0.0015570751 +138 -0.0025386858 +139 -0.0014269051 +140 0.002304196 +141 0.0017299628 +142 0.0027960096 +143 0.0076820985 +144 -0.0079212418 +145 -0.0017760952 +146 0.00056810081 +147 -0.002893933 +148 0.0090171461 +149 -0.0048042782 +150 0.00058932377 +151 0.00017170853 +152 -0.0035441974 +153 0.0043755975 +154 0.0084104895 +155 -0.005701828 +156 0.0018862645 +157 -0.0037968043 +158 -0.0049495224 +159 0.010596751 +160 -0.0089947785 +161 0.0012556332 +162 0.0055142779 +163 -0.0062561089 +164 0.0038259902 +165 -0.0011985974 +166 -0.0049824898 +167 0.011615239 +168 -0.0088481353 +169 0.0067664258 +170 -0.0021850029 +171 -0.0020955691 +172 0.0065267348 +173 -0.0093968866 +174 0.010932961 +175 -0.0053299546 +176 0.00051623668 +177 0.010631414 +178 -0.0061742852 +179 0.0047321249 +180 -0.0041945108 +181 0.00041651391 +182 0.0059446844 +183 -0.0073002656 +184 0.0056609192 +185 -0.0031166474 +186 0.0030953688 +187 0.001780965 +188 -0.0028736768 +189 0.0018569937 +190 -0.013309515 +191 0.0091007007 +192 -0.0032373501 +193 -0.0039707857 +194 0.011440142 +195 -0.0057663289 +196 0.004801657 +197 -0.0013462481 +198 -0.010549285 +199 0.010122314 +200 -0.0035914536 +201 -0.00088911725 +202 0.0033173624 +203 -0.0043540954 +204 0.0030779559 +205 -0.0025979372 +206 0.0016403824 +207 -0.0024759414 +208 0.0032173406 +209 -0.0030610313 +210 -0.0016666896 +211 0.0015944701 +212 -0.0023360152 +213 0.0048610048 +214 -0.0032376247 +215 -4.3995002e-05 +216 6.6794023e-05 +217 0.0027313477 +218 0.0012655508 +219 -0.0017807253 +220 -0.0016059832 +221 -0.0032230254 +222 0.0025585309 +223 -0.0011469088 +224 -0.0003959904 +225 0.0053054824 +226 -0.0083941959 +227 0.0015681321 +228 0.0041374876 +229 -0.0057795873 +230 0.012391208 +231 -0.0089103375 +232 -0.0057140203 +233 0.010399712 +234 -0.0084861502 +235 0.0069274989 +236 -0.0035049527 +237 -0.0032573957 +238 0.006458053 +239 -0.0073720368 +240 0.004089722 +241 -0.0039903411 +242 0.0042265311 +243 0.0033469261 +244 -0.0019453617 +245 -0.002372851 +246 -0.0048265504 +247 0.0021513391 +248 0.0093348207 +249 -0.0069923934 +250 -0.0025467685 +251 0.0029155541 +252 -0.0025788452 +253 0.001574745 +254 0.0045629202 +255 -0.0040519536 +256 0.0076833817 +257 -0.0074180399 +258 -0.00063383685 +259 0.0068584823 +260 -0.0096914403 +261 0.0059967688 +262 0.00045410173 +263 -0.001403505 +264 0.0081904238 +265 -0.0071767739 +266 0.0059756132 +267 0.0017534261 +268 -0.004887574 +269 0.0048234918 +270 -0.0068738558 +271 0.0038855002 +272 0.0022543436 +273 -6.9437609e-05 +274 -0.0022807576 +275 0.0013418244 +276 0.0011818884 +277 0.00076014954 +278 0.0049090373 +279 -0.0070762441 +280 -0.0035987494 +281 -0.00042682359 +282 0.0075464111 +283 -0.0014126097 +284 -0.00064224669 +285 0.0043936991 +286 -0.0010854328 +287 0.0026627405 +288 -0.0056961166 +289 -0.0022827355 +290 0.00798009 +291 -0.0076570431 +292 0.0063197703 +293 -0.0046694987 +294 -0.0024289403 +295 0.014527988 +296 -0.004486569 +297 -0.0080975585 +298 0.0095232942 +299 -0.010183442 +300 0.01195895 +301 -0.004018328 +302 -0.011547823 +303 0.010954626 +304 -0.0091701818 +305 0.0042623717 +306 0.0034892822 +307 -0.010150087 +308 0.0037818881 +309 0.0026481578 +310 -0.0088027283 +311 0.0074229712 +312 -0.002371628 +313 -0.0019573871 +314 0.0067617097 +315 -0.0072601173 +316 0.001730287 +317 0.0016428277 +318 -0.0014072933 +319 0.0055637106 +320 -0.0082579367 +321 -0.00076510199 +322 0.0030415574 +323 -0.0036437184 +324 0.004035587 +325 0.00082805112 +326 -0.0026851012 +327 0.0072246657 +328 -0.005339296 +329 -0.0043448825 +330 0.010643155 +331 -0.0081609374 +332 0.0066917325 +333 0.0012791562 +334 -0.01113791 +335 0.0090475954 +336 -0.010853231 +337 0.0032409009 +338 0.0040980312 +339 -0.0049287883 +340 0.0016793288 +341 -0.00061239968 +342 -0.0017427787 +343 0.0036588193 +344 -0.0067342253 +345 0.0067958251 +346 0.00043325857 +347 -0.0062904337 +348 0.0073918666 +349 -0.0066576978 +350 0.0026485433 +351 -0.0023968324 +352 -0.00020262248 +353 0.0055669462 +354 0.0031921639 +355 0.0029113674 +356 -0.0020937975 +357 -0.0015773086 +358 -0.0011931629 +359 0.0019845672 +360 0.0010049488 +361 -0.0043402076 +362 0.0069653274 +363 -0.0066296993 +364 0.0040835956 +365 -0.0022719748 +366 0.0031787892 +367 0.0018863936 +368 -0.0043240145 +369 0.0031209756 +370 0.0032751251 +371 -0.0043714253 +372 0.0010235949 +373 0.005830025 +374 -0.0087525349 +375 0.011878699 +376 -0.0092464787 +377 0.0051095452 +378 0.00049215492 +379 -0.0097728624 +380 0.0087838903 +381 -0.0098013112 +382 0.0068713438 +383 0.0049554926 +384 -0.0043905163 +385 -0.0015883465 +386 0.0021411048 +387 -0.00053965888 +388 0.0036745358 +389 0.0014808036 +390 -0.004536402 +391 0.0015192218 +392 0.0027196502 +393 -0.0025810566 +394 0.0031082096 +395 -4.7723387e-06 +396 0.0020796938 +397 -0.0022570854 +398 -0.003936731 +399 0.0084666388 +400 -0.0057506351 +401 0.0016458976 +402 0.0094691866 +403 -0.008839108 +404 0.0050982854 +405 -0.0010481337 +406 -0.0069512806 +407 0.010890251 +408 -0.0057060768 +409 0.0014311795 +410 0.011839364 +411 -0.009251874 +412 0.0021195342 +413 -0.0023409846 +414 -0.0063670687 +415 0.015033781 +416 -0.0088340168 +417 0.0079325639 +418 -0.0024966017 +419 -0.0032571545 +420 0.0071797801 +421 -0.0057685757 +422 0.0065634168 +423 -0.0010758619 +424 0.0016557167 +425 -0.0047244662 +426 0.0030926208 +427 0.0010412274 +428 -0.0091296123 +429 0.0059321171 +430 -0.004148807 +431 -0.00095115911 +432 0.0094210884 +433 -0.0078277968 +434 -0.0012672641 +435 0.0050365588 +436 -0.0071693578 +437 0.0058395732 +438 -0.0051660217 +439 -0.0013598015 +440 0.011156443 +441 -0.014047785 +442 0.015500496 +443 -0.00036496224 +444 -0.0050689753 +445 0.0055969248 +446 -0.0040965089 +447 0.00058886366 +448 0.0076116355 +449 -0.01027737 +450 0.00046901907 +451 0.001038831 +452 -0.0013155834 +453 0.0050353034 +454 -5.9224741e-05 +455 -0.0065878485 +456 0.0062157693 +457 -0.0041094506 +458 -0.0028793431 +459 0.0037869066 +460 -0.0023136901 +461 0.001233849 +462 0.00063285754 +463 -0.001011581 +464 0.004749887 +465 -0.01004642 +466 0.0079936783 +467 0.00078925829 +468 -0.005341806 +469 0.0060564244 +470 -0.0098092403 +471 -0.0029105401 +472 0.0059783383 +473 -0.0072104572 +474 0.0051409769 +475 0.0018890171 +476 -0.0014278876 +477 0.0010991714 +478 -0.0031653206 +479 0.0064217826 +480 0.0050600168 +481 -0.0037536295 +482 0.0016811847 +483 -0.00051376806 +484 0.00042566853 +485 0.0034279566 +486 0.0048093524 +487 -0.0063048747 +488 0.0075198538 +489 -0.00304979 +490 0.0021628828 +491 0.0049535774 +492 -0.0073786608 +493 0.0066929183 +494 -0.010125056 +495 0.0034794835 +496 0.00019589747 +497 -0.0036975265 +498 0.0083901558 +499 -0.0051172093 +500 -0.00025500495 diff --git a/src/gromacs/fileio/xvgr.cpp b/src/gromacs/fileio/xvgr.cpp index fc65cf8d02..a9cb9b8f32 100644 --- a/src/gromacs/fileio/xvgr.cpp +++ b/src/gromacs/fileio/xvgr.cpp @@ -501,24 +501,25 @@ static char *fgets3(FILE *fp, char **ptr, int *len, int maxlen) static int wordcount(char *ptr) { - int i, n, is[2]; + int i, n = 0, is[2]; int cur = 0; #define prev (1-cur) - if (strlen(ptr) == 0) + if (NULL != ptr) { - return 0; - } - /* fprintf(stderr,"ptr='%s'\n",ptr); */ - n = 1; - for (i = 0; (ptr[i] != '\0'); i++) - { - is[cur] = isspace(ptr[i]); - if ((i > 0) && (is[cur] && !is[prev])) + for (i = 0; (ptr[i] != '\0'); i++) { - n++; + is[cur] = isspace(ptr[i]); + if ((0 == i) && !is[cur]) + { + n++; + } + else if ((i > 0) && (!is[cur] && is[prev])) + { + n++; + } + cur = prev; } - cur = prev; } return n; } @@ -690,6 +691,8 @@ int read_xvg_legend(const char *fn, double ***y, int *ny, *y = yy; sfree(tmpbuf); + sfree(base); + sfree(fmt); if (legend_nalloc > 0) { diff --git a/src/gromacs/gmxana/correl.c b/src/gromacs/gmxana/correl.c deleted file mode 100644 index a8c8c430ff..0000000000 --- a/src/gromacs/gmxana/correl.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * This file is part of the GROMACS molecular simulation package. - * - * Copyright (c) 1991-2000, University of Groningen, The Netherlands. - * Copyright (c) 2001-2008, The GROMACS development team. - * Copyright (c) 2013,2014, 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 "correl.h" - -#include -#include -#include - -#include "gromacs/fft/fft.h" -#include "gromacs/utility/smalloc.h" - -#define SWAP(a, b) tempr = (a); (a) = (b); (b) = tempr - -void four1(real data[], int nn, int isign) -{ - int n, mmax, m, j, istep, i; - double wtemp, wr, wpr, wpi, wi, theta; - real tempr, tempi; - - n = nn << 1; - j = 1; - for (i = 1; i < n; i += 2) - { - if (j > i) - { - SWAP(data[j], data[i]); - SWAP(data[j+1], data[i+1]); - } - m = n >> 1; - while (m >= 2 && j > m) - { - j -= m; - m >>= 1; - } - j += m; - } - mmax = 2; - while (n > mmax) - { - istep = 2*mmax; - theta = 6.28318530717959/(isign*mmax); - wtemp = sin(0.5*theta); - wpr = -2.0*wtemp*wtemp; - wpi = sin(theta); - wr = 1.0; - wi = 0.0; - for (m = 1; m < mmax; m += 2) - { - for (i = m; i <= n; i += istep) - { - j = i+mmax; - tempr = wr*data[j]-wi*data[j+1]; - tempi = wr*data[j+1]+wi*data[j]; - data[j] = data[i]-tempr; - data[j+1] = data[i+1]-tempi; - data[i] += tempr; - data[i+1] += tempi; - } - wr = (wtemp = wr)*wpr-wi*wpi+wr; - wi = wi*wpr+wtemp*wpi+wi; - } - mmax = istep; - } -} - -#undef SWAP - -static void realft(real data[], int n, int isign) -{ - int i, i1, i2, i3, i4, n2p3; - real c1 = 0.5, c2, h1r, h1i, h2r, h2i; - double wr, wi, wpr, wpi, wtemp, theta; - - theta = 3.141592653589793/(double) n; - if (isign == 1) - { - c2 = -0.5; - four1(data, n, 1); - } - else - { - c2 = 0.5; - theta = -theta; - } - wtemp = sin(0.5*theta); - wpr = -2.0*wtemp*wtemp; - wpi = sin(theta); - wr = 1.0+wpr; - wi = wpi; - n2p3 = 2*n+3; - for (i = 2; i <= n/2; i++) - { - i4 = 1+(i3 = n2p3-(i2 = 1+(i1 = i+i-1))); - h1r = c1*(data[i1]+data[i3]); - h1i = c1*(data[i2]-data[i4]); - h2r = -c2*(data[i2]+data[i4]); - h2i = c2*(data[i1]-data[i3]); - data[i1] = h1r+wr*h2r-wi*h2i; - data[i2] = h1i+wr*h2i+wi*h2r; - data[i3] = h1r-wr*h2r+wi*h2i; - data[i4] = -h1i+wr*h2i+wi*h2r; - wr = (wtemp = wr)*wpr-wi*wpi+wr; - wi = wi*wpr+wtemp*wpi+wi; - } - if (isign == 1) - { - data[1] = (h1r = data[1])+data[2]; - data[2] = h1r-data[2]; - } - else - { - data[1] = c1*((h1r = data[1])+data[2]); - data[2] = c1*(h1r-data[2]); - four1(data, n, -1); - } -} - -static void twofft(real data1[], real data2[], real fft1[], real fft2[], int n) -{ - int nn3, nn2, jj, j; - real rep, rem, aip, aim; - - nn3 = 1+(nn2 = 2+n+n); - for (j = 1, jj = 2; j <= n; j++, jj += 2) - { - fft1[jj-1] = data1[j]; - fft1[jj] = data2[j]; - } - four1(fft1, n, 1); - fft2[1] = fft1[2]; - fft1[2] = fft2[2] = 0.0; - for (j = 3; j <= n+1; j += 2) - { - rep = 0.5*(fft1[j]+fft1[nn2-j]); - rem = 0.5*(fft1[j]-fft1[nn2-j]); - aip = 0.5*(fft1[j+1]+fft1[nn3-j]); - aim = 0.5*(fft1[j+1]-fft1[nn3-j]); - fft1[j] = rep; - fft1[j+1] = aim; - fft1[nn2-j] = rep; - fft1[nn3-j] = -aim; - fft2[j] = aip; - fft2[j+1] = -rem; - fft2[nn2-j] = aip; - fft2[nn3-j] = rem; - } -} - -void correl(real data1[], real data2[], int n, real ans[]) -{ - int no2, i; - real dum, *fft; - - snew(fft, 2*n+1); - twofft(data1, data2, fft, ans, n); - no2 = n/2; - for (i = 2; i <= n+2; i += 2) - { - dum = ans[i-1]; - ans[i-1] = (fft[i-1]*dum+fft[i]*ans[i])/no2; - ans[i] = (fft[i]*dum-fft[i-1]*ans[i])/no2; - } - ans[2] = ans[n+1]; - realft(ans, no2, -1); - sfree(fft); -} diff --git a/src/gromacs/gmxana/expfit.c b/src/gromacs/gmxana/expfit.c deleted file mode 100644 index 61f9f7699e..0000000000 --- a/src/gromacs/gmxana/expfit.c +++ /dev/null @@ -1,722 +0,0 @@ -/* - * 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, 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 -#include - -#include "gromacs/fileio/xvgr.h" -#include "gromacs/gmxana/gstat.h" -#include "gromacs/legacyheaders/typedefs.h" -#include "gromacs/math/vec.h" -#include "gromacs/utility/fatalerror.h" -#include "gromacs/utility/futil.h" -#include "gromacs/utility/smalloc.h" - -const int nfp_ffn[effnNR] = { 0, 1, 2, 3, 2, 5, 7, 9, 4, 3}; - -const char *s_ffn[effnNR+2] = { - NULL, "none", "exp", "aexp", "exp_exp", "vac", - "exp5", "exp7", "exp9", "erffit", NULL, NULL -}; -/* We don't allow errest as a choice on the command line */ - -const char *longs_ffn[effnNR] = { - "no fit", - "y = exp(-x/a1)", - "y = a2 exp(-x/a1)", - "y = a2 exp(-x/a1) + (1-a2) exp(-x/a3)", - "y = exp(-v) (cosh(wv) + 1/w sinh(wv)), v = x/(2 a1), w = sqrt(1 - a2)", - "y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5", - "y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7", - "y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7 exp(-x/a8) + a9", - "y = 1/2*(a1+a2) - 1/2*(a1-a2)*erf( (x-a3) /a4^2)", - "y = a2*ee(a1,x) + (1-a2)*ee(a2,x)" -}; - -extern gmx_bool mrqmin_new(real x[], real y[], real sig[], int ndata, real a[], - int ia[], int ma, real **covar, real **alpha, real *chisq, - void (*funcs)(real, real [], real *, real []), - real *alamda); - -static real myexp(real x, real A, real tau) -{ - if ((A == 0) || (tau == 0)) - { - return 0; - } - return A*exp(-x/tau); -} - -void erffit (real x, real a[], real *y, real dyda[]) -{ -/* Fuction - * y=(a1+a2)/2-(a1-a2)/2*erf((x-a3)/a4^2) - */ - - real erfarg; - real erfval; - real erfarg2; - real derf; - - erfarg = (x-a[3])/(a[4]*a[4]); - erfarg2 = erfarg*erfarg; - erfval = gmx_erf(erfarg)/2; - derf = M_2_SQRTPI*(a[1]-a[2])/2*exp(-erfarg2)/(a[4]*a[4]); - *y = (a[1]+a[2])/2-(a[1]-a[2])*erfval; - dyda[1] = 1/2-erfval; - dyda[2] = 1/2+erfval; - dyda[3] = derf; - dyda[4] = 2*derf*erfarg; -} - - - -static void exp_one_parm(real x, real a[], real *y, real dyda[]) -{ - /* Fit to function - * - * y = exp(-x/a1) - * - */ - - real e1; - - e1 = exp(-x/a[1]); - *y = e1; - dyda[1] = x*e1/sqr(a[1]); -} - -static void exp_two_parm(real x, real a[], real *y, real dyda[]) -{ - /* Fit to function - * - * y = a2 exp(-x/a1) - * - */ - - real e1; - - e1 = exp(-x/a[1]); - *y = a[2]*e1; - dyda[1] = x*a[2]*e1/sqr(a[1]); - dyda[2] = e1; -} - -static void exp_3_parm(real x, real a[], real *y, real dyda[]) -{ - /* Fit to function - * - * y = a2 exp(-x/a1) + (1-a2) exp(-x/a3) - * - */ - - real e1, e2; - - e1 = exp(-x/a[1]); - e2 = exp(-x/a[3]); - *y = a[2]*e1 + (1-a[2])*e2; - dyda[1] = x*a[2]*e1/sqr(a[1]); - dyda[2] = e1-e2; - dyda[3] = x*(1-a[2])*e2/sqr(a[3]); -} - -static void exp_5_parm(real x, real a[], real *y, real dyda[]) -{ - /* Fit to function - * - * y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 - * - */ - - real e1, e2; - - e1 = exp(-x/a[2]); - e2 = exp(-x/a[4]); - *y = a[1]*e1 + a[3]*e2 + a[5]; - - if (debug) - { - fprintf(debug, "exp_5_parm called: x = %10.3f y = %10.3f\n" - "a = ( %8.3f %8.3f %8.3f %8.3f %8.3f)\n", - x, *y, a[1], a[2], a[3], a[4], a[5]); - } - dyda[1] = e1; - dyda[2] = x*e1/sqr(a[2]); - dyda[3] = e2; - dyda[4] = x*e2/sqr(a[4]); - dyda[5] = 0; -} - -static void exp_7_parm(real x, real a[], real *y, real dyda[]) -{ - /* Fit to function - * - * y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7 - * - */ - - real e1, e2, e3; - - e1 = exp(-x/a[2]); - e2 = exp(-x/a[4]); - e3 = exp(-x/a[6]); - *y = a[1]*e1 + a[3]*e2 + a[5]*e3 + a[7]; - - dyda[1] = e1; - dyda[2] = x*e1/sqr(a[2]); - dyda[3] = e2; - dyda[4] = x*e2/sqr(a[4]); - dyda[5] = e3; - dyda[6] = x*e3/sqr(a[6]); - dyda[7] = 0; -} - -static void exp_9_parm(real x, real a[], real *y, real dyda[]) -{ - /* Fit to function - * - * y = a1 exp(-x/a2) + a3 exp(-x/a4) + a5 exp(-x/a6) + a7 - * - */ - - real e1, e2, e3, e4; - - e1 = exp(-x/a[2]); - e2 = exp(-x/a[4]); - e3 = exp(-x/a[6]); - e4 = exp(-x/a[8]); - *y = a[1]*e1 + a[3]*e2 + a[5]*e3 + a[7]*e4 + a[9]; - - dyda[1] = e1; - dyda[2] = x*e1/sqr(a[2]); - dyda[3] = e2; - dyda[4] = x*e2/sqr(a[4]); - dyda[5] = e3; - dyda[6] = x*e3/sqr(a[6]); - dyda[7] = e4; - dyda[8] = x*e4/sqr(a[8]); - dyda[9] = 0; -} - -static void vac_2_parm(real x, real a[], real *y, real dyda[]) -{ - /* Fit to function - * - * y = 1/2 (1 - 1/w) exp(-(1+w)v) + 1/2 (1 + 1/w) exp(-(1-w)v) - * - * = exp(-v) (cosh(wv) + 1/w sinh(wv)) - * - * v = x/(2 a1) - * w = sqrt(1 - a2) - * - * For tranverse current autocorrelation functions: - * a1 = tau - * a2 = 4 tau (eta/rho) k^2 - * - */ - - double v, det, omega, omega2, em, ec, es; - - v = x/(2*a[1]); - det = 1 - a[2]; - em = exp(-v); - if (det != 0) - { - omega2 = fabs(det); - omega = sqrt(omega2); - if (det > 0) - { - ec = em*0.5*(exp(omega*v)+exp(-omega*v)); - es = em*0.5*(exp(omega*v)-exp(-omega*v))/omega; - } - else - { - ec = em*cos(omega*v); - es = em*sin(omega*v)/omega; - } - *y = ec + es; - dyda[2] = (v/det*ec+(v-1/det)*es)/(-2.0); - dyda[1] = (1-det)*v/a[1]*es; - } - else - { - *y = (1+v)*em; - dyda[2] = -v*v*em*(0.5+v/6); - dyda[1] = v*v/a[1]*em; - } -} - -static void errest_3_parm(real x, real a[], real *y, real dyda[]) -{ - real e1, e2, v1, v2; - - if (a[1]) - { - e1 = exp(-x/a[1]) - 1; - } - else - { - e1 = 0; - } - if (a[3]) - { - e2 = exp(-x/a[3]) - 1; - } - else - { - e2 = 0; - } - - if (x > 0) - { - v1 = 2*a[1]*(e1*a[1]/x + 1); - v2 = 2*a[3]*(e2*a[3]/x + 1); - *y = a[2]*v1 + (1-a[2])*v2; - dyda[1] = 2* a[2] *(v1/a[1] + e1); - dyda[3] = 2*(1 - a[2])*(v2/a[3] + e2); - dyda[2] = (v1 - v2); - } - else - { - *y = 0; - dyda[1] = 0; - dyda[3] = 0; - dyda[2] = 0; - } -} - -typedef void (*myfitfn)(real x, real a[], real *y, real dyda[]); -myfitfn mfitfn[effnNR] = { - exp_one_parm, exp_one_parm, exp_two_parm, exp_3_parm, vac_2_parm, - exp_5_parm, exp_7_parm, exp_9_parm, erffit, errest_3_parm -}; - -real fit_function(int eFitFn, real *parm, real x) -{ - static real y, dum[8]; - - mfitfn[eFitFn](x, parm-1, &y, dum); - - return y; -} - -/* lmfit_exp supports up to 3 parameter fitting of exponential functions */ -static gmx_bool lmfit_exp(int nfit, real x[], real y[], real dy[], real ftol, - real parm[], real dparm[], gmx_bool bVerbose, - int eFitFn, int fix) -{ - real chisq, ochisq, alamda; - real *a, **covar, **alpha, *dum; - gmx_bool bCont; - int i, j, ma, mfit, *lista, *ia; - - if ((eFitFn < 0) || (eFitFn >= effnNR)) - { - gmx_fatal(FARGS, "fitfn = %d, should be in 0..%d (%s,%d)", - effnNR-1, eFitFn, __FILE__, __LINE__); - } - - ma = mfit = nfp_ffn[eFitFn]; /* number of parameters to fit */ - snew(a, ma+1); - snew(covar, ma+1); - snew(alpha, ma+1); - snew(lista, ma+1); - snew(ia, ma+1); - snew(dum, ma+1); - for (i = 1; (i < ma+1); i++) - { - lista[i] = i; - ia[i] = 1; /* fixed bug B.S.S 19/11 */ - snew(covar[i], ma+1); - snew(alpha[i], ma+1); - } - if (fix) - { - if (bVerbose) - { - fprintf(stderr, "Will keep parameters fixed during fit procedure: %d\n", - fix); - } - for (i = 0; i < ma; i++) - { - if (fix & 1< 1) - { - fprintf(stderr, " %10.5e", a[2]); - } - if (mfit > 2) - { - fprintf(stderr, " %10.5e", a[3]); - } - if (mfit > 3) - { - fprintf(stderr, " %10.5e", a[4]); - } - fprintf(stderr, "\n"); - } - j++; - bCont = ((fabs(ochisq - chisq) > fabs(ftol*chisq)) || - ((ochisq == chisq))); - } - while (bCont && (alamda != 0.0) && (j < 50)); - if (bVerbose) - { - fprintf(stderr, "\n"); - } - - /* Now get the covariance matrix out */ - alamda = 0; - - /* mrqmin(x-1,y-1,dy-1,nfit,a,ma,lista,mfit,covar,alpha, - * &chisq,expfn[mfit-1],&alamda) - */ - if (!mrqmin_new(x-1, y-1, dy-1, nfit, a, ia, ma, covar, alpha, &chisq, - mfitfn[eFitFn], &alamda)) - { - return FALSE; - } - - for (j = 0; (j < mfit); j++) - { - parm[j] = a[j+1]; - dparm[j] = covar[j+1][j+1]; - } - - for (i = 0; (i < ma+1); i++) - { - sfree(covar[i]); - sfree(alpha[i]); - } - sfree(a); - sfree(covar); - sfree(alpha); - sfree(lista); - sfree(dum); - - return TRUE; -} - -real do_lmfit(int ndata, real c1[], real sig[], real dt, real x0[], - real begintimefit, real endtimefit, const output_env_t oenv, - gmx_bool bVerbose, int eFitFn, real fitparms[], int fix) -{ - FILE *fp; - char buf[32]; - - int i, j, nparm, nfitpnts; - real integral, ttt; - real *parm, *dparm; - real *x, *y, *dy; - real ftol = 1e-4; - - nparm = nfp_ffn[eFitFn]; - if (debug) - { - fprintf(debug, "There are %d points to fit %d vars!\n", ndata, nparm); - fprintf(debug, "Fit to function %d from %g through %g, dt=%g\n", - eFitFn, begintimefit, endtimefit, dt); - } - - snew(x, ndata); - snew(y, ndata); - snew(dy, ndata); - - j = 0; - for (i = 0; i < ndata; i++) - { - ttt = x0 ? x0[i] : dt*i; - if (ttt >= begintimefit && ttt <= endtimefit) - { - x[j] = ttt; - y[j] = c1[i]; - - /* mrqmin does not like sig to be zero */ - if (sig[i] < 1.0e-7) - { - dy[j] = 1.0e-7; - } - else - { - dy[j] = sig[i]; - } - if (debug) - { - fprintf(debug, "j= %d, i= %d, x= %g, y= %g, dy= %g\n", - j, i, x[j], y[j], dy[j]); - } - j++; - } - } - nfitpnts = j; - integral = 0; - if (nfitpnts < nparm) - { - fprintf(stderr, "Not enough data points for fitting!\n"); - } - else - { - snew(parm, nparm); - snew(dparm, nparm); - if (fitparms) - { - for (i = 0; (i < nparm); i++) - { - parm[i] = fitparms[i]; - } - } - - if (!lmfit_exp(nfitpnts, x, y, dy, ftol, parm, dparm, bVerbose, eFitFn, fix)) - { - fprintf(stderr, "Fit failed!\n"); - } - else if (nparm <= 3) - { - /* Compute the integral from begintimefit */ - if (nparm == 3) - { - integral = (parm[0]*myexp(begintimefit, parm[1], parm[0]) + - parm[2]*myexp(begintimefit, 1-parm[1], parm[2])); - } - else if (nparm == 2) - { - integral = parm[0]*myexp(begintimefit, parm[1], parm[0]); - } - else if (nparm == 1) - { - integral = parm[0]*myexp(begintimefit, 1, parm[0]); - } - else - { - gmx_fatal(FARGS, "nparm = %d in file %s, line %d", - nparm, __FILE__, __LINE__); - } - - /* Generate THE output */ - if (bVerbose) - { - fprintf(stderr, "FIT: # points used in fit is: %d\n", nfitpnts); - fprintf(stderr, "FIT: %21s%21s%21s\n", - "parm0 ", "parm1 (ps) ", "parm2 (ps) "); - fprintf(stderr, "FIT: ------------------------------------------------------------\n"); - fprintf(stderr, "FIT: %8.3g +/- %8.3g%9.4g +/- %8.3g%8.3g +/- %8.3g\n", - parm[0], dparm[0], parm[1], dparm[1], parm[2], dparm[2]); - fprintf(stderr, "FIT: Integral (calc with fitted function) from %g ps to inf. is: %g\n", - begintimefit, integral); - - sprintf(buf, "test%d.xvg", nfitpnts); - fp = xvgropen(buf, "C(t) + Fit to C(t)", "Time (ps)", "C(t)", oenv); - fprintf(fp, "# parm0 = %g, parm1 = %g, parm2 = %g\n", - parm[0], parm[1], parm[2]); - for (j = 0; (j < nfitpnts); j++) - { - ttt = x0 ? x0[j] : dt*j; - fprintf(fp, "%10.5e %10.5e %10.5e\n", - ttt, c1[j], fit_function(eFitFn, parm, ttt)); - } - xvgrclose(fp); - } - } - if (fitparms) - { - for (i = 0; (i < nparm); i++) - { - fitparms[i] = parm[i]; - } - } - sfree(parm); - sfree(dparm); - } - - sfree(x); - sfree(y); - sfree(dy); - - return integral; -} - -void do_expfit(int ndata, real c1[], real dt, real begintimefit, real endtimefit) -{ - int i, n; - real *x, *y, *Dy; - real aa, bb, saa, sbb, A, tau, dA, dtau; - - fprintf(stderr, "Will fit data from %g (ps) to %g (ps).\n", - begintimefit, endtimefit); - - snew(x, ndata); /* allocate the maximum necessary space */ - snew(y, ndata); - snew(Dy, ndata); - n = 0; - - for (i = 0; (i < ndata); i++) - { - if ( (dt*i >= begintimefit) && (dt*i <= endtimefit) ) - { - x[n] = dt*i; - y[n] = c1[i]; - Dy[n] = 0.5; - fprintf(stderr, "n= %d, i= %d, x= %g, y= %g\n", n, i, x[n], y[n]); - n++; - } - } - fprintf(stderr, "# of data points used in the fit is : %d\n\n", n); - expfit(n, x, y, Dy, &aa, &saa, &bb, &sbb); - - A = exp(aa); - dA = exp(aa)*saa; - tau = -1.0/bb; - dtau = sbb/sqr(bb); - fprintf(stderr, "Fitted to y=exp(a+bx):\n"); - fprintf(stderr, "a = %10.5f\t b = %10.5f", aa, bb); - fprintf(stderr, "\n"); - fprintf(stderr, "Fitted to y=Aexp(-x/tau):\n"); - fprintf(stderr, "A = %10.5f\t tau = %10.5f\n", A, tau); - fprintf(stderr, "dA = %10.5f\t dtau = %10.5f\n", dA, dtau); -} - - -void expfit(int n, real *x, real *y, real *Dy, real *a, real *sa, - real *b, real *sb) -{ - real *w, *ly, A, SA, B, SB; - int i; - real sum, xbar, ybar, Sxx, Sxy, wr2, chi2, gamma, Db; - -#define ZERO 0.0 -#define ONE 1.0 -#define ONEP5 1.5 -#define TWO 2.0 - -#define sqr(x) ((x)*(x)) - - /*allocate memory */ - snew(w, n); - snew(ly, n); - - /* Calculate weights and values of ln(y). */ - for (i = 0; (i < n); i++) - { - w[i] = sqr(y[i]/Dy[i]); - ly[i] = log(y[i]); - } - - /* The weighted averages of x and y: xbar and ybar. */ - sum = ZERO; - xbar = ZERO; - ybar = ZERO; - for (i = 0; (i < n); i++) - { - sum += w[i]; - xbar += w[i]*x[i]; - ybar += w[i]*ly[i]; - } - xbar /= sum; - ybar /= sum; - - /* The centered product sums Sxx and Sxy, and hence A and B. */ - Sxx = ZERO; - Sxy = ZERO; - for (i = 0; (i < n); i++) - { - Sxx += w[i]*sqr(x[i]-xbar); - Sxy += w[i]*(x[i]-xbar)*(ly[i]-ybar); - } - B = Sxy/Sxx; - A = ybar-B*xbar; - - /* Chi-squared (chi2) and gamma. */ - chi2 = ZERO; - gamma = ZERO; - for (i = 0; (i < n); i++) - { - wr2 = w[i]*sqr(ly[i]-A-B*x[i]); - chi2 += wr2; - gamma += wr2*(x[i]-xbar); - } - - /* Refined values of A and B. Also SA and SB. */ - Db = -ONEP5*gamma/Sxx; - B += Db; - A -= ONEP5*chi2/sum-xbar*Db; - SB = sqrt((chi2/(n-2))/Sxx); - SA = SB*sqrt(Sxx/sum+sqr(xbar)); - *a = A; - *b = B; - *sa = SA; - *sb = SB; -} diff --git a/src/gromacs/gmxana/gmx_analyze.c b/src/gromacs/gmxana/gmx_analyze.c index a2f9799621..8d1eab6bee 100644 --- a/src/gromacs/gmxana/gmx_analyze.c +++ b/src/gromacs/gmxana/gmx_analyze.c @@ -41,6 +41,9 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" +#include "gromacs/correlationfunctions/expfit.h" +#include "gromacs/correlationfunctions/integrate.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/gmxana/geminate.h" #include "gromacs/gmxana/gmx_ana.h" @@ -391,7 +394,7 @@ static void average(const char *avfile, int avbar_opt, } } -static real anal_ee_inf(real *parm, real T) +static real anal_ee_inf(double *parm, real T) { return sqrt(parm[1]*2*parm[0]/T+parm[3]*2*parm[2]/T); } @@ -408,7 +411,7 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n, double blav, var; char **leg; real *tbs, *ybs, rtmp, dens, *fitsig, twooe, tau1_est, tau_sig; - real fitparm[4]; + double fitparm[4]; real ee, a, tau1, tau2; if (n < 4) @@ -628,8 +631,9 @@ static void estimate_error(const char *eefile, int nb_min, int resol, int n, if (bFitAc) { - int fitlen; - real *ac, acint, ac_fit[4]; + int fitlen; + real *ac, acint; + double ac_fit[4]; snew(ac, n); for (i = 0; i < n; i++) @@ -787,14 +791,15 @@ static void do_fit(FILE *out, int n, gmx_bool bYdy, int ny, real *x0, real **val, int npargs, t_pargs *ppa, const output_env_t oenv) { - real *c1 = NULL, *sig = NULL, *fitparm; - real tendfit, tbeginfit; - int i, efitfn, nparm; + real *c1 = NULL, *sig = NULL; + double *fitparm; + real tendfit, tbeginfit; + int i, efitfn, nparm; efitfn = get_acffitfn(); - nparm = nfp_ffn[efitfn]; + nparm = effnNparams(efitfn); fprintf(out, "Will fit to the following function:\n"); - fprintf(out, "%s\n", longs_ffn[efitfn]); + fprintf(out, "%s\n", effnDescription(efitfn)); c1 = val[n]; if (bYdy) { diff --git a/src/gromacs/gmxana/gmx_angle.c b/src/gromacs/gmxana/gmx_angle.c index 2a093478e4..544842106f 100644 --- a/src/gromacs/gmxana/gmx_angle.c +++ b/src/gromacs/gmxana/gmx_angle.c @@ -40,6 +40,7 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" #include "gromacs/fileio/trnio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/gmxana/gmx_ana.h" @@ -55,7 +56,6 @@ #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" - static void dump_dih_trn(int nframes, int nangles, real **dih, const char *fn, real *time) { diff --git a/src/gromacs/gmxana/gmx_chi.c b/src/gromacs/gmxana/gmx_chi.c index 8c377df06a..3717abb12b 100644 --- a/src/gromacs/gmxana/gmx_chi.c +++ b/src/gromacs/gmxana/gmx_chi.c @@ -41,6 +41,7 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/matio.h" #include "gromacs/fileio/pdbio.h" @@ -59,6 +60,7 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" +#include "gmx_ana.h" static gmx_bool bAllowed(real phi, real psi) { diff --git a/src/gromacs/gmxana/gmx_densorder.cpp b/src/gromacs/gmxana/gmx_densorder.cpp index 99f6807992..bf4f6c68ea 100644 --- a/src/gromacs/gmxana/gmx_densorder.cpp +++ b/src/gromacs/gmxana/gmx_densorder.cpp @@ -39,6 +39,8 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" +#include "gromacs/correlationfunctions/expfit.h" #include "gromacs/fileio/matio.h" #include "gromacs/fileio/tpxio.h" #include "gromacs/fileio/trxio.h" @@ -353,21 +355,21 @@ static void interfaces_txy (real ****Densmap, int xslices, int yslices, int zsli t_interf ****intf2, const output_env_t oenv) { /*Returns two pointers to 3D arrays of t_interf structs containing (position,thickness) of the interface(s)*/ - FILE *xvg; - real *zDensavg; /* zDensavg[z]*/ - int i, j, k, n; - int xysize; - int ndx1, ndx2, *zperm; - real densmid; - real splitpoint, startpoint, endpoint; - real *sigma1, *sigma2; - real beginfit1[4]; - real beginfit2[4]; - real *fit1 = NULL, *fit2 = NULL; - const real *avgfit1; - const real *avgfit2; - const real onehalf = 1.00/2.00; - t_interf ***int1 = NULL, ***int2 = NULL; /*Interface matrices [t][x,y] - last index in row-major order*/ + FILE *xvg; + real *zDensavg; /* zDensavg[z]*/ + int i, j, k, n; + int xysize; + int ndx1, ndx2, *zperm; + real densmid; + real splitpoint, startpoint, endpoint; + real *sigma1, *sigma2; + double beginfit1[4]; + double beginfit2[4]; + double *fit1 = NULL, *fit2 = NULL; + const double *avgfit1; + const double *avgfit2; + const real onehalf = 1.00/2.00; + t_interf ***int1 = NULL, ***int2 = NULL; /*Interface matrices [t][x,y] - last index in row-major order*/ /*Create int1(t,xy) and int2(t,xy) arrays with correct number of interf_t elements*/ xysize = xslices*yslices; snew(int1, tblocks); diff --git a/src/gromacs/gmxana/gmx_dielectric.c b/src/gromacs/gmxana/gmx_dielectric.c index 5f4ce88446..18d1d4a38b 100644 --- a/src/gromacs/gmxana/gmx_dielectric.c +++ b/src/gromacs/gmxana/gmx_dielectric.c @@ -39,9 +39,12 @@ #include #include #include +#include +#include "gromacs/correlationfunctions/expfit.h" +#include "gromacs/correlationfunctions/integrate.h" +#include "gromacs/fft/fft.h" #include "gromacs/fileio/xvgr.h" -#include "gromacs/gmxana/correl.h" #include "gromacs/gmxana/gmx_ana.h" #include "gromacs/gmxana/gstat.h" #include "gromacs/legacyheaders/copyrite.h" @@ -53,6 +56,10 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" +#include "gromacs/utility/fatalerror.h" +#include "gromacs/math/gmxcomplex.h" +#include "gromacs/math/utilities.h" +#include "gmx_ana.h" /* Determines at which point in the array the fit should start */ int calc_nbegin(int nx, real x[], real tbegin) @@ -155,6 +162,8 @@ void do_four(const char *fn, const char *cn, int nx, real x[], real dy[], t_complex *tmp, gw, hw, kw; int i, nnx, nxsav; real fac, nu, dt, *ptr, maxeps, numax; + gmx_fft_t fft; + int fftcode; nxsav = nx; /*while ((dy[nx-1] == 0.0) && (nx > 0)) @@ -169,15 +178,24 @@ void do_four(const char *fn, const char *cn, int nx, real x[], real dy[], { nnx *= 2; } + snew(tmp, 2*nnx); printf("Doing FFT of %d points\n", nnx); for (i = 0; (i < nx); i++) { tmp[i].re = dy[i]; } - ptr = &tmp[0].re; - four1(ptr-1, nnx, -1); - + if ((fftcode = gmx_fft_init_1d_real(&fft, nnx, + GMX_FFT_FLAG_NONE)) != 0) + { + gmx_fatal(FARGS, "gmx_fft_init_1d_real returned %d", fftcode); + } + if ((fftcode = gmx_fft_1d_real(fft, GMX_FFT_COMPLEX_TO_REAL, + (void *)tmp, (void *)tmp)) != 0) + { + gmx_fatal(FARGS, "gmx_fft_1d_real returned %d", fftcode); + } + gmx_fft_destroy(fft); dt = x[1]-x[0]; if (epsRF == 0) { @@ -259,17 +277,16 @@ int gmx_dielectric(int argc, char *argv[]) #define NFILE asize(fnm) output_env_t oenv; int i, j, nx, ny, nxtail, eFitFn, nfitparm; - real dt, integral, fitintegral, *fitparms, fac, rffac; + real dt, integral, fitintegral, fac, rffac; + double *fitparms; double **yd; real **y; const char *legend[] = { "Correlation", "Std. Dev.", "Fit", "Combined", "Derivative" }; - static int fix = 0, bFour = 0, bX = 1, nsmooth = 3; + static int fix = 0, bX = 1, nsmooth = 3; static real tendInt = 5.0, tbegin = 5.0, tend = 500.0; static real A = 0.5, tau1 = 10.0, tau2 = 1.0, eps0 = 80, epsRF = 78.5, tail = 500.0; real lambda; t_pargs pa[] = { - { "-fft", FALSE, etBOOL, {&bFour}, - "use fast fourier transform for correlation function" }, { "-x1", FALSE, etBOOL, {&bX}, "use first column as [IT]x[it]-axis rather than first data set" }, { "-eint", FALSE, etREAL, {&tendInt}, @@ -358,7 +375,7 @@ int gmx_dielectric(int argc, char *argv[]) } eFitFn = sffn2effn(s_ffn); - nfitparm = nfp_ffn[eFitFn]; + nfitparm = effnNparams(eFitFn); snew(fitparms, 4); fitparms[0] = tau1; if (nfitparm > 1) diff --git a/src/gromacs/gmxana/gmx_dipoles.cpp b/src/gromacs/gmxana/gmx_dipoles.cpp index b0f4c12451..f13e0da111 100644 --- a/src/gromacs/gmxana/gmx_dipoles.cpp +++ b/src/gromacs/gmxana/gmx_dipoles.cpp @@ -42,12 +42,12 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" #include "gromacs/fileio/enxio.h" #include "gromacs/fileio/matio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/gmxana/gmx_ana.h" -#include "gromacs/gmxana/gstat.h" #include "gromacs/legacyheaders/calcmu.h" #include "gromacs/legacyheaders/copyrite.h" #include "gromacs/legacyheaders/macros.h" diff --git a/src/gromacs/gmxana/gmx_dos.c b/src/gromacs/gmxana/gmx_dos.c index 65b6eaad3d..560ab280f5 100644 --- a/src/gromacs/gmxana/gmx_dos.c +++ b/src/gromacs/gmxana/gmx_dos.c @@ -40,13 +40,13 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" +#include "gromacs/correlationfunctions/integrate.h" #include "gromacs/fft/fft.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" -#include "gromacs/gmxana/correl.h" #include "gromacs/gmxana/gmx_ana.h" -#include "gromacs/gmxana/gstat.h" #include "gromacs/legacyheaders/copyrite.h" #include "gromacs/legacyheaders/macros.h" #include "gromacs/legacyheaders/txtdump.h" @@ -58,6 +58,7 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" +#include "gmx_ana.h" enum { VACF, MVACF, DOS, DOS_SOLID, DOS_DIFF, DOS_CP, DOS_S, DOS_A, DOS_E, DOS_NR diff --git a/src/gromacs/gmxana/gmx_energy.c b/src/gromacs/gmxana/gmx_energy.c index 3319c96e81..eca1ca6166 100644 --- a/src/gromacs/gmxana/gmx_energy.c +++ b/src/gromacs/gmxana/gmx_energy.c @@ -41,6 +41,7 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" #include "gromacs/fileio/enxio.h" #include "gromacs/fileio/tpxio.h" #include "gromacs/fileio/trxio.h" diff --git a/src/gromacs/gmxana/gmx_gyrate.c b/src/gromacs/gmxana/gmx_gyrate.c index a1f3622fdc..ebf112f286 100644 --- a/src/gromacs/gmxana/gmx_gyrate.c +++ b/src/gromacs/gmxana/gmx_gyrate.c @@ -40,6 +40,7 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" #include "gromacs/fileio/tpxio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" @@ -56,6 +57,7 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" +#include "gmx_ana.h" real calc_gyro(rvec x[], int gnx, atom_id index[], t_atom atom[], real tm, rvec gvec, rvec d, gmx_bool bQ, gmx_bool bRot, gmx_bool bMOI, matrix trans) diff --git a/src/gromacs/gmxana/gmx_hbond.c b/src/gromacs/gmxana/gmx_hbond.c index 5d960071a7..3e9acb11c9 100644 --- a/src/gromacs/gmxana/gmx_hbond.c +++ b/src/gromacs/gmxana/gmx_hbond.c @@ -41,14 +41,16 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" +#include "gromacs/correlationfunctions/crosscorr.h" +#include "gromacs/correlationfunctions/expfit.h" +#include "gromacs/correlationfunctions/integrate.h" #include "gromacs/fileio/matio.h" #include "gromacs/fileio/tpxio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" -#include "gromacs/gmxana/correl.h" #include "gromacs/gmxana/geminate.h" #include "gromacs/gmxana/gmx_ana.h" -#include "gromacs/gmxana/gstat.h" #include "gromacs/legacyheaders/copyrite.h" #include "gromacs/legacyheaders/macros.h" #include "gromacs/legacyheaders/txtdump.h" @@ -63,6 +65,8 @@ #include "gromacs/utility/gmxomp.h" #include "gromacs/utility/smalloc.h" +#include "geminate.h" + /*#define HAVE_NN_LOOPS*/ typedef short int t_E; @@ -2374,9 +2378,10 @@ static real compute_weighted_rates(int n, real t[], real ct[], real nt[], 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; + FILE *fp; + real e_1; + double fitparm[4]; + int i; e_1 = exp(-1); for (i = 0; (i < n); i++) @@ -2395,7 +2400,8 @@ static void smooth_tail(int n, real t[], real c[], real sigma_c[], real start, fitparm[0] = 10; } fitparm[1] = 0.95; - do_lmfit(n, c, sigma_c, 0, t, start, t[n-1], oenv, bDebugMode(), effnEXP2, fitparm, 0); + 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[], diff --git a/src/gromacs/gmxana/gmx_rdf.c b/src/gromacs/gmxana/gmx_rdf.c index 47c4bc0c6f..4dda9da2ff 100644 --- a/src/gromacs/gmxana/gmx_rdf.c +++ b/src/gromacs/gmxana/gmx_rdf.c @@ -40,6 +40,7 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/integrate.h" #include "gromacs/fileio/tpxio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" diff --git a/src/gromacs/gmxana/gmx_rotacf.c b/src/gromacs/gmxana/gmx_rotacf.c index 4eb9a6ec18..e48fc483f2 100644 --- a/src/gromacs/gmxana/gmx_rotacf.c +++ b/src/gromacs/gmxana/gmx_rotacf.c @@ -40,9 +40,9 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" #include "gromacs/fileio/trxio.h" #include "gromacs/gmxana/gmx_ana.h" -#include "gromacs/gmxana/gstat.h" #include "gromacs/legacyheaders/macros.h" #include "gromacs/legacyheaders/typedefs.h" #include "gromacs/legacyheaders/viewit.h" diff --git a/src/gromacs/gmxana/gmx_tcaf.c b/src/gromacs/gmxana/gmx_tcaf.c index b676ffc6a2..668073ef65 100644 --- a/src/gromacs/gmxana/gmx_tcaf.c +++ b/src/gromacs/gmxana/gmx_tcaf.c @@ -41,6 +41,8 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" +#include "gromacs/correlationfunctions/expfit.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" @@ -59,7 +61,6 @@ #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" - #define NK 24 #define NPK 4 @@ -79,10 +80,10 @@ static void process_tcaf(int nframes, real dt, int nkc, real **tc, rvec *kfac, { FILE *fp, *fp_vk, *fp_cub = NULL; int nk, ntc; - real **tcaf, **tcafc = NULL, eta; + real **tcaf, **tcafc = NULL, eta, *sig; int i, j, k, kc; int ncorr; - real fitparms[3], *sig; + double fitparms[3]; nk = kset_c[nkc]; ntc = nk*NPK; diff --git a/src/gromacs/gmxana/gmx_velacc.c b/src/gromacs/gmxana/gmx_velacc.c index 34c378d3a4..c66255db23 100644 --- a/src/gromacs/gmxana/gmx_velacc.c +++ b/src/gromacs/gmxana/gmx_velacc.c @@ -41,6 +41,7 @@ #include #include "gromacs/commandline/pargs.h" +#include "gromacs/correlationfunctions/autocorr.h" #include "gromacs/fft/fft.h" #include "gromacs/fileio/confio.h" #include "gromacs/fileio/trxio.h" @@ -58,6 +59,7 @@ #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" +#include "gmx_ana.h" static void index_atom2mol(int *n, atom_id *index, t_block *mols) { diff --git a/src/gromacs/gmxana/gstat.h b/src/gromacs/gmxana/gstat.h index a07b3ed513..ac08579eb5 100644 --- a/src/gromacs/gmxana/gstat.h +++ b/src/gromacs/gmxana/gstat.h @@ -48,30 +48,6 @@ extern "C" { struct gmx_residuetype_t; -/*********************************************** - * - * A U T O C O R R E L A T I O N - * - ***********************************************/ - -real LegendreP(real x, unsigned long m); - -#define eacNormal (1<<0) -#define eacCos (1<<1) -#define eacVector (1<<2) -#define eacRcross (1<<3 | eacVector) -#define eacP0 (1<<4 | eacVector) -#define eacP1 (1<<5 | eacVector) -#define eacP2 (1<<6 | eacVector) -#define eacP3 (1<<7 | eacVector) -#define eacP4 (1<<8 | eacVector) -#define eacIden (1<<9) - -enum { - effnNONE, effnEXP1, effnEXP2, effnEXP3, effnVAC, - effnEXP5, effnEXP7, effnEXP9, effnERF, effnERREST, effnNR -}; - /* must correspond with 'leg' g_chi.c:727 */ enum { edPhi = 0, edPsi, edOmega, edChi1, edChi2, edChi3, edChi4, edChi5, edChi6, edMax @@ -103,95 +79,6 @@ typedef struct { } t_dlist; -extern const int nfp_ffn[effnNR]; - -extern const char *s_ffn[effnNR+2]; - -extern const char *longs_ffn[effnNR]; - -int sffn2effn(const char **sffn); -/* Returns the ffn enum corresponding to the selected enum option in sffn */ - -t_pargs *add_acf_pargs(int *npargs, t_pargs *pa); -/* Add options for autocorr to the current set of options. - * *npargs must be initialised to the number of elements in pa, - * it will be incremented appropriately. - */ - -void cross_corr(int n, real f[], real g[], real corr[]); -/* Simple minded cross correlation algorithm */ - -real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose, - real tbeginfit, real tendfit, real dt, real c1[], real *fit); -/* Fit an ACF to a given function */ - -void do_autocorr(const char *fn, const output_env_t oenv, - const char *title, - int nframes, int nitem, real **c1, - real dt, unsigned long mode, gmx_bool bAver); -/* Calls low_do_autocorr (see below). After calling add_acf_pargs */ - -void low_do_autocorr(const char *fn, const output_env_t oenv, - const char *title, int nframes, int nitem, - int nout, real **c1, real dt, unsigned long mode, - int nrestart, gmx_bool bAver, gmx_bool bNormalize, - gmx_bool bVerbose, real tbeginfit, real tendfit, - int nfitparm); -/* - * do_autocorr calculates autocorrelation functions for many things. - * It takes a 2 d array containing nitem arrays of length nframes - * for each item the ACF is calculated. - * - * A number of "modes" exist for computation of the ACF - * - * if (mode == eacNormal) { - * C(t) = < X (tau) * X (tau+t) > - * } - * else if (mode == eacCos) { - * C(t) = < cos (X(tau) - X(tau+t)) > - * } - * else if (mode == eacIden) { **not fully supported yet** - * C(t) = < (X(tau) == X(tau+t)) > - * } - * else if (mode == eacVector) { - * C(t) = < X(tau) * X(tau+t) - * } - * else if (mode == eacP1) { - * C(t) = < cos (X(tau) * X(tau+t) > - * } - * else if (mode == eacP2) { - * C(t) = 1/2 * < 3 cos (X(tau) * X(tau+t) - 1 > - * } - * else if (mode == eacRcross) { - * C(t) = < ( X(tau) * X(tau+t) )^2 > - * } - * - * For modes eacVector, eacP1, eacP2 and eacRcross the input should be - * 3 x nframes long, where each triplet is taken as a 3D vector - * - * For mode eacCos inputdata must be in radians, not degrees! - * - * Other parameters are: - * - * fn is output filename (.xvg) where the correlation function(s) are printed - * title is the title in the output file - * nframes is the number of frames in the time series - * nitem is the number of items - * c1 is an array of dimension [ 0 .. nitem-1 ] [ 0 .. nframes-1 ] - * on output, this array is filled with the correlation function - * to reduce storage - * nrestart is the number of steps between restarts for direct ACFs - * (i.e. without FFT) When set to 1 all points are used as - * time origin for averaging - * dt is the time between frames - * bAver If set, all ndih C(t) functions are averaged into a single - * C(t) - * (bFour If set, will use fast fourier transform (FFT) for evaluating - * the ACF: removed option, now on the command line only) - * bNormalize If set, all ACFs will be normalized to start at 0 - * nskip Determines whether steps a re skipped in the output - */ - typedef struct { const char *name; /* Description of the J coupling constant */ real A, B, C; /* Karplus coefficients */ @@ -226,25 +113,6 @@ void calc_distribution_props(int nh, int histo[], * */ - -/*********************************************** - * - * F I T R O U T I N E S - * - ***********************************************/ -void do_expfit(int ndata, real c1[], real dt, - real begintimefit, real endtimefit); - -void expfit(int n, real x[], real y[], real Dy[], - real *a, real *sa, - real *b, real *sb); -/* This procedure fits y=exp(a+bx) for n (x,y) pairs to determine a and b. - * The uncertainties in the y values must be in the vector Dy. - * The standard deviations of a and b, sa and sb, are also calculated. - * - * Routine from Computers in physics, 7(3) (1993), p. 280-285. - */ - void ana_dih_trans(const char *fn_trans, const char *fn_histo, real **dih, int nframes, int nangles, const char *grpname, real *time, gmx_bool bRb, @@ -347,47 +215,6 @@ void normalize_histo(int npoints, int histo[], real dx, real normhisto[]); * normhisto normalized output histogram */ -real fit_function(int eFitFn, real *parm, real x); -/* Returns the value of fit function eFitFn at x */ - -/* Use Levenberg-Marquardt method to fit to a nfitparm parameter exponential */ -/* or to a transverse current autocorrelation function */ -/* Or: "There is no KILL like OVERKILL", Dr. Ir. D. van der Spoel */ -real do_lmfit(int ndata, real c1[], real sig[], real dt, real *x, - real begintimefit, real endtimefit, const output_env_t oenv, - gmx_bool bVerbose, int eFitFn, real fitparms[], int fix); -/* Returns integral. - * If x == NULL, the timestep dt will be used to create a time axis. - * fix fixes fit parameter i at it's starting value, when the i'th bit - * of fix is set. - */ - -real evaluate_integral(int n, real x[], real y[], real dy[], - real aver_start, real *stddev); -/* Integrate data in y, and, if given, use dy as weighting - * aver_start should be set to a value where the function has - * converged to 0. - */ - -real print_and_integrate(FILE *fp, int n, real dt, - real c[], real *fit, int nskip); -/* Integrate the data in c[] from 0 to n using trapezium rule. - * If fp != NULL output is written to it - * nskip determines whether all elements are written to the output file - * (written when i % nskip == 0) - * If fit != NULL the fit is also written. - */ - -int get_acfnout(void); -/* Return the output length for the correlation function - * Works only AFTER do_auto_corr has been called! - */ - -int get_acffitfn(void); -/* Return the fit function type. - * Works only AFTER do_auto_corr has been called! - */ - /* Routines from pp2shift (anadih.c etc.) */ void do_pp2shifts(FILE *fp, int nframes, diff --git a/src/gromacs/gmxana/levenmar.c b/src/gromacs/gmxana/levenmar.c deleted file mode 100644 index c84f103bc0..0000000000 --- a/src/gromacs/gmxana/levenmar.c +++ /dev/null @@ -1,768 +0,0 @@ -/* - * 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, 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 -#include -#include - -#include "gromacs/utility/basedefinitions.h" -#include "gromacs/utility/real.h" - -static void nrerror(const char error_text[], gmx_bool bExit) -{ - fprintf(stderr, "Numerical Recipes run-time error...\n"); - fprintf(stderr, "%s\n", error_text); - if (bExit) - { - fprintf(stderr, "...now exiting to system...\n"); - exit(1); - } -} - -/* dont use the keyword vector - it will clash with the - * altivec extensions used for powerpc processors. - */ - -static real *rvector(int nl, int nh) -{ - real *v; - - v = (real *)malloc((unsigned) (nh-nl+1)*sizeof(real)); - if (!v) - { - nrerror("allocation failure in rvector()", TRUE); - } - /* cppcheck-suppress memleak - * free_vector does the same vector arithmetic */ - return v-nl; -} - -static int *ivector(int nl, int nh) -{ - int *v; - - v = (int *)malloc((unsigned) (nh-nl+1)*sizeof(int)); - if (!v) - { - nrerror("allocation failure in ivector()", TRUE); - } - /* cppcheck-suppress memleak - * free_vector does the same vector arithmetic */ - return v-nl; -} - - -static real **matrix1(int nrl, int nrh, int ncl, int nch) -{ - int i; - real **m; - - m = (real **) malloc((unsigned) (nrh-nrl+1)*sizeof(real*)); - if (!m) - { - nrerror("allocation failure 1 in matrix1()", TRUE); - } - m -= nrl; - - for (i = nrl; i <= nrh; i++) - { - m[i] = (real *) malloc((unsigned) (nch-ncl+1)*sizeof(real)); - if (!m[i]) - { - nrerror("allocation failure 2 in matrix1()", TRUE); - } - m[i] -= ncl; - } - return m; -} - -static double **dmatrix(int nrl, int nrh, int ncl, int nch) -{ - int i; - double **m; - - m = (double **) malloc((unsigned) (nrh-nrl+1)*sizeof(double*)); - if (!m) - { - nrerror("allocation failure 1 in dmatrix()", TRUE); - } - m -= nrl; - - for (i = nrl; i <= nrh; i++) - { - m[i] = (double *) malloc((unsigned) (nch-ncl+1)*sizeof(double)); - if (!m[i]) - { - nrerror("allocation failure 2 in dmatrix()", TRUE); - } - m[i] -= ncl; - } - return m; -} - -static int **imatrix1(int nrl, int nrh, int ncl, int nch) -{ - int i, **m; - - m = (int **)malloc((unsigned) (nrh-nrl+1)*sizeof(int*)); - if (!m) - { - nrerror("allocation failure 1 in imatrix1()", TRUE); - } - m -= nrl; - - for (i = nrl; i <= nrh; i++) - { - m[i] = (int *)malloc((unsigned) (nch-ncl+1)*sizeof(int)); - if (!m[i]) - { - nrerror("allocation failure 2 in imatrix1()", TRUE); - } - m[i] -= ncl; - } - return m; -} - - - -static real **submatrix(real **a, int oldrl, int oldrh, int oldcl, - int newrl, int newcl) -{ - int i, j; - real **m; - - m = (real **) malloc((unsigned) (oldrh-oldrl+1)*sizeof(real*)); - if (!m) - { - nrerror("allocation failure in submatrix()", TRUE); - } - m -= newrl; - - for (i = oldrl, j = newrl; i <= oldrh; i++, j++) - { - m[j] = a[i]+oldcl-newcl; - } - - return m; -} - - - -static void free_vector(real *v, int nl) -{ - free((char*) (v+nl)); -} - -static void free_ivector(int *v, int nl) -{ - free((char*) (v+nl)); -} - -static void free_dvector(int *v, int nl) -{ - free((char*) (v+nl)); -} - - - -static void free_matrix(real **m, int nrl, int nrh, int ncl) -{ - int i; - - for (i = nrh; i >= nrl; i--) - { - free((char*) (m[i]+ncl)); - } - free((char*) (m+nrl)); -} - -static real **convert_matrix(real *a, int nrl, int nrh, int ncl, int nch) -{ - int i, j, nrow, ncol; - real **m; - - nrow = nrh-nrl+1; - ncol = nch-ncl+1; - m = (real **) malloc((unsigned) (nrow)*sizeof(real*)); - if (!m) - { - nrerror("allocation failure in convert_matrix()", TRUE); - } - m -= nrl; - for (i = 0, j = nrl; i <= nrow-1; i++, j++) - { - m[j] = a+ncol*i-ncl; - } - return m; -} - - - -static void free_convert_matrix(real **b, int nrl) -{ - free((char*) (b+nrl)); -} - -#define SWAP(a, b) {real temp = (a); (a) = (b); (b) = temp; } - -static void dump_mat(int n, real **a) -{ - int i, j; - - for (i = 1; (i <= n); i++) - { - for (j = 1; (j <= n); j++) - { - fprintf(stderr, " %10.3f", a[i][j]); - } - fprintf(stderr, "\n"); - } -} - -gmx_bool gaussj(real **a, int n, real **b, int m) -{ - int *indxc, *indxr, *ipiv; - int i, icol = 0, irow = 0, j, k, l, ll; - real big, dum, pivinv; - - indxc = ivector(1, n); - indxr = ivector(1, n); - ipiv = ivector(1, n); - for (j = 1; j <= n; j++) - { - ipiv[j] = 0; - } - for (i = 1; i <= n; i++) - { - big = 0.0; - for (j = 1; j <= n; j++) - { - if (ipiv[j] != 1) - { - for (k = 1; k <= n; k++) - { - if (ipiv[k] == 0) - { - if (fabs(a[j][k]) >= big) - { - big = fabs(a[j][k]); - irow = j; - icol = k; - } - } - else if (ipiv[k] > 1) - { - nrerror("GAUSSJ: Singular Matrix-1", FALSE); - return FALSE; - } - } - } - } - ++(ipiv[icol]); - if (irow != icol) - { - for (l = 1; l <= n; l++) - { - SWAP(a[irow][l], a[icol][l]); - } - for (l = 1; l <= m; l++) - { - SWAP(b[irow][l], b[icol][l]); - } - } - indxr[i] = irow; - indxc[i] = icol; - if (a[icol][icol] == 0.0) - { - fprintf(stderr, "irow = %d, icol = %d\n", irow, icol); - dump_mat(n, a); - nrerror("GAUSSJ: Singular Matrix-2", FALSE); - return FALSE; - } - pivinv = 1.0/a[icol][icol]; - a[icol][icol] = 1.0; - for (l = 1; l <= n; l++) - { - a[icol][l] *= pivinv; - } - for (l = 1; l <= m; l++) - { - b[icol][l] *= pivinv; - } - for (ll = 1; ll <= n; ll++) - { - if (ll != icol) - { - dum = a[ll][icol]; - a[ll][icol] = 0.0; - for (l = 1; l <= n; l++) - { - a[ll][l] -= a[icol][l]*dum; - } - for (l = 1; l <= m; l++) - { - b[ll][l] -= b[icol][l]*dum; - } - } - } - } - for (l = n; l >= 1; l--) - { - if (indxr[l] != indxc[l]) - { - for (k = 1; k <= n; k++) - { - SWAP(a[k][indxr[l]], a[k][indxc[l]]); - } - } - } - free_ivector(ipiv, 1); - free_ivector(indxr, 1); - free_ivector(indxc, 1); - - return TRUE; -} - -#undef SWAP - - -static void covsrt(real **covar, int ma, int lista[], int mfit) -{ - int i, j; - real swap; - - for (j = 1; j < ma; j++) - { - for (i = j+1; i <= ma; i++) - { - covar[i][j] = 0.0; - } - } - for (i = 1; i < mfit; i++) - { - for (j = i+1; j <= mfit; j++) - { - if (lista[j] > lista[i]) - { - covar[lista[j]][lista[i]] = covar[i][j]; - } - else - { - covar[lista[i]][lista[j]] = covar[i][j]; - } - } - } - swap = covar[1][1]; - for (j = 1; j <= ma; j++) - { - covar[1][j] = covar[j][j]; - covar[j][j] = 0.0; - } - covar[lista[1]][lista[1]] = swap; - for (j = 2; j <= mfit; j++) - { - covar[lista[j]][lista[j]] = covar[1][j]; - } - for (j = 2; j <= ma; j++) - { - for (i = 1; i <= j-1; i++) - { - covar[i][j] = covar[j][i]; - } - } -} - -#define SWAP(a, b) {swap = (a); (a) = (b); (b) = swap; } - -static void covsrt_new(real **covar, int ma, int ia[], int mfit) -/* Expand in storage the covariance matrix covar, so as to take - * into account parameters that are being held fixed. (For the - * latter, return zero covariances.) - */ -{ - int i, j, k; - real swap; - for (i = mfit+1; i <= ma; i++) - { - for (j = 1; j <= i; j++) - { - covar[i][j] = covar[j][i] = 0.0; - } - } - k = mfit; - for (j = ma; j >= 1; j--) - { - if (ia[j]) - { - for (i = 1; i <= ma; i++) - { - SWAP(covar[i][k], covar[i][j]); - } - for (i = 1; i <= ma; i++) - { - SWAP(covar[k][i], covar[j][i]); - } - k--; - } - } -} -#undef SWAP - -static void mrqcof(real x[], real y[], real sig[], int ndata, real a[], - int ma, int lista[], int mfit, - real **alpha, real beta[], real *chisq, - void (*funcs)(real, real *, real *, real *)) -{ - int k, j, i; - real ymod, wt, sig2i, dy, *dyda; - - dyda = rvector(1, ma); - for (j = 1; j <= mfit; j++) - { - for (k = 1; k <= j; k++) - { - alpha[j][k] = 0.0; - } - beta[j] = 0.0; - } - *chisq = 0.0; - for (i = 1; i <= ndata; i++) - { - (*funcs)(x[i], a, &ymod, dyda); - sig2i = 1.0/(sig[i]*sig[i]); - dy = y[i]-ymod; - for (j = 1; j <= mfit; j++) - { - wt = dyda[lista[j]]*sig2i; - for (k = 1; k <= j; k++) - { - alpha[j][k] += wt*dyda[lista[k]]; - } - beta[j] += dy*wt; - } - (*chisq) += dy*dy*sig2i; - } - for (j = 2; j <= mfit; j++) - { - for (k = 1; k <= j-1; k++) - { - alpha[k][j] = alpha[j][k]; - } - } - free_vector(dyda, 1); -} - - -gmx_bool mrqmin(real x[], real y[], real sig[], int ndata, real a[], - int ma, int lista[], int mfit, - real **covar, real **alpha, real *chisq, - void (*funcs)(real, real *, real *, real *), - real *alamda) -{ - int k, kk, j, ihit; - static real *da, *atry, **oneda, *beta, ochisq; - - if (*alamda < 0.0) - { - oneda = matrix1(1, mfit, 1, 1); - atry = rvector(1, ma); - da = rvector(1, ma); - beta = rvector(1, ma); - kk = mfit+1; - for (j = 1; j <= ma; j++) - { - ihit = 0; - for (k = 1; k <= mfit; k++) - { - if (lista[k] == j) - { - ihit++; - } - } - if (ihit == 0) - { - lista[kk++] = j; - } - else if (ihit > 1) - { - nrerror("Bad LISTA permutation in MRQMIN-1", FALSE); - return FALSE; - } - } - if (kk != ma+1) - { - nrerror("Bad LISTA permutation in MRQMIN-2", FALSE); - return FALSE; - } - *alamda = 0.001; - mrqcof(x, y, sig, ndata, a, ma, lista, mfit, alpha, beta, chisq, funcs); - ochisq = (*chisq); - } - for (j = 1; j <= mfit; j++) - { - for (k = 1; k <= mfit; k++) - { - covar[j][k] = alpha[j][k]; - } - covar[j][j] = alpha[j][j]*(1.0+(*alamda)); - oneda[j][1] = beta[j]; - } - if (!gaussj(covar, mfit, oneda, 1)) - { - return FALSE; - } - for (j = 1; j <= mfit; j++) - { - da[j] = oneda[j][1]; - } - if (*alamda == 0.0) - { - covsrt(covar, ma, lista, mfit); - free_vector(beta, 1); - free_vector(da, 1); - free_vector(atry, 1); - free_matrix(oneda, 1, mfit, 1); - return TRUE; - } - for (j = 1; j <= ma; j++) - { - atry[j] = a[j]; - } - for (j = 1; j <= mfit; j++) - { - atry[lista[j]] = a[lista[j]]+da[j]; - } - mrqcof(x, y, sig, ndata, atry, ma, lista, mfit, covar, da, chisq, funcs); - if (*chisq < ochisq) - { - *alamda *= 0.1; - ochisq = (*chisq); - for (j = 1; j <= mfit; j++) - { - for (k = 1; k <= mfit; k++) - { - alpha[j][k] = covar[j][k]; - } - beta[j] = da[j]; - a[lista[j]] = atry[lista[j]]; - } - } - else - { - *alamda *= 10.0; - *chisq = ochisq; - } - return TRUE; -} - - -gmx_bool mrqmin_new(real x[], real y[], real sig[], int ndata, real a[], - int ia[], int ma, real **covar, real **alpha, real *chisq, - void (*funcs)(real, real [], real *, real []), - real *alamda) -/* Levenberg-Marquardt method, attempting to reduce the value Chi^2 - * of a fit between a set of data points x[1..ndata], y[1..ndata] - * with individual standard deviations sig[1..ndata], and a nonlinear - * function dependent on ma coefficients a[1..ma]. The input array - * ia[1..ma] indicates by nonzero entries those components of a that - * should be fitted for, and by zero entries those components that - * should be held fixed at their input values. The program returns - * current best-fit values for the parameters a[1..ma], and - * Chi^2 = chisq. The arrays covar[1..ma][1..ma], alpha[1..ma][1..ma] - * are used as working space during most iterations. Supply a routine - * funcs(x,a,yfit,dyda,ma) that evaluates the fitting function yfit, - * and its derivatives dyda[1..ma] with respect to the fitting - * parameters a at x. On the first call provide an initial guess for - * the parameters a, and set alamda < 0 for initialization (which then - * sets alamda=.001). If a step succeeds chisq becomes smaller and - * alamda de-creases by a factor of 10. If a step fails alamda grows by - * a factor of 10. You must call this routine repeatedly until - * convergence is achieved. Then, make one final call with alamda=0, - * so that covar[1..ma][1..ma] returns the covariance matrix, and alpha - * the curvature matrix. - * (Parameters held fixed will return zero covariances.) - */ -{ - void covsrt(real **covar, int ma, int ia[], int mfit); - gmx_bool gaussj(real **a, int n, real **b, int m); - void mrqcof_new(real x[], real y[], real sig[], int ndata, real a[], - int ia[], int ma, real **alpha, real beta[], real *chisq, - void (*funcs)(real, real [], real *, real [])); - int j, k, l; - static int mfit; - static real ochisq, *atry, *beta, *da, **oneda; - - if (*alamda < 0.0) /* Initialization. */ - { - atry = rvector(1, ma); - beta = rvector(1, ma); - da = rvector(1, ma); - for (mfit = 0, j = 1; j <= ma; j++) - { - if (ia[j]) - { - mfit++; - } - } - oneda = matrix1(1, mfit, 1, 1); - *alamda = 0.001; - mrqcof_new(x, y, sig, ndata, a, ia, ma, alpha, beta, chisq, funcs); - ochisq = (*chisq); - for (j = 1; j <= ma; j++) - { - atry[j] = a[j]; - } - } - for (j = 1; j <= mfit; j++) /* Alter linearized fitting matrix, by augmenting. */ - { - for (k = 1; k <= mfit; k++) - { - covar[j][k] = alpha[j][k]; /* diagonal elements. */ - } - covar[j][j] = alpha[j][j]*(1.0+(*alamda)); - oneda[j][1] = beta[j]; - } - if (!gaussj(covar, mfit, oneda, 1)) /* Matrix solution. */ - { - return FALSE; - } - for (j = 1; j <= mfit; j++) - { - da[j] = oneda[j][1]; - } - if (*alamda == 0.0) /* Once converged, evaluate covariance matrix. */ - { - covsrt_new(covar, ma, ia, mfit); - free_matrix(oneda, 1, mfit, 1); - free_vector(da, 1); - free_vector(beta, 1); - free_vector(atry, 1); - return TRUE; - } - for (j = 0, l = 1; l <= ma; l++) /* Did the trial succeed? */ - { - if (ia[l]) - { - atry[l] = a[l]+da[++j]; - } - } - mrqcof_new(x, y, sig, ndata, atry, ia, ma, covar, da, chisq, funcs); - if (*chisq < ochisq) - { - /* Success, accept the new solution. */ - *alamda *= 0.1; - ochisq = (*chisq); - for (j = 1; j <= mfit; j++) - { - for (k = 1; k <= mfit; k++) - { - alpha[j][k] = covar[j][k]; - } - beta[j] = da[j]; - } - for (l = 1; l <= ma; l++) - { - a[l] = atry[l]; - } - } - else /* Failure, increase alamda and return. */ - { - *alamda *= 10.0; - *chisq = ochisq; - } - return TRUE; -} - -void mrqcof_new(real x[], real y[], real sig[], int ndata, real a[], - int ia[], int ma, real **alpha, real beta[], real *chisq, - void (*funcs)(real, real [], real *, real[])) -/* Used by mrqmin to evaluate the linearized fitting matrix alpha, and - * vector beta as in (15.5.8), and calculate Chi^2. - */ -{ - int i, j, k, l, m, mfit = 0; - real ymod, wt, sig2i, dy, *dyda; - - dyda = rvector(1, ma); - for (j = 1; j <= ma; j++) - { - if (ia[j]) - { - mfit++; - } - } - for (j = 1; j <= mfit; j++) /* Initialize (symmetric) alpha), beta. */ - { - for (k = 1; k <= j; k++) - { - alpha[j][k] = 0.0; - } - beta[j] = 0.0; - } - *chisq = 0.0; - for (i = 1; i <= ndata; i++) /* Summation loop over all data. */ - { - (*funcs)(x[i], a, &ymod, dyda); - sig2i = 1.0/(sig[i]*sig[i]); - dy = y[i]-ymod; - for (j = 0, l = 1; l <= ma; l++) - { - if (ia[l]) - { - wt = dyda[l]*sig2i; - for (j++, k = 0, m = 1; m <= l; m++) - { - if (ia[m]) - { - alpha[j][++k] += wt*dyda[m]; - } - } - beta[j] += dy*wt; - } - } - *chisq += dy*dy*sig2i; /* And find Chi^2. */ - } - for (j = 2; j <= mfit; j++) /* Fill in the symmetric side. */ - { - for (k = 1; k < j; k++) - { - alpha[k][j] = alpha[j][k]; - } - } - free_vector(dyda, 1); -} -- 2.11.4.GIT