4 enum { gemNULL
, gemNONE
, gemDD
, gemAD
, gemAA
, gemA4
, gemNR
};
5 static const char *gemType
[] = {NULL
, "none", "dd", "ad", "aa", "a4", NULL
};
7 /* The first few sections of this file contain functions that were adopted,
8 * and to some extent modified, by Erik Marklund (erikm[aT]xray.bmc.uu.se,
9 * http://folding.bmc.uu.se) from code written by Omer Markovitch (email, url).
10 * This is also the case with the function eq10v2() in geminate.c.
12 * The parts menetioned in the previous paragraph were contributed under a BSD license.
15 /* This first part is derived from complex.c which I recieved from Omer Markowitch.
18 * ------------- from complex.c ------------- */
21 /* definition of PI */
23 #define PI (acos(-1.0))
26 /* definition of the type complex */
33 /* ------------ end of complex.c ------------ */
35 /* This next part was derived from cerror.c and rerror.c,
36 * also received from Omer Markovitch.
37 * ------------- from [cr]error.c ------------- */
40 #define sPI (sqrt(PI))
43 /* ------------ end of [cr]error.c ------------ */
45 /* ///////////////// REVERSIBLE GEMINATE RECOMBINATION ///////////////////
46 * Here follow routines and structs for reversible geminate recombination.
58 /* Used in the rewritten version of Omer's gem. recomb. analysis */
59 double ka
, kd
; /* -- || -- results[] */
60 double sigma
; /* -- || -- sigma */
61 double D
; /* The diffusion coefficient */
62 double kD
; /* Replaces kD in analyse_corr_gem3d() */
64 /* The following members are for calcsquare() and takeAwayBallistic() */
65 double tDelta
; /* Time between frames */
66 /* double logAfterTime; /\* Time after which we do the lsq calculations on a logarithmic timescale. *\/ */
67 int nFitPoints
; /* Number of points to take from the ACF for fitting */
68 double begFit
; /* Fit from this time (ps) */
69 double endFit
; /* Fit up to this time (ps) */
70 /* double logDelta; */
72 /* To get an equal number of points in the lin and log regime,
73 * we'll use logDelta to calculate where to sample the ACF.
74 * if i and j are indices in the linear and log regime, then:
75 * j = Cexp(A(i+nLin)),
76 * where C = (nLin**2 / len) and A = log(len/nLin) / nLin.
77 * This expands to j = (nLin**2 / len) * exp((i+nLin) * log(len/nLin) / nLin).
78 * We'll save part of our brains and some computing time if we pre-calculate
79 * 1) logDelta = log(len/nLin) / nLin
80 * 2) logPF = nLin**2 / len
81 * and get j = logPF * exp((i+nLin) * logDelta). */
83 /* I will redo this for a fit done entirely in log-log.
85 * nFitPoints' = nFitPoints-1
90 * (j'=len <=> i=nFitPoints')
91 * => A=log(len)/nFitPoints'
92 * => j = exp(i*log(len)/(nFitPoints-1)) -1
94 /* #define GETLOGINDEX(i,params) (params)->logPF * exp(((i)+(params)->nLin) * (params)->logDelta)
97 int nLin
; /* Number of timepoints in the linear regime */
98 int len
; /* Length of time and ct arrays */
99 int nExpFit
; /* Number of exponentials to fit */
100 real ballistic
; /* Time before which the ballistic term should be fitted */
101 gmx_bool bDt
; /* TRUE => use time derivative at time 0
102 * to find fastest component.
103 * FALSE => use coefficient in exponenetial
104 * to find fastest component. */
109 size_t n
; /* Number of data points (lin-log) */
110 double *y
; /* The datapoints */
111 double *ctTheory
; /* The theoretical ct which will be built by gemFunc_f. */
116 double tDelta
; /* time difference between subsequent datapoints */
117 size_t nData
; /* real size of the data */
119 double *doubleLogTime
;
123 extern void takeAwayBallistic(double *ct
, double *t
,
125 int nexp
, gmx_bool bDerivative
);
128 extern t_gemParams
*init_gemParams(const double sigma
, const double D
,
129 const real
*t
, const int len
, const int nFitPoints
,
130 const real begFit
, const real endFit
,
131 const real ballistic
, const int nBalExp
, const gmx_bool bDt
);
133 /* Fit to geminate recombination model.
134 Returns root mean square error of fit. */
135 extern real
fitGemRecomb(double *ct
, double *time
, double **ctFit
,
136 const int nData
, t_gemParams
*params
);
138 extern void dumpN(const real
*e
, const int nn
, char *fn
);