0
$\begingroup$

I'm trying to visualize a cross-section of a finite continuous solenoid's B-Field (cylindrical coordinate equations from Wikipedia). I believe I have calculated the radial and z-axis fields, but I'm having trouble combining them and visualizing them in a StreamPlot or VectorPlot. Suggestions are appreciated.

u0 = 4 Pi 1*^-7;
coilRadius = 0.0390;
coilLength = 0.0500;
coilCurrent = 400;
coilTurns = 500;

zp[z_] := z + coilLength/2
zm[z_] := z - coilLength/2

kp[rho_, z_] := Sqrt[(
 4 coilRadius rho)/((coilRadius + rho)^2 + zp[z]^2)]
km[rho_, z_] := Sqrt[(
 4 coilRadius rho)/((coilRadius + rho)^2 + zm[z]^2)]
h[rho_] := Sqrt[(4 coilRadius rho)/(coilRadius + rho)^2]

br[rho_, z_] := 
 1/(4 π coilLength) (coilCurrent coilTurns u0) Sqrt[coilRadius/
  rho] ((((kp[rho, z]^2 - 2) EllipticK[kp[rho, z]^2])/kp[rho, z] + (
      2 EllipticE[kp[rho, z]^2])/
      kp[rho, z]) - (((km[rho, z]^2 - 2) EllipticK[km[rho, z]^2])/
      km[rho, z] + (2 EllipticE[km[rho, z]^2])/km[rho, z]))
bz[rho_, z_] := ((coilCurrent coilTurns u0) /((4 π coilLength) Sqrt[
      coilRadius rho])) (zp[z] kp[rho, 
      z] (EllipticK[
        kp[rho, z]^2] + ((coilRadius - rho) EllipticPi[h[rho]^2, 
         kp[rho, z]^2])/(coilRadius + rho)) - 
    zm[z] km[rho, 
      z] (EllipticK[
        km[rho, z]^2] + ((coilRadius - rho) EllipticPi[h[rho]^2, 
         km[rho, z]^2])/(coilRadius + rho)))

Plots:

GraphicsRow[{
  ContourPlot[
   br[rho, z], {rho, 0, coilRadius}, {z, -coilLength/2, coilLength/2},
   PlotRange -> All, Contours -> 20, ColorFunction -> "Rainbow"],

  ContourPlot[
   bz[rho, z], {rho, 0, coilRadius}, {z, -coilLength/2, coilLength/2},
   PlotRange -> All, Contours -> 20, ColorFunction -> "Rainbow"],

  ContourPlot[
   Sqrt[bz[rho, z]^2 + br[rho, z]^2], {rho, 0, 
    coilRadius}, {z, -coilLength/2, coilLength/2},
   PlotRange -> Automatic, Contours -> 20, ColorFunction -> "Rainbow"]
  }, ImageSize -> Large]

enter image description here
enter image description here

$\endgroup$
2
$\begingroup$

This works:

bFieldCylin2D[r_, ζ_] = {br[r, ζ], 0, bz[r, ζ]};
bField3D[x_, y_, z_] = 
  TransformedField["Cylindrical" -> "Cartesian", 
   bFieldCylin2D[r, ζ], {r, th, ζ} -> {x, y, z}];

Show[
 SliceContourPlot3D[
  Sqrt[bField3D[x, y, z][[1]]^2 + bField3D[x, y, z][[2]]^2 + 
    bField3D[x, y, z][[3]]^2],
  {"XStackedPlanes", 1},
  {x, -coilRadius, coilRadius},
  {y, -coilRadius, coilRadius},
  {z, -coilLength/2, coilLength/2},
  Contours -> 20, ColorFunction -> "TemperatureMap"],

 VectorPlot3D[bField3D[x, y, z],
  {x, -coilRadius, coilRadius},
  {y, -coilRadius, coilRadius},
  {z, -coilLength/2, coilLength/2},
  VectorStyle -> Red, VectorScale -> Small]
 ]  

enter image description here

$\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.