In short
A solenoid is a long coil of wire, many turns per unit length, with current flowing through it. Inside, far from the ends, the magnetic field is uniform and points along the axis:
Outside the solenoid the field is essentially zero (field lines close through the interior and outside at infinity, diluting to negligible density).
A toroid is a solenoid bent into a ring. The field lives entirely inside the torus, runs in circles along the major circumference, and depends on the radial position:
Outside the toroid (both in the hole and beyond the outer edge) the field is zero.
Both results come from Ampère's circuital law with a cleverly chosen Amperian loop. The solenoid derivation uses a rectangular Amperian loop that straddles the winding; the toroid derivation uses a circular Amperian loop concentric with the torus.
Why these two shapes dominate engineering: they confine the magnetic field to a tiny known volume, leave the rest of the world field-free, and the B value depends only on the current and the turn density — geometry you can measure with a ruler. This makes them easy to design, easy to simulate, and easy to control. Every MRI scanner, every inductor on a printed-circuit board, every tokamak plasma confinement coil is one of these two shapes.
A single loop of wire gives you a dipole field — strong at the centre, falling off as 1/x^3 on the axis, nonzero everywhere in space. That is a messy thing to live with. If you are building an MRI scanner at AIIMS Delhi, you want a three-tesla field inside the patient's head and zero field outside, so that nothing in the next room can disturb your measurement. If you are building a small inductor on a mobile-phone motherboard, you want the magnetic flux confined to a few cubic millimetres so it does not crosstalk into the adjacent Bluetooth antenna.
Both of these demand a field that is large where you want it and small everywhere else. Nature gives you two shapes that do exactly that: the solenoid and the toroid. A solenoid is a long, straight coil. A toroid is that same coil bent into a closed ring. In both, the field is huge inside and vanishingly small outside. This article shows why.
The trick is Ampère's circuital law, which says that the line integral of \vec B around any closed loop equals \mu_0 times the current threading that loop:
If you can choose a loop along which \vec B is either constant (so you can pull it out of the integral) or zero (so that piece of the loop contributes nothing), then Ampère's law gives you B directly. For the solenoid and toroid, symmetry hands you exactly such a loop.
The solenoid — a long coil of wire
A solenoid is a wire wound in a tight helix around a cylindrical form. In the idealisation we use here, the wire is wound so tightly that the helix is effectively a stack of n circular loops per unit length, each carrying current I. For a solenoid of total length L with N turns, n = N/L.
Three qualitative facts before the derivation
1. The field inside is parallel to the axis. By symmetry, the wire has rotational symmetry around the axis and translational symmetry along the axis (far from the ends). Any transverse field component would need a preferred direction — but there is none. Only an axial component is allowed.
2. The field inside is spatially uniform. Translational symmetry along the axis means B cannot depend on position along the axis. Cylindrical symmetry means B cannot depend on the azimuthal angle. Moreover — and this is the non-obvious part — B turns out not to depend on the radial position either, as long as you are inside the solenoid. The Ampère-law derivation below shows this.
3. The field outside is approximately zero. The field lines that emerge from one end of the solenoid must return to the other end (magnetic field lines always close). They spread over an enormous outer region — effectively, over the whole of space outside the solenoid — so the field density is vanishingly small everywhere outside. For an ideally infinite solenoid, the outside field is exactly zero.
The Ampère-law derivation
Choose an Amperian loop in the shape of a rectangle, with one side of length \ell running inside the solenoid parallel to the axis and the opposite side running outside the solenoid, also parallel to the axis. The two short sides connect the two long sides radially.
Step 1. Traverse the loop a \to b \to c \to d \to a and break the line integral into four pieces:
Step 2. Evaluate each piece.
-
a \to b (inside, parallel to axis): \vec B is uniform and along the axis; d\vec l is also along the axis (same direction if we traverse from a to b matching the \vec B direction). So \vec B\cdot d\vec l = B\,dl, and the integral is B\cdot\ell.
-
b \to c (short side, radially outward, crossing the solenoid wall): \vec B is along the axis; d\vec l is perpendicular (radial). So \vec B\cdot d\vec l = 0. Integral is 0.
-
c \to d (outside, parallel to axis): \vec B \approx 0 outside. Integral is 0.
-
d \to a (short side, radially inward): Same as b\to c: \vec B\perp d\vec l. Integral is 0.
Why: the dot product \vec B\cdot d\vec l selects the component of \vec B along the direction of traversal. On the long inside side it gives B; on the two short sides it gives 0 because B is axial and d\vec l is radial; on the long outside side it gives 0 because B itself is zero there. The loop has been engineered so only one of its four legs contributes.
Step 3. Sum:
Step 4. Count the enclosed current. The Amperian loop surrounds n\ell turns of the wire (because there are n turns per unit length, and the loop's length along the solenoid axis is \ell). Each turn carries current I, so:
Why: Ampère's law counts the total current passing through any surface bounded by the Amperian loop. A flat surface stretched across our rectangle intersects n\ell wire turns, each contributing I.
Step 5. Apply Ampère:
Cancel \ell:
Why: the length \ell appears on both sides and drops out — the result is independent of \ell, which proves that the field does not depend on position along the axis. And since we never specified the radial position of the inside leg of the rectangle (it could be on the axis or near the wall), the result is also independent of radial position. Inside the solenoid, B is genuinely uniform.
What this formula depends on — and what it doesn't
B = \mu_0 nI is one of the shortest, most useful results in electromagnetism. Notice:
- It depends on n, not on N and L separately. Doubling the length of the solenoid while keeping the same turn density gives you the same B. What matters is how tight the winding is, not how long it is.
- It does not depend on the solenoid's radius. A 2\ \text{cm}-diameter solenoid and a 20\ \text{cm}-diameter solenoid with the same n and same I have the same internal field (though the second encloses 100 times more magnetic flux).
- It does not depend on position inside the solenoid. Every point in the interior — on-axis, near the wall, anywhere in between — sees the same \vec B. This is a remarkable fact that you would not guess from adding up the fields of individual loops; it emerges only from the Ampère-law shortcut.
When the formula breaks down — the end effects
B = \mu_0 nI is the ideal infinite-solenoid result. Real solenoids are finite, and near the ends the field is weaker because some flux has already begun to escape radially outward. A good rule of thumb: the infinite-solenoid formula is accurate to a few percent as long as you are at least a radius away from either end. Within one radius of an end, you need the proper end-effect formulas (which can be derived from the Biot-Savart integral over all turns, or looked up in a table).
At the very end of a long solenoid, the field drops to exactly half the infinite-solenoid value: B_\text{end} = \mu_0 n I/2. The symmetry argument is that the field at the end equals the field an infinite solenoid would produce at its centre contributed by only the half of the turns that actually exist — hence half the value.
Interactive: solenoid field vs turn density and current
The toroid — a solenoid bent into a ring
Take the solenoid above and bend it until its two ends meet, forming a closed ring. That is a toroid. Any wire wound this way — around the surface of an inflated donut or a cylinder bent into a ring — produces a magnetic field that lives entirely inside the doughnut.
The Ampère-law derivation for a toroid
Choose an Amperian loop as a circle of radius r concentric with the torus's central axis. By symmetry:
- The magnitude B is constant all along this circle — any azimuthal angle is equivalent to any other.
- The direction of \vec B is tangent to the circle (along the toroidal direction, going around the donut's long way).
Step 1. The line integral simplifies because \vec B is parallel to d\vec l everywhere on the loop, and |\vec B| = B is constant:
Step 2. Count enclosed current. If the loop lies inside the torus (i.e., a < r < b), it encloses all N turns of the winding, each carrying current I. So:
Why: every turn of the winding crosses the flat disk bounded by the Amperian circle once. A flat disk through the hole of the donut intersects each turn exactly once (the turn goes through the hole on one side and around on the other; the disk is threaded by the side that goes through). Do a thought experiment: tilt the disk through the hole; you see N wires piercing it.
Step 3. Apply Ampère:
Solve for B:
Why: the factor 2\pi r converts the toroidal circumference into the field magnitude. Note that B depends on r — the radial position within the torus — unlike the solenoid where B was uniform. A toroid's field is strongest near the inner wall (small r) and weakest near the outer wall (large r).
Field outside the toroid
- In the central hole (r < a): An Amperian loop here encloses no wire at all (the wires are on the outside of the hole). I_\text{enclosed} = 0, so B = 0.
- Beyond the outer wall (r > b): An Amperian loop here encloses each turn twice — once where it goes through the hole and once where it wraps around outside — but in opposite directions, so the net I_\text{enclosed} = 0. Hence B = 0.
The toroid's field is completely confined to the interior of the doughnut shape. A compass held anywhere outside the toroid — even right next to the wires — is not disturbed at all. That is why toroids are the electromagnetic-compatibility darling of circuit design: a toroidal inductor on a PCB radiates essentially zero magnetic flux into its neighbours.
Toroid vs solenoid — the relationship
The circumference of a toroidal loop at "average" radius r_0 = (a+b)/2 is L = 2\pi r_0. If the toroid has N turns over this length, the effective turn density is n = N/(2\pi r_0). Then:
This matches the toroid formula at r = r_0. So a toroid behaves like a solenoid bent into a ring, and the "bending" just spreads the turn density around the full circumference. If the torus is thin (a\approx b), the 1/r variation across its cross-section is small and you can treat it as an approximate solenoid with uniform B throughout.
Worked examples
Example 1: Design a solenoid to cancel Earth's field
You are setting up a magneto-optic experiment at an IIT Bombay lab and want to cancel Earth's magnetic field (B_\text{Earth} = 5\times 10^{-5}\ \text{T}) inside a sample region. You will use a solenoid of diameter 30\ \text{cm} and length 60\ \text{cm} (much longer than wide, so the ideal-solenoid formula applies). The power supply delivers up to I = 3\ \text{A}. How many turns N must you wind?
Step 1. Set the required field.
(Orientation: align the solenoid axis opposite to the direction of Earth's field at the lab location, so \vec B_\text{solenoid} + \vec B_\text{Earth} = 0.)
Step 2. Apply the solenoid formula.
Why: we know B, \mu_0, and I; we solve for n, the turns per unit length.
Step 3. Compute n.
Why: the product \mu_0 I = (4\pi\times 10^{-7})\times 3 = 3.77\times 10^{-6}\ \text{T·m}. Dividing B = 5\times 10^{-5}\ \text{T} by this gives the turns per metre.
Step 4. Multiply by the solenoid's length.
Why: you need only about eight turns total — Earth's field is tiny, and cancelling it takes very little coil. A practical design might use 15 turns at 1.5\ \text{A} (so you can trim the current up or down to exactly null Earth's field), but the order of magnitude is correct.
Result: N \approx 8 turns with I = 3\ \text{A}, or equivalently 15 turns at 1.5\ \text{A} for finer trim-ability.
What this shows: A tiny coil can cancel Earth's field. This is why every precision magnetometer is inside a set of Helmholtz or solenoid coils — Earth's 50\ \mu\text{T} background is easy to null out, and once it is nulled, you can measure the tiny fields of biological currents, ferroelectric domains, or atomic spins. For a full mu-metal shielded magneto-optics setup at IIT Bombay's physics department, the solenoid-cancellation is the first level of field control; further nulling is done with feedback-controlled Helmholtz pairs.
Example 2: An SST-1-style toroidal plasma confinement field
The Steady State Superconducting Tokamak (SST-1) at the Institute for Plasma Research (IPR) in Gandhinagar uses toroidal field coils to confine hot plasma. Consider a simplified toroid with major radius R_0 = 1.1\ \text{m} (the distance from the torus axis to the centre of the cross-section), minor radius a = 0.2\ \text{m} (the cross-section radius), and N = 16 toroidal field coils each carrying I = 10000\ \text{A}. Find the magnetic field at the plasma centre (r = R_0) and at the inner edge (r = R_0 - a).
Step 1. Total effective turns around the torus. Each of the 16 coils counts as one turn encircling the plasma, so N_\text{total} = 16 (the number of turns threading the Amperian loop at any given r).
Why: each toroidal coil is a loop of wire that goes over the top of the torus and under the bottom, encircling the plasma column. An Amperian loop concentric with the torus axis, at plasma radius, is threaded by 16 such coil windings.
Step 2. Apply the toroid formula at r = R_0.
Simplify:
Why: the 4\pi in the numerator cancels with 2\pi in the denominator to leave a factor of 2. Then 2\times 16\times 10^4\times 10^{-7} = 32\times 10^{-3}. Divide by 1.1 to get about 29\ \text{mT}.
Step 3. Field at the inner edge r = R_0 - a = 0.9\ \text{m}.
Scaling from the previous answer: B(0.9) = B(1.1)\times (1.1/0.9) = 0.029\times 1.222 \approx 0.036\ \text{T}.
Step 4. Field at the outer edge r = R_0 + a = 1.3\ \text{m}.
Why: for a given N and I, B\propto 1/r. Moving from r = 1.1 to 0.9 strengthens B by a factor of 1.1/0.9; moving to 1.3 weakens it by 1.1/1.3.
Step 5. Check the field gradient across the plasma cross-section.
The field varies by about 38\% across the plasma cross-section. This is a large non-uniformity — in reality, SST-1 uses additional poloidal field coils to shape the plasma and compensate, and the real physics is richer than a single toroid formula captures. But the toroidal formula gives the dominant field and its order of magnitude.
Result: B(\text{plasma centre}) \approx 29\ \text{mT}; B(\text{inner edge}) \approx 36\ \text{mT}; B(\text{outer edge}) \approx 25\ \text{mT}.
What this shows: A modest 10\ \text{kA} per coil (huge by household standards, modest by tokamak standards) and 16 coils produce a field of tens of milli-tesla across a cross-section a half-metre wide. This field is strong enough to make plasma ions spiral on radii of a few centimetres, confining them long enough for fusion reactions. Real fusion tokamaks like ITER go to 5\ \text{T} by using superconducting coils with currents closer to 70\ \text{kA} — but the scaling law is the same: B\propto NI/r, the formula we derived.
Common confusions
-
"Inside the solenoid the field points in the direction of the axis, but which way?" Use the right-hand rule on the windings: curl your right-hand fingers along the direction the current flows in the turns; your thumb points in the direction of \vec B. A solenoid wound so that current flows clockwise when viewed from one end has \vec B pointing away from you on that end.
-
"The formula B = \mu_0 nI makes B independent of the wire thickness." It does — and that is exact in the ideal case. In a real tightly-wound solenoid, the thicker the wire, the fewer turns per unit length you can achieve, so n drops. But for the same n, wire thickness does not change B. (It does change resistance, heat dissipation, and the maximum current, which indirectly set the operating B.)
-
"If a toroid has finite thickness, the B(r) = \mu_0 NI/(2\pi r) formula still holds exactly inside." Yes — as long as you stay inside the torus material. The derivation never assumed the torus was thin; it only used the azimuthal symmetry and the fact that the Amperian loop is enclosed N times.
-
"The solenoid field outside is exactly zero." Approximately zero. For an infinitely long solenoid it is rigorously zero. For a finite solenoid, field lines emerge from one end, spread through all space, and return to the other end. If you measured B a metre away from a 30\ \text{cm} solenoid with B_\text{inside} = 10\ \text{mT}, you would find something like B_\text{outside} \sim 10\ \mu\text{T} — small but not zero.
-
"MRI magnets are basically big solenoids." The superconducting magnet of a 3 T MRI scanner is indeed a solenoid — a very clever one, with the turn distribution engineered so that the field is not only strong inside but uniform to parts per million across the imaging volume. This uniformity is what lets the Larmor precession frequency be a clean function of position (coded by the gradient coils), enabling the Fourier-transform imaging that makes MRI work. A student's B = \mu_0 nI gives you the ball-park; real MRI design is far more intricate.
-
"A toroid with a gap is still a toroid." No — cut a small gap in the torus and the field inside is dramatically reduced because flux leaks through the gap into the external region. This is exactly what happens in a transformer with an air gap in the core: the permeability of the gap is \mu_0, much less than iron's \mu \sim 10^3\mu_0, so even a thin gap carries most of the magnetic "voltage drop" (magnetomotive force).
If your goal was to understand why solenoids and toroids confine their fields and derive the two key formulas, you have what you need. What follows is the level of detail expected for a JEE Advanced or first-year IIT electromagnetism course — the inductance of these devices, the energy stored, the Biot-Savart derivation of the finite-solenoid field, and the connection to Maxwell's equations.
Inductance
When the current through a solenoid changes, the flux through its own turns changes, and by Faraday's law an EMF appears across its terminals. The ratio of flux-linkage to current is the self-inductance:
For a solenoid of cross-sectional area A, length \ell, and N turns:
Why: the flux through one turn is BA; the flux-linkage sums the contribution from every turn because the same \Phi threads each of N turns, hence the factor N. Dividing by I cancels the driving current, leaving a geometric quantity.
A 1000-turn, 5\ \text{cm}^2, 20\ \text{cm}-long solenoid has L = (4\pi\times 10^{-7})(10^6)(5\times 10^{-4})/(0.2) = 3.1\ \text{mH} — a typical inductor in a switching power supply for a laptop charger.
For the toroid:
Energy stored in the magnetic field
A current-carrying inductor stores energy. The total energy is
Expressing L for a solenoid:
where V = A\ell is the solenoid's interior volume and we used B = \mu_0 nI. This identifies the magnetic energy density:
For a 3\ \text{T} MRI magnet, u_B = (3)^2/(2\times 4\pi\times 10^{-7}) = 3.6\ \text{MJ/m}^3. Over a one-cubic-metre interior, that is 3.6\ \text{MJ} of stored energy — enough to accelerate a 1\ \text{kg} mass to 2.7\ \text{km/s}. A quench (sudden loss of superconductivity) dumps this energy as heat, which is why MRI rooms are designed with quench vents to safely boil off the helium coolant.
Finite-solenoid field — the Biot-Savart route
The Ampère-law derivation assumed an infinite solenoid. For a finite solenoid of length \ell and radius R, you can still derive the on-axis field by treating each turn as a loop and integrating over the loops using the on-axis field of a loop,
summed over the loops distributed uniformly along the length. The result, at an axial position x measured from one end of a solenoid of length \ell, is:
At the centre x = \ell/2:
In the limit \ell \gg R: B\to \mu_0 nI, recovering the infinite-solenoid result. At the end x = 0: B = \mu_0 nI/2\cdot\ell/\sqrt{\ell^2+R^2}\to \mu_0 nI/2 in the long-solenoid limit — the half-field end-effect.
Connection to Maxwell's equations
Ampère's law as we used it — \oint\vec B\cdot d\vec l = \mu_0 I_\text{enclosed} — is the third of Maxwell's four equations, restricted to magnetostatics (no time-varying electric fields). For time-varying fields, Maxwell added the displacement current term \mu_0\varepsilon_0\,d\Phi_E/dt to the right-hand side:
For a solenoid being driven by DC or low-frequency AC, the displacement-current correction is negligible, and our derivations remain accurate. For RF solenoids operating at gigahertz frequencies — as in the gradient coils inside an MRI scanner — the full Maxwell treatment is needed, and electromagnetic-wave effects become important.
The AIIMS 3-T MRI magnet
The whole-body 3-tesla MRI scanner at AIIMS Delhi is a superconducting solenoid about 2\ \text{m} long with an inner bore of 60\ \text{cm}. It uses niobium-titanium wire cooled to about 4\ \text{K} by liquid helium. The superconducting state means zero resistance, so once the current is started it flows indefinitely (a persistent current on the order of 500\ \text{A}), and the 3\ \text{T} field is maintained for years without any power supply connected. To reach 3\ \text{T} with a 2\ \text{m} solenoid at 500\ \text{A} requires n = B/(\mu_0 I) \approx 5000 turns/m — a winding density achievable with 0.1\ \text{mm}-diameter superconducting wire tightly packed. The total energy stored is tens of megajoules; the uniformity is a few parts per million across a 50\ \text{cm} imaging volume, achieved by shimming the winding density across the length. All of it, at root, is the simple formula B = \mu_0 nI applied with ingenuity.
Where this leads next
- Ampère's Circuital Law — the tool we used to derive both B = \mu_0 nI and B = \mu_0 NI/(2\pi r), and the broader framework for symmetric-current geometries.
- Magnetic Field of Common Current Configurations — the loop and arc results that the solenoid is built from, and the Biot-Savart derivation of the finite-solenoid field.
- Force on a Current-Carrying Conductor — how a wire immersed in the solenoid's uniform field experiences a force, the foundational physics of a moving-coil loudspeaker and every linear motor.
- Electromagnetic Induction — Faraday's Law — what happens when the current through a solenoid changes with time: the induced EMF, the self-inductance, and the path to transformers and electric generators.
- Magnetic Field and the Biot-Savart Law — the fundamental law underlying every magnetostatic result in this article.