How do I define a domain for my contour plot on the xy-plane in polar coordinates?

20 views (last 30 days)
Hi,
I'm attempting to plot the pressure coefficient of an incompressible and inviscid flow around a non-rotating cylinder on the xy-plane. Here's what I've tried:
U = 1.0;
R = 1.0;
x = [-10:0.01:10];
y = [-10:0.01:10];
[X, Y] = meshgrid(x, y);
u_r = U*(1.0 - R^2./(X.^2+Y.^2)).*X./sqrt(X.^2+Y.^2);
v_theta = -U*(1.0 + R^2./(X.^2+Y.^2)).*Y./sqrt(X.^2+Y.^2);
v_mag = sqrt(u_r.^2 + v_theta.^2); % Velocity magnitude
C_p = 1.0 - v_mag.^2/U^2; % Pressure coefficient
contour(X, Y, C_p, 100);
The problem I'm encountering is that the "flow" inside the cylinder is somehow taking all of my contour lines. Thus, I wish to limit my domain to the outside of a circle with radius=1. I can set my X and Y to be outside a 2x2 box, but that is not a solution to my problem. Any help would be greatly appreciated!
  1 Comment
Timothy
Timothy on 8 Sep 2013
After spending more time looking around, I found a solution!
I ended up using the contour option of specifying the contour line levels. I did some quick algebra to determine the minimum and maximum pressure coefficients that would result at theta = 0 and 180 deg (stagnation -> minimum -> C_p = -3) and at theta = 90 and 270 deg (C_p = 1). From here I used:
v = [-3.0:0.01:1.0];
contour(X, Y, C_p, v);
This plots all the contour lines within this specified domain which is exactly the contour lines outside the circular domain, albeit, there are some lines that cross into the domain since the contour lines are continuous. In order to cover up these excess data points, I plotted a solid circle made up of hundreds of black circles. I did this by doing:
v = [-3.0:0.1:1.0];
t = linspace(0,2*pi,length(x));
contour(X, Y, C_p, v);
hold on
for i = 0:10000
xc = 0.0001*i*cos(t);
yc = 0.0001*i*sin(t);
plot(xc, yc, 'k');
end
hold off
I hope that this helps anyone else who runs into this problem in the future! Good luck community!

Sign in to comment.

Accepted Answer

Timothy
Timothy on 8 Sep 2013
Here's a close-up of the solution! :)

More Answers (0)

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!