Figure 1-1. One positive and one negative charge oscillating
Overview
There are two simulation methods included in the repository, but the pipeline for each is the same. Each simulation is run with a given timestep, iteration count, and point charge generating function. The script runs through the simulation and stores the information in .jld2 files located in the /cache directory. Then the user runs the plot.jl file, specifying colors and post processing the vectors, to generate a .mp4 video animating the motion of the point charges and electric and magnetic fields.
The first simulation method is jefimenko-feynman.jl, which uses the Jefiimenko-Feynman (Heaviside-Feynman) equations to find the electric and magnetic fields based on the positions of the point charges.
The second method is causal-rk4.jl, which uses a Runge-Kutta 4 solver to iterate an initial electric field with Maxwell's equations. In this simulation the electric field can be seen as directly causing the magnetic field, whereas the jefimenko-feynman method instead views electric and magnetic fields as being directly generated by charges and currents.
Point Charge Generation
The point charges are generated by a function, and each one has a position parametrized as a function of time, as well as a change. The position function can be manually edited to generate a number of complex parametric shapes. The function below will generate 32 point charges that move around in a toroid.
function getPointCharges()
function toroid(t, ϕ)
w = 0.5
r = 2.5
k = 16
s = 0.075 * c * t + ϕ
return [cos(s) * (r + w * sin(k * s)),
sin(s) * (r + w * sin(k * s)),
w * cos(k * s)]
end
return [PointCharge(t -> toroid(t, ϕ), 1) for ϕ in 0:π/16:31π/16]
end
Figure 2-1. Magnetic field generated by 32 point charges moving in a toroid
If the number of charges is increased to 64, the structure becomes more apparent (Figure 2-2). Note that the magnetic field inside the torus points along the toroidal direction, while in the center of the torus the field points in the negative z direction.
Figure 2-2. Magnetic field generated by 64 point charges moving in a toroid
Here's an animation of 4 point charges rotating in a circle (Figure 2-3). Notice that the magnetic field in the middle is rather strong and points in the negative z direction.
Figure 2-3. Magnetic field generated by 4 point charges moving in a circle