Cooling of a Cube

Example from the PscFunctions package

Using PscFunctions routines it is possible to obtain a line of new solutions of initial boundary value problems for the heat equation .
Solution of the problem of temperature distribution in unlimited in all directions three-dimensional solid with a given initial temperature may be found with the help of 3D Poisson integral. If the initial temperature function is represented as
psi(x,y,z) = f[1](x)*f[2](y)*f[3](z)  then the 3D integral disintegrates into the product of three integrals.
As an example we shall solve a problem about cooling of the unit cube with constant initial temperature
psi(x,y,z) = 1  and zero boundary temperature.
Let's consider a unit function on segment [0,1].  For this function we execute odd periodic extension with period 2 to entire axis. This can be made with the help of
FPeriodic  routine of the PSCFunctions  package. Using obtained function F(x)  it is possible to construct the function psi(x,y,z) = F(x)*F(y)*F(z) . This function should be substituted in the Poisson formula that will give a solution of the problem. At the beginning we generate the function F(x).

>    restart;
with(PscFunctions):
f:=x->1:
Ff:=FPeriodic(f,0..1,style='odd',checkcont=false):
F:=x->subs(t=x,Ff(t)):
print('F(x)'=F(x));
plot(F(x),x=-2..3,thickness=2,color=BLACK);

F(x) = signum(-1+Mod(x+1,2))

[Maple Plot]

Function Mod(t,a)  used in the previous formulas gives the remainder on division of the first argument by the second .
In the following code with the help of  
SCuboid  routine of our package we create the equation of a surface of the cube.

>    Cube:=SCuboid(1,1,1):
xc:=(u,v)->Cube[1](u,v):yc:=(u,v)->Cube[2](u,v):zc:=(u,v)->Cube[3](u,v): pc:=plot3d([xc(u,v),yc(u,v),zc(u,v)],u=0..4,v=-1..2,scaling=CONSTRAINED,grid=[9,7],axes=BOXED,labels=["X","Y","Z"],style=WIREFRAME,color=BLACK):
plot3d([xc(u,v),yc(u,v),zc(u,v)],u=0..4,v=-1..2,scaling=CONSTRAINED,grid=[17,13],axes=BOXED,labels=["X","Y","Z"]);
`Equation of the Cube`;
X=xc(u,v);
Y=yc(u,v);
Z=zc(u,v);

[Maple Plot]

`Equation of the Cube`

X = 1/2*abs(u)-1/2*abs(u-1)-1/2*abs(u-2)+1/2*abs(u-3)
Y = 1/2+1/2*abs(v)-1/2*abs(v-1)
Z = 1/2-1/4*abs(abs(u-1)-abs(u-2)-abs(u-3)+abs(-4+u)+abs(v-1)-abs(v-2)+abs(v)-abs(1+v))+1/4*abs(2+abs(u-1)-abs(u-2)-abs(u-3)+abs(-4+u)+abs(v-1)-abs(v-2)+abs(v)-abs(1+v))
Z = 1/2-1/4*abs(abs(u-1)-abs(u-2)-abs(u-3)+abs(-4+u)+abs(v-1)-abs(v-2)+abs(v)-abs(1+v))+1/4*abs(2+abs(u-1)-abs(u-2)-abs(u-3)+abs(-4+u)+abs(v-1)-abs(v-2)+abs(v)-abs(1+v))

Then we shall construct a temperature function U(x,y,z,t) = U[1](x,t)*U[1](y,t)*U[1](z,t) .
Temperature distribution we represent in three orthogonal sections passing through the centre of the cube. For this purpose with the help of  
DRectDomain     routine of our package we generate the equation of section area of the cube, i.e. the equation of the plane region of the quadrate. Functions ( x1(u,v),y1(u,v),z1(u,v) ), ( x2(u,v),y2(u,v),z2(u,v) ), ( x3(u,v), y3(u,v) z3(u,v) )  represent parametric equations of these sections. For each of these sections we create the function of color, which corresponds to temperature of the points of the section.

>    v:=(x,t)->evalf[4](1/sqrt(Pi)*Int(F(x+2*sqrt(t)*tau)*exp(-tau^2),tau=-10..10, method=_d01ajc)):
L:=1: NN:=10: h:=L/NN:
U1:=(x,t)->FPolyline([seq([h*i,v(h*i,t)],i=0..NN)])(x):
U:=(x,y,z,t)->U1(x,t)*U1(y,t)*U1(z,t): # temperature distribution in the cube
tr:=DRectDomain(x->0,x->1,0..1): # equation of the square
x1:=(u,v)->1/2:        y1:=(u,v)->tr[1](u,v): z1:=(u,v)->tr[2](u,v):
x2:=(u,v)->tr[1](u,v): y2:=(u,v)->1/2:        z2:=(u,v)->tr[2](u,v):
x3:=(u,v)->tr[1](u,v): y3:=(u,v)->tr[2](u,v): z3:=(u,v)->1/2:
t0:=0.01:   # point of time
clr:=(i,u,v)->U(x||i(u,v),y||i(u,v),z||i(u,v),t0):
scAll:=plot3d([[x1(u,v),y1(u,v),z1(u,v)],\
               [x2(u,v),y2(u,v),z2(u,v)],\
               [x3(u,v),y3(u,v),z3(u,v)]],u=0..1,v=0..1,\
    scaling=CONSTRAINED,grid=[11,11],axes=BOXED,labels=["X","Y","Z"],\
    color=[[clr(1,u,v),0,0],[clr(2,u,v),0,0],[clr(3,u,v),0,0]]):
plots[display](scAll,pc);

[Maple Plot]