lineintscal.mws
Line Integrals of Scalar Fields
Using Maple and the
vec_calc
Package
This worksheet shows how to compute line integrals of scalar fields using
Maple
and the
vec_calc
package. As examples we compute
* The Average Temperature along a Wire
* The Mass and Center of Mass of a Wire
To start the
vec_calc
package, execute the following commands:
>
restart;
>
libname:=libname,"C:/mylib/vec_calc7":
>
with(vec_calc): vc_aliases:
>
with(linalg):with(student):with(plots):
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the name changecoords has been redefined
>
The Average Temperature along a Wire
When a temperature probe is inserted into a fluid, it records the average temperature along the probe.
The temperature of the fluid in a 27"x36"x21" box is
. A probe having the shape of the curve
for
< 3 is inserted into the box. We want to find the average temperature along the probe. Then we will compare it to the average temperature in the box.
We first define the functions which describe the curve and the temperature.
>
r:=MF(t,[3*t^2, t^3+3*t, t^3-3*t+3]);
>
T:=MF([x,y,z],x*y-x*z);
We can plot the curve using the command
>
spacecurve(r(t),t=0..3, axes=boxed, color=blue, thickness=3, orientation=[-30,80], scaling=constrained);
The tangent vector (or velocity) along the curve is
>
v:=D(r);
and its length is
>
interface(showassumed=0);
>
assume(t, real); lv:=len(v(t));
Along the curve, the temperature is
>
Tr:=T(op(r(t))); Tr:=simplify(%);
The average value of the temperature is
=
Note: The denominator is the arc length.
We compute the average temperature:
>
Tave:=Int(Tr*lv,t=0..3)/Int(lv,t=0..3);
>
Tave:=value(%); evalf(%);
This can be compared to the average value in the box:
>
1/(27*36*21)*Muint(T(x,y,z),x=0..27, y=0..36, z=0..21); value(%); evalf(%);
So the probe measures a temperature which is somewhat too high.
Another way to compute these line integrals is to use the
Line_int_scalar
command (or its alias
Lis
) from the
vec_calc
package which works directly with the parametrized curve and the scalar function:
>
Lis(T,r,t=0..3)/Lis(1,r,t=0..3); Tave:=value(%);
>
The Mass and Center of Mass of a Wire
A wire initially has the shape of the parametric curve
for
where distances are measured in
. However, it has non-uniform thickness. At the point
the cross sections are circles of radius
. Assuming the wire is made from metal whose density is
, we first want to find the mass and center of mass of the wire.
If the wire is hung from the center point
, it will rotate until the center of mass is directly below the suspension point. We want to plot the curve both before and after making this rotation and then make an animation of the wire spinning about the
-axis.
We first input the parametrized curve and plot it:
>
r:=[t*cos(t),t*sin(t),-abs(t)];
>
spacecurve(r, t=-2*Pi..2*Pi, orientation=[60,75], color=red, axes=normal, view=[default,default,-2*Pi..0.1]);
We can add the thickness of the wire by switching to a tubeplot. The radius is:
>
R:=.12+.1*cos(t);
>
tubeplot(r, radius=R, t=-2*Pi..2*Pi, orientation=[60,75], color=red, axes=normal);
Next, we find the tangent vector (velocity) to the curve and its length:
>
v:=diff(r,t);
>
lv:=len(v); simplify(%); lv2:=subs(abs(1,t)^2=1,%);
At the point
the cross sectional radius is
>
R:=.12+.1*cos(t);
and the density is
>
rho:=1.1;
So the mass of a segment of length
is
and the total mass is
. We compute:
>
Int(rho*Pi*R^2*lv2,t=-2*Pi..2*Pi); value(%); M:=evalf(%);
The first moments are found by adding factors of
,
or
(in terms of the curve) inside the integral. The center of mass is then found by dividing the first moments by the mass.
>
mom:=map(Int,evall(rho*Pi*R^2*lv2*r),t=-2*Pi..2*Pi); mom:=evalf(%);
>
cm:=mom/M;
Notice that the
-component of the center of mass is
as should be expected from symmetry.
If the wire is hung from
it will rotate about the
-axis by an angle
>
phi:=arctan(cm[2]/cm[3]);
The rotation matrix is
>
T:=matrix([[1,0,0],[0,cos(phi),-sin(phi)],[0,sin(phi),cos(phi)]]);
So the rotated curve is
>
r2:=evalm(T &* r);
To check this, we also rotate the center of mass
>
cm2:=evalm(T &* cm);
The center of mass is now on the
-axis. (The first time I did this, I got the rotation matrix transposed.)
We plot the new curve:
>
tubeplot(r2, radius=R, t=-2*Pi..2*Pi, orientation=[60,75], color=red, axes=normal);
To rotate about the
-axis, we need the rotation matrix
>
Tz:=matrix([[cos(theta),-sin(theta),0],[sin(theta),cos(theta),0],[0,0,1]]);
We now make the movie:
>
plotlist:=NULL:
>
for i from 1 to 24 do
theta:=i*Pi/12;
plotlist:=plotlist,tubeplot(evalm(Tz &* r2), radius=R, t=-2*Pi..2*Pi, orientation=[60,75], color=red, axes=normal);
od:
>
display([plotlist], insequence=true);
>
>