# Need an explanation of setting Boundary Condition in pdepe (PDE Solver)

I am trying to solve the Advection-Diffusion equation using pdepe (PDE solver) in Matlab. I am not clear why we are writing pl=cl-1.0 for setting boundary condition at $x=0$. At left boundary, I am setting C(0,t)=1 and C(L,t)=0.1.

I need an explanation of it.

clear
close all
%P(1)=1;
P(2)=1;
L=0.01;
maxt=40;
m=0;
t=linspace(0,maxt,100);
x=linspace(0,L,50);
sol=pdepe(m,@PDEfun,@ICfun,@BCfun,x,t,[],P);
c=sol;
figure(1)
surf(x,t,c);
xlabel('distance x')
ylabel('time t')
zlabel('species c')
figure(2)
hold all
for n=linspace(1,length(t),10)
plot(x/L,(c(n,:)))

end
%legend([t = 1], ['t'=length(t)]);
xlabel('x/L')
ylabel('C(x,t)/C0')
grid on;

%.........................................
function [g,f,s]=PDEfun(x,t,c,dcdx,P)
D=0.000001;
k=0;%-0.0167;
U=0;%.001;
g=1;
f=D.*dcdx;
s=-(U*dcdx)+(k*c);
end
%..................................
function c0=ICfun(x,P)
c0=1.0;
end
%................................
function [p1,q1,pr,qr]=BCfun(x1,c1,xr,cr,t,P)
%c0=P(2);
p1=c1-1.0;   q1=0;   pr=cr-0.1;   qr=0;
end

• Did you look at equation 1-5 in the documentation (mathworks.com/help/matlab/ref/pdepe.html)? With $q=0$, that equation for the form of the BC is $p=0$., e.g. $c-1$. – Bill Greene Jul 16 '18 at 9:52
• Yes, I have seen but had some confusion. p = 0 means c −1 = 0 => c = 1 at left boundary. Am I right? – Raj Jul 16 '18 at 23:49