how can I add complex boundary conditions to pdepe functions?

I am trying to solve a following problem: dq(x,t)/dt=D*d/dx(dq(x,t)/dx)
with initial conditions: q(x,0)=0 and boundary conditions: dq(0,t)/dx=0 q(x,t)=f(cs) (for example linear function A*cs) B*D*dq(x,t)/dx=k*(cc-cs)
where cc is a concentration dependent on time and it is changing with time
My code (example constants) is as follows: function [c,f]=func1(x,t,q,Dqdx) c=1; D=5; f=D*Dqdx;
function q0=init(x) q0=0;
function [p1,q1,pr,qr]=bound(x1,u1,xr,ur,t) %I don't know where I need to put this: q(x,t)=f(cs) (for example linear function A*cs) p1=0; q1=1; B=10; cc=linspace(0,1,500); %should i put it here? or in main function? cs=linspace(0,0.1,50); pr=iso(cc,cs); % I am sure that it is not ok qr=B; % this one too
function y=iso(cc,cs) kf=10; y=kf.*(cc-cs);
I appreciate any help

 Accepted Answer

A boundary condition of the form dq/dx=0 is set as
p=0 ; q=1 ;
a boundary condition of the form q=f(cs) is set as
p=u-f(cs); q=0;
a boundary condition of the form B*D*dq/dx=k*(cc-cs) is set as
p=-k*(cc-cs); q=B;
Best wishes
Torsten.

2 Comments

It works. Thank you very much :)
I have another problem with this function? I am trying to estimate D coefficient. I was trying with lsqcurvefit and fminserach, however it doesn't work. The pdepe results are not the function and I cannot estimate coefficient in pdefunc? Thanks for any help.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 9 Apr 2015

Commented:

on 15 Apr 2015

Community Treasure Hunt

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

Start Hunting!