Hello,
I'm simulating the internal thermal and chemical dynamics of a fuel cell, using pdepe function (which is new to me). There are plenty of variables ( u1, u2, ..., un ) to be solved. However, I find that for each variable ui added, pdepe asks for boundary conditions (left and right) of ui, which I don't have sometimes.
For a simplified example, I don't know how to give boundary conditions of u2 for the following problem:
Its code is here (modified from MATLAB's example of pdepe):
function pde_example
m = 0;
x = linspace(0,1,20);
t = linspace(0,2,20);
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t);
u1 = sol(:,:,1);
u2 = sol(:,:,2);
figure(1)
surf(x,t,u1)
title('Solution of u1')
xlabel('Distance x')
ylabel('Time t')
figure(2)
plot(x,u1(end,:))
title('Solution of u1 at t = 2')
xlabel('Distance x')
ylabel('u1(x,2)')
figure(3)
surf(x,t,u2)
title('Solution of u2.')
xlabel('Distance x')
ylabel('Time t')
figure(4)
plot(x,u2(end,:))
title('Solution of u2 at t = 2')
xlabel('Distance x')
ylabel('u2(x,2)')
function [c,f,s] = pdex1pde(x,t,u,DuDx)
c = [pi^2;0];
f = [DuDx(1);0];
s = [0;u(2)-DuDx(1)];
function u0 = pdex1ic(x)
u0 = [sin(pi*x);pi*cos(pi*x)];
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
pl = [ul(1); ul(2)-pi*exp(-t)];
ql = [0;0];
pr = [pi*exp(-t); ur(2)+pi*exp(-t)];
qr = [1;0];
It seems that this code can get the appropriate solution of u2 only if boundary conditions of u2 is given (i.e. ul(2)-pi*exp(-t) and ur(2)+pi*exp(-t)), which is obtained manually. If it's true, it will be a disaster for my simulation. Or am I wrong? How to get the appropriate solutions without manual pre-calculation? Thanks a lot!