MathGroup Archive 2004

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

Search the Archive

Re: Iteration of Initial Conditions for required Boundary Value with NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52811] Re: Iteration of Initial Conditions for required Boundary Value with NDSolve
  • From: bghiggins at ucdavis.edu
  • Date: Mon, 13 Dec 2004 04:23:54 -0500 (EST)
  • References: <cpejtd$6vr$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

If I understand your problem correctly,  believe the problem as stated
is overspecified. You cannot  specify smax and then search for a value
of sz such that x(smax)=3 and y(smax)=2. What you need to do is search
for both sz and smax . One way to do this is to use a shooting method.
The following code does the task automatically given initial guesses
for sz and smax. I should point out that the solution space has a
turning point(limit point) so there are likely two solutions. depending
on what your initial guesses are for sz and smax. I have a web site
that has a notebook that discusses the shooting method in some detail:
http://www.higgins.ucdavis.edu/chemmath.php

Here is the code for your problem

kgi = 3 10^-3; soln[sz1_, smax1_] := NDSolve[{ph''[
s] == ph'[s]/s, ph[sz1] == 10^-7, ph'[sz1] == kgi,
x'[s] == Cos[ph[s]], x[sz1] == 0, y'[s] == Sin[ph[s]], y[sz1] == 0},
{ph, x, y}, {s, sz1, smax1}];

yend[sz1_?NumericQ, smax1_?NumericQ] := First[y[smax1] /. soln[sz1,
smax1]]
xend[sz1_?NumericQ, smax1_?NumericQ] := First[x[smax1] /. soln[sz1,
smax1]]

val = {sz1,
smax1} /. FindRoot[Evaluate[{yend[sz1, smax1] == 2, xend[
sz1, smax1] == 3}], {sz1, 0.01, 0.02}, {smax1, 3.5, 4}];

xyplot[{sz1_,
smax1_}] := ParametricPlot[Evaluate[{x[s], y[s]} /. soln[sz1,
smax1]], {s, sz1, smax1}]
xyplot[val]


  • Prev by Date: Re: BatchMode
  • Next by Date: Re: MMA 5.1 Integrals
  • Previous by thread: Iteration of Initial Conditions for required Boundary Value with NDSolve
  • Next by thread: Re: Iteration of Initial Conditions for required Boundary Value with NDSolve