MATH529L02: Heat equation

One-dimensional heat equation

Dirichlet jump boundary conditions

Solve (Subscript[u, t])=k (Subscript[u, xx]) with u(0,t)=0, u(L,t)=0, u(x,0)=100 for 0<x<L, k=1

nT=40; (* Number of terms in sine series *)

α = Table[ n (π/L),{n,1,nT}];

b=Table[(2/L)Integrate[100 Sin[α[[n]] x],{x,0,L}],{n,1,nT}];

ListPlot[b]

u[x_,t_,L_]=Sum[ b[[n]] Sin[ α[[n]] x ] Exp[ - ((α[[n]])^2) t],{n,1,nT}];

Plot[Table[u[x,t,1],{t,0,0.02,0.0025}],{x,0,1},PlotRange->All,Frame->True,PlotLabel->"Heat equation solution",FrameLabel->{"x","u(x,t)"},GridLines->Automatic]

Manipulate[Plot[u[x,t,1],{x,0,1},PlotRange->All,Frame->True,PlotLabel->"Heat equation solution",FrameLabel->{"x","u(x,t)"},GridLines->Automatic],{t,0,0.02,0.0025}]

Manipulate[Plot[u[x,t,1],{x,0,1},PlotRange->All,Frame->True,PlotLabel->"Heat equation solution",FrameLabel->{"x","u(x,t)"},GridLines->Automatic],{t,0,0.002,0.0001}]

Dirichlet smooth boundary conditions

Solve (Subscript[u, t])=k (Subscript[u, xx]) Exercise 2: u(0,t)=0, u(L,t)=0, u(x,0)=x(L-x) for 0<x<L, k=1

nT=40; (* Number of terms in sine series *)

α = Table[ n (π/L),{n,1,nT}];

bF[a_]=Integrate[x (L-x) Sin[a x],{x,0,L}]

b=Table[bF[α[[n]]],{n,1,nT}];

ListPlot[b /. L->1,PlotRange->All]

u[x_,t_,L_]=Sum[ b[[n]] Sin[ α[[n]] x ] Exp[ - ((α[[n]])^2) t],{n,1,nT}];

Plot[Table[u[x,t,1],{t,0,0.02,0.0025}],{x,0,1},PlotRange->All,Frame->True,PlotLabel->"Heat equation solution",FrameLabel->{"x","u(x,t)"},GridLines->Automatic]

Two-dimensional heat equation

(Subscript[u, t])=k ((Subscript[u, xx])+(Subscript[u, yy])), u(x,y,t=0)=100 on the [0,1]x[0,1] unit square, with zero temperature on edges

Dirichlet boundary conditions

nT=40; (* Number of terms in sine series *)

α = Table[ m π,{m,1,nT}]; β = Table[ n π,{n,1,nT}];

bF[u_,v_]=4Integrate[100 Sin[u x] Sin[v y],{x,0,1},{y,0,1}]

bF[u_]=Limit[bF[u,v],{v->u}]

b=Table[If[m==n,bF[α[[m]]],bF[α[[m]],β[[n]]]],{m,1,nT},{n,1,nT}];

ListPlot3D[b,PlotRange->All]

u[x_,y_,t_]=Sum[ b[[m,n]] Sin[ α[[m]] x ] Sin[ β[[n]] y ] Exp[ -( ((α[[m]])^2)+ ((β[[n]])^2)) t],{m,1,nT},{n,1,nT}];

Manipulate[Plot3D[u[x,y,t],{x,0,1},{y,0,1},PlotRange->All,Axes->True,PlotLabel->"Heat equation solution",AxesLabel->{"x","y","u"}],{t,0,0.02,0.0025}]

Manipulate[ContourPlot[u[x,y,t],{x,0,1},{y,0,1},PlotRange->All,Axes->True,PlotLabel->"Heat equation solution",AxesLabel->{"x","y","u"},Contours->Table[temp,{temp,0,100,10}]],{t,0,0.02,0.0025}]

Questions to investigate

Dirichlet BVP with no edge discontinuity

(Subscript[u, t])=k ((Subscript[u, xx])+(Subscript[u, yy])), u(x,y,t=0)=xy(1-x)(1-y) on the [0,1]x[0,1] unit square, with zero temperature on edges

Neumann BVP with  edge discontinuity

(Subscript[u, t])=k ((Subscript[u, xx])+(Subscript[u, yy])), u(x,y,t=0)=100 on the [0,1]x[0,1] unit square, with zero temperature on x=0, x=1 vertical edges, (Subscript[u, y])(x,y=0,t)=0, (Subscript[u, y])(x,y=1,t)=0

Neumann BVP with no edge discontinuity

(Subscript[u, t])=k ((Subscript[u, xx])+(Subscript[u, yy])), u(x,y,t=0)=xy(1-x)(1-y) on the [0,1]x[0,1] unit square, , (Subscript[u, x])(x=0,y,t)=0, (Subscript[u, x])(x=1,y,t)=0,(Subscript[u, y])(x,y=0,t)=0, (Subscript[u, y])(x,y=1,t)=0