User:Eas4200c.f08.wiki.d/HW4

Idealized Single Cell Airfoil
function IdealizedSingleCell

a = 4; b = 2; r = b/2; t1 = .008; t2 = .01; t3 = .01;

y = linspace(0, -r, 25);

y(26:50) = linspace(-r, 0, 25);

y(51) = a; y(52) = 0;

z = sqrt(r^2 - y(1:25).^2);

z(26:50) = -sqrt(r^2 - y(26:50).^2);

z(51) = -r; z(52) = r;

plot(y,z)

A_bar = pi/2*(b/2)^2 + .5*b*a;

ThetaG = 1/(2*A_bar)*(pi*(b/2)/t1 + a/t2 + sqrt(a^2+b^2)/t3); % *q

J = 2*A_bar/ThetaG

EDU>> IdealizedSingleCell

J =

0.1001



Rectangular 2-Cell Airfoil
function Rectangle2Cell

a = .3; b = .6; c = .4;

t1 = .003; t2 = .005; t12 = .004;

A1_bar = a*c; A2_bar = b*c;

X = 2*a/t1 + c/t1 + c/t12;

Y = 2*b/t2 + c/t2 + c/t12;

Z = -c/t12;

alpha = (A2_bar*X - A1_bar*Z)/(A1_bar*Y - A2_bar*Z);

J = (4*A1_bar^2 + 4*alpha*A1_bar*A2_bar)/(X + Z*alpha)

EDU>> Rectangle2Cell

J =

8.5507e-004

Circle Validation
function Circle(c,P_0)

R = c/2; check = 1; j = 1;

while check == 1 ns = 2*j; y = linspace(0,c,ns); for i = 1:ns z_u(i) = sqrt(R^2-(y(i)-R)^2); z_l(i) = -sqrt(R^2-(y(i)-R)^2); end

plot(y,z_u,y,z_l)

A_bar = 0; y_bar = 0; z_bar = 0; s = 0; y_u = y;   y_l = y;

for i = 1:ns-1 PQ = [0 y(ns-i)-y(ns-i+1) z_u(ns-i)-z_u(ns-i+1)]; r = [0 y(ns-i+1)-P_0(2) z_u(ns-i+1)-P_0(3)]; a = cross(r,PQ)/2; A_bar = A_bar + a;       y_bar = y_bar + (y_u(i)+y_u(i+1))/2*norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); z_bar = z_bar + (z_u(i)+z_u(i+1))/2*norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); s = s + norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); end

for i = 1:ns-1 PQ = [0 y(i+1)-y(i) z_l(i+1)-z_l(i)]; r = [0 y(i)-P_0(2) z_l(i)-P_0(3)]; a = cross(r,PQ)/2; A_bar = A_bar + a;       y_bar = y_bar + (y_l(i)+y_l(i+1))/2*norm([y_l(i+1) z_l(i+1)]-[y_l(i) z_l(i)]); z_bar = z_bar + (z_l(i)+z_l(i+1))/2*norm([y_l(i+1) z_l(i+1)]-[y_l(i) z_l(i)]); s = s + norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); end NS(j) = ns; A_BAR(j) = A_bar(1); if abs(pi*R^2-A_bar(1))/(pi*R^2)<.01 check = 0; else j = j+1; end end

y_bar = y_bar/s; z_bar = z_bar/s;

A_bar = A_BAR(j)

subplot(2,1,1), plot(y_u,z_u,y_l,z_l,y_bar,z_bar,'x'), xlabel('y'), ylabel('z'), title('NACA 2415 Airfoil')

subplot(2,1,2), plot(NS,A_BAR), xlabel('ns'), ylabel('A_b_a_r'), title('ns vs. A_b_a_r')

EDU>> Circle(1,[0 0 0])

A_bar =

0.7779



NACA 2415 Single Cell Airfoil
function Airfoil(NACA,c,P_0)

m = floor(NACA/1000)/100;

p = (floor(NACA/100)-floor(NACA/1000)*10)/10;

ta = (NACA-floor(NACA/100)*100)/100;

ts = .002;

check = 1; j = 1;

while check ==1 ns = 5*j; y = linspace(0,1,ns); for i = 1:ns if y(i)<=p z_c(i) = (m/p^2)*(2*p*y(i)-y(i)^2); theta(i) = atan((m/p^2)*(2*p-2*y(i))); else z_c(i) = (m/(1-p)^2)*((1-2*p)+2*p*y(i)-y(i)^2); theta(i) = atan((m/(1-p)^2)*(2*p-2*y(i))); end z_t(i) = 5*ta*(.2969*y(i)^.5-.1260*y(i)-.3516*y(i)^2+.2843*y(i)^3-.1015*y(i)^4); y_u(i) = (y(i) - z_t(i)*sin(theta(i)))*c; z_u(i) = (z_c(i) + z_t(i)*cos(theta(i)))*c; y_l(i) = (y(i) + z_t(i)*sin(theta(i)))*c; z_l(i) = (z_c(i) - z_t(i)*cos(theta(i)))*c; end Area = 0; y_bar = 0; z_bar = 0; s = 0; for i = 1:ns-1 PQ = [0 y_u(ns-i)-y_u(ns-i+1) z_u(ns-i)-z_u(ns-i+1)]; r = [0 y_u(ns-i+1)-P_0(2) z_u(ns-i+1)-P_0(3)]; a = cross(r,PQ)/2; Area = Area + a;       y_bar = y_bar + (y_u(i)+y_u(i+1))/2*norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); z_bar = z_bar + (z_u(i)+z_u(i+1))/2*norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); s = s + norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); end for i = 1:ns-1 PQ = [0 y_l(i+1)-y_l(i) z_l(i+1)-z_l(i)]; r = [0 y_l(i)-P_0(2) z_l(i)-P_0(3)]; a = cross(r,PQ)/2; Area = Area + a;       y_bar = y_bar + (y_l(i)+y_l(i+1))/2*norm([y_l(i+1) z_l(i+1)]-[y_l(i) z_l(i)]); z_bar = z_bar + (z_l(i)+z_l(i+1))/2*norm([y_l(i+1) z_l(i+1)]-[y_l(i) z_l(i)]); s = s + norm([y_u(i+1) z_u(i+1)]-[y_u(i) z_u(i)]); end NS(j) = ns; A_BAR(j) = Area(1); J(j) = 4*Area(1)^2*ts/s; if j ~= 1 if abs((J(j)-J(j-1))/J(j-1))*100<1 check = 0; end end j = j+1; end

y_bar = y_bar/s; z_bar = z_bar/s;

A_bar = A_BAR(j-1)

subplot(2,1,1), plot(y_u,z_u,y_l,z_l,y_bar,z_bar,'x'), xlabel('y'), ylabel('z'), title('NACA 2415 Airfoil')

subplot(2,1,2), plot(NS,J), xlabel('ns'), ylabel('Torsional Constant, J'), title('ns vs. J')



NACA 2415 3-Cell Airfoil
function Airfoil3Cell(NACA,c,P_0)

m = floor(NACA/1000)/100;

p = (floor(NACA/100)-floor(NACA/1000)*10)/10;

ta = (NACA-floor(NACA/100)*100)/100;

ts = .002; tp = .003;

check = 1; j = 1;

while check ==1 ns = 20*j; y = linspace(0,1,ns); for i = 1:ns if y(i)<=p z_c(i) = (m/p^2)*(2*p*y(i)-y(i)^2); theta(i) = atan((m/p^2)*(2*p-2*y(i))); else z_c(i) = (m/(1-p)^2)*((1-2*p)+2*p*y(i)-y(i)^2); theta(i) = atan((m/(1-p)^2)*(2*p-2*y(i))); end z_t(i) = 5*ta*(.2969*y(i)^.5-.1260*y(i)-.3516*y(i)^2+.2843*y(i)^3-.1015*y(i)^4); y_u(i) = (y(i) - z_t(i)*sin(theta(i)))*c; z_u(i) = (z_c(i) + z_t(i)*cos(theta(i)))*c; y_l(i) = (y(i) + z_t(i)*sin(theta(i)))*c; z_l(i) = (z_c(i) - z_t(i)*cos(theta(i)))*c; end for i = 1:ns if y_u(i) > c/4 P1UpperIndex = i;           break end end for i = 1:ns if y_l(i) > c/4 P1LowerIndex = i;           break end end for i = P1UpperIndex:ns if y_u(i) > 3*c/4 P2UpperIndex = i;           break end end for i = P1LowerIndex:ns if y_l(i) > 3*c/4; P2LowerIndex = i;           break end end %Cell 1 C1y = (y_u(P1UpperIndex)+y_l(P1LowerIndex))/2; for i = 1:P1UpperIndex C1y(i+1) = y_u(P1UpperIndex-i+1); end for i = 1:P1LowerIndex C1y = [C1y, y_l(i)]; end C1y = [C1y, (y_u(P1UpperIndex)+y_l(P1LowerIndex))/2]; C1z = (z_u(P1UpperIndex)+z_l(P1LowerIndex))/2; for i = 1:P1UpperIndex C1z(i+1) = z_u(P1UpperIndex-i+1); end for i = 1:P1LowerIndex C1z = [C1z, z_l(i)]; end C1z = [C1z, (z_u(P1UpperIndex)+z_l(P1LowerIndex))/2]; %Cell 2 for i = 1:P2UpperIndex-P1UpperIndex C21y(i) = y_u(P2UpperIndex-i+1); end C21y = [C21y, y_l(P1LowerIndex), y_u(P2UpperIndex); for i = 1:P2UpperIndex-P1UpperIndex C21z(i) = z_u(P2UpperIndex-i+1); end C21z = [C21z, z_l(P1LowerIndex), z_u(P2UpperIndex); for i=1:P2LowerIndex-P1LowerIndex C22y(i) = y_l(P1LowerIndex+i-1); end C22y = [C22y, y_u(P2UpperIndex), y_l(P1LowerIndex)] for i=1:P2LowerIndex-P1LowerIndex C22z(i) = z_l(P1LowerIndex+i-1); end C22z = [C22z, z_u(P2UpperIndex), z_l(P1LowerIndex)] %Cell 3 C3y = (y_u(P2UpperIndex)+y_l(P2LowerIndex))/2; for i = 1:ns-P2LowerIndex C3y(i+1) = y_l(P2LowerIndex+i-1) end for i = 1:ns-P2UpperIndex C3y'(i) = y_u(ns-i+1) end C3y = [C3y, C3y', (y_u(P2UpperIndex)+y_l(P2LowerIndex))/2]; C3z = (z_u(P2UpperIndex)+z_l(P2LowerIndex))/2; for i = 1:ns-P2LowerIndex C3z(i+1) = z_l(P2LowerIndex+i-1) end for i = 1:ns-P2UpperIndex C3z'(i) = z_u(ns-i+1) end C3z = [C3z, C3z', (z_u(P2UpperIndex)+z_l(P2LowerIndex))/2]; %Area & Torsional Constant Area1 = 0; Area21 = 0; Area22 = 0; Area3 = 0; for i = 1:size(C1y) PQ = [0 C1y(ns-i)-C1y(ns-i+1) C1z(ns-i)-C1z(ns-i+1)]; r = [0 C1y(ns-i+1)-(y_u(P1UpperIndex)+y_l(P1LowerIndex))/2 C1z(ns-i+1)-0]; a = cross(r,PQ)/2; Area1 = Area1 + a;   end for i = 1:size(C21y) PQ = [0 C21y(i+1)-C21y(i) C21z(i+1)-C21z(i)]; r = [0 C21y(i)-y_l(P1LowerIndex) C21z(i)-z_l(P1LowerIndex)]; a = cross(r,PQ)/2; Area21 = Area21 + a;   end for i = 1:size(C22y) PQ = [0 C22y(i+1)-C22y(i) C22z(i+1)-C22z(i)]; r = [0 C22y(i)-y_u(P2UpperIndex) C22z(i)-z_u(P2UpperIndex)]; a = cross(r,PQ)/2; Area22 = Area22 + a;   end for i = 1:size(C3y) PQ = [0 C3y(i+1)-C3y(i) C3z(i+1)-C3z(i)]; r = [0 C3y(i)-(y_u(P2UpperIndex)+y_l(P2LowerIndex))/2 C3z(i)-0]; a = cross(r,PQ)/2; Area3 = Area3 + a;   end NS(j) = ns; A_BAR(j) = Area(1); if j ~= 1 if abs((A_BAR(j)-A_BAR(j-1))/A_BAR(j-1))*100<.01 check = 0; end end j = j+1; end

y_bar = y_bar/s; z_bar = z_bar/s;

A_bar = A_BAR(j-1)

P1y = [y_u(P1UpperIndex) y_l(P1LowerIndex)];

P1z = [z_u(P1UpperIndex) z_l(P1LowerIndex)];

P2y = [y_u(P2UpperIndex) y_l(P2LowerIndex)];

P2z = [z_u(P2UpperIndex) z_l(P2LowerIndex)];

subplot(2,1,1), plot(y_u,z_u,y_l,z_l,y_bar,z_bar,'x',P1y,P1z,P2y,P2z), xlabel('y'), ylabel('z'), title('NACA 2415 Airfoil')

subplot(2,1,2), plot(NS,A_BAR), xlabel('ns'), ylabel('A_b_a_r'), title('ns vs. A_b_a_r')