From: Pham Duc Dung on
Thanks for sharing
------------------
[url=http://funwares.com/prostate-massage/]Prostate massage[/url]
[url=http://www.escortincontriitalia.com/Escort_Girls/Rimini/]Escort Rimini[/url]
From: Dave Esc on
Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote in message <510568279.19891.1279004055575.JavaMail.root(a)gallium.mathforum.org>...
> > Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> > in message
> > <1443157399.21287.1277794843549.JavaMail.root(a)gallium.
> > mathforum.org>...
> > > > I'm trying to get a numerical solution for the
> > mass
> > > > diffusion from a sphere into a fluid of finite
> > > > volume, analagous to thermal diffusion in the
> > cooling
> > > > of a sphere in a well-stirred solution. The
> > problem I
> > > > am having is that I cannot apply the right
> > boundary
> > > > condition in pdepe to represent flux from the
> > sphere
> > > > into the surrounding fluid, which is initially
> > free
> > > > of diffusing material.
> > >
> > > This flux is usually represented by a boundary
> > condition
> > > of the kind
> > > -D*dc/dx = beta*(c-c_inf)
> > > (D: diffusion coefficient,
> > > beta: mass transfer coefficient,
> > > c_inf : concentration in the surrounding fluid)
> > >
> > > Why can't you apply this condition ?
> > >
> >
> > Hi Torsten
> >
> > I'm trying to apply the above condition using pdepe
> > solver but c_inf has to be updated at each time step.
> > I have tried to form a loop where at first c_inf = 0
> > and then the pde solver is used over a time step dt
> > subject to the boundary condition you prescribe, then
> > c_inf is updated subject to dc_inf/dt = J*S/V where J
> > is flux across sphere surface area S into surrounding
> > fluid volume V. This value of c_inf is then to be
> > used in the next step of the pdepe and continues for
> > the required time span. The trouble I am having is
> > using the latest solution values of the pde (ie c
> > distribution within the sphere). Using this method I
> > guess I would effectively have to update the inital
> > conditions each time step?
> > Here is the code that I have attempted to use but
> > will only give solutions for the first time step:
> >
> > function [c,f,s] = pde1(x,t,u,DuDx)
> > c = 1;
> > f = DuDx;
> > s = 0;
> > %---------------------------------------------------
> > function u0 = pde1ic(x)
> > u0 = 0.0005;
> > %---------------------------------------------------
> > function [pl,ql,pr,qr] = pde1bc(xl,ul,xr,ur,t)
> > global c_inf
> > betaD = 0.02;
> > pl = 0;
> > ql = 1;
> > pr = betaD*(ur - c_inf);
> > qr = 1;
> > %---------------------------------------------------
> > global c_inf
> > R0 = 0.0015;
> > S = 2.83E-05;
> > V = 0.000001;
> > A = R0*S/V;
> > dx = 0.02;
> > tau = 1.7556;
> > dt = tau/99;
> > tstep = (tau/dt)+1;
> > c_inf = zeros(1,tstep);
> > for k = 1:tstep;
> > m = 2;
> > x = 0:.02:1;
> > t = [0 dt/2 dt];
> > sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
>
> Use here
> u(:,:,k) = sol(:,:,1);
> c_inf = c_inf - A*dt*(u(3,51,k)-u(3,50,k))/dx;
> end;
>
> c_inf should be a scalar variable for use in pde1bc.
>
> > u(:,:,k) = sol(:,:,end);
> > c_inf(1,:) =
> > :) = c_inf(1,k)-A*dt*((u(3,51,k)-u(3,50,k))/dx);
> > end;
> > %---------------------------------------------------
> >
> > The problem seems to be getting the pde to use
> > updated u, for each step of the loop the pde reverts
> > back to the ic. u0=0.0005 when I want it to use the
> > latest values of u obtained.
> > Any idea how to do this or how to resolve the
> > problem?
> > Regards
>
> Make _u_ and _k_ global variables, initialize u = 0.0005 before the first call to pdepe and use u(3,:,k) in pde1ic at time step k to set up u0.
>
> Best wishes
> Torsten.

Thanks for your response Torsten

I have changed c_inf to a scalar as you suggested. Is there anyway I would be able to all c_inf values as what I'm really after is a release profile showing c_inf with time?

I have initialised u by using u = 0.0005*ones(3,51,100) before the for loop and set up pde1ic as follows:

function u0 = pde1ic(x)
global c_inf u k
u0 = u(3,:,k);

but I get the error:

??? Attempted to access c(2); index out of bounds because numel(c)=1.

Error in ==> pdepe at 242
if c(j) == 0

Error in ==> pde at 16
sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
---------------------------------------------------------------------------------------------------------

Do you know where I am going wrong?
Many Thanks.
From: Torsten Hennig on
> Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> in message
> <510568279.19891.1279004055575.JavaMail.root(a)gallium.m
> athforum.org>...
> > > Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de>
> wrote
> > > in message
> > >
> <1443157399.21287.1277794843549.JavaMail.root(a)gallium.
> > > mathforum.org>...
> > > > > I'm trying to get a numerical solution for
> the
> > > mass
> > > > > diffusion from a sphere into a fluid of
> finite
> > > > > volume, analagous to thermal diffusion in the
> > > cooling
> > > > > of a sphere in a well-stirred solution. The
> > > problem I
> > > > > am having is that I cannot apply the right
> > > boundary
> > > > > condition in pdepe to represent flux from the
> > > sphere
> > > > > into the surrounding fluid, which is
> initially
> > > free
> > > > > of diffusing material.
> > > >
> > > > This flux is usually represented by a boundary
> > > condition
> > > > of the kind
> > > > -D*dc/dx = beta*(c-c_inf)
> > > > (D: diffusion coefficient,
> > > > beta: mass transfer coefficient,
> > > > c_inf : concentration in the surrounding fluid)
> > > >
> > > > Why can't you apply this condition ?
> > > >
> > >
> > > Hi Torsten
> > >
> > > I'm trying to apply the above condition using
> pdepe
> > > solver but c_inf has to be updated at each time
> step.
> > > I have tried to form a loop where at first c_inf
> = 0
> > > and then the pde solver is used over a time step
> dt
> > > subject to the boundary condition you prescribe,
> then
> > > c_inf is updated subject to dc_inf/dt = J*S/V
> where J
> > > is flux across sphere surface area S into
> surrounding
> > > fluid volume V. This value of c_inf is then to be
> > > used in the next step of the pdepe and continues
> for
> > > the required time span. The trouble I am having
> is
> > > using the latest solution values of the pde (ie c
> > > distribution within the sphere). Using this
> method I
> > > guess I would effectively have to update the
> inital
> > > conditions each time step?
> > > Here is the code that I have attempted to use but
> > > will only give solutions for the first time step:
> > >
> > > function [c,f,s] = pde1(x,t,u,DuDx)
> > > c = 1;
> > > f = DuDx;
> > > s = 0;
> > >
> %---------------------------------------------------
> > > function u0 = pde1ic(x)
> > > u0 = 0.0005;
> > >
> %---------------------------------------------------
> > > function [pl,ql,pr,qr] = pde1bc(xl,ul,xr,ur,t)
> > > global c_inf
> > > betaD = 0.02;
> > > pl = 0;
> > > ql = 1;
> > > pr = betaD*(ur - c_inf);
> > > qr = 1;
> > >
> %---------------------------------------------------
> > > global c_inf
> > > R0 = 0.0015;
> > > S = 2.83E-05;
> > > V = 0.000001;
> > > A = R0*S/V;
> > > dx = 0.02;
> > > tau = 1.7556;
> > > dt = tau/99;
> > > tstep = (tau/dt)+1;
> > > c_inf = zeros(1,tstep);
> > > for k = 1:tstep;
> > > m = 2;
> > > x = 0:.02:1;
> > > t = [0 dt/2 dt];
> > > sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
> >
> > Use here
> > u(:,:,k) = sol(:,:,1);
> > c_inf = c_inf - A*dt*(u(3,51,k)-u(3,50,k))/dx;
> > end;
> >
> > c_inf should be a scalar variable for use in
> pde1bc.
> >
> > > u(:,:,k) = sol(:,:,end);
> > > c_inf(1,:) =
> > > :) = c_inf(1,k)-A*dt*((u(3,51,k)-u(3,50,k))/dx);
> > > end;
> > >
> %---------------------------------------------------
> > >
> > > The problem seems to be getting the pde to use
> > > updated u, for each step of the loop the pde
> reverts
> > > back to the ic. u0=0.0005 when I want it to use
> the
> > > latest values of u obtained.
> > > Any idea how to do this or how to resolve the
> > > problem?
> > > Regards
> >
> > Make _u_ and _k_ global variables, initialize u =
> 0.0005 before the first call to pdepe and use
> u(3,:,k) in pde1ic at time step k to set up u0.
> >
> > Best wishes
> > Torsten.
>
> Thanks for your response Torsten
>
> I have changed c_inf to a scalar as you suggested. Is
> there anyway I would be able to all c_inf values as
> what I'm really after is a release profile showing
> c_inf with time?
>

Of course. Define an array c_inf_array and set
c_inf_array(k) = c_inf in time step k.

> I have initialised u by using u =
> 0.0005*ones(3,51,100) before the for loop and set up
> pde1ic as follows:
>
> function u0 = pde1ic(x)
> global c_inf u k
> u0 = u(3,:,k);
>

pde1ic returns a scalar, not a vector.

Before a call to pdepe, initialize a variable _index_
in the calling program to 0 and declare _index_ to be a global variable.

Then try

function u0 = pde1ic(x)
global index c_inf u k
index = index + 1;
u0 = u(3,index,k);

I hope pde1ic is called for x(1) first, then x(2),..., then x(end). Otherwise you have to play how the
i-th call of pdepe to pde1ic corresponds to the
solution of u in the i-th grid point.

> but I get the error:
>
> ??? Attempted to access c(2); index out of bounds
> because numel(c)=1.
>
> Error in ==> pdepe at 242
> if c(j) == 0
>
> Error in ==> pde at 16
> sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
> ------------------------------------------------------
> ---------------------------------------------------
>
> Do you know where I am going wrong?
> Many Thanks.

Best wishes
Torsten.
From: Dave Esc on
Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote in message <1867042751.20626.1279014665946.JavaMail.root(a)gallium.mathforum.org>...
> > Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> > in message
> > <510568279.19891.1279004055575.JavaMail.root(a)gallium.m
> > athforum.org>...
> > > > Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de>
> > wrote
> > > > in message
> > > >
> > <1443157399.21287.1277794843549.JavaMail.root(a)gallium.
> > > > mathforum.org>...
> > > > > > I'm trying to get a numerical solution for
> > the
> > > > mass
> > > > > > diffusion from a sphere into a fluid of
> > finite
> > > > > > volume, analagous to thermal diffusion in the
> > > > cooling
> > > > > > of a sphere in a well-stirred solution. The
> > > > problem I
> > > > > > am having is that I cannot apply the right
> > > > boundary
> > > > > > condition in pdepe to represent flux from the
> > > > sphere
> > > > > > into the surrounding fluid, which is
> > initially
> > > > free
> > > > > > of diffusing material.
> > > > >
> > > > > This flux is usually represented by a boundary
> > > > condition
> > > > > of the kind
> > > > > -D*dc/dx = beta*(c-c_inf)
> > > > > (D: diffusion coefficient,
> > > > > beta: mass transfer coefficient,
> > > > > c_inf : concentration in the surrounding fluid)
> > > > >
> > > > > Why can't you apply this condition ?
> > > > >
> > > >
> > > > Hi Torsten
> > > >
> > > > I'm trying to apply the above condition using
> > pdepe
> > > > solver but c_inf has to be updated at each time
> > step.
> > > > I have tried to form a loop where at first c_inf
> > = 0
> > > > and then the pde solver is used over a time step
> > dt
> > > > subject to the boundary condition you prescribe,
> > then
> > > > c_inf is updated subject to dc_inf/dt = J*S/V
> > where J
> > > > is flux across sphere surface area S into
> > surrounding
> > > > fluid volume V. This value of c_inf is then to be
> > > > used in the next step of the pdepe and continues
> > for
> > > > the required time span. The trouble I am having
> > is
> > > > using the latest solution values of the pde (ie c
> > > > distribution within the sphere). Using this
> > method I
> > > > guess I would effectively have to update the
> > inital
> > > > conditions each time step?
> > > > Here is the code that I have attempted to use but
> > > > will only give solutions for the first time step:
> > > >
> > > > function [c,f,s] = pde1(x,t,u,DuDx)
> > > > c = 1;
> > > > f = DuDx;
> > > > s = 0;
> > > >
> > %---------------------------------------------------
> > > > function u0 = pde1ic(x)
> > > > u0 = 0.0005;
> > > >
> > %---------------------------------------------------
> > > > function [pl,ql,pr,qr] = pde1bc(xl,ul,xr,ur,t)
> > > > global c_inf
> > > > betaD = 0.02;
> > > > pl = 0;
> > > > ql = 1;
> > > > pr = betaD*(ur - c_inf);
> > > > qr = 1;
> > > >
> > %---------------------------------------------------
> > > > global c_inf
> > > > R0 = 0.0015;
> > > > S = 2.83E-05;
> > > > V = 0.000001;
> > > > A = R0*S/V;
> > > > dx = 0.02;
> > > > tau = 1.7556;
> > > > dt = tau/99;
> > > > tstep = (tau/dt)+1;
> > > > c_inf = zeros(1,tstep);
> > > > for k = 1:tstep;
> > > > m = 2;
> > > > x = 0:.02:1;
> > > > t = [0 dt/2 dt];
> > > > sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
> > >
> > > Use here
> > > u(:,:,k) = sol(:,:,1);
> > > c_inf = c_inf - A*dt*(u(3,51,k)-u(3,50,k))/dx;
> > > end;
> > >
> > > c_inf should be a scalar variable for use in
> > pde1bc.
> > >
> > > > u(:,:,k) = sol(:,:,end);
> > > > c_inf(1,:) =
> > > > :) = c_inf(1,k)-A*dt*((u(3,51,k)-u(3,50,k))/dx);
> > > > end;
> > > >
> > %---------------------------------------------------
> > > >
> > > > The problem seems to be getting the pde to use
> > > > updated u, for each step of the loop the pde
> > reverts
> > > > back to the ic. u0=0.0005 when I want it to use
> > the
> > > > latest values of u obtained.
> > > > Any idea how to do this or how to resolve the
> > > > problem?
> > > > Regards
> > >
> > > Make _u_ and _k_ global variables, initialize u =
> > 0.0005 before the first call to pdepe and use
> > u(3,:,k) in pde1ic at time step k to set up u0.
> > >
> > > Best wishes
> > > Torsten.
> >
> > Thanks for your response Torsten
> >
> > I have changed c_inf to a scalar as you suggested. Is
> > there anyway I would be able to all c_inf values as
> > what I'm really after is a release profile showing
> > c_inf with time?
> >
>
> Of course. Define an array c_inf_array and set
> c_inf_array(k) = c_inf in time step k.
>
> > I have initialised u by using u =
> > 0.0005*ones(3,51,100) before the for loop and set up
> > pde1ic as follows:
> >
> > function u0 = pde1ic(x)
> > global c_inf u k
> > u0 = u(3,:,k);
> >
>
> pde1ic returns a scalar, not a vector.
>
> Before a call to pdepe, initialize a variable _index_
> in the calling program to 0 and declare _index_ to be a global variable.
>
> Then try
>
> function u0 = pde1ic(x)
> global index c_inf u k
> index = index + 1;
> u0 = u(3,index,k);
>
> I hope pde1ic is called for x(1) first, then x(2),..., then x(end). Otherwise you have to play how the
> i-th call of pdepe to pde1ic corresponds to the
> solution of u in the i-th grid point.
>

>
> Best wishes
> Torsten.

Hi again

I defined the above terms as follows:

global c_inf u k index
..
..
..
c_inf = 0;
c_inf_array = zeros(100,1);
u = 0.0005*ones(3,51,100);
index = 0;
for k = 1:tstep;
m = 2;
x = 0:.02:1;
t = [0 dt/2 dt];
sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
u(:,:,k) = sol(:,:,1);
c_inf = c_inf - A*dt*(u(3,51,k)-u(3,50,k))/dx;
c_inf_array(k) = c_inf;
end;
%--------------------------------------------------------------------
function u0 = pde1ic(x)
global index c_inf u k
index = index + 1;
u0 = u(3,index,k);
%--------------------------------------------------------------------

but get error:

??? Attempted to access u(3,52,2); index out of bounds because size(u)=[3,51,100].

Error in ==> pde1ic at 4
u0 = u(3,index,k);
Error in ==> pdepe at 224
temp = feval(ic,xmesh(1),varargin{:});

Error in ==> pde at 18
sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);

I dont know how to terminate/set maximum value for _index_ and still keep u0 a scalar!
Please help.

Many Thanks
From: Torsten Hennig on
>
> Hi again
>
> I defined the above terms as follows:
>
> global c_inf u k index
> .
> .
> .
> c_inf = 0;
> c_inf_array = zeros(100,1);
> u = 0.0005*ones(3,51,100);
> index = 0;
> for k = 1:tstep;

Put index = 0 here (_inside_ instead of outside
the k-loop). I suspect pdepe already finished
one time step dt ; so index was 51 and has to be
reset to 0 for the next time step.

> m = 2;
> x = 0:.02:1;
> t = [0 dt/2 dt];
> sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
> u(:,:,k) = sol(:,:,1);
> c_inf = c_inf - A*dt*(u(3,51,k)-u(3,50,k))/dx;
> c_inf_array(k) = c_inf;
> end;
> %-----------------------------------------------------
> ---------------
> function u0 = pde1ic(x)
> global index c_inf u k
> index = index + 1;
> u0 = u(3,index,k);
> %-----------------------------------------------------
> ---------------
>
> but get error:
>
> ??? Attempted to access u(3,52,2); index out of
> bounds because size(u)=[3,51,100].
>
> Error in ==> pde1ic at 4
> u0 = u(3,index,k);
> Error in ==> pdepe at 224
> temp = feval(ic,xmesh(1),varargin{:});
>
> Error in ==> pde at 18
> sol = pdepe(m,@pde1,@pde1ic,@pde1bc,x,t);
>
> I dont know how to terminate/set maximum value for
> _index_ and still keep u0 a scalar!
> Please help.
>
> Many Thanks
>

Best wishes
Torsten.