Professional Documents
Culture Documents
IIST
l2=h*(vi+.5 *m1);
m2=(-h)*(vi+.5 *m1)*(fi+.5 *k1)/2 ;
k3=h*(ui+.5 *l2);
l3=h*(vi+.5 *m2);
m3=(-h)*(vi+.5 *m2)*(fi+.5 *k2)/2 ;
k4=h*(ui+l3);
l4=h*(vi+m3);
m4=(-h)*(vi+m3)*(fi+k3)/2 ;
fi=fi+(k1+2 *k2+2 *k3+k4)/6 ;
ui=ui+(l1+2 *l2+2 *l3+l4)/6 ;
vi=vi+(m1+2 *m2+2 *m3+m4)/6 ;
Blasius.cpp Sunday 22 May 2011 10:48:02 IST
Page 2 of 2
}
phi2=abs(ui-1 );
long double slope=(phi2-phi1)/e;
long double s1=s;
s=s-(phi1/slope);
//defining tolerance
long double tol=abs(s1-s);
if (tol<.0001 )
break ;
}
//After convergence we will get true value of s for which we will calculate solution
vi=s;
ui=u0;
fi=f0;
cout<<"0" <<" " <<fi<<" " <<ui<<" " <<vi<<endl;
for (int n=0 ;n<1001 ;n++)
{
k1=h*ui;
l1=h*vi;
m1=(-h)*(vi*fi)/2 ;
k2=h*(ui+.5 *l1);
l2=h*(vi+.5 *m1);
m2=(-h)*(vi+.5 *m1)*(fi+.5 *k1)/2 ;
k3=h*(ui+.5 *l2);
l3=h*(vi+.5 *m2);
m3=(-h)*(vi+.5 *m2)*(fi+.5 *k2)/2 ;
k4=h*(ui+l3);
l4=h*(vi+m3);
m4=(-h)*(vi+m3)*(fi+k3)/2 ;
fi=fi+(k1+2 *k2+2 *k3+k4)/6 ;
ui=ui+(l1+2 *l2+2 *l3+l4)/6 ;
vi=vi+(m1+2 *m2+2 *m3+m4)/6 ;
cout<<(n+1 )*h<<" " <<fi<<" " <<ui<<" " <<vi<<endl;
}
return 0 ;
}
Go to terminal
Go to the directory of file
Type command g++ -o Blasius Blasius.cpp and enter
Type command ./Blasius ->Blasius.dat and enter this will generate datafile i.e solution of pde
Type command gnuplot < Blasius.gnu and enter this will generate Blasius.eps file in which graph is
ploted.