A solenoid is a coil of wire long enough that the field inside it is very nearly uniform, and its strength is set by B = μ0nI — turns per metre times current, and nothing else. Drag the turns, the length and the current below, swap the air core for iron, and watch the field lines thicken or thin in the bore.

Inside a Solenoid

Stretch the coil and the field drops, even though not a single turn was removed. The slider you are really moving is n = N/L, and the field only ever cared about that.

Field at the centre  B(0)
4.9634 mT
1.26% below the ideal 5.0265 mT
CORE SATURATED
Soft iron cannot carry much more than 2 T.
Turns per metre
2,000 /m
Ideal field
5.0265 mT
Field at the end
2.5053 mT
End / centre
0.5047
Flux through a turn
6.2372 µWb
Length / diameter
6.25
Ends matter: the ideal formula overstates B by 1.26%.
Turns, N500
Length, L0.250 m
Current, I2.0 A
Coreair
Coil radius R = 0.020 m (d = 0.040 m), fixed. It is deliberately not a control: the radius never appears in B.
Air core: relative permeability 1.
Try this: note the field, then drag L from 0.25 m to 0.50 m without touching N. Same wire, same current, half the field.

What Is the Solenoid Simulator?

The solenoid simulator is a free interactive physics lab that runs in your browser — nothing to install and no sign-up. Drag turns, length and current to see the magnetic field inside a coil change live, and watch B = mu0nI in action. It reports field at the centre b as you drag the sliders.

What you can change in the solenoid simulator
ControlRangeStep
Number of turns on the coil100 – 200010
Length of the coil0.05 – 0.60 m0.005
Current through the winding0.1 – 10 A0.1

How to use the solenoid simulator

Three sliders and a pair of core buttons drive everything. Turns and current behave the way you expect: double either one and the field doubles exactly. The length slider is the one that catches people out. Stretch the coil from 0.25 m to 0.50 m and the field falls by half, though not a single turn was removed and the current never moved. You are not really editing a length at all — you are editing turns per metre, n = N/L, and that is the only thing the field ever responds to.

The readouts are there to be checked rather than admired. The field at the mouth of the coil sits at almost exactly half the field at the centre — 0.5047 on the default settings — because at the centre you have coil on both sides of you, and at the end only on one. Squash the coil short and that figure climbs above half, which is the simulator telling you it is no longer a long solenoid. The dashed reference line marks the ideal μ0nI, and the gap between it and the bar is exactly how much a coil of finite length falls short: 1.26 per cent at the default, over 20 per cent when you wind the length right down.

The simulator solves the exact on-axis field of a finite coil, not the textbook idealisation, which is why those two numbers differ at all. Notice what is missing from B = μ0nI: the radius. A narrow coil and a fat one with the same turns per metre and the same current produce the same interior field, so the radius here is fixed at 0.020 m and printed as text rather than given a slider. To put your own numbers through the same algebra, use the Magnetic Field Calculator, and for where the formula comes from, read what a solenoid is and how it works.

One misconception the iron button is designed to break. Selecting a soft-iron core multiplies the field by a relative permeability of 500 — briefly. On the default settings that predicts 2.4817 T, which no soft iron will deliver, so the reading clamps at 2 T and the saturation lamp lights. That ceiling is where the neat linear model stops describing the metal. Everything the coil does with that field belongs to the wider story of the magnetic field, and changing the current instead of the core is the doorway to electromagnetic induction.

Frequently asked questions

How do I use a solenoid simulator to find the magnetic field?

Set the three sliders to your coil and read the field straight off the panel. Turns and length together fix the turns per metre, n = N/L, which the simulator prints for you; current scales the answer in direct proportion. The default coil, 500 turns over 0.25 m carrying 2 A, gives 2000 turns per metre and a centre field of 4.9634 mT.

Why does making the solenoid longer reduce the field if the turns stay the same?

Because the field depends on turns per metre, not on turns. Stretching the same 500 turns from 0.25 m to 0.50 m halves n from 2000 to 1000 per metre, and the centre field falls from 4.9634 mT to 2.5053 mT. Not one turn was removed and the current never changed. The length slider is really an n slider in disguise.

Why does the simulator show half the field at the end of the coil?

At the centre you have coil on both sides of you; at the mouth you have coil on one side only, so roughly half the contribution disappears. The default coil reads 0.5047, just over half. Squash the coil short and that figure climbs: at 0.05 m it reaches 0.5945, because a stubby coil is nearly uniform along its own short length.

Does the coil radius change the field in the simulator?

Not in the ideal formula, where B = mu0nI contains no radius at all. It does appear in the exact finite-length field the simulator actually solves, through the end correction. That is why the radius is fixed at 0.020 m and shown as text rather than as a slider: it changes how far short of the ideal a real coil falls, not the ideal value itself.

What does the saturation warning mean when I select the iron core?

It means the linear model has stopped being true. The iron button multiplies the field by a relative permeability of 500, which on the default settings predicts 2.4817 T. Real soft iron cannot carry much beyond about 2 T; past that its permeability collapses toward 1. The simulator clamps the reading at 2 T and lights the lamp rather than reporting a figure the metal could not produce.

References & formula source

  • Halliday, Resnick & Walker — Fundamentals of Physics, chapter on magnetic fields due to currents (solenoids and toroids).
  • Young & Freedman — University Physics with Modern Physics, chapter on sources of magnetic field.
  • Griffiths — Introduction to Electrodynamics, chapter on magnetostatics (finite-length solenoid on the axis).
  • Further reading: Solenoid — Wikipedia