B514 of 15
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

B5 · Lesson 14 · Magnetic field lab

Biot–Savart in code, uniform-field coils, solenoids, orbits and a Hall measurement

Every magnetic field in this unit came from a symmetric shape: an infinite wire, a circular loop, an ideal solenoid. Real coils are square, short, or bent around a sensor, and the Biot–Savart law handles them all if you add up enough small pieces of current. In this lab you'll write that sum, check it against the shapes you know, design a Helmholtz pair for a uniform field, build a finite solenoid out of loops, track a charge through a field with a method that keeps its speed exact, and pull a carrier density out of noisy Hall data.

  • Two coaxial coils of radius R carry equal currents. The curve is the field along their shared axis, relative to its value at the midpoint, as you move along the axis.
  • Set the spacing to R: the curve is flattest there, the Helmholtz condition, where the field's second derivative at the center vanishes.
  • Closer coils give a dip at the center, wider ones a hump. The readout gives the field 0.1R from the center, relative to the center.

Predict

A Helmholtz pair of 100-turn coils, each 10 cm in radius, carries 1 A. What is the field at the center, compared with one coil alone at its own center?

Name it

Biot–Savart in pieces

A short piece of wire d𝐥 carrying I contributes d𝐁=μ0I4πd𝐥×𝐫r3 at a point a displacement r away. Split any path into many short pieces, put each piece's current at its midpoint, and add the contributions. Check the sum on shapes with known answers: a circle's center (μ0I2R), its axis, and a square's center (22μ0Iπa).

Helmholtz coils

Two coaxial coils of radius R spaced R apart give a field at the center of (45)3/2μ0NIR, uniform to about 1 part in 10 000 within 0.1R of the center. Calibration coils for magnetometers and setups that cancel the Earth's field use them.

Finite solenoids

A solenoid is a stack of loops. On its axis, a solenoid of length L and radius R with n turns per meter gives

B(z)=μ0nI2(z+L/2(z+L/2)2+R2−z−L/2(z−L/2)2+R2),

which approaches μ0nI at the center only when L≫R.

Tracking a charge

The magnetic force does no work, so a good numerical method should keep the speed constant. The Boris method splits each step into a half push by any electric field, an exact-length rotation by the magnetic field, and another half push: it conserves the speed to rounding error in a pure magnetic field, however many steps it takes.

Fitting Hall data

The Hall voltage is VH=IBnqt, plus an offset when the voltage probes aren't perfectly opposite each other. Fitting a line to VH against I removes the offset as the intercept and gives n from the slope.

Worked example

Find the field of a 10 cm length of wire carrying 1 A, 1 cm from its middle, and compare it with an infinite wire.

Show the solution
  1. Field of a straight segment. Adding Biot–Savart pieces along the segment gives B=μ0I4πr⋅2(L/2)r2+(L/2)2
  2. Put in the numbers. With r = 1 cm and a half-length of 5 cm: B=10−5×0.10.012+0.052=19.6μT
  3. Infinite wire. μ0I2πr=20.0μT
  4. Compare. A wire ten times longer than the distance to it already acts as infinite to within 2%. The far parts of a wire contribute little, since their pieces are both distant and nearly lined up with the point.

Answer the 10 cm wire makes 19.6 µT, against 20.0 µT for an infinite wire.

Worked example

How uniform is the field of a Helmholtz pair, and how much worse is it with the coils 20% too far apart?

Show the solution
  1. At the Helmholtz spacing. With the coils R apart, the axial field 0.1R from the center is B(0.1R)B(0)=0.99989 uniform to 1.1 parts in 10 000.
  2. At 1.2R. With the coils 20% too far apart, the same ratio is B(0.1R)B(0)=1.0034 30 times less uniform, with a dip at the center.
  3. Why the Helmholtz spacing is so flat. It makes the field's second derivative vanish at the center, so its first error is fourth order in distance.
  4. What misplacement costs. A few millimeters of misplacement in a 10 cm coil spoils that quickly.

Answer at the Helmholtz spacing the field 0.1R from the center is within 1.1 parts in 10 000 of the center value; with the coils 20% too far apart it is 30 times less uniform.

Worked example

A Hall bar 0.2 mm thick in a 0.5 T field reads 31.7, 62.9, 94.1, 125.3 and 156.5 mV at 1 to 5 mA. What is its carrier density?

Show the solution
  1. Fit a line. The points lie on a line of slope 31.2 V/A, with an intercept of 0.5 mV, the probes' offset.
  2. Solve for the density. The slope is Bnqt, so n=Bqt⋅slope, where qt⋅slope=1.602×10−19×2×10−4×31.2=1.00×10−21
  3. Carrier density. n=0.51.00×10−21=5.0×1020m−3
  4. Why fit a line. Dividing a single reading by its current would have included the offset: at 1 mA it would give 31.7 V/A and n about 1.6% low.
  5. Another way. Reversing the field and averaging is the other common way to cancel the offset.

Answer the carrier density is 5.0×1020 m⁻³.

Check

Step 1. Write biot_savart(path, I, pts, n): path is a list of 3D points joined by straight segments carrying current I, pts an M × 3 array of field points. Split each segment into n pieces at their midpoints and return the M × 3 array of fields, with μ₀ = 4π × 10⁻⁷.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 2. Write coil_axis(R, I, z) for one turn's axial field, and helmholtz_variation(R, s, span) that puts two coils at z=±s/2, samples their total axial field at 2001 points from −span to span, and returns (max − min) divided by the center value.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 3. Write solenoid_sum(n, I, L, R, z, m) that builds a solenoid of length L, radius R and n turns per meter from m equally spaced loops (each carrying the current of nL/m turns) and returns the axial field at z. Compare with the exact formula in solenoid_exact. coil_axis is included.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 4. Write boris(q, m, v0, B, dt, steps) that moves a charge in a uniform magnetic field by the Boris rotation, returning the array of positions and the final velocity. Each step: 𝐭=q𝐁mΔt2, 𝐬=2𝐭1+t2, 𝐯′=𝐯+𝐯×𝐭, 𝐯←𝐯+𝐯′×𝐬, then 𝐱←𝐱+𝐯Δt.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Step 5. Write hall_density(I, VH, B, t) that fits VH=aI+b by least squares to measured arrays (amperes and volts) and returns the carrier density n=Bqta in m⁻³.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

A Helmholtz pair has 50 turns per coil, radius 5 cm, and carries 2 A.

(a)

What field does it make at its center?

Write units the way you normally would: 1.5 µT, 1500 nT and 0.0015 mT are the same answer.

(b)

How far apart should the coils be for the most uniform field?

Check

An electron moves at 1 × 10⁶ m/s square to a 1 mT field. What is the radius of the circle a correct simulation should trace?

Write units the way you normally would: 1.5 mm, 1500 µm and 0.0015 m are the same answer.

Explain why

Why is it important that a simulation of a charge in a magnetic field keep the speed exactly constant?

Practice

Keep practicing

4 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.