Steady State Solutions

In this Notebook we solve the PDE
u_t=u_xx
u(0,t)=T1
u(L,t)=T2
u(x,0)=0
We do this by finding the steady state solution us(x) and setting v=u-us, solving
v_t=v_xx
v(0,t)=0
v(L,t)=0
v(x,0)=-us(x)

Parameters

L=1;
T1=20;
T2=100;

Steady State Solution

us[x_]:=(T2-T1)/L*x+T1;

Fourier Series for -us(x)

Simplify[2/L*Integrate[-1*us[x]*Sin[n*π*x/L],{x,0,L}],Assumptions->n∈Integers]

b[n_]:=((40 (-1+5 (((-1))^n)))/(n π));

Construction of Solution

u[x_,t_,M_]:=Sum[b[n]*Sin[n*π*x/L]*Exp[-n^2*π^2*t/L^2],{n,1,M}]+us[x]

Plot of Solution at Different Times

M=100;

Plot[{u[x,.001,M],u[x,.1,M],u[x,.2,M],u[x,.3,M],u[x,.4,M],u[x,.5,M]},{x,0,L},PlotRange->{0,T2}]

Contour Plot

M=100;
T=1;
DensityPlot[u[x,t,M], {x, 0, L}, {t, 0, T}, PlotRange->{0,T2}, PlotLegends->Automatic, PlotPoints-> 30, FrameLabel->{"x","t"}, LabelStyle->Directive[Bold, Black, Medium],ColorFunction->"Rainbow"]

ContourPlot[u[x,t,M], {x, 0, L}, {t, 0, T}, PlotRange->{0,T2}, PlotLegends->Automatic, PlotPoints-> 30, FrameLabel->{"x","t"}, LabelStyle->Directive[Bold, Black, Medium],ColorFunction->"Rainbow"]

Animation of Solution

Animate[Plot[u[x,t,T],{x,0,L},PlotRange->{0,T2}],{t,0,1}]