Magnetic Flux through a Loop of Wire

Manipulate[
Module[{fluxequation},

findFlux[field_List]:=
Integrate[
Integrate[
((field/.x->r Cos[theta]/.y->r Sin[theta]/.z->h).gradient[z-h]*r),
{r,0,rad}],{theta,0,2Pi}];
fluxequation = findFlux[field];

Show[
VectorFieldPlots`VectorFieldPlot3D[Evaluate@field,{x,-5,5},{y,-5,5},{z,0,10},VectorFieldPlots`VectorHeads->arrow,PlotPoints->7],
ParametricPlot3D[{radius Cos[u],radius Sin[u],height},{u,0,2Pi}],

PlotRange->{{-5,5},{-5,5},{0,10}},Boxed->False,Axes->axes,ImageSize->{400,350},PlotLabel->Row[{"magnetic flux = ",N@fluxequation/.rad->radius/.h->height," Webers"}],SphericalRegion->True
]

](*End Module*),

{{field,{x,-y,1},"magnetic field"},{
{0,0,1}->"{0, 0, 1}",
{1,1,1}->"{1, 1, 1}",
{x,y,-2z}->"{x, y, -2z}",
{x,-y,1}->"{x, -y, 1}",{y^2,z^2,x^2}->Row[{"{",Superscript["y","2"],", ",Superscript["z","2"],", ",Superscript["x","2"],"}"}]},ControlType->PopupMenu},
{{radius,2,"radius of the loop"},1,5,Appearance->"Labeled"},
{{height,5,"location of the loop"},0,10,Appearance->"Labeled"},
{{arrow,True,"show arrowheads"},{True,False}},
{{axes,True,"show axes"},{True,False}},

TrackedSymbols:>Manipulate,SynchronousInitialization->False,
Initialization:>{
Clear[x,y,z];
Get["VectorFieldPlots`"];
gradient[eq_]:={D[eq,x],D[eq,y],D[eq,z]};}
]

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Magnetic Flux through a Loop of Wire" from The Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/MagneticFluxThroughALoopOfWire/

Contributed by: Ernest Lee

A full-function Wolfram Mathematica 6 system is required to edit this notebook.
GET WOLFRAM MATHEMATICA 6 »

© The Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »