from site_cons.site_init import link_wtk_graph
-FIGURES = ['unfolding', 'afm', 'landscape-cant', 'monte-carlo', 'piezo']
+FIGURES = ['unfolding', 'afm', 'kramers-integrand', 'landscape',
+ 'landscape-cant', 'monte-carlo', 'piezo']
# Get the passed in environment.
Import('env')
--- /dev/null
+import palette;
+import wtk_graph;
+
+real a = 0.2;
+real b = 0.7;
+real x_min = 0;
+real x_max = 1;
+real f_min = 0; // zoom in on region of interest
+real f_max = 1;
+real n = 20; // number of integration traces
+
+real f_raw(real x) {return -(x-a)*(x-b)**2;}
+real f_raw_min = f_raw(x_max);
+real f_raw_max = f_raw(x_min);
+real f(real x) {return (f_raw(x)-f_raw_min)/(f_raw_max-f_raw_min);}
+
+real ep(real x) {return (exp(f(x)));}
+real em(real x) {return (exp(-f(x)));}
+real integrand(real x, real y) {return (ep(y) * em(x));}
+
+picture pic1;
+scale(pic1, Linear, Linear);
+image(pic1, integrand, (x_min, x_min), (x_max, x_max), BWRainbow());
+real x;
+for (int i = 1; i <= n; ++i) {
+ x = x_min + i*(x_max-x_min)/(n + 1);
+ draw(pic1, (0, x) -- (x, x));
+}
+size(pic1, 5cm, 5cm, point(pic1, SW), point(pic1, NE));
+label(pic1, sLabel("Kramers integrand"), point(pic1, N), align=N);
+frame f1 = shift((2cm, 0)) * pic1.fit();
+add(f1);
+
+picture pic2;
+scale(pic2, Linear, Linear);
+draw(pic2, graph(em, x_min, x_max, operator ..), red);
+size(pic2, 5cm, 1cm, point(pic2, SW), point(pic2, NE));
+xaxis(pic2, sLabel("$x'$"), Bottom);
+frame f2 = pic2.fit();
+f2 = shift((min(f1).x - min(f2).x, min(f1).y - max(f2).y)) * f2;
+add(f2);
+label(Label("$e^{-U(x')}$"), (max(f2)+min(f2))/2 + (-18pt, 0));
+
+picture pic3;
+scale(pic3, Linear, Linear);
+draw(pic3, rotate(90)*graph(ep, x_min, x_max, operator ..), red);
+size(pic3, 1cm, 5cm, point(pic3, SW), point(pic3, NE));
+yaxis(pic3, sLabel("$x$"), Left);
+frame f3 = pic3.fit();
+f3 = shift((min(f1).x - max(f3).x, min(f1).y - min(f3).y)) * f3;
+add(f3);
+label(rotate(90)*Label("$e^{U(x)}$"), (max(f3)+min(f3))/2 + (0, -18pt));
+// This graphic is very similar to landscape.asy
+
import wtk_graph;
-size(6cm,4cm,IgnoreAspect);
+size(6cm, 4cm, IgnoreAspect);
-scale(Linear,Linear);
+scale(Linear, Linear);
real a = 0.2;
real b = 0.7;
real F = 0.3;
real k = 0.5;
-real x_min = 1;
-real x_max = 0;
+real x_min = 0;
+real x_max = 1;
+real f_min = 0;
+real f_max = 1;
real f_raw(real x) {return -(x-a)*(x-b)**2;}
-real f_min = f_raw(x_min);
-real f_max = f_raw(x_max);
-real f(real x) {return (f_raw(x)-f_min)/(f_max-f_min);}
-
-// df/dx = -(x-b)**2 - 2(x-a)(x-b)
-// at the extremes, df/dx = 0, so
-// (x-b)**2 = -2(x-a)(x-b)
-// so
-// x-b = 0
-// x = b
-// or
-// -2(x-a) = (x-b)
-// x = (2a + b)/3
+real f_raw_min = f_raw(x_max);
+real f_raw_max = f_raw(x_min);
+real f(real x) {return (f_raw(x)-f_raw_min)/(f_raw_max-f_raw_min);}
real x_fold = (2*a+b)/3;
real x_barrier = b;
real force(real x) {return const_force(x)+1/2*k*(x-x_fold)**2;}
real f_force(real x) {return f(x)+(force(x)-f(x_fold));}
-draw(graph(f, 0, 1, operator ..), blue);
-draw(graph(const_force, 0, 1, operator ..), dashed);
-draw(graph(force, 0, 1, operator ..), black);
-draw(graph(f_force, 0, 1, operator ..), red);
+draw(graph(f, x_min, x_max, operator ..), blue);
+draw(graph(const_force, x_min, x_max, operator ..), dashed);
+draw(graph(force, x_min, x_max, operator ..), black);
+draw(graph(f_force, x_min, x_max, operator ..), red);
-dot(sLabel("folded",align=S),(x_fold, f(x_fold)));
-dot(sLabel("barrier",align=N),(x_barrier, f(x_barrier)));
+label(sLabel("folded", align=S), Scale((x_fold, f(x_fold))));
+label(sLabel("barrier", align=N), Scale((x_barrier, f(x_barrier))));
-xlimits(0, 1, Crop);
-ylimits(0, 1, Crop);
+xlimits(x_min, x_max, Crop);
+ylimits(f_min, f_max, Crop);
-label(sLabel("Energy landscape schematic"), point(N), N);
+label(sLabel("Cantilever-altered energy landscape"), point(N), N);
xaxis(sLabel("End-to-end distance $x$"), BottomTop);
-yaxis(sLabel("Free energy $E$"), LeftRight);
+yaxis(sLabel("Free energy $U_F$"), LeftRight);
--- /dev/null
+import wtk_graph;
+
+size(6cm, 4cm, IgnoreAspect);
+
+scale(Linear, Linear);
+
+real a = 0.2;
+real b = 0.6;
+real x_min = 0;
+real x_max = 1;
+real f_min = 0.5; // zoom in on region of interest
+real f_max = 0.8;
+real x_arrow = 0.2; // range around x_barrier
+real y_arrow = 0.08; // offset above U_F(x)
+real state_size = 7pt; // size of current-state dot
+
+real f_raw(real x) {return -(x-a)*(x-b)**2;}
+real f_raw_min = f_raw(x_max);
+real f_raw_max = f_raw(x_min);
+real f(real x) {return (f_raw(x)-f_raw_min)/(f_raw_max-f_raw_min);}
+real f_arrow(real x) {return (f(x) + y_arrow);}
+
+// df/dx = -(x-b)**2 - 2(x-a)(x-b)
+// at the extremes, df/dx = 0, so
+// (x-b)**2 = -2(x-a)(x-b)
+// so
+// x-b = 0
+// x = b
+// or
+// -2(x-a) = (x-b)
+// x = (2a + b)/3
+
+real x_fold = (2*a+b)/3;
+real x_barrier = b;
+real x_unfold = (2*b + x_max)/3;
+real x_state = (3*x_fold + x_barrier)/4;
+
+path f_path = graph(f, x_min, x_max, operator ..);
+draw(f_path, blue);
+
+path arrow_path = graph(f_arrow, x_barrier-x_arrow/2, x_barrier+x_arrow/2,
+ operator ..);
+draw(arrow_path, Arrow);
+label(sLabel("$k_u$", align=N), point(arrow_path, length(arrow_path)/2));
+
+real[] state_ts = intersect(f_path, (x_state, f_min)--(x_state, f_max));
+real state_t = state_ts[0]; // time along f_path
+pair state_perp = scale(1/10cm)*rotate(90)*dir(f_path, state_t);
+pair state_point = (x_state, f(x_state)) + state_perp*state_size/2;
+pen state_pen = linewidth(state_size) + currentpen;
+
+label(sLabel("folded", align=S), Scale((x_fold, f(x_fold))));
+label(sLabel("barrier", align=N), Scale((x_barrier, f(x_barrier))));
+label(sLabel("unfolded", align=NE), Scale((x_unfold, f(x_unfold))));
+dot(Scale(state_point), state_pen);
+label(sLabel("state", align=N), Scale(state_point) + (0, state_size/20cm));
+
+xlimits(x_min, x_max, Crop);
+ylimits(f_min, f_max, Crop);
+
+label(sLabel("Unfolding energy landscape"), point(N), N);
+xaxis(sLabel("End-to-end distance $x$"), BottomTop);
+yaxis(sLabel("Free energy $U_F$"), LeftRight);