Application Center - Maplesoft

App Preview:

Average Temperature and Center of Mass of a Wire

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application



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 T(x,y,z) = x*y-x*z . A probe having the shape of the curve r(t) = [3*t^2, t^3+3*t, t^3-3*t+3] for 0 < t < 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]);

r := [proc (t) options operator, arrow; 3*t^2 end p...

> T:=MF([x,y,z],x*y-x*z);

T := proc (x, y, z) options operator, arrow; x*y-x*...

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);

[Maple Plot]

The tangent vector (or velocity) along the curve is

> v:=D(r);

v := [proc (t) options operator, arrow; 6*t end pro...

and its length is

> interface(showassumed=0);

> assume(t, real); lv:=len(v(t));

lv := 3*sqrt(2)*(1+t^2)

Along the curve, the temperature is

> Tr:=T(op(r(t))); Tr:=simplify(%);

Tr := 3*t^2*(t^3+3*t)-3*t^2*(t^3-3*t+3)

Tr := 18*t^3-9*t^2

The average value of the temperature is T[ave] = Int(T,s)/Int(1,s) = Int(T(r)*abs(v),t = 0 .. 3)/Int(abs(v),t = 0 .. 3)

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 := Int(3*(18*t^3-9*t^2)*sqrt(2)*(1+t^2),t = 0 ...

> Tave:=value(%); evalf(%);

Tave := 6777/40


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(%);

1/20412*Int(Int(Int(x*y-x*z,x = 0 .. 27),y = 0 .. 3...



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(%);

Int(3*(18*t^3-9*t^2)*sqrt(2)*(1+t^2),t = 0 .. 3)/In...

Tave := 6777/40


The Mass and Center of Mass of a Wire

A wire initially has the shape of the parametric curve r(t) = [t*cos(t), t*sin(t), -abs(t)] for -2*Pi < t `` < 2*Pi where distances are measured in cm . However, it has non-uniform thickness. At the point r(t) the cross sections are circles of radius R(t) = .12+.1*cos(t) cm . Assuming the wire is made from metal whose density is rho = 1.1 gm/(cm^3) , we first want to find the mass and center of mass of the wire.

If the wire is hung from the center point r(0) = [0, 0, 0] , 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 z -axis.

We first input the parametrized curve and plot it:

> r:=[t*cos(t),t*sin(t),-abs(t)];

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]);

[Maple Plot]

We can add the thickness of the wire by switching to a tubeplot. The radius is:

> R:=.12+.1*cos(t);

R := .12+.1*cos(t)

> tubeplot(r, radius=R, t=-2*Pi..2*Pi, orientation=[60,75], color=red, axes=normal);

[Maple Plot]

Next, we find the tangent vector (velocity) to the curve and its length:

> v:=diff(r,t);

v := [cos(t)-t*sin(t), sin(t)+t*cos(t), -signum(t)]...

> lv:=len(v); simplify(%); lv2:=subs(abs(1,t)^2=1,%);

lv := sqrt((cos(t)-t*sin(t))^2+(sin(t)+t*cos(t))^2+...


lv2 := sqrt(t^2+2)

At the point r(t) the cross sectional radius is

> R:=.12+.1*cos(t);

R := .12+.1*cos(t)

and the density is

> rho:=1.1;

rho := 1.1

So the mass of a segment of length ds = abs(v)*dt is dm = rho*Pi*R^2*abs(v)*dt and the total mass is Int(rho*Pi*R^2*abs(v),t = -2*Pi .. 2*Pi) . We compute:

> Int(rho*Pi*R^2*lv2,t=-2*Pi..2*Pi); value(%); M:=evalf(%);

Int(1.1*Pi*(.12+.1*cos(t))^2*sqrt(t^2+2),t = -2*Pi ...

int(1.1*Pi*(.12+.1*cos(t))^2*sqrt(t^2+2),t = -2*Pi ...

M := 3.103241813

The first moments are found by adding factors of x , y or z (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(%);

mom := [Int(1.1*Pi*(.12+.1*cos(t))^2*sqrt(t^2+2)*t*...
mom := [Int(1.1*Pi*(.12+.1*cos(t))^2*sqrt(t^2+2)*t*...

mom := [0., -6.548546357, -13.92722413]

> cm:=mom/M;

cm := [0., -2.110227546, -4.487959679]

Notice that the x -component of the center of mass is 0 as should be expected from symmetry.

If the wire is hung from [0, 0, 0] it will rotate about the x -axis by an angle

> phi:=arctan(cm[2]/cm[3]);

phi := .4395226637

The rotation matrix is

> T:=matrix([[1,0,0],[0,cos(phi),-sin(phi)],[0,sin(phi),cos(phi)]]);

T := matrix([[1, 0, 0], [0, .9049548765, -.42550754...

So the rotated curve is

> r2:=evalm(T &* r);

r2 := vector([t*cos(t), .9049548765*t*sin(t)+.42550...

To check this, we also rotate the center of mass

> cm2:=evalm(T &* cm);

cm2 := vector([0., 0., -4.959318741])

The center of mass is now on the z -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);

[Maple Plot]

To rotate about the z -axis, we need the rotation matrix

> Tz:=matrix([[cos(theta),-sin(theta),0],[sin(theta),cos(theta),0],[0,0,1]]);

Tz := matrix([[cos(theta), -sin(theta), 0], [sin(th...

We now make the movie:

> plotlist:=NULL:

> for i from 1 to 24 do
plotlist:=plotlist,tubeplot(evalm(Tz &* r2), radius=R, t=-2*Pi..2*Pi, orientation=[60,75], color=red, axes=normal);

> display([plotlist], insequence=true);

[Maple Plot]