Adjust inputs and press Play to animate the loop simulation.
The circular loop is the most elementary building block of many magnetic devices. When electric current flows around a closed path, it establishes a magnetic field that threads through the loop and extends outward into space. This simulator keeps the original purpose of the calculator—computing the magnetic field at the center via —while augmenting it with an animated model of a test charge responding to that field. By observing the particle's trajectory and the shading that reflects the field magnitude across the plane of the loop, users gain intuitive insight into how current and radius influence magnetic behavior. The model assumes a single, perfectly circular loop of negligible thickness immersed in vacuum so that the permeability is and no ferromagnetic materials disturb the field.
The system uses the following variables: current in amperes, loop radius in meters, particle charge in coulombs, particle mass in kilograms, and numerical time step in seconds. The magnetic field is computed directly from the Biot–Savart law by dividing the loop into sixty segments and summing their contributions at each point in the canvas. The test particle starts to the right of the loop with its velocity pointing upward so that the Lorentz force bends it into a curved path. Idealizations include ignoring radiation reaction, resistive losses in the wire, and relativistic effects; speeds remain low compared with the speed of light. The absence of electric fields means the magnetic force does no work, so the particle's kinetic energy should remain constant except for numerical error.
The magnetic field contribution from a small segment of current is expressed through the Biot–Savart law:
where is a differential element of the loop and is the vector from the element to the field point. The simulator discretizes the loop and sums these contributions to obtain . The particle's motion follows Newton's second law with the magnetic Lorentz force:
The kinetic energy should remain constant, enabling energy drift to serve as a diagnostic of numerical accuracy. All units are SI, and inputs are validated to prevent NaN or infinite values.
The simulator advances the particle using a classical fourth-order Runge–Kutta (RK4) integrator. At each step, the state vector is updated by evaluating the derivatives four times and combining them to achieve an error on the order of . The time step is clamped between 1×10-5 and 0.05 seconds to balance accuracy and performance. Field calculations are debounced so that rapid changes in input parameters do not trigger redundant recomputation. Because the Biot–Savart evaluation is the most expensive operation, the grid of field magnitudes is precomputed when inputs change, allowing smooth animation thereafter. The HTML canvas is redrawn at roughly 60 frames per second, and the simulation loop subdivides each frame into however many fixed time steps are required to integrate the motion stably.
Suppose a loop of radius 0.10 m carries a current of 5 A. The magnetic field at the center is , which evaluates to approximately 3.14×10-5 T. If a particle with charge 1 µC and mass 1 µg enters this field with speed 100 m/s, the radius of its circular motion near the center should be , yielding about 0.32 m. Running the simulation with these parameters shows the particle tracing a loop of comparable size. Deviations from perfect circularity arise because the field is weaker away from the center, illustrating how spatial variation in affects dynamics. The energy bar below the canvas tracks kinetic energy and reveals only a tiny drift—usually less than 0.1%—demonstrating the stability of the RK4 integrator.
Case | I (A) | R (m) | Bcenter (µT) |
---|---|---|---|
Baseline | 5 | 0.10 | 31.4 |
Double Current | 10 | 0.10 | 62.8 |
Double Radius | 5 | 0.20 | 15.7 |
The gray circle indicates the wire loop. Background shading darkens where the magnetic field magnitude is stronger; near the center the color is most intense. A small orange particle represents the charged test body. Pressing “Play” sets it in motion according to the Lorentz force. Because the field points perpendicular to the canvas, the particle curves within the plane without spiraling out. The energy bar displays the current kinetic energy relative to its initial value, while the live summary announces the field at the center and the relative energy drift. The CSV download provides time, position, velocity, and energy at each step for further analysis.
Although informative, the simulation simplifies several realities. The Biot–Savart integral uses a modest number of segments, so the field is approximate, especially near the wire. Finite wire thickness, skin effects at high frequencies, and mutual inductance with other circuits are ignored. The particle is treated classically; quantum effects such as Landau quantization are neglected. Because only magnetic forces are considered, electric fields from charge separation in the wire are absent, and radiation emitted by the accelerating charge is ignored. Numerical errors accumulate if the time step is set too large, and extremely strong currents can cause the particle to exit the canvas before meaningful behavior is observed.
Future iterations could include multiple loops or a solenoid to show field superposition, adaptive time stepping to maintain a chosen error tolerance, or relativistic corrections when particle speeds approach light speed. Coupling the simulation to an electric circuit model would permit exploration of Lenz's law and induced currents. A phase-space plot of velocity components could reveal conservation of the speed magnitude more clearly, while 3D rendering would better depict the toroidal structure of the magnetic field.
Related calculators: Magnetic Field of a Solenoid, Magnetic Field of a Straight Wire, Magnetic Dipole Field.