Re: Problem with partial differential equations
- To: mathgroup at smc.vnet.net
- Subject: [mg23502] Re: Problem with partial differential equations
- From: Roland Franzius <Roland.Franzius at uos.de>
- Date: Tue, 16 May 2000 02:44:51 -0400 (EDT)
- References: <8etp9i$n1n@smc.vnet.net> <BH0R4.93$5j.5351@ralph.vnet.net> <84CS4.206$5j.13403@ralph.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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>> +++