0% found this document useful (0 votes)
97 views51 pages

FLUID Dynamics Assignment 1

This document contains the solutions to fluid dynamics assignment problems involving analytical and numerical solutions. [1] Analytical solutions were found for the concentration of a substance in a fluid over time using ordinary differential equations. Numerical solutions using the Euler and RK-4 methods were compared, showing RK-4 to be more accurate. [2] Eigenvalues and eigenvectors were calculated to find the analytical solution for two coupled first-order linear differential equations modeling fluid flow. [3] Tables and plots were generated to compare numerical solutions using the Euler and RK-4 methods to the analytical solution for several fluid dynamics problems. RK-4 consistently provided more accurate results. [4] Stream
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views51 pages

FLUID Dynamics Assignment 1

This document contains the solutions to fluid dynamics assignment problems involving analytical and numerical solutions. [1] Analytical solutions were found for the concentration of a substance in a fluid over time using ordinary differential equations. Numerical solutions using the Euler and RK-4 methods were compared, showing RK-4 to be more accurate. [2] Eigenvalues and eigenvectors were calculated to find the analytical solution for two coupled first-order linear differential equations modeling fluid flow. [3] Tables and plots were generated to compare numerical solutions using the Euler and RK-4 methods to the analytical solution for several fluid dynamics problems. RK-4 consistently provided more accurate results. [4] Stream
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 51

FLUID DYNAMICS

ASSIGNMENT – 1
(MCEN90008)

Kartik Nawpute – 1014961 (knawpute@student.unimelb.edu.au)


Drishti Bindra – 947227 (dbindra@student.unimelb.edu.au)
Question 1 (a)
Analytical Solution:
ⅆ𝑥 𝑥3
= −
ⅆ𝑡 4
−1 ⅆ𝑡
( 3 ) ⅆ𝑥 =
𝑥 4
Integrating both the sides
x −2 𝑡
= + 𝐶1
2 4
1 t
2
+ + c1 = 0
2x 4
To find out the constant c, substituting initial conditions i.e.
t = 0, x = 8
1
+ 0 + C1 = 0
2(8)2
−1
C1 =
128
Thus the equation becomes
1 t 1
2
+ − =0
2x 4 128
Finding x at t=0
1 32t + 1
2
=
2x 128
64 64
x2 = 𝑥 =√
32t+1 32𝑡+1

Considering the positive part only and neglecting the negative parts
Question 1 (b)

TABLE FOR QUESTION 1B

t EU RK-4
Analytical h=0.1 h=0.01 h=0.001 h=0.1 h=0.01 h=0.001

0.2 2.9408 -2.0352 2.8405 2.9313 1.857 2.9409 2.9409


0.4 2.1535 -1.6726 2.1025 2.1486 1.6013 2.1535 2.1535
0.6 1.7799 -1.4615 1.7471 1.7768 1.4286 1.78 1.78
0.8 1.5511 -1.3173 1.5274 1.5488 1.3019 1.5511 1.5511
1 1.3926 -1.2101 1.3473 1.3908 1.2039 1.3926 1.3926
EU Method

h = 0.1

h = 0.01
h = 0.001

RK-4 Method

h = 0.1
h = 0.01

h = 0.001

CONCLUSION: RK-4 method is the more accurate numerical method.


Question 1(c)

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)

TABLE FOR X-VALUES (QUESTION 1D)

t EU RK-4
Analytical h=0.1 h=0.01 h=0.001 h=0.1 h=0.01 h=0.001

0.4 -5.5776 -4.3571 -4.2325 -4.2189 -4.219 -4.219


0.8 1.0526 1.3211 1.2543 1.2434 1.2464 1.2464
1.2 10.5993 4.5675 4.1862 4.1461 4.1462 4.1462
1.6 -0.5153 -1.6757 -1.5076 -1.4286 -1.4885 -1.4885
2 -19.259 -4.771 -4.1248 -4.0596 -4.0593 -4.0593

TABLES F0R Y-VALUES (QUESTION 1D)

t EU RK-4
Analytical h=0.1 h=0.01 h=0.001 h=0.1 h=0.01 h=0.001

0.4 2.6144 1.6891 1.6377 1.6336 1.6325 1.6325


0.8 -6.8995 -4.363 -4.1216 -4.0934 -4.0953 -4.0953
1.2 -5.639 -1.5452 -1.4068 -1.3968 -1.3933 -1.3933
1.6 11.7528 4.7416 4.2305 4.1732 4.1767 4.1767
2 11.7521 1.3697 1.1681 1.1555 1.1494 1.1494

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

Red line: h = 0.1 Blue line: h = 0.01 Green Line: h = 0.001


By RK-4 Method

Blue Line = h =0.1 Green Line: h = 0.01 Red Line: h = 0.001

Note: (Red line is hidden by green line)

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,

Blue lines: source Red lines: sink


PART (B) : The stagnation points and the separatrix of the given problem is obtained at the
point where the velocity components are equal to zero. Thus, we set the values of x and y zero
one after the other in the velocity equation to find the value of stagnation point,
𝜕𝜑
𝑢=
𝜕𝑦
𝑄𝑠 𝑥 𝑄𝑒 𝑥 𝑄𝑠 𝑥 𝑄𝑒 𝑥
𝑢= ×( 2 2
)− ×( 2 2
)+ ×( 2 2
)− ×( )
2𝜋 (𝑦 − 𝑙𝑠 ) + 𝑥 2𝜋 (𝑦 − 𝑙𝑒 ) + 𝑥 2𝜋 (𝑦 + 𝑙𝑠 ) + 𝑥 2𝜋 (𝑦 + 𝑙𝑒 )2 + 𝑥 2

𝜕𝜑
𝑣=−
𝜕𝑥

𝑄𝑠 𝑦 − 𝑙𝑠 𝑄𝑒 𝑦 − 𝑙𝑒 𝑄𝑠 𝑦 + 𝑙𝑠 𝑄𝑒 𝑦 + 𝑙𝑒
𝑣= ×( 2 2
)− ×( 2 2
)+ ×( 2 2
)− ×( )
2𝜋 (𝑦 )
− 𝑙𝑠 + 𝑥 2𝜋 (𝑦 )
− 𝑙𝑒 + 𝑥 2𝜋 (𝑦 )
+ 𝑙𝑠 + 𝑥 2𝜋 (𝑦 + 𝑙𝑒 )2 + 𝑥 2

First let us put x = 0 in the equation for Y-velocity,


𝑄𝑠 2𝑦 𝑄𝑒 2𝑦
𝑣(𝑥, 𝑦) = ( 2 2 )− ( 2 )=0
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
𝑄𝑒

Now we put the value of y = 0 in the X-velocity equation,


𝑄𝑠 2𝑥 𝑄𝑒 2𝑥
𝑢(𝑥, 𝑦) = ( 2 2 )− ( 2 )=0
2𝜋 𝑥 + 𝑙𝑠 2𝜋 𝑥 + 𝑙𝑒2

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,

Blue lines: source


Red lines: sink
Black lines: separatrix
Green spots: Stagnation points

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
𝑄𝑠

By substituting Qe=4, Qs=1, Ls=2, le=3.5

The value of separatrix for this function are,

(𝑥, 𝑦) = (1.118,0)
(𝑥, 𝑦) = (0,0)
(𝑥, 𝑦) = (−1.118,0)

Blue lines: source


Red lines: sink
Black lines: separatrix
Green spots: Stagnation Points
Question 3(A)

Plot for the streamlines surrounding the four vortices

Blue Lines: Streamlines for all the vortices combined.

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)

Blue Lines: Streamlines


Black circle: Cylinder
Red Lines: Separatrix
Green spots: Stagnation points

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𝑈∞ 𝜋𝑎

To satisfy the Kutta – Jowkowski condition,

𝜃+𝛼 =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)

Applying Bernoullis’s equation for the first and final point,

𝜌𝑈∞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

𝑉4 is the magnitude of velocity in the 𝑧4 plane


To find the velocity on the surface of the aerofoil
We have,
ⅆ𝑤
𝑉4 = | |
ⅆ𝑧4
Where
ⅆ𝑤
| | 𝑖𝑠 𝑡ℎⅇ 𝑣ⅇ𝑙𝑜𝑐𝑖𝑡𝑦 𝑜𝑛 𝑡ℎⅇ 𝑠𝑢𝑟𝑓𝑎𝑐ⅇ 𝑜𝑓 𝑡ℎⅇ 𝑎ⅇ𝑟𝑜𝑓𝑜𝑖𝑙.
ⅆ𝑧4
On applying the chain rule, we get,
ⅆ𝑤 ⅆ𝑤 ⅆ𝑧 ⅆ𝑧1 ⅆ𝑧2 ⅆ𝑧3
= . . . .
ⅆ𝑧4 ⅆ𝑧 ⅆ𝑧1 ⅆ𝑧2 ⅆ𝑧3 ⅆ𝑧4

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

Pressure Distribution over an aerofoil


APPENDIX:

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)')

function dxdt = ffunc(x)


dxdt = -x^3/4;
end

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)')

function dxdt = ffunc(x)


dxdt = -x^3/4;
end
QUESTION 1(D)

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)')

function dxdt = ffunc(x,y)


dxdt = -3*x-5*y;
end
function dydt=gfunc(x,y)
dydt = 5*x+3*y;
end

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)')

function dxdt = ffunc(x,y)


dxdt = -3*x-5*y;
end
function dydt=gfunc(x,y)
dydt = 5*x+3*y;
end
RK-4 method
clear all
close all

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)')

function dxdt = ffunc(x,y)


dxdt = -3*x-5*y;
end
function dydt=gfunc(x,y)
dydt = 5*x+3*y;
end

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 [xr,yr] = streamlinefunc(xs,ys,tf,h)


for j = 1:length(xs)
t = 0:h:tf;
x(1) = xs(j);
y(1) = ys(j);
for k = 1:length(t)-1
k11 = ffunc(x(k),y(k));
k12 = gfunc(x(k),y(k));
k21 = ffunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k22 = gfunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k31 = ffunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k32 = gfunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k41 = ffunc((x(k)+h*k31),(y(k)+h*k32));
k42 = gfunc((x(k)+h*k31),(y(k)+h*k32));
x(k+1) = x(k) + h*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y(k+1) = y(k) + h*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
xr(j,:) = x ;
yr(j,:) = y ;
end
end

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

% Stagnation Points and Seperatrix

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 [xr,yr] = streamlinefunc(xs,ys,tf,h)


for j = 1:length(xs)
t = 0:h:tf;
x(1) = xs(j);
y(1) = ys(j);
for k = 1:length(t)-1
k11 = ffunc(x(k),y(k));
k12 = gfunc(x(k),y(k));
k21 = ffunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k22 = gfunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k31 = ffunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k32 = gfunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k41 = ffunc((x(k)+h*k31),(y(k)+h*k32));
k42 = gfunc((x(k)+h*k31),(y(k)+h*k32));
x(k+1) = x(k) + h*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y(k+1) = y(k) + h*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
xr(j,:) = x ;
yr(j,:) = y ;
end
end
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(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

% Stagnation Points and Seperatrix

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 [xr,yr] = streamlinefunc(xs,ys,tf,h)


for j = 1:length(xs)
t = 0:h:tf;
x(1) = xs(j);
y(1) = ys(j);
for k = 1:length(t)-1
k11 = ffunc(x(k),y(k));
k12 = gfunc(x(k),y(k));
k21 = ffunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k22 = gfunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k31 = ffunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k32 = gfunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k41 = ffunc((x(k)+h*k31),(y(k)+h*k32));
k42 = gfunc((x(k)+h*k31),(y(k)+h*k32));
x(k+1) = x(k) + h*(1/6*k11 + 1/3*(k21+k31) + 1/6*k41);
y(k+1) = y(k) + h*(1/6*k12 + 1/3*(k22+k32) + 1/6*k42);
end
xr(j,:) = x ;
yr(j,:) = y ;
end
end

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);

% U and V for the four Vortices


u1 = (-(0.9).*y1)./((2*pi).*(((x1-2).^2)+(y1.^2)));
v1 = ((0.9).*(x1-2))./((2*pi).*(((x1-2).^2)+(y1.^2)));
u2 = (-(0.9).*(y2-2))./((2*pi).*(((x2).^2)+((y2-2).^2)));
v2 = ((0.9).*(x2))./((2*pi).*(((x2).^2)+((y2-2).^2)));
u3 = (-(0.9).*y3)./((2*pi).*(((x3+2).^2)+(y3.^2)));
v3 = ((0.9).*(x3+2))./((2*pi).*(((x3+2).^2)+(y3.^2)));
u4 = (-(0.9).*(y4+2))./((2*pi).*(((x4).^2)+((y4+2).^2)));
v4 = ((0.9).*(x4))./((2*pi).*(((x4).^2)+((y4+2).^2)));
u = u1 + u2 + u3 + u4;
v = v1 + v2 + v3 + v4;

[xr1,yr1] = Vortices4(x,y,tf,h,xs,ys,u,v);

% Main RK-4 Function for Plotting


function [xr,yr] = Vortices4(x,y,tf,h,xs,ys,u,v)
h=1;
for i =1:length(h)
tf = 50;
t = 0:h:tf;
for n = 1:length(t)
if n == 1
k11 = ffunc(x,y);
k12 = gfunc(x,y);
k21 = ffunc(x+(h/2)*k11,y+(h/2)*k12);
k22 = gfunc(x+(h/2)*k11,y+(h/2)*k12);
k31 = ffunc(x+(h/2)*k21,y+(h/2)*k22);
k32 = gfunc(x+(h/2)*k21,y+(h/2)*k22);
k41 = ffunc(x+h*k31,y+h*k32);
k42 = gfunc(x+h*k31,y+h*k32);
A(n,:) = x+(k11/6+(k21+k31)/3+k41/6)*h;
B(n,:) = y+(k12/6+(k22+k32)/3+k42/6)*h;
else
x = A(n-1,:);
y = B(n-1,:);
k11 = ffunc(x,y);
k12 = gfunc(x,y);
k21 = ffunc(x+(h/2)*k11,y+(h/2)*k12);
k22 = gfunc(x+(h/2)*k11,y+(h/2)*k12);
k31 = ffunc(x+(h/2)*k21,y+(h/2)*k22);
k32 = gfunc(x+(h/2)*k21,y+(h/2)*k22);
k41 = ffunc(x+h*k31,y+h*k32);
k42 = gfunc(x+h*k31,y+h*k32);
A(n,:) = x+(k11/6+(k21+k31)/3+k41/6)*h;
B(n,:) = y+(k12/6+(k22+k32)/3+k42/6)*h;
end
xr(n,:) = A(n,:);
yr(n,:) = B(n,:);
end
figure
plot(xr(:,1),yr(:,1),'r--')
hold on
plot(xr(:,2),yr(:,2),'b--')
hold on
plot(xr(:,3),yr(:,3),'r')
hold on
plot(xr(:,4),yr(:,4),'b')
hold on
quiver(xs,ys,u,v,'k')
hold on
axis([-3 3 -3 3])
daspect([1 1 1])
grid on
xlabel('X-axis')
ylabel('Y-axis')
end
end

% Functions for Veloctities in X direction (U) for all Vortices


function Uflow1 = ffunc(x,y)
M = [1 2 3 4];
for i = 1:length(M)
for j = 1:length(M)-1
if i == j
N(i,j) = M(j+1);
else if i<j
N(i,j) = M(j+1);
else
N(i,j)= M(j);
end
end
end
end
for m = 1:length(M)
for n = 1:length(N(m,:))
tau = 0.9;
C = tau/(2*pi);
U(m,n) = (-C).*(((y(m)) - y(N(m,n)))./(((x(m)-x(N(m,n)))^2)+((y(m)-
y(N(m,n)))^2)));
end
Uf = sum(U,2);
end
Uflow1 = transpose(Uf);
end

% Velocity in Y-direction (V) for all Vortices


function Vflow1 = gfunc(x,y)
M = [1 2 3 4];
for i = 1:length(M)
for j = 1:length(M)-1
if i == j
N(i,j) = M(j+1);
else if i<j
N(i,j) = M(j+1);
else
N(i,j)= M(j);
end
end
end
end
for m = 1:length(M)
for n = 1:length(N(m,:))
tau = 0.9;
C = tau/(2*pi);
V(m,n) = (C.*(((x(m)) - x(N(m,n)))./(((x(m)-x(N(m,n)))^2)+((y(m)-
y(N(m,n)))^2))));
end
Vf = sum(V,2);
end
Vflow1 = transpose(Vf);
end

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)')

% Main RK-4 Fnction

function [xr,yr] = streamlinefunc(xs,ys)


h = 0.1;
tf = 40000;
for j = 1:length(xs)
t = 0:h:tf;
x(1) = xs(j);
y(1) = ys(j);
for k = 1:length(t)
k11 = ffunc(x(k),y(k));
k12 = gfunc(x(k),y(k));
k21 = ffunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k22 = gfunc((x(k)+h/2*k11),(y(k)+h/2*k12));
k31 = ffunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k32 = gfunc((x(k)+h/2*k21),(y(k)+h/2*k22));
k41 = ffunc((x(k)+h*k31),(y(k)+h*k32));
k42 = gfunc((x(k)+h*k31),(y(k)+h*k32));
x(k+1) = x(k) + h*(k11/6 + (k21+k31)/3 + k41/6);
y(k+1) = y(k) + h*(k12/6 + (k22+k32)/3 + k42/6);
end
plot(x,y,'k')
xlabel('X-axis');
ylabel('Y-axis');
daspect([1 1 1])
hold on
xr(j,:) = x;
yr(j,:) = y;
end
end

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

% Main body of RK-4 Function


function [zr] = streamlinefunc(zs)
h = 0.01;
tf = 20;
for j = 1:length(zs)
t = [0:h:tf];
z(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)
h = 0.01;
tf = 20;
for j = 1:length(zs)
t = 0:h:tf;
z(1) = zs(j);
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(j,:) = z;
end
end
function dwdz = zfunc(z)
Uinf = 1; a = 1; tau = pi*a*Uinf;
dwdz = -Uinf*(1-((a^2)./(z^2))) - 1i*(tau./(2*pi*z));
end
function dwdz_opp = z1func(z)
Uinf = 1; a = 1; tau = pi*a*Uinf;
dwdz_opp = Uinf*(1-((a^2)./(z^2))) + 1i*(tau./(2*pi*z));
end

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;

% Cylindrical body and streamlines


ys = -5:0.2:5;
xs(1:length(ys))= 5;
alpha = 10*pi/180 ;
zs = xs + 1i*ys;
zs1 = (exp(-1i*alpha)).*zs;
zs = zs1;
[zr] = streamlinefunc(zs,tf,h);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'b','linewidth',1)
rectangle('Position',[-1,-1,2,2],'Curvature',[1 1],'Facecolor',[0 0
0]);
axis equal
hold on
axis([-3 3 -3 3])
daspect([1 1 1])
grid on;
xlabel('X-axis'); % Label the x-axis
ylabel('Y-axis'); % Label the y-axis
title('Question 4(B)');
end

% 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;

% Jowkowski Circle plotted in Yellow


theta = 0:3.6:360;
patch(cosd(theta)+ x0,sind(theta)+ y0,'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;

% Cylinder Plot and Streamlines


ys = -5:0.2:5;
xs(1:length(ys))= 5;
zs = xs + 1i*ys;
zs1 = (exp(-1i*alpha)).*zs;
zs2 = zs1+ x0 +(1i*y0);
[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([-4 4 -3 3])
daspect([1 1 1])
hold on
xlabel('X-axis');
ylabel('Y-axis');
title(' Question 4(C)');
end
% Stagnation Point 1 and separatrix 1
stgx = -sqrt(15/16)+sin(alpha)/4+x0;
stgy = -0.2501-cos(alpha)/4+y0;
zs = stgx + 1i*stgy;
zs1 = (exp(-1i*alpha))*zs;
[zr] = streamlinefunc(zs1);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'r','linewidth',3)
hold on
end
scatter(real(zs1),imag(zs1),'g','filled');
hold on
% Stagnation point 2 and separatrix 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',3)
hold on
end
scatter(real(zs1),imag(zs1),'g','filled');
hold on
%% Main RK-4 Function
function [zr] = streamlinefunc(zs)
h = 0.01;
tf = 30;
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; tau = pi*a*Uinf;
dwdz = (-Uinf*(1-((a^2)./(z.^2))) - 1i*(tau./(2*pi.*z)));
end
function dwdz2 = z1func(z)
Uinf = 1; a = 1; tau = pi*a*Uinf;
dwdz2 = (Uinf*(1-((a^2)./(z.^2))) + 1i*(tau./(2*pi.*z)));
end

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

% Separatrix Lines and Stagnation Points


stgx = -sqrt(15/16)+sin(alpha)/4+xorig;
stgy = -0.2501-cos(alpha)/4+yorig;
zs = stgx + 1i*stgy;
zs1 = (exp(-1i*alpha))*zs;
[zr] = streamlinefunc(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

% 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;

%Plot of Streamlines and Aerofoil


ys = [-5:0.2:5];
xs(1:length(ys)) = 5;
zs = xs+ 1i*ys;
dwdz = -Uinf*(1 - (a.^2)./(zs.^2)) - 1i.*C./zs ;
[zr] = streamlinefunc(zs);
for t = 1:size(zr,1)
plot(real(zr(t,:)),imag(zr(t,:)),'b')
hold on
axis([-5 5 -3 3])
daspect([1 1 1])
xlabel('X-axis');
ylabel('Y-axis');
title('Question 4(E) - AEROFOIL ');
end

% 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

% Main Rk-4 Function


function [zr] = streamlinefunc(zs)
h = 0.01;
tf = 30;
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;
alpha = (10*pi)/180;
xorig = 0.05;
yorig = 0;
r =0.95;
z2(n) = (exp(-1i*alpha)).*z(n);
z3(n) = z2(n)+ xorig +(1i*yorig);
z4(n) = z3(n) + ((r^2)./z3(n));
z5(n) = (exp(1i*alpha)).*z4(n);
end
zr(q,:) = z5;
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;
alpha = (10*pi)/180;
xorig = 0.05;
yorig = 0;
r = 0.95;
z2(n) = (exp(-1i*alpha)).*z(n);
z3(n) = z2(n)+ xorig +(1i*yorig);
z4(n) = z3(n) + ((r^2)./z3(n));
z5(n) = (exp(1i*alpha)).*z4(n);
end
zr(q,:) = z5;
end
end
function dwdz = zfunc(z)
Uinf = 1; a = 1; alpha = (10*pi)/180;
tau = 4*Uinf*pi*a*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*Uinf*pi*a*sin(alpha);
dwdz2 = (Uinf*(1-((a^2)./(z.^2))) + 1i*(tau./(2*pi.*z)));
end

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 ;

% Using the four Transformations


z1 = exp(-1i*alphar).*z; % Rotating to the z1
z2 = z1 + xorig + (1i*yorig); % Bodily shift to z2
z3 = z2 +((r^2)./z2.^2); % Jowkowsky transformation to z3
z4 = exp(1i*alphar).*z3; % Rotating back

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)')

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy