Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
assigning initial conditions on PDE solver?

Subject: assigning initial conditions on PDE solver?

From: Christian Abegglen

Date: 9 May, 2006 06:08:32

Message: 1 of 6

Hi
I'd like to model adsorption of a substance onto activated carbon,
using the homogenous surface diffusion model. This model uses a
partial differential equation:
dq/dt = K/r^2 d/dr(r^2 dq/dr)

I can solve this equation easily using pdepe. In the next step, I'd
like to solve this equation in a loop, where the calculated end-state
(q(x, t_end)) should be used as new initial condition.

However, I can't use a vector as initial condition. In the newsgroups
I found exactly my problem. Unfortunately I don't fully understand
its solution, how to use pdeval...
anonymissy, "assigning initial conditions on PDE solver?" #, 11 Mar 2004 12:52 am </WebX?50@@.eed2dac>


I tried the following:

sol = pdepe(m, @pdehsdm, @pdehsdmic, @pdehsdmbc, x, t, [], q_old)
...
function q0 = pdehsdmic(m, x, q_old)
q0 = pdeval(m, x, q_old, xout);

where q_old is a row vector q(t_end, x) and x = linspace(0,R,10).

I know that q0 is a matrix with [q_old, dq_old/dx], but I don't get
to run my program.

Help will be greatly appreciated.

Thanks in advance

Christian

Subject: assigning initial conditions on PDE solver?

From: Vassili

Date: 15 May, 2006 05:52:41

Message: 2 of 6

Christian Abegglen wrote:
>
>
> Hi
> I'd like to model adsorption of a substance onto activated carbon,
> using the homogenous surface diffusion model. This model uses a
> partial differential equation:
> dq/dt = K/r^2 d/dr(r^2 dq/dr)
>
> I can solve this equation easily using pdepe. In the next step, I'd
> like to solve this equation in a loop, where the calculated
> end-state
> (q(x, t_end)) should be used as new initial condition.
>
> However, I can't use a vector as initial condition. In the
> newsgroups
> I found exactly my problem. Unfortunately I don't fully understand
> its solution, how to use pdeval...
> <a href="/WebX?50@@.eed2dac">anonymissy, "assigning initial
conditions on PDE solver?" #, 11 Mar 2004 12:52 am</a>
>
>
>
> I tried the following:
>
> sol = pdepe(m, @pdehsdm, @pdehsdmic, @pdehsdmbc, x, t, [], q_old)
> ...
> function q0 = pdehsdmic(m, x, q_old)
> q0 = pdeval(m, x, q_old, xout);
>
> where q_old is a row vector q(t_end, x) and x = linspace(0,R,10).
>
> I know that q0 is a matrix with [q_old, dq_old/dx], but I don't get
> to run my program.
>
> Help will be greatly appreciated.
>
> Thanks in advance
>
> Christian

You are right, in fact one needs to specify initial values only in
mesh nodes, therefore a vector should have been sufficient.

For second etc. runs of your loop
it is possible to define INIFUN via interpolation:

let x = mesh nodes, xx arbitrary point(s) from (0,R)
v = q(t_end, x) %your vector same size as x

function qini=inifun(xx,v,x)
qini=interp1(x,v,xx);

It is interesting to find out whether pdepe really needs any xx
different from x. If no, instead of interp1 you could simply write

qini=v;

did you try this?

Subject: assigning initial conditions on PDE solver?

From: Peiwen Lau

Date: 5 Mar, 2013 02:35:08

Message: 3 of 6

Hi Christian. Just wonder if you managed to solve the model using pdepe. I'm working on the same problem, and perhaps we can help each other out. An example of assigning a vector as the initial condition is as follows:
function u0 = pdex4ic(x)
global C0
u0= [0;C0];
end
if you'd like to assign the initial condition as a function of x, you can use the if..else function in matlab as well.

One question though, how did you manage to solve for the original pde? I'm stuck at defining the boundary equation, at r=R, D*dq/dr=kf(C-Cf), which type of approach did you use to solve for it? Help is very much appreciated. Thanks.

Regards,
Pei Wen

"Christian Abegglen" <cabegglen@yahoo.com> wrote in message <ef34907.-1@webx.raydaftYaTP>...
> Hi
> I'd like to model adsorption of a substance onto activated carbon,
> using the homogenous surface diffusion model. This model uses a
> partial differential equation:
> dq/dt = K/r^2 d/dr(r^2 dq/dr)
>
> I can solve this equation easily using pdepe. In the next step, I'd
> like to solve this equation in a loop, where the calculated end-state
> (q(x, t_end)) should be used as new initial condition.
>
> However, I can't use a vector as initial condition. In the newsgroups
> I found exactly my problem. Unfortunately I don't fully understand
> its solution, how to use pdeval...
> anonymissy, "assigning initial conditions on PDE solver?" #, 11 Mar 2004 12:52 am </WebX?50@@.eed2dac>
>
>
> I tried the following:
>
> sol = pdepe(m, @pdehsdm, @pdehsdmic, @pdehsdmbc, x, t, [], q_old)
> ...
> function q0 = pdehsdmic(m, x, q_old)
> q0 = pdeval(m, x, q_old, xout);
>
> where q_old is a row vector q(t_end, x) and x = linspace(0,R,10).
>
> I know that q0 is a matrix with [q_old, dq_old/dx], but I don't get
> to run my program.
>
> Help will be greatly appreciated.
>
> Thanks in advance
>
> Christian

Subject: assigning initial conditions on PDE solver?

From: Torsten

Date: 5 Mar, 2013 07:22:09

Message: 4 of 6

>
> One question though, how did you manage to solve for the original pde? I'm stuck at defining the boundary equation, at r=R, D*dq/dr=kf(C-Cf), which type of approach did you use to solve for it? Help is very much appreciated. Thanks.
>
> Regards,
> Pei Wen

If you set
f=D*DuDx
in pdex1pde,
you will have to set
qr=1;
pr=-kf*(ur-Cf);
in pdex1bc.

Best wishes
Torsten.

Subject: assigning initial conditions on PDE solver?

From: Torsten

Date: 5 Mar, 2013 09:10:08

Message: 5 of 6

"Torsten" wrote in message <kh46f1$r9u$1@newscl01ah.mathworks.com>...
> >
> > One question though, how did you manage to solve for the original pde? I'm stuck at defining the boundary equation, at r=R, D*dq/dr=kf(C-Cf), which type of approach did you use to solve for it? Help is very much appreciated. Thanks.
> >
> > Regards,
> > Pei Wen
>
> If you set
> f=D*DuDx
> in pdex1pde,
> you will have to set
> qr=1;
> pr=-kf*(ur-Cf);
> in pdex1bc.
>
> Best wishes
> Torsten.

I guess you meant
"at r=R, D*dq/dr=kf(q-Cf)"
instead of
"at r=R, D*dq/dr=kf(C-Cf)".
If not, you will have to explain what C is (assuming that kf and Cf are constants).

Best wishes
Torsten.

Subject: assigning initial conditions on PDE solver?

From: gunesh

Date: 5 Apr, 2013 15:26:06

Message: 6 of 6

Vassili <O@K.all> wrote in message <ef34907.0@webx.raydaftYaTP>...
> Christian Abegglen wrote:
> >
> >
> > Hi
> > I'd like to model adsorption of a substance onto activated carbon,
> > using the homogenous surface diffusion model. This model uses a
> > partial differential equation:
> > dq/dt = K/r^2 d/dr(r^2 dq/dr)
> >
> > I can solve this equation easily using pdepe. In the next step, I'd
> > like to solve this equation in a loop, where the calculated
> > end-state
> > (q(x, t_end)) should be used as new initial condition.
> >
> > However, I can't use a vector as initial condition. In the
> > newsgroups
> > I found exactly my problem. Unfortunately I don't fully understand
> > its solution, how to use pdeval...
> > <a href="/WebX?50@@.eed2dac">anonymissy, "assigning initial
> conditions on PDE solver?" #, 11 Mar 2004 12:52 am</a>
> >
> >
> >
> > I tried the following:
> >
> > sol = pdepe(m, @pdehsdm, @pdehsdmic, @pdehsdmbc, x, t, [], q_old)
> > ...
> > function q0 = pdehsdmic(m, x, q_old)
> > q0 = pdeval(m, x, q_old, xout);
> >
> > where q_old is a row vector q(t_end, x) and x = linspace(0,R,10).
> >
> > I know that q0 is a matrix with [q_old, dq_old/dx], but I don't get
> > to run my program.
> >
> > Help will be greatly appreciated.
> >
> > Thanks in advance
> >
> > Christian
>
> You are right, in fact one needs to specify initial values only in
> mesh nodes, therefore a vector should have been sufficient.
>
> For second etc. runs of your loop
> it is possible to define INIFUN via interpolation:
>
> let x = mesh nodes, xx arbitrary point(s) from (0,R)
> v = q(t_end, x) %your vector same size as x
>
> function qini=inifun(xx,v,x)
> qini=interp1(x,v,xx);
>
> It is interesting to find out whether pdepe really needs any xx
> different from x. If no, instead of interp1 you could simply write
>
> qini=v;
>
> did you try this?

Hi Vassili,

I am trying the method you recommended but I am struggling in parsing the data to the icfun function. Could you please explain how the icfun function could be called with the multiple input variables.

Thanks

Gunesh

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us