Can you use a changing boundary condition in pdepe?

2 views (last 30 days)
I'm trying to set up a pdepe plot that for lower values of t, the graphs cross the x-axis and for higher values of t, the graphs go to zero. Does anyone know how I can achieve this? This is the code I have at the moment but all of the graphs are going to zero:
function pdex1
m = 0;
x = linspace(0,1,20);
t = linspace(0,20,50);
hold on
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
C = sol(:,:,1);
hold on
plot(x,C(1,:));
plot(x,C(4,:));
plot(x,C(10,:));
plot(x,C(15,:));
plot(x,C(20,:));
plot(x,C(25,:));
plot(x,C(30,:));
axis([0 1 0 1])
% --------------------------------------------------------------
function [c,f,s] = pdex1pde(x,t,u,DCDx)
L = 0.1;
Dg = 5.2e-6;
A = L^2/Dg;
c = A;
f = DCDx;
s = 0;
end
% --------------------------------------------------------------
function C0 = pdex1ic(z)
C0 = 0;
end
% --------------------------------------------------------------
function [pl,ql,pr,qr] = pdex1bc(xl,Cl,xr,Cr,t)
pl = 0;
ql = 1;
pr = Cr - 1;
qr = 0;
end
end
  1 Comment
Tom
Tom on 9 Jul 2012
Can you explain more about the graphs crossing the x axis? Since the left hand boundary is set to 0 flux, the right hand boundary is set to 1, and the initial condition is 0, there is no reason for any results to be negative, unless I have misunderstood?

Sign in to comment.

Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!