Mathematica Code
wireno = 12; (*The number of wires*)
wires = Table[
{(i + 0.5)/1.5, (-1)^i},
{i, -wireno/2,
wireno/2 -
1}]; (*This table contains the locations of the wires*)
symbcircle[{xi_, yi_}, rad_] = Graphics[{
White,
EdgeForm[Thick],
Disk[{xi, yi}, rad]}];
cdot[{xi_, yi_}, rad_] = Graphics[Disk[{xi, yi}, rad/3]];
ccross[{xi_, yi_}, rad_] = Graphics[{
Thick,
{Line[{{xi - rad, yi}, {xi + rad, yi}}],
Line[{{xi, yi - rad}, {xi, yi + rad}}]}}];
iinsymbol[{xi_, yi_}, rad_] =
Show[symbcircle[{xi, yi}, rad],
ccross[{xi, yi}, rad]]; (*Symbol for current going into the page*)
ioutsymbol[{xi_, yi_}, rad_] =
Show[symbcircle[{xi, yi}, rad],
cdot[{xi, yi}, rad]]; (*Symbol for current comng out of the page*)
wiresin[rad_] = Graphics[Show[
Table[
iinsymbol[{wires[[n, 1]], wires[[n, 2]]}, rad],
{n, 1, wireno,
2}]]];(*Table containing positions of all "in" current symbols*)
\
wiresout[rad_] = Graphics[Show[
Table[
ioutsymbol[{wires[[n, 1]], wires[[n, 2]]}, rad],
{n, 2, wireno,
2}]]];(*Table containing positions of all "out" current symbols*)
\
wiresymbols[rad_] =
Show[wiresout[rad], wiresin[rad]]; (*All current symbols*)
r[{xi_, yi_}] =
Sqrt[(x - xi)^2 + (y - yi)^2]; (*Distance from {x,y} to {xi, yi}*)
f[{xi_, yi_}] =
{(y - yi)/r[{xi, yi}]^2,
-(x - xi)/r[{xi, yi}]^2}; (*Circular vector field*)
ftot = Sum[
wires[[k, 2]]*f[wires[[k]]],
{k, 1,
wireno}]; (*Sum of effects of all wores (including direction \
governed by y-positon*)
cplot = ContourPlot[
Sqrt[ftot[[1]]^2 +
ftot[[2]]^2], (*Magnitude of resultant vecotr*)
{x, -6, 6},
{y, -4, 4},
PlotPoints -> 50,
PlotRange -> {0, 6.01},(*We want a line at the top edge,
and this ensures it*)
Contours -> Table[i/3, {i, 0, 18}],
Frame -> False,
AspectRatio -> 4/6,
ImageSize -> 1200,
ColorFunction -> "Rainbow"];
Show[cplot, wiresymbols[0.07]]
Category:Magnetic fields around solenoids
Category:Images with Mathematica source code