Skip to main content Skip to footer site map
Reza Malek-Madani

shear1

f[x_, y_] = Sinh[2 Pi y]/(Cosh[2 Pi y] - Cos[2 Pi x]);
g[x_, y_] = - Sin[2 Pi x]/(Cosh[2 Pi y] - Cos[2 Pi x]);
NumOfPoints=100;     (*Number of points on the boundary of parcels*)
(* Initial Layers*)
layers={-0.1, -0.15, -0.2, -0.25};
colors={RGBColor[1,0,0], RGBColor[0,1,0],RGBColor[0,0,1], RGBColor[0,0.5,0.5]};
tfin=1;             (*Total Time*)
interval = 0.01;       (*Time between snapshots*)
diffeqn[tfinal_,aa_,bb_]:=NDSolve[{x'[t]==f[x[t],y[t]],
                                 y'[t]==g[x[t],y[t]],
                                 x[0]==aa, y[0]==bb},
                                 {x,y}, {t,0,tfinal}, MaxSteps->10000];
Do[initdata[i]=N[Table[{w,layers[[i]]},
        {w, -2, 2, 4/NumOfPoints}]];
     oldsolution[i]=Table[diffeqn[tfin,initdata[i][[j,1]],
                           initdata[i][[j,2]]], {j, Length[initdata[i]]}];
     data[i]=Table[{x[t], y[t]} /. oldsolution[i], {t, 0, tfin, interval}];
     ColoredSnapshots[i]=Table[Graphics[{PointSize[0.005],
       {colors[[i]],
       Map[Point, Flatten[data[i][[j]],1]]}}],  {j, Length[data[i]]}],
{i,Length[layers]}]; 
Do[
    graph[i]=Table[Show[ColoredSnapshots[k][[i]],
    PlotRange->{{-2,2}, {-2,2}},
    AspectRatio->Automatic],
    {k,Length[layers]}],
{i, Length[ColoredSnapshots[1]]}];       
allplots=Table[Show[graph[i],PlotRange->{{-2,2}, {-2,2}},
          AspectRatio->Automatic],{i,Length[ColoredSnapshots[1]]}];
Export["shearlayera.gif",allplots,"GIF",ImageSize->{300,300}]
go to Top