All published worksheets from http://sagenb.org
Image: ubuntu2004
The import commands load the libraries we will need to call certain functions.
Define some useful constants
Define a function for computing the field of a particle with a magnetic dipole
Define a function for computing the field of a magnetic monopole
We will compute the flux at points along a radius of the loop, separated by a distance dR, and use this to compute the integrated flux over the entire loop
Below is the main loop over time. At each time step, we move the particle forward according to its speed, compute the fields at each point along the radius of the loop, and from this we compute the flux. By keeping track of the flux from the previous time step in variables called oldflux, we may approximate the flux derivative as the ratio of the change in flux and the change in time.
The following commands make a nice plot of our results.