       Re: Boundary conditions in NDSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg56818] Re: [mg56773] Boundary conditions in NDSolve
• From: Ramesh Raju Mudunuri <rameshrajum at gmail.com>
• Date: Fri, 6 May 2005 03:01:40 -0400 (EDT)
• References: <200505051003.GAA22073@smc.vnet.net>
• Reply-to: Ramesh Raju Mudunuri <rameshrajum at gmail.com>
• Sender: owner-wri-mathgroup at wolfram.com

Hi,
The present version of NDSolve handles linear BVPs (Boundary Value
Problem) well. Your BVP is non-linear. NDSolve is excellent for
Initial Value Problems. It is very good at handling parabolic and
hyperbolic PDEsl. We can use these features to solve non-linear BVPs
with NDSolve. Here I mention two such methods.
The first is the well known Shooting method, where we guess one or
more of the initial conditions and iterate using a non-linear solver
to get the boundary conditions right.For your problem, guess the value
of f at -L, and find the deviation of the solution at L. The following
function does that

fAtOne[s_?NumericQ]:=
Module[{f},
sol=f/.NDSolve[{f''[x]\[Equal]K^2*Sin[f[x]],f'[-L]\[Equal]A,
f[-L]\[Equal]s},f,{x,-L,L}][];
sol[L]-B]

Plot the function for different s to see where the roots are. It lets
us also know if there are multiple solutions. We can get a good guess
for FindRoot from the plot. For

A=-1; B=1; K=3; L=1

Plot[fAtOne[s],{s,-10,10}]

shows that there are atleast three solutions. The solutions can be
found easily as

Solution One

FindRoot[fAtOne[s],{s,-1}]
fAtOne[s]/.%
Plot[sol[x],{x,-L,L},PlotRange\[Rule]All]

Solution Two

FindRoot[fAtOne[s],{s,0}]
fAtOne[s]/.%
Plot[sol[x],{x,-L,L},PlotRange\[Rule]All]

Solution Three

FindRoot[fAtOne[s],{s,-4.1}]
fAtOne[s]/.%
p1=Plot[sol[x],{x,-L,L},PlotRange\[Rule]All]

In the second method, the same BVP can be posed as a steady state
version of a PDE (parabolic PDE in this case). Here we solve a PDE.
The method is more involved, and is problem dependent. However if the
physics of the problem is well known, it is usually not difficult to
construct a PDE. In case of multiple solutions, the initial conditions
determine the final steady state. Here is a solution corresponding to
solution Three above.

sol1 = f /.
NDSolve[{-4*Sin[f[x, t]]*D[f[x, t],
t] + D[f[x, t], x, x] ==
K^2*Sin[f[x, t]],
(D[f[x, t], x] /. x -> -L) == A,
f[L, t] == B, f[x, 0] ==
A*(x - L) + B}, f, {x, -L, L},
{t, 0, 2}][]
p2 = Plot[sol1[x, 2], {x, -L, L},
PlotRange -> All, PlotRange -> All]

It can be seen that either method gives the same solution.

Show[p1,p2]

Hope this helps,

Ramesh

On 5/5/05, YZ <z at ***.ohio-state.edu> wrote:
> Hello,
>
> when I NDSolve a 2nd order DE, I cant seem to give two boundary
> conditions at different point of an interval I am solving it on:
>
> NDSolve[{f''[x]==K^2*Sin[f[x]],f'[-L]==A, f[-L]==B},f,{x,-L,L}]
> produces good result, but i.e.
>
> NDSolve[{f''[x]==K^2*Sin[f[x]],f'[-L]==A, f[L]==B},f,{x,-L,L}]
>   ____here derivative is given at left edge, but the functi0n itself is
> given at the right edge___
>
> produces error:
>
> NDSolve::"bvlin"
> "The differential equation(s) and/or boundary conditions are not linear
> in the dependent variables. NDSolve requires linearity to compute the
> solution of a multipoint boundary value problem. "
>
> Is there a way around this?
>
> Thanks
>
> YZ
>
>

• Prev by Date: Re: letrec/named let
• Next by Date: Re: InitializationCell -> Toggle shortcut key
• Previous by thread: Re: Boundary conditions in NDSolve
• Next by thread: Re: Boundary conditions in NDSolve