Message Boards Message Boards

How to 3D plot or 2D plot a solution of NDSolve?

Posted 2 years ago

Initial conditions

a = 0.99; b = Sqrt[1 - a^2]; u = 10; eps = 8.854*10^(-12)

f0[v_] = (a/Sqrt[Pi])*Exp[-v^2] + (b/Sqrt[Pi])*Exp[-(v - u)^2];

u1 = Log[((1 - a^2)/a^2)^(1/2)]/(2*u) + u/2;

u2 = 3*u/2 - Log[((1 - a^2)/a^2)^(1/2)]/(2*u);

u1

u2

(*plot of f0*)

Plot[f0[v], {v, u1, u2}]

(* NDSolve of a sistem of 2 eqs that depend on v and t *)

sol = NDSolve[{D[go[v, t], t] + 

     D[D[w[v, t], t], v]/(v^3) + (-3*v^(-4))*D[w[v, t], t] == 0, 

   go[v, 0] == f0[v], 

   D[w[v, t], t] == Pi/eps*(v^2)*D[go[v, t], v]*w[v, t],

   w[v, 0] == 0}, 
{go[v, t]}, {v, u1, u2}, {t, 0, 1000000}]


Plot3D[sol[v, t]], {v, u1, u2}, {t, 0, 10}]

And no the plot is blank. I simply can't do anything with the results from NDSolve...

POSTED BY: Diogo Carvalho

There is something wrong with your code, which I have modified to get a solution. I have no idea about your initial/boundary conditions. At least the code below produces plots and shows what you could do

sol = NDSolve[
   {
    D[go[v, t], t] + D[D[w[v, t], t], v]/(v^3) + (-3*v^(-4))*D[w[v, t], t] == 0,
    go[v, 0] == f0[v],
    D[w[v, t], t] == Pi/eps*(v^2)*D[go[v, t], v]*w[v, t],
    w[v, 0] == 0
    },
   {go, w},
   {v, u1, u2}, {t, 0, 20}] // Flatten

fgo = go /. sol
fw = w /. sol

Plot3D[{fgo[x, y], fw[x, y]}, {x, 6, 10}, {y, 0, 20}]
Plot[fw[8, t], {t, 0, 10}, PlotStyle -> {Red, Thick}]
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract