Boundary condition in PDEPE function
Show older comments
Hi! I'm having some trouble implementing the boundary condition into the matlab PDEPE solver. The equations stand for bacterial density (B) and nutrient density (N):
dB/dt = D*d2B/dx2 - v*dB/dx + lambda*(N/(N+K))*B
dN/dt = D*d2N/dx2 - v*dN/dx - lambda*(N/(N+K))*B/Y
Shortly, the bacteria are seeded in a tube-shaped structure (in 1D, not in 3D). Then, an inflow of nutrients can enter from the left boundary. So the boundary condition are as follows:
At x=0 -------> flux(B)=0 and flux(N)=v*n_in
At x=L -------> flux(B)=0 and flux(N)=0
I'm quite sure that main script, equations and initial conditions are correct. My doubt is about the boundary conditions: is it correct the way I wrote them? I don't understand how to use the matlab equation p+q*f=0, although I've seen the examples on matlab's doc page and others forums.
This is my script:
% parameters
P.lambda=0.32; % [1/h]
P.K=0.1; % [mMoles]
P.Y=0.184; % [OD/mMoles]
P.n_in=2; % [mMoles]
P.v=1*(1e-4*3600); % [cm/h]
P.D=0.2*1e4*(1e-8*3600); % [cm2/h]
P.L=7; % [cm]
% time and space mesh
x=0:0.1:P.L;
t=0:0.1:100;
% pdepe solver
m=0;
eqn=@(x,t,u,dudx) sis_eqn(x,t,u,dudx,P);
ic=@(x) sis_ic(x,P);
bc=@(xl,ul,xr,ur,t) sis_bc(xl,ul,xr,ur,t,P);
sol=pdepe(m,eqn,ic,bc,x,t);
u1=sol(:,:,1);
u2=sol(:,:,2);
figure(1)
for i=1:5:length(t)
subplot 211, plot(x,u1(i,:),'-or')
axis([x(1) x(end) 0 5])
subplot 212, plot(x,u2(i,:),'-o')
axis([x(1) x(end) 0 P.v*P.n_in])
pause(0.2)
end
% function: equation
function [c,f,s]=sis_eqn(x,t,u,dudx,P)
c = [1;1];
f = [P.D;P.D].*dudx;
s = [-P.v*dudx(1)+P.lambda*(u(2)/(u(2)+P.K))*u(1) ; -P.v*dudx(2)-P.lambda*(u(2)/(u(2)+P.K))*u(1)/P.Y ];
end
% function: initial conditions
function u0=sis_ic(x,P)
u0=[0.01;0];
end
% function: boundary conditions
function [pl,ql,pr,qr]=sis_bc(xl,ul,xr,ur,t,P)
pl = [0;P.v*P.n_in];
ql = [-1;-1/P.D];
pr = [0;0];
qr = [-1;-1/P.D];
end
Answers (0)
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!