I need help plotting a range of stream lines in my velocity field plot.
44 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jason Harvey
am 25 Mär. 2016
Beantwortet: Kavitha G N
am 12 Sep. 2023
I am new to matlab so please excuse my naivety. I need to plot streamlines for psi = [0:1:6] over the range -3<x<3. Any assistance would be greatly appreciated. Here is what I currently have;
[x,y] = meshgrid(-3:.5:3,-3:.5:3);
u = 2*y; % u velocity function
v = 1+(2*x); % v velocity function
xmarker = -0.5; %stagnation 'x' point
ymarker = 0; % stagnation 'y' point
figure
hold on
quiver (x,y,u,v)
plot(xmarker,ymarker,'r*') % stagnation point
axis([-3 3 -3 3])
%stream function
psi(0) = y^2 - x^2 - x -0.25
0 Kommentare
Akzeptierte Antwort
Ced
am 25 Mär. 2016
Hi
Nice plotting! I believe contour might help, something like
%stream function
psi = y.^2 - x.^2 - x -0.25;
contour(x,y,psi,[0:1:6])
Cheers
2 Kommentare
Weitere Antworten (2)
Harish babu
am 12 Apr. 2016
I need help plotting a range of stream lines for velocity and temperature plots in any numerical methods
1 Kommentar
Kavitha G N
am 12 Sep. 2023
Need help in plotting the stream lines. I have Orr-sommerfeld equation (1/aR)(D^2 - a^2)^2 Psi - 2i psi - (1-x^2)(D^2 - a^2) psi = c(D^2 - a^2)psi.I have to plot stream lines to this equation with boundaries psi(-1)=0 and psi(1)=0. I have written this but i coldnot validate. Can any one please help to correct this if there are any.
% Define the number of grid points and domain
N = 50; % Number of grid points
Lx = 10; % Streamwise domain length
Ly = 2; % Wall-normal domain length
% Define the x and y vectors based on the grid dimensions
x = linspace(0, Lx, N-1);
y = linspace(0, Ly, N-1);
[X,Y] = meshgrid(x,y);
% Define the Chebyshev differentiation matrix
[D, x] = cheb(N);
D2 = D^2;
D2 = D2(2:N, 2:N); % Remove boundary points
% Define the Orr-Sommerfeld operators A and B
I = eye(N-1);
a = 0.05; % Adjust the value of 'a' as needed
R = 500000; % Adjust the value of 'R' as needed
S = diag([0; 1./(1-x(2:N).^2); 0]);
D4 = (diag(1-x.^2)*D^4 - 8*diag(x)*D^3 - 12*D^2)*S;
D4 = D4(2:N, 2:N);
A = (D4 - 2*a^2*D2 + a^4*I) / (a*R) - 2i*I - 1i*diag(1-x(2:N).^2)*(D2 - a^2*I);
B = D2 - a^2*I;
% Calculate eigenvalues and eigenvectors
[vecs, vals] = eig(A, B);
% Find the eigenmode with the maximum growth rate
[max_growth, max_idx] = max(real(diag(vals)));
most_unstable_mode = vecs(:, max_idx);
real_most_unstable_mode =real(most_unstable_mode);
% Reshape the eigenmode to match the grid dimensions
psi = zeros(N-1, N-1);
psi(:, 1:N-1) =reshape(real_most_unstable_mode.*eye(N-1), [], N-1);
disp(psi);
% Create a 2D contour plot of the stream function
contour(X,Y,psi,100,'-b');
xlabel('x');
ylabel('y');
title('Stream Function');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Vector Fields finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!