Homework 3 Solution
Homework 3 Solution
FLIGHT MECHANICS
D. R. Kirk
QUESTION 1: SAMPLE MATLAB SCRIPT
close all;
clear all;
% Question 1
a=1;
lambda=1;
[x,y]=meshgrid(-5:0.01:5,-5:0.01:5);
psi=lambda./2./pi.*atan(2.*x.*y./(x.^2-y.^2+a.^2));
V=[min(min(psi)):(max(max(psi))-min(min(psi)))/10:max(max(psi))];
cs=contour(x,y,psi,V);
% Note the use of the contour function here. To use the streamline command we could have
% found the the u and v components of the velocity, which would have added some complexity
% to this problem. Since we are only interested in sketching some of the streamlines,
% I simply plotted a constant values of psi without any regard for the exact values.
% Note that this would involve iteration to solve the resulting equation for either x or y given
% a constant value of psi.
% clabel(cs,V);
% If you uncomment the above line, MATLAB will label all the contours for
% you as well. It is a little messy so use the zooming tool to see what is 2
% really going on, especially in Quesiton #2.
QUESTION 1: STREAMLINE PLOT
• Find the stream function and plot some streamlines for the combination of a line
source, , at (x,y)=(0,a) and an equal line source located at (0,-a)
3
QUESTION 1: EXAMPLE OF LABELED CONTOURS
• Find the stream function and plot some streamlines for the combination of a line
source, , at (x,y)=(0,a) and an equal line source located at (0,-a)
4
QUESTION 2: SAMPLE MATLAB SCRIPT
% Question 2
gamma=-1;
[x,y]=meshgrid(-2.001:0.01:2.001,-2:0.01:2);
% Notice the choice on the starting and ending bounds that I have selected.
% Since the natural log of 0 is negative infinity MATLAB has problems
% plotting streamlines with this value. Therefore I selected some starting
% and ending points that eliminate the argument of the natural log from
% ever being zero.
psi=gamma./2./pi.*log(sqrt((x-a).^2+y.^2))+gamma./2./pi.*log(sqrt((x+a).^2+y.^2));
figure(2)
V=[min(min(psi)):(max(max(psi))-min(min(psi)))/20:max(max(psi))];
cs=contour(x,y,psi,V);
clabel(cs,V);
xlabel('x-direction'); ylabel('y-direction'); title('Homework #4: Question 2'); grid; 5
QUESTION 2: STREAMLINE PLOT
• Find the stream function and plot some streamlines for the combination of a
counterclockwise line vortex with strength at (x,y)=(a,0) and an equal line
vortex placed at (-a,0).
6
QUESTION 2: EXAMPLE OF LABELED CONTOURS
• Find the stream function and plot some streamlines for the combination of a
counterclockwise line vortex with strength at (x,y)=(a,0) and an equal line
vortex placed at (-a,0).
7
QUESTION 3: SAMPLE MATLAB SCRIPT, POLAR AND CARTESIAN
% Question 3 in Polar Coordinates
lambda=-1000;
gamma=1600;
[psi,r]=meshgrid(0:100:1000,0:0.01:10);
theta=(psi-gamma./2./pi.*log(r))./(lambda./2./pi);
% Note that here we were able to solve for theta explicitly, unlike either
% x or y in Question (1) or Question (2). Also, I am not sure if MATLAB can
% do contour plots in polar coordinates.
figure(3)
polar(theta,r);
title('Homework #4: Question 3, Polar Approach'); grid;
[x,y]=meshgrid(-10:0.1:10,-10:0.1:10);
psi=lambda./2./pi.*atan(y./x)+gamma./2./pi.*log(sqrt(x.^2+y.^2));
figure(4)
V=[min(min(psi)):(max(max(psi))-min(min(psi)))/20:max(max(psi))];
cs=contour(x,y,psi,V);
xlabel('x-direction'); ylabel('y-direction'); title('Homework #4: Question 3, Cartesian Approach'); grid;
8
QUESTION 3: POLAR COORDINATES
• A tornado is simulated by a line sink =-1000 m2/s plus a line vortex =1600
m2/s. Find the angle between any streamline and radial line, and show that it is
independent of both r and . If this tornado forms in sea-level standard air, what is
the local pressure and velocity 25 meters from the center of the tornado?
9
EXTRA CREDIT: LOG SPIRALS AND THE DIVINE RATIO
10
QUESTION 3: CARTESIAN COORDINATES
• A tornado is simulated by a line sink =-1000 m2/s plus a line vortex =1600
m2/s. Find the angle between any streamline and radial line, and show that it is
independent of both r and . If this tornado forms in sea-level standard air, what is
the local pressure and velocity 25 meters from the center of the tornado?
Explain what is
going on here
11
QUESTION 3: INCREASED FIDELITY
a=1;
gamma=1;
[x,y]=meshgrid(-3.001:0.01:3.001,-3:0.01:3);
psi=-3.*gamma./2./pi.*log(sqrt(x.^2+(y-a).^2))+1.*gamma./2./pi.*log(sqrt(x.^2+(y+a).^2));
V=[min(min(psi)):(max(max(psi))-min(min(psi)))/50:max(max(psi))];
figure(1)
contour(x,y,psi,V);
xlabel('x-direction'); ylabel('y-direction'); title('Homework #4: Question 4'); grid;
figure(2)
phi=3.*gamma./2./pi.*atan((y-a)./x)-1.*gamma./2./pi.*atan((y+a)./x);
Z=[min(min(phi)):(max(max(phi))-min(min(phi)))/50:max(max(phi))];
contour(x,y,psi,V);
hold on;
contour(x,y,phi,Z);
xlabel('x-direction'); ylabel('y-direction'); title('Homework #4: Question 4'); grid;
13
QUESTION 1: FINDING MINIMUM VELOCITY USING SYMBOLIC MATH
% find velocity components using MATLAB's symbolic toolbox
syms x y a gamma u v
psi=-3.*gamma./2./pi.*log(sqrt(x.^2+(y-1).^2))+1.*gamma./2./pi.*log(sqrt(x.^2+(y+1).^2));
% clear all
a=1;
gamma=1;
[x,y]=meshgrid(-3:0.05:3,-3:0.05:3);
u=-3./4.*gamma./pi./(x.^2+y.^2-2.*y+1).*(2.*y-2)+1./4.*gamma./pi./(x.^2+y.^2+2.*y+1).*(2.*y+2);
v=3./2.*gamma./pi./(x.^2+y.^2-2.*y+1).*x-1./2.*gamma./pi./(x.^2+y.^2+2.*y+1).*x;
V=sqrt(u.^2+v.^2);
Vmin=min(min(V))
loc_Vmin=find(V==Vmin);
xloc_Vmin=x(loc_Vmin);
yloc_Vmin=y(loc_Vmin);
% The following command will generate a 3-D picture of the velocity field
figure(3)
surf(x,y,V);
hold on;
plot3(xloc_Vmin,yloc_Vmin,Vmin,'.r','MarkerSize',20);
colorbar;
title('Homework #4: Question 4 Velocity Magnitude'); grid;
xlabel('x-direction'); ylabel('y-direction'); zlabel('Velocity Magnitude');
15
QUESTION 4: PLOT OF AND
16
QUESTION 4: VELOCITY MAGNITUDE (SYMBOLIC MATH)
17
QUESTION 4: MAGNITUDE AND LOCATION OF VMIN
18