The electromagnetic field is fully described by a vector field called the
4-potential
. It has four components that we can label any way we
want, the traditional way is to use:

where
is called the electrostatic scalar potential,
is called
the vector potential and
is the speed of light.
The Lagrangian density for the free (noninteracting) field is:

The Lagrangian for a (charged) particle is:

it produces the following charge density:

The interaction between the charged particle (or in general any charged body) with some charge density and the electromagnetic field is given by the Lagrangian density:

where:

There are several approaches how to obtain the above Lagrangians from some other assumptions, but ultimately the exact form of the Lagrangians has to be given by experiment. It is our only assumption and we derive everything else from it. All together, the Lagrangian of a charged particle and an electromagnetic field is:
(1)
Note that:

The Euler-Lagrange equations for the electromagnetic field (in terms of
and
) are:

(2)
Equations for the particle (in terms of
and
) are:

(3)
Where
is called the electromagnetic field strength tensor:

The only way to measure the electric field is through its interaction with the
charge particle. As such, the actual physical field (that can be measured) is
, which is invariant under any gauge transformation:

where
is a gauge function:

In other words, two different
related by the gauge transformation
represent the exact same physical electromagnetic field (as given by the field
tensor). As such, we can modify the Lagrangian by applying the gauge
transformation to the field
: this changes the equations of motion for
the field (thus the numerical values for
will be different), but
doesn’t change the equation of motion for the particle, so the change will not
have any physical effect (cannot be measured).
By choosing
as a solution to the equation
, we get:

So for any 4-potential we can find
such that the transformed 4-potential
obeys the Lorenz gauge condition
.
In order to obtain a gauge
invariant Lagrangian, we need to express it using
using the
following identity:

The 4-divergence
doesn’t change Euler-Lagrange equations, so we can ignore it.
We can see, that in the Lorenz gauge
the term
(which is gauge invariant)
simplifies to the term
in the
Lagrangian (1). The gauge invariant Lagrangian is:
(4)
The E.-L. equation for the particle doesn’t change, the equation for the field becomes:

(5)
Which in Lorenz gauge simplifies to equation (2).
In order to write equations of motion in terms of
only, we
need another equation for it:
(6)
We used the fact, that the partial derivatives are symmetric in the indices
and
while
is antisymmetric.
Maxwell’s equations are the equations for the electromagnetic field in terms of the physical field strengh tensor, equations (5) and (6):

The field strength tensor is antisymmetric, so it has 6 independent components (we use metric tensor with signature -2):

There is freedom in how we label the components. The standard way is to express
them using physical fields
and
that are introduced by:

or in components:

Comparing to the above, we get:

In particular:

so we get:

In terms of
and
fields, the Maxwell’s equations become:

In Lorenz gauge, the equation for the 4-potential is (2):

The solution to this equation is:

For scalar potential (
) we get:

And for vector potential (
) we get:
(7)
The equation for the charge particle (3) is:

In components:

Using coordinate time
and coordinates
instead of the proper time
and 4-vector
, we need to rewrite the action:

where
is the Lagrangian expressed in coordinates
and
(and thus is not Lorentz invariant):

the particle’s canonical momentum
is:

where
is the kinetic momentum.
Euler-Lagrange equations are:

For continuous case (current), the force due to the magnetic field is:

Expressing
in terms of
we get:

The system of equations was solved for
using the code
(in there
,
and
):
>>> from sympy import var, solve
>>> var("P1 P2 P3 m c v1s v2s v3s")
(P1, P2, P3, m, c, v1s, v2s, v3s)
>>> vs = v1s+v2s+v3s
>>> solve([P1**2*(1-vs/c**2) -v1s*m**2,
... P2**2*(1-vs/c**2) -v2s*m**2,
... P3**2*(1-vs/c**2) -v3s*m**2], [v1s, v2s, v3s])
{v1s: P1**2*c**2/(P1**2 + P2**2 + P3**2 + c**2*m**2),
v2s: P2**2*c**2/(P1**2 + P2**2 + P3**2 + c**2*m**2),
v3s: P3**2*c**2/(P1**2 + P2**2 + P3**2 + c**2*m**2)}
And the absolute value was removed by using the fact, that
has the same
sign as
which follows from the second equation.
The Hamiltonian is:

The stress tensor is calculated from the Lagrangian:

using the Noether formula:

We raise the
index:

This tensor is not symmetric under the exchange of the
indices. To
make it symmetric, we add a total derivative term
, where
is antisymmetric
in its first two indices. This guarantees that
so that the new stress energy
tensor is still conserved. We choose
and get:

where we used
.
Another way to derive the stress energy tensor is from general relativity using the formula:

So we write the action:

And vary with respect to
:

And we get:

Maxwell’s equations in Lorenz gauge (2):

have the solution for the vector potential (7):

Assuming
:

The magnetic field is then:

If the current can be approximated by an infinitely-narrow wire, we get:

and:

Let’s assume infinite straight wire carrying constant current
:

Where we used the value of the folowing integral:
![\int_{-\infty}^\infty {\d l \over (x^2+y^2 + (z - l)^2)^{3\over 2} }
= \int_{-\infty}^\infty {\d u \over (x^2+y^2 + u^2)^{3\over 2} } =
= \left[u\over (x^2+y^2) \sqrt{x^2+y^2 + u^2}\right]_{-\infty}^\infty
= \left[\sign u\over (x^2+y^2) \sqrt{
\left(x\over u\right)^2 + \left(y\over u\right)^2 + 1}
\right]_{-\infty}^\infty =
= {1\over x^2+y^2} - \left(-{1\over x^2+y^2}\right) = {2\over x^2+y^2}](../../_images/math/2700a818e0cb88645a9936b21a0d10e5c6ab4f31.png)
For
:

Let’s assume a circular loop:

Due to the symmetry of the problem, we can set
:

In the last equation we used the fact, that
is odd and
is
even on the interval
.
For
we get:

Helmholtz coil is a set of two circular loops of radius
, that are
apart, where
. Let’s calculate the magnetic field on the axis.
Magnetic field of the first coil is (see the previous example):

Second coil is positioned
above the first one:

The total magnetic field is:

The field in the middle:

For
we get:

where the magnitude of
is:

For
and
turns we get the magnitude of the field as
(we use SI units, so
is in
and
in tesla):

Code:
>>> from math import pi, sqrt
>>> "%e" % (8*4*pi*1e-7*130 / (5*sqrt(5)*0.15))
'7.792861e-04'
Equation of motion for an electron in this field is:

The general solution is:

So the electron is moving in a circle with a center
,
depends on the initial direction of the velocity and
is the magnitude
of the initial velocity. There can also be a possible movement in the
direction, but for the following initial conditions there is none:

Then we get:

So the radius of the circle is
.
Let the electrons by accelerated by the electric potential
:

So the initial velocity is:

and we get for the radius:

from which the electron charge versus mass ratio is:

For
,
,
,
,
we get:

Code:
>>> from math import pi
>>> r = 0.15
>>> N = 130
>>> V = 300
>>> R = 0.05
>>> I = 1.48
>>> mu0 = 4*pi*1e-7
>>> "%e" % (125 * V * r**2 / (32 * mu0**2 * R**2 * N**2 * I**2))
'1.804238e+11'
Reference value is:

Code:
>>> e = 1.6021766e-19
>>> c = 299792458
>>> eV = e
>>> KeV = 1e3 * eV
>>> m = 510.998910 * KeV / c**2
>>> m
9.109382795192204e-31
>>> "%e" % (e / m)
'1.758820e+11'
or even simpler (we do not actually need the value of the electron charge
):
>>> c = 299792458
>>> KeV = 1e3
>>> m = 510.998910 * KeV / c**2
>>> "%e" % (1/m)
'1.758820e+11'
We can use the experimental value to calculate the electron rest mass energy:

The force on a wire 1 due to a magnetic field of a wire 2 is:

Where
is the magnetic field produced by the wire 2.
Combining these two equations we get:

We calculate the force between two parallel straight infinite wires:

Where we used the value of the folowing integral:
![\int_{-\infty}^\infty \d l_2 {d \over (d^2 + (l_1 - l_2)^2)^{3\over 2} }
= \int_{-\infty}^\infty \d x {d \over (d^2 + x^2)^{3\over 2} } =
= \left[x\over d \sqrt{d^2 + x^2}\right]_{-\infty}^\infty
= \left[\sign x\over d \sqrt{\left(d\over x\right)^2 + 1}
\right]_{-\infty}^\infty =
= {1\over d} - \left(-{1\over d}\right) = {2\over d}](../../_images/math/0ac5fb6791eab43ede18a5933fd4a552b24d2575.png)
As such, the direction of the force on the first wire (at coordinates
going in the
direction) will be to the left and the force per
unit length is:

Because the second wire is at the coordinates
and the force on the first wire is in the direction
, the force between the wires is attractive, as long as
and
have the same sign (either both currents go up, or both down)
and repulsive if
and
have opposite signs.
Let
,
, then the force is attractive and
(we also use
):

We calculate the force between two perpendicular straight infinite wires:

The integral is an odd functin of
, so it is zero. We used the value of
the folowing integral (but in fact it is already seen before this integral is
needed that the double integral must be zero):
![\int_{-\infty}^\infty \d l_2 {l_1 \over (d^2 + l_1^2 + l_2^2)^{3\over 2} }
= \left[l_1 l_2\over (d^2+l_1^2) \sqrt{d^2 +l_1^2 + l_2^2}
\right]_{-\infty}^\infty
= \left[l_1 \sign l_2\over (d^2+l_1^2)
\sqrt{\left(d\over l_2\right)^2 + \left(l_1\over l_2\right)^2 + 1}
\right]_{-\infty}^\infty =
= {l_1\over d^2+l_1^2} - \left(-{l_1\over d^2 + l_1^2}\right)
= {2 l_1\over d^2 + l_1^2}](../../_images/math/f52fc0089fc40e5c7609eb76a41f487957edd576.png)
As such, there will be no net force.
We calculate the net force on a square loop with current
of side
,
whose center is
far from an infinitely long wire with current
:
The wire has coordinates
and the magnetic field from it is (see the
example above):

The four sides of the loop are (
):

and the differentials are:

The net force on the loop is:
![{\bf F} = I_1 \int \d {\bf l}_1 \times {\bf B}
= I_1 \int \d {\bf l}_1 \times (0, -1, 0) {\mu_0 I_2 \over 2\pi
({\bf l}_1)_x} =
= {\mu_0 I_1 I_2\over 2\pi}\left(
\int_0^a {(0, 0, 1)\d l_1\over d-{a\over 2} + l_1}
+\int_0^a {(1, 0, 0)\d l_1\over d+{a\over 2}}
+\int_0^a {(0, 0, -1)\d l_1\over d+{a\over 2}-l_1}
+\int_0^a {(-1, 0, 0)\d l_1\over d-{a\over 2}}
\right) =
= {\mu_0 I_1 I_2\over 2\pi}\left(
(0, 0, 1)\left[\log \left| d-{a\over 2} + l_1 \right|
-\log \left|d + {a\over 2} - l_1\right| \right]_0^a
+(1, 0, 0)\left({a\over d + {a\over 2}}-{a\over d - {a\over 2}}
\right)\right) =
= {\mu_0 I_1 I_2\over 2\pi}\left(
(0, 0, 1) \cdot 0 +
(1, 0, 0){a^2\over d^2 - \left({a\over 2}\right)^2}
\right) =
= (1, 0, 0){\mu_0 I_1 I_2\over 2\pi}
{a^2\over d^2 - \left({a\over 2}\right)^2}](../../_images/math/43dc2f7277403febd2a0e0a896f1b23511ec814d.png)

A good model of a bar magnet of the length
and width
is a combination
of two magnetic monopoles (that sit inside the magnet, so one cannot actually
see them, just their behavior outside the magnet):

where:

The magnetic moment vector is:

and its magnitude then is:

The permeability is:

For a typical bar magnet, we have for example:

The unit of
is Tesla:
.
We throw a magnet through a coil and calculate the voltage on the coil.
We use two model of the bar magnet: a magnetic dipole and two monopoles
apart.
Geometry:

Field of the dipole:

we will need:

and

Field of two monopoles:

we will need:

and

Now we can calculate the voltage:

for the dipole we get

For two monopoles we get

For the dipole, the function

has a maximum and minimum for:

with the max value:

Code:
>>> from sympy import var, solve, S, refine, Q
>>> var("a z")
(a, z)
>>> f = z / (a**2+z**2)**(S(5)/2)
>>> solve(f.diff(z), z)
[-a/2, a/2]
>>> f.subs(z, a/2)
16*sqrt(5)*a/(125*(a**2)**(5/2))
>>> refine(f.subs(z, a/2), Q.positive(a))
16*sqrt(5)/(125*a**4)
So the maximum voltage is:

If we drop the magnet from height
above the coil into it, then its speed
will be
in the middle of the coil, when
. Then:

And we get for the voltage dependence for dipole:

The time difference between the maximum and minimum is the time difference
between
and
, so:

The total flux doesn’t depend on the particular dependence of
and
:
![\Phi = \int_0^\infty V(t) \d t =
= - {3\mu_0 m\over 2} \int_0^\infty{v(t)a^2z(t)
\over (a^2 + z(t)^2)^{5\over2}} \d t =
= - {3\mu_0 m\over 2} \int_0^\infty{{\d z\over\d t}a^2z(t)
\over (a^2 + z(t)^2)^{5\over2}} \d t =
= - {3\mu_0 m\over 2} \int_0^\infty{a^2z
\over (a^2 + z^2)^{5\over2}} \d z =
= - {3\mu_0 m\over 4} \int_{a^2}^\infty{a^2
\over u^{5\over2}} \d u =
= - {3\mu_0 m a^2\over 4} \left(-{2\over 3}\right)
\left[1\over u^{3\over2}\right]_{a^2}^\infty =
= - {3\mu_0 m a^2\over 4} \left(-{2\over 3}\right)
\left[-1\over a^3\right] =
= - {\mu_0 m \over 2a}](../../_images/math/fb17ad83f8b94e8db60fc931b69439595ccefd7a.png)
For the voltage dependence of two monopoles, we get:

The total flux doesn’t depend on the particular dependence of
and
:

Note that in the limit
, we get the magnetic moment
and
the last formula for two monopoles flux becomes the dipole flux.
As a particular example, consider a coil with
loops,
,
,
. Then the total flux from the second peak
is:

Code:
>>> from math import pi, sqrt
>>> mu0 = 4*pi*1e-7
>>> cm = 0.01
>>> Q_m = 43.
>>> d = 1.8*cm
>>> a = 1.4*cm
>>> N = 500
>>> -N*mu0*Q_m*d/sqrt(a**2+d**2)
-0.02132647889395681
For a single loop with
we get:

and for a single loop with
we get:

Code:
>>> a = 1.25*cm
>>> -mu0*Q_m*d/sqrt(a**2+d**2)
-4.438304942066266e-05
>>> a = 1.8*cm
>>> -mu0*Q_m*d/sqrt(a**2+d**2)
-3.820879326816195e-05
Let’s consider resistor (with voltage
) and capacitor (with voltage
and current
) in a series. Voltage on the battery
is
, then the equation for the circuit is:

with initial condition
. We differentiate it:

and the initial condition follows from the first equation
.
The solution is:

Now we calculate the charge (using the initial condition for the charge above for the lower bound of the integral):
![Q(t) = \int_0^t I(t') \d t'
= {V\over R} \int_0^t e^{-{t'\over RC}} \d t'
= {V\over R} \left[-RC e^{-{t'\over RC}}\right]_0^t =
= {V\over R} \left[-RC e^{-{t\over RC}}+RC\right]
= VC \left(1-e^{-{t\over RC}}\right)](../../_images/math/0b6ebfebdf4c440c867662a9e935cb23ec07aae9.png)
The voltage on the resistor is:

The voltage on the capacitor is:

Half life of the capacitor is defined as the time
so that the charge is
half of the total charge, and we get:

In general, the task is to find the five quantities:

where
(
) is the electron (hole) concentration,
(
) is the electron (hole) current density,
is the
electric field.
And we have five equations that relate them. We start with the continuity equation:

where the current density
is composed of electron and hole current
densities:

and the charge density
is composed of mobile (electrons and holes) and
fixed charges (ionized donors and acceptors):

where
and
is the electron and hole concetration,
is the net
doping concetration (
where
is the concentration of ionized
donors, charged positive, and
is the concentration of ionized acceptors,
charged negative) and
is the electron charge (positive). We get:

Assuming the fixed charges
are time invariant, we get:

where
is the net recombination rate for electrons and holes (a positive
value means recombination, a negative value generation of carriers). We get the
carrier continuity equations:
(8)
Then we need material relations that express how the current
is
generated using
and
and
. A drift-diffusion model is to assume
a drift current (
) and a diffusion (
),
which gives:
(9)
where
,
,
,
are the carrier mobilities and
diffusivities.
Final equation is the Gauss’s law:

(10)
Combining (9) and (8) we get the following three
equations for three unknowns
,
and
:

And it is usually assumed that the magnetic field is time independent, so
and we get:
(11)
These are three nonlinear (due to the terms
and
) equations for three unknown functions
,
and
.
We can substract the first two equations and we get:

and using
and
, we get:

So far we didn’t make any assumptions. Most of the times the net doping
concetration
is time independent, which gives:

Assuming further
, we just get the equation of
continuity and the Gauss law:

Finally, assuming also that that
doesn’t depend on
time, we get:

Let’s calculate the 1D pn-junction. We take the equations (11) and
write them in 1D for the stationary state
(
):

We expand the derivatives and assume that
and
is constant:

and we put the second derivatives on the left hand side:
(12)
now we introduce the variables
:

and rewrite (12):

So we are solving the following six nonlinear first order ODE:
(13)