Particles are nodes. Interactions are edges. A GNN predicts each particle's next-step acceleration. Roll it out 1000 steps and you get fluid dynamics, rigid bodies, and granular materials — no hand-crafted physics equations required.
Simulating physics is hard. Traditional particle simulators like SPH (Smoothed Particle Hydrodynamics) or FEM (Finite Element Method) run slowly because they solve differential equations at each time step. Millions of particles, thousands of time steps, hours of CPU time — and if you change the material from water to sand, you rewrite the whole solver.
What if the simulator learned from data instead? You have a high-fidelity reference simulator: expensive, slow, but accurate. Run it on thousands of scenarios. Record the particle positions at each time step. Train a neural network to predict the next state from the current one. At test time, run the neural network instead of the solver. It's 100,000x faster.
The paper presents a single, unified framework called Graph Network-based Simulator (GNS) that works across multiple physics domains:
The same architecture, same hyperparameters, same training procedure — different training data, different behavior. The GNN learns the physics from trajectories; no equations are hard-coded.
Traditional simulators are accurate but slow. Neural simulators are fast but approximate. Click particles to add them and watch the simplified physics — this is what GNS replaces the expensive solver with.
The first design decision: how to turn a physical system into a graph. The answer is beautifully simple. Each particle is a node. Two particles become connected by an edge if their Euclidean distance is below a threshold r — the interaction radius. This creates a connectivity radius graph, similar to a k-nearest-neighbors graph.
The interaction radius r is a hyperparameter. Too small: neighbors miss important interactions. Too large: every particle connects to every other, removing sparsity and defeating the purpose of a GNN. In practice, r is set based on the physics: for water, the interaction length is roughly 2× the average particle spacing.
[v(t), v(t-1), ..., v(t-C+1), particle_type] — shape [d·C + n_types].[x_i - x_j, ||x_i - x_j||]. This encodes the geometry of the interaction — how far apart and in which direction. The GNN uses this to compute interaction forces that depend on geometry, as Newton's laws require.Physical systems have walls, floors, and containers. These aren't particles, but they exert forces. GNS handles this with a trick: add the distance to each boundary as an extra dimension of the node feature vector. If the box has 4 walls, add 4 distances: [d_left, d_right, d_top, d_bottom]. The GNN learns from data how much walls affect particle motion — no hard-coded reflection equations.
Particles with edges drawn when distance < radius r. Drag the radius slider to see connectivity change. The GNN operates on this graph at every time step.
GNS uses a three-part GNN architecture: an encoder that embeds raw node and edge features into latent vectors, a processor (M message-passing layers) that propagates interactions through the graph, and a decoder that reads out each node's acceleration from its final latent vector.
A simplified GNS-style simulation. Particles interact via repulsion and gravity. Adjust message-passing depth and interaction radius. Add particles and watch the system evolve.
python class GNS(nn.Module): def __init__(self, input_dim, hidden=128, M=10): # Encoder: raw features → latent self.node_enc = MLP(input_dim, hidden) # [d*C + types] → 128 self.edge_enc = MLP(3, hidden) # [rel_disp(2) + dist(1)] → 128 # Processor: M rounds of message passing self.processors = nn.ModuleList([ InteractionLayer(hidden) for _ in range(M) ]) # Decoder: latent → acceleration self.decoder = MLP(hidden, 2) # → (ax, ay) def forward(self, pos, vel_hist, particle_type, edges): # Build features node_feat = torch.cat([vel_hist, particle_type], dim=-1) i, j = edges rel_disp = pos[j] - pos[i] dist = rel_disp.norm(dim=-1, keepdim=True) edge_feat = torch.cat([rel_disp, dist], dim=-1) # Encode h = self.node_enc(node_feat) # [N, 128] e = self.edge_enc(edge_feat) # [E, 128] # Process (M rounds, with residuals) for layer in self.processors: h, e = layer(h, e, edges) # Decode acceleration acc = self.decoder(h) # [N, 2] — predicted (ax, ay) return acc
Training GNS to predict one-step acceleration is straightforward: minimize the L2 loss between the predicted and ground-truth acceleration at each time step. But the real challenge is rollout — autoregressive generation of long trajectories where each step's output becomes the next step's input.
GNS addresses exposure bias with noise injection during training. Before computing each training example, add small random Gaussian noise to the particle positions. This mimics the corrupted inputs the model will see during rollout. The model learns to be robust to small positional errors because it saw them during training.
The noise level σ is a crucial hyperparameter. Too small: model is still brittle at rollout. Too large: training is destabilized. The paper uses σ chosen to match the typical one-step positional error of a preliminary trained model — a principled data-driven calibration.
Why train to predict acceleration rather than position directly? Because acceleration is bounded and smooth. Positions can drift arbitrarily. If you train to predict the next position and the current position has a small error, the model must output a large correction — amplifying instability. Acceleration prediction gives the physics integrator more natural control over trajectory correction.
Compare rollout stability with and without noise injection at training time. Adjust noise level and see how long the simulation stays physically plausible.
The most striking claim of the GNS paper: a model trained on 1000-particle simulations generalizes to 5000-particle simulations. This is remarkable because the graph structure changes completely — different number of nodes, different connectivity, different dynamics. How?
This is why the GNN architecture is not just a design choice but a philosophical commitment. A fully connected network takes the entire state as input and cannot generalize to different system sizes. An LSTM processes a fixed-length sequence and has the same problem. The GNN processes each node's local neighborhood independently — and that operation scales to any number of nodes.
GNS also generalizes across materials using the particle type feature. Each particle's feature vector includes a one-hot encoding of its material type (water, sand, goop, rigid). When a new simulation mixes materials, the GNN learns interactions between different type codes. The MultiMaterial scenario — water + sand + rigid blocks — is trained jointly and the GNN learns all pairwise interaction types from data.
Training containers are rectangular boxes. At test time, the model encounters L-shaped containers, ramps, and bowls (in the ramp scenarios). Since boundary information is encoded as distances to boundary planes (not as explicit geometry), the model generalizes to different container shapes as long as the local boundary distance is still meaningful.
| What Generalizes | How | Limit |
|---|---|---|
| Particle count | Local processing — node operation independent of N | Very high particle counts may need sampling |
| Material mix | Material type as a feature | Unseen material type combinations |
| Container shape | Boundary as distance feature | Very complex geometry not in training set |
| Initial conditions | Learned dynamics, not memorized trajectories | Extrapolation far from training distribution |
GNS was evaluated on 5 physics domains with rollout lengths of 300-1000 steps. Metrics: mean squared error on particle positions (MSE) and qualitative visual fidelity assessed by human raters.
| Domain | Particles | Rollout Steps | Position MSE (×10-4) | Qualitative |
|---|---|---|---|---|
| WaterRamps | ~1000 | 600 | 0.8 | Physically plausible splashing |
| SandRamps | ~1000 | 400 | 1.2 | Correct pile formation angles |
| Goop | ~800 | 500 | 0.6 | Sticky deformation preserved |
| MultiMaterial | ~1500 | 300 | 1.9 | Inter-material interactions correct |
| FluidShake | ~600 | 1000 | 0.5 | Sloshing oscillations preserved |
Ablation studies confirmed three key design choices:
Traditional physics simulators are built on first principles. They solve the Navier-Stokes equations for fluids, the Mohr-Coulomb yield criterion for sand, constitutive relations for elastic and plastic solids. Every material requires new equations, new numerical methods, new implementations. Each simulator is a specialized tool.
Several failure modes of GNS are worth knowing:
| Property | Traditional (SPH/FEM) | GNS |
|---|---|---|
| Speed | Slow (minutes/trajectory) | Fast (seconds/trajectory) |
| Generalization to new material | New code required | New training data required |
| Conservation laws | Enforced by construction | Approximate (may drift) |
| Interpretability | Full (known equations) | Black box |
| Extrapolation | Reliable (solves equations) | Risky (may fail out-of-distribution) |
| Multi-material | Hard (different solvers) | Easy (particle type feature) |
GNS is part of a broader movement: neural simulation, or replacing expensive physics solvers with learned surrogates. Understanding its lineage and successors maps the field.
| Method | Key Idea | vs GNS |
|---|---|---|
| Interaction Networks (Battaglia 2016) | GNN for physics (precursor) | GNS scales and adds noise augmentation |
| GNS (this paper) | Particle GNN + noise + rollout | — |
| MeshGraphNets (Pfaff 2021) | GNS on meshes (FEM graphs) | Non-uniform mesh, same GNN backbone |
| DPI-Nets (Li 2019) | Differentiable physics GNN | GNS trains on data; DPI-Nets has analytic gradients |
| NeuralODE-based methods | Learn continuous dynamics | GNS uses discrete time steps; NeuralODE is continuous |
| Physics-informed NNs (PINNs) | Embed PDEs as loss terms | GNS is purely data-driven; PINNs use equation knowledge |
Sanchez-Gonzalez et al. "Learning to Simulate Complex Physics with Graph Networks." ICML 2020. arXiv:2002.09405
"Physics is local. A particle obeys laws set by its neighbors — not the global configuration. The GNN knows this."