Definuj rychlostne vektorove pole

vp1[x1_,x2_]=1.0
vp2[x1_,x2_]=0.0

Zaciatocna funkcia

phi0[x1_,x2_]=Exp[-50.0*((x1-.25)^2+(x2-0.5)^2)];
Plot3D[phi0[x,y],{x,0,1},{y,0,1},PlotRange->{0,1}]
ContourPlot[phi0[x,y],{x,0,1},{y,0,1},PlotRange->{0,1}]

Parametre pre numericku metodu, zaciatocna numericka funkcia

ii=20; L = 1.0; h=L/ii;
For[i=0, i<=ii, i++, 
For[j=0,j<=ii,j++,
phi[i,j,0] = phi0[i*h,j*h]]];
i=.;j=.;
ListPlot3D[Table[phi[i,j,0],{j,0,ii},{i,0,ii}],DataRange->{{0,1},{0,1}},PlotRange->All]
ListContourPlot[Table[phi[i,j,0],{j,0,ii},{i,0,ii}],DataRange->{{0,1},{0,1}},PlotRange->All]
ListContourPlot[Table[phi[i,j,0],{j,0,ii},{i,0,ii}],DataRange->{{0,1},{0,1}},Contours->{0.0}]

Numericka metoda

T=0.5;nn=10;tau=h/1.0;
For[n=0,n<nn,n++,
{
For[i=1, i<=ii-1, i++, 
For[j=1,j<=ii-1,j++,
{
phix =(phi[i,j,n]-phi[i-1,j,n])/h,
phiy =(phi[i,j,n]-phi[i,j-1,n])/h,
phi[i,j,n+1] = phi[i,j,n] - tau*vp1[i*h,j*h]*phix - tau*vp2[i*h,j*h]*phiy
}
]
],
For[i=0, i<=ii, i++,phi[i,0,n+1]=phi[i,ii,n+1]=phi[0,i,n+1]=phi[ii,i,n+1]=0.0;],
Print[ListContourPlot[Table[phi[i,j,n+1],{j,1,ii-1},{i,1,ii-1}],DataRange->{{0,1},{0,1}}]]
}
];