3 # Use a single hooke domain with a constant unfolding rate, so
4 # unfolding force is proportional to time, and connect multiple
5 # identical constant unfolding domains. We expect an exponential
9 # spring constant k=df/dx \__
10 # velocity v=dx/dt / `--> df/dt = kv --> f = kvt (+ f0)
11 # unfolding rate K=1 frac/s
13 # Population as a function of force/time follows
14 # p(t) = exp(-tK) = exp(-FK/kv) = p(F)
15 # so histogram of unfolding vs. force p(F) normalized to p(0)=1 should follow
16 # -binwidth N0 dp/dF = binwidth N0 pK/kv = binwidth N0 K/kv exp(-FK/kv)
18 # usage: const_rate.sh <num_domains> <velocity> <spring_constant> <unfolding_rate>
22 echo "usage: $0 <num_domains> <velocity> <spring_constant> <unfolding_rate>"
32 # since we're on the cluster, we'll go crazy and get really good statistics ;)
34 df=`python -c "print 0.1/$RATE"`
36 SAWSIM=../../bin/sawsim
37 DATA=const_rate_${NDOM}_${V}_${K}_${RATE}.d
38 HIST=const_rate_${NDOM}_${V}_${K}_${RATE}.hist
39 COMPFILE=const_rate_${NDOM}_${V}_${K}_${RATE}.compare
40 GPFILE=const_rate_${NDOM}_${V}_${K}_${RATE}.gp
41 PNGFILE=const_rate_${NDOM}_${V}_${K}_${RATE}.png
44 # our predicted histogram (see notes above) is
45 # hist(F) = binwidth N0 K/kv exp(-FK/kv) = A exp(F/B)
46 theoryA=`python -c "print $df*$N*$NDOM*$RATE/float($K*$V)"`
47 theoryB=`python -c "print float(-$K*$V)/$RATE"`
48 THEORY_FN="$theoryA * exp(x / ($theoryB))"
53 if [ "$ISACLUSTER" -eq 1 ]
56 qcmd xtimes $N $SAWSIM -v$V -s cantilever,hooke,$K -N1 \
57 -s folded,null -N$NDOM -s unfolded,null \
58 -k folded,unfolded,const,$RATE -q folded \
59 | grep -v '^#' | cut -f1 >> $DATA
62 xtimes $N $SAWSIM -v$V -s cantilever,hooke,$K -N1 \
63 -s folded,null -N$NDOM -s unfolded,null \
64 -k folded,unfolded,const,$RATE -q folded \
65 | grep -v '^#' | cut -f1 >> $DATA
69 if [ $DEBUG -eq 1 ]; then
70 echo "cat $DATA | stem_leaf -v-1 -b$df -c | sed 's/://' > $HIST"
72 cat $DATA | stem_leaf -v-1 -b$df -c | sed 's/://' > $HIST
74 # fit the data to an exponential decay
75 if [ $DEBUG -eq 1 ]; then
76 echo "cat $HIST | ./fit_exponential"
78 FIT=`cat $HIST | ./fit_exponential` || exit 1
79 B=`echo "$FIT" | sed -n 's/time constant:[[:space:]]*//p'`
80 A=`echo "$FIT" | sed -n 's/initial value:[[:space:]]*//p'`
81 echo -e "force scale:\t$B\t(expected $theoryB)" > $COMPFILE
82 echo -e "initial value:\t$A\t(expected $theoryA)" >> $COMPFILE
85 # generate gnuplot script
86 if [ $DEBUG -eq 1 ]; then
87 echo "generate Gnuplot script"
89 echo "set terminal png" > $GPFILE
90 echo "set output '$PNGFILE'" >> $GPFILE
91 echo "set logscale y" >> $GPFILE
92 echo "set xlabel 'Force'" >> $GPFILE
93 echo "set ylabel 'Deaths'" >> $GPFILE
94 echo "theory(x) = $THEORY_FN" >> $GPFILE
95 echo "fit(x) = $A * exp(x / $B)" >> $GPFILE
96 echo "plot theory(x), '$HIST' with points, fit(x)" >> $GPFILE
98 if [ $DEBUG -eq 1 ]; then