3 # Use a single hooke domain with a constant unfolding rate, so unfolding force
4 # is proportional to time, and we expect an exponential population decay.
7 # spring constant k=df/dx \__
8 # velocity v=dx/dt / `--> df/dt = kv --> f = kvt (+ f0)
9 # unfolding rate K=1 frac/s
11 # Population as a function of force/time follows
12 # p(t) = exp(-tK) = exp(-FK/kv) = p(F)
13 # so histogram of unfolding vs. force p(F) normalized to p(0)=1 should follow
14 # -binwidth N0 dp/dF = binwidth N0 pK/kv = binwidth N0 K/kv exp(-FK/kv)
16 # test with lots of runs of
17 # sawsim -v1 -mhooke -a1 -kconst -K1 -F1
18 # which is not a problem, because 200 runs of that takes ~1 second:
19 # time xtimes 200 sawsim -v1 -mhooke -a1 -kconst -K1 -F1 > /dev/null
21 # usage: const_rate.sh <velocity> <spring_constant> <unfolding_rate>
25 echo "usage: const_rate.sh <velocity> <spring_constant> <unfolding_rate>"
34 # since we're on the cluster, we'll go crazy and get really good statistics ;)
36 df=`python -c "print 0.1/$RATE"`
38 SAWSIM=../../bin/sawsim
39 DATA=const_rate_${V}_${K}_$RATE.d
40 HIST=const_rate_${V}_${K}_$RATE.hist
41 COMPFILE=const_rate_${V}_${K}_$RATE.compare
42 GPFILE=const_rate_${V}_${K}_$RATE.gp
43 PNGFILE=const_rate_${V}_${K}_$RATE.png
46 # our predicted histogram (see notes above) is
47 # hist(F) = binwidth N0 K/kv exp(-FK/kv) = A exp(F/B)
48 theoryA=`python -c "print $df*$N*$RATE/float($K*$V)"`
49 theoryB=`python -c "print float(-$K*$V)/$RATE"`
50 THEORY_FN="$theoryA * exp(x / ($theoryB))"
55 if [ "$ISACLUSTER" -eq 1 ]
58 #qcmd "xtimes $N $SAWSIM -v$V -mhooke -a$K -kconst -K$RATE -F1 | grep -v '^#' >> $DATA"
60 qcmd xtimes $N $SAWSIM -v$V -s folded,hooke,$K -N1 -s unfolded,null \
61 -k folded,unfolded,const,$RATE -q folded \
62 | grep -v '^#' | cut -f1 >> $DATA
65 #xtimes $N $SAWSIM -v$V -mhooke -a$K -kconst -K$RATE -F1 | grep -v '^#' >> $DATA
67 xtimes $N $SAWSIM -v$V -s folded,hooke,$K -N1 -s unfolded,null \
68 -k folded,unfolded,const,$RATE -q folded \
69 | grep -v '^#' | cut -f1 >> $DATA
73 if [ $DEBUG -eq 1 ]; then
74 echo "cat $DATA | stem_leaf -v-1 -b$df | sed 's/://' > $HIST"
76 cat $DATA | stem_leaf -v-1 -b$df | sed 's/://' > $HIST
78 # fit the data to an exponential decay
79 if [ $DEBUG -eq 1 ]; then
80 echo "cat $HIST | ./fit_exponential"
82 FIT=`cat $HIST | ./fit_exponential` || exit 1
83 B=`echo "$FIT" | sed -n 's/time constant:[[:space:]]*//p'`
84 A=`echo "$FIT" | sed -n 's/initial value:[[:space:]]*//p'`
85 echo -e "force scale:\t$B\t(expected $theoryB)" > $COMPFILE
86 echo -e "initial value:\t$A\t(expected $theoryA)" >> $COMPFILE
89 # generate gnuplot script
90 if [ $DEBUG -eq 1 ]; then
91 echo "generate Gnuplot script"
93 echo "set terminal png" > $GPFILE
94 echo "set output '$PNGFILE'" >> $GPFILE
95 echo "set logscale y" >> $GPFILE
96 echo "set xlabel 'Force'" >> $GPFILE
97 echo "set ylabel 'Deaths'" >> $GPFILE
98 echo "theory(x) = $THEORY_FN" >> $GPFILE
99 echo "fit(x) = $A * exp(x / $B)" >> $GPFILE
100 echo "plot theory(x), '$HIST' with points, fit(x)" >> $GPFILE
102 if [ $DEBUG -eq 1 ]; then