Rankine Leading Edge Graph
2 views (last 30 days)
Show older comments
Roxanne Williamson
on 27 Feb 2022
Commented: William Rose
on 1 Mar 2022
m = 1;
V = 1;
disp('V m')
disp([V m])
disp('Velocity Potential:')
disp('Stream function:')
disp('psi=V*y+(m/2/pi * atan2(y,x)')
disp('The (x,y) components of velocity (u,v):')
disp('u = V + m/2pi*x/(x^2+y^2)')
disp('v = m/2pi * y/(x^2+y^2)')
xstg = -m/2/pi/V;
ystg = 0; %stagnation point locations
N = 1000;
xinf = 3;
xd = xstg:xinf/N:xinf;
for n = 1:length(xd)
if n ==1
yd(1) = 0;
else
yd(n) = m/2/V;
for it = 1:2000
yd(n) = (m/2/V)*(1-1/pi*atan2(yd(n),xd(n)));
end
end
end
xL(1) = xd(end);
yL = -yd(end);
for nn = 2:length(xd)-1
xL(nn) = xd(end-nn);
yL(nn) = -yd(end-nn);
end
plot([xd xL],[yd yL],'k',[-1 3],[0 0],'k'), axis([-1 3 -1 1])
u = V +(m/2*pi)*(xd./(xd.^2+yd.^2));
v = m/(2*pi)*(yd./(xd.^2+yd.^2));
Cp = 1 - (u.^2+v.^2)/V^2;
hold on
plot(xd,Cp); axis([-1 3 -1 1])
plot(0,m/V/4,'o')
plot(xstg,ystg,'o')
plot([1 3],[m/2/V],'--k')
[Cpmin ixd] = min(Cp);
xmin = xd(ixd);
ymin = yd(ixd);
plot(xmin,ymin,'+r')
Cpmin
phi = V*xd + (m/4/pi).*log(xd.^2+yd.^2);
dx = diff(xd);
dy = diff (yd);
ds = sqrt(dx.^2+dy);
dph = diff(phi);
ut = dph./ds;
xm = xd(1:end-1)+dx/2;
psi= V*yd + (m/2/pi).*atan2(yd,xd);
plot(xm,1-ut.^2/V^2,'r')
th = 0:pi/25:2*pi;
r = (m/2/pi/V)*(pi-th)./sin(th);
xb=r.*cos(th);
yb=r.*sin(th);
plot(xb,yb,'om')
thm = 0;
for nit = 1:1000
thm = atan2(pi-thm,pi-thm-1);
end
thdegrees = thm*180/pi;
rm=(m/2/pi/V)*(pi-thm)/sin(thm)
xm = rm*cos(thm);
ym = rm*sin(thm);
plot(xm,rm,'dk')
um = V +m/2/pi*xmin/(xmin^2+ymin^2);
vm = m/2/pi*ymin/(xmin^2+ymin^2);
Cpm = 1 - (um^2+vm^2)/V^2
title('Rankine Nose Outline')
0 Comments
Accepted Answer
William Rose
on 27 Feb 2022
What is the question?
This line is missing something:
Cp = 1 - (u.^2+v.^2)V^2;
We must add * or / or + or - or something. I choose to add "/" to keep the dimensions consistent:
Cp = 1 - (u.^2+v.^2)/V^2;
After that, I get an error at the for loop:
zd = xstg:xinf/N:xinf;
for n = 1:length(xd)...
which is fixed if I change zd to xd:
xd = xstg:xinf/N:xinf;
for n = 1:length(xd)...
Then I get a "dot indexing is not supported" error at this line
yd(n) = (m/2/V)*(1-1/pi*atan2(yd(n).xd(n)));
so I replace the . with ,
yd(n) = (m/2/V)*(1-1/pi*atan2(yd(n),xd(n)));
Then I get a lot of numbers on the console, so I add a semicolon to the end of a line
yL(nn) = -yd(end-nn)
Then I get another "dot indexing is not supported" error at line
plot(xd.Cp).axis([-1 3 -1 1])
so I change it to
plot(xd,Cp); axis([-1 3 -1 1])
The I get error "Unable to resolve the name xstf.ystg." at line
plot(xstf.ystg,'o')
so I change it to
plot(xstf,ystg,'o')
and now the error at same line is "Unrecognized function or variable 'xstf'.", so I change it again to
plot(xstg,ystg,'o')
Then it is "Unrecognized function or variable 'dx'." at line
xmin = dx(ixd);
so I change it to
xmin = xd(ixd);
Then I get error "Unrecognized function or variable 'dy'." at line
dy - diff (yd);
so I change it to
dy = diff (yd);
Then an error at line
xm = xd(1:end01)+dx/2;
so I change it to
xm = xd(1:end-1)+dx/2;
The dot indexing problem at line
psi= V*yd + (m/2/pi).*atan2(yd.xd);
so I change it to
psi= V*yd + (m/2/pi).*atan2(yd,xd);
Then "Unrecognized function or variable 'ym'." at line
plot(xm,ym,'dk')
so I change it so
plot(xm,rm,'dk')
Then the script runs to completion without error. It produces a plot and displays some results on the console. See below.
%roxanneWilliamsonCp.m
%By Roxanne Williamson with help from W. Rose
m = 1;
V = 1;
disp('V m')
disp([V m])
disp('Velocity Potential:')
disp('phi = V*x+(m/4/pi)*log(x^2+y^2)')
disp('Stream function')
disp('psi=V*y+(m/2/pi * atan2(y,x)')
disp('The (x,y) components of velocity (u,v):')
disp('u = V + m/2/pi*xc/(x^2+y^2)')
disp('v = m/2/pi * y/(x^2+y^2)')
xstg = -m/2/pi/V;
ystg = 0; %stagnation point locations
N = 1000;
xinf = 3;
xd = xstg:xinf/N:xinf;
for n = 1:length(xd)
if n ==1
yd(1) = 0;
else
yd(n) = m/2/V;
for it = 1:2000
yd(n) = (m/2/V)*(1-1/pi*atan2(yd(n),xd(n)));
end
end
end
xL(1) = xd(end);
yL = -yd(end);
for nn = 2:length(xd)-1
xL(nn) = xd(end-nn);
yL(nn) = -yd(end-nn);
end
plot([xd xL],[yd yL],'k',[-1 3],[0 0],'k'), axis([-1 3 -1 1])
u = V +m/2/pi*yd./(xd.^2+yd.^2);
v = m/2/pi*yd./(xd.^2)/V^2;
Cp = 1 - (u.^2+v.^2)/V^2;
hold on
plot(xd,Cp); axis([-1 3 -1 1])
plot(0,m/V/4,'o')
plot(xstg,ystg,'o')
plot([1 3],[m/2/V],'--k')
[Cpmin ixd] = min(Cp);
xmin = xd(ixd);
ymin = yd(ixd);
plot(xmin,ymin,'+r')
Cpmin
phi = V*xd + (m/4/pi).*log(xd.^2+yd.^2);
dx = diff(xd);
dy = diff (yd);
ds = sqrt(dx.^2+dy);
dph = diff(phi);
ut = dph./ds;
xm = xd(1:end-1)+dx/2;
psi= V*yd + (m/2/pi).*atan2(yd,xd);
plot(xm,1-ut.^2/V^2,'r')
th = 0:pi/25:2*pi;
r = (m/2/pi/V)*(pi-th)./sin(th);
xb=r.*cos(th);
yb=r.*sin(th);
plot(xb,yb,'om')
thm = 0;
for nit = 1:1000
thm = atan2(pi-thm,pi-thm-1);
end
thdegrees = thm*180/pi;
rm=(m/2/pi/V)*(pi-thm)/sin(thm)
xm = rm*cos(thm);
plot(xm,rm,'dk')
um=V+m/2/pi*xmin/(xmin^2+ymin^2);
vm = m/2/pi*ymin/(xmin^2+ymin^2);
Cpm = 1-(um^2+vm^2)/V^2
One adresses errors one at a time until there are none left. Good luck.
7 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
