Flow Across a Closed Curve
How do we get the unit normal? Remember the gradient section?
If the curve is given by g(x,y)=0, a normal vector at a point is given by gradient(g) evaluated at that point. The unit normal is grad(g)/||grad(g)||.
As an example, compute the flow of v(x,y)=x i + y j through the circle x^2+y^2=9.
In[27]:=
v[x_,y_]:={x,y}
In[28]:=
f[x_,y_]:=x^2+y^2-9
In[29]:=
grad2[f][x,y]
Out[29]=
{2 x, 2 y}
In[30]:=
n=grad2[f][x,y]/norm2[grad2[f][x,y]]
Out[30]=
2 x 2 y
{-----------------, -----------------}
2 2 2 2
Sqrt[4 x + 4 y ] Sqrt[4 x + 4 y ]
In[31]:=
v[x,y].n
Out[31]=
2 2
2 x 2 y
----------------- + -----------------
2 2 2 2
Sqrt[4 x + 4 y ] Sqrt[4 x + 4 y ]
To integrate v.n ds, we need the result from the section "Another Look at Line Integrals":
v.n ds is v(x(t),y(t),z(t)).n(x(t), y(t), z(t)) ||r'(t)|| dt.
We must parametrize f(x,y) as r(t)=3cos[t] i + 3sin[t] j.
In[32]:=
r[t_]:={3 Cos[t], 3 Sin[t]}
In[33]:=
vn=v[x,y].n /.{x->3 Cos[t], y->3 Sin[t]}
Out[33]=
2 2
18 Cos[t] 18 Sin[t]
----------------------------- + -----------------------------
2 2 2 2
Sqrt[36 Cos[t] + 36 Sin[t] ] Sqrt[36 Cos[t] + 36 Sin[t] ]
In[34]:=
Simplify[norm2[D[r[t],t]]]
Out[34]=
3
In[35]:=
vnds=Integrate[3 vn ,{t,0,2 Pi}]
Out[35]=
18 Pi
By the way, if the curve f(x,y) is already parametrized as r(t)={x(t),y(t)}, then r'(t)={x'(t),y'(t)} is the tangent vector, so the unit normal vector must be
n(t)={-y'(t),x(t)}/||{-y'(t),x(t)}||
or
n(t)={y'(t),-x(t)}/||{y'(t),-x(t)}||
The choice depends upon the choice of inner pointing or outer pointing normal. (Remember the veccalc1 notebook?)
(Check: Is r'(t).n(t)=0?)
In the above example, we have (using the gradient) that n=
In[36]:=
Simplify[n/.{x->3 Cos[t], y->3 Sin[t]}]
Out[36]=
{Cos[t], Sin[t]}
Using the parametrization we have n=
In[37]:=
parametrizedn=
D[{r[t][[2]],-r[t][[1]]},t]/norm2[D[{r[t][[2]],-r[t][[1]]},t]];
Simplify[parametrizedn]
Out[37]=
{Cos[t], Sin[t]}