The fundamental magnetism formula for calculating the magnetic field inside a long solenoid is B = μ0 · μr · (N / L) · I. This equation dictates the field strength in Tesla based on your coil geometry, current, and core material. However, blindly plugging numbers into this equation is the fastest way to design a coil that either fails to pull a relay armature or melts your 26 AWG magnet wire into a puddle of slag. Below, we break down the math, track the units, and expose the non-linear physical limits that textbook magnetism formulas often ignore.

The Core Solenoid Magnetism Formula and Symbol Map

When building electromagnets, inductors, or relays, Ampere’s Law simplifies into the solenoid equation. This assumes the coil is tightly wound and the length is significantly greater than the diameter. Here is the master formula and the exact spec-sheet definitions for every variable.

Symbol Parameter Standard SI Unit Practical Notes & Constants
B Magnetic Flux Density (Field Strength) Tesla (T) Often measured in milliTesla (mT) or Gauss (1 T = 10,000 Gauss) on the bench.
μ0 Vacuum Permeability T·m/A Constant: 4π × 10-7 (approx. 1.2566 × 10-6) T·m/A. NIST Reference.
μr Relative Permeability of Core Dimensionless Air = 1. Mild steel = 100 to 1,000. Pure iron = 5,000. Ferrite = 20 to 5,000.
N Total Number of Turns Dimensionless (count) Must be the total wraps, not turns per layer.
L Length of the Coil Meters (m) The physical length of the wound section, not the total wire length.
I Current Amperes (A) DC current. For AC, this is the instantaneous or RMS value depending on the application.

Rearranged Forms, Unit Traps, and Realistic Magnitudes

On the bench, you rarely solve for B directly. Usually, you have a target field strength and need to find the required current or turns. Here are the algebraically rearranged forms:

  • Solve for Current (I): I = B / (μ0 · μr · (N/L))
  • Solve for Turns (N): N = (B · L) / (μ0 · μr · I)
  • Solve for Coil Length (L): L = (μ0 · μr · N · I) / B
  • Solve for Core Permeability (μr): μr = B / (μ0 · (N/L) · I)

Unit Mistakes That Break the Math

The most common reason a DIY electromagnet calculation fails is unit mismatch. The formula demands strict SI units. If you measure your coil length in centimeters (e.g., 5 cm) and plug in 5 instead of 0.05, your calculated B field will be off by a factor of 100. Similarly, confusing μ (absolute permeability) with μr (relative permeability) will result in missing the 10-7 multiplier entirely, yielding absurdly high Tesla values.

What Does a Realistic Answer Look Like?

Bench Reality Check: If your calculation yields a B field of 15 Tesla, your math is wrong or your core is magic. Earth's magnetic field is ~0.00005 T (50 μT). A strong neodymium magnet surface is ~1.2 T. An MRI machine is 1.5 T to 3.0 T. A well-designed DIY iron-core electromagnet will max out between 0.8 T and 1.6 T before the core saturates.

Solved Bench Problems: Unit Tracking in Action

Let’s run two practical scenarios, tracking the dimensional analysis to ensure the units resolve correctly to Tesla (T).

Problem 1: Air-Core Coil for a Metal Detector

Given: You wind a 250-turn search coil over a 0.15 m PVC pipe form. You drive it with 0.8 A of DC current. What is the center field strength?

  • N = 250
  • L = 0.15 m
  • I = 0.8 A
  • μr = 1 (Air/PVC core)

Setup: B = (1.2566 × 10-6 T·m/A) · (1) · (250 / 0.15 m) · (0.8 A)

Unit Tracking: [T·m/A] · [1/m] · [A] = [T]

Calculation: B = (1.2566 × 10-6) · (1666.67) · (0.8) = 0.00167 T (or 1.67 mT).

Verdict: A very realistic, albeit weak, field for an air-core sensor coil.

Problem 2: Sizing a Relay Coil

Given: You need a 0.25 T field to pull a steel armature. Your coil form is 0.02 m long, wrapped around a silicon steel core (μr = 4,000). Your driver circuit can only supply 0.05 A (50 mA). How many turns do you need?

  • Target B = 0.25 T
  • L = 0.02 m
  • μr = 4,000
  • I = 0.05 A

Rearranged Formula: N = (B · L) / (μ0 · μr · I)

Calculation: N = (0.25 · 0.02) / (1.2566 × 10-6 · 4000 · 0.05)

N = 0.005 / 0.00025132 = 19.89 turns.

Verdict: Round up to 20 turns. Because the high-permeability steel core multiplies the field immensely, you need very few turns at low current to achieve a strong pull.

Real-World Scenario: Designing a 12V DIY Magnetic Lock

Textbook formulas assume linear materials. The workbench does not. Here is a narrative walkthrough of a failed 12V magnetic cabinet lock design that perfectly illustrates the limits of basic magnetism formulas. (For deeper reading on magnetic circuit limits, see the Electromagnetism tutorials at Electronics-Tutorials).

The Setup

A maker wants to build a fail-safe magnetic lock for a heavy wooden cabinet. They use a 10 mm diameter mild steel rod (μr assumed at 1,000) as the core. They wind 500 turns of 26 AWG magnet wire tightly over a 0.05 m length. They connect it directly to a 12V DC bench supply.

The Numbers (Theoretical)

  1. Wire Length & Resistance: Mean circumference per turn is ~0.0314 m. Total wire = 500 × 0.0314 = 15.7 m. 26 AWG copper is ~0.134 Ω/m. Total Resistance (R) = 2.1 Ω.
  2. Current (I): I = V/R = 12V / 2.1 Ω = 5.71 A.
  3. Magnetic Field (B): B = (1.2566 × 10-6) · (1000) · (500 / 0.05) · (5.71) = 71.7 Tesla.

The Outcome

The maker flips the switch. The lock engages with a loud snap. Thirty seconds later, the magnet wire insulation begins to smoke. Within two minutes, the 26 AWG wire fuses open, destroying the coil. Furthermore, the pulling force was noticeably weaker than the 71 T calculation implied.

What Went Wrong?

1. Core Saturation (The 71T Illusion): The formula B = μ0μrnI assumes μr is constant. It is not. Mild steel physically cannot support a magnetic flux density higher than roughly 1.6 to 1.8 Tesla. Once the magnetic domains in the steel align (saturation), the core effectively becomes air (μr drops toward 1). The extra 5 Amps of current was wasted as heat, generating almost zero additional magnetic field.

2. Thermal Derating and Ampacity: 26 AWG wire has a maximum chassis ampacity of about 1.5 A to 2.0 A. Pushing 5.71 A through it resulted in massive I2R heating (over 68 Watts dissipated in a tiny coil). As the copper heated, its resistance increased, dropping the current dynamically, but not before the thermal limit of the enamel insulation (usually 155°C for Class F) was breached.

When This Formula Applies (and When It Fails)

To use magnetism formulas safely and effectively, you must understand the boundary conditions of the derivation. The solenoid equation is not a universal law; it is a specific application of Ampere’s Law with strict geometric and material assumptions.

Where It Works Perfectly

  • Long, tightly wound coils: The coil length (L) must be at least 5 to 10 times greater than the coil radius. If you have a short, fat pancake coil, the field at the center drops significantly, and this formula will overestimate B by 20% or more.
  • Linear materials: Air, vacuum, and non-magnetic metals (copper, aluminum, brass) have a μr of exactly 1. The formula is perfectly linear and accurate for these cores.
  • Low-flux ferromagnetic cores: If you are operating an iron core well below its saturation point (e.g., designing for 0.2 T in a silicon steel core that saturates at 1.8 T), the linear assumption holds.

Where It Fails on the Bench

  • Fringing and Edge Effects: The formula calculates the field at the exact center of an infinitely long solenoid. At the physical ends of your real-world coil, the magnetic field lines bow outward (fringing), and the field strength drops to roughly half of the calculated center value.
  • High-Current Ferromagnets: As demonstrated in the mag-lock scenario, once you hit the B-H curve knee (saturation), the linear formula becomes useless. You must consult the specific B-H hysteresis curve datasheet for your exact steel alloy and use iterative magnetic circuit analysis (Hopkinson’s Law) instead.
  • AC High-Frequency Applications: At high frequencies, skin effect in the wire and eddy currents in solid iron cores drastically alter the effective impedance and internal field distribution. Laminated or ferrite cores must be used, and complex impedance (Z) replaces simple DC resistance.

Mastering these magnetism formulas means knowing when to trust the algebra and when to trust the physical limits of the materials on your workbench. Always size your wire for the thermal reality of the current, and always respect the saturation limit of your core.