MATLAB: Advection-dominant 1D advection-diffusion equation

pdepdepe

I'm trying to solve the following 1D PDE of an advection-diffusion equation:
for , and
I used the pdepe function, here's the code:
function c = lfaF2
para.Ao = 10^-5; % Ao
para.DA = 10^-6; % D
para.L = 40;
para.T = 180;
para.dx = 0.1; % x discretization step
para.dt = 0.1; % t discretization step
c.x = 0:para.dx:para.L;
c.t = 0:para.dt:para.T;
m = 0;
fun = @(x,t,u,dudx) lfapde(x,t,u,dudx,para);
bc = @(xl,ul,xr,ur,t) lfabc(xl,ul,xr,ur,t,para);
c.A = pdepe(m,fun,@lfaic,bc,c.x,c.t);
c.surf = surf(c.x,c.t,c.A,'LineStyle','none');
title('Flow')
xlabel('Distance (mm)')
ylabel('Time (s)')
bar = colorbar;
bar.Label.String = 'Concentration (M)';
end
function [c,f,s] = lfapde(x,t,u,dudx,para)
c = 1;
f = para.DA*dudx;
v = para.L/para.T;
s = -v*dudx;
end
function u0 = lfaic(x)
u0 = 0;
end
function [pl,ql,pr,qr] = lfabc(xl,ul,xr,ur,t,para)
pl = ul-para.Ao;
ql = 0;
pr = 0;
qr = 1;
end
The code works fine for or but when and , I get spurious oscillatory behaviors:
This is usually seen when numerically solving advection-diffusion equations when the Peclet number, (advection dominant). I have two questions:
1) Why does affect the stability of the solution when it is not in the Peclet number formula?
2) How can I solve such a problem in Matlab without reducing the distance step size?

Best Answer

I think a step change in A0 is just too severe for the numerics to handle correctly once it gets to a certain size. Instead of implementing it as an instantaneous step change you might consider feeding it in more gradually in time. For example you could implement it as A0*(1 - exp(-t/2)) or similar. With this it would take about 5 or 6 seconds to get up to what is effectively its full value.
Just a suggestion!
Related Question