• API
• FAQ
• Tools
• Trends
• Archive
daily pastebin goal
36%
SHARE
TWEET

Turing Stripes

Matthen May 17th, 2013 199 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. window[x_] := (Cos[Pi x] + 1)/2;
2. n = 3;
3. ps = {0.6, -0.3, 0.1};
4. as = {0.1, 0.5, 0.8};
5. initu[x_] := Sum[2 as[[i]] Exp[-20 (x - ps[[i]])^2], {i, n}];
6. Tmax = 80;
7. \[Tau] = 0.1; du2 = 0.00028; dv2 = 0.005; \[Kappa] = -0.005;
8. soln = NDSolve[{
9.     D[u[x, t], t] ==
10.      du2  D[u[x, t], {x, 2}] + u[x, t] - u[x, t]^3 -
11.       v[x, t] - \[Kappa],
12.     \[Tau] D[v[x, t], t] ==
13.      dv2  D[v[x, t], {x, 2}] + u[x, t] - v[x, t],
14.     u[x, 0] == 0.5 window[x] x,
15.     v[x, 0] == 0.1 window[x],
16.     Derivative[1, 0][u][-1, t] == 0,
17.     Derivative[1, 0][u][1, t] == 0,
18.     Derivative[1, 0][v][-1, t] == 0,
19.     Derivative[1, 0][v][1, t] == 0
20.     }, {u, v}, {x, -1, 1}, {t, 0, Tmax}];
21. frame[tt_] := Show[
22.    ArrayPlot[{
23.      Table[
24.       Tanh[
25.        3 Max[0, (First[(u[x, t] - v[x, t]) /. soln] /. {x -> xx,
26.             t -> tt})]]^2,
27.       {xx, -1, 1, 2/100}]}
28.     , AspectRatio -> 1, ColorFunction -> "DeepSeaColors",
29.     Frame -> False]
30.    ,
31.    Plot[
32.     Max[0, (1 + First[(u[x, t] /. soln)] /. {x -> (xx - 50)/50,
33.          t -> tt})/2]
34.     , {xx, 0, 101}, PlotRange -> {-1, 1},
35.     PlotStyle -> Directive[Thick, Red], Axes -> None],
36.    Plot[
37.     Max[0, (1 + First[(v[x, t] /. soln)] /. {x -> (xx - 50)/50,
38.          t -> tt})/2]
39.     , {xx, 0, 101}, PlotRange -> {-1, 1},
40.     PlotStyle -> Directive[Thick, Yellow]],
41.    ImageSize -> 300];
42. Manipulate[
43.  frame[Exp[tt] - 0.99],
44.  {tt, 0, 3.5}
45.  ]
RAW Paste Data
Top