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

OVD1-program

eps = 0.1; gamma = 0.123; vnu = 3.2; tfinal = 3;

vor1[xnu_,ynu_,t] = 1/ynu - vnu+ eps xnu/gamma Sin[t/gamma];
vor2[xnu_, ynu_, t_] = -eps ynu /gamma Sin[t/gamma];
vortices = 
  NDSolve[{x1'[t]==vor1[x1[t], y1[t], t], 
      y1'[t] == vor2[x1[t], y1[t], t], x1[0] == 0, y1[0]==1}, {x1, 
      y1}, {t, 0, tfinal}];
xnu[t_]:= First[x1[t] /. vortices];
ynu[t_] := First[y1[t] /. vortices];
f[x_,y_,t_] := -((y-ynu[t])/((x-xnu[t])^2+(y-ynu[t])^2)-
   (y+ynu[t])/((x-xnu[t])^2+(y+ynu[t])^2))- vnu+ 
    eps x/gamma Sin[t/gamma];
g[x_, y_, t_ ]:= (x-xnu[t])*((y-ynu[t])/((x-xnu[t])^2+(y-ynu[t])^2)-
    (y+ynu[t])/((x-xnu[t])^2+(y+ynu[t])^2))-
    eps y/gamma Sin[t/gamma];
NumOfPoints=100;     (*Number of points on the boundary of parcels*)
radius = 0.31;      (*Radius of each initial parcel*)
(* Initial Centers of individual parcels*)
centers={{0.3, 0.3},{0.9, 0.9},{1.8, 1.8}};
interval = 0.03;       (*Time between snapshots*)
diffeqn[tfin_,aa_,bb_]:=NDSolve[{x'[t]==f[x[t],y[t],t],
                                 y'[t]==g[x[t],y[t],t],
                                 x[0]==aa, y[0]==bb},
                                 {x,y}, {t,0,tfin}, MaxSteps->10000];
Do[initdata[i]=N[Table[{centers[[i,1]]+radius*Cos[w],
                        centers[[i,2]]+radius*Sin[w]},
        {w, 0, 2*Pi, 2*Pi/NumOfPoints}]];
     oldsolution[i]=Table[diffeqn[tfinal,initdata[i][[j,1]],
                           initdata[i][[j,2]]], {j, Length[initdata[i]]}];
     data[i]=Table[{x[t], y[t]} /. oldsolution[i], {t, 0, tfinal, interval}];
     ColoredSnapshots[i]=Table[Graphics[{PointSize[0.01],
     {RGBColor[1-0.2*i, 0.2*i, 0],
     Map[Point, Flatten[data[i][[j]],1]]}}],  {j, Length[data[i]]}],
{i,Length[centers]}]; 

Do[
    giffile=Show[Table[ColoredSnapshots[k][[i]],
    {k,Length[centers]}],
    PlotRange->{{-5,5}, {-3,3}},
    AspectRatio->Automatic];
    llabel=StringJoin[ToString[i],".gif"];
    Display[llabel,giffile,"GIF"],
{i, Length[ColoredSnapshots[1]]}];
go to Top