3 # Use a single hooke domain with a bell unfolding rate, so unfolding force
4 # is proportional to time, and we expect a peaked death histogram.
7 # spring constant k=df/dx=1 \__
8 # velocity v=dx/dt=1 / `--> df/dt = kv = 1 --> f = t (+ f0)
9 # unfolding rate K= a e^(bf) (frac/s)
11 # let P(f) be the population existing at force f (normed so P(0)=0).
12 # the probability of dying (normed # deaths) between f and f+df is given by
13 # dD = K P(f) * dt = K P(f) df/kv since dt = df/kv
14 # this is what whe plot in the normalized histogram with dD in a bin of width
15 # df. The continuous analog is the function dD/df = K/kv P(f).
18 # dP/P = -K dt = -a e^{bf} df/kv = -z e^{bf} df where z ≡ a/kv
19 # ln(P) = -z/b e^{bf) + c
20 # P = C e^{-z/b e^{bf}}
21 # Applying our f0=0 boundary condition we see that C = P0 e^{z/b}.
22 # Plugging P(f) into our formula for dD/df yields
23 # dD/df = K/kv P(f) = z e^{bf} P0 e^{z/b} e^{-z/b e^{bf}}
24 # dD/df = P0 z e^{bf + z/b(1-e^{bf})}
26 # The histogram scaling isn't dD/df, though, it's dD/d(bin)
27 # dD/d(bin) = dD/df df/d(bin) = binwidth P0 z e^{bf + z/b(1-e^{bf})}
29 # test with lots of runs of
30 # v- T=1/kB v- v=1 v- k=1
31 # sawsim -T7.24296e22 -v1 -s folded,hooke,1 -N1 -s unfolded,null \
32 # -k "folded,unfolded,bell,{1,1}" -q folded
34 # (kB = 1.3806503 10-23 J/K, we use T=1/kB to get the bell K=e^{-f})
36 # 60 runs of that takes ~1 second:
37 # time xtimes 60 sawsim -T7.24296e22 -v1 -s folded,hooke,1 -N1 \
38 # -s unfolded,null -k "folded,unfolded,bell,{1,1}" -q folded \
43 # since we're on the cluster, we'll go crazy and get really good statistics ;)
46 SAWSIM=../../bin/sawsim
53 # dD/d(bin) = binwidth P0 z e^{bf + z/b(1-e^{bf})}
54 # where z ≡ a/kv, and b = Δx/kBT
55 KB=1.3806503e-23 # J/K
58 if [ "$STYLE" == "ones" ]
60 df=1e-1 # histogram bin width
74 B=`echo "print ($DX/($KB*$T))" | python`
75 Z=`echo "print (float($A)/($K*$V))" | python`
76 THEORY_FN="$df * $N * $Z * exp($B*x + $Z/$B *(1 - exp($B*x)))"
80 if [ "$ISACLUSTER" -eq 1 ]
83 #qcmd "xtimes $N $SAWSIM -T$T -v$V -mhooke -a$K -kbell -K$A,$DX -F1 | grep -v '^#' >> $DATA"
85 qcmd "xtimes $N $SAWSIM -T$T -v$V -s folded,hooke,$K -N1 -s unfolded,null -k 'folded,unfolded,bell,{$A,$DX}' -q folded | grep -v '^#' | cut -f1 >> $DATA"
88 #xtimes $N $SAWSIM -T$T -v$V -mhooke -a$K -kbell -K$A,$DX -F1 | grep -v '^#' >> $DATA
90 xtimes $N $SAWSIM -T$T -v$V -s folded,hooke,$K -N1 -s unfolded,null -k "folded,unfolded,bell,{$A,$DX}" -q folded | grep -v '^#' | cut -f1 >> $DATA
94 cat $DATA | stem_leaf -v-1 -b$df | sed 's/://' > $HIST
97 FIT=`cat $HIST | ./fit_bell`
99 FITZ=`echo "$FIT" | sed -n 's/a:[[:space:]]*//p'`
100 FITB=`echo "$FIT" | sed -n 's/b:[[:space:]]*//p'`
101 echo -e "z:\t$FITZ\t(expected $Z)"
102 echo -e "b:\t$FITB\t(expected $B)"
104 # generate gnuplot script
105 echo "set terminal png" > $GPFILE
106 echo "set output '$PNGFILE'" >> $GPFILE
107 echo "set logscale y" >> $GPFILE
108 echo "set xlabel 'Time'" >> $GPFILE
109 echo "set ylabel 'Deaths'" >> $GPFILE
110 echo "theory(x) = $THEORY_FN" >> $GPFILE
111 echo "fit(x) = $df * $N * $FITZ * exp($FITB*x + $FITZ/$FITB*(1-exp($FITB*x)))" >> $GPFILE
112 echo "plot theory(x), '$HIST' with points, fit(x)" >> $GPFILE