How to solve a PDE where the boundary condition is an spatial ODE

I have a PDE which i need to solve to get both the spatial and time related results. However i am confused as to how to pose the problem in matlab especially with the boundary conditions. I have attached the problem so that it is clear what i am talking about. The initial condition for lambda at t=0 is 0. The boundary conditions (at x = 0 and at x = L) is N_lambda = 0. Can anyone help me out here in defining the problem in matlab. Thank you very much in advance

 Accepted Answer

I suggest you use the pdepe function to solve this PDE.
In PDE of the type you show, especially when the PDE represents a physical phenomenon, terms like your N_lambda are referred to as the "flux." pdepe makes it easy to define boundary conditions where the flux equals a specified value, e.g. zero.
pdepe requires you to create a function to define your PDE. For your example it would look something like this:
function [c,f,s] = pdeDefinition(x,t,lam,dlamdx)
epsi=1;
Vm=2;
DLam=3;
nd=4;
ip=5;
F=6;
c = epsi/Vm;
f = DLam/Vm*dlamdx - nd*ip/F;
s = S+r;
end
The boundary condition function, which you also have to write, would look something like this.
function [pl,ql,pr,qr] = bcFunc(xl,lam_l,xr,lam_r,t)
pl = 0;
ql = 1;
pr = 0;
qr = 1;
end

6 Comments

Thank you very much Mr. Greene. Since i am new to matlab, i am a bit slow in this. Just to make sure, in the BC functin p and q represent flux and lamda right? the input to this funtion is xl,xr,lam_l,lam_r --> Does this mean the strating and end point of the length and lamda values at these points? What is the most confusing for me is the BC function. Since there are only 2 BC for flux, i do not understand why there are 4 defined in the function.
Everything in the pdeDefinition function is clear. But if i am not wrong, the pdepe of matlab wants an m term doesnt it?
Read the documentation of "pdepe" and look at the examples provided. Then all your questions will be answered.
E.g. you would know that the boundary condition pdepe accepts is given by
pl + ql*f = 0 in the left boundary point,
pr + qr*f = 0 in the right boundary point.
where pl, ql and ql, qr are some meaningless expressions you have to specify and f is the flux function prescribed in "pdeDefinition".
So if you set
f = DLam/Vm*dlamdx - nd*ip/F
in "pdeDefinition", your boundary condition with pl = pr = 0 and ql = qr = 1
would read
0 + 1*(DLam/Vm*dlamdx - nd*ip/F) = 0
, thus
DLam/Vm*dlamdx - nd*ip/F = 0
And this is the boundary condition you wrote you want to prescribe.
Thank you very much for the detailed explaination. This clears all my questions. have a nice day.!
I have one last question. How can i pass some extra paramters in the PDEfunction ?
Regarding pdepe BC, this note I wrote several years ago might be useful.
Regarding the usage of pdepe in general, I strongly recommend starting with a simple PDE that you know the analytical solution to and experiment with that until you are comfortable with the syntax and options.
Thank you very much for the notes. I was able to solve the PDE with your provided method. The PDE gives a solution in time and space. What i am now looking for is to use the last row of the results (at t = tend of the pdepe) to another PDE as initial condition. Since the result of the first PDE is a vector of size (1*n), how can it be passed into the inital condition of another pdepe solver. How to do it? When i try to pass an array in IC it is always a scalar zero.
1st PDE
Solution : (1*n) array
Use Solution as Initial condition for 2nd PDE

Sign in to comment.

More Answers (0)

Products

Tags

Community Treasure Hunt

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

Start Hunting!