4
$\begingroup$

When I try to create a ContourPlot of the magnitude of the following vector I get a white area that should be filled with values.

Running the following code:

Bx := 0
By[y_, z_] := (\[Mu]0*j*(y - dy))/(2*Pi ((y - dy)^2 + (z - dz)^2))
Bz[y_, z_] := (\[Mu]0*j*(z - dz))/(2*Pi ((y - dy)^2 + (z - dz)^2))

bwi3D[y_, z_] := {Bx, By[y, z], Bz[y, z]}

bb3Dz = {0, 0, -(\[Mu]0*j)/(2 Pi 5 10^-6)}

const = {\[Mu]0 -> 4 Pi*10^-7, \[Chi] -> -4.5 *10^-4};

params = {j -> 5, V -> (25*10^-18), dz -> 0, dy -> 0};

b3Dz[y_, z_] := bwi3D[y, z] + bb3Dz /. const /. params    

ContourPlot[Sqrt[(b3Dz[y, z][[2]] /. const /. params)^2 + (b3Dz[y, z][[3]] /. const /.params)^2],
      {y, -10 (10^-6), 10*(10^-6)}, {z, -10 (10^-6), 10*(10^-6)},
      ColorFunction -> "Rainbow", Contours -> 100, FrameLabel -> {"y (m)", "z (m)"},
      PlotLabel -> "Contour of field magnitude with z bias"]

I get a contour that looks like this:

Contour

Zooming in reveals contours in regions that were previously engulfed in this white area and using PlotRange -> All results in the following monstrosity:

PlotRange->All

I think this issue is tied to the fact that there is a singularity in this function at y=0 and z=0, but I don't know how to exclude this point. I also have no clue why PlotRange->All is resulting in an all purple plot.

Any help would be appreciated.

Edit: Thanks for bearing with me while I added all the code and fixed the formatting

$\endgroup$
4
  • $\begingroup$ Hi Bob, here is some more code: Bx := 0 By[y_, z_] := (\[Mu]0*j*(y - dy))/(2*Pi ((y - dy)^2 + (z - dz)^2)) Bz[y_, z_] := (\[Mu]0*j*(z - dz))/(2*Pi ((y - dy)^2 + (z - dz)^2)) bwi3D[y_, z_] := {Bx, By[y, z], Bz[y, z]} const = {\[Mu]0 -> 4 Pi*10^-7, \[Chi] -> -4.5 *10^-4}; params = {j -> 5, V -> (25*10^-18), dz -> 0, dy -> 0}; b3Dz[y_, z_] := bwi3D[y, z] + bb3Dz /. const /. params I think this should be enough to reproduce this code? Also it doesn't recognise Clipping as a function. Thank you for your reply. $\endgroup$ Commented Nov 14, 2014 at 17:09
  • $\begingroup$ @AmirArshad Hi ! Please, add this to your original post to make it a complete question. $\endgroup$
    – Sektor
    Commented Nov 14, 2014 at 17:11
  • $\begingroup$ Sure, no problem. $\endgroup$ Commented Nov 14, 2014 at 17:12
  • $\begingroup$ I think everything should be there guys. Sorry for taking so long! $\endgroup$ Commented Nov 14, 2014 at 17:18

1 Answer 1

4
$\begingroup$
Bx = 0;
By[y_, z_] = (\[Mu]0*j*(y - dy))/(2*Pi ((y - dy)^2 + (z - dz)^2));
Bz[y_, z_] = (\[Mu]0*j*(z - dz))/(2*Pi ((y - dy)^2 + (z - dz)^2));

bwi3D[y_, z_] = {Bx, By[y, z], Bz[y, z]};

bb3Dz = {0, 0, -(\[Mu]0*j)/(2 Pi 5 10^-6)};

const = {\[Mu]0 -> 4 Pi*10^-7, \[Chi] -> -4.5*10^-4};

params = {j -> 5, V -> (25*10^-18), dz -> 0, dy -> 0};

b3Dz[y_, z_] = bwi3D[y, z] + bb3Dz /. const /. params;

Manipulate[
 ContourPlot[
  Sqrt[(b3Dz[y, z][[2]] /. const /. params)^2 +
    (b3Dz[y, z][[3]] /. const /. params)^2],
  {y, -10 (10^-6), 10*(10^-6)},
  {z, -10 (10^-6), 10*(10^-6)},
  ColorFunction -> "Rainbow", Contours -> 100,
  FrameLabel -> {"y (m)", "z (m)"},
  PlotLabel -> "Contour of field magnitude with z bias",
  ClippingStyle -> Automatic,
  PlotRange -> {0, maxPeak}],
 {{maxPeak, .6}, .5, 5, .1, Appearance -> "Labeled"},
 SynchronousUpdating -> False]

enter image description here

As the PlotRange is increased the contours get pulled closer around the peak and there is little relative variation in the majority of the plot.

$\endgroup$
1
  • $\begingroup$ Thanks for this. For my project the more important area is the minimum which is located at z=5x10^-6 but I just wanted to understand what this white region was and how i could demonstrate what was going on. This Manipulation of the contours is great. Thanks for your time. $\endgroup$ Commented Nov 14, 2014 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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