Samsara blog
Electromagnetics of current loops

  1. Introduction - 20 March 2021

Top of blog

Introduction - 20 March 2021

This project is about calculating and displaying the electric and magnetic fields created by an arbitrary configuration of current loops, or by any arbitrary configuration of moving and non-moving charges. Loops can be combined into aggregate structures such as stacks, tori, sheets, spheres, and meshes embedded in a surface.

The math

The calculations performed by this program are fairly simple (and probably equally naive), but they must be performed for every combination of (x, y, z) grid point with every individual charge. However, all calculations are independent of one another and could all be performed in parallel, if possible, although they must eventually be combined and summed to form the final fields:

dE(x,y,z,i) = c1 * charge(i) / |R(i)|^2, in the direction of R(i);  E(x,y,z) = sum(dE(x,y,z,i)) over all charges i

dB(x,y,z,i) = c2 * charge(i) * (V(i) X R(i)) / |R(i)|^3, in the direction of V(i) X R(i);  B(x,y,z) = sum(dB(x,y,z,i)) over all charges i

where c1 and c2 are coupling constants currently set to 1.0, E, B, R, and V are 3d vectors, and X is the 3d vector cross-product.

The E field is calculated from all electric charges, whereas the B field is calculated only from moving electric charges. All the fields created here are static. They are snapshots in time, and there is no dynamical motion (i.e. no forces are calculated). The display reference frame is "at rest," and the motions of aggregate structures (such as stacks of loops) are added to individual charges before calculation. The calculations can all be performed interactively on one computer while you wait, or they can be broken into pieces and distributed to multiple servers in real time, or as batch jobs, and then combined and displayed as they are completed.


A single stationary positive electric charge creates an electric field that (almost) everywhere points away from the charge (the field is undefined at the charge), and no magnetic field. Similarly, a stationary negative electric charge creates an electric field that points toward the charge. In the bottom middle plot, the vector lengths have been scaled, as well as the colors, to show the actual magnitude of the field at each point, which decreases with distance:

A positive electric charge moving in a particular direction (or a negative electric charge moving in the opposite direction) creates a magnetic field around it. Everywhere, the field is orthogonal to both the direction of motion and the radius vector from the charge to the calculated location. The direction of motion defines an orthogonal plane of possible B field directions, and the radius at each point limits the possibilities to two tangential directions. Thus, the B field tends to encircle the charge along its direction of motion. In this model, the E field is unaffected by the motion. As well, the B field is undefined at the charge, although it tends to zero there, unlike the electric field:

Two opposite electric charges separated by a short distance produce the familiar electric dipole:

If they move in the same direction (or in any other directions), they produce a particular magnetic field:


The same field is produced by two similar electric charges moving in opposite directions. The orientation of the configuration has been changed so that the charges now move in the XY plane:

A similar field is produced by 4 moving charges:

As more charges are added, the field approaches the continuous ideal (at the resolution of the grid). The last row of plots have 128 charges, but the loop is now shown as a continuous curve:

In this program, current lines, loops, and other aggregate structures are composed of discrete charges distributed along their geometry at a granularity that is (usually) smaller than that of the computational grid (e.g. the array of 3d point locations). This is done because:

  1. Although there is a known solution (equation) for the electric and magnetic fields surrounding a continuous electric current loop, this solution involves elliptical integrals, which must be approximated on the computer anyway, requiring additional calculation time, without necessarily any additional accuracy.
  2. In the "real world," all currents are likely discontinuous and composed of discrete charges, whether they are individually tracked or not.
  3. One of my uses for this program is to elucidate the fields surrounding a network of loops carying specific discrete signals, which are manifested as charges and gaps.

Below is an example of 5 random current loops. Loops appear green when a positive current flows in the counter-clockwise direction, and red when it flows clockwise, as seen from the 3d viewpoint. When shown as individual charges with velocity arrows, positive charges are green, and negative charges red (no matter what way they are going):

Here are the magnetic and electric fields:


Loops can be combined into stacks:

or tori:

or sheets, etc...:


One of the more interesting configurations (to me) is a sphere of parallel current loops that follow the lines of latitude. Initially, the charges in each loop rotate about their common center at the same angular rate, as if the sphere was a solid rotating shell of charge:

Here are the magnetic and electric fields:

In the next example, the loop rotation rate decreases between the equator and the poles (in this case, from 1.0 at 0 degrees latitude to 0.0 at +-90 degrees). This is called differential rotation, and is thought to be a property of stars like our own. Compare the following figure to the one above:

This has the effect of making the magnetic field slightly stronger at the equator and weaker at the poles. Compare the following plots without (left) and with (right) differential rotation:

The electric field is the same in both cases:


Here is an example of several randomly oriented current loops embedded in the surface of a sphere:

Below are the corresponding magnetic and electric fields. Note that in addition to an overall background field which is different inside and outside of the sphere (as in the plots above), there are local features near the surface of the sphere that appear in both the magnetic and electric fields, and which resemble the radial and circumferential fields of a single moving charge, and the electric dipole. This appears to be a general property of these configurations:

One problem with the configurations above is that the loops should probably not cross. Here is an example of a similar configuration where they do not touch:

Here are the magnetic and electric fields. Note again that most of the interesting features occur in or just above the surface of the sphere where the currents come close together:

Ideally, the current in each loop should be going the same direction as in nearby loops, and all should be rotating aligned with the sphere's axis of rotation. Note that this should be possible at the higher latitudes (near the poles), but not at the equator. This is an interesting combinatorial problem in itself, and might be the topic of a later update.


If I had time, and was so inclined, I would also look at the electric and magnetic fields from a meandering river of current, including loopbacks and cutoffs (click image for full size):

Imagine, if you can, fields similar to those above surrounding several current rivers embedded in a sphere. One would expect the local features of both fields to depend on the curvature of the flow, and the proximity to other flows in the same and other streams. You can see more about meandering river simulations here.


Different 3d point grids can be used for the calculations. Here is a charge configuration of 25 random non-crossing loops embedded in a sphere:

Now the calculations are performed on a spherical grid of points at different {radius, latitude, longitude}. Cross-sections can be shown for different radii:

For different latitudes:

And for different longitudes (and the loops are not drawn):

Rectangular grids allow cross-sections at different x, y, or z values:

At left is another random loop configuration. At right, the orientation of current flow in each loop is in the same direction as the rotation of the sphere. In the latter case, the overall magnetic field is also generally aligned with the rotational axis (the z axis):

Next: complex charges.

13 Apr 2021

©Sky Coyote 2021