MATLAB: PDEPE function

pdepe diffusion nonlinear

Hello everyone, I would like to use pdepe for solving a heat equation 1D space, so it looks good. But I don't really understand where the diffusion coefficient is ?
I would like to solve : (1)–> du/dt = d/dx(D(u) du/dx) with D(u) the non linear diffusion coefficient function of u. Is it possible to put D(u) at this location in the equation (1)?
Thanks to the community. 🙂

Best Answer

Yes it is possible in pdefun :)
Look at example:
function diffusion
m = 0;
x = linspace(0,1,20);
t = linspace(0,2,5);
sol = pdepe(m,@eqtn,@ic,@bc,x,t);
u = sol(:,:,1);
figure;
surf(x,t,u);
xlabel('Distance x');
ylabel('Time t');
% --------------------------------------------------------------------------



function [c,f,s] = eqtn(x,t,u,DuDx)
c = 1;
f = Dfsn(u)*DuDx;
s = 0;
% --------------------------------------------------------------------------
function u0 = ic(x)
u0 = 1:length(x);
% --------------------------------------------------------------------------
function [pl,ql,pr,qr] = bc(xl,ul,xr,ur,t)
pl = ul;
ql = 2;
pr = ur;
qr = 2;
% --------------------------------------------------------------------------
function d = Dfsn(u)
d = sqrt(u+1);
Where Dfsn is your non linear diffusion coefficient function.