See the direction of an invisible field

Magnetic Field Simulator

See how a magnetic field changes around movable magnets. Start with a compass grid, compare four field views, and drag a compass probe to inspect direction and strength.

Starts in Compass Grid. Drag a magnet or the compass probe; use Hide controls to clear the view.

Drag the magnet body to move · Drag an end or scroll over it to rotate · Drag the compass to measure · Hide or show controls at any time

See a magnetic field one compass at a time

Magnetic Field Simulator starts in Compass Grid mode. Small red-and-gray needles show the local field direction around a movable magnet, making changes easy to see as you move, rotate or flip it. The larger draggable compass acts as a probe, with a readout of field strength, horizontal and vertical components, and direction.

Move the magnets and follow the needles

  1. Drag the middle of a magnet to move it across the board. The selected magnet has a dashed outline.
  2. Drag either end to rotate it, or scroll while pointing over the magnet. Flip reverses its orientation by half a turn.
  3. Choose Add to introduce another magnet, up to three. Select a magnet before changing its settings or using Remove. At least one magnet stays on the board.
  4. Drag the circular compass probe to a different position and compare its needle with the surrounding grid. Watch the strength and direction readouts change.

Use Hide controls in the panel header to minimize the controls and reveal more of the field. The header remains visible with a Show controls button, so the panel can be restored without resetting your experiment. On smaller screens the panel sits at the bottom and its expanded contents scroll. Fullscreen enlarges the same playground.

Compare four views of the same field

  • Compass Grid: the default view, with regularly spaced needles aligned to the local magnetic field.
  • Field lines: traced curves with arrowheads to show direction. Their colors follow the field-strength legend.
  • Iron filings: a fixed scattering of short marks oriented with the field. They reveal patterns rather than simulating moving metal grains.
  • Strength map: a colored field-strength background with field lines over it. The legend uses a logarithmic scale, so equal color intervals represent ratios rather than equal additions.

Try the same arrangement in all four modes. Compass Grid is useful for reading direction at many points; the strength map makes spatial differences in magnitude easier to notice. Changing the visualization does not move the magnets or the probe.

Remanence, magnet length and the Earth-field option

The Remanence Br slider adjusts the selected magnet's model parameter from 0.10 to 1.45 tesla. It is not the field strength at every point on the board. Magnet length ranges from 15 to 100 millimeters, while the modeled cylinder radius stays fixed at 10 millimeters. Use the 50 mm scale bar as a reference for the displayed cross-section.

The optional Earth field adds a uniform 50-microtesla component pointing toward the top of the board. That is a simplified background setting for this experiment, not a location-specific model of Earth's magnetic field. Reset returns to one magnet, the default probe position and Compass Grid, and switches the Earth-field option off.

Read the probe and save a view

The probe reports magnitude in millitesla, switching to tesla for large values. Bx and By show the horizontal and vertical field components, with upward treated as positive in the readout. Direction is measured counterclockwise from the rightward horizontal direction. The animated needle can briefly swing while settling after a change; the numeric readout describes the field at its current position.

Pause needle holds the animated compass angle while leaving the controls and field readouts available. Resume needle lets it settle again. When reduced motion is requested, the needle aligns directly without swinging. Save image downloads the canvas as a JPEG without the controls. This supplied simulator is silent. Animation suspends when the tab is hidden or the playground scrolls out of view.

What this model represents

The supplied model represents uniformly magnetized cylinders using a finite stack of circular current loops and elliptic-integral calculations. Contributions from the magnets and optional background field are added together. Field lines are traced numerically through a two-dimensional cross-section containing the magnet axes. Finite sampling and regularization near the modeled currents keep this an educational approximation rather than a calibrated design instrument.

The board holds at most three magnets and a fixed pool of 9,000 filing samples. Expensive field views are cached until settings or magnets change, field-line tracing has a step limit, and interactive canvas resolution is capped at about 1.8 million pixels. No external graphics library, image texture or audio file is needed. The larger probe shows how direction varies locally; it does not model force or torque on the magnets themselves.