Magflow: Differentiable Simulation of Industrial-Grade 6D Magnetic Levitation

Philipp Hartmann, Jannick Stranghöner, Klaus NeumannarXiv 2026 · arXiv

TL;DR

Magflow is a fully differentiable, GPU-parallel simulator that enables training neural controllers for 6D magnetic levitation (MagLev) purely from simulated physics. The resulting controllers transfer zero-shot to real industrial hardware, achieving 4 kHz real-time control and unlocking capabilities—such as full 360° rotation and support for non-standard mover shapes—that were previously impossible with traditional control engineering.

What Problem Does This Paper Address?

Magnetic levitation with six degrees of freedom (6D) is a "holy grail" for frictionless, high-precision industrial transport. However, it is inherently unstable. To make real-time control at kilohertz rates possible, industrial systems currently rely on hardware-software co-design. Engineers design the magnets (movers) and coils (stators) specifically so that the electromagnetic forces can be approximated by simple, "hand-crafted" analytical models.

The catch? These approximations only work within a very narrow "validity region." For example, standard industrial movers are often restricted to a yaw rotation of just ±5°. If you want to use a different magnet shape or rotate further, the math breaks down, and the mover crashes. The authors ask: Can we move the complex physics computation out of the real-time loop and into offline training to break these constraints?

Methods

The authors introduce Magflow, a simulator implemented entirely in JAX. Unlike traditional models that use simplified "harmonic commutation," Magflow computes the underlying physics directly:

  • Electromagnetic Physics: It uses the Biot-Savart law and Lorentz force integrals to model interactions between stator coils, mover magnets, and Hall-effect sensors.
  • Differentiability: Because it is built in JAX, the entire simulation is differentiable. This allows the team to use Backpropagation Through Time (BPTT) to train a neural controller. Instead of the trial-and-error of Reinforcement Learning, BPTT uses exact gradients from the physics engine to tell the controller how to improve.
  • Neural Architecture: The controller is a 4-layer Gated Recurrent Unit (GRU) that maps raw magnetic field readings directly to 72 actuator commands (coil currents).
  • Sim-to-Real: To ensure the controller works on real hardware, they use domain randomization, varying parameters like magnet strength, mass, and sensor noise during training.
Fig. 1. Magflow is the first differentiable simulator for 6D magnetic levitation, fusing the electromagnetic physics and the neural controller into a single GPU computational graph. Backpropagation through time trains the controller end- to-end, purely from physics. The trained controller then transfers zero-shot to the real hardware running at 4 kHz.

Datasets

The paper does not use a static dataset. Instead, training data is generated procedurally within the Magflow simulator across thousands of parallel "worlds." For evaluation, they use a real-world industrial platform (Beckhoff XPlanar) and a Vicon motion capture system to provide ground-truth measurements for comparison against the simulation.

Key Insights and Ideas

  • Co-design is not a physical necessity: The paper proves that we don't need to simplify hardware geometry just to make the math tractable. A neural network can learn to "invert" complex, non-linear physics if provided with a high-fidelity differentiable simulator.
  • Differentiable Simulators > RL: For domains with smooth, well-understood physics (like electromagnetics), differentiable simulation is far more efficient than standard Reinforcement Learning. It provides a direct signal for how to adjust weights to reduce tracking error.
  • Zero-Shot Industrial Control: It is possible to take a "black box" neural network trained entirely on a GPU and have it control unstable, high-speed industrial hardware at 4 kHz without any fine-tuning on the real machine.

Key Results

The neural controller, trained exclusively in Magflow, achieved several "firsts" for this industrial platform:

  • Extended Workspace: It achieved a full 360° yaw rotation, shattering the previous ±5° limit of engineered controllers.
  • New Topologies: The system successfully levitated and controlled a plain bar magnet—a geometry for which no hand-crafted analytical controller exists on this platform.
  • Extreme Maneuvers: It demonstrated continuous 360° roll rotation of a bar magnet, a feat previously only seen in specialized research setups with optical tracking.
  • Robustness: The controller maintained stable levitation even when loaded with a 1.3 kg payload (roughly 4x the mover's own weight).
  • Real-time Performance: The GRU inference consistently ran within the strict 250 µs window required for 4 kHz industrial control.
The neural controller enables full 360° yaw rotation and control of non-standard mover shapes like a bar magnet.

Limitations and Future Work

While Magflow achieves impressive qualitative behaviors, it currently lags behind proprietary, highly-tuned industrial controllers in absolute precision. The neural controller's RMS tracking error is roughly 0.3 mm, whereas industrial systems aim for micrometer-scale precision.

The authors suggest that the "precision gap" is likely due to the neural network's capacity rather than the simulator itself. Future work will explore larger models, residual learning to correct for unmodeled physics (like eddy currents), and scaling the system to handle movers traveling across multiple stator tiles.

Summary updated

Abstract

Magnetic levitation with six-degrees-of-freedom enables frictionless transport and micrometer-scale positioning in principle, but low-level control is inherently challenging due to its complex and unstable dynamics. Industrial systems typically rely on deep hardware-software co-design, where mover and stator geometries are jointly designed to enable a compact, hand-crafted approximation of the electromagnetic force computation, thereby keeping control computationally tractable at kilohertz rates. However, this approach imposes overly conservative constraints on the operating workspace and the range of supported mover topologies. Instead of reducing the underlying physics to a hand-crafted approximation, we compute the physics directly. We introduce Magflow, a fully differentiable, GPU-parallel simulator for 6D magnetic levitation. It is used to train the first neural controller for an industrial-grade 6D magnetic levitation system that is learned purely from simulated physics. We show that the learned neural controller transfers zero-shot from simulation to real hardware while satisfying hard real-time constraints at 4 kHz. The learned controller achieves qualitatively new behaviors and even levitates a mover topology for which no hand-crafted solution exists. These results demonstrate that co-design is not a physical necessity for 6D magnetic levitation control. More broadly, control learning from simulated physics can find solutions beyond the reach of control engineering in demanding industrial domains. Source code and demonstration videos are publicly available at https://sites.google.com/view/magflow.
BibTeX
@misc{hartmann2026magflow,
  author = {Philipp Hartmann and Jannick Stranghöner and Klaus Neumann},
  title = {{Magflow: Differentiable Simulation of Industrial-Grade 6D Magnetic Levitation}},
  year = {2026},
  eprint = {2611.23050},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.23050},
}
Figure