MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: trouble with NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63709] Re: trouble with NDSolve
  • From: dh <dh at metrohm.ch>
  • Date: Tue, 10 Jan 2006 04:50:35 -0500 (EST)
  • References: <dplhgq$eio$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Lahm,
your formulation of the problem has some weak points.
1) the sink term is not a boundary condition, but a term of the
differential equation
2) In a numerical solution, you can not have a infinitely thin sink, you
must give it a certain width.
3) From what you write, it is not clear what the boundary condition on
the forth boundary is. Is it a wall with no diffusion perpendicular to
the wall, or is x extending to -1?
4) Are you interested in the temporal evolution? This will heavily
depend on the initial values near the sink. In your description this is
missing. It is actually contradictory because youe specify c[t=0]=1 and 
c=0 at the sink. On the other hand, if you only want the steady state, 
it is not
important.

To fix this:
1) to ensure that we have c=0 inside the sink, we can add a flow term to
the diff-equation that gives a large negative flow if the concentration
is different from zero. E.g. Add on the right side:
-10^3 If[Abs[x] < 0.1 && Abs[y] < 0.1, f[x, y, t], 0]
Here we assumed a rather large sink, but it is better first to make
things work for a large sink, because you may encounter numerical
problemsn for sinks too small.
If you observe a concentration different from zero inside the sink, you
may increase the factor 10.
2) Try first with a large sink and then decrease the size until you get
numerical problems.
3) Specify the boundary
4) If you want to model temporal behaviour, you must specify the initial
values close to the sink in a numerical consistent way, e.g. jumps would
  give infinite values for the flow. If you are only interested in the
final steady steat, it does not matter.

Here is an example, assuming that the fourth boundary is an inpenetrable
wall at x=0 and the initial conditions are  f[x,y,0]==1. :

eq = {D[f[x, y, t], t] == D[f[x, y, t], {x, 2}] + D[f[x, y, t], {y, 2}]-
           10^3 If[Abs[x] < 0.1 && Abs[y] < 0.1,
       f[x, y, t], 0],
       f[x, y, 0] == 1,
       f[x, -1, t] == 1,
       f[x, 1, t] == 1,
       f[1, y, t] == 1,
       Derivative[1, 0, 0][f][0, y, t] == 0};
fun = f /. NDSolve[eq, f, {x, 0, 1}, {y, -1, 1}, {t, 0, 1}][[1]]
Plot3D[fun[x, y, 1], {x, 0, 1}, {y, -1, 1},
       ViewPoint -> {-2.488, -1.585, 1.659}, PlotRange -> All,
       PlotPoints -> 50]

Daniel

lahm wrote:
> i have trouble with solving a diffusion problem with NDSolve. I would like to get a 2D concentration profile using second Fick's law dc/dt=d2c/dx2 + d2c/dy2. c is concentration and is function of t,x and y. The initial condition is concentration=1 everywhere. The boundary conditions are c=1 for x=1, y=1 and y=-1. On x=0, however, the concentration is 0, but only for -0.01<y<0.01, the other part of x=0 acts neutral, is neither a sink nor an inlet, concentration therefore is determined by the sink and the boundaries. Now when I try to imput that c=0 only at a part of x=0,  I get the message that boundary condition is not specified on a single edge of the boundary of the computational domain. NDSolve::bcedge: I tried several different approaches, but all of them have failed. There's always something wrong so mathematica always encounters some problem.  I can't make only one part of the boundary work as a sink an the other to be neutral. Please help!
> 


  • Prev by Date: Re: TraceScan
  • Next by Date: Re: Puzzle Challenge
  • Previous by thread: Re: trouble with NDSolve
  • Next by thread: exif jpeg info files