Apologies, on the code given I have texted out the "C" variable. That obviously is required to run the code.
Unable to perform assignment because the size of the left side is 1 by 1 and the size of the right side is 1 by 2
2 views (last 30 days)
Show older comments
I'm trying to use the source panel method for a computaional fluid dynamics problem, but my code is giving the error stated in the title at Inorm in the embedded for loop. All of the code above "working code" is just given for context. Please help me out here.
C = 2; %Chord Length
a18 = .574; % f Plane Circle radius
TR18 = 0.18; %Thickness Ratios
epsilon18 = .0721; %Thickness parameters
k = 1.889; %Trailing edge angle parameter
theta = 0:.0001:deg2rad(360); %theta runs from 0 to 2pi in very small increments, deg2rad is a conversion
%Equations for Van de Vooren Airfoil r & theta when TR = .18
r1_18 = sqrt(((a18.*cos(theta))-a18).^2+((a18.*sin(theta))).^2);
r2_18 = sqrt(((a18.*cos(theta))-(epsilon18.*a18)).^2+(a18.*sin(theta)).^2);
theta1_18 = atan2(a18.*sin(theta),(a18.*cos(theta))-a18);
theta2_18 = atan2(a18.*sin(theta),(a18.*cos(theta))-epsilon18.*a18);
%x and z coordinates of the Van de Vooren airfoil when TR = .18
x1_18 = ((r1_18).^k)./((r2_18).^(k-1));
x2_18 = cos(k.*theta1_18).*cos((k-1).*theta2_18);
x3_18 = sin(k.*theta1_18).*sin((k-1).*theta2_18);
x18 = x1_18.*(x2_18+x3_18); %splits up the eq
z1_18 = ((r1_18).^k)./((r2_18).^(k-1));
z2_18 = sin(k.*theta1_18).*cos((k-1).*theta2_18);
z3_18 = cos(k.*theta1_18).*sin((k-1).*theta2_18);
z18 = z1_18.*(z2_18-z3_18); %splits up the eq
N = 8; % number of panels
dx = 4/N; % change in x
xp = zeros(1,N/2);
xp(1) = 0; % first xp in panel method will always be 0
xp(2) = x18(1) - dx; % 2nd xp val calc
zp = zeros(1,N+1 - N/2);
zp(1) = 0;
for i = 3:1:(N/2 + 1)
xp(i) = xp(i-1) - dx;
end
xp = [xp, flip(xp(1:N/2),2)]; % airfoil is symmetrical; flip xp variables about x-axis
% first zp will always be zero
for j = 2:(N/2 + 1)
n = xp(j);
[val1,idx] = min(abs(x18-n));
zp(j) = z18(idx);
if any(zp < 0)
idx2 = find(zp < 0);
zp(idx2) = zp(idx2)*-1;
end
end
zp = [zp,(-1).*flip(zp(1:N/2),2)]; % airfoil is symmetrical; flip zp variables about x-axis
plot(xp+1,zp)
set(gca, 'XAxisLocation', 'origin', 'YAxisLocation', 'origin');
title('Panel Method');
axis equal
zeta = zeros(N,1); % angle from Vinf to bottom of panel
eta = zeros(N,1); % angle from Vinf to outward normal of panel
conX = zeros(N,1); % X coordinates of control points
conZ = zeros(N,1); % Y coordinates of control points
s = zeros(N,1); % panel length
for i = 1:N
zeta(i) = -alpha0 + atan2((zp(i+1)-zp(i)),(xp(i+1)-xp(i)));
eta(i) = zeta(i)+pi/2;
if eta(i)>2*pi, eta(i)=eta(i)-2*pi;
elseif eta(i)<0, eta(i)=eta(i)+2*pi;
end
conX(i) = (xp(i+1)+xp(i))/2;
conZ(i) = (zp(i+1)+zp(i))/2;
s(i) = sqrt((xp(i+1)-xp(i))^2 + (zp(i+1)-zp(i))^2);
end
plot(xp+1,zp,'b',conX+1,conZ,'-rs');
set(gca, 'XAxisLocation', 'origin', 'YAxisLocation', 'origin');
axis equal;
legend('Panel Approximation','Control Points')
title('Panel Layout');
%//////////////////////////^^^working code^^^/////////
Inorm = zeros(N,N); % normal integral
Itan = zeros(N,N); % tangent integral
Vnorm = zeros(N,1); % normal velocity
jwoi = zeros(N-1,N); % j without i
for i=1:N
jwoi(:,i)=[1:i-1 i+1:N];
xi=conX(i);
zi=conZ(i);
for k = 1:N-1
j = jwoi(k,i);
xpj = xp(j); zpj = zp(j);
A(i,j) = -(xi-xpj)*cos(zeta(j))-(zi-zpj)*sin(zeta(j));
B(i,j) = (xi-xpj)^2+(zi-zpj)^2;
%C(i,j) = sin(zeta(i)-zeta(j));
D(i,j) = (zi-zpj)*cos(zeta(i))-(xi-xpj)*sin(zeta(i));
E = sqrt(B-A.^2);
sj = s(j);
Inorm(i,j) = C./2.*log((sj^2+2.*A.*sj+B)./B)+(D-A.*C)/E.*(atan2((sj+A),E)-atan2(A,E));
Itan(i,j) = (D-A.*C)./2./E.*log((sj.^2+2.*A.*sj+B)./B)-C.*(atan2((sj+A),E)-atan2(A,E));
end
Vnorm(i,1) = cos(beta(i));
end
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Earth, Ocean, and Atmospheric Sciences 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!