Magnetic Field of a Current — 3D simulator: wire, loop, solenoid | Physlabo
Loading...

Magnetic Field of a Current: Wire, Loop, Solenoid

A steady current I creates a magnetic field with induction B around a conductor.
The direction of the field lines follows the right-hand (screw) rule, and the magnitude follows the Biot–Savart law:
for an infinite wire B = μ₀I / (2πr), inside a long solenoid B = μ₀nI.

Drag the scene to rotate, scroll to zoom; drag the yellow dot to measure the field

Scale of magnetic fields: how strong is yours? (logarithmic — to the right it is many times stronger)
Earth50 µT fridge magnet5 mT MRI scanner1.5 T

What is what on the scene

  • Blue lines with running lights — the lines of the magnetic field B: the lights run the way the field points. The denser, brighter and thicker the lines, the stronger the field: they crowd near the conductor and spread apart far away.
  • Golden lights and arrow — the electric current I: by convention the current runs from “+” to “−” (the electrons actually move the other way). The larger the current, the faster the lights and the brighter the glow.
  • Red-and-white arrow at the yellow dot — a compass needle: the red end shows the direction of B. Drag the yellow dot with the mouse or a finger — the needle turns along the field and the numbers on the readout are recalculated.
  • Bright thread with red beads — the B line through your point: this is how a tiny “test north pole” would drift if released at this point: it always moves along the field line.
  • Glow on the plane and dashes — a map of the field strength |B|: the brighter the glow, the stronger the field (the scale is logarithmic). The dashes are “iron filings”: they line up along the B lines, as in the classroom experiment.
  • Green arrow, orange arc and screw — the hand rule: the right-hand grip rule: the green arrow (thumb) follows the current I, the orange arc (curled fingers) shows how the B lines curl. The green screw advances along the current and turns the way the field goes.
5,0
One-click experiments
Show

The scale is real: one grid division of the scene is 5 cm, the current goes up to 10 A. For a straight wire the formula is exact; for a loop and a solenoid the field is calculated from the Biot–Savart law (exactly, via elliptic integrals).

Three conductors — a straight wire, a circular loop and a solenoid — and one field around them. Turn the current up, reverse it, drag the yellow dot with a mouse or a finger and watch the compass needle turn along the B lines while the readout is recalculated from exact formulas. Not sure about the hand rule? Switch on “Check yourself” or “Mystery current”.

The idea in 30 seconds

1

Current creates a magnetic field

Near any wire carrying a current a compass needle turns — Ørsted noticed this in 1820. No magnet is needed: moving charges create the magnetic field themselves. No current — no field; more current — a stronger field.

2

The direction comes from a hand rule

Field lines are closed. Around a straight wire they are rings: point the thumb of your right hand along the current and the curled fingers show how the lines curl (a screw is driven in the same way). For a loop it is the other way round: the fingers follow the current in the turns and the thumb shows B inside. Reverse the current and everything turns around.

3

Stronger: closer, more current, more turns

Near a straight wire the field falls as 1/r: twice as far, half as strong. A loop gathers the field at its centre, and in a solenoid the turns add their fields, so inside there is an almost uniform field B ≈ μ₀nI — like a bar magnet. Outside the solenoid the field is weak.

Try it yourself

  1. Press “I ×2”: the current doubles — the field at the point is exactly twice as strong too (see the readout and the B(I) graph — a straight line).
  2. At a straight wire press “r ×2”: twice as far — half the field. And “Like the Earth” picks the current for which the field next to the wire equals that of the whole planet (≈ 50 µT): close to the wire it takes just a few amperes.
  3. Press “Reverse the current”: all the lines, the compass needle and the screw turn around. Then switch on “Check yourself” and guess the direction of B at the yellow dot with the hand rule, no peeking.
  4. Choose the loop and press “Outside, beside”: the field lines leave the loop and come back round, so outside B points the opposite way to the centre (on the right-hand graph the field changes sign).
  5. Choose the solenoid and compare “At the centre”, “At the end” and “Outside, beside”. Inside the field is almost the same everywhere, outside it is many times weaker. Press “N ×2” — for the same length the field inside doubles.
  6. Switch on “Mystery current”: the current is hidden. Measure B at the point and find the current from the formula — this is how a physicist measures a current by its magnetic field.

Graphs: how B depends on distance and on current

Where it works in real life

ElectromagnetWind a wire on an iron core and you get a magnet that is switched on and off by the current: it lifts scrap metal and drops the load when the current is cut.
Electric bell and relayCurrent flows through a coil, which pulls an armature — the contact opens, the current stops, the armature springs back... This is how a bell and a relay work: a small current switches a large one.
MRI scannerA huge solenoid with a superconducting winding creates an almost uniform field of about 1.5 T inside — 30,000 times stronger than the Earth’s. The image of the body is built from the response of hydrogen atoms in this field.
Loudspeaker and headphonesIn a loudspeaker a coil carrying a current hangs in the field of a magnet. The audio signal changes the current, the coil’s field is attracted to and repelled by the magnet — the cone shakes and makes sound.
Wires in the wall and power linesEvery cable carrying a current has a magnetic field around it, however weak. Near a high-voltage line it is clearly stronger than the Earth’s — which is why a compass behaves oddly there.
Compass and Ørsted’s experimentA compass needle is a tiny magnet and it turns along B. Bring it to a wire with a current — it turns not to the north but along the wire’s field line: this is how Ørsted discovered the link between electricity and magnetism.

KEY FORMULAS

Induction of the field of a straight wire

$$B = \frac{\mu_0 I}{2\pi r}, \qquad \mu_0 = 4\pi \cdot 10^{-7}$$

An infinite wire: B falls off as 1/r and wraps into rings around the current; μ₀ = 4π·10⁻⁷ H/m

▶ Detailed Explanation
Around an infinite straight wire carrying a current I the induction lines are circles centred on the wire and lying in planes perpendicular to it; the direction is given by the screw rule. The Biot–Savart law integrated along the whole wire gives the exact result B = μ₀I/(2πr): the induction is inversely proportional to the distance r from the wire — go twice as close and the field is twice as strong. The magnetic constant μ₀ = 4π·10⁻⁷ H/m is the proportionality coefficient of the magnetic interaction, and B is proportional to the current: double I and the field doubles. A check example: I = 5 A, r = 6 cm → B = 4π·10⁻⁷ · 5 / (2π · 0.06) ≈ 16.7 µT — about a third of the Earth’s magnetic field (≈ 50 µT). A grid division in the simulator is 5 cm, so r on the readout is a real distance.

A circular loop

$$B_0 = \frac{\mu_0 I}{2R}, \qquad B(z) = \frac{\mu_0 I R^2}{2\,(R^2+z^2)^{3/2}}$$

The field is strongest at the centre of the loop and falls off along the axis; off the axis it comes from the Biot–Savart law

▶ Detailed Explanation
A circular loop of radius R carrying a current I is a wire bent into a circle. At the centre every current element contributes in the same direction, and the Biot–Savart law reduces to B₀ = μ₀I/(2R): at the same current a smaller loop gives a stronger field. On the axis at a distance z from the centre B = μ₀IR²/(2(R²+z²)^{3/2}): at z = 0 it gives the central value, while for z ≫ R the field falls off as 1/z³ — a distant loop behaves like a small magnet (a magnetic dipole). Off the axis there is no simple formula: the field is expressed through complete elliptic integrals. The simulator computes exactly these, so the B lines and the numbers are exact at any point. Outside the loop the lines come back, and B there points opposite to the central one. Example: R = 6 cm, I = 5 A → B₀ = 4π·10⁻⁷ · 5 / (2 · 0.06) ≈ 52 µT.

A solenoid

$$B = \mu_0 n I = \frac{\mu_0 N I}{L}, \qquad n = \frac{N}{L}, \qquad B_0 = \mu_0 n I\,\frac{L}{\sqrt{L^2+4R^2}}$$

Almost uniform inside, weak outside — the lines close outside through the ends

▶ Detailed Explanation
A solenoid is N turns wound on a cylinder of length L; it is natural to speak of the number of turns per unit length n = N/L. Inside a long solenoid the fields of all turns add up along the axis and the field is almost uniform: B = μ₀nI. It is proportional to the current and to the turn density but does not depend on the radius of the turns. Outside the field is weak, and the lines that leave one end close outside and enter the other — a magnet with poles; the direction of B inside is set by the right-hand rule applied to the current in the turns. The formula μ₀nI is exact only for an infinitely long solenoid. In a short one the field at the centre is weaker by the factor L/√(L²+4R²) (for L = 17.5 cm and R = 4 cm — by 9 %), and at the end it is about half of that in the middle. The simulator adds the exact fields of all N turns, so it shows these differences honestly.

The Biot–Savart law

$$d\vec{B} = \frac{\mu_0 I}{4\pi}\,\frac{d\vec{l}\times\vec{r}}{r^3}, \qquad B = \frac{\mu_0 I}{4\pi}\int \frac{dl\sin\alpha}{r^2}$$

Every element of the wire contributes; the direction follows the cross product dl × r

▶ Detailed Explanation
The Biot–Savart law is the basis of every formula in the simulator: the induction at a point is the sum of the contributions of all small elements dl of the current-carrying wire. The contribution is proportional to the current and to the sine of the angle between the element and the direction to the point, and inversely proportional to the square of the distance; the direction comes from the cross product dl × r by the right-hand rule. For a straight wire the sum reduces to B = μ₀I/(2πr), for a loop to the centre and axis formulas (off the axis to elliptic integrals), and the field of a solenoid is the sum of the fields of its turns. The simulator computes all of this exactly and builds the B lines as level lines of the flux function: the same magnetic flux passes between neighbouring lines, so where the lines are denser the field is stronger.

Ampère’s circuital law and the screw rule

$$\oint \vec{B}\cdot d\vec{l} = \mu_0 I, \qquad B = \frac{\mu_0 I}{2\pi r}$$

The circulation of B around a closed loop equals μ₀I: the directions of the field and the current are tied by the right-hand rule

▶ Detailed Explanation
The screw rule is the visual form of Ampère’s circuital law. Go around a contour encircling the wire and sum B·dl: you get μ₀I, and the sense of the traversal and the direction of the current are tied together like the rotation and the advance of a right-handed screw. Drive the screw along the current and its handle turns the way the B lines wrap. For a straight wire these are rings counter-clockwise when the current goes up (seen from above), for a loop and a solenoid — the axial direction inside and the return outside. The right-hand rule works the same way: for a wire the thumb is along the current and the curled fingers follow the field lines; for a loop it is the other way round: fingers along the current, thumb along B. A check in the simulator: in the “Measurements” panel, for a wire B·2πr always equals μ₀I, whatever the distance of the point.

A current-carrying wire is the simplest source of a magnetic field. The electrons in it move in an ordered way, and that ordered motion is the current. Around a straight wire the induction lines B close into rings; inside a long solenoid they are almost straight and equally dense, while outside the field is many times weaker: the lines leave one end, sweep around the coil and enter the other — just like a permanent magnet. A magnetic field cannot be touched, so the simulator lets you “see” it in four ways at once: lights running along the B lines (they go the way the field points), “iron filings” lined up along the lines, a glowing map of the field strength, and the compass needle at the yellow dot.

The magnitude of the induction follows from the Biot–Savart law: the field at a point is the sum of the contributions of all small elements of the wire. For an infinite straight wire it gives the exact formula B = μ₀I / (2πr): the field is inversely proportional to the distance — move twice as close and it is twice as strong. At the centre of a circular loop of radius R the induction is B = μ₀I / (2R), and on the loop axis at a distance z from the centre it is B = μ₀IR² / (2(R² + z²)³ᐟ²). Inside a long solenoid with n = N / L turns per unit length the field is uniform and equals B = μ₀nI, so inside it behaves like a permanent magnet. The simulator does not approximate: it computes the field of the loop and the solenoid exactly (through complete elliptic integrals), so subtleties that school formulas miss are visible: in a short solenoid the centre is weaker than the “ideal” μ₀nI (by 9 % in our case), and outside the loop and the coil the lines come back, so B points the opposite way.

The direction is explained by the screw rule: drive a screw along the current and its handle turns the way the B lines go. For a straight wire this is the familiar right-hand rule: thumb along the current, bent fingers show how the field rings wrap around. For a loop and a solenoid it is the other way round: the fingers follow the current in the turns and the thumb shows B inside. Tick “Screw and right-hand rules” and watch the green arrow, the orange arc and the screw: when you reverse the current everything turns around together with the field.

Drag the yellow dot — the compass needle there turns along B, a glowing thread shows the field line through that point, and the readout and the “Measurements” panel recalculate the induction with a µT or mT prefix and compare it with the Earth’s magnetic field. The scale under the scene shows where your field stands against a fridge magnet and an MRI scanner. “Check yourself” hides the lines and the needle and asks for the direction of B — including a trick question at a point outside the coil. “Mystery current” hides the current: measure B and find I from the formula — this is how a physicist measures a current by its magnetic field.