Remove silly tex/ directory.
[thesis.git] / src / figures / expt-sawtooth / expt-sawtooth.asy
1 import wtk_graph;
2
3 size(15cm,10cm,IgnoreAspect);
4
5 scale(Linear, Linear);
6 real k = infinity; /* spring constant in N/m, already accounted for (0.05) */
7 real xscale=1e9;
8 real fscale=1e12;
9
10 real xmin = -5e-9;
11 real xmax = 300e-9;
12 real fmin = -100e-12;
13 real fmax = 1000e-12;
14 real fnmax = 300e-12;
15
16 real kB = 1.3806504e-23;
17 real T = 300;
18 real p = 3.7e-10;
19 real WLC(real x, real L, real p=p, real T=T, real kB=kB,
20          real xLmax=0.99, real fmax=fnmax) {
21   real f = infinity;
22   if (x < 0)
23     return infinity;
24   if (x/L <= xLmax)
25     f = kB*T/p*(0.25*(1/(1-x/L)^2 - 1) + x/L);
26   if (f > fnmax)
27     return infinity;
28   return f;
29 }
30
31 void graphSawtooth(string file="datafile", real k,
32                    int xcol=0, int fcol=1,
33                    real xscale=1, real fscale=1, real dx=0, real df=0,
34                    pen p=red) {
35   file fin=input(file).line();
36   real[][] a=fin.dimension(0,0);
37   a=transpose(a);
38   real[] x=a[xcol];
39   real[] f=a[fcol];
40   x = x - f/k; /* Remove cantilever extension */
41   graphData(x=x, y=f, xscale=xscale, yscale=fscale,
42             dx=dx, dy=df, p=p, dots=false);
43 }
44
45 /* expt.dat already scaled to nm and pN */
46 graphSawtooth("expt.dat", k=k, p=psoft);
47
48 file fin = input('expt-Ls.dat').line();
49 real[][] a = fin.dimension(0,0);
50 a = transpose(a);
51 real[] Ls = a[0];
52 int i;
53 for (i=0; i<Ls.length; ++i) {
54   real fn(real x) {
55     real f = WLC(x / xscale, L=Ls[i]);
56     if (f == infinity) {
57       write(x, fnmax*fscale * 1.1);
58       return fnmax*fscale * 1.1;
59     }
60     write(x, f*fscale);
61     return f*fscale;
62   }
63   draw(graph(fn, a=0, b=0.9*Ls[i]*xscale), p=phard);
64 }
65
66 xlimits(xmin*xscale, xmax*xscale, crop=true);
67 ylimits(fmin*fscale, fmax*fscale, crop=true);
68
69 xaxis(sLabel("Distance (nm)"), BottomTop, LeftTicks);
70 yaxis(sLabel("Force (pN)"), LeftRight, RightTicks);
71 label(sLabel("Poly-ubiquitin force curve"), point(N), N);