Home▸Physics & Mechanics▸Magnetic Levitation Simulator (2D)

Magnetic Levitation Simulator (2D)

Interactive 2D side-view magnetic levitation simulator: balance real repulsion or attraction forces against gravity, compare a passively stable permanent-magnet track with an open-loop-unstable electromagnet that needs PID feedback control, and watch height, net force and stability update live.

Physics & Mechanics2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-3d-magnetic-levitation ↗ Open standalone

This 2D side-view simulator balances real magnetic forces against gravity to hold an object in mid-air. In permanent-magnet mode, an inverse-cube repulsion force from a track below the puck naturally strengthens as the gap shrinks and weakens as it grows, giving a passively stable levitation height with no active control needed. Switch to electromagnet mode and the puck instead hangs below an overhead coil whose inverse-square attraction pulls harder the closer it gets — an open-loop unstable configuration that crashes or drifts away unless a PID feedback loop continuously trims the coil current to hold it at the target gap. Adjust the field strength and object mass, nudge the puck with the perturb button, and watch levitation height, net force, drive current and stability update live as the system either settles, oscillates, or fails.

⚙ Under the hood

2D side-view force-balance simulator: a permanent-magnet track passively levitates a puck via inverse-cube repulsion, while an overhead electromagnet mode shows the open-loop-unstable inverse-square attraction that needs PID feedback control to hold a stable gap.

physicsmagnetic levitationmaglevforce balancePID controlelectromagnetism2D

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)