Ferrofluid Shape Control with Deep Reinforcement Learning

Anthony Czubarow, Antonio Terpin, Raffaello D'AndreaarXiv 2026

TL;DR

Researchers have developed a way to "sculpt" magnetic liquids into complex, transient shapes using deep model-based reinforcement learning and a single electromagnet. By learning directly from physical interaction rather than complex simulations, the system masters the nonlinear dynamics of ferrofluids to achieve precise geometric targets like stars and pentominoes.

What Problem Does This Paper Address?

Ferrofluids—liquids infused with magnetic nanoparticles—are a dream material for soft robotics because they can reshape, split, and move in response to magnetic fields. However, controlling them is a nightmare. Their behavior is governed by "nonlinear continuum dynamics," meaning the way they stretch and flow is incredibly complex and hard to model mathematically.

While previous research has used large arrays of electromagnets to hold ferrofluids in static shapes, this paper tackles a more difficult challenge: transient shape control. The goal is to reach a specific geometry as the fluid moves, even if that shape is unstable and only exists for a fraction of a second. Furthermore, the authors aim to do this with minimal hardware—just one fixed electromagnet—by exploiting the fluid's own momentum and surface tension.

Methods

The team built a custom experimental platform consisting of a glass jar filled with ferrofluid immersed in water, an overhead camera for visual feedback, and a single electromagnet positioned underneath.

To handle the control logic, they turned to DreamerV3, a state-of-the-art model-based reinforcement learning (RL) algorithm. Instead of relying on a pre-built simulator (which would likely fail to capture the real-world fluid nuances), the system learns "on the job." 1. World Modeling: The agent interacts with the physical fluid, collecting camera images and recording the effects of different magnetic current commands. It uses this data to build an internal "world model" of how the fluid behaves. 2. Imagined Training: The agent then trains its control policy by "imagining" interactions within this learned model, which is much faster and safer than constant physical testing. 3. Visual Reward: The system is rewarded based on the Intersection-over-Union (IoU)—a measure of how well the fluid's silhouette overlaps with a target shape. Because the shapes are transient, the reward is specifically designed to favor improvements in the "best match" seen over a short window of time.

Fig. 1. Ferrofluid shapes reached through deep reinforcement learning.

Datasets

The researchers evaluated their system on a diverse "benchmark" of 20 target shapes categorized into three families:

  • Polygons: Triangle, Square, Pentagon, and Hexagon.
  • Asterisks: Shapes with 3, 4, 5, and 6 radial rays.
  • Pentominoes: 12 complex geometric figures (like the 'L', 'T', and 'X' shapes familiar to Tetris fans).

Key Insights and Ideas

  • Dynamics as a Tool: The core "aha moment" is that fluid motion isn't just a hurdle to overcome; it's a tool. A moving interface can pass through shapes that are impossible to maintain at equilibrium.
  • Learning Beats Modeling: By learning directly from physical interaction, the authors bypassed the "sim-to-real gap"—the common problem where a policy trained in a perfect simulation fails in the messy real world.
  • Single Magnet Versatility: It is surprising how much geometric variety a single magnet can produce. By pulsing the current, the agent can cause the fluid to stretch into limbs and then "catch" it at the right moment of recoil to match a target.
  • The Persistence of Memory: To train for transient shapes, the reward function must "remember" the best match achieved during an episode. If you only reward the final state, the agent never learns to hit a fleeting target in the middle of a maneuver.
The system learns to reach complex shapes like these polygons and asterisks.

Key Results

The learned policies were highly successful across the board:

  • Performance Gain: Trained policies achieved a 30.7% relative gain in shape matching accuracy compared to untrained stochastic policies.
  • Consistency: For simpler shapes like triangles and squares, the system reached the target threshold in nearly every attempt (e.g., 122/150 for the triangle).
  • Complexity: Even for difficult pentominoes, the agent learned to reproduce the main "limbs" of the shapes, though some fine details like sharp corners were naturally rounded by fluid surface tension.
  • Speed: The targets were typically reached within 2 to 7 seconds of starting the maneuver.
  • Transience: As expected, the shapes were brief. The fluid typically stayed within a high-accuracy range for only 0.07 to 0.34 seconds before continuing its deformation.

Limitations and Future Work

  • Geometric Resolution: A single magnet has limits. It struggled to resolve very closely spaced features (like the "kinks" in an 'N' or 'W' pentomino), often merging them into a single mass.
  • IoU as a Metric: While IoU is great for area overlap, it doesn't prioritize sharp corners or specific topological features. Future work could incorporate rewards based on curvature or skeletonization.
  • Scaling Up: The authors suggest that adding more magnets could enable even richer shapes and more sustained control.
  • Soft Robotic Applications: This "learning from interaction" approach could be extended to teach ferrofluid robots how to navigate through tight pipes or manipulate small objects by changing their shape on the fly.

Summary updated

Abstract

Ferrofluids are liquids containing magnetic nanoparticles, enabling shape control through external magnetic fields. This deformability supports their use as soft robotic bodies that can navigate confined spaces and manipulate objects. Their nonlinear continuum dynamics, however, make reliable control challenging. Existing work shows how spatial magnetic fields from electromagnet arrays can establish and maintain desired ferrofluid configurations. A complementary objective is to exploit the fluid's dynamics under limited actuation to reach prescribed shapes that may not be sustainable at equilibrium. Here, we use deep model-based reinforcement learning to control these transient shapes. Learning directly through physical interaction, our policies select current commands for a single fixed electromagnet based on visual observations, guiding the moving ferrofluid toward prescribed geometries. The learned policies repeatedly attain a variety of shapes spanning polygons, asterisks and pentominoes. These results demonstrate that learning directly from physical interaction enables reliable fluid shaping, opening new possibilities for controlling ferrofluid-based soft robots.
BibTeX
@misc{czubarow2026ferrofluid,
  author = {Anthony Czubarow and Antonio Terpin and Raffaello D'Andrea},
  title = {{Ferrofluid Shape Control with Deep Reinforcement Learning}},
  year = {2026},
  eprint = {2611.25232},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.25232},
}
Figure