# Physics equations/Magnetic field calculations
## The Biot-Savart law

The Biot–Savart law is used for computing the resultant magnetic field B at position r generated by a steady current I (for example due to a wire): a continual flow of charges which is constant in time and the charge neither accumulates nor depletes at any point. The law is a physical example of a line integral: evaluated over the path C the electric currents flow. The equation in SI units is:
**Problem: Generalize this line integral to a volume integral involving current density.
Let J be the current density vector, and let dA be a vector that denotes direction and a small (differential) area. (The direction of dA is normal to the area element). Since the vectors parallel, the inner (dot) product J·dA equals the scalar product JdA. Also parallel to both J and dA is dL, an element of length along the wire. Since the normal to the area is parallel to the length, dAdL equals dV, which is the volume element. Hence IdL equals JdV, where dL and J both have direction. Thus the line integral over current becomes a volume integral:
    $\mathbf {B} ={\frac {\mu _{0}}{4\pi }}\iiint _{V}\ {\frac {(\mathbf {J} \,dV)\times \mathbf {\hat {r}} }{r^{2}}}$

## Magnetic field lines for typical geometries

| Magnetic field near a long straight wire. | Magnetic field due to a current loop. | Magnetic field due to a solenoid |

## Magnetic field due to a current loop

*Problem: Show that if circular loop of radius $a$ carries a current $I$, then the magnetic field at the center of the loop points in the ${\hat {z}}$ direction and as a magnitude of:
    $B_{\text{center}}={\frac {\mu _{o}I}{2a}}$.
(This represents the magnetic field at $z=0$ in the figure to the right; the magnetic field points in the ${\hat {z}}$ direction.)
The distance from the source current, $Id{\vec {\ell }}$, to the field point (at the center) is always $a\;d{\vec {\ell }}$. Since ${\hat {r}}$ is perpendicular to $Id{\vec {\ell }}$, and since their cross product always points along the axis of the loop, we have
    $d{\vec {B}}={\frac {\mu _{0}}{4\pi }}{\frac {Id{\vec {\ell }}\times {\hat {r}}}{|r|^{2}}}={\frac {\mu _{0}}{4\pi }}{\frac {Id\ell }{a^{2}}}{\hat {n}}$
where ${\hat {n}}$ is a unit vector pointing along the axis. Since $\oint d\ell =2\pi a$, we have our result.
***Problem:Show that if circular loop of radius $a$ carries a current $I$, then the magnetic field at the at a distance $z$ away from the center is in the z direction, has magnitude:
    $B(z)={\frac {\mu _{o}I}{2}}{\frac {a^{2}}{\left(z^{2}+a^{2}\right)^{3/2}}}$
An element of the magnetic field due to an element of current is shown in the figure above and to the right. Here, $d{\vec {B}}$ points downward because the element at the top of the loop was chosen. We seek only the $z$ component, so we multiply by the cosine of the acute angle in the right triangle shown: $dB_{\text{z}}=dBsin(\theta )$, where
    $\sin(\theta )={\frac {a}{\left(z^{2}+a^{2}\right)^{1/2}}}$
where z is the distance from the center of the loop. The rest of solution resembles the calculation of the magnetic field at the center of a loop.

## Ampère's circuital law

The "integral form" of the original Ampère's circuital law is a line integral of the magnetic field around any closed curve C (This closed curve is arbitrary but it must be closed, meaning that it has no endpoints). The curve C bounds both a surface S, and any current which pierces that surface is said to be enclosed by the surface. The line integral of the magnetic B-field (in tesla, T) around closed curve C is proportional to the total current I$_{enc}$ passing through a surface S (enclosed by C):
    $\oint _{C}{\vec {B}}\cdot \mathrm {d} {\boldsymbol {\ell }}=\mu _{0}I_{\mathrm {enc} }$

## Maxwell's correction term (displacement current)

This equation might is not generally valid if a time-dependent electric field is present, as was discovered by James Clerk Maxwell, who added the displacement current term to Ampere's law around 1861. The need for this extra term can be seen in the figure to the right. The diagram shows a capacitor being charged by current $I\,$ flowing through a wire, which creates a magnetic field $\mathbf {B} \,$ around it. The magnetic field is found from Ampere's law:
*****Problem: Show that with Maxwell's correction (with $\partial {\vec {E}}/\partial t$), Ampere's law becomes:
    $\oint _{C}{\vec {B}}\cdot \mathrm {d} {\boldsymbol {\ell }}=\mu _{0}\int _{S}({\vec {J}}+\epsilon _{0}{\frac {\partial {\vec {E}}}{\partial t}})\cdot d\mathbf {S} \,$
where,
    $\int _{S}{\vec {J}}\cdot d\mathbf {S} =I_{\mathrm {enc} }$
The equation says that the integral of the magnetic field $\mathbf {B} \,$ around a loop $\partial S\,$ is equal to the current $\mathbf {J} \,$ through any surface spanning the loop, plus a term depending on the rate of change of the electric field $\mathbf {E} \,$ through the surface. This term, the second term on the right, is the displacement current. For applications with no time varying electric fields (unchanging charge density) it is zero and is ignored. However in applications with time varying fields, such as circuits with capacitors, it is needed, as shown below. Any surface intersecting the wire, such as $S_{1}\,$, has current $I\,$ passing through it so Ampere's law gives the correct magnetic field:
    $B={\frac {\mu _{0}I}{2\pi r}}\,$
But surface $S_{2}\,$ spanning the same loop that passes between the capacitor's plates has no current flowing through it, so without the displacement current term Ampere's law gives:
    $B=0\,$
So without the displacement current term Ampere's law fails; it gives different results depending on which surface is used, which is inconsistent. The 'displacement current' term provides a second source for the magnetic field besides current; the rate of change of the electric field $\mathbf {E} \,$. Between the capacitor's plates, the electric field is increasing, so the rate of change of electric field through the surface $S_{2}\,$ is positive, and its magnitude gives the correct value for the field field $\mathbf {B} \,$ found above.

## Magnetic field due to a long straight wire

*Problem: Show that in the vicinity of a long, straight wire carrying current $I\,$, Ampere's law yields:
    ${\vec {B}}={\frac {\mu _{0}I}{2\pi r}}\,{\hat {\theta }}$
where ${\hat {\theta }}$ is a unit vector that points in the azimuthal direction, and $\mu _{0}$ is the magnetic constant.
Do the line integral around on a circle centered around the loop. $\oint _{C}{\vec {B}}\cdot \mathrm {d} {\boldsymbol {\ell }}=2\pi rB$

## Magnetic field inside a long thin solenoid

*Problem: Show that in the vicinity of a long, thin solenoid of length $L$
    ${\vec {B}}=\mu _{0}{\frac {N}{L}}I=\mu _{0}n'I$
where $I\,$ is the current, $N$ is the number of turns, and $n'$ is the number of turns per unit length.
Do the line integral shown. Of the four paths,only l$_1$ is non-zero. If $_{/ell}$ is the length of that path, then the total current enclosed is $_{n'/ell}$

## references

* ↑ https://en.wikipedia.org/w/index.php?title=Amp%C3%A8re%27s_circuital_law&oldid=578507291
* ↑ Example taken from Feynman, Richard; Robert Leighton; Matthew Sands (1964) The Feynman Lectures on Physics, Vol.2, Addison-Wesley, USA, p.18-4, using slightly different terminology.
* ↑ https://commons.wikimedia.org/w/index.php?title=File:Displacement_current_in_capacitor.svg&oldid=38260258
Basic Magnetic Terms definition with Formulas