MATLAB: Pdepe the problem of negative concentrations

MATLABnegative concentrationspdepe

pdepe the problem of negative concentrations.
May be a bit stupid question,
Assume that we have the simplest form of the diffusion equation
dC(x,t)/dt = D * d2C(x,t)/dx2
with initial conditions C(x,0) = C0
and Neumann boundary conditions (representing for example, consumption of the ions from the electrode): – left side (x=0), no-flux: dC(0,t)/dx = 0 ==> pl = 0; ql = 1 – right side (x=L), constant current flux: dC(L,t)/dx = I/(F*A) ==> pr = I/(F*A); qr = 1 where I is applied constant current; F is Faraday number; A is the electrode surface. So, I/(F*A) = const.
When I run the simulation at some moment I've got the negative values of the concentrations C(x,t) at the whole distance of the electrode. This solution is definitely non-physical.
How can I solve the problem of negative concentrations within pdepe? Is it possible? (may be there are some methods like changing of the boundary conditions when C(x,t) reaches 0 at the right boundary, assign the "negative concentrations" 0 (like C(x,t)=0) after the simulation, etc.)
Thank you very much for your answer and advice beforehand,
Sincerely,
Alexander Ledovskikh

Best Answer

In this case, pr and qr must be defined as
qr = 1
pr = -D_Li*I/(F*A)
Best wishes
Torsten.