Message Boards Message Boards

0
|
3526 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

NDSolve: graph of the partial derivative?

Posted 11 years ago
Hi everybody!
I worked some time using Wolfram Mathematica, but now I'm dealing with a problem I don't know how to solve.
The question is the following: I use NDSolve trying to find the numerical approximation to the exact solution of PDE. Then I need to draw a graph, where the partial derivative of this solution is used, but I don't know how to do that.
In Help it is written, that if sol - is the numerical solution of ODE, then y'/.sol gives the numerical approximation to the derivative, but as I understand, such a trick doesn't work with PDEs.

 R = 1000;
 V = 0.1;
 sol = NDSolve[{D[A[t, x, y, z], t] +
      V*Sin[z]*Exp[-z/R]*D[A[t, x, y, z], x] == (1/R)*
      D[A[t, x, y, z], z, z], A[0, x, y, z] == Sin[x] + Sin[y],
    A[t, 0, y, z] == A[t, 2*Pi, y, z],
    A[t, x, 0, z] == A[t, x, 2*Pi, z]},
   A, {t, 0, 10}, {x, 0, 2*Pi}, {y, 0, 2*Pi}, {z, 0, 10}]
 Manipulate[
Plot3D[A[t, x, y, z] /. First[sol], {t, 0, 10}, {x, 0, 2*Pi}], {y, 0,
   2*Pi}, {z, 0, 10}]
v1[t_, x_, y_, z_] :=
  Exp[-t/R]*(V*Sin[z] - A[t, x, y, z] /. First[sol]);
Manipulate[
Plot3D[v1[t, x, y, z], {t, 0, 10}, {x, 0, 2*Pi}], {y, 0, 2*Pi}, {z,
  0, 10}]


In the last but one line instead of A[t,x,y,z]/.First I'd like to get D[A[t,x,y,z],x]/.First, but such a command doesn't work.
Thanks beforehand! 
POSTED BY: Mark Turtsinskyi
2 Replies
Hi, 

you need to use Evaluate[] function, see example below:
 (* your code *)
 R = 1000;
 V = 0.1;
 sol = NDSolve[{D[A[t, x, y, z], t] +
      V*Sin[z]*Exp[-z/R]*D[A[t, x, y, z], x] == (1/R)*
      D[A[t, x, y, z], z, z], A[0, x, y, z] == Sin[x] + Sin[y],
    A[t, 0, y, z] == A[t, 2*Pi, y, z],
    A[t, x, 0, z] == A[t, x, 2*Pi, z]},
   A, {t, 0, 10}, {x, 0, 2*Pi}, {y, 0, 2*Pi}, {z, 0, 10}]
(* added *)
nsol = Evaluate[A[t, x, y, z] /. sol][[1, 0]];
(* this can be used to get some values *)
nsol[0, 0, 0, 0]
nsol[0, Pi/2, 0, 0]
nsol[0, Pi/2, Pi/2, 0]
(* plotting *)
Plot[nsol[x, 0, 0, 0] /. x -> t, {t, 0, 10}]
(* plot par. der. vs. t *)
Plot[D[nsol[x, 0, 0, 0], x] /. x -> t, {t, 0, 10}]

I.M.
POSTED BY: Ivan Morozov
Thanks a lot for your advice!
POSTED BY: Mark Turtsinskyi
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