Velocity potential with quiver command
28 次查看(过去 30 天)
显示 更早的评论
Hi everyone,
I am studying potential flows, i tried to use the quiver command to determine the velocity field. I took this code of a freestream velocity around a cylinder with a vortex. I have the streamfunction. My idea was to find the velocity components u and v with derivatives of Streamfunction with respect y and x, respectively.
nx = 100;
xmin = -3.5;
xmax = 1.5;
ny = 100;
ymin = -3.0;
ymax = 1.5;
[x, y] = meshgrid(linspace(xmin, xmax, nx), linspace(ymin, ymax, ny));
U0 = 5.0;
Gamma = 8*pi;
xGamma = -1.0;
yGamma = -1.0;
K = 5.0;
xK = -1.0;
yK = -1.0;
radius = inline('sqrt((x-x1).^2+(y-y1).^2)', 'x', 'y', 'x1', 'y1');
PsiK = K*sin(atan2(y-yK, x-xK))./radius(x, y, xK, yK);
PsiGamma = Gamma*log(radius(x, y, xGamma, yGamma))/2/pi;
StreamFunction = U0*y-PsiGamma-PsiK;
levmin = StreamFunction(1, nx);
levmax = StreamFunction(ny, nx/2);
levels = linspace(levmin, levmax, 50);
contour(x, y, StreamFunction, levels)
hold on
theta = linspace(0, 2*pi);
plot(xGamma+cos(theta), yGamma+sin(theta), 'k-')
axis equal
axis([xmin, xmax, ymin, ymax])
ylabel('y')
xlabel('x')
I tried to use the definition u = diff(StreamFunction,y) and v = -diff(StreamFunction,x) , but it generates an error.
Could you help me?
Thank you very much!
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vector Fields 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!