I have a vector field named nqvrbmmf[mu0, a, b, c, x, y, z]
. It is basically the magnetic field of a cube with sides a, b, c
and the origin of the Cartesian
coordinate system is at the center of the cube. When I display the field with VectorPlot3D
, I am not assigning the parameters beforehand, but Postfix
them with ReplaceAll
like:
VectorPlot3D[
nqvrbmmf[mu0, a, b, c, x, y, z] , {x, -1.5*a,
5.5*a + 4*gap}, {y, -2*b, 2*b}, {z, -3.5*c, 1.5*c + R},
VectorPoints -> {40, 20, 30}, BoxRatios -> Automatic,
Axes -> True, PlotLegends -> Automatic,
PlotRange -> {{-0.015, 0.059}, {-0.02, 0.02}, {-0.035, 0.115}}] //
ReplaceAll[#, {mu0 -> 10^6, a -> 0.01, b -> 0.01, c -> 0.01,
gap -> 0.001, R -> 0.1}] & // Quiet // AbsoluteTiming
and I get a nice little plot:
I want to move the origin of the Cartesian
to the z=-0.1
point and display the field as:
VectorPlot3D[
nqvrbmmf[mu0, a, b, c, x, y, z - R] , {x, -1.5*a,
5.5*a + 4.0*gap}, {y, -2.0*b, 2.0*b}, {z, -3.5*c, 1.5*c + R},
VectorPoints -> {40, 20, 30}, BoxRatios -> Automatic,
Axes -> True, PlotLegends -> Automatic,
PlotRange -> {{-0.015, 0.059}, {-0.02, 0.02}, {-0.035, 0.115}}] //
ReplaceAll[#, {mu0 -> 10^6, a -> 0.01, b -> 0.01, c -> 0.01,
gap -> 0.001, R -> 0.1}] & // Quiet // AbsoluteTiming
and I get another nice little plot like:
All looks good. Now I would like to refer to the coordinates of the field by {x1,y1,z1}
, instead of the {x,y,z-R
} , so I do a TransformedField
transformation:
tnqvrbmmf[mu0_, a_, b_, c_, x1_, y1_, z1_] =
TransformedField["Cartesian" -> "Cartesian",
nqvrbmmf[mu0, a, b, c, x, y, z - R], {x, y, z} -> {x1, y1, z1}];
and checking it with a Point
and the parameters, like:
In[13]:= tnqvrbmmf[mu0, a, b, c, x1, y1, z1] //. {mu0 -> 10^6,
a -> 0.01, b -> 0.01, c -> 0.01, x1 -> -0.015, y1 -> -0.02,
z1 -> -0.035, gap -> 0.001, R -> 0.1}
Out[13]= {9.90952, 13.2127, 58.4381}
Looks ok, so I try to display it as I done previously:
VectorPlot3D[
tnqvrbmmf[mu0, a, b, c, x1, y1, z1] , {x1, -1.5*a,
5.5*a + 4.0*gap}, {y1, -2.0*b, 2.0*b}, {z1, -3.5*c, 1.5*c + R},
VectorPoints -> {40, 20, 30}, BoxRatios -> Automatic,
Axes -> True, PlotLegends -> Automatic,
PlotRange -> {{-0.015, 0.059}, {-0.02, 0.02}, {-0.035, 0.115}}] //
ReplaceAll[#, {mu0 -> 10^6, a -> 0.01, b -> 0.01, c -> 0.01,
gap -> 0.001, R -> 0.1}] & // Quiet // AbsoluteTiming
However now Mathematica
thinks for more than 2 magnitudes of time and throws out all the values and gives me an empty box, like:
The interesting thing is that if make the parameters' assignment before the VectorPlot3D
, then I get the right plot, like:
mu0 = 10^6; a = 0.01; b = 0.01; c = 0.01; gap = 0.0099; R = 0.1;
VectorPlot3D[
tnqvrbmmf[mu0, a, b, c, x1, y1, z1] , {x1, -1.5*a,
5.5*a + 4.0*gap}, {y1, -2.0*b, 2.0*b}, {z1, -3.5*c, 1.5*c + R},
VectorPoints -> {40, 20, 30}, BoxRatios -> Automatic, Axes -> True,
PlotLegends -> Automatic,
PlotRange -> {{-0.015, 0.059}, {-0.02, 0.02}, {-0.035, 0.115}}] //
Quiet // AbsoluteTiming
very quickly.
So, what am I doing wrong with ReplaceAll
after TransformedField
is done? Thanks ahead, János