QiLing Tools

🧲Magnetic Field Simulator - Wires, Loops, Solenoids & Field Lines

This tool turns the standard magnetic-field set pieces of school and university physics into pictures you can play with. In the wire cross-section mode the wires run perpendicular to the screen: add ⊙ (out of the page) or ⊗ (into the page) currents, drag them around, change the current, or drop in a bar magnet (modelled as a uniformly magnetised bar through its equivalent surface currents). Field lines are contours of the vector potential A_z, so they crowd together where the field is strong; overlay arrows or compass needles and a log-scale |B| heat map, and green arrows show the magnetic force on each wire, checked against μ₀I₁I₂/(2πd) when there are two. The loop and solenoid modes show a side cut through the axis: the off-axis field is computed exactly with complete elliptic integrals K and E, field lines are contours of the flux function ψ = ρA_φ, and a chart below plots B(z) along the axis — for a solenoid, the exact finite-length curve against the sum over discrete turns and the ideal μ₀nI. Switch on a Helmholtz pair to see the flat region at the centre. Drag the crosshair probe to read the field magnitude, components and direction anywhere.

Free · No sign-up · Runs in your browserLast updated:

Loading tool...

How to use Magnetic Field Simulator

  1. 1Pick a mode: wire cross-section, circular loop or solenoid
  2. 2In cross-section mode choose a scene or add wires and magnets, drag them, and select one to change its current or remanence; in the loop modes set the radius, current, turns and length
  3. 3Toggle field lines, arrows, compass needles, the heat map and forces, and drag the probe to read B at any point
  4. 4Compare the results, the on-axis B(z) chart and the formulas to see superposition and the right-hand rule at work

FAQ

Why do parallel wires carrying current in the same direction attract?
Each wire sits in the field of the other. By the right-hand rule, wire 1’s field at wire 2 is perpendicular to the line joining them, and F = IL × B then points from wire 2 back toward wire 1 — so like currents attract and opposite currents repel. The force per length is F/L = μ₀I₁I₂/(2πd): two long wires 1 m apart carrying 1 A each feel 2×10⁻⁷ N/m, which used to be the definition of the ampere. The green arrows in the tool are computed live from I ẑ × B.
Is the field inside a solenoid really μ₀nI?
μ₀nI is the result for an infinitely long solenoid. On the axis of a finite one the exact centre value is μ₀nI·(L/2)/√((L/2)² + R²): with a length ten times the radius it is only about 2% below ideal, and it falls toward the ends, where it is roughly half the centre value. The B(z) chart plots the exact and ideal curves together and the results list their ratio, so you can see when the long-solenoid approximation holds.
How are the field lines drawn?
In cross-section mode the field of each long straight wire is the curl of a vector potential A_z = −(μ₀I/2π) ln r, and contours of A_z are everywhere tangent to B. Drawing those contours at equal spacing gives field lines whose density is proportional to |B|. Loops and solenoids are axially symmetric, so their lines are contours of the flux function ψ = ρA_φ (2πψ is the flux through a circle of radius ρ), with A_φ computed exactly from complete elliptic integrals rather than an approximation.
Why does a Helmholtz coil give such a uniform field?
With two coaxial coils carrying the same current and spaced exactly one radius apart, the second derivative of B(z) at the centre vanishes, and the first and third vanish by symmetry, so the field only starts to change at fourth order — it is extremely flat. The centre field is (4/5)^{3/2}·μ₀NI/a. Tick the Helmholtz option and the results show the relative variation within ±a/2, while the B(z) chart develops a clear plateau.