Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Problem with partial differential equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23521] Re: Problem with partial differential equations
  • From: Max Ulbrich <ulbrich at biochem.mpg.de>
  • Date: Tue, 16 May 2000 22:29:53 -0400 (EDT)
  • Organization: Rechenzentrum der Max-Planck-Gesellschaft in Garching
  • References: <8etp9i$n1n@smc.vnet.net> <BH0R4.93$5j.5351@ralph.vnet.net> <84CS4.206$5j.13403@ralph.vnet.net> <8fqqoh$gun@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Roland,

of course I didn't have the problem with P1, but with P2, like in

P1[x_, t_] := 2*x^2;
P2[x_, t_] := 2*(x + t)^2;
Diff = 0.2;
G[x_] := Exp[-x^2];

solution = n /. First[NDSolve[
      {Derivative[0, 1][n][x, t] == Diff*Derivative[2, 0][n][x, t] +
         n[x, t]*Derivative[2, 0][P2][x, t] +
         Derivative[1, 0][n][x, t]*Derivative[1, 0][P2][x, t],
        n[x, 0] == G[x],
        n[-3., t] == G[-3.],
       n[3., t] == G[3.]},
        n, {x, -3, 3}, {t, 0, 4},
      StartingStepSize -> 0.05]];
Plot3D[solution[x, t], {x, -2, 2}, {t, 0, 4}];

when I change the potential in the part with the differential equation.
Then I get an error message like

NDSolve::ndnum:
    The right-hand side of the differential equation does not evaluate to a
number at t == 0.

Bye,

Max


Roland Franzius wrote:

> Hi Max, I don't see a problem.
>
> In:
>
> P1[x_, t_] := 2*x^2;
> P2[x_, t_] := 2*(x + t)^2;
> Diff = 0.2;
> G[x_] := Exp[-x^2];
>
> solution = n /. First[NDSolve[
>       {Derivative[0, 1][n][x, t] == Diff*Derivative[2, 0][n][x, t] +
>          n[x, t]*Derivative[2, 0][P1][x, t] +
>          Derivative[1, 0][n][x, t]*Derivative[1, 0][P1][x, t],
>         n[x, 0] == G[x],
>         n[-3., t] == G[-3.],
>        n[3., t] == G[3.]},
>         n, {x, -3, 3}, {t, 0, 4},
>       StartingStepSize -> 0.05]];
> Plot3D[solution[x, t], {x, -2, 2}, {t, 0, 4}];
>
> Out:  -SurfaceGrafics-
>
> This has been copied and pasted from below with replacement  = -> := in
> the first 4 lines
>
> My diffusion problem solution is looking quite similar:
>
> Needs["Graphics`Arrow`"];
>
> Diffuse[name_,density0_]:= name=
> y/.
> NDSolve[ {D[y[t, x], t] == D[y[t, x], x, x],  y[0, x] == density0[x],
> Derivative[0, 1][y][t, 0] == 0, Derivative[0, 1][y][t, Pi] == 0},
> y,  {t, 0, 4}, {x, 0, Pi}, MaxSteps -> 400][[1]]
>
> Diffuse[YD,#*Sin[4*#]^2&]
>
> pl = Plot3D[
>         YD[t, x],{x, 0.01, Pi - 0.1}, {t, 0, 0.05}, PlotPoints -> 50, Mesh ->
> False,
>        PlotRange -> {-0.5, 3}, Boxed -> False,
>         Axes -> None, DisplayFunction -> Identity];
>
> AxesAndText =
> Graphics[{RGBColor[0., .6, 0.],
>         Arrow[{0.1, 0.24}, {0.4, 0.14}],
>         Text["Ort", {0.33, 0.12}],
>         RGBColor[1., 0, 0],
>         Arrow[{0.75, 0.1}, {0.85, 0.3}],
>         Text["Zeit", {0.8, 0.3}],
>         RGBColor[0, 0, 1.],
>         Arrow[{0.04, 0.36}, {0.04, 0.6}],
>         Text["Temp", {0.10, 0.58}],
>         RGBColor[0., 0., 0.],
>         Text["Tempt", {0.47, 0.35}],
>         RGBColor[0., 0., 0.],
>         Text["Temp0", {0.24, 0.55}],
>         Text["Abl0", {0.2, 0.5}],
>         Text["Abl0", {0.86, 0.45}]}];
>
> Show[pl, AxesAndText]
>
> good luck
>
> roland
>
> ps: only by chance I just saw your reply at
> comp.soft-sys.math.mathematica
>
> Max Ulbrich wrote:
> >
> > Hi Roland, I tried, but I still get an error message like
> >
> > NDSolve::ndnum:
> >     The right-hand side of the differential equation does not evaluate
> > to a number at t == 0.
> >
> > Has anyone an idea what is wrong?
> >
> > Max
> >
> > Roland Franzius wrote:
> >
> > > Hi Max,
> > > seems to work if you use delayed definitions (at evalutation time)
> > >
> > > > P1[x_,t_]:=2x^2;
> > > > P2[x_,t_]:=2(x+t)^2;
> > > > Diff=0.2;
> > > > G[x_]:=Exp[-x^2];
> > >
> > > probably a problem of fixing variables to numbers
> > >
> > > Max Ulbrich wrote:
> > > >
> > > > Hi,
> > > >
> > > > I have a problem with a partial differential equation.
> > > > I want to solve a diffusion problem in a time-dependent potential.
> > > > It works with the potential P1, but not with P2.
> > > > Can someone help me?
> > > >
> > > > P1[x_,t_]=2x^2;
> > > > P2[x_,t_]=2(x+t)^2;
> > > > Diff=0.2;
> > > > G[x_]=Exp[-x^2];
> > > > solution=n/.First[
> > > >       NDSolve[{Derivative[0,1][n][x,t]==
> > > >
> > > > Diff*Derivative[2,0][n][x,t]+n[x,t]*Derivative[2,0][P1][x,t]+
> > > >
> > > > Derivative[1,0][n][x,t]*Derivative[1,0][P1][x,t],n[x,0]==G[x],
> > > >           n[-3,t]==G[-3],n[3,t]==G[3]},n,{x,-3,3},{t,0,4},
> > > >         StartingStepSize->0.05]];
> > > > Plot3D[solution[x,t],{x,-2,2},{t,0,4}];
> > > >
> > > > Max Ulbrich
> > > > ulbrich at biochem.mpg.de
> > >
> > > --
> > > Roland Franzius
> > >
> > >   +++ exactly <<n>> lines of this message have value <<FALSE>> +++
>
> --
> Roland Franzius
> Theor. Physik FB Physik, Univ. Osnabrueck
>
>   +++ exactly <<n>> lines of this message have value <<FALSE>> +++



  • Prev by Date: Re: Parametric Solving Question From 14 Year Old
  • Next by Date: Complex Plane
  • Previous by thread: Re: Problem with partial differential equations
  • Next by thread: Re: NURBS ?