Example 3

Consider the potential u=x^2+y^2.

In[51]:=

  Clear[u,v]
  u[x_,y_]:=x^2+y^2

The flow has velocity v=grad u.

In[52]:=

  v[x_,y_]:=grad2[u][x,y]
  v[x,y]

Out[52]=

  {2 x, 2 y}

The flow is irrotational because it comes from a potential, that is, curl v=curl(grad u)=0. This is a freebie.

In[53]:=

  curl2[v][x,y]

Out[53]=

  0

Find the streamlines.

In[54]:=

  Clear[x,y]
  DSolve[x'[t]/(2 x[t])==y'[t]/(2 y[t]),y[t],t]

Out[54]=

             -2 C[1] + Log[x[t]]
  {{y[t] -> E                   }}

In[55]:=

  Clear[x,y];
  DSolve[{x'[t]/(2 x[t])==y'[t]/(2 y[t])},y,t];
  y=Evaluate[y[t]/.Flatten[%][[1]]]/.x[t]->x;
  y

Out[55]=

   -2 C[1] + Log[x]
  E

So . . .

This simplifies to y=c x, or, for the purposes of contour plotting, y/x=c.

In[56]:=

  Clear[x,y]
  stream=ContourPlot[y/x,{x,-5,5},{y,-5,5},ContourShading->False,
  AspectRatio->Automatic];

The plot is an example of not paying attention and hoping Mathematica knows what it is doing. This is a poor plot. Why? Because y/x has problems at x=0 and we asked for the range {x,-5,5}. The PlotPoints option can help you here.

In[57]:=

  Clear[x,y]
  stream=ContourPlot[y/x,{x,-5,5},{y,-5,5},ContourShading->False,
  AspectRatio->Automatic,PlotPoints->100];

Are there sources or sinks?

Are there sources or sinks? ...

Recall that the net flow across a circle of radius r in this vector fields is
(by the 2D Divergence theorem):

Double integral of div v over the circle. Since div v=4 this is simply 4 times the area of the circle (4pi r^2).

This potential, u=x^2+y^2, satisfies Poisson's equation with f=4.

In[59]:=

  div2[grad2[u]][x,y]

Out[59]=

  4

Up to Laplace's and Poisson's Equations