Magnetic Field Calculator: Wires, Coils, Solenoids and the Lorentz Force
By FindMySum · Last reviewed
Every electric current makes a magnetic field, and every magnetic field pushes on moving charges. This magnetic field calculator covers both halves of that story with the standard formulas from introductory physics. It finds the field around a long straight wire, at the centre of a circular coil and inside a solenoid, and the force a field exerts on a current-carrying wire, between two parallel wires and on a moving charged particle such as an electron, proton or alpha particle. Each field result is compared with the Earth's own field so you can tell whether it is tiny or enormous.
Fields from currents
A long straight wire. The field lines form circles around the wire, and their strength falls with distance:
- B = μ₀I ÷ (2πr)
Here μ₀ is the magnetic permeability of free space, about 1.2566 × 10⁻⁶ N/A², I the current and r the perpendicular distance. The calculator's default, 10 A at 5 cm, gives 4.0 × 10⁻⁵ T or 40 µT, a little less than the Earth's field in southern Canada. Doubling the distance halves the field.
A circular coil. At the centre of a coil of N turns and radius R, the contributions from every part of the wire point the same way and add up:
- B = μ₀NI ÷ (2R)
A 100-turn coil of radius 5 cm carrying 10 A gives 0.0126 T, about 250 times the Earth's field. Along the coil's axis the field falls off, and the chart shows how.
A solenoid. Wind the wire into a long helix and the field inside becomes nearly uniform:
- B = μ₀μᵣnI, with n = N ÷ L turns per metre
That formula assumes an infinitely long solenoid. For a real one of length L and radius R, the field at the centre is μ₀μᵣNI ÷ √(L² + 4R²), which the calculator uses as its main result. For 100 turns over 20 cm with a 5 cm radius and 10 A, the ideal formula gives 6.28 mT and the finite-length one 5.62 mT. The longer and thinner the coil, the closer they get. An iron core multiplies the field by its relative permeability μᵣ, up to the point where the iron saturates.
Forces from fields
A wire in a field. A straight wire of length L carrying current I across a field B feels
- F = BIL sin θ
where θ is the angle between the wire and the field. The force is largest when they are perpendicular and zero when they are parallel. This is the principle of every electric motor and loudspeaker. A 20 cm wire with 10 A at 30° to a 0.5 T field feels exactly 0.5 N.
Two parallel wires. Each wire sits in the other's field, so they push or pull on each other with a force per metre of
- F/L = μ₀I₁I₂ ÷ (2πd)
Currents in the same direction attract; opposite currents repel. For 1 A in each wire, 1 m apart, the force is 2 × 10⁻⁷ N per metre. That was the official definition of the ampere from 1948 until 2019.
A moving charge. A particle of charge q moving at speed v through a field B feels the magnetic part of the Lorentz force:
- F = |q|vB sin θ
Because this force is always perpendicular to the velocity, it bends the path into a circle (or a helix if the velocity has a part along the field) of radius r = mv⊥ ÷ (|q|B). The time for one turn, T = 2πm ÷ (|q|B), does not depend on the speed at all; its inverse is the cyclotron frequency.
Worked example: a proton in a magnet
A proton moving at 1,000 km/s straight across a 0.5 T field:
- F = 1.602 × 10⁻¹⁹ C × 10⁶ m/s × 0.5 T = 8.01 × 10⁻¹⁴ N
- r = (1.6726 × 10⁻²⁷ kg × 10⁶ m/s) ÷ (1.602 × 10⁻¹⁹ C × 0.5 T) = 0.0209 m, about 2 cm
- T = 2π × 1.6726 × 10⁻²⁷ ÷ (1.602 × 10⁻¹⁹ × 0.5) = 1.31 × 10⁻⁷ s, a cyclotron frequency of 7.62 MHz
An electron at the same speed would circle 1,836 times faster in a circle 1,836 times smaller, because its mass is that much less. Mass spectrometers use exactly this difference to sort ions by mass.
Directions: the right-hand rules
The calculator gives magnitudes. For directions, use your right hand. For a wire, point your thumb along the current and your fingers curl the way the field circles. For a force on a positive charge or a current, point your fingers along the velocity or current, curl them toward B, and your thumb shows the force. Flip the result for electrons.
How big is a tesla?
The Earth's field is about 25 to 65 µT, depending on location, roughly 50 µT across southern Canada. A fridge magnet is a few millitesla, a hospital MRI scanner 1.5 to 3 T, and the strongest steady laboratory magnets about 45 T. One tesla is 10,000 gauss.
Limits
These are the idealised textbook results: infinitely long thin wires, perfect circular coils, the field on the axis at the centre of a solenoid, iron cores without saturation, and particles well below the speed of light. The calculator leaves out the electric part of the Lorentz force and alternating-current effects. For real magnet design, measure or use finite-element software.
More questions
Can a magnetic field do work on a charged particle?
No. The magnetic force is always perpendicular to the particle's velocity, so it changes the direction of motion but never the speed or kinetic energy. That is why a charge in a uniform field moves in a circle at constant speed. Electric fields do the work in particle accelerators; magnetic fields steer and focus the beam.
Why do power lines not affect compasses much?
Two things. The field of a wire falls off with distance, and transmission lines carry alternating current that reverses 60 times a second in North America, so a compass needle cannot follow it and sees an average of about zero. Directly under a large line, the oscillating field is typically a few microtesla, a fraction of the Earth's steady field.
What happens inside a cyclotron?
Charged particles circle in a strong magnetic field, and an alternating voltage kicks them each half turn. Because the period 2πm ÷ (qB) does not depend on the speed, the kicks stay in step as the particles speed up and spiral outward. Canada's TRIUMF laboratory in Vancouver runs one of the largest cyclotrons in the world.
How does a loudspeaker use the force on a wire?
A coil of wire sits in the gap of a permanent magnet. The music signal sends a changing current through the coil, and the force F = BIL on the wire pushes the coil and the attached cone back and forth, which moves the air. The same force spins electric motors.
What is magnetic permeability?
It measures how easily a material supports a magnetic field. Vacuum has μ₀, about 1.257 × 10⁻⁶ N/A². Most materials, including air, water and copper, have a relative permeability μᵣ very close to 1. Ferromagnetic materials such as iron, nickel and some steels have μᵣ in the hundreds or thousands until they saturate.
Why is μ₀ no longer exactly 4π × 10⁻⁷?
Until 2019 the ampere was defined through the force between two wires, which fixed μ₀ at exactly 4π × 10⁻⁷ N/A². The 2019 SI redefinition fixed the elementary charge instead, so μ₀ became a measured quantity. The CODATA 2022 value differs from 4π × 10⁻⁷ only in the tenth significant figure, far too small to matter here.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.