MathGroup Archive 2003

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

Search the Archive

Re: Boundary Conditions for NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41436] Re: Boundary Conditions for NDSolve
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Mon, 19 May 2003 05:14:55 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <ba50ti$sek$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

you must prevent that NDSolve[] evaluate your functions for
nonnumeric arguments and

F[t_?NumericQ] := phi /. FindRoot[phi - 0.1*Sin[phi] == t, {phi, 0}]
rh[t_?NumericQ] := 1 - 0.1*Cos[F[t]]

sol = NDSolve[{D[u[x, t], t] == D[u[x, t], x, x], u[x, 0] == 30, 
      Derivative[1, 0][u][1, t] == 0, 
      Derivative[1, 0][u][0, t] == (1/rh[t])^2 - u[0, t]^4}, 
    u, {x, 0, 1}, {t, 0, 5}]

give only an message about the inconsistent initial-bondary conditions
and a numerical solution.

Regards
  Jens

Lindsey Malcom wrote:
> 
> Dear MathGroup,
> 
> I am trying to use mathematica to numerically solve the diffusion
> equation for a body orbiting the sun. In order to do this, I must solve
> for the heliocentric distance as a function of time t, and use this as a
> part of my boundary condition.
> 
> First, I use FindRoot to solve for the eccentric anomaly (I am leaving
> out the constants and just setting eccentricity to 0.1 and semimajor
> axis = 1)
> 
> F[t_]:=phi /. FindRoot[phi-0.1*Sin[phi]==t,{phi,0}]
> 
> Next, I use this result to solve for the heliocentric distance:
> 
> rh[t_]:=1-0.1*Cos[F[t]]
> 
> These two functions work fine, and produce numeric results when i
> evaluate them at a specifc time. However the problems start when I try
> to use the function rh[t] in my boundary condition.
> 
> To solve for the temperature at any depth and time, call this function
> u, I do
> 
> sol= NDSolve[{D[u[x,t],t] == D[u[x,t],x,x], u[x,0]==30,
>     Derivative[1,0][u][1,t]==0,
>     Derivative[1,0][u][0,t]== (1/rh[t])^2-u[0,t]^4},u,{x,0,1},{t,0,5}]
> 
> When i try to find the numerical solution, i get all sorts of error
> messages like
> 
> FindRoot::frnum:
> Function{0.403324-1.t} is not a length 1 list of numbers at {phi}={0.446506}
> 
> and also something about FindRoot[phi-0.1*Sin[phi]==t, {phi, Random[]}]
> is neither a list of replacement rules nor a valid dispatch table, and
> so cannot be used for replacing.
> 
> Can anyone offer any suggestions? I am desperate for help.
> 
> Thanks.
> 
> Sincerely,
> 
> Lindsey Malcom


  • Prev by Date: RE: Re: any good tutorials?
  • Next by Date: Re: pitfall in analytic function
  • Previous by thread: Re: Boundary Conditions for NDSolve
  • Next by thread: Real-time rotations of 3-D plots