Drawing Wired Closed Objects Using Rankine Oval

8 Ansichten (letzte 30 Tage)
joonyoung Go
joonyoung Go am 1 Dez. 2019
Verschoben: Mathieu NOE am 17 Apr. 2025
[x,y] = meshgrid(-10:0.01:10);
Here is my code and picture
m=5;
a=2;
U=1;
psi = U*y-m*atan2(2*a*y,x.^2+y.^2-a.^2);
contour(x,y,psi,100);
grid on;
......PNG
I want to represent a closed object by wire in Rankin Oval code.
The picture you want is:asd.PNG
How should I change my code?

Antworten (1)

suen
suen am 17 Apr. 2025
Verschoben: Mathieu NOE am 17 Apr. 2025
% Parameters for the Rankine Oval
V_inf = 10; % Uniform flow velocity (m/s)
b = 1; % Distance of source and sink from origin (m)
Lambda = 20; % Source strength (m^2/s)
% Define grid for plotting
[x, y] = meshgrid(linspace(-5, 5, 200), linspace(-5, 5, 200));
% Uniform flow stream function
psi_uniform = V_inf * y;
% Stream function for the source at (-b, 0)
r_source = sqrt((x + b).^2 + y.^2); % Distance to the source
theta_source = atan2(y, x + b); % Angle to the source
psi_source = (Lambda / (2 * pi)) * theta_source;
% Stream function for the sink at (b, 0)
r_sink = sqrt((x - b).^2 + y.^2); % Distance to the sink
theta_sink = atan2(y, x - b); % Angle to the sink
psi_sink = -(Lambda / (2 * pi)) * theta_sink;
% Total stream function
psi_total = psi_uniform + psi_source + psi_sink;
% Adjust streamline density
num_contours = 30; % Change this value to adjust streamline intensity
min_psi = min(psi_total(:)); % Minimum value of the stream function
max_psi = max(psi_total(:)); % Maximum value of the stream function
contour_levels = linspace(min_psi, max_psi, num_contours); % Custom contour levels
% Plot the streamlines
figure;
contour(x, y, psi_total, contour_levels, 'LineColor', 'blue', 'LineWidth', 1); % Draw streamlines
hold on;
% Mark the source and sink locations
plot(-b, 0, 'ro', 'MarkerSize', 8, 'MarkerFaceColor', 'r'); % Source
plot(b, 0, 'ko', 'MarkerSize', 8, 'MarkerFaceColor', 'k'); % Sink
% Plot the Rankine Oval shape
% The oval corresponds to a specific streamline (e.g., psi = 0)
contour(x, y, psi_total, [0 0], 'r-', 'LineWidth', 2); % Extract the oval shape
% Add labels and title
title('Streamlines and Rankine Oval Shape');
xlabel('x (m)');
ylabel('y (m)');
axis equal;
grid on;
% Add a legend
legend('Streamlines', 'Source', 'Sink', 'Rankine Oval', 'Location', 'Best');
% Close hold state
hold off;
% you can adjust the velocity and the strength yourself

Kategorien

Mehr zu Thermal Analysis finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by