Understanding the solenoid and wire magnetic field calculator — concept and principle
This calculator estimates the magnetic flux density inside a long solenoid and around a long straight wire, and gives the inductance of the solenoid for a 1 cm² cross-section. It helps with coil design, physics problems and checking whether a cable could disturb a compass.
How it is calculated
- Long solenoid: B = µ₀ · µr · (N / L) · I, where N is the number of turns and L the coil length in metres. Shown in millitesla.
- Long straight wire: B = µ₀ · I / (2πr), with r the distance from the wire. Shown in microtesla.
- Solenoid inductance: L_coil = µ₀ · µr · N² · A / L, with A fixed at 1 cm² = 10⁻⁴ m². Shown in millihenries.
µ₀ = 4π × 10⁻⁷ H/m is the magnetic constant. For another cross-section, multiply the inductance by the area in cm².
The principle
Both formulas come from Ampère's circuital law, which says that the magnetic field summed around a closed loop equals µ₀ times the current passing through the loop. For a straight wire, the field lines are circles around it, so B times the circumference 2πr equals µ₀I. For a long solenoid, the field inside is nearly uniform and parallel to the axis, and almost zero outside. A rectangular loop of length L that passes through the coil encloses N turns, giving B · L = µ₀NI. A core material multiplies the field by its relative permeability µr. Inductance follows because the flux through each turn is B · A and there are N turns linking it.
Worked example
- Inputs: I = 2 A, N = 500 turns, L = 0.2 m, r = 0.01 m, µr = 1.
- Turns per metre: 500 ÷ 0.2 = 2,500 /m.
- Solenoid field: 4π × 10⁻⁷ × 2,500 × 2 = 6.2832 × 10⁻³ T = 6.2832 mT.
- Wire field: 4π × 10⁻⁷ × 2 ÷ (2π × 0.01) = 4 × 10⁻⁵ T = 40 µT.
- Inductance: 4π × 10⁻⁷ × 500² × 10⁻⁴ ÷ 0.2 = 1.5708 × 10⁻⁴ H = 0.15708 mH.
| Length (m) | Solenoid field (mT) |
|---|---|
| 0.05 | 25.13274123 |
| 0.1 | 12.56637061 |
| 0.15 | 8.37758041 |
| 0.2 | 6.283185307 |
| 0.25 | 5.026548246 |
| 0.3 | 4.188790205 |
| 0.4 | 3.141592654 |
How to read the result
For comparison, Earth's magnetic field at the surface is roughly 25 to 65 µT, so a 2 A wire at 1 cm produces a field of the same order and can deflect a nearby compass. A few millitesla is typical of an air-core coil; iron-core electromagnets reach around 1 to 2 T before the core saturates.
Common mistakes
- Using the long-solenoid formula for a short, fat coil. It is accurate only when the length is much greater than the diameter; at the ends of a long coil, the field drops to about half.
- Entering a large µr for an open rod core. The formula assumes the material fills the whole magnetic path; an open core raises the field far less than µr.
Frequently asked questions
Does the field depend on the coil diameter?
For an ideal long solenoid, no. Only turns per metre, current and core matter.
What is the difference between tesla and gauss?
1 T = 10,000 G, so 40 µT equals 0.4 G.
Sources: CODATA recommended values of the fundamental physical constants, NIST (vacuum magnetic permeability µ₀) · D. J. Griffiths, Introduction to Electrodynamics, Cambridge University Press, chapter 5 · NOAA National Centers for Environmental Information, World Magnetic Model