Impulsive start, possibly followed by an impulsive stop, by the discrete-vortex 3 % method with uniform elements 4 clear 5 clc 6 % input parameters 7 n = 100; % input the number of elements 8 ntsteps = 200; % the number of time steps for this run 9 tstop = 205.
Impulsive start, possibly followed by an impulsive stop, by the discrete-vortex 3 % method with uniform elements 4 clear 5 clc 6 % input parameters 7 n = 100; % input the number of elements 8 ntsteps = 200; % the number of time steps for this run 9 tstop = 205.
Impulsive start, possibly followed by an impulsive stop, by the discrete-vortex 3 % method with uniform elements 4 clear 5 clc 6 % input parameters 7 n = 100; % input the number of elements 8 ntsteps = 200; % the number of time steps for this run 9 tstop = 205.
1 % Unsteady Flow over a Flat Plate following an impulsive Start, 2 % possibly followed by an impulsive stop, by the discrete-vortex 3 % method with uniform elements 4 clear 5 clc 6 % input parameters 7 n = 100; % input the number of elements 8 ntsteps = 200; % input the number of time steps for this run 9 tstop = 205; % the time step when the impulsive start is 10 % followed by an impulsive stop 11 % input the angle of attack in degrees 12 alfa = 20; 13 sa = sind(alfa); 14 ca = cosd(alfa); 15 np = n + 1; 16 dx = 1/n; 17 dx34 = 3*dx/4; 18 dx14 = dx/4; 19 % input the cut-off to avoid the singularity 20 % associated with the vortices in the wake 21 cutoff = 0.25*dx; 22 % time step for more-or-less evenly 23 % spaced vortices in the wake 24 dt = dx; 25 % control points 26 xcpt = (0:n-1)*dx + dx34; 27 % vortex points 28 xvor = (0:n)*dx + dx14 29 yvor(1:np) = 0; 30 ycpt(1:n) = 0; 31 % first n rows of the influence matrix, which is 32 % independent of alfa, and the right-hand side 33 for i = 1:n; 34 R(i) = -sa; 35 for j = 1:np; 36 A(i,j) = 1/(xcpt(i) - xvor(j)); 37 end 38 end 39 % last row to sum for the circulation 40 A(np,1:np) = 1; 41 R(np) = 0; 42 % instant just after the start, time = 1 43 G = inv(A)*R'; 44 % velocity jump; note 2*pi, which 45 % was missing in in A(i,j) 46 du = -2*pi*G./dx; 47 % rotate the plate through alfa 48 % here we take the freestream to be horizontal 49 % and place the plate at an angle of attack -1- C:\Users\Domenico\Documents\MATLAB\lastraimpulsiva.m luned 10 febbraio 2014 14:54 50 yv = -xvor*sa; 51 yc = -xcpt*sa; 52 xv = xvor*ca; 53 xc = xcpt*ca; 54 % XXXXXXXXXXXXXX FIGURE(1) XXXXXXXXXXXXXXXXXX 55 % coordinates for plotting the 56 % plate at an angle of attack 57 xplate(1) = 0; xplate(2) = ca; 58 yplate(1) = 0; yplate(2) = -sa; 59 figure(1) 60 plot( xplate,yplate,':k', xv,yv,'.g', xc,yc,'xb') 61 axis equal 62 axis ([-.2, 1.2, -.5 .2]); 63 xlabel('\bf\itx','fontsize',14); 64 ylabel('\bf\ity ','fontsize',14) 65 set(get(gca,'YLabel'),'Rotation',0.0) 66 title([num2str(n),' panels']) 67 % XXXXXXXXXXXXXX FIGURE(2) XXXXXXXXXXXXXXXXXXX 68 % the exact steady-state solution, the exact 69 % unsteady solution does not exist 70 nplot = 100; 71 x = linspace(.01,1,nplot); 72 due = 2*sa*sqrt((1-x)./x); 73 figure(2) 74 plot( x, due, xvor,du,'.', xvor,du, xvor,yvor,'.g', xcpt,ycpt,'xb' ) 75 xlabel('\bf\itposition on the plate','fontsize',12 ); 76 ylabel('\bf\it\Deltau ','fontsize',14) 77 set(get(gca,'YLabel'),'Rotation',0.0) 78 time = 1; 79 title([num2str(n),' panels, time step = ',num2str(time)]) 80 axis ([-.05, 1.05, -7 7]); 81 grid 82 % check figures 1 and 2 83 pause 84 % the initial value of phi (vel. potential) around the plate 85 phiO(1:np) = 0; 86 % the initial sum of the circulations around the vortices 87 % in the wake, sum(Gw) 88 sgw = 0; 89 %XXXXXXXXXX time-marching begins here XXXXXXXXXXXXXXXX 90 for time = 2:ntsteps 91 % step 1:shed the 'starting' vortex at the trailing 92 % edge at the beginning of the time step 93 % one vortex is added to the wake at each time step 94 Gw(time-1) = G(np); 95 xw(time-1) = xv(np); 96 yw(time-1) = yv(np); 97 gammaC(time-1) = sum(G(1:n)); 98 % update the sum of the circulations around the vortices in the wake -2- C:\Users\Domenico\Documents\MATLAB\lastraimpulsiva.m luned 10 febbraio 2014 14:54 99 sgw = sgw + Gw(time-1); 100 % step 2: convect the wake to its new position 101 % to convect the wake, first find the velocity 102 % at the location of each vortex in the wake, 103 for j = 1:time-1 104 xp = xw(j); 105 yp = yw(j); 106 % contribution to the velocity from the freestream 107 u(j) = 1; 108 v(j) = 0; 109 if time > tstop 110 u(j) = 0; % used when the impulsive start is 111 v(j) = 0; % followed by an implusive stop 112 end 113 % contribution from the bound vortex sheet (the plate) 114 for i = 1:n; 115 rsq = ( xp - xv(i) )^2 + ( yp - yv(i) )^2; 116 f = G(i)/rsq; 117 u(j) = u(j) - f*( yp - yv(i) ); 118 v(j) = v(j) + f*( xp - xv(i) ); 119 end 120 % contribution from the free vortex sheet (the wake) 121 for i = 1:time-1 122 rsq = ( xp - xw(i) )^2 + ( yp - yw(i) )^2; 123 if rsq > cutoff; 124 f = Gw(i)/rsq; 125 u(j) = u(j) - f*( yp - yw(i) ); 126 v(j) = v(j) + f*( xp - xw(i) ); 127 end 128 end 129 end 130 % step 3: move each vortex in the wake to its 131 % new position using a simple Euler algorithm 132 for i = 1:time-1 133 xw(i) = xw(i) + u(i)*dt; 134 yw(i) = yw(i) + v(i)*dt; 135 end 136 % the wake is now in its new position and so the downwash 137 % (the velocity associated with the vorticity in the wake) 138 % on the wing has changed and must be re-computed 139 % step4: re-compute the downwash from the wake and the 140 % freestream on the plate the influence matrix does not change 141 for i = 1:n 142 xp = xc(i); 143 yp = yc(i); 144 % contribution to the velocity from the freestream 145 uu = 1; 146 vv = 0; 147 if time > tstop -3- C:\Users\Domenico\Documents\MATLAB\lastraimpulsiva.m luned 10 febbraio 2014 14:54 148 uu = 0; % used when the impulsive start is 149 vv = 0; % followed by an impulsive stop 150 end 151 % contribution from the wake 152 for k = 1:time - 1 153 rsq = ( xp - xw(k) )^2 + ( yp - yw(k) )^2; 154 f = Gw(k)/rsq; 155 uu = uu - f*( yp - yw(k) ); 156 vv = vv + f*( xp - xw(k) ); 157 end 158 % the right-hand side now contains the velocity of the freestream 159 % and that associated with wake's vorticity 160 R(i) = - uu*sa - vv*ca; 161 end 162 % the sum of the circulations in the wake plus the sum of the 163 % circulations on the plate plus the circulation for the new 164 % vortex at the trailing edge must add up to zero: transpose of 165 % the known circulations in the wake 166 R(np) = -sgw; 167 % step 5: compute the new distribution of 168 % circulation on the plate 169 G = inv(A)*R'; 170 % this is the end of the calculations for this time 171 % step -- the wake is in its new position and the 172 % circulations on the plate plus the new vortex at 173 % the trailing edge have been determined so that the 174 % no-penetration and Kutta conditions are satisfied, 175 % consistent with the wake in its new position, and 176 % the circulation around the plate and its wake is 177 % still zero 178 % XXXXXXXXXXXXX figure(1) XXXXXXXXXXXXXXX 179 % plot the wake as it's being calculated 180 figure(1) 181 plot(xv(np), yv(np),'.r', xw,yw,'.r','linewidth',1); 182 hold on 183 plot(xplate, yplate,' k','linewidth',2); 184 axis equal 185 xlabel('\bf\itx','fontsize',14); 186 ylabel('\bf\ity ','fontsize',14) 187 set(get(gca,'YLabel'),'Rotation',0.0) 188 title([num2str(n),' panels, Time Step = ',num2str(time)]) 189 hold off 190 % XXXXXXXXXXXXX figure(2) XXXXXXXXXXXXXXXXX 191 % plot the pressure jump as it's being calculated 192 for i = 1:np 193 phi(i) = sum( G(1:i) ); 194 end 195 % d(phi)/dt 196 dGdt = -2*pi*( phi(1:np) - phiO(1:np) )/dt; -4- C:\Users\Domenico\Documents\MATLAB\lastraimpulsiva.m luned 10 febbraio 2014 14:54 197 phiO = phi; 198 du2 = -2*pi*G(1:np)./dx; 199 up = ca + du2; 200 ul = ca - du2; 201 cpu = 1 - up.*up; 202 cpl = 1 - ul.*ul; 203 dcp = -2*dGdt' - cpl + cpu; 204 figure(2) 205 plot(xv, dcp) 206 xlabel('\bf\itx','fontsize',14); 207 ylabel('\bf\it\DeltaC_P ','fontsize',14) 208 set(get(gca,'YLabel'),'Rotation',0.0) 209 grid 210 title([num2str(n),' panels, time step = ',num2str(time)]) 211 % XXXXXXXXXXX figure(3) XXXXXXXXXXXXXXXXXXX 212 % plot the velocity jump a cross the plate as it's being calculated 213 du = -2*pi*G/dx; 214 up = ca + 0.5*du; 215 upe = ca + 0.5*due; 216 ul = ca - 0.5*du; 217 ule = ca - 0.5*due; 218 figure(3) 219 plot(xv, up, xv, ul) 220 xlabel('\it\bfx','fontsize',14); 221 ylabel('\bf\itvelocity along the surfaces','fontsize',12) 222 axis([-.1, 1.1, -1, 3]) 223 title([num2str(n),' panels, time step = ',num2str(time)]) 224 grid 225 drawnow 226 % end of the "for"-loop in the time-marching 227 end 228 % XXXXXXXXXXXXX figure(4) XXXXXXXXXXXXXXXXXXXXXXX 229 % plot the jump in airspeed across the surface' 230 du = -2*pi*G/dx; 231 figure(4) 232 plot( x, due, xvor,du,'.', xvor,du, xvor,yvor,'.g', xcpt,ycpt,'xb' ) 233 xlabel('\bf\itx','fontsize',14); 234 ylabel('\bf\it\Deltau ','fontsize',14) 235 set(get(gca,'YLabel'),'Rotation',0.0) 236 title([num2str(n),' panels, time step = ',num2str(time)]) 237 grid 238 axis ([-.05, 1.05, -.8 7]); 239 % XXXXXXXXXXXXXXXXXX figure(5) XXXXXXXXXXXXXXXXXXXXX 240 % plot the circulation around the plate as a function of time 241 figure(5) 242 plot((1:time-1), Gw(1:time-1)) 243 xlabel('time step') 244 ylabel('\Gamma\itw_T_E ') 245 set(get(gca,'YLabel'),'Rotation',0.0) -5- C:\Users\Domenico\Documents\MATLAB\lastraimpulsiva.m luned 10 febbraio 2014 14:54 246 title(['\bfG(np) for ',num2str(n),' panels']) 247 % XXXXXXXXXXXXXXXXXXX figure(6) XXXXXXXXXXXXXXXX 248 figure (6) 249 xfinal = tstop/n + 1.5 250 [xfp,yfp] = meshgrid(-.5:.1:xfinal, -2:.05:.7); 251 [ n1 n2 ] = size(xfp); 252 % sum of the contributions to the velocity components from 253 % the distributions of vortices and the freestream 254 for i = 1:n1; 255 for j = 1:n2; 256 xp = xfp(i,j); 257 yp = yfp(i,j); 258 % contribution from the freestream 259 ufp(i,j) = 1; 260 vfp(i,j) = 0; 261 ufpd(i,j) = 0; 262 vfpd(i,j) = 0; 263 % contribution from the boundary layer (bound vortex sheet) 264 for in = 1:n; 265 rsq = ( xp - xv(in) )^2 + yp*yp; 266 if rsq > cutoff 267 f = G(in)/rsq; 268 ufp(i,j) = ufp(i,j) - f*yp; 269 vfp(i,j) = vfp(i,j) + f*( xp -xv(in)); 270 ufpd(i,j) = ufpd(i,j) - f*( yp-yv(in)); 271 vfpd(i,j) = vfpd(i,j) + f*( xp -xv(in)); 272 end 273 end 274 % contribution from the wake (free vortex sheet) 275 for in = 1:time-1; 276 rsq = ( xp - xw(in) )^2 + ( yp - yw(in) )^2; 277 if rsq > cutoff; 278 f = Gw(in)/rsq; 279 ufp(i,j) = ufp(i,j) - f*( yp - yw(in) ); 280 vfp(i,j) = vfp(i,j) + f*( xp - xw(in) ); 281 ufpd(i,j) = ufpd(i,j) - f*( yp - yw(in) ); 282 vfpd(i,j) = vfpd(i,j) + f*( xp - xw(in) ); 283 end 284 end 285 end 286 end 287 scale = 1.; 288 quiver(xfp,yfp,ufp,vfp, scale,'b', 'LineWidth',0.1); 289 hold on 290 axis equal 291 plot(xplate,yplate,'k','linewidth',2) 292 title(['\bfImpulsively started & stopped flat plate: ',... 293 '\alpha = ',num2str(alfa),' degs.'],'fontsize', 11) 294 hold off -6- C:\Users\Domenico\Documents\MATLAB\lastraimpulsiva.m luned 10 febbraio 2014 14:54 295 % XXXXXXXXXXXXXXXXXXX Figure(7) XXXXXXX 296 figure(7) 297 scale = 2; 298 quiver(xfp,yfp,ufpd,vfpd, scale,'b', 'LineWidth',0.1); 299 hold on 300 axis equal 301 plot(xplate,yplate,'k','linewidth',2) 302 title(['\bfImpulsively started & stopped flat plate: ',... 303 '\alpha = ',num2str(alfa),' degs.'],'fontsize', 11) 304 hold off 305 hold on 306 axis equal 307 title(['\bfImpulsively started & stopped flat plate: ',... 308 '\alpha = ',num2str(alfa),' degs.'],'fontsize', 11) 309 hold off 310 -7-