├── Panel method Kuethe and Chow-Foundations-of-Aerodynamics.pdf ├── README.md ├── Vortex_Panel_Method.m └── naca0012_160cos.txt /Panel method Kuethe and Chow-Foundations-of-Aerodynamics.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dpkprm/Vortex-Panel-Method/c429bce27410569eb63f9fbd71184654d5a59ae1/Panel method Kuethe and Chow-Foundations-of-Aerodynamics.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vortex-Panel-Method 2 | A MATLAB code to calculate the potential flow around an arbitrary airfoil 3 | The code is based on the theory from from Kuethe and Chow - "Foundations-of-Aerodynamics". The code needs an input file containing the coordinates of the airfoil. 4 | This can be obtained from Airfoil Tools or other sources. 5 | Make sure that the cooridinates are sorted as follows, trailing edge -> lower surface -> leading edge -> upper surface -> trailing edge. 6 | -------------------------------------------------------------------------------- /Vortex_Panel_Method.m: -------------------------------------------------------------------------------- 1 | 2 | %% Data Acquisition and Re-arranging 3 | data = load('naca2410_160cos.txt'); %Load Airfoil Coordianted from http://airfoiltools.com/airfoil/naca4digit 4 | XB = flip(data(:,1)); 5 | YB = flip(data(:,2)); 6 | YB(1,1) = 0; 7 | YB(end,1) = 0; 8 | 9 | M = size(XB,1); 10 | 11 | z = 1; 12 | %% Calculation of control points and other geometric parameters 13 | alpha = 0; 14 | alpha = (alpha) * (pi/180); 15 | 16 | for i = 1:M-1 17 | X(i,1) = 0.5*( XB(i) + XB(i+1) ); 18 | Y(i,1) = 0.5*( YB(i) + YB(i+1) ); 19 | S(i,1) = sqrt( (XB(i+1)-XB(i))^2 + (YB(i+1)-YB(i))^2 ); 20 | theta(i,1) = atan2( (YB(i+1)-YB(i)) , (XB(i+1)-XB(i)) ); 21 | RHS(i,1) = sin(theta(i) - alpha); 22 | end 23 | 24 | %% Calculation of Coefficients 25 | 26 | for i = 1:M-1 27 | for j = 1:M-1 28 | if (i == j) 29 | CN1(i,j) = -1; 30 | CN2(i,j) = 1 ; 31 | CT1(i,j) = 0.5*pi; 32 | CT2(i,j) = 0.5*pi; 33 | else 34 | A = - (X(i) - XB(j))*(cos(theta(j))) - (Y(i) - YB(j))*(sin(theta(j))); 35 | B = (X(i) - XB(j))^2 + (Y(i) - YB(j))^2; 36 | C = sin(theta(i) - theta(j)); 37 | D = cos(theta(i) - theta(j)); 38 | E = (X(i) - XB(j))*sin(theta(j)) - (Y(i) - YB(j))*cos(theta(j)); 39 | F = log(1 + ((S(j))^2 + (2*A*S(j))) / B); 40 | G = atan2((E*S(j)) , (B + A*S(j))); 41 | P = ((X(i) - XB(j)) * sin(theta(i) - 2*theta(j))) + ((Y(i) - YB(j)) * cos(theta(i) - 2*theta(j))); 42 | Q = ((X(i) - XB(j)) * cos(theta(i) - 2*theta(j))) - ((Y(i) - YB(j)) * sin(theta(i) - 2*theta(j))); 43 | 44 | CN2(i,j) = D + ((0.5*Q*F)/S(j)) - ((A*C + D*E)*(G/S(j))); 45 | CN1(i,j) = 0.5*D*F + C*G - CN2(i,j); 46 | CT2(i,j) = C + ((0.5*P*F)/S(j)) + ((A*D - C*E)*(G/S(j))); 47 | CT1(i,j) = 0.5*C*F - D*G - CT2(i,j); 48 | end 49 | end 50 | end 51 | 52 | %% Computation of Influence Coefficients 53 | for i = 1:M-1 54 | AN(i,1) = CN1(i,1); 55 | AN(i,M) = CN2(1,M-1); 56 | AT(i,1) = CT1(i,1); 57 | AT(i,M) = CT2(i,M-1); 58 | for j = 2:M-1 59 | AN(i,j) = CN1(i,j) + CN2(i,j-1); 60 | AT(i,j) = CT1(i,j) + CT2(i,j-1); 61 | end 62 | end 63 | AN(M,1) = 1; 64 | AN(M,M) = 1; 65 | for j = 2:M-1 66 | AN(M,j) = 0; 67 | end 68 | RHS(M) = 0; 69 | 70 | %% Solve for Gamma and velocity/pressure 71 | Gama = AN\RHS; % Solving for a syetem of linear equations 72 | 73 | for i = 1:M-1 74 | V(i) = cos(theta(i)-alpha); 75 | for j = 1:M 76 | V(i) = V(i) + AT(i,j)*Gama(j); 77 | CP(i) = 1 - (V(i))^2; 78 | end 79 | end 80 | 81 | figure(1) 82 | plot(X,CP); 83 | set(gca,'Ydir','reverse'); 84 | xlabel('x/c'); 85 | ylabel('Coefficient of Pressure'); 86 | grid on; 87 | grid minor; 88 | 89 | %% Calculation of Lift Coefficient 90 | 91 | CPl = CP(1:((M-1)/2)); 92 | CPl = flip(CPl); 93 | CPu = CP((((M-1)/2)+1):end); 94 | 95 | dCP = CPl - CPu; 96 | dx = X((((M-1)/2)+1):end); 97 | 98 | Cl(z) = trapz(dx,dCP); 99 | z = z+1; -------------------------------------------------------------------------------- /naca0012_160cos.txt: -------------------------------------------------------------------------------- 1 | 1.000000 0.001260 2 | 0.999615 0.001314 3 | 0.998459 0.001476 4 | 0.996534 0.001745 5 | 0.993844 0.002120 6 | 0.990393 0.002600 7 | 0.986185 0.003182 8 | 0.981228 0.003864 9 | 0.975528 0.004642 10 | 0.969096 0.005515 11 | 0.961940 0.006478 12 | 0.954072 0.007527 13 | 0.945503 0.008658 14 | 0.936248 0.009867 15 | 0.926320 0.011149 16 | 0.915735 0.012500 17 | 0.904508 0.013914 18 | 0.892658 0.015387 19 | 0.880203 0.016914 20 | 0.867161 0.018489 21 | 0.853553 0.020107 22 | 0.839400 0.021763 23 | 0.824724 0.023452 24 | 0.809547 0.025168 25 | 0.793893 0.026905 26 | 0.777785 0.028659 27 | 0.761249 0.030423 28 | 0.744311 0.032193 29 | 0.726995 0.033962 30 | 0.709330 0.035725 31 | 0.691342 0.037476 32 | 0.673059 0.039209 33 | 0.654508 0.040917 34 | 0.635720 0.042596 35 | 0.616723 0.044237 36 | 0.597545 0.045835 37 | 0.578217 0.047383 38 | 0.558769 0.048874 39 | 0.539230 0.050302 40 | 0.519630 0.051660 41 | 0.500000 0.052940 42 | 0.480370 0.054136 43 | 0.460770 0.055241 44 | 0.441231 0.056247 45 | 0.421783 0.057148 46 | 0.402455 0.057938 47 | 0.383277 0.058609 48 | 0.364280 0.059157 49 | 0.345492 0.059575 50 | 0.326941 0.059857 51 | 0.308658 0.060000 52 | 0.290670 0.059998 53 | 0.273005 0.059848 54 | 0.255689 0.059547 55 | 0.238751 0.059092 56 | 0.222215 0.058481 57 | 0.206107 0.057714 58 | 0.190453 0.056790 59 | 0.175276 0.055709 60 | 0.160600 0.054473 61 | 0.146447 0.053083 62 | 0.132839 0.051542 63 | 0.119797 0.049854 64 | 0.107342 0.048021 65 | 0.095492 0.046049 66 | 0.084265 0.043942 67 | 0.073680 0.041705 68 | 0.063752 0.039345 69 | 0.054497 0.036867 70 | 0.045928 0.034276 71 | 0.038060 0.031580 72 | 0.030904 0.028783 73 | 0.024472 0.025893 74 | 0.018772 0.022915 75 | 0.013815 0.019854 76 | 0.009607 0.016715 77 | 0.006156 0.013503 78 | 0.003466 0.010223 79 | 0.001541 0.006877 80 | 0.000385 0.003468 81 | 0.000000 0.000000 82 | 0.000385 -0.003468 83 | 0.001541 -0.006877 84 | 0.003466 -0.010223 85 | 0.006156 -0.013503 86 | 0.009607 -0.016715 87 | 0.013815 -0.019854 88 | 0.018772 -0.022915 89 | 0.024472 -0.025893 90 | 0.030904 -0.028783 91 | 0.038060 -0.031580 92 | 0.045928 -0.034276 93 | 0.054497 -0.036867 94 | 0.063752 -0.039345 95 | 0.073680 -0.041705 96 | 0.084265 -0.043942 97 | 0.095492 -0.046049 98 | 0.107342 -0.048021 99 | 0.119797 -0.049854 100 | 0.132839 -0.051542 101 | 0.146447 -0.053083 102 | 0.160600 -0.054473 103 | 0.175276 -0.055709 104 | 0.190453 -0.056790 105 | 0.206107 -0.057714 106 | 0.222215 -0.058481 107 | 0.238751 -0.059092 108 | 0.255689 -0.059547 109 | 0.273005 -0.059848 110 | 0.290670 -0.059998 111 | 0.308658 -0.060000 112 | 0.326941 -0.059857 113 | 0.345492 -0.059575 114 | 0.364280 -0.059157 115 | 0.383277 -0.058609 116 | 0.402455 -0.057938 117 | 0.421783 -0.057148 118 | 0.441231 -0.056247 119 | 0.460770 -0.055241 120 | 0.480370 -0.054136 121 | 0.500000 -0.052940 122 | 0.519630 -0.051660 123 | 0.539230 -0.050302 124 | 0.558769 -0.048874 125 | 0.578217 -0.047383 126 | 0.597545 -0.045835 127 | 0.616723 -0.044237 128 | 0.635720 -0.042596 129 | 0.654508 -0.040917 130 | 0.673059 -0.039209 131 | 0.691342 -0.037476 132 | 0.709330 -0.035725 133 | 0.726995 -0.033962 134 | 0.744311 -0.032193 135 | 0.761249 -0.030423 136 | 0.777785 -0.028659 137 | 0.793893 -0.026905 138 | 0.809547 -0.025168 139 | 0.824724 -0.023452 140 | 0.839400 -0.021763 141 | 0.853553 -0.020107 142 | 0.867161 -0.018489 143 | 0.880203 -0.016914 144 | 0.892658 -0.015387 145 | 0.904508 -0.013914 146 | 0.915735 -0.012500 147 | 0.926320 -0.011149 148 | 0.936248 -0.009867 149 | 0.945503 -0.008658 150 | 0.954072 -0.007527 151 | 0.961940 -0.006478 152 | 0.969096 -0.005515 153 | 0.975528 -0.004642 154 | 0.981228 -0.003864 155 | 0.986185 -0.003182 156 | 0.990393 -0.002600 157 | 0.993844 -0.002120 158 | 0.996534 -0.001745 159 | 0.998459 -0.001476 160 | 0.999615 -0.001314 161 | 1.000000 -0.001260 --------------------------------------------------------------------------------