Learning to Simulate Unseen Physical Systems with Graph Neural Networks
Abstract
Recently there is an increasing interest in learning to simulate the dynamics of physic systems via machine learning.
However, existing approaches fail to generalize to physical substances not in the training set, such as liquids with different viscosities or elastomers with different elasticities.
Here we present a machine learning method embedded with physical priors and material parameters, which we term as “Graph-based Physics Engine” (GPE), to efﬁciently model the physical dynamics of different substances in a wide variety of challenging scenarios.
We demonstrate that GPE can generalize to different material properties not seen in the training set by simply modifying the physical parameters, and also performs well from single-step predictions to multi-step roll-out simulations.
GPE provides new insights into the construction of learnable simulators and is a key step toward predicting unknown physics problems in the real world.
Introduction
Simulation of the dynamic of unknown physics systems is crucial in many scientiﬁc and engineering areas Belytschko et al. [1994], Sulsky et al. [1995], Jiang et al. [2016], Sifakis and Barbic [2012], Han et al.
[2017], Holl et al.
Building high precision physics simulators requires extensive domain knowledge and substantial engineering effort.
Also the approximation techniques used to ensure perceptual realism make the simulations deviate from the laws of reality in the long term.
Recently, several neural network based simulators were proposed to learn physical dynamics from large-scale training data Battaglia et al. [2016], Chang et al. [2016], Li et al. [2018], Mrowca et al.
Sanchez-Gonzalez et al.
[2018], Li et al. [2019], Ummenhofer et al. [2019], Sanchez-Gonzalez et al. Their success prove the feasibility of using machine learning to improve physics simulation.
One common drawback of the aforementioned methods is the lack of generalization for unseen physical processes and substances.
For example, if the training dataset consist dynamics of softer elastomers and harder elastomers, it is expected that the model can generalize to elastomers with other levels of elasticity.
However, most ML-based simulators fail to do so since they can only simulate the physic systems in the training dataset.
To this end, we introduce a new machine learning approach to model physical interaction dynamics with graphs, which we term “Graph-based Physics Engine” (GPE).
Our network represents discrete physical systems by a graph structure which models force interactions using a message passing neural network (MPNN) Gilmer et al.
The contribution of GPE is multifaceted.
First, the physical parameters such as elasticity of elastomers are introduced to enable the model to generalize across different systems.
Second, a uniﬁed model architecture is used to learn different types of physical dynamics, from viscous ﬂuid simulations to ﬁnite element mechanics (FEM) analysis.
Additionally, we introduce the law of momentum conservation in MPNN to increase stability of learning.
Various experiment results show that GPE has good long-term roll-out stability even if it is learned over single-step loss.
1.1 Related Work
Learning physical dynamics from data is one of the most important research areas in physics
Grzeszczuk et al.
A variety of neural network architectures, such as RNN Kadupitiya et al. [2020], CNN Ummenhofer et al. and GNN Sanchez-Gonzalez et al. [2018], Battaglia et al.
[2016], Li et al.
[2018, 2019], have been adopted to simulate dynamics of physical systems.
In particular, Ummenhofer et al. Ummenhofer et al.
[2019] developed a novel CNN based on smoothedparticle hydrodynamics (SPH) theory to simulate the motion of a Lagrangian ﬂuid.
Battaglia et al.
Battaglia et al.
and Sanchez-Gonzalez et al. Sanchez-Gonzalez et al.
[2020, 2018, 2019] demonstrated the effectiveness and generality to model the dynamics by message passing.
On the other hand, Mrowca et al.
Mrowca et al.
[2018] and Li et al. Li et al.
[2018, 2019] used hierarchical graph neural networks to simulate non-rigid deformation and collision deformation of structured physical systems such as elastomers.
However, all the aforementioned work can only simulate the systems seen in the training set, which inspires us to allow the learned model to simulate unseen materials.
Model Framework
Assume ( G 0 , G 1 , ..., G T ) is the evolutionary trajectory of a physical system over time, where the directed graph G t
= <
O t , R t > ∈ G represents the state of the system at time t .
Vertices O =
{ o i } represent the collection of discrete units of objects, and edges R = {
( o i , o j ) } represent the (directed) interaction relationship between the particles.
A learnable graph-based physics engine (GPE) s θ : G → G models physical dynamics by mapping the graph representation G t to the graph representation at the next time step G t +1 .
Similar to SanchezGonzalez et al.
[2020], we use message passing neural networks (MPNN) Gilmer et al.
[2017] to model the evolutionary dynamics of physical systems as follows.
[Equation]
For l = 1 , ..., L :
[Equation]
Decoder :
[Equation]
The encoders map the raw features of the nodes and the edges into hidden vectors.
The processors iteratively compute messages on the edges, aggregate messages on nodes and update node hidden vectors.
Finally, the decoder predicts the position of the nodes at the next step.
The model is trained by minimizing the mean-squared-error (MSE) between predicted positions and the ground truth.
2.1 Graph Representation of a Physical System
The topology of the graph depends on how the physical system is being discretized.
For unstructured systems such as liquids, snow or sand, a nearest neighbor graph is used to model the connectivity between particles, where two particles o i and o j are connected if their distance is within some threshold r .
The nearest neighbor topology reﬂects the fact that the strength of interaction between two particles vanishes as their distance increases.
For structured systems such as elastomers, we use a mesh to discretize the system.
In order to take consideration of the long-range interaction during the deformation of solids, we use a multi-scale grid graph topology similar to Mrowca et al. [2018], Li et al.
We merge four neighboring nodes into one "macro-mesh" described as a virtual node, which is connected to all the four lower-layer nodes and other virtual nodes.
The merging process continues until all the nodes are merged into one super node.
These virtual nodes and edges serve to describe the macro structure and build a high-speed path for force transmission.
Notice that the connectivity of nearest neighbor graph needs to be updated during every roll-out step whereas the multi-scale grid graph does not.
Input feature.
The input features on GPE nodes contain the material properties of each unit (such as the viscosity of water, the friction angle of sand, the hardening coefﬁcient of snow, the Young’s modulus of an elastomer), the velocity of the unit, and the external forces applied such as gravity.
Position information is not included in the input feature, which makes GPE naturally satisfy the translation and permutation invariance.
Momentum conservation.
Either the nearest neighbor graph or multi-scale grid graph contains bi-directional edges between connected nodes.
We only calculate the message m i,j on one of the edges, and introduce the law of momentum conservation by simply requiring the message on the opposite edge to be m j,i = − m i,j .
Experiments 3.1 Physical Domains and Datasets
We evaluate the performance of GPE in several different physical domains containing different types of materials and dynamics.
The S AND , S NOW and E LASTOMER domains generated by TaichiMPM engine Hu et al. [2020, 2019] contain dynamics of sand, snow and elstomers with different physical parameters hitting a wall then deforming.
The V ISCOUS FLUID domain generated by FLIPViscosity3D engine Batty et al. [2007], Batty and Bridson [2008] contains dynamics of ﬂuids with different levels of viscousity.
The F INITE E LEMENT M ECHANICAL (FEM) domain contains dynamics of elastomers with different Young’s modulus hitting an uneven obstacle.
The domains represent a wide variety of physical systems but can be simulated by a uniﬁed model.
The details of data generation processes, model architectures and hyperparameters are relegated to Appendix A.
3.2 Results
In Figure 2, we visualize the S AND and FEM dynamics predicted by GPE.
We observe that the roll-out trajectories predicted by GPE are very similar to ground truths, even if the models are trained only by single-step error.
Moreover, it can be seen that GPE can simulate physical systems with unseen parameters.
Visualizations of other domains are relegated to Appendix B.
To quantify the performance of the simulation on unseen materials, we compare GPE with three baselines, DPI-Net with hierarchy Li et al. [2018], GNS Sanchez-Gonzalez et al. [2020] and ConvNet Ummenhofer et al.
We calculate the average MSE of each time step in roll-out for the aforementioned domains on unseen physical parameters.
For GPE and DPI-Net, nearest neighbor graph are used for the S AND , S NOW and V ISCOUS F LUID , while multi-scale grid graphs are used for the E LATOMER and FEM.
For GNS and ConvNet, the graph topology are consistent with original Methods [Table] DPI
[Table] NetLi et al. [Table] [Table]
Gonzalez
[Table]
papers.
As shown in Table 1, GPE outperforms the baseline methods in most domains, demonstrating its better ability to generalize to unseen systems.
Finally, we demonstrate the effect of momentum conservation on V ISCOUS F LUID domain.
By introducing momentum conservation, only half of the messages on the edges are computed, leading to a 37% reduction of forward computation time.
As shown in Figure 3, GPE with momentum conservation is more stable at the beginning of training, converges faster, and performs better on the test set, compared to GPE without such a constraint.
Conclusion
In this paper we proposed GPE, a graph-based learnable physical engine that simulates the dynamics of complex systems by learning the message passing between nodes.
Our experiments show that GPE can simulate complex evolutionary trajectories in a variety of domains and has good generalization ability to unseen materials.
We also introduce momentum conservation in the model to reduce computational cost and stabilize the training process.
Thanks to the universality, expressiveness and generalization of modeling, graph-based learnable physics engines show great potential for applications in high precision simulation of complex systems and inverse problem solving.
Our study helps shed light on using machine learning for physical reasoning
A Implementation Details
Here we illustrate the details of the implementation of GPE which are omitted in Section 3.1.
Data generation.
The S AND , S NOW and E LASTOMER dataset are generated by Taichi-MPM engine Hu et al.
The V ISCOUS F LUID dataset are generated by FLIPViscosity3D engine Batty et al.
[2007], Batty and Bridson [2008]. We independently sample 2000 trajectories with 10 different physical parameters as training set, 300 trajectories as test set and 300 trajectories as validation set with physical parameters that did not appear in the training set, where each trajectories contain 1000 frames.
Most systems contain approximately 2500 particles, while the viscous liquid system contain about 5000 particles.
The FEM dataset is obtained from standard simulation formulas.
We independently sample 2000 trajectories as training set, 300 trajectories as test set andtrajectories as validation set, where each trajectories contain 800 frames and the system approximately 1000 meshes.
We train the model on FEM data with Young’s modulus from 1 MPa to 4 MPa, and test the model on data with Young’s modulus from 0.5 MPa to 10 MPa.
Implementation Details.
The encoders Enc v
and Enc e are MLPs with 2 layers and 128 neurons per layer.
The processors Proc v
and Proc e are MLPS with 2 layers and 128 neurons per layer.
In Processor, the number of steps for message passing is 12.
The decoder Dec v is an MLP with 2 layers and 128 neurons per layer.
All activation functions are PReLU.
For S AND and S NOW domains, the cutoff radius for nearest neighbor graph is 0.4.
The model is trained 1000 epochs, using the Adam optimizer and decaying the learning rate from 5 × 10 − 5 to 1 × 10 − 6 .
We compare the performance of GPE with baselines GNS Sanchez-Gonzalez et al. [2020], DPI-Net Li et al. [2018], and ConvNet Ummenhofer et al.
Boundary nodes.
In GPE, the boundaries and obstacles are modeled as a special type of nodes, which allow the learned model to generalize to scenarios with more complex boundaries.
B Visualization Results
In Figure 4, the enlarged image of the mechanical ﬁnite element analysis shows the distribution of stresses in deformation in more detail.
In Figure 5, we present the visualization results of S NOW , E LASTOMER and V ISCOUS FLUID predicted by GPE