Differentiable Molecular Simulations for Control and Learning

Wujie Wang, Simon Axelrod, Rafael Gómez‐Bombarelli

Abstract

Traditional molecular dynamics simulations solve the "forward" problem: given a Hamiltonian, what is the resulting behavior? This paper introduces a framework for differentiable molecular simulations that addresses the "inverse" problem—learning energy functions from experimental data and controlling systems to reach target states. By treating the entire simulation as a differentiable layer, the authors enable end-to-end optimization of macroscopic observables.

Introduction

In molecular science, researchers often seek to determine the underlying energy functions that produce observed experimental arrangements or to identify the external forces required to steer a system toward a specific configuration, such as a folded protein. These inverse problems are typically solved through trial-and-error or computationally expensive black-box optimization. The core challenge lies in the complexity of integrating differential equations over vast time scales, which obscures the relationship between initial parameters and final outcomes.

Differentiable Simulation Framework

The proposed framework makes physical simulations fully differentiable, allowing for the calculation of analytical gradients of macroscopic observables with respect to the Hamiltonian.

Differentiable simulation pipeline integrating Graph Neural Networks (GNNs) and ODE solvers to minimize loss against target observables.

Key technical components include:

  • Adjoint Sensitivity Method: This memory-efficient technique backpropagates gradients through time by solving a secondary "adjoint" differential equation backward, avoiding the need to store every intermediate simulation step.
  • Graph Neural Networks (GNNs): The SchNet architecture is employed to represent the Hamiltonian, ensuring that the learned energy functions respect physical symmetries like rotation and translation.
  • Differentiable Thermostats and Histograms: The authors implemented differentiable versions of standard tools, such as Nose-Hoover chains for temperature control and Gaussian-smeared histograms for structural analysis, ensuring a smooth gradient flow throughout the pipeline.

Benchmarks and Applications

The method was evaluated across four diverse physical systems:

  1. Toy 2D System: A particle in a double-well potential used for initial validation.
  2. 3D Polymer Folding: Steering a linear chain into a helical structure.
  3. Liquid Water: Training a GNN-based force field to reproduce experimental X-ray diffraction data at 298K.
  4. Quantum Retinal Model: Optimizing light-driven isomerization in the retinal chromophore.

Results and Discussion

A significant advantage of this approach is that it eliminates the need for predefined "reaction coordinates." The simulation automatically discovers optimal pathways by simply minimizing the distance to the target state.

Evolution of the Potential Energy Surface (PES) and learned bias potential over 100 epochs, showing the trajectory steering from start to target.

In the polymer folding task, the system successfully learned a bias potential to achieve a specific helix over 40,000 simulation steps. For liquid water, the GNN matched the experimental pair correlation function ($g(r)$), effectively learning the physics of the liquid from its structural thumbprint. Furthermore, in the quantum retinal task, the framework optimized electric field pulses to increase quantum yield from 0.6 to 0.8 within 50 epochs.

Limitations and Future Directions

Despite its success, the method faces challenges related to time scales and chaotic dynamics. Differentiating through extremely long trajectories remains computationally intensive, and the "butterfly effect" in physical systems can lead to noisy or exploding gradients. Future work will explore extending the framework to more complex thermodynamic conditions, such as constant pressure, and applying it to the design of self-assembling smart materials.

Summary updated

Abstract

Molecular dynamics simulations use statistical mechanics at the atomistic scale to enable both the elucidation of fundamental mechanisms and the engineering of matter for desired tasks. The behavior of molecular systems at the microscale is typically simulated with differential equations parameterized by a Hamiltonian, or energy function. The Hamiltonian describes the state of the system and its interactions with the environment. In order to derive predictive microscopic models, one wishes to infer a molecular Hamiltonian that agrees with observed macroscopic quantities. From the perspective of engineering, one wishes to control the Hamiltonian to achieve desired simulation outcomes and structures, as in self-assembly and optical control, to then realize systems with the desired Hamiltonian in the lab. In both cases, the goal is to modify the Hamiltonian such that emergent properties of the simulated system match a given target. We demonstrate how this can be achieved using differentiable simulations where bulk target observables and simulation outcomes can be analytically differentiated with respect to Hamiltonians, opening up new routes for parameterizing Hamiltonians to infer macroscopic models and develop control protocols.
BibTeX
@inproceedings{wang2020differentiable,
  author = {Wujie Wang and Simon Axelrod and Rafael Gómez‐Bombarelli},
  title = {{Differentiable Molecular Simulations for Control and Learning}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
}
Figure