Notes Lecture
Notes Lecture
Lecture 5
References
% diffusion constant
global D
D = 0.001;
% domain
global dx
dx = 0.02; % step size in x dimension
dt = 0.1; % step size in t dimension
xmesh = -1:0.02:1; % domain in x
tmesh = 0:0.1:10; % domain in t
figure(1)
surf(tmesh,xmesh,sol_fd')
title('Finite differences')
xlabel('t')
ylabel('x')
zlabel('u(x,t)')
figure(2)
surf(tmesh,xmesh,sol_pdepe')
title('Matlab pdepe')
xlabel('t')
ylabel('x')
zlabel('u(x,t)')
global D
c = 1;
f = D * DuDx; % diffusion
s = 0; % homogeneous, no driving term
% --------------------------------------------------------------
function u0 = ic(x)
% Initial conditions function
global dx
u0 = (x==0)/dx; % delta impulse at center
% --------------------------------------------------------------
50
40
30
u(x,t)
20
10
0
1
0.5 10
8
0
6
-0.5 4
2
x -1 t
0
Matlab pdepe
50
40
30
u(x,t)
20
10
0
1
0.5 10
8
0
6
-0.5 4
2
x -1 t
0