Presets
Playback
Coils
Probe
Charged particle
Camera
Layers
Quality
Model check
The science
What this page shows
A set of coaxial circular current loops (a single loop, a Helmholtz pair, a solenoid, an anti-Helmholtz pair or a magnetic bottle) and the magnetic field they make. The field is not a drawing: at every point it is the exact sum of the fields of the individual loops. You can drop a charged particle into the field and watch it spiral along the field lines, bounce between the ends of a bottle, or leave the window.
Field of one current loop
For a loop of radius a carrying current I, at axial position z and distance ρ from the axis the exact field components are Bz = (μ0 I / 2π) [K(m) + (a² - ρ² - z²)/((a-ρ)²+z²) E(m)] / √((a+ρ)²+z²) and Bρ = (μ0 I z / 2πρ) [-K(m) + (a² + ρ² + z²)/((a-ρ)²+z²) E(m)] / √((a+ρ)²+z²), where K and E are complete elliptic integrals with parameter m = 4aρ / ((a+ρ)² + z²) (the page computes them with the arithmetic-geometric mean). On the axis this reduces to Bz = μ0 I a² / (2 (a² + z²)3/2). A coil with N turns carries an effective current N I. Fields of several loops simply add.
Helmholtz and anti-Helmholtz pairs
Two identical loops one radius apart (separation = R) make an almost uniform field between them, because the second derivative of Bz cancels at the centre: B = (4/5)3/2 μ0 N I / R. Reversing one current (anti-Helmholtz) gives zero field at the centre and a constant gradient around it, a quadrupole, as used to trap cold atoms.
Field lines and the colour map
Field lines are curves that are everywhere parallel to B; the page integrates dr/ds = B/|B| with a midpoint step. They never end, because ∇·B = 0: they close on themselves, so lines that leave one end of a solenoid return around the outside. The colour map shows log |B|. Compass needles point along B (red end = north).
Charged-particle motion
The force is F = q v × B, which does no work, so kinetic energy is constant. The page uses the Boris method (drift, rotate about B, drift), which keeps the speed exact to rounding. In a uniform field the particle circles at the gyro-radius r = m v⊥ / (|q| B) with period 2π m / (|q| B) and drifts along B at v∥. In a slowly varying field the magnetic moment μ = m v⊥² / (2B) is an approximate constant (an adiabatic invariant), so when the particle moves into stronger field v⊥ grows at the expense of v∥ and, if the field is strong enough at the ends, v∥ reaches zero and the particle is reflected: a magnetic mirror. Two coils spaced more than one radius apart form a magnetic bottle that traps particles whose pitch angle is large enough.
Checks run in the page
1. Loop field near the axis against the closed-form axis formula. 2. Helmholtz centre field against (4/5)3/2 μ0 N I / R, and the vanishing curvature at the centre. 3. ∇·B = 0 by central differences at five points. 4. A proton in a bottle: energy conserved to rounding and magnetic moment constant within 6 % over thousands of gyrations.
Honest simplifications
The loops are infinitely thin filaments; a real winding has a finite cross-section, and the field inside the copper differs. There is no iron (a core would multiply the field and is not modelled), no self-inductance or heating, and the particle does not radiate or collide. The particle starts in the plane y = 0 and the drawing of its path in the 2D view is its projection on that plane. The speeds in the sliders are chosen so that gyro-radii are visible at the coil sizes shown, not to model a specific experiment.