MapleHeatSeekingTH.mws

Heat Seeking Particle

Adapted from the Maple 8 Getting Started Guide

A particle is placed on a heated plate and begins moving.  The motion will always be in the direction of the greatest increase in temperature.  The task is to determine the path this "heat seeking" particle will take.  This worksheet investigates finding this path.

The temperature at a point on the plate is given by f.  The particle starts at the point (x1,y1).

>    with(plots):

Warning, the name changecoords has been redefined

>    x:='x';

>    y:='y';

x := 'x'

y := 'y'

>    f:=100-10*x^2-y^4;

f := 100-10*x^2-y^4

Determining the Direction of Motion (Gradient)

>    fx:=diff(f,x);

fx := -20*x

>    fy:=diff(f,y);

fy := -4*y^3

Picking a Starting Point

>    x1:=2.5;

x1 := 2.5

>    y1:=2.5;

y1 := 2.5

>    x:='x';

>    y:='y';

x := 'x'

y := 'y'

Temperature at the Starting Point

>    T1:=eval(f,{x=x1,y=y1});

T1 := -1.5625

Contour Plot of the Temperature of the Plate

>    contourplot(f,x=-3..3,y=-1..3,contours=8,filled=true);

[Maple Plot]

Approximating the Path of the Heat Seeking Particle on the Contour Plot

>    LevelContour:=contourplot(f,x=-3..3,y=-1..3,contours=8,filled=true):

>    gx:=eval(fx,{x=P[1],y=P[2]});

gx := -20*P[1]

>    gy:=eval(fy,{x=P[1],y=P[2]});

gy := -4*P[2]^3

>    point2d1:=Array(1..45);

point2d1 := Array(%id = 21940756)

>    route2d1:=Array(1..45);

route2d1 := Array(%id = 20512940)

>    timestep:=0.15;

timestep := .15

>    point2d1[1]:=<x1,y1>;

point2d1[1] := Vector(%id = 3134700)

>    for i from 1 to 44 do
route2d1[i]:=LinearAlgebra[Normalize](eval(<gx,gy>,P=point2d1[i]));
point2d1[i+1]:=eval(<P[1],P[2]>,P=point2d1[i]+timestep*route2d1[i]);
end do:

>    listpoints2d1:=[seq(convert(point2d1[i],list),i=1..45)]:

>    path2d1:=pointplot(listpoints2d1,style=line,color=blue,thickness=3):

>    display(LevelContour,path2d1);

[Maple Plot]

The Path of the Heat Seeking Particle on the Contour Plot   with a Different Starting Point

>   

>    x1:=-1;

x1 := -1

>    y1:=2.5;

y1 := 2.5

Temperature at the Starting Point

>    T1:=eval(f,{x=x1,y=y1});

T1 := 50.9375

Approximating the New Path of the Heat Seeking Particle on the Contour Plot

>    gx:=eval(fx,{x=P[1],y=P[2]});

gx := -20*P[1]

>    gy:=eval(fy,{x=P[1],y=P[2]});

gy := -4*P[2]^3

>    point2d2:=Array(1..45);

point2d2 := Array(%id = 21943836)

>    route2d2:=Array(1..45);

route2d2 := Array(%id = 22001740)

>    timestep:=0.15;

timestep := .15

>    point2d2[1]:=<x1,y1>;

point2d2[1] := Vector(%id = 22003260)

>    for i from 1 to 44 do
route2d2[i]:=LinearAlgebra[Normalize](eval(<gx,gy>,P=point2d2[i]));
point2d2[i+1]:=eval(<P[1],P[2]>,P=point2d2[i]+timestep*route2d2[i]);
end do:

>    listpoints2d2:=[seq(convert(point2d2[i],list),i=1..45)]:

>    path2d2:=pointplot(listpoints2d2,style=line,color=blue,thickness=3):

>    display(LevelContour,path2d2);

[Maple Plot]

Both Paths

>    display(LevelContour,path2d1,path2d2);

[Maple Plot]

Plotting the Analytical Solutions in Green

>    AnalPath1:=plot([2.5*exp(-20*t),5/sqrt(200*t+4),t=0..6],x=-3..3,y=-1..3,color=green,thickness=3):

>    AnalPath2:=plot([-exp(-20*t),5/sqrt(200*t+4),t=0..6],x=-3..3,y=-1..3,color=green,thickness=3):

>    display(LevelContour,AnalPath1,AnalPath2);

[Maple Plot]

>    display(LevelContour,path2d1,path2d2,AnalPath1,AnalPath2);

[Maple Plot]

>   

>