When you need to design an electromagnet, build a custom relay, or size an inductor, guessing the magnetic flux density will lead to melted wire or weak actuation. The direct answer for the magnetic field inside an ideal, air-core solenoid is calculated using the formula B = (μ0 × N × I) / L. This gives you the flux density (B) in Teslas based on your wire turns (N), current (I), and coil length (L).
While online tools can act as a quick calculator, magnetic field generation on the workbench requires understanding the underlying assumptions. If you plug in the wrong units or ignore core saturation, your physical build will fail to match the digital math. Here is the complete derivation, rearranged forms, and bench-tested scenarios you need to design reliable electromagnetic components.
The Core Solenoid Formula and Symbol Definitions
The foundational equation for the magnetic field inside a long, tightly wound solenoid is derived from Ampere's Law. According to Georgia State University's HyperPhysics, the field inside an ideal solenoid is uniform and depends strictly on the turn density and the current, independent of the coil's diameter.
B = (μ0 × N × I) / L
| Symbol | Parameter Name | Standard SI Unit | Typical DIY Range |
|---|---|---|---|
| B | Magnetic Flux Density | Tesla (T) | 0.005 T to 0.1 T (5mT - 100mT) |
| μ0 | Vacuum Permeability (Constant) | T·m/A or H/m | 4π × 10-7 (≈ 1.2566 × 10-6) |
| N | Total Number of Turns | Dimensionless (count) | 100 to 2,000 turns |
| I | Current through the wire | Amperes (A) | 0.5 A to 5.0 A |
| L | Length of the solenoid coil | Meters (m) | 0.02 m to 0.2 m (2cm - 20cm) |
When This Formula Applies (and Its Assumptions)
This specific calculator magnetic field equation assumes an ideal air-core solenoid. For the math to hold true within a 5% margin of error, your coil length (L) must be at least 10 times greater than its diameter. It also assumes the field is measured at the center of the coil; the field strength drops to exactly half at the physical ends of the solenoid. Finally, it assumes an air core. If you insert a ferromagnetic core (like an iron bolt), you must multiply the result by the relative permeability (μr) of the material—until the core saturates.
Rearranged Forms for Electromagnet Design
On the bench, you rarely know all variables upfront. Usually, you have a target magnetic field and a fixed power supply, and you need to figure out how much wire to wind. Here are the algebraically rearranged forms solving for each design variable:
- Solving for Current (I): I = (B × L) / (μ0 × N)
Use this when your coil is already wound, and you need to know how many amps to push through it to hit a specific Tesla target. - Solving for Turns (N): N = (B × L) / (μ0 × I)
Use this when designing a new coil. You know your power supply's max current and the physical space (L) available on the bobbin. - Solving for Length (L): L = (μ0 × N × I) / B
Use this to find the minimum coil length required to prevent the field from exceeding a safety threshold, given a fixed wire spool and current.
Solved Problems with Strict Unit Tracking
The most common reason DIY electromagnets fail to match theoretical calculations is unit mismanagement. The SI system demands strict adherence to base units. Here are two step-by-step derivations.
Problem 1: Finding the Magnetic Field of an Air-Core Coil
Given: You wind N = 400 turns of 26 AWG magnet wire over a length L = 8 cm. You connect it to a bench supply pushing I = 2.0 A. What is the magnetic field B at the center?
- Convert to SI Base Units: L = 8 cm → 0.08 m. (N and I are already correct).
- Substitute into the formula: B = (1.2566 × 10-6 T·m/A × 400 × 2.0 A) / 0.08 m
- Multiply the numerator: 1.2566 × 10-6 × 800 = 0.00100528 T·m
- Divide by the denominator: 0.00100528 / 0.08 = 0.012566 T
- Convert to practical units: 0.012566 T = 12.57 mT (milliteslas).
Problem 2: Sizing Turns for a Target Field
Given: You need a target field B = 30 mT to reliably pull a steel armature. Your coil former allows a winding length L = 5 cm. Your power supply maxes out at I = 1.5 A. How many turns (N) do you need?
- Convert to SI Base Units: B = 30 mT → 0.03 T. L = 5 cm → 0.05 m.
- Select the rearranged formula: N = (B × L) / (μ0 × I)
- Substitute values: N = (0.03 T × 0.05 m) / (1.2566 × 10-6 T·m/A × 1.5 A)
- Calculate numerator: 0.03 × 0.05 = 0.0015 T·m
- Calculate denominator: 1.2566 × 10-6 × 1.5 = 1.8849 × 10-6 T·m
- Divide: 0.0015 / 1.8849 × 10-6 = 795.79
- Round to physical reality: You must wind 796 full turns.
Real-World Scenario: Building a 50mT DIY Relay Actuator
Formulas assume perfect conditions. Let us walk through a real bench scenario where the math met physical reality, highlighting the gap between an air-core calculator magnetic field and a ferromagnetic build.
The Setup
The goal was to build a custom linear actuator to replace a burnt-out 12V automotive relay. We used a 10mm diameter, 50mm long mild steel (1018) bolt as the core. The target was a 50 mT air-gap field to pull a steel lever. We chose 26 AWG enameled copper wire (magnet wire) and planned to run it at 1.5 A from a regulated bench supply.
The Numbers
Using the air-core rearranged formula for N: N = (0.05 T × 0.05 m) / (1.2566 × 10-6 × 1.5 A) = 1,326 turns.
The coil circumference was roughly 31.4 mm. Total wire length = 1,326 × 0.0314 m ≈ 41.6 meters. According to wire tables, 26 AWG copper has a resistance of about 0.134 Ω/m. Total coil resistance R = 41.6 m × 0.134 Ω/m = 5.57 Ω.
To push 1.5 A through 5.57 Ω, Ohm's law dictates we needed V = I × R = 1.5 × 5.57 = 8.35 V. The power dissipation would be P = I²R = 1.5² × 5.57 = 12.5 W.
The Outcome and What Went Wrong
We wound the 1,326 turns, applied 8.35 V, and measured the field at the bolt tip using an SS49E linear Hall effect sensor. The meter read 410 mT—over eight times our calculated 50 mT target. The actuator slammed shut with excessive force, and within four minutes, the coil insulation began to smoke.
What went wrong? Two critical physics realities were ignored:
- Core Permeability (μr): The formula used was for an air core (μr = 1). Mild steel has a relative permeability of roughly 100 to 2,000 depending on the exact alloy and annealing. The steel bolt multiplied our magnetic field massively. However, steel saturates magnetically around 1.6 T to 2.0 T. Once saturated, adding more current yields almost zero extra field, just heat.
- Thermal Limits: Dissipating 12.5 W of heat in a tightly wound coil the size of a AA battery, with no active cooling and sealed by enamel, caused a thermal runaway. The 26 AWG wire was too thin for continuous duty at that power density.
The Fix: We rewound the coil using thicker 22 AWG wire (lowering resistance and heat), reduced the turns to 300 (relying on the steel's μr to reach the target field), and added a 10 Ω power resistor in series to limit the steady-state current to 0.8 A.
Unit Traps and Realistic Magnitude Checks
When using any calculator, magnetic field outputs are highly sensitive to input errors. Use this checklist to sanity-check your results before cutting wire.
Unit Mistakes That Break the Math
- Centimeters instead of Meters: If you input L = 5 instead of L = 0.05, your calculated B will be 100 times too small, or your required N will be 100 times too high. Always convert length to meters first.
- Milliamps instead of Amps: Entering 500 mA as '500' instead of '0.5' will skew your result by a factor of 1,000.
- Gauss vs. Tesla Confusion: Many cheap bench gaussmeters display in Gauss (G). The SI formula outputs Teslas (T). Remember the hard conversion: 1 Tesla = 10,000 Gauss. If your calculator says 0.02 T, your meter should read 200 G.
What a Realistic Answer Magnitude Looks Like
If your calculator spits out a number, compare it against these physical benchmarks to spot decimal errors:
- Earth's Magnetic Field: ~0.00005 T (50 µT). If your DIY coil calculates to this level, you have too few turns or too little current.
- Standard Fridge Magnet: ~0.005 T (5 mT).
- Functional DIY Electromagnet / Relay: 0.02 T to 0.1 T (20 mT to 100 mT). This is the sweet spot for air-core or lightly loaded actuators.
- Saturated Iron Core / Heavy Lifting Magnet: 1.0 T to 2.0 T. You cannot exceed ~2.2 T with standard ferromagnetic cores, regardless of how much current you push.
- Hospital MRI Machine: 1.5 T to 3.0 T (requires superconducting niobium-titanium wire cooled by liquid helium).
By anchoring your calculations to strict SI units and respecting the physical limits of your core material, you can move from abstract math to reliable, high-force electromagnetic builds on the first attempt.






