FLUID Dynamics Assignment 1
FLUID Dynamics Assignment 1
ASSIGNMENT – 1
(MCEN90008)
Considering the positive part only and neglecting the negative parts
Question 1 (b)
t EU RK-4
Analytical h=0.1 h=0.01 h=0.001 h=0.1 h=0.01 h=0.001
h = 0.1
h = 0.01
h = 0.001
RK-4 Method
h = 0.1
h = 0.01
h = 0.001
ANALYTICAL SOLUTION:
ⅆ x −3 −5 𝑥
[y] = [ ][ ]
ⅆt 3 3 𝑦
A solution for x and y is required
Thus,
(x1 x2 ) = (𝐴𝐵)ⅇ 𝜆𝑡
−3 −5 1 0 𝐴
[ ]−𝜆[ ]( ) = 0
5 3 0 1 𝐵
−3 −5
[ ]
5 3−𝜆
A non-trivial solution (A ≠ 0 anⅆ B ≠ 0 ) requires,
−(3 + 𝜆) −9
| |
9 (3 − 𝜆)
−(9 − 𝜆2 ) + 25 = 0
𝜆2 − 9 + 25 = 0
𝜆2 = −16
𝜆 = ±4𝑖
When 𝜆 = ±4𝑖
−(3 + 4𝑖) −9 𝐴
| |( ) = 0
9 (3 − 4𝑖) 𝐵
ⅆ𝑥
𝑎 𝑏 𝑥
[ ⅆ𝑡 ] = [ ][ ]
ⅆ𝑦 𝑐 ⅆ 𝑦
ⅆ𝑡
𝑥 −3 −5 𝑥
[𝑦] = [ ][ ]
5 3 𝑦
−(−3 + 4𝑖)𝑥 − 5𝑦 = 0
5𝑦 = (−3 − 4𝑖)𝑥
(−3 − 4𝑖)𝑥
𝑦=
5
𝑥
General vector = [(−3−4𝑖)𝑥]
5
Assume x=5
5
=[ ]
−3 − 4𝑖
The general form = ⅇ 𝜆𝑡 [ⅇ𝑖𝑔ⅇ𝑛 𝑣ⅇ𝑐𝑡𝑜𝑟]
5
= ⅇ 4𝑖𝑡 [ ]
−3 − 4𝑖
5
= [𝑐𝑜𝑠4𝑡 + 𝑖𝑠𝑖𝑛4𝑡] [ ]
−3 − 4𝑖
5𝑐𝑜𝑠4𝑡 + 5𝑖𝑠𝑖𝑛4𝑡
=[ ]
−3𝑐𝑜𝑠4𝑡 − 3𝑖𝑠𝑖𝑛4𝑡 − 4𝑖𝑐𝑜𝑠4𝑡 + 4𝑠𝑖𝑛4𝑡
5𝑐𝑜𝑠4𝑡 5𝑖𝑠𝑖𝑛4𝑡
= 𝑐1 [ ] + 𝑐2 [ ]
−3𝑐𝑜𝑠4𝑡 + 4𝑠𝑖𝑛4𝑡 −3𝑖𝑠𝑖𝑛4𝑡 − 4𝑖𝑐𝑜𝑠4𝑡
5 0
= 𝑐1 [ ] − 𝑐2 [ ]
−3 4
−1 5 0
[ ] = 𝑐1 [ ] + 𝑐2 [ ]
4 −3 4
We get
−1 −17
𝑐1 = ; 𝐶2 =
5 20
−17
X = [-𝑐𝑜𝑠4𝑡 20
𝑠𝑖𝑛4𝑡]
35
Y = [-4𝑐𝑜𝑠4𝑡 𝑠𝑖𝑛4𝑡]
20
Question 1(D)
t EU RK-4
Analytical h=0.1 h=0.01 h=0.001 h=0.1 h=0.01 h=0.001
t EU RK-4
Analytical h=0.1 h=0.01 h=0.001 h=0.1 h=0.01 h=0.001
BY MATLAB:
BY EU METHOD
h = 0.1
h = 0.01
H = 0.001
BY RK-4 METHOD
h = 0.1
H=0.01
h = 0.001
Question 1(E)
Using MATLAB:
By EU Method
Question 1(f)
Question 1(G)
For starting positions (2,0), (3,0), (4,0), (5,0), (6,0), (7,0) i.e. from the inner streamline to outer
streamline
Question 2: Smoker’s Problem
PART (A) : The smoker’s problem consists of a source flow (the smokers) in a room with a
suction fan (the sink). We use method of images to ignore the values of the smoke particles in
the negative y-axis and then arrive at a combined stream function for the flow as,
𝑄𝑠 𝑦 − 𝑙𝑠 𝑄𝑠 𝑦 + 𝑙𝑠 𝑄𝑒 𝑦 − 𝑙𝑒 𝑄𝑒 𝑦 + 𝑙𝑒
𝜓(𝑥, 𝑦) = tan−1 ( )+ tan−1 ( )+ tan−1 ( )+ tan−1 ( )
2𝜋 𝑥 2𝜋 𝑥 2𝜋 𝑥 2𝜋 𝑥
The velocity components of the source and the sink are arrived at by differentiating the stream
function above in relation to the following expressions,
ⅆ𝑥 ⅆ𝜓(𝑥, 𝑦)
𝑢(𝑥, 𝑦) = =
ⅆ𝑡 ⅆ𝑦
ⅆ𝑦 ⅆ𝜓(𝑥, 𝑦)
𝑣(𝑥, 𝑦) = = −
ⅆ𝑡 ⅆ𝑥
Then, we get the streamline by setting a number of points in the CSYS to be worked in using the
following formula,
𝑥 = 𝑥𝑜 + 0.1 cos 𝑛𝜃
𝑦 = 𝑙𝑠 + 0.1 sin 𝑛𝜃
Then, define the formula for the X and Y velocity components as a variable and call the
streamline function that was used in the previous question and use RK-4 to solve the equations.
This will generate a Streamline pattern as follows,
𝜕𝜑
𝑣=−
𝜕𝑥
𝑄𝑠 𝑦 − 𝑙𝑠 𝑄𝑒 𝑦 − 𝑙𝑒 𝑄𝑠 𝑦 + 𝑙𝑠 𝑄𝑒 𝑦 + 𝑙𝑒
𝑣= ×( 2 2
)− ×( 2 2
)+ ×( 2 2
)− ×( )
2𝜋 (𝑦 )
− 𝑙𝑠 + 𝑥 2𝜋 (𝑦 )
− 𝑙𝑒 + 𝑥 2𝜋 (𝑦 )
+ 𝑙𝑠 + 𝑥 2𝜋 (𝑦 + 𝑙𝑒 )2 + 𝑥 2
Solving this equation, we get the value of y stagnation point and the negative values can be
ignored as the method of images is used to ignore all the streamlines below the ground,
𝑄
(𝑄𝑠 𝑙𝑒2 −𝑙𝑠2 )
𝑦 = ±√ 𝑒
𝑄𝑠
−1
𝑄𝑒
Since, we consider the values of X in both the left and right side of the axis we need to consider
both the positive and negative values of the stagnation point in X. The value of X-Stagnation
point is,
𝑄
𝑙𝑒2 − 𝑄𝑒 𝑙𝑠2
𝑠
𝑥 = ±√
𝑄𝑒
𝑄𝑠 − 1
Then putting in the values of the volume flux and the distance of the source and sink from the
origin in the equation for stagnation points we get the value of separatrix as,
(𝑥, 𝑦) = (4.07738,0)
(𝑥, 𝑦) = (0,0)
(𝑥, 𝑦) = (−4.07738,0)
Putting in these values we get the streamline plot with the separatrix as below,
Question 2(C)
Now, the same MATLAB code used in the previous problem can be modified to the new
value of volume flux of the sink and the streamline function of the flow will be,
𝑄
(𝑄𝑠 𝑙𝑒2 −𝑙𝑠2 )
𝑦= √ 𝑒
𝑄𝑠
𝑄𝑒 − 1
𝑄
𝑙𝑒2 − 𝑄𝑒 𝑙𝑠2
𝑠
𝑥 = ±√
𝑄𝑒
−1
𝑄𝑠
(𝑥, 𝑦) = (1.118,0)
(𝑥, 𝑦) = (0,0)
(𝑥, 𝑦) = (−1.118,0)
Question 3(B)
The vortices induce a counter-clockwise motion to each other and they start rotating in the
counter-clockwise direction.
After running the code for h=1, h=0.1, h=0.01, it was found that the convergence was reached
at h =0.1 and running the code for step size h=0.01 did not make a difference to the output.
Red dotted line: Vortex 1 (2, 0)
Blue dotted line: Vortex 2 (0, -2)
Red solid line: Vortex 3 (-2, 0)
Blue solid line: Vortex 4 (0, -2)
Question 3(C)
Question 4(A)
Question 4(B)
Question 4 (C)
Blue line : Streamlines Red line : Seperatrix Yellow circle : Jowkowski circle
Green spots : Stagnation points on the surface of the cylinder Black circle : Cylinder
Question 4(D)
The Kutta – Jowkowski condition states that, ‘A body with a sharp trailing edge which is moving
through a fluid will create about itself a circulation of sufficient strength to hold the rear stagnation
point at the trailing edge. ‘
The stagnation points on a cylinder are given by the formula below
−Γ
𝜃 = 𝑠𝑖𝑛−1 ( )
4𝑈∞ 𝜋𝑎
𝜃+𝛼 =0
Where α = angle of attack,
−Γ
𝛼 = 𝑠𝑖𝑛−1 ( )
4𝑈∞ 𝜋𝑎
Thus, the circulation needed to maintain the stagnation point at the trailing edge is given by
𝚪 = (𝟒𝑼∞ 𝝅𝒂)𝒔𝒊𝒏𝜶
Question 4(E)
Question 4(F)
𝜌𝑈∞2
𝜌𝑉42
𝑃∞ + = 𝑃4 +
2 2
This gives us,
𝜌𝑈∞2 𝜌𝑉42
𝑃4 − 𝑃∞ 2 − 2 = 1 − 𝑉4
2
𝐶𝑝 = 2 = 2 2
𝜌𝑈∞ 𝜌𝑈∞ 𝑈∞
2 2
Thus when
𝑈∞ = 1,
𝐶𝑝 = 1 − 𝑉42
We know that
1. Rotation
→ 𝑧1 = 𝑧. ⅇ −𝑖𝛼
ⅆ𝑧1
= ⅇ −𝑖𝛼
ⅆ𝑧
2. Bodily Shift
→ 𝑧2 = 𝑧1 + 𝑥0 + 𝑖𝑦0
ⅆ𝑧2
=1
ⅆ𝑧1
3. Jowkowski transformation
𝑏2
→ 𝑧3 = 𝑧2 +
𝑧2
ⅆ𝑧3 𝑏2
=1− 2
ⅆ𝑧2 𝑧2
4. Rotation
→ 𝑧4 = 𝑧3 ⅇ 𝑖𝛼
ⅆ𝑧4
= ⅇ 𝑖𝛼
ⅆ𝑧3
QUESTION 1(B)
Eu method
clear all
close all
h=0.001;
x(1)=8;
t=0:h:1;
for i=1:length(t)-1
x(i+1) = x(i)+ ffunc(x(i))*h;
end
plot(t,x);
hold on
xlabel('Time (t)')
ylabel('X-Axis (x)')
RK-4 method
clear all
close all
h=0.1;
x(1)=8;
t=0:h:8;
for i=1:length(t)-1
k1 = ffunc(x(i));
k2 = ffunc(x(i)+h*k1/2);
k3 = ffunc(x(i)+h*k2/2);
k4 = ffunc(x(i)+h*k3);
x(i+1) = x(i)+ ((k1/6)+(k2+k3)/3 + k4/6)*h;
end
disp(x);
plot(t,x);
xlabel('Time (t)')
ylabel('X-Axis (x)')
Eu method
close all
clear all
h=0.001;
x(1)=-1;
y(1)=4;
t=0:h:2;
for i=1:length(t)-1
x(i+1)=x(i)+(h*ffunc(x(i),y(i)));
y(i+1)=y(i)+(h*gfunc(x(i),y(i)));
end
%disp(x);
plot(x,y);
xlabel('X-axis (x)')
ylabel('Y-Axis (y)')
RK-4 method
clear all
close all
h=0.001;
t=0:h:2;
x(1)=-1;
y(1)=4;
for i = 1:length(t)-1
k11 = ffunc(x(i),y(i));
k12 = gfunc(x(i),y(i));
k21 = ffunc((x(i)+h/2*k11),(y(i)+h/2*k12));
k22 = gfunc((x(i)+h/2*k11),(y(i)+h/2*k12));
k31 = ffunc((x(i)+h/2*k21),(y(i)+h/2*k22));
k32 = gfunc((x(i)+h/2*k21),(y(i)+h/2*k22));
k41 = ffunc((x(i)+h*k31),(y(i)+h*k32));
k42 = gfunc((x(i)+h*k31),(y(i)+h*k32));
x(i+1) = x(i) + h*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y(i+1) = y(i) + h*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
X = -cos(4*t)-17*sin(4*t)/4 ;
Y = 35*sin(4*t)/20 + 4*cos(4*t);
figure
plot(x,y,'k');
hold on
plot(X,Y,'r:');
hold on
xlabel('X-axis (x)')
ylabel('Y-Axis (y)')
axis([-8 8 -8 8])
function dxdt=ffunc(x,y)
dxdt = -3*x-5*y;
end
function dydt=gfunc(x,y)
dydt = 5*x+3*y;
end
QUESTION 1(E)
Eu method
close all
clear all
h=0.1;
x1(1)=-1;
y1(1)=4;
t=0:h:2;
for i=1:length(t)-1
x1(i+1)=x1(i)+(h*ffunc(x1(i),y1(i)));
y1(i+1)=y1(i)+(h*gfunc(x1(i),y1(i)));
end
h=0.01;
x2(1)=-1;
y2(1)=4;
t=0:h:2;
for i=1:length(t)-1
x2(i+1)=x2(i)+(h*ffunc(x2(i),y2(i)));
y2(i+1)=y2(i)+(h*gfunc(x2(i),y2(i)));
end
h=0.001;
x3(1)=-1;
y3(1)=4;
t=0:h:2;
for i=1:length(t)-1
x3(i+1)=x3(i)+(h*ffunc(x3(i),y3(i)));
y3(i+1)=y3(i)+(h*gfunc(x3(i),y3(i)));
end
%disp(x);
plot(x1,y1,'r-');
hold on
plot(x2,y2,'b-');
hold on
plot(x3,y3,'g-');
hold on
xlabel('X-axis (x)')
ylabel('Y-Axis (y)')
h1=0.1;
x1(1)=-1;
y1(1)=4;
t=0:h1:2;
for i=1:length(t)-1
k11 = ffunc(x1(i),y1(i));
k12 = gfunc(x1(i),y1(i));
k21 = ffunc((x1(i)+h1/2*k11),(y1(i)+h1/2*k12));
k22 = gfunc((x1(i)+h1/2*k11),(y1(i)+h1/2*k12));
k31 = ffunc((x1(i)+h1/2*k21),(y1(i)+h1/2*k22));
k32 = gfunc((x1(i)+h1/2*k21),(y1(i)+h1/2*k22));
k41 = ffunc((x1(i)+h1*k31),(y1(i)+h1*k32));
k42 = gfunc((x1(i)+h1*k31),(y1(i)+h1*k32));
x1(i+1) = x1(i) + h1*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y1(i+1) = y1(i) + h1*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
h2=0.01;
x2(1)=-1;
y2(1)=4;
t=0:h2:2;
for i=1:length(t)-1
k11 = ffunc(x2(i),y2(i));
k12 = gfunc(x2(i),y2(i));
k21 = ffunc((x2(i)+h2/2*k11),(y2(i)+h2/2*k12));
k22 = gfunc((x2(i)+h2/2*k11),(y2(i)+h2/2*k12));
k31 = ffunc((x2(i)+h2/2*k21),(y2(i)+h2/2*k22));
k32 = gfunc((x2(i)+h2/2*k21),(y2(i)+h2/2*k22));
k41 = ffunc((x2(i)+h2*k31),(y2(i)+h2*k32));
k42 = gfunc((x2(i)+h2*k31),(y2(i)+h2*k32));
x2(i+1) = x2(i) + h2*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y2(i+1) = y2(i) + h2*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
h3=0.001;
x3(1)=-1;
y3(1)=4;
t=0:h3:2;
for i=1:length(t)-1
k11 = ffunc(x3(i),y3(i));
k12 = gfunc(x3(i),y3(i));
k21 = ffunc((x3(i)+h3/2*k11),(y3(i)+h3/2*k12));
k22 = gfunc((x3(i)+h3/2*k11),(y3(i)+h3/2*k12));
k31 = ffunc((x3(i)+h3/2*k21),(y3(i)+h3/2*k22));
k32 = gfunc((x3(i)+h3/2*k21),(y3(i)+h3/2*k22));
k41 = ffunc((x3(i)+h3*k31),(y3(i)+h3*k32));
k42 = gfunc((x3(i)+h3*k31),(y3(i)+h3*k32));
x3(i+1) = x3(i) + h3*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y3(i+1) = y3(i) + h3*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
figure
plot(x1,y1,'b-');
hold on
plot(x2,y2,'r-');
hold on
plot(x3,y3,'g-');
hold on
xlabel('X-axis (x)')
ylabel('Y-Axis (y)')
axis([-7 7 -6 6])
function dxdt=ffunc(x,y)
dxdt = -3*x-5*y;
end
function dydt=gfunc(x,y)
dydt = 5*x+3*y;
end
QUESTION 1(F)
close all
clear all
h=0.1;
x1(1)=-1;
y1(1)=4;
t=0:h:2;
for i=1:length(t)-1
x1(i+1)=x1(i)+(h*ffunc(x1(i),y1(i)));
y1(i+1)=y1(i)+(h*gfunc(x1(i),y1(i)));
end
h=0.01;
x2(1)=-1;
y2(1)=4;
t=0:h:2;
for i=1:length(t)-1
x2(i+1)=x2(i)+(h*ffunc(x2(i),y2(i)));
y2(i+1)=y2(i)+(h*gfunc(x2(i),y2(i)));
end
h=0.001;
x3(1)=-1;
y3(1)=4;
t=0:h:2;
for i=1:length(t)-1
x3(i+1)=x3(i)+(h*ffunc(x3(i),y3(i)));
y3(i+1)=y3(i)+(h*gfunc(x3(i),y3(i)));
end
%disp(x);
plot(x1,y1,'r-');
hold on
plot(x2,y2,'b-');
hold on
plot(x3,y3,'g-');
hold on
xlabel('X-axis (x)')
ylabel('Y-Axis (y)')
QUESTION 1(G)
clear all
close all
xs = [2 3 4 5 6 7];
ys = [0 0 0 0 0 0];
h=0.001;
t=0:h:2;
x(1)=-1;
y(1)=4;
for j = 1:length(xs)
x(1) = xs(j);
y(1) = ys(j);
for i = 1:length(t)-1
k11 = ffunc(x(i),y(i));
k12 = gfunc(x(i),y(i));
k21 = ffunc((x(i)+h/2*k11),(y(i)+h/2*k12));
k22 = gfunc((x(i)+h/2*k11),(y(i)+h/2*k12));
k31 = ffunc((x(i)+h/2*k21),(y(i)+h/2*k22));
k32 = gfunc((x(i)+h/2*k21),(y(i)+h/2*k22));
k41 = ffunc((x(i)+h*k31),(y(i)+h*k32));
k42 = gfunc((x(i)+h*k31),(y(i)+h*k32));
x(i+1) = x(i) + h*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y(i+1) = y(i) + h*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
plot (x,y);
hold on
end
X = -cos(4*t)-17*sin(4*t)/4 ;
Y = 35*sin(4*t)/20 + 4*cos(4*t);
xlabel('X-axis (x)')
ylabel('Y-Axis (y)')
daspect([1 1 1]) ;
%axis([-10 10 -15 15])
function dxdt=ffunc(x,y)
dxdt = -3*x-5*y;
end
function dydt=gfunc(x,y)
dydt = 5*x+3*y;
end
QUESTION 2(A)
close all
tf = 1000 ;
h = 0.001 ;
% Source Plot
r = 0.1;
theta = 0:10:360 ;
for k=1:length(theta)-1
xs = r*cosd(theta);
ys = 2+r*sind(theta);
end
[xr,yr] = streamlinefunc(xs,ys,tf,h) ;
for n=1:length(xs)
plot(xr(n,:),yr(n,:),'b-','linewidth',1)
hold on
end
% Sink Plot
r = 5;
theta = -18:4.5:210 ;
for k = 1:length(theta)-1
xs = r*cosd(theta) ;
ys = 3.5+r*sind(theta) ;
end
[xr,yr] = streamlinefunc(xs,ys,tf,h);
for m = 1:length(xs)
plot(xr(m,:),yr(m,:),'r','linewidth',1);
hold on;
end
daspect([1 1 1]);
xlabel('X-axis'); % Label the x-axis
ylabel('Y-axis'); % Label the y-axis
title('Flow from Smokers to Extraction fan');
function dxdt=ffunc(x,y)
le = 3.5 ; ls = 2 ; Qs = 1; Qe = 1.4;
s = sqrt(x.^2 + (y-ls)^2);
e = sqrt(x.^2 + (y-le)^2);
if s<0.05
dxdt = 0;
else
if e<0.05
dxdt = 0;
else
dxdt = (Qs/2/pi)*(x/(x^2+(y-ls)^2)+x/(x^2+(y+ls)^2)) -
(Qe/2/pi)*(x/(x^2+(y-le)^2)+x/(x^2+(y+le)^2));
end
end
end
function dydt=gfunc(x,y)
le = 3.5 ; ls = 2 ; Qs = 1; Qe = 1.4;
s = sqrt(x.^2 + (y-ls)^2);
e = sqrt(x.^2 + (y-le)^2);
if s<0.05
dydt = 0 ;
else
if e<0.05
dydt = 0;
else
dydt = (Qs/2/pi)*(((y-ls)/(x^2+(y-ls)^2))+((y+ls)/(x^2+(y+ls)^2))) -
(Qe/2/pi)*(((y-le)/(x^2+(y-le)^2))+((y+le)/(x^2+(y+le)^2)));
end
end
end
QUESTION 2(B)
close all
tf = 2000 ;
h = 0.01 ;
% Source Plot
r = 0.1;
theta = 0:10:360 ;
for k=1:length(theta)-1
xs = r*cosd(theta);
ys = 2+r*sind(theta);
end
[xr,yr] = streamlinefunc(xs,ys,tf,h) ;
for n=1:length(xs)
plot(xr(n,:),yr(n,:),'b-','linewidth',1)
hold on
end
% Sink Plot
r = 5;
theta = -22.5:4.5:210 ;
for k = 1:length(theta)-1
xs = r*cosd(theta) ;
ys = 3.5+r*sind(theta) ;
end
[xr,yr] = streamlinefunc(xs,ys,tf,h);
for m = 1:length(xs)
plot(xr(m,:),yr(m,:),'r','linewidth',1);
hold on;
end
le = 3.5 ; ls = 2 ; Qs = 1; Qe = 1.4;
stx = sqrt((le^2 - (Qe/Qs)*ls^2)/((Qe/Qs)-1));
sty = sqrt(((Qs/Qe)*le^2-ls^2)/((Qs/Qe)-1));
xs = [0.001 -0.001 -stx stx];
ys = [0 0 0.001 0.001];
[xr,yr] = streamlinefunc(xs,ys,tf,h);
for k=1:length(xs)
plot(xr(k,:),yr(k,:),'k','linewidth',3)
hold on
end
scatter(stx,sty,'filled','g')
hold on
scatter(-stx,sty,'filled','g')
daspect([1 1 1]);
xlabel('X-axis'); % Label the x-axis
ylabel('Y-axis'); % Label the y-axis
title('Flow from Smokers to Extraction fan');
function dydt=gfunc(x,y)
le = 3.5 ; ls = 2 ; Qs = 1; Qe = 1.4;
s = sqrt(x.^2 + (y-ls)^2);
e = sqrt(x.^2 + (y-le)^2);
if s<0.05
dydt = 0 ;
else
if e<0.05
dydt = 0;
else
dydt = (Qs/2/pi)*(((y-ls)/(x^2+(y-ls)^2))+((y+ls)/(x^2+(y+ls)^2))) -
(Qe/2/pi)*(((y-le)/(x^2+(y-le)^2))+((y+le)/(x^2+(y+le)^2)));
end
end
end
QUESTION 2(C)
clear all
close all
tf = 5000;
h = 0.01 ;
% Source Plot
r = 0.1;
theta = 0:12:360 ;
for k=1:length(theta)-1
xs = r*cosd(theta);
ys = 2+r*sind(theta);
end
[xr,yr] = streamlinefunc(xs,ys,tf,h) ;
for n=1:length(xs)
plot(xr(n,:),yr(n,:),'b-','linewidth',1)
hold on
end
% Sink Plot
r = 10;
theta = -18:6:200 ;
for k = 1:length(theta)-1
xs = r*cosd(theta) ;
ys = 3.5+r*sind(theta) ;
end
[xr,yr] = streamlinefunc(xs,ys,tf,h);
for m = 1:length(xs)
plot(xr(m,:),yr(m,:),'r','linewidth',1);
hold on;
end
le = 3.5 ; ls = 2 ; Qs = 1; Qe = 4;
stx = sqrt((le^2 - (Qe/Qs)*ls^2)/((Qe/Qs)-1));
sty = sqrt(((Qs/Qe)*le^2-ls^2)/((Qs/Qe)-1));
xs = [0 0 -0.001 0.001];
ys = [0.001 0.001 sty sty];
[xr,yr] = streamlinefunc(xs,ys,tf,h);
for k=1:length(xs)
plot(xr(k,:),yr(k,:),'k','linewidth',3)
hold on
end
scatter(stx,sty,'filled','g')
hold on
daspect([1 1 1]);
axis([-4 4 0 5])
xlabel('X-axis'); % Label the x-axis
ylabel('Y-axis'); % Label the y-axis
title('Flow from Smokers to Extraction fan');
function dxdt=ffunc(x,y)
le = 3.5 ; ls = 2 ; Qs = 1; Qe = 4;
s = sqrt(x.^2 + (y-ls)^2);
e = sqrt(x.^2 + (y-le)^2);
if s<0.05
dxdt = 0;
else
if e<0.05
dxdt = 0;
else
dxdt = (Qs/2/pi)*(x/(x^2+(y-ls)^2)+x/(x^2+(y+ls)^2)) -
(Qe/2/pi)*(x/(x^2+(y-le)^2)+x/(x^2+(y+le)^2));
end
end
end
function dydt=gfunc(x,y)
le = 3.5 ; ls = 2 ; Qs = 1; Qe = 4;
s = sqrt(x.^2 + (y-ls)^2);
e = sqrt(x.^2 + (y-le)^2);
if s<0.05
dydt = 0 ;
else
if e<0.05
dydt = 0;
else
dydt = (Qs/2/pi)*(((y-ls)/(x^2+(y-ls)^2))+((y+ls)/(x^2+(y+ls)^2))) -
(Qe/2/pi)*(((y-le)/(x^2+(y-le)^2))+((y+le)/(x^2+(y+le)^2)));
end
end
end
QUESTION 3(A)
clear all
close all
x = -5:1:5;
y = -5:1:5;
tf = 100;
h = 0.01;
tau = -0.9;
X = [-2 2 0 0];
Y = [0 0 2 -2];
[xr,yr] = vortexfunction(x,y,tf,h);
function [xr,yr] = vortexfunction(x,y,tf,h)
t = 0:h:tf;
for l=1:length(x)
x1(1) = x(l);
for m=1:length(y)
y1(1) = y(m);
for n=1:length(t)-1
k11 = ffunc(x1(n),y1(n));
k12 = gfunc(x1(n),y1(n));
k21 = ffunc(x1(n)+(h/2)*k11,y1(n)+(h/2)*k12);
k22 = gfunc(x1(n)+(h/2)*k11,y1(n)+(h/2)*k12);
k31 = ffunc(x1(n)+(h/2)*k21,y1(n)+(h/2)*k22);
k32 = gfunc(x1(n)+(h/2)*k21,y1(n)+(h/2)*k22);
k41 = ffunc(x1(n)+h*k31,y1(n)+h*k32);
k42 = gfunc(x1(n)+h*k31,y1(n)+h*k32);
x1(n+1) = x1(n)+((1/6)*k11+(1/3)*(k21+k31)+(1/6)*k41)*h;
y1(n+1) = y1(n)+((1/6)*k12+(1/3)*(k22+k32)+(1/6)*k42)*h;
end
plot(x1,y1,'b','linewidth',1)
xlabel('X-axis');
ylabel('Y-axis');
title('Four Vortices')
daspect([1 1 1])
axis([-8 8 -8 8])
hold on
end
end
xr(l,:) = x1;
yr(l,:) = y1;
end
function U = ffunc(x,y)
tau = -0.9;
C = tau/(2*pi);
X = [-2 2 0 0];
Y = [0 0 2 -2];
for k = 1:4
u(k) = -C.*((y-Y(k))./((x+X(k)).^2+(y-Y(k)).^2));
end
U = u(1)+u(2)+u(3)+u(4);
end
function V = gfunc(x,y)
tau = -0.9;
C = tau/(2*pi);
X = [-2 2 0 0];
Y = [0 0 2 -2];
for k = 1:4
v(k) = C.*((x+X(k))./((x+X(k)).^2+(y-Y(k)).^2));
end
V = v(1)+v(2)+v(3)+v(4);
end
QUESTION 3(B)
clear all
close all
% Plot of the Vortices (4)
syms x y x1 x2 x3 x4 y1 y2 y3 y4 h
x = [2 0 -2 0];
y = [0 2 0 -2];
h=0.01 ;
[xs,ys] = meshgrid(-8:0.1:8,-8:0.1:8);
[x1,y1] = meshgrid(-8:0.1:8,-8:0.1:8);
[x2,y2] = meshgrid(-8:0.1:8,-8:0.1:8);
[x3,y3] = meshgrid(-8:0.1:8,-8:0.1:8);
[x4,y4] = meshgrid(-8:0.1:8,-8:0.1:8);
[xr1,yr1] = Vortices4(x,y,tf,h,xs,ys,u,v);
clear all
close all
syms x y x1 x2 x3 x4 y1 y2 y3 y4
X = -20:1:-5;
X2 = 5:1:20;
Y = -20:1:-5;
Y2 = 5:1:20;
X1 = [X X X2 X2];
Y1 = [Y -Y Y2 -Y2];
[xr,yr] = streamlinefunc(X1,Y1);
% Stagnation Point and Separatrix Line
xs = [0.001 -0.001 1 -1] ;
ys = [0 0 0 0] ;
[xr,yr] = streamlinefunc(xs,ys);
for j = 1:size(xr,1)
plot(xr(j,:),yr(j,:),'r','linewidth',2);
hold on;
end
xs = [0];
ys = [30];
[xr,yr] = streamlinefunc(xs,ys);
for j = 1:size(xr,1)
plot(xr(j,:),yr(j,:),'r','linewidth',2);
hold on;
end
scatter(0,0,'go','filled');
axis([-30 30 0 30])
hold on
daspect([1 1 1])
title('Question 3(C)')
function U = ffunc(x,y)
tau = 2;
C = tau/(2*pi) ;
U = C.*(((-(y-15))./(((x-1).^2)+((y-15).^2)))+(((y+15))./(((x-
1).^2)+((y+15).^2)))+(((y-15))./(((x+1).^2)+((y-15).^2)))+((-
(y+15))./(((x+1).^2)+((y+15).^2))));
end
function V = gfunc(x,y)
tau = 2;
C = tau/(2*pi) ;
V = (C.*((((x-1))./(((x-1).^2)+((y-15).^2)))+((-(x-1))./(((x-
1).^2)+((y+15).^2)))+((-(x+1))./(((x+1).^2)+((y-
15).^2)))+(((x+1))./(((x+1).^2)+((y+15).^2)))));
end
QUESTION 4(A)
clear all
close all
% System
syms x y U a T h tf zs
% Plotting the cylinder and the streamlines
ys = -5:0.2:5;
xs(1:length(ys)) = 5;
zs = xs + 1i*ys;
[zr] = streamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'b','linewidth',0.8)
hold on
rectangle('Position',[-1,-1,2,2],'Curvature',[1 1],'Facecolor',[0 0
0]);
axis([-5 5 -3.5 3.5])
daspect([1 1 1])
xlabel('X-axis');
ylabel('Y-axis');
title('Question 4(A)');
end
% Stagnation Point 1
xs1 = -sqrt(15/16);
ys1 = -0.2501;
zs = xs1 + 1i*ys1;
[zr] = streamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'r','linewidth',1)
hold on
end
scatter(xs1,ys1,'filled','g');
hold on
%Stagnation Point 2
xs2 =sqrt(15/16);
ys2 = -0.2501;
zs = xs2 + 1i*ys2;
[zr] = oppstreamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'r','linewidth',1)
hold on
end
scatter(xs2,ys2,'filled','g');
hold on
QUESTION 4(B)
clear all
close all
% SYSTEM
syms x y U a T h tf zs
Uinf = 1; a = 1;
alpha = (10*pi)/180;
tau = pi*a*Uinf;
% Stagnation point 1
theta = pi+atan((-1/4)/-(sqrt(15/16)));
alpha = (10*pi)/180;
a = theta+alpha;
stgx = cos(a)-0.001;
stgy = sin(a)-0.001;
zs = exp(-1i*alpha)*(stgx + 1i*stgy);
[zr] = streamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'r','linewidth',1)
hold on
end
scatter(stgx,stgy,'filled','g');
hold on
%Stagnation Point 2
theta = atan((-1/4)/(sqrt(15/16)));
aplha = 10*pi/180 ;
a = theta+alpha;
stgx = cos(a)+0.001;
stgy = sin(a)+0.001;
zs = stgx + 1i*stgy;
[zr] = oppstreamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),-imag(zr(t,:)),'r','linewidth',1)
hold on
end
scatter(stgx,stgy,'filled','g');
hold on
% Main RK-4 Function
function [zr] = streamlinefunc(zs,tf,h)
h = 0.01;
tf = 20;
for j = 1:length(zs)
t = 0:h:tf;
z(1) = zs(j);
z1(1) = zs(j);
for n = 1:length(t)
k1=zfunc(z(n));
k2=zfunc(z(n)+(h/2)*k1);
k3=zfunc(z(n)+(h/2)*k2);
k4=zfunc(z(n)+h*k3);
k1c = conj(k1);
k2c = conj(k2);
k3c = conj(k3);
k4c = conj(k4);
z(n+1)=z(n)+(k1c/6+(k2c+k3c)/3+k4c/6)*h;
end
zr(j,:) = z ;
end
end
function [zr] = oppstreamlinefunc(zs,tf,h)
h = 0.01;
tf = 20;
for k = 1:length(zs)
t = 0:h:tf;
z(1) = zs(k);
for n = 1:length(t)
k1=z1func(z(n));
k2=z1func(z(n)+(h/2)*k1);
k3=z1func(z(n)+(h/2)*k2);
k4=z1func(z(n)+h*k3);
k1c = conj(k1);
k2c = conj(k2);
k3c = conj(k3);
k4c = conj(k4);
z(n+1)=z(n)+(k1c/6+(k2c+k3c)/3+k4c/6)*h;
end
zr(k,:) = z ;
end
end
function dwdz = zfunc(z)
Uinf = 1; a = 1;
alpha = (10*pi)/180;
tau = 4*pi*a*Uinf*sin(alpha);
dwdz = (-Uinf*(1-((a^2)./(z.^2))) - 1i*(tau./(2*pi.*z)));
end
function dwdz2 = z1func(z)
Uinf = 1; a = 1;
alpha = (10*pi)/180;
tau = -4*pi*a*Uinf*sin(alpha);
dwdz2 = (Uinf*(1-((a^2)./(z.^2))) + 1i*(tau./(2*pi.*z)));
end
Question 4(C)
clear all
close all
Uinf = 1; a = 1; alpha = (10*pi)/180;
tau = pi*a*Uinf;
x0 = 0.05;
y0 = 0;
for t = 1:length(theta)
r = 0.95 ;
x1(t) = r*cosd(theta(t));
y1(t) = r*sind(theta(t));
end
z1 = x1+ 1i*y1;
Question 4(D)
clear all
close all
Uinf = 1; a = 1;
alpha = (10*pi)/180;
tau = 4*pi*a*Uinf*sin(alpha);
xorig = 0.05;
yorig = 0;
% Jowkowski circle in Yellow
theta = 0:3.6:360;
patch(cosd(theta)+ xorig,sind(theta)+ yorig,'y')
hold on
for t = 1:length(theta)
r = 0.95 ;
x1(t) = r*cosd(theta(t));
y1(t) = r*sind(theta(t));
end
z1 = x1+ 1i*y1;
plot(real(z1),imag(z1),'b','linewidth',1);
hold on
% Streamlines
ys = -5:0.2:5;
xs(1:length(ys))= 5;
zs = xs + 1i*ys;
zs1 = (exp(-1i*alpha)).*zs;
zs2 = zs1+ xorig +(1i*yorig);
[zr] = streamlinefunc(zs2);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'b','linewidth',1)
hold on
rectangle('Position',[-1,-1,2,2],'Curvature',[1 1],'Facecolor',[0 0
0]);
axis equal
axis([-4 4 -3 3])
daspect([1 1 1])
xlabel('X-axis');
ylabel('Y-axis');
title('Question 4(D)');
end
% Stagnation Point 2
stgx = sqrt(15/16)+sin(alpha)/4;
stgy = -0.2501+cos(alpha)/4;
zs = stgx + 1i*stgy;
zs1 = (exp(-1i*alpha))*zs;
[zr] = oppstreamlinefunc(zs1);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'r','linewidth',2)
hold on
end
scatter(real(zs1),imag(zs1),'g','filled');
hold on
% Function for RK - 4
function [zr] = streamlinefunc(zs)
h = 0.01;
tf = 20;
for q = 1:length(zs)
t = 0:h:tf;
z(1) = zs(q);
for n = 1:length(t)
k1=zfunc(z(n));
k2 = zfunc(z(n)+(h/2)*k1);
k3 = zfunc(z(n)+(h/2)*k2);
k4 = zfunc(z(n)+h*k3);
k1c = conj(k1);
k2c = conj(k2);
k3c = conj(k3);
k4c = conj(k4);
z(n+1)=z(n)+(k1c/6+(k2c+k3c)/3+k4c/6)*h;
end
zr(q,:) = z;
end
end
function [zr] = oppstreamlinefunc(zs)
h = 0.01;
tf = 20;
for q = 1:length(zs)
t = 0:h:tf;
z(1) = zs(q);
for n = 1:length(t)
k1 = z1func(z(n));
k2 = z1func(z(n)+(h/2)*k1);
k3 = z1func(z(n)+(h/2)*k2);
k4 = z1func(z(n)+h*k3);
k1c = conj(k1);
k2c = conj(k2);
k3c = conj(k3);
k4c = conj(k4);
z(n+1)=z(n)+(k1c/6+(k2c+k3c)/3+k4c/6)*h;
end
zr(q,:) = z;
end
end
function dwdz = zfunc(z)
Uinf = 1; a = 1;
alpha = (10*pi)/180;
tau = 4*pi*a*Uinf*sin(alpha);
dwdz = (-Uinf*(1-((a^2)./(z.^2))) - 1i*(tau./(2*pi.*z)));
end
function dwdz2 = z1func(z)
Uinf = 1; a = 1;
alpha = (10*pi)/180;
tau = 4*pi*a*Uinf*sin(alpha);
dwdz2 = (Uinf*(1-((a^2)./(z.^2))) + 1i*(tau./(2*pi.*z)));
end
Question 4(E)
clear all
close all
Uinf = 1; a = 1; r = 0.95;
alpha = (10*pi)/180;
tau = 4*Uinf*pi*a*sin(alpha);
C = tau/(2*pi) ;
xorig = 0.05;
yorig = 0;
% Stagnation Point 1
stgx = -sqrt(15/16);
stgy = 0.25;
zs = stgx + 1i*stgy;
[zr] = streamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'r','linewidth',2)
hold on
scatter(real(zr(1,1)),imag(zr(1,1)),'g','filled')
hold on
end
% Stagnation Point 2
stgx = sqrt(15/16);
stgy = [0.25];
zs = stgx + 1i*stgy;
[zr] = oppstreamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'r','linewidth',2)
hold on
scatter(real(zr(1,1)),imag(zr(1,1)),'g','filled')
hold on
end
% Aerofoil
theta = 0:pi/50:2*pi;
for t = 1:length(theta)
x2(t) = cos(theta(t));
y2(t) = sin(theta(t));
end
z1 = x2+1i*y2;
z2 = (exp(-1i*alpha)).*z1;
z3 = z2 + xorig+1i*yorig;
z4 = z3 +((r^2)./z3);
z5 = (exp(1i*alpha)).*z4;
zs = z5;
fill (real(zs),imag(zs),'k')
hold on
Question 4(F)
clear all
close all
Uinf = 1; a = 1; r = 0.95;
alphad = 10 ; alphar = pi/18;
xorig = a - r; yorig = 0;
theta = 0 : 1.8 : 360;
thetar = 0 : pi/100 : 2*pi;
x = a.*cos(thetar) ;
y = a.*sin(thetar) ;
z = x + 1i.*y ; % Original Plane
tau = 4*Uinf*pi*a*sin(alphar);
C = tau/(2*pi) ;
dwdz = -Uinf*(1 - (a.^2)./(z.^2)) - 1i.*C./z ;
dz23 = 1 - (r.^2)./(z2.^2) ;
dwz4 = dwdz./(dz23);
V4 = abs(dwz4) ;
Cp = 1 - ((V4).^2) ;
plot(real(z4),Cp,'k','linewidth',1);
axis([-3 3 -16 2])
daspect([1 1 1])
xlabel('X4');
ylabel('Coefficient of Pressure (Cp)');
title('Question 4(F)')