I am trying use contour function in MATLAB to plot the pressure coefficient in the entire flow domain and pin the pressure coefficient at the stagnation points? Any assistance

24 次查看(过去 30 天)
k = 1;
Uinf = 1;
rho = 1.2;
[x y] = meshgrid ([-1:0.1:1],[-1:0.1:1]);
u = -k/(2*pi)*(x.^2 + y.^2 - 2*y.^2)./(x.^2 + y.^2).^2;
v = k/(2*pi)*(-2*x.*y)./(x.^2 + y.^2).^2;
u(find(abs(u)>5))=0;
v(find(abs(v)>5))=0;
Umag = sqrt(u.^2 + v.^2)
cp = 1-(Umag.^2/Uinf^2);
DelP = 0.5*rho*(Uinf^2 - Umag.^2);
figure
contourf(x, y, DelP, 100, 'LineStyle', 'none')
colormap('gray')
hold on
quiver(x, y, u, v, 1)
streamline(x, y, u, v, ones(1, 21)*-1,[-0.01:0.001:0.01])

回答(1 个)

Abhinaya Kennedy
Abhinaya Kennedy 2024-4-3
Hi Kamar,
To plot the pressure coefficient “cp” in the entire flow domain and pinpoint the stagnation points, you can follow the structure you've started with and make a few adjustments.
  1. Plot the pressure coefficient “cp” instead of the pressure difference “DelP”.
  2. Identify and mark the stagnation points where the velocity magnitude is close to zero.
k = 1;
Uinf = 1;
rho = 1.2;
[x, y] = meshgrid([-1:0.1:1], [-1:0.1:1]);
% Velocity components
u = -k/(2*pi)*(x.^2 + y.^2 - 2*y.^2)./(x.^2 + y.^2).^2;
v = k/(2*pi)*(-2*x.*y)./(x.^2 + y.^2).^2;
% Limiting the velocity to avoid singularities/overflow
u(abs(u) > 5) = 0;
v(abs(v) > 5) = 0;
Umag = sqrt(u.^2 + v.^2);
% Pressure coefficient
cp = 1 - (Umag.^2/Uinf^2);
% Plotting the pressure coefficient
figure;
contourf(x, y, cp, 100, 'LineStyle', 'none');
colorbar; % To show the scale of Cp
colormap('jet'); % Use a more colorful colormap for better visibility
hold on;
% Velocity field
quiver(x, y, u, v, 1);
% Streamlines
streamline(x, y, u, v, ones(1, 21)*-1, [-0.01:0.001:0.01]);
% Identifying and marking stagnation points
% A simple approach: Find where velocity components are both close to zero
stagnationPointsX = x(abs(u) < 0.01 & abs(v) < 0.01);
stagnationPointsY = y(abs(u) < 0.01 & abs(v) < 0.01);
% Marking stagnation points
plot(stagnationPointsX, stagnationPointsY, 'ro', 'MarkerFaceColor', 'b');
title('Pressure Coefficient (Cp) and Flow Field');
xlabel('X Coordinate');
ylabel('Y Coordinate');
You might need to adjust the stagnation point thresholds based on your specific requirements or the characteristics of the flow you're studying.
This link will provide you with more information on plotting specific points on your figure: https://www.mathworks.com/help/matlab/ref/plot.html#bvcbkvu-1
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by