You are on page 1of 12

Advanced Fluid Mechanics

Coding Assignment - 1

1. Problem Definition
To solve the partial differential equation for the Blasius Equation
1
f ' ' ' ( ) + f '' ( ) f ( )=0
2
This is the governing equation for a laminar flow past a semiinfinite flat
plate which is derived from the continuity equation and mass momentum
equation by introducing single composite dimensionless variable . In this
assignment, the approach is to solve Blasius equation numerically using
Runge-Kutta Method and Newton Raphson Method.

2. Governing Equation
Blasius found a classical approach to find the selfsimilar solution of
Prandtls problem arising from laminar flow past a semiinfinite flat plate
leads to a oneparameter family of problems involving a third order
nonlinear ordinary differential equation on the semi-infinite domain .

Fig.1 Boundary layer formation on flat plate


For laminar flow past the flat plate, the boundary layer equations given
below can be solved exactly for u and v being velocities in x and y axis
direction, assuming that the free-stream velocity U is constant (dU/dx =0).

u v

0
x y

Continuity Equation

u
u
1 dp
u
v

v
x
y
dx
y
2

u
Mass Momentum Equation

The solution was given by Blasius. With an ingenious coordinate


transformation, Blasius showed that the dimensionless velocity profile u/U
is a function only of the single composite dimensionless variable . The
value of is given by, where being kinematic viscosity.
= y

U
x

1
2

( ) Uu =f ( )
'

The substitution of the above two equations in governing equation and by


simplification, the equation becomes as below for a flow past flat plate.
1 ''
'''
f ( ) + f ( ) f ( )=0
2
This equation is a third order partial differential equation with two initial
conditions and one boundary conditions. The initial and boundary
conditions are
,
At y =0, f ( 0 ) =f ( 0 )=0

At y = , f , ( , )=1.0
As the above equation has only two initial conditions and one boundary
value, the equation can be converted into three linear single degree
partial differential equation and solved numerically using Runge-Kutta
Method and Newton Raphson Method. Newton Raphson method is used for
predicting the value of f(0).
The governing equation can be written as three ordinary differential
equation
1
f ' ' ' ( ) + f '' ( ) f ( )=0
2
Let us assume,

g()=f ' ()
h ( )=g ' ( )=f ' ' ( )
h' ( )=

so,

1
f () h ( )
2

a. Runge-Kutta Method

The RungeKutta method is an important family of implicit and explicit


iterative methods, which are used in temporal discretization for the
approximation of solutions of ordinary differential equations. The fourthorder Runge-Kutta method requires four evaluations per step h. Here k1,
k2, k3 and k4 are constants of that are being evaluated for the finding the
solution of the above three equations.
k 1=f ( x n , y n )
k
h
k 2=f x n + , y n + 1 h
2
2

k
h
k 3 =f x n + , y n + 2 h
2
2

k 4=f ( xn +h , y n +k 3 h )
h
y n+1= y n+ ( k 1+ 2 k 2 +2 k 3 +k 4 )
6
b. Newton Raphson Method

Newton's method is a method for finding successively better


approximations to the roots (or zeroes) of a real-valued function. The
method gives roots of the equation and are given by
f (x)
x i+1=x i '
f (x )
For the finding of the initial value of h(0), the above method is utilised.

3. Initial Conditions
This is a third order partial differential equation with two initial conditions
and one boundary conditions. The boundary and initial conditions are

At y =0, f ( 0 ) =f , ( 0 )=0
,
At y = , f ( , )=1.0

4. Mathematical Formulation
Blasius Equation for a flow past a flat plate is given by
1
f ' ' ' ( ) + f '' ( ) f ( )=0
2
Let us assume,

g()=f ' ()

'
''
h ( )=g ( )=f ( )

Hence, the above third order equation can be converted into the following
three linear ordinary single order differential equations.
'
f ( )=g ()

g' ( )=h ( )
h' ( )=

1
f () h ( )
2

The above three linear ordinary differential equation can be solved by RK4
method by having the initial conditions as
f ( 0 )=0
f ' ( 0 )=g (0)=0
f , ( )=g ( )=1.0
As there is no initial valve for third equation, the initial value for h is
evaluated using Newton Raphson method for the root of the equation
g ( )1.0=0
The expression for Newton Raphson is given by

10

10

10

(h ( 10 )ih ( 10 )i1)
g( i1)

h(10)i+1=h(10)i
h(0)=h(10)i+1

5. Flow Chart

6. Results
The code for solving the Blasius Equation is written in MATLAB verison
2012b. The code is executed and the result is given below. The value for
h(0) is found to be 0.332057 using Newton Raphson Method.

-------------------------------------------------------------Advanced Fluid Mechanics - Code:AM5531


Coding Assignment
Name: Dhiwakar V M
Roll No: AM15M015
Program to solve Blasius equation using RungeKutta Method(RK4)
-------------------------------------------------------------eta
f
g
h
0.000000
0.000000
0.000000
0.332057
0.100000
0.001660
0.033206
0.332048
0.200000
0.006641
0.066408
0.331984
0.300000
0.014941
0.099599
0.331809
0.400000
0.026560
0.132764
0.331470
0.500000
0.041493
0.165885
0.330911
0.600000
0.059735
0.198937
0.330079
0.700000
0.081277
0.231890
0.328922
0.800000
0.106108
0.264709
0.327389
0.900000
0.134213
0.297354
0.325433
1.000000
0.165572
0.329780
0.323007
1.100000
0.200160
0.361938
0.320072
1.200000
0.237949
0.393776
0.316589
1.300000
0.278903
0.425237
0.312529
1.400000
0.322982
0.456262
0.307865
1.500000
0.370139
0.486789
0.302581
1.600000
0.420321
0.516757
0.296663
1.700000
0.473469
0.546101
0.290112
1.800000
0.529518
0.574758
0.282931
1.900000
0.588396
0.602667
0.275136
2.000000
0.650024
0.629766
0.266752
2.100000
0.714320
0.655998
0.257809
2.200000
0.781193
0.681310
0.248351
2.300000
0.850550
0.705653
0.238426
2.400000
0.922290
0.728982
0.228092
2.500000
0.996311
0.751260
0.217412
2.600000
1.072506
0.772455
0.206455
2.700000
1.150765
0.792544
0.195294
2.800000
1.230977
0.811510
0.184007
2.900000
1.313030
0.829343
0.172669
3.000000
1.396808
0.846044
0.161360
3.100000
1.482201
0.861619
0.150155
3.200000
1.569095
0.876081
0.139128
3.300000
1.657381
0.889453
0.128347
3.400000
1.746950
0.901761
0.117876
3.500000
1.837699
0.913040
0.107773
3.600000
1.929525
0.923330
0.098086
3.700000
2.022333
0.932673
0.088859
3.800000
2.116030
0.941118
0.080126
3.900000
2.210528
0.948715
0.071912
4.000000
2.305747
0.955518
0.064234
4.100000
2.401607
0.961580
0.057103
4.200000
2.498040
0.966957
0.050520
4.300000
2.594978
0.971703
0.044480

4.400000
4.500000
4.600000
4.700000
4.800000
4.900000
5.000000
5.100000
5.200000
5.300000
5.400000
5.500000
5.600000
5.700000
5.800000
5.900000
6.000000
6.100000
6.200000
6.300000
6.400000
6.500000
6.600000
6.700000
6.800000
6.900000
7.000000
7.100000
7.200000
7.300000
7.400000
7.500000
7.600000
7.700000
7.800000
7.900000
8.000000
8.100000
8.200000
8.300000
8.400000
8.500000
8.600000
8.700000
8.800000
8.900000
9.000000
9.100000
9.200000
9.300000
9.400000

2.692361
2.790134
2.888248
2.986657
3.085321
3.184204
3.283274
3.382503
3.481868
3.581346
3.680919
3.780572
3.880291
3.980064
4.079882
4.179737
4.279621
4.379530
4.479457
4.579401
4.679357
4.779322
4.879296
4.979276
5.079260
5.179248
5.279239
5.379232
5.479227
5.579223
5.679220
5.779218
5.879217
5.979215
6.079215
6.179214
6.279214
6.379213
6.479213
6.579213
6.679213
6.779213
6.879213
6.979213
7.079213
7.179213
7.279213
7.379212
7.479212
7.579212
7.679212

0.975871
0.979514
0.982683
0.985427
0.987789
0.989815
0.991542
0.993008
0.994245
0.995286
0.996155
0.996879
0.997478
0.997971
0.998375
0.998705
0.998973
0.999189
0.999363
0.999501
0.999612
0.999699
0.999768
0.999822
0.999864
0.999896
0.999922
0.999941
0.999956
0.999967
0.999975
0.999982
0.999987
0.999990
0.999993
0.999995
0.999996
0.999997
0.999998
0.999999
0.999999
0.999999
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000
1.000000

0.038973
0.033981
0.029484
0.025457
0.021871
0.018698
0.015907
0.013465
0.011342
0.009506
0.007928
0.006579
0.005432
0.004463
0.003648
0.002968
0.002402
0.001935
0.001550
0.001236
0.000981
0.000774
0.000608
0.000475
0.000370
0.000286
0.000220
0.000169
0.000129
0.000098
0.000074
0.000055
0.000041
0.000031
0.000023
0.000017
0.000012
0.000009
0.000006
0.000005
0.000003
0.000002
0.000002
0.000001
0.000001
0.000001
0.000000
0.000000
0.000000
0.000000
0.000000

9.500000
9.600000
9.700000
9.800000
9.900000
10.000000

7.779212
7.879212
7.979212
8.079212
8.179212
8.279212

1.000000
1.000000
1.000000
1.000000
1.000000
1.000000

0.000000
0.000000
0.000000
0.000000
0.000000
0.000000

7. Appendix (MATLAB Code)


The matlab code appended below has a subroutine RK4 which calculates the
expected value at =10

clear all;
clc;
disp('-----------------------------------------------------');
disp('Advanced Fluid Mechanics - Code:AM5531');
disp('Coding Assignment ');
disp('Name: Dhiwakar V M
Roll No:
AM15M015');
disp('Program to solve Blasius equation using RungeKutta
Method(RK4)');
disp('-----------------------------------------------------');
err=10;
h1=0.1;
h2=0.2;
ci=RK4(h1,0);
cf=RK4(h2,0);
while (abs(err)>.000001)
hf=h2-(cf-1)*(h2-h1)/(cf-ci);
err=cf-1;
h1=h2;
h2=hf;

ci=cf;
cf=RK4(hf,0);
end
disp(sprintf('
eta
f
g
disp(sprintf('%10f %10f %10f %10f',0,0,0,hf));
display(RK4(hf,1));

h'));

Subroutine for Rung-Kutta Method(RK4) is given below and has to saved


in the name RK4.m in the same folder of the main program.
function C = RK4(X,P)
an(1)=0;
af(1)=0;
ag(1)=0;
ah(1)=X;
df=g;
dg=h;
dh=-0.5*f*h;
i=1;
hh=0.1;
for co=0:hh:10
kf1=ag(i);
kg1=ah(i);
kh1=-0.5*af(i)*ah(i);
kf2=(ag(i)+0.5*kg1*hh);
kg2=(ah(i)+0.5*kh1*hh);
kh2=-0.5*(af(i)+.5*kf1*hh)*(ah(i)+0.5*kh1*hh);
kf3=(ag(i)+0.5*kg2*hh);
kg3=(ah(i)+0.5*kh2*hh);
kh3=-0.5*(af(i)+.5*kf2*hh)*(ah(i)+0.5*kh2*hh);
kf4=(ag(i)+kg3*hh);
kg4=(ah(i)+kh3*hh);
kh4=-0.5*(af(i)+kf3*hh)*(ah(i)+kh3*hh);
an(i+1)=an(i)+hh;
af(i+1)=(af(i)+1/6*(kf1+2*kf2+2*kf3+kf4)*hh);
ag(i+1)=(ag(i)+1/6*(kg1+2*kg2+2*kg3+kg4)*hh);
ah(i+1)=(ah(i)+1/6*(kh1+2*kh2+2*kh3+kh4)*hh);
i=i+1;
if(P==1)
disp(sprintf('%10f %10f %10f %10f',an(i),af(i),ag(i),
ah(i)));
end
end
C = ag(i);
if(P==1)

plot(an,af,'b');
hold on
plot(an,ag,'r');
plot(an,ah,'g');
title('Solution for Blasius Equation for a Flat Plate')
xlabel('eta')
ylabel('f')
end

You might also like