%
%  w02div.m -- flows & divergence (djm, 12 jan 2004)
%
%  flow arrows

clear;  close all

L = 4.0;  ds = 2*L/13;

%  set x & y-vectors &  grid matrices ("help meshgrid")

x = -L:ds:+L;  y = -L:ds:+L;
[xx,yy] = meshgrid(x,y);
rr = sqrt(xx.^2 + yy.^2);

%- - - - - 

%  calculate velocity set #1

uu = xx./rr;  vv = yy./rr;

%  plot vector field ("help quiver") outside unit circle ("help gt")

figure(1)
quiver(x,y, uu, vv,0.5)
hold on
quiver(x,y,-uu,-vv,0.5,'.')
axis([-L +L -L +L]);  axis square;

%  label plot

title(['\bf flow vectors (u=x/r, v=y/r)'])
xlabel('\bf x-axis')
ylabel('\bf y-axis')

%- - - - - 

%  calculate velocity set #2

uu = xx./rr./rr;  vv = yy./rr./rr;

%  plot vector field ("help quiver") outside unit circle ("help gt")

figure(2)
quiver(x,y, uu, vv,0.5)
hold on
quiver(x,y,-uu,-vv,0.5,'.')
axis([-L +L -L +L]);  axis square;

%  label plot

title(['\bf flow vectors (u=x/r^2, v=y/r^2)'])
xlabel('\bf x-axis')
ylabel('\bf y-axis')

%- - - - - 

%  calculate velocity set #2

uu = -xx;  vv = yy;

%  plot vector field ("help quiver") outside unit circle ("help gt")

figure(3)
quiver(x,y, uu, vv,0.5)
hold on
quiver(x,y,-uu,-vv,0.5,'.')
axis([-L +L -L +L]);  axis square;

%  label plot

title(['\bf flow vectors (u=-x, v=y)'])
xlabel('\bf x-axis')
ylabel('\bf y-axis')


