Question: I have to use the source panel method to calculate the Cp about a given airfoil. I have done my best to follow my professors
I have to use the source panel method to calculate the Cp about a given airfoil. I have done my best to follow my professors instructions, but my Matlab code is giving me incorrect results. Can someone help me troubleshoot this code?
oad Original Airfoil Points
data loadAirfoilData.mat';
x data.unnamed:;
y data.unnamed:;
V;
alpha degrad;
Interpolate new points
ds sqrtdiffx diffy;
s ; cumsumds;
N ;
snew linspace send N ;
xnew interps x snew, 'linear';
ynew interps y snew, 'linear';
pointsxnew: ynew:;
figure;
plotx yo 'DisplayName', 'Original Airfoil';
hold on;
plotxnew, ynew, x 'DisplayName', 'Interpolated Airfoil';
legend;
xlabelx;
ylabely;
titleOriginal and Interpolated Airfoil';
grid on;
axis equal;
Control Points
xcontrol zerosN;
ycontrol zerosN;
for i :N
nextpoint modi N;
xcontrolipointsi pointsnextpoint, ;
ycontrolipointsi pointsnextpoint, ;
end
controlPoints xcontrol, ycontrol;
Plot the airfoil and control points
figure;
plotpoints: points:o 'DisplayName', 'Airfoil'; Airfoil points
hold on;
plotcontrolPoints: controlPoints:xr 'DisplayName', 'Control Points'; Control points
legend;
xlabelx;
ylabely;
titleAirfoil and Control Points';
grid on;
axis equal;
Panel Lengths
deltaS zerosN;
for i :N
nextpoint modi N;
dx pointsnextpoint, pointsi;
dy pointsnextpoint, pointsi;
deltaSi sqrtdxdy;
end
Panel Angle w respect to x axis
theta zerosN;
for i :N
nextpoint modi N;
dx pointsnextpoint, pointsi;
dy pointsnextpoint, pointsi;
thetai atandy dx;
if thetai
thetai thetaipi;
end
end
Length from control point to control point
r zerosN N;
for i :N
for j :N
dzeta controlPointsj controlPointsi;
deta controlPointsj controlPointsi;
ri j sqrtdzeta deta;
end
end
Angle between control point i and j w respect to the x axis
phi zerosN N;
for i :N
for j :N
dzeta controlPointsj controlPointsi;
deta controlPointsj controlPointsi;
phii j atandeta dzeta;
if phii j
phii j phii jpi;
end
end
end
Circulation and Normal influence coefficients
C zerosN N;
Cbar zerosN N;
for i :N
for j :N
if i ~ j
Ci jsinthetai phii j pi ri j deltaSj;
Cbari jcosthetai phii j pi ri j deltaSj;
else
Ci j;
Cbari j;
end
end
end
Source Strength
RHS zerosN;
for i :N
RHSi V sinthetai alpha;
end
A zerosN N;
for i :N
for j :N
if i j
Ai j;
else
Ai j Ci j;
end
end
end
q A RHS;
Tangential Velocity
Vt zerosN;
for i :N
Vti V costhetai alpha;
for j :N
if i ~ j
Vti Vti qj Cbari j;
end
end
end
Pressure Coefficient
Ensure Cp is computed
Cp Vt V; Vectorized computation of Cp
Plot Cp distribution
figure;
plotcontrolPoints: Cpo; Cp vs xcoordinates of control points
xlabelx Chordwise Position;
ylabelCp;
titlePressure Coefficient Distribution';
grid on;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
