# Velocity potential with quiver command

10 views (last 30 days)
Rafael Lima on 4 Aug 2020
Answered: KSSV on 4 Aug 2020
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!

KSSV on 4 Aug 2020
quiver(x,y,u,v)