# Understanding how to solve DAE

I am solving the following pde that is discretized in space using method of lines, in MATLAB using ode15s.

$$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2}-v\frac{\partial C}{\partial x}$$ with initial condition $$c(x,0) = 4000$$ and with Dirichlet boundary condition

$$C(x=0,t>0) = 4100$$

Neumann boundary condition $$\frac{\partial C}{\partial x}=0\text{ at } x=L ; t>0.$$

function DiffusionConvectionMATLAB
format short
global D
m = 0;
x = linspace(0,60,10);
t = 0.1:0.1:2;
D = 900;
sol = pdepe(m,@pdefun,@icfun,@bcfun,x,t)
function [g,f,s] = pdefun(x,t,c,DcDx)
v = 200;
g = 1;
f = D*DcDx;
s = -v*DcDx;
end

function c0 = icfun(x)
c0 = 4000;
end

function [pl,ql,pr,qr] = bcfun(xl,cl,xr,cr,t)
pl = cl-4100;
ql = 0;
pr = 0;
qr = 1;
end
end


From what I understand, the above pde is solved as a differential algebraic equation(DAE) in MATLAB using BDF solvers.

Could someone explain the actual steps involved in solving the above transport equation as a DAE? I would like to understand and code it up myself.

• As far as I see, pdepe is for solving parabolic-elliptic PDEs in 1d. Where do you see that its solving the equation as dae? – VorKir Jan 6 at 20:21
• @VorKir It is mentioned towards the end of the documentation provided in this link – Natasha Jan 7 at 5:22
• There is an article about ode15s. Also see p. 481 of "Solving Ordinary Differential Equations II: Stiff and Differential-Algebraic Problems" – homocomputeris Jan 11 at 13:06