Magnetic field from a coil (on Mathematica)

In summary, the Mathematica script calculates the magnetic field at a point using the Biot-Savart law. However, the R3 term in the denominator is an error, and it affects the final result.
  • #1
TheDestroyer
402
1
Hello guys,

I'm trying to find the configuration of two circular coils in a configuration similar to Helmholtz coils that would homogenize the magnetic field best at a volume between them.

So the first thing step I took in that is use the Biot-Savart law to calculate the magnetic field produced at each point through that coil. The coordinate system is Cylinderical coordinates, and the coil is placed on the xy-plane, its center matches the origin (0,0,0).

The function is

[itex]
\begin{array}{l}
dl = \sqrt {d{x^2} + d{y^2}} = Rd\theta \\
B\left( {\overrightarrow r } \right) = \frac{{{\mu _0}I}}{{4\pi {R^3}}}\int\limits_0^{2\pi } {\left( {\overrightarrow {dl} \times \left( {\overrightarrow r - \overrightarrow R } \right)} \right)d\theta } \\
B\left( {x,y,z} \right) = \frac{{{\mu _0}I}}{{4\pi {R^3}}}\int\limits_0^{2\pi } {\left( {\left( { - R\sin \theta ,R\cos \theta ,0} \right) \times \left( {x - R\cos \theta ,y - R\sin \theta ,z} \right)} \right)d\theta }
\end{array}[/itex]

where r(x,y,z) is the position vector from origin to the point, at which the magnetic field is to be calculated; R is the radius of the coil.

I wrote a Mathematica script to do this integral, but it always gives a single number (representing a 2 pi R^2 constant result from the cross product and the integral), no matter how I change x,y and z. This is the function I'm using.

FieldAtPoint[x_, y_, z_] :=
(u0 i)/(4 Pi r^2)
Integrate[
Cross[r{-Sin[t], Cos[t], 0}, ({x - r Cos[t], y - r Sin[t], z})], {t,
0, 2 Pi}]
Do you find anything wrong within my calculations? Please advise. How do I do this correctly?

Thank you for any efforts.
 
Last edited:
Physics news on Phys.org
  • #2
You need this term in the denominator: |x(obs) - x(coil)|3

The R3 term is an error -- it's |x(coil)|3
 
  • #3
@lpetrich Thanks a lot! what a stupid mistake!
 

Related to Magnetic field from a coil (on Mathematica)

What is a magnetic field?

A magnetic field is a region around a magnet or electric current where magnetic forces can be observed. It is a vector quantity, meaning it has both magnitude and direction.

How is a magnetic field created?

A magnetic field is created by moving electric charges, such as those found in a current-carrying wire or in the atoms of a permanent magnet. The direction of the magnetic field is determined by the direction of the moving charges.

What is a coil?

A coil is a conductor wound into a series of loops or turns. When a current flows through the coil, it creates a magnetic field. Coils are commonly used in electromagnets and inductors.

How can I calculate the magnetic field from a coil on Mathematica?

You can use the built-in function MagneticField in Mathematica to calculate the magnetic field from a coil. This function takes into account the dimensions and orientation of the coil, as well as the current flowing through it.

What factors affect the strength of the magnetic field from a coil?

The strength of the magnetic field from a coil depends on several factors, including the number of turns in the coil, the current flowing through it, and the distance from the coil. The material and shape of the core (if present) can also affect the strength of the magnetic field.

Similar threads

Replies
2
Views
423
  • Electromagnetism
Replies
1
Views
1K
Replies
3
Views
501
Replies
4
Views
1K
Replies
14
Views
873
  • Electromagnetism
Replies
1
Views
739
Replies
2
Views
712
  • Electromagnetism
2
Replies
43
Views
2K
  • Electromagnetism
Replies
5
Views
1K
Replies
5
Views
919
Back
Top