fluid dynamics - Flow field around cylinder in Matlab -
i'm pretty new different plots in matlab , i'm trying write code show flow field around cylinder in matlab. i'm @ start , first of want make circle in rectangular domain (cylinder should not right in middle of field).
so far, have set want know if it's possible make cylinder more circular , less oval, because domain rectangle , not square. points on circle correct want better. tips on this? code have @ moment is:
u_i = 20; % ambient velocity = 4; % cylinder radius c = -a*5; % starting coordinate (x) b = a*10; % ending coordinate (x) d = -60; % starting coordinate (y) e = 60; % ending coordinate (y) n = a*50; % number of intervals (step size in grid) [x,y] = meshgrid([c:(b-c)/n:b],[d:(e-d)/n:e]'); = 1:length(x) k = 1:length(x); f = sqrt(x(i,k).^2 + y(i,k).^2); if f < x(i,k) = 0; y(i,k) = 0; end end end % definition of polar variables r = sqrt(x.^2+y.^2); theta = atan2(y,x); %% creation of streamline function z = u_i.*r.*(1-a^2./r.^2).*sin(theta);%- g*log(r)/(2*pi); %% creation of figure m = 100; s = ones(1,m+1)*a; t = [0:2*pi/m:2*pi]; %% streamline plot contour(x,y,z,50); hold on polar(t,s,'-k'); % axis square title('stream lines'); grid off
Comments
Post a Comment