When Physics Simulations Learn to Design

Reading time: 17 Minutes

Physics has always been good at answering the question: given a system and its initial conditions, what will happen next? Partial differential equations (PDEs) are the language of that prediction, describing how materials evolve, how phases separate, how quantum states change over time. But a harder and often more useful question is the inverse: given a desired outcome, what should we change to get there. Answering that question with PDE-based models has historically required significant custom mathematical work for every new physical system. A new study by researchers at MIT and Imperial College London, published in Physical Review Research, asks whether automatic differentiation, the same computational tool that powers modern machine learning, can make that work general and reusable.

The answer, demonstrated across four physically distinct problems, is yes. The key idea is to make the entire simulation pipeline differentiable: from an experimental image of a material, through geometry processing, through the PDE dynamics, to a measurable outcome. Once every step in that chain can propagate gradients, an optimizer can ask (for any objective and any physical model)  which way to nudge the parameters.

The four demonstrations span learning physical models from noisy data, controlling phase boundary motion, designing spatially varying coatings to suppress phase separation in battery particles, and steering a Bose-Einstein condensate into a desired quantum state. What unifies them is not the physics but the computational structure.


Shared mathematical structure

Although the four problems look very different, they share a common mathematical structure. In each case, the state of the system varies across space and evolves over time according to a PDE derived from a single function, called an energy or free energy functional. This functional acts as a landscape that assigns an energy to every possible configuration. The shape of that landscape determines how the system moves.

In most of the problems, the system slides downhill. Two classical examples from materials science show this. The Cahn-Hilliard equation describes conserved dynamics: material moves from place to place, but the total amount stays fixed. For instance, when particles diffuse from regions of high concentration to low. The Allen-Cahn equation describes non-conserved dynamics, where the local amount can also change because material is added or removed. For example when lithium enters a battery particle through a chemical reaction at its surface. In both cases, the system keeps lowering its free energy until it settles.

The quantum example works differently. A Bose-Einstein condensate, described by the Gross-Pitaevskii equation, doesn’t lose energy. Instead, its wavefunction moves across the energy landscape rather than down it, conserving the total energy. But the equation is still derived from an energy functional in the same way. This lets a single computational framework handle all four problems.

These models cover very different physical systems, from battery electrodes to ultracold atoms. Yet each provides two of the three ingredients needed for optimization: a description of how a physical state evolves, and a set of parameters or external controls that influence that evolution. The third ingredient, an objective that defines the desired outcome, is chosen by the researcher.

Normally, these equations are used in the forward direction: the physical parameters and initial state are specified, the PDE is solved, and the outcome is observed. The inverse direction involves adjusting parameters or controls to produce a desired outcome. This is the domain of PDE-constrained optimization and optimal control, a field with a long history of successful applications.

To adjust parameters efficiently, an optimizer needs gradients: how much the outcome changes when each parameter is nudged. Traditionally, these are computed by deriving a second set of equations, known as adjoint equations. These equations run backward through the simulation. The derivations are often lengthy and specific to each model. They must be redone whenever the model changes, such as with a new material, boundary condition, or objective.

This work instead applies automatic differentiation (AD) directly through the PDE simulation. Rather than writing out equations for how the outcome depends on the parameters, the computer tracks how each step of the calculation, including every time step of the PDE, contributes to the final result. The simulation is implemented in JAX, a framework built around this capability, that also provides GPU acceleration. AD has been used in computational physics before.The authors’ twist is pairing AD with a differentiable way to handle irregular shapes from experimental images, described below. They also apply it across a whole class of free-energy-driven models, not just one. The same code handles Cahn-Hilliard dynamics, Allen-Cahn dynamics, and the Gross-Pitaevskii equation. Swapping in a new free energy functional or boundary condition is straightforward. AD works out the new gradients on its own, with no new derivations.

The optimization loop is therefore:

This is the same principle used to train neural networks. Here, however, instead of adjusting the weights of a neural network, the optimizer adjusts the parameters of a physical simulation.

PDE solvers are often designed around simple domains such as rectangles or circles, where the boundary can be described mathematically and handled cleanly by the numerical method. Experimental data, by contrast, may come from microscopy or X-ray imaging and arrive as pixelated binary images. A real electrode particle looks nothing like a rectangle. It has a complicated, irregular boundary with fine features that vary from particle to particle. Traditionally, solving a PDE on such a shape means building a custom computational mesh that follows the boundary precisely. This is technically demanding and time-consuming, and it must be repeated for every new particle. Fitting such a mesh into a pipeline that has to pass gradients is harder still.

The authors avoid meshing altogether in two steps (Figure 1). First, they smooth the pixelated image by evolving it under a modified Allen-Cahn equation. This replaces the abrupt inside/outside boundary with a narrow diffuse region. In doing so, they remove pixelation artifacts while preserving the important features of the original shape. Second, they use the smoothed boundary method, a technique for solving equations on irregular shapes without a fitted mesh. It rewrites the governing PDE so it can be solved on a simple rectangular grid. The boundary conditions are then applied across the diffuse region rather than at a sharp edge. Both steps are differentiable, so gradients can pass through the entire pipeline:

Combined with AD, this end-to-end differentiability lets the authors work directly on structures taken from experiments. They can learn models and optimize controls without building a custom mesh for each one.


Working Backwards From What We See

The first test asks whether the framework can recover physics from observations. Before using differentiability to control a system, the researchers use it to learn one.

The researchers first simulate phase separation on shapes reconstructed from images of real graphite battery electrodes. They run both Cahn-Hilliard and Allen-Cahn dynamics, then add random noise to the results. At its strongest, the noise reaches 30% of the natural variation in the concentration field. The optimizer never sees the free energy or kinetic parameters behind the data. Instead, it starts from a deliberately wrong guess: a free energy that doesn’t phase-separate at all. From there, it keeps adjusting its parameters until its simulations match what was observed.

This is an inverse problem. Instead of predicting data from physics, the framework infers the physics from data. What makes it hard is the combination of nonlinear dynamics, complex geometry, and substantial noise. Yet the framework recovers the known free energy and kinetic functions even at the highest noise level. After about 10 optimization steps, the learned model is already close to the true one. By step 90, the two are nearly indistinguishable (Figure 2). The whole fit takes just minutes on a single GPU. The only gaps are at extreme concentrations that rarely appear in the data.

There is a caveat. These tests use synthetic data, generated from the same kind of model the optimizer is fitting. That makes for a clean, controlled benchmark. But real experimental noise is messier, and the true physics may not fit the assumed parametrization at all. If that parametrization is too restrictive, the model could fit the data well and still miss important physics. Real experiments bring both problems at once: imperfect models and systematic measurement errors. Handling them together remains an open challenge.

Still, experimental observations could do more than test an existing model. They could reveal the model itself, free energy landscape included, right on the irregular shapes where the physics happens.


The Hidden Lever at the Wall

The position and shape of phase boundaries matter in many technologies. In microfluidics and lab-on-a-chip devices, precise control over fluid interfaces is essential for routing droplets and mixing reagents. In battery electrodes, the morphology of phase boundaries influences how lithium is stored and released. Being able to steer an interface to a desired configuration without physically touching it is therefore a broadly useful capability.

But how do you steer an interface without touching it? One answer lies where the interface meets a solid wall. The angle at which the boundary between two phases meets that wall is called the wetting angle. It is set by a balance of surface energies, and it is not fixed. In electrowetting, for example, an applied voltage can shift it on demand. When the angle changes, so do the forces on the interface, and the interface moves.

The authors test this on a phase boundary inside a circular domain whose wall is split into two halves. Whatever wetting angle is imposed on one half, the mirror-image angle is imposed on the other. This bends the boundary into an S shape. Since a longer, curved boundary costs more interfacial energy, the boundary swings round to straighten itself out. In effect, the wetting angle becomes a steering wheel, one that could be turned with a voltage in an experiment. The question is how to turn it, moment by moment, to bring the boundary to a target orientation. A forward simulation can only tell you what a given protocol does; finding the right one means working backwards.

The authors approach this in two steps. In the first step, the optimizer is given a single requirement, that is, to reach the target orientation by the end of the simulation. This establishes that the optimizer can find a working protocol at all, and it does, converging in just 10 to 20 iterations (Figure 3). But this formulation says nothing about how quickly the interface gets there: any path that ends in the right place counts as success.

The second step changes the goal. The optimizer is now penalized for every moment the interface spends away from the target, so it is rewarded for getting there as fast as possible and then staying put. It responds by driving the wetting angle close to zero, an extreme setting that makes the boundary rotate faster. In both cases a penalty on abrupt changes keeps the protocol smooth. Changing a single line of the objective, from “end up here” to “get here quickly”, changes the strategy the optimizer discovers, without any new derivation.


How a Patterned Coating Tames Phase Separation

The first two demonstrations established that the framework can learn the physics of a system from data and steer it toward a desired state through time-varying control. But such control requires continuous intervention during operation. A more durable solution would be to design the material itself so that the undesired behavior never arises, engineering the problem away rather than controlling around it.

This is the challenge taken up in the third demonstration, and the material at the center of it is lithium iron phosphate (LFP), one of the most widely used cathode materials in lithium-ion batteries. LFP is chemically stable, safe, and cheap, but it has a persistent problem. During charging and discharging, it tends to separate into lithium-rich and lithium-poor regions. These phase-separated domains create uneven reaction rates across the particle, accelerate degradation, and make it harder to accurately estimate the battery’s state of charge.

LFP particles are routinely coated with carbon, which supplies the electrical conductivity the material lacks on its own. But not all coatings perform equally. Experiments have found that uneven, glucose-derived carbon coatings outperform uniform polydopamine ones when the battery is cycled quickly. Could the unevenness itself be helping? The coating sets how fast lithium enters at each point on the surface. So a patterned coating could, in principle, steer where lithium goes and stop phase separation before it starts. To find out, the authors let the optimizer design the coating pattern itself, working on real particle shapes reconstructed from X-ray images.

First, the optimizer is asked a basic feasibility question: does a spatially nonuniform coating exist that keeps the lithium concentration uniform throughout the particle during lithiation, while preserving the overall reaction rate? The answer is yes. The optimized particle fills almost evenly, in stark contrast to the pronounced phase separation produced by a uniform coating.

The difference shows up in the voltage, too (Figure 4). A phase-separating particle produces flat plateaus and sudden jumps. The optimized one gives a smooth curve, as if the material were a single, uniform solid solution. The pattern the optimizer finds is revealing. It slows the reaction in a band around the facets where the lithium-rich phase tends to nucleate first. Lithium is redirected instead toward the center of the particle’s main face. The authors read this as a way of disrupting nucleation before it can grow into full phase separation. It also offers a possible explanation for the coating experiments. Better conductivity between particles is one benefit; suppressing phase separation within each particle may be another.

Next comes a practical question: how finely would a coating need to be patterned? The optimizer is run with coating patterns of increasing spatial resolution, from coarse variations across the particle down to progressively finer features. Concentration uniformity improves as the resolution increases, but the improvement saturates at a characteristic length scale of about 200 nanometers. Patterning the coating more finely than this provides little additional benefit within the model. In other words, arbitrarily fine control is not needed; control at roughly the 200 nanometer scale is enough. As for how such a coating might be made, the authors suggest chemically prepatterning the side facets during synthesis so that the carbon coats them differently. This suggests a possible route from simulation to fabrication.


Guiding a Quantum State

The fourth and final demonstration takes the framework into quantum mechanics, where the target state is topologically very different from the initial one and the system is acutely sensitive to how it is driven. Getting a quantum condensate from one configuration to another is not just a matter of reaching the right endpoint; the path itself determines whether the system arrives intact or riddled with unwanted excitations.

A Bose-Einstein condensate (BEC) is a cloud of atoms cooled to near absolute zero, where they behave collectively as a single coherent quantum state. BECs are increasingly important for quantum sensing, interferometry, and simulation. Many of these applications require preparing the condensate in particular spatial configurations, such as split condensates for interferometry and toroidal condensates for studying persistent currents. Each corresponds to the ground state of a particular trapping potential, so preparing one reliably demands precise control over how that potential is shaped over time.

The problem is that you cannot simply switch the trap to its final configuration and expect the condensate to follow. Unlike the dissipative systems in the earlier demonstrations, which settle down after being disturbed, a condensate conserves energy. That is, once excited, it stays excited. If the trapping potential changes too quickly, the condensate is knocked out of its ground state and acquires unwanted excitations, like sloshing and breathing modes. This degrades the target state for practical applications. The safe alternative is adiabatic evolution, in which the trap is changed so slowly that the condensate remains in the instantaneous ground state throughout the transformation. But truly adiabatic transformations can take far longer than practical experiments allow. This has motivated the search for shortcuts to adiabaticity: faster protocols that reach the same final state without leaving excitations behind.

Finding such shortcuts has been an active area of quantum control research for years, and optimal control theory has been applied to BEC state preparation before. What this work adds is the same thing it adds to the classical demonstrations. The same code that learned battery free energies is reused here with a different energy functional.

The authors put this to the test with a particularly challenging target: transforming a simple single-well condensate into a combined split-and-toroidal configuration, the ground state of a trap with a face-like topology that is qualitatively different from the starting point. This is not a small perturbation; it is a fundamental reorganization of the condensate’s spatial structure. Finding a protocol that achieves it without exciting unwanted modes is far from obvious.

As a baseline, the authors first try the simplest possible protocol: a linear interpolation between the initial and final trapping potentials. The linear ramp produces substantial oscillations and high infidelity with respect to the target state, confirming that naively interpolating between the two configurations is insufficient. The problem is not the speed but the route: the straight-line path between the two traps happens to excite the condensate along the way.

Next, the optimizer is given control over the entire trajectory of the trapping potential, not just the start and end points. The trap is built from three adjustable wells and a bump, described by 20 parameters that can each vary over time. The optimizer is asked to bring the condensate to the target by the halfway point and then hold it there without oscillation. The result is a time-varying potential profile that achieves much lower infidelity than the linear ramp and produces a smooth, oscillation-free transition to the desired configuration (Figure 5).

The optimizer is never told what an effective shortcut looks like. It emerges from gradient-based optimization through the Gross-Pitaevskii dynamics. The simulations use a simplified two-dimensional model of the condensate, so turning the protocol into an experiment would take further work. But the output is a concrete, time-varying trap trajectory, which is the kind of input an experiment needs.


Differentiable Physics as a New Kind of Scientific Tool

Taken together, these four demonstrations make a case that goes beyond any individual result. The problems span soft matter, electrochemistry, and quantum physics. The physical equations are different, the geometries are different, and the design objectives are different. Yet the computational structure is the same in every case: a differentiable simulation connects parameters to outcomes, and gradient-based optimization finds the parameters that produce the desired outcome.

What AD brings to PDE-constrained optimization is not a new mathematical idea but a new level of generality. Adjoint-based methods have long enabled gradient computation for specific physical models. But applying them to a new model requires new derivations, and combining them with complex experimental geometries compounds the difficulty. AD computes the same gradients automatically, by working backwards through the simulation’s own steps. The same loop of simulating, differentiating and updating carries over unchanged across free energy models, boundary conditions, spatial heterogeneities, and quantum control problems. A researcher with a new physical model and a new design objective still has to decide what to optimize and how to parametrize it, but no longer has to derive new gradient equations before getting started.


The Hard Part Is Still Ahead

No modeling framework is without constraints, and it is worth being clear about where this one has room to grow.

The most fundamental limitation is model fidelity. The quality of any learned or optimized result depends on how well the chosen PDE and free energy functional represent the true physics. If the parametrization is too restrictive, that is, if the real free energy has features the model cannot represent, the optimizer will find the best solution within a limited class, which may not transfer to experiment. As noted earlier, the learning demonstration sidesteps this by generating its data from the same model class it fits, a controlled but idealized setting. The results are also single best-fit answers, without the uncertainty estimates that a probabilistic extension could provide.

Computational scale is a second constraint. Differentiating through long time integrations requires storing intermediate states of the forward trajectory, and memory usage grows with the number of time steps. The authors mitigate this with checkpointing strategies that reduce memory from O(T) to O(log T), at the cost of recomputing parts of the simulation, but very high resolution simulations or long time horizons will still push against practical limits. All the demonstrations here are two-dimensional; full three-dimensional problems will test these limits further.

A third, more technical constraint concerns the gradients themselves. AD returns the exact gradient of the simulation as written, including its particular time step and grid, which is not always the same as the gradient of the underlying physics. Stiff equations like Cahn-Hilliard need specialized integrators just to remain stable, and over long time horizons, small errors in the starting state can grow and make gradients noisy or unreliable. The authors found, for instance, that splitting long trajectories into shorter independent segments made learning from noisy data more robust. Choices like these remain problem-specific and require care.

Finally, none of the optimized designs has yet left the computer. The patterned LFP coating and the BEC protocol exist only as simulations, for now. The obvious next step is to close the loop. That means using the framework to guide fabrication, then feeding the measurements back to refine the model. It is also the most important step if differentiable physics is to become a practical tool for materials design.

The foundation laid here, end-to-end differentiable PDE solvers on experimentally derived geometries, makes that loop far easier to build, for a much wider range of problems, than before. Whether it becomes routine will depend on how well the framework scales to noisier data, more complex models, and the inevitable gap between simulation and physical reality.

Leave a Reply