forked from jte0419/Panel_Methods
-
Notifications
You must be signed in to change notification settings - Fork 0
/
STREAMLINE_VPM_N.m
69 lines (62 loc) · 3.19 KB
/
STREAMLINE_VPM_N.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [Nx,Ny] = STREAMLINE_VPM_N(XP,YP,XB,YB,phi,S,numPan,jInd)
% FUNCTION - COMPUTE NX AND NY GEOMETRIC INTEGRALS FOR VORTEX PANEL METHOD // N AIRFOILS
% Written by: JoshTheEngineer
% YouTube : www.youtube.com/joshtheengineer
% Website : www.joshtheengineer.com
%
% PURPOSE
% - Compute the geometric integral at point P due to source panels
% - Source panel strengths are constant, but can change from panel to panel
% - Geometric integral for X-direction: Nx(pj)
% - Geometric integral for Y-direction: Ny(pj)
%
% REFERENCE
% - [1]: Streamline Geometric Integral SPM, Nx(pj) and Ny(pj)
% Link: https://www.youtube.com/watch?v=BnPZjGCatcg
%
% INPUTS
% - XP : X-coordinate of computation point, P
% - YP : Y-coordinate of computation point, P
% - XB : X-coordinate of boundary points
% - YB : Y-coordinate of boundary points
% - phi : Angle between positive X-axis and interior of panel
% - S : Length of panel
% - numPan : Number of panels
% - jInd : Actual panel indices (not inter-airfoil panels)
%
% OUTPUTS
% - Nx : Value of X-direction geometric integral (Ref [1])
% - Ny : Value of Y-direction geometric integral (Ref [1])
% Initialize arrays
Nx = zeros(numPan,1); % Initialize Nx integral array
Ny = zeros(numPan,1); % Initialize Ny integral array
% Compute Nx and Ny
for j = 1:1:numPan % Loop over all panels
% Compute intermediate values
A = -(XP-XB(jInd(j)))*cos(phi(jInd(j))) - ... % A term
(YP-YB(jInd(j)))*sin(phi(jInd(j)));
B = (XP-XB(jInd(j)))^2+(YP-YB(jInd(j)))^2; % B term
Cx = sin(phi(jInd(j))); % Cx term (X-direction)
Dx = -(YP-YB(jInd(j))); % Dx term (X-direction)
Cy = -cos(phi(jInd(j))); % Cy term (Y-direction)
Dy = XP-XB(jInd(j)); % Dy term (Y-direction)
E = sqrt(B-A^2); % E term
if (~isreal(E))
E = 0;
end
% Compute Nx
term1 = 0.5*Cx*log((S(jInd(j))^2+2*A*S(jInd(j))+B)/B); % First term in Nx equation
term2 = ((Dx-A*Cx)/E)*(atan2((S(jInd(j))+A),E) - atan2(A,E)); % Second term in Nx equation
Nx(j) = term1 + term2; % Compute Nx integral
% Compute Ny
term1 = 0.5*Cy*log((S(jInd(j))^2+2*A*S(jInd(j))+B)/B); % First term in Ny equation
term2 = ((Dy-A*Cy)/E)*(atan2((S(jInd(j))+A),E) - atan2(A,E)); % Second term in Ny equation
Ny(j) = term1 + term2; % Compute Ny integral
% Zero out any NANs, INFs, or imaginary numbers
if (isnan(Nx(j)) || isinf(Nx(j)) || ~isreal(Nx(j)))
Nx(j) = 0;
end
if (isnan(Ny(j)) || isinf(Ny(j)) || ~isreal(Ny(j)))
Ny(j) = 0;
end
end