In electronic circuits, electrons flow through the wires, but the energy does not. The energy flows through the fields surrounding the wires. The direction of that flow is determined by the Poynting vector, named after John Henry Poynting. Yes, it's a pun and I love it. Anyway, the operation looks like this:
where
The code is done in Python 3.8 using the Visual Python 7 (vpython) package. If you haven't already, install Python then type the following into your command line to add the vpython package:
pip install vpython --upgrade
All calcuations are done for when the circuit is in something called the "steady state", which is when circuit has found an equilbrium (i.e. not immediately after you turn it on). That means the display is static. There is no animating. The program performs the calcuations, displays the objects and arrows, and then stops.
The yellow sphere is supposed to be a light bulb and the blue cylinder is a battery. For the arrows: cyan is the electric field, orange is the magnetic field, and white is the Poynting vector. Strong effects are shown as larger arrows.
My goal was to confirm the orientation of the Poynting vector given the steady state conditions. You can see from the image above that, while the energy does flow through the field outside the wires, most of the energy is immediately outside the wires. The energy still mostly flows along the wires. I discuss this weird effect in the following videos:
This code is under the GNU General Public License v3.0.