You are on page 1of 3

Blasius Solution Example

The following short code calculates the non-dimensional speed component u for
the Blasius transformation variable η. The Blasius ODE is

f ′′′ + 12 f f ′′ = 0

subject to the boundary conditions of f (0) = f ′ (0) = 0 and f ′ (∞) = 1. This


third-order ODE can be handled by the Matlab function ode45, which can solve
systems of first-order ODE of the form y ′ = f (η, y). The solution y is found by
marching from an initial value of y at η = 0 up to a maximum η.

To convert a single third-order ODE into a system of first-order ODE we can


use the following trick to define vector y.

y1 = f

y2 = f ′ = y1′

y3 = f ′′ = y2′

y4 = f ′′′ = − 21 y1 y3 = y3′

Thus writing vector y as having components [y1 , y2 , y3 ], we need to provide a


function f (η, y) that calculates [y2 , y3 , − 21 y1 y3 ].

The function ode45 takes as arguments:

• the handle of a function which defines y ′ = f (η, y),


• the initial and final integration steps for η, and
• an initial value for y.
For the first two components of y, the initial value is zero but the initial value
of the third component f ′′ is unknown. What is known is that f ′ should go to
unity as η → ∞. An initial value for the f ′′ can be found by trial and error, or
as in this example using the fsolve command to search for the initial value. As
the function f tends quickly towards unity for values of η > 5, it is reasonable
to stop ode45 at maximum η of 10.

Using fsolve a good value for the initial value of y is [0, 0, 0.328554].

function [u,eta]=blasius(y0)

% The maximum eta value to use. Should be >5.


eta_max=10;

% If an initial y0 is not provided, calculate one using the requirement

1
% that y(3)=1 at eta_max.
if (nargin==0)
[y0]=find_initial_value();
display([’f’’’’(0)=’,num2str(y0(3))]);
end
% March the initial solution y0 at eta=0 up to eta_max.
[sol]=ode45(@blasiusode,[0 eta_max],y0);
% The values of eta used by ode45
[eta]=sol.x;
% The values of f’ or y(2).
[u]=sol.y(2,:);

if (nargin==0)
clf;
plot(u,eta,’-o’);
xlabel(’u/U’);
ylabel(’\eta’);
end

% The following are nested functions to support the above code.


% The Blasius ODE
function [dy]=blasiusode(eta,y)
% It’s always a good idea to initialize arrays before use.
% eta is unused.
dy=zeros(3,1);
dy(1)=y(2);
dy(2)=y(3);
dy(3)=-0.5*y(1)*y(3);
end
% An optional function to find the best y0
function [y0]=find_initial_value()
% Suppress informational messages from fsolve. Normally, You should
% use the default options at first.
options=optimset(’fsolve’);
options=optimset(options,’Display’,’off’);
options=optimset(options,’Algorithm’,’levenberg-marquardt’);
% Solve for the best y0
y0=fsolve(@check_bc,[0;0;.3],options);
end
% The test for y0
function [F]=check_bc(y0)
[sol]=ode45(@blasiusode,[0 eta_max],y0);
F=sol.y(2,end)-1;
end
end

2
f’’(0)=0.32855

ans =

Columns 1 through 15

-0.0000 0.0002 0.0012 0.0062 0.0314 0.1570 0.3935 0.6801 0.8751

Columns 16 through 23

0.9999 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000

10

5
η

0
−0.2 0 0.2 0.4 0.6 0.8 1 1.2
u/U

You might also like