-
Notifications
You must be signed in to change notification settings - Fork 0
/
COMPUTE_KL_VPM.m
64 lines (55 loc) · 3.11 KB
/
COMPUTE_KL_VPM.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
function [K,L] = COMPUTE_KL_VPM(XC,YC,XB,YB,phi,S)
% FUNCTION - COMPUTE K AND L GEOMETRIC INTEGRALS FOR VORTEX PANEL METHOD
% PURPOSE
% - Compute the integral expression for constant strength vortex panels
% - Vortex panel strengths are constant, but can change from panel to panel
% - Geometric integral for panel-normal : K(ij)
% - Geometric integral for panel-tangential: L(ij)
% INPUTS
% - XC : X-coordinate of control points
% - YC : Y-coordinate of control points
% - 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
%
% OUTPUTS
% - K : Value of panel-normal integral (Ref [1])
% - L : Value of panel-tangential integral (Ref [2])
% Number of panels
numPan = length(XC); % Number of panels
% Initialize arrays
K = zeros(numPan,numPan); % Initialize K integral matrix
L = zeros(numPan,numPan); % Initialize L integral matrix
% Compute integral
for i = 1:1:numPan % Loop over i panels
for j = 1:1:numPan % Loop over j panels
if (j ~= i) % If panel j is not the same as panel i
A = -(XC(i)-XB(j))*cos(phi(j))-(YC(i)-YB(j))*sin(phi(j)); % A term
B = (XC(i)-XB(j))^2+(YC(i)-YB(j))^2; % B term
Cn = -cos(phi(i)-phi(j)); % C term (normal)
Dn = (XC(i)-XB(j))*cos(phi(i))+(YC(i)-YB(j))*sin(phi(i)); % D term (normal)
Ct = sin(phi(j)-phi(i)); % C term (tangential)
Dt = (XC(i)-XB(j))*sin(phi(i))-(YC(i)-YB(j))*cos(phi(i)); % D term (tangential)
E = sqrt(B-A^2); % E term
if (~isreal(E))
E = 0;
end
% Compute K
term1 = 0.5*Cn*log((S(j)^2+2*A*S(j)+B)/B); % First term in K equation
term2 = ((Dn-A*Cn)/E)*(atan2((S(j)+A),E)-atan2(A,E)); % Second term in K equation
K(i,j) = term1 + term2; % Compute K integral
% Compute L
term1 = 0.5*Ct*log((S(j)^2+2*A*S(j)+B)/B); % First term in L equation
term2 = ((Dt-A*Ct)/E)*(atan2((S(j)+A),E)-atan2(A,E)); % Second term in L equation
L(i,j) = term1 + term2; % Compute L integral
end
% Zero out any NANs, INFs, or imaginary numbers
if (isnan(K(i,j)) || isinf(K(i,j)) || ~isreal(K(i,j)))
K(i,j) = 0;
end
if (isnan(L(i,j)) || isinf(L(i,j)) || ~isreal(L(i,j)))
L(i,j) = 0;
end
end
end