Message Boards Message Boards

Calculate the magnetic dipole due to a current circular loop?

Posted 5 years ago

Hey guys, I'm very new to mathematica, and am not a programmer. The last programming class I took was in 2005 for C++! But I'm taking a physics course to get into grad school and this is a project that we're workin on.

I can't seem to get actual values for my integrals. I understand that along the x-axis, I should see an output of 0. But, I get some message that doesn't mean anything to me. The code is posted below, and I've attached both the .nb file as well as our rubric so that you can see what we're trying to do.

The rubric says:

(a) Use the Biot-Savart law to calculate the magnetic field at any point in the yz-plane (i.e., at (0, y, z)) of the current loop shown in the figure below. The source point is (R cos ?, R sin ?, 0), and ? runs from 0 to 2?. Set up the integrals from which you could calculate Bx, By, and Bz.

(b) Evaluate the integral for Bx(y,z) and show that it is equal to zero.

(c) Use the Mathematica functions NIntegrate[] and StreamPlot[] to display the magnetic field lines By(y, z) and Bz(y, z) due to a current circular loop in the yz-plane. Take the current on the loop of radius 15 cm to be 1.5 A.

My code:

Clear["Global'*"]

u0 = 1.257*10^(-6); (*Permiability of free space*)
Ic = 1.5; (*Current in amps*)
R = .15; (*Radius in meters*)
ymax = 2.5*R;
zmax = 2.5*R;
\[Mu] = 4*\[Pi]*10^(-7);

B = \[Mu]*Ic/(2*R);
Bz[0, 0];

Bx[y_,z_]:=\[Mu]*Ic/(4*\[Pi]) *NIntegrate[((z*R*Cos[\[Phi]])/(R^2+y^2-2*y*R*Sin[\[Phi]]+z^2)^(3/2)),{\[Phi],0,2\[Pi]}] (*Integral for Biot-Savart Law along the x-axis. This will equal 0. Prove it*)

By[y_, z_] := \[Mu]*Ic/(4*\[Pi]) *NIntegrate[((z*R*Sin[\[Phi]])/(R^2 + y^2 - 2*y*R*Sin[\[Phi]] + z^2)^(3/2)), {\[Phi], 0, 2 \[Pi]}] (*Integral for Biot-Savart Law along the y-axis*)

Bz[y_, z_] := \[Mu]*Ic/(4*\[Pi]) *NIntegrate[((R^2 - y*R*Sin[\[Phi]])/(R^2 + y^2 - 2*y*R*Sin[\[Phi]] + z^2)^(3/2)), {\[Phi], 0, 2 \[Pi]}] (*Integral for Biot-Savart Law along the z-axis*)

p1 = StreamPlot[{By[y, z], Bz[y, z]}, {y, -ymax, ymax}, {z, -zmax, zmax}]
POSTED BY: Ryan Schmidt
Posted 5 years ago

Try this

Clear["Global'*"]
u0 = 1.25710^(-6); (*Permiability of free space*)
Ic = 1.5; (*Current in amps*)
R = .15; (*Radius in meters*)
ymax = 2.5*R;
zmax = 2.5*R;
? = 4?*10^(-7); B = ? Ic/(2R); Bz[0, 0];
Bx[y_?NumericQ, z_?NumericQ] := ? Ic/(4?) NIntegrate[((z R Cos[?])/(R^2+y^2-2y R Sin[?]+z^2)^(3/2)),{?,0,2?}] (*Integral for Biot-Savart Law along the x-axis. This will equal 0. Prove it*)
By[y_?NumericQ, z_?NumericQ] := ? Ic/(4?) NIntegrate[((z R Sin[?])/(R^2 + y^2 - 2y R Sin[?] + z^2)^(3/2)), {?, 0, 2 ?}] (*Integral for Biot-Savart Law along the y-axis*)
Bz[y_?NumericQ, z_?NumericQ] := ? Ic/(4?) NIntegrate[((R^2 - y R Sin[?])/(R^2 + y^2 - 2y R Sin[?] + z^2)^(3/2)), {?, 0, 2 ?}] (*Integral for Biot-Savart Law along the z-axis*)
p1 = StreamPlot[{By[y, z], Bz[y, z]}, {y, -ymax, ymax}, {z, -zmax, zmax}]
POSTED BY: Bill Nelson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract