In: Advanced Math
Find the finite-difference solution of the heat-conduction
problem
PDE: ut = uxx 0 < x < 1, 0 < t < 1
BCs:
⇢
u(0, t) = 0
ux(1, t) = 0
0 < t < 1
IC: u(x, 0) = sin(pi x) 0 x 1
for t = 0.005, 0.010, 0.015 by the explicit method. Assume
solution:
function [y]=pdeeq()
format long;
h=0.1;
k=0.005;
l=k/(h^2);
x=0:h:1;
t=0:k:0.015;
for i=1:length(x)
u(i,1)=sin(pi*x(i));
end
for i=1:length(t)
u(1,i)=0;
u(length(x),i)=0;
end
for j=1:length(t)-1
for i=2:length(x)-1
u(i,j+1)=l*(u(i+1,j)+u(i-1,j))+(1-2*l)*u(i,j);
end
end
disp(u);
Solution:
t=0 t=0.005 t=0.010 t=0.015
0
0
0
0
0.309016994374947
0.293892626146237 0.279508497187474
0.265828377610012
0.587785252292473
0.559016994374947 0.531656755220025
0.505635621484342
0.809016994374947
0.769420884293813 0.731762745781211
0.695947727757254
0.951056516295154
0.904508497187474 0.860238700294483
0.818135621484342
1.000000000000000
0.951056516295154 0.904508497187474
0.860238700294484
0.951056516295154
0.904508497187474 0.860238700294484
0.818135621484342
0.809016994374947
0.769420884293814 0.731762745781211
0.695947727757254
0.587785252292473
0.559016994374947 0.531656755220025
0.505635621484342
0.309016994374948
0.293892626146237 0.279508497187474
0.265828377610013
0
0
0
0