Thanks to those who brought this to our attention. In investigating the slowdown in recent versions of Mathematica, it looks like the slow evaluation is a result of VectorPlot3D needing to evaluate the nqvrbmmf[mu0, a, b, c, x, y, z]
function at all the points that the plot samples. You can see that individual calls of nqvrbmmf
are relatively slow:
In[5]:= Do[
nqvrbmmf[1000000, 0.01`, 0.01`, 0.01`, x, y,
z] /. {x -> RandomReal[{-0.015`, 0.059`}],
y -> RandomReal[{-0.02`, 0.02`}],
z -> RandomReal[{-0.035`, 0.115`}]}, 200] // AbsoluteTiming
Out[5]= {19.7192, Null}
This slow evaluation time can be addressed by forcing evaluation of VectorPlot3D's first argument with Evaluate prior to the actual evaluation of the plot:
In[6]:= AbsoluteTiming[
VectorPlot3D[
Evaluate[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;]
Out[6]= {1.43917, Null}
The problem here was actually in Mathematica 11.0.1, where it looks like VectorPlot3D's first argument was evaluating before it should, leading to the speedup and causing the confusion.