3
$\begingroup$

I have an interpolation function. Lets think of it as f={fx,fy,fz}.

I would like to operate on the fx part of interpolation and say, multiply it by five and plot it.

I can easily separate the derivative of interpolation function, as seen below as a curl, but I can't work out how to do anything similar for the original interpolation function.

f[x_, y_, z_] := {y, x, 0}
testdata = Flatten[Table[N@{x, y, z, {y, x, 0}}, {x, -3, 3 , 0.5}, {y, -3, 3,0.5},{z, 0, 1, 0.5}], 2];

intf = Interpolation[testdata];
intfd[x_, y_, z_] = D[intf[x, y, z], {{x, y, z}}];


intfcurl[x_, y_, z_] := 
 Module[{q = intfd[x, y, z]}, {q[[2, 3]] - q[[3, 2]], q[[3, 1]] - q[[1, 3]], q[[1, 2]] - q[[2, 1]]}]

VectorPlot3D[intf[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]
VectorPlot3D[intfcurl[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]

Edit for clarification: Is there a way to do use the interpolation function like the curl example? e.g r= intf[x, y, z], then r[[1]] for the x dimension?

What I would like to do is multiply the x dimension of the interpolation function with the x dimension of the curl, i.e., I'd like to do something like:

intffunction[x_, y_, z_] := 
 Module[{q = intfd[x, y, z], r= intf[x,y,z]}, {r[[1]](q[[2, 3]] - q[[3, 2]]), r[[2]](q[[3, 1]] - q[[1, 3]]), r[[3]](q[[1, 2]] - q[[2, 1]])}]

Where r[[1]], r[[2]] and r[[3]], refer to the x,y,z dimensions respectively. Of course, however, r[[1]], and r[[2]], r[[3]] doesn't refer to the x,y,z dimensions in mathematica, but hopefully this gives an idea.

$\endgroup$
1
$\begingroup$

You can generate data with proper replacement and use ListVectorPlot3D.

vector = Table[intf[x, y, z] /. {x_, y_, z_} :> {x, 5 y, z}, 
              {x, -3, 3}, {y, -3, 3}, {z, 0, 1}];
ListVectorPlot3D[vector]

enter image description here

Or to do it in your way

intf1[x_, y_, z_] :=  Module[{q = intf[x, y, z]}, {q[[1]], 5 q[[2]], q[[3]]}]

VectorPlot3D[intf1[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]

However

intffunction[x_, y_, z_] := Module[{q = intfd[x, y, z], r= intf[x,y,z]},
{r[[1]](q[[2, 3]] - q[[3, 2]]), r[[2]](q[[3, 1]] - q[[1, 3]]), 
 r[[3]] q[[1, 2]] - q[[2, 1]])}]

will give you an empty output because your initial vector field is in xy plane. So its curl would be along z and $\vec{v}.(\nabla \times \vec{v})$ will be zero.

$\endgroup$
  • $\begingroup$ Is there a way to do it like the curl example? e.g r= intf[x, y, z], then r[[1]] for the x dimension? $\endgroup$ – Tomi Jun 26 '16 at 19:36
  • 1
    $\begingroup$ yes and you already know the answer :). I add it to my answer. $\endgroup$ – Sumit Jun 26 '16 at 22:12
1
$\begingroup$

This works for me:

Clear[intfcurl];
intfcurl[x_?NumericQ, y_?NumericQ, z_?NumericQ] := 
 With[{q = intfd[x, y, z]}, {q[[2, 3]] - q[[3, 2]], 
   q[[3, 1]] - q[[1, 3]], q[[1, 2]] - q[[2, 1]]}]

VectorPlot3D[intf[x, y, z] intfcurl[x, y, z], {x, -3, 3}, {y, -3, 3}, {z, 0, 1}]

(But it helps not to have testdata based on a function with zero curl!)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.