I was trying to solve a very simple pde with matlab pdepe solver . du/dt=D(d2u/dr2+1/r(du/dr)+0.01, IC=0.1 and BC: du/dr=0 at 0 and 1. I set it to solve for 5 spatial grid points while allowing the source term (0.01) at the 5th grid point only and for the rest it is zero . Even though my diffusion coefficient D=0 , why do i still get a rise of U at the 4th grid point (figure 1) . I did the same with method of lines and there were no increase in the value of U at the 4th grid point for the similar condition (figure 2). i have added the code here and also the result. Can anyone tell me where i did the mistake in pdepe ? why diffusion is occurring between the 5th and 4th grid ?
if truefunction pdexm = 1; % cyndrical coordinate
x = linspace(1,5,5); % space grid
t = linspace(0,20,1000);% time grid
opts=odeset('MaxStep', 0.4);sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t,opts);u = sol(:,:,1);figure% A time plot of u
plot(t,u(:,:,1)); xlabel('Distance x')ylabel('Time t')endif true % -------------description of the function
function [c,f,s] = pdex1pde(x,t,u,DuDx)D=0; % diffusion coefficient
c = 1;f =D*DuDx; if (x>4) s = 0.01;elses=0;endendif true if true
% ————-initial condition function u0 = pdex1ic(x) u0 = 0.1; end
endif true % ------- no flux boudary condition
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)pl = 0;ql = 1;pr =0;qr = 1;end
Best Answer