Error message opening a file after start Mathematica, later runs error-free

After starting Mathematica and loading a file with Manipulate and ContourPlot3D function I get the message: ContourPlot3D::valuef: B2[x,y,z,0.05,0.05,0.015,Br] must be a numerical function. >>. Evaluate Notebook here after gives the intended functionalty without any error message.
Close all and reload the file gives again an error. Close file and reload gives no error message. What is happening here?

Structure:

  • initialisation variables

  • Defintion of a vector function B2[x_, y_, z_, a_, b_, c_, Br_] := …
    Manipulate[
    {Show@MapThread[ContourPlot3D[#1, {x, -0.1, 0.1}, {y, -0.1, 0.1}, {z, 0, 0.1},Contours → Range[-Brange, Brange, Brange 0.1],
    BoundaryStyle → Directive[#2, Thick], Background → Black,Boxed → False,RegionFunction → (! (#1 [GreaterSlantEqual] -0.0001 && #2 <=
    0.0001 && #3 [GreaterSlantEqual] 0) && ! (#3 <=0) && ! (#3 > Alfa) &),
    ContourStyle → Directive[Opacity[0.8], Specularity[White, 10]], ImageSize → {400, 400}, ColorFunction → Function[{x, y, z, f}, Hue[ 2 f]],
    PlotPoints → 20 (Hi + 1), MaxRecursion → 0, Mesh → False, Lighting → “Neutral”] &, {B2[x, y, z, a, b, c, Br] {sx, sy, sz}, {Red, Yellow, Green}}]},
    Row[{Control[{{a, 0.05, “a”}, 0.001, 0.1, 0.001, ImageSize → Small}],
    Control[{{b, 0.05, “b”}, 0.001, 0.1, 0.001, ImageSize → Small}], Control[{{c, 0.015, “c”}, 0.001 , 0.02, 0.002,
    ImageSize → Small}]}, Spacer[10]], Row[{Control[{{Alfa, 0.1, “Z”}, 0.001 , 0.1, 0.005,ImageSize → Small}], Spacer[20],
    Control[{{Brange, 0.5, “L”}, 0.05 , 1, 0.05, ImageSize → Small}], Spacer[10], Control[{{sx, 1}, {0, 1}}], Spacer[10], Control[{{sy, 1}, {0, 1}}],
    Spacer[10], Control[{{sz, 1}, {0, 1}}], Spacer[10], Control[{{Hi, 0}, {0, 1}}]}]]!
    Sample output included

Dear John,

I have made the first cell an initialisation cell and set the default for Hi to 1 instead of zero. Also I save the definitions. The problem seems to be that the dynamic content is evaluated. Now it seems to work alright.

Cheers,
Marco

PS: Nice plot by the way!

I just noticed that we can do a bit better. I added an automatic evaluation of the initialisation cells. Now the figure comes up right at the beginning, even before evaluating the notebook.

M.

Dear Marco, thanks for the compliment and the solution, the last one works well.
It represent the magnetic field of a rectangular magnet, split in the three components, Bx, By and Bz.
The unique “selling feature” is the representation of a vectorfield as a function of the x,y,z position.
It is interesting for those who are involved in electro-magnetic fields, fluid/gas dynamics, etc.
I started more than one year ago with Mathematica and these pictures are unbeaten.

The next step is to add this to Wolfram Demonstrations.

Kind regards John Compter