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

> Drag current-carrying wires and bar magnets to see field lines, compass needles and |B|. Exact loop and solenoid fields, on-axis B(z) and forces between wires.

- URL: https://qilingtools.com/en/math/magnetic-field
- Category: Physics Tools (https://qilingtools.com/en/physics)
- Tags: [Physics](https://qilingtools.com/en/tags/physics), [Education](https://qilingtools.com/en/tags/education)
- Last updated: 2026-10-26
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

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.

## How to use

1. Pick a mode: wire cross-section, circular loop or solenoid
2. In 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. Toggle field lines, arrows, compass needles, the heat map and forces, and drag the probe to read B at any point
4. Compare the results, the on-axis B(z) chart and the formulas to see superposition and the right-hand rule at work

## Features

- Place any number of wires and bar magnets and recompute the field live
- Field lines (vector-potential contours), arrows, compass needles and a |B| heat map
- Force arrows between wires, checked against μ₀I₁I₂/(2πd)
- Exact elliptic-integral fields for loops, Helmholtz pairs and finite solenoids
- On-axis B(z): exact, discrete-turn sum and ideal μ₀nI side by side
- Probe readout, solenoid inductance and stored energy, right-hand-rule diagrams

## 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.

## Related tools

- [Unit Converter](https://qilingtools.com/en/math/unit): Free online unit converter: length, area, volume, weight, temperature, time, speed, data, pressure, energy and angle — one value converts every unit at once.
- [Vector Calculator](https://qilingtools.com/en/math/vector): Free online vector calculator for 2D and 3D: addition, scalar multiples, dot and cross products, magnitude, angle, unit vector and projections, with checks.
- [Significant Figures Calculator](https://qilingtools.com/en/math/significant-figures): Free online sig fig calculator: count significant figures digit by digit, round to N sig figs or decimals with six rounding modes, and compute by sig fig rules.
- [Tone Generator](https://qilingtools.com/en/audio/tone-generator): Free online tone generator: sine, square, sawtooth and triangle waves from 1 to 20,000 Hz, a note picker, sweeps, white/pink/brown noise and a WAV download.
- [Audio Spectrogram](https://qilingtools.com/en/audio/spectrogram): Free online spectrogram generator: see time, frequency and level from a Hann-windowed STFT, with FFT size, log axis, dB range and colour maps. Exports PNG.
- [Decibel Meter](https://qilingtools.com/en/audio/decibel): Free online decibel meter: measure noise with your mic in real time, A/C/Z weighting, fast/slow response, min/max/average/Leq, 60-second graph and calibration.
- [Physics Formula Calculator](https://qilingtools.com/en/math/physics): Physics formulas solved with steps: SUVAT, projectiles, Newton’s laws, inclines, energy, Ohm’s law, resistors, RC, buoyancy, waves, lenses, gravity.
- [Fourier Series & FFT Visualizer](https://qilingtools.com/en/math/fourier): Fourier series coefficients and animated partial sums for square, sawtooth, triangle or any function (Gibbs), draw-your-own epicycles and FFT spectra.
