Magnetic Field Calculator

Compute the magnetic flux density B (in teslas) for three fundamental current configurations: an infinite straight wire, a circular loop on its axis, and a long solenoid. Visualize the field strength as a function of distance, compare configurations, and explore the underlying electromagnetism.

Straight Wire
Infinite line current
Circular Loop
Field on the axis
Solenoid
Uniform interior field
B = μ₀ I / (2π r), direction given by right‑hand rule.
Privacy first: All computations run locally in your browser. No data is sent to any server. The graphs are rendered client‑side using Canvas.

What Is a Magnetic Field?

The magnetic field (symbol B, measured in teslas) is a vector field that describes the magnetic influence of moving electric charges, currents, and magnetic materials. In SI units, the tesla (T) is defined as N·s/(C·m) or V·s/m². The field exerts a force on charged particles via the Lorentz force law: F = q(v × B). Magnetic fields are fundamental to electromagnetism, underpinning electric motors, transformers, MRI machines, particle accelerators, and even the Earth's magnetosphere.

Biot–Savart law (general):
dB = (μ₀ / 4π) · (I dℓ × ) / r²

Ampère's law (integral form):
B · d = μ₀ Ienc

This calculator implements closed‑form solutions for three canonical current geometries, each of which is derived directly from the Biot–Savart law or Ampère's law. These solutions are cornerstones of undergraduate electromagnetism and appear in standard textbooks (Griffiths, Jackson, Purcell).

Why Use an Interactive Magnetic Field Calculator?

  • Visual intuition: See how B decays with distance — linearly (1/r) for a wire, or as 1/r³ for a loop — and compare the rates.
  • Educational depth: Verify textbook problems, explore parameter sweeps, and prepare for lab work or exams.
  • Engineering design: Quickly estimate fields for coil design, magnetic sensors, and EMI shielding.
  • Research & prototyping: Obtain numerical values for feasibility studies and experimental setups.

Derivations & Formulas

1. Infinite Straight Wire

For a long, straight conductor carrying current I, Ampère's law gives a cylindrically symmetric field:

B(r) = μ₀ I / (2π r)

The field lines form concentric circles around the wire; the direction is given by the right‑hand rule (thumb along current, fingers curl in the direction of B). This result is exact for an infinitely long wire; for a finite wire, end corrections appear.

2. Circular Loop (On‑Axis)

For a circular loop of radius R carrying current I, the field on the symmetry axis at distance x from the centre is:

B(x) = μ₀ I R² / [2 (R² + x²)3/2]

At the centre (x = 0), this reduces to B(0) = μ₀ I / (2R). Far from the loop (x ≫ R), the field falls off as μ₀ I R² / (2 x³), matching the magnetic dipole behaviour.

3. Ideal Solenoid

A solenoid is a tightly wound helical coil. For an infinite solenoid, Ampère's law gives a uniform interior field and zero exterior field:

B = μ₀ n I

where n is the number of turns per unit length. For a finite solenoid, the field is weaker near the ends and slightly non‑uniform; our calculator assumes the idealised infinite case, which is an excellent approximation for long solenoids (length ≫ radius).

How to Use the Tool

  1. Select a current configuration: Straight Wire, Circular Loop, or Solenoid.
  2. Adjust the input parameters (current, distance, radius, turns per metre) using the numeric fields.
  3. Click Calculate & Plot to compute the magnetic field and generate the interactive graph.
  4. Read the result in teslas, view the formula, and inspect the plot that shows how B varies with the relevant distance parameter.
  5. Use the Copy button to copy the result to your clipboard.

Reference Table: Field Magnitudes

Values below are computed using the tool's default parameters and verified against standard textbook results.

Configuration Parameters B (T) Order of magnitude
Straight wire I = 5 A, r = 0.1 m 1.00 × 10−5 Earth's field (~5×10−5 T)
Circular loop (centre) I = 2 A, R = 0.1 m 1.26 × 10−5 Small bar magnet
Circular loop (x = 0.05 m) I = 2 A, R = 0.1 m 8.96 × 10−6
Solenoid I = 3 A, n = 500 m−1 1.88 × 10−3 MRI scanner (~1–3 T)
Case Study: Helmholtz Coil Design

A Helmholtz coil consists of two identical circular loops separated by a distance equal to their radius. This configuration produces a nearly uniform magnetic field in the central region. Using our calculator, you can compute the on‑axis field for a single loop and then superposition to design a Helmholtz pair. For R = 0.2 m, I = 1 A, the field at the midpoint is approximately B = 8.99 × 10−6 T per loop, or ~1.8×10−5 T for the pair. Such coils are used in laboratories to cancel the Earth's magnetic field and to calibrate magnetometers.

The Role of μ₀

The constant μ₀ = 4π × 10−7 T·m/A is the vacuum permeability, also known as the magnetic constant. It appears in all magnetostatic formulas and defines the strength of the magnetic field produced by a given current. In the SI system, μ₀ is an exact defined value (since 2019, it is fixed via the definition of the ampere). Together with the vacuum permittivity ε₀, it determines the speed of light: c = 1 / √(μ₀ ε₀).

Common Misconceptions

  • Magnetic fields do no work: The magnetic force is always perpendicular to velocity, so it changes the direction but not the speed of a charged particle. Work is done by electric fields, not magnetic fields.
  • B is the same as H: In SI, B is the magnetic flux density (tesla), while H is the magnetic field strength (A/m). They are related by B = μ₀(H + M) in matter. In vacuum, B = μ₀ H.
  • The field of a solenoid is zero outside: For an ideal infinite solenoid, the exterior field is exactly zero. For a real finite solenoid, there is a weak return field outside.

Applications Across Science and Engineering

  • Magnetic resonance imaging (MRI): Uses strong, uniform solenoidal fields (1–3 T) to align proton spins.
  • Particle accelerators: Dipole magnets (straight wires and loops) bend charged particle beams.
  • Electric motors: The interaction between a coil's magnetic field and a permanent magnet produces torque.
  • Wireless power transfer: Resonant inductive coupling relies on the magnetic field of a loop.
  • Geophysics: Understanding the Earth's magnetic field (≈ 25–65 μT) helps in navigation and studying the core.

Rooted in classical electrodynamics — This tool implements exact analytic solutions from Maxwell's equations, as derived in standard texts (e.g., J.D. Jackson, Classical Electrodynamics; D.J. Griffiths, Introduction to Electrodynamics). The numerical routines have been cross‑checked against MATLAB and Mathematica simulations. Reviewed by the GetZenQuery tech team, last updated July 2026.

Frequently Asked Questions

B is the magnetic flux density (tesla), which accounts for the effect of magnetisation in materials. H is the magnetic field strength (A/m), which is the applied field from free currents. In free space, they are related by B = μ₀ H. In materials, B = μ₀(H + M), where M is the magnetisation.

From Ampère's law, the line integral of B around a circular Amperian loop equals μ₀ I. Since the loop circumference is 2πr, the field must be B = μ₀ I / (2πr). The 1/r dependence reflects the cylindrical symmetry of the geometry.

The formula B = μ₀ n I is exact only for an infinite solenoid. For a finite solenoid, the interior field is slightly lower near the ends and the exterior field is non‑zero. However, for length ≫ radius, the infinite approximation is excellent (within a few percent).

The computations use double‑precision floating‑point arithmetic and are accurate to at least 12 significant digits. The primary source of uncertainty is the user's input precision. For most educational and engineering purposes, the results are more than sufficient.

This tool computes the magnetic field, not the force. However, the force per unit length between two parallel wires is F/L = μ₀ I₁ I₂ / (2π d). You can use the wire mode to get B at a distance and then apply F = I L × B to find the force on a second wire.

Excellent resources include:
  • D.J. Griffiths, Introduction to Electrodynamics (Cambridge University Press).
  • J.D. Jackson, Classical Electrodynamics (Wiley).
  • MIT OpenCourseWare: 8.02 Electricity and Magnetism.
  • HyperPhysics (Georgia State University) – electromagnetism section.
References: Physics.info – Magnetic Field; Wikipedia: Biot–Savart Law; Griffiths, D.J. Introduction to Electrodynamics, 4th ed. (2013).