Electromagnetism
Magnetic Field
Force on moving charges, generated by moving charges and magnets — F = q·v×B
A magnetic field B is a vector field that exerts force on moving electric charges and on magnetic dipoles. Created by moving charges (currents), magnetized materials, and changing electric fields. Force on a charge: F = q·v × B (perpendicular to both v and B). Drives motors, generators, MRI scanners, particle accelerators. Earth has a magnetic field that protects us from solar wind.
- Force on moving chargeF = q·v × B
- Unitstesla (T) = N/(A·m); gauss = 10⁻⁴ T
- Generated byMoving charges (currents), spins, dipoles
- Earth's surface field~25-65 µT (strongest at poles)
- Refrigerator magnet~5 mT
- Strong electromagnet (lab)1-30 T (MRI ~1.5 T; high-field labs >40 T)
Interactive visualization
Press play, or step through manually. The visualization is yours to drive — try it before reading on.
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
Lorentz force
Force on a charge q moving at velocity v in a magnetic field B:
F = q · v × B
The force is:
- Perpendicular to BOTH v and B (right-hand rule).
- Magnitude q·v·B·sin θ (θ = angle between v and B).
- Zero if v parallel to B (no force on charges moving along field).
- Maximum when v perpendicular to B.
Combined with electric force (F_total = q·E + q·v×B), this is the full Lorentz force.
Circular motion in B field
Charge q moving perpendicular to uniform B feels constant centripetal force:
q·v·B = m·v² / r
r = m·v / (q·B)
And period:
T = 2π·m / (q·B) (cyclotron period; independent of v!)
Field magnitudes
| Source | B |
|---|---|
| Earth's surface (avg) | 50 µT |
| Refrigerator magnet | 5 mT (50 G) |
| Bar magnet (near pole) | 10 mT |
| Inside an MRI | 1.5-7 T |
| Strongest commercial magnets | ~10 T (electromagnets), ~1.5 T (permanent) |
| High-field research | 30-45 T (steady), ~100 T (pulsed) |
| Neodymium magnet (small) | 1-1.5 T at surface |
| Pulsar magnetic field | ~10⁸ T (extreme) |
| Magnetar (neutron star) | ~10¹¹ T (most extreme known) |
JavaScript — magnetic field calculations
// Lorentz force on a charge
function lorentzForce(q, v_vec, B_vec) {
// F = q · (v × B)
const cross = [
v_vec[1]*B_vec[2] - v_vec[2]*B_vec[1],
v_vec[2]*B_vec[0] - v_vec[0]*B_vec[2],
v_vec[0]*B_vec[1] - v_vec[1]*B_vec[0]
];
return cross.map(c => q * c);
}
// Electron moving 1e6 m/s in 1 T field
const F = lorentzForce(-1.602e-19, [1e6, 0, 0], [0, 0, 1]);
console.log(F); // [0, -1.6e-13, 0] N (downward y)
// Cyclotron radius
function cyclotronRadius(mass, velocity, charge, B) {
return mass * velocity / (Math.abs(charge) * B);
}
// Electron in 1 T field, 1e6 m/s
const r_e = cyclotronRadius(9.11e-31, 1e6, 1.602e-19, 1);
console.log(`Electron radius: ${(r_e * 1e6).toFixed(2)} µm`); // ~5.7 µm
// Cyclotron frequency (independent of speed!)
function cyclotronFrequency(charge, B, mass) {
return Math.abs(charge) * B / (2 * Math.PI * mass);
}
// Proton in 1 T
const f_p = cyclotronFrequency(1.602e-19, 1, 1.673e-27);
console.log(`Proton cyclotron at 1T: ${(f_p / 1e6).toFixed(1)} MHz`); // 15.2
// Magnetic field from a long straight wire
const mu_0 = 4 * Math.PI * 1e-7; // T·m/A
function fieldFromWire(I, distance) {
// B = μ_0·I/(2π·r)
return mu_0 * I / (2 * Math.PI * distance);
}
// 10 A wire, 1 cm away
console.log(`B from 10A wire at 1cm: ${(fieldFromWire(10, 0.01) * 1e6).toFixed(0)} µT`); // ~200
// Solenoid field (interior)
function solenoidField(n_turns_per_meter, current) {
return mu_0 * n_turns_per_meter * current;
}
// 1000 turns/m, 5 A
console.log(`Solenoid: ${(solenoidField(1000, 5) * 1000).toFixed(2)} mT`); // 6.28
// Earth's field deflection
function earthDeflection(speed, charge, mass, B = 50e-6) {
// Cyclotron radius
return cyclotronRadius(mass, speed, charge, B);
}
// Cosmic ray proton (1e8 m/s) in Earth's field
console.log(`Cosmic proton radius in Earth's field: ${earthDeflection(1e8, 1.602e-19, 1.673e-27).toFixed(0)} m`);
// Massive radius — barely deflected (more deflection at higher latitudes due to angle)
// Tesla in different units
function teslaToGauss(T) { return T * 1e4; }
function gaussToTesla(G) { return G * 1e-4; }
console.log(`1 T = ${teslaToGauss(1)} G`); // 10000
console.log(`Earth ~ 0.5 G = ${gaussToTesla(0.5).toExponential(2)} T`); // 5e-5
Where magnetic fields matter
- Motors and generators. Convert between electrical and mechanical via magnetic forces and induction.
- Particle accelerators. Bend charged particle beams in circular paths.
- MRI imaging. Strong B fields align nuclear spins; modulate to image tissues.
- Compasses and navigation. Earth's field; magnetometers in phones.
- Plasma confinement. Tokamaks contain hot fusion plasmas with strong B fields.
- Mass spectrometry. B field separates ions by mass-to-charge ratio.
- Astrophysics. Magnetic fields in stars, galaxies, jets, accretion disks. Earth's magnetosphere protects from solar wind.
Common mistakes
- Confusing magnetic and electric fields. They're related but distinct (different units, sources, force laws). Maxwell unifies them but for most applications, treat separately.
- Thinking magnetic force does work. It doesn't — F is always perpendicular to v, so dW/dt = F·v = 0. Only changes direction; energy comes from work done by electric fields or other agents.
- Treating magnets as monopoles. Magnetic monopoles haven't been observed (despite searches). Magnets always have N AND S poles paired.
- Wrong direction with right-hand rule. Use right hand for positive charges; for negative (electrons), reverse direction.
- Confusing T and G. Earth's field is ~50 µT = 0.5 G. Watch units in tables and equations.
- Forgetting field can vary. Earth's field varies with location and time. Magnets have non-uniform fields. For complex situations, careful 3D analysis needed.
Frequently asked questions
How does a magnet field exert force?
Force on a moving charge: F = q·v × B (Lorentz force). Perpendicular to BOTH velocity and B field. Magnetic force does NO work (F always perpendicular to v) — only changes direction of motion, not speed. Charged particles moving in uniform B field travel in circles.
How is a magnetic field generated?
By moving electric charges (currents) and intrinsic atomic magnetic moments (electron spin, orbital). Static charges produce only electric field. Currents produce magnetic field around them. Permanent magnets — aligned electron spins/orbitals in iron, nickel, cobalt and certain alloys.
What's Earth's magnetic field?
Generated by molten iron currents in Earth's outer core (geodynamo). Surface strength 25-65 µT. Protects us from solar wind by deflecting charged particles. Magnetic poles (where field is vertical) ≠ geographic poles. Field is currently weakening; geomagnetic reversals every ~200,000-300,000 years (last ~780,000 years ago).
How does an MRI scanner use magnetic fields?
Strong static B field (~1.5 to 7 T) aligns hydrogen nuclei in body. RF pulses tip them; they precess at Larmor frequency. As they relax, they emit RF detected by coils. Different tissues relax at different rates — image contrast. 7T MRI possible; higher fields (11.7 T being tested) for research.
What's a magnetic dipole moment?
Vector quantifying a magnet's strength. For a current loop — m = I·A (current times area). For an atom — sum of orbital + spin contributions. In B field, dipoles experience torque τ = m × B (aligning with B). Bar magnets are dipoles; refrigerator magnets work via dipole-dipole forces.
How are electric and magnetic fields related?
Two aspects of one electromagnetic field. In one frame, you might see purely electric or magnetic; in another, mixed. Special relativity unifies them — Maxwell's equations are Lorentz-invariant. Charges produce E; currents produce B. Changing E creates B (Maxwell's correction); changing B creates E (Faraday's law).
How is a magnetic field measured?
Hall effect sensors (semiconductor — measure transverse voltage from charges deflected by B). Magnetometers (very sensitive: SQUID for fT-level fields). Compasses align with field direction. Modern smartphones have magnetometers (compasses + gyroscope).