You are on page 1of 2

MATLAB guide to plot a Half Body Potential Flow

After studying in the previous tutorial some of MATLAB capabilities to create 2D and 3D plots
we can proceed to apply some of these tools to create plots of particular body shapes formed by
combining basic potential flows. As seen in class, by combining basic potential (ideal) flows it
is possible to reproduce the flow around a cylinder, the flow over a Rankine oval or the flow of
a half body.
Cylinder:
 =    +  
 




=  1   


Rankine Oval:



!
" 

!
" 

=    + #  + #!
 

= $

%
2$
()* + 
2'
, + $  

Half Body:
.

  

=    + # 

.

  

$
= $ + 0()* 1 2
,

 

Thus, the purpose of this short guide is to help you creating the plot of one of these flows, in
this case a half body, so you can create without much trouble the plot corresponding to the flow
over a cylinder and over a Rankine oval.
The MATLAB code presented below creates streamlines of the flow of a uniform stream over a
half body. In this example U = 1 m/s, and m = 25 m2/s. But before getting to the code it is
important to notice that since we need to create the plot over all four quadrants and the second
term in the expression that describes the half body contains the inverse tangent of y/x it is
necessary to handle carefully this ratio since if x takes the value of zero the ratio becomes
infinite and the software will not be able to handle it.

Thus, to circumvent this issue we create four different meshes; two of them corresponding to
the first and fourth quadrants with x starting from 0.05 and increasing in steps of 0.05 and the
other two corresponding to the second and third quadrants with x starting at 0.05 and
decreasing in steps of 0.05. In this way we avoid having values of x = 0.

clc;
clear all;
m=25;
U = 1;
%Mesh for fourth quadrant and corresponding stream value function
[X1,Y1] = meshgrid(.05:.1:30,-30:.1:-.05);
psi1 = U*Y1 + m/(2*pi)*atan(Y1./X1);
%Mesh for first quadrant and corresponding stream value function
[X2,Y2] = meshgrid(.05:.1:30,.05:.1:30);
psi2 = U*Y2 + m/(2*pi)*atan(Y2./X2);
%Mesh for second quadrant and corresponding stream value function
[X3,Y3] = meshgrid(-30:.1:-.05,.05:.1:30);
psi3 = U*Y3 + m/(2*pi)*atan(Y3./X3);
%Mesh for third quadrant and corresponding stream value function
[X4,Y4] = meshgrid(-30:.1:-.05,-30:.1:-.05);
psi4 = U*Y4 + m/(2*pi)*atan(Y4./X4);
figure (1)
A='on';
B = 2;
C = 2.5;
contour(X1,Y1,psi1,'k','showtext',A,'textstep',B,'levelstep',C);
hold on;
contour(X2,Y2,psi2,'k','showtext',A,'textstep',B,'levelstep',C);
hold on;
contour(X3,Y3,psi3,'k','showtext',A,'textstep',B,'levelstep',C);
hold on;
contour(X4,Y4,psi4,'k','showtext',A,'textstep',B,'levelstep',C);
hold off;
xlim([-30 30]);ylim([-30 30]);
xlabel('X');ylabel('Y');
grid on;

Use this code as a reference to plot the cylinder and Rankine oval assigned for homework.

You might also like