Learning Large-Time-Step Molecular Dynamics with Graph Neural Networks
Abstract
Molecular dynamics (MD) simulation predicts the trajectory of atoms by solving
Newton’s equation of motion with a numeric integrator.
Due to physical constraints, the time step of the integrator need to be small to maintain sufﬁcient precision.
This limits the efﬁciency of simulation.
To this end, we introduce a graph neural network (GNN) based model, MDNet, to predict the evolution of coordinates and momentum with large time steps.
In addition, MDNet can easily scale to a larger system, due to its linear complexity with respect to the system size.
We demonstrate the performance of MDNet on a 4000-atom system with large time steps, and show that MDNet can predict good equilibrium and transport properties, well aligned with standard MD simulations.
Introduction
Molecular dynamics (MD) is a simulation technique for analyzing the movement of many-body systems by solving Newton’s equation of motion.
The resulting trajectories provide a view of dynamic evolution of atoms and molecules, and can be used to analyze the equilibrium and transport properties of the system [1].
MD plays a key role in many scientiﬁc ﬁelds, including materials science [2, 3], biochemistry [4], drug discovery [5], etc.
The core of an MD algorithm is to solve Newton’s equation of motion at discrete time steps.
One of the most frequently used algorithm is the ordinary Verlet integrator [6], which predicts the coordinate of atom i at time t , q i ( t ) , after time step ∆ t by:
[Equation]
where the potential energy U of the system is a function of the coordinates q .
The time step ∆ t must be set small enough to avoid the contribution of O (∆ t 4 ) .
In practice, ∆ t is usually chosen at femtosecond scale (1 fs = 10 − 15 s).
Recently, efforts have been made to solve the classical mechanics of many-body systems via machine learning methods [7–12].
However, all these methods are limited to small systems containing only dozens of atoms, whereas practical MD simulations usually involve thousands to millions of atoms.
Therefore, a scalable machine learning approach with linear complexity is highly desired.
In this paper, we propose MDNet, a scalable graph neural network (GNN) model to predict the dynamics of many-body systems.
The key contribution is to predict the movement of an atom based on its local environment encoded by a series of descriptors similar as DeePMD [13, 14].
In addition, we introduce momenta in the local environment descriptor and make the model comply with the law of conservation of momenta.
We show that MDNet can simulate a system containing thousands of atoms with a time step 128 times larger than that of the Verlet integrator.
The resulting equilibrium and transport properties are shown to be consistent with the simulations using the Verlet integrator.
1.1 Related Work
The trajectories of MD simulations can be viewed as sequence data hence could be learned by sequence models, such as recurrent neural networks (RNNs).
Tsai et al. showed that one-dimensional stochastic trajectories generated from higher-dimensional dynamics can be learned by long shortterm memory network (LSTM).
Kadupitiya et al.
demonstrated that LSTM was able to predict MD trajectory for systems containing 16 atoms.
Another type of models including HNN [10], SRNN [11],
GFNN [12] and others [15–19], manged to incorporate physical knowledge and solve mechanical problems by learning Hamiltonian or other physical quantities.
However, all the aforementioned models used the information of all atoms to predict the dynamics, which limits their scalability.
In traditional MD simulations, a common assumption is that atoms only interact with their neighbors.
Motivated by this assumption, Satorras et al.
proposed E(n) equivariant graph neural networks (EGNNs), which model the system by a graph and achieve linear complexity [20].
Compared to EGNN, MDNet use more sophisticated descriptors of local environments and achieve better performance.
Background
We brieﬂy introduce some basic notations in Hamiltonian mechanics that MDNet is built upon.
The
Hamiltonian for an N-particle system in d dimensions can be written as:
[Equation]
where p , q are the momenta and coordinates of the atoms.
The momentum is deﬁned as p i
= m i
v i , where m i and v are the mass and velocity of atom i , respectively.
T ( p ) =
(cid:80) Ni =1 p
i 2 m i is the kinetic energy of the system and U ( q ) is the potential energy induced by interaction between atoms.
The motion of atoms is determined by Hamilton’s equation:
[Equation]
which is a generalization of Newton’s equation of motion.
The equation is then solved at discrete time steps via numeric integrators, where the velocity Verlet (appendix A) [21] is the most widely used one.
Model Architecture
In Hamilton’s equation (3), the variation of q only depends on p and vice versa.
However, with a larger time step, atoms interact with each other, thus, ∆ q depends not only on p , but also q (and so is ∆ p ).
In MDNet, we model ∆ q and ∆ p via neural networks:
[Equation]
and the integration algorithm becomes:
[Equation]
In MDNet, the system is represented by a graph where each atom is represented by a node.
Two nodes are connected by an edge if the distance between them is less than a cut-off distance, r c .
For an edge between node i and j , its edge feature and message is calculated as:
[Equation]
where r ij = ||
q i − q j || 2 is the Euclidean distance between node i and j , e ij ∈ R m 1 and m
ij ∈
R m 2 .
In three-dimensional space, m 1 = 7.
The features 1 r i,j and q i − q j r 2 ij are motivated from DeePMD [13, 14] and p i − p
j brings the information of momenta.
Relative coordinates and momenta are used to preserve translation invariance.
The edge operator φ e is an MLP.
Then, edge features and messages are gathered to nodes.
For node i with neighbors { j k } nk =0 , the local embedding L i is computed as
E
[Equation]
Here permutation invariance is preserved by the multiplication between E i and M i .
Finally, the variation of coordinates and momenta are predicted by aggregating the contribution of each edge,
[Equation]
To ensure the conservation of momentum, for any edge, we randomly choose one direction, e.g. i -> j, compute ∆ p ij and let ∆ p ji = − ∆ p ji .
This treatment is also applied to the calculation of ∆ q ij ’s.
Experiments
We test the performance of MDNet on a liquid argon system containing 4000 atoms.
The interatomic interaction is modeled by Lennard-Jones potential [22]:
[Equation]
where r is the distance between two atoms, (cid:15) and σ are set to 0.2374 kcal/mol and 3.432 Å respectively.
Although there is only one kind of interaction in the system, the dynamics could be rather complicated, with increasing space and time scale.
Dataset: To create the dataset, we run classical MD simulations with LAMMPS using Verlet integrator with a time step of 1 fs.
We independently sample 20 trajectories from different initialized conﬁgurations, where 15 are used for training, 3 are used for testing and 2 are used for validation.
For each trajectory, we randomly initialize 4000 atoms in a simulation box with periodic boundary condition in all directions.
The system is ﬁrst relaxed under 80 K and 1 bar in the NPT ensemble with
Nosé-Hoover (NH) thermostat [23] and barostat for 20000 steps.
Then, the system is further relaxed under 80 K in the NVT ensemble with NH thermostat for 20000 steps.
Finally, a NVE simulation is performed for 2560 steps and only the trajectory of this ﬁnal stage is used.
In each trajectory, we sample 10 frames { q ( t i ) , p ( t i ) } 10 i =1 of the system and use { q ( t i + ∆ t ) , p ( t i + ∆ t ) } 10 i =1 as targets.
According to the time reversibility of MD, the reversed data are also added to the dataset.
Besides, an extra 40960-steps MD simulation in the NVT ensemble is performed to validate roll-out performance.
Implementation details:
The cutoff radius r c for constructing the nearest neighbor graph is 7. Å. The MLPs φ e and φ o both have 4 layers and use ReLU [24] as activation function.
φ e hasneurons in each hidden layer and φ o has 200 neurons in each hidden layer.
Training is carried out for 1000 epoch, batch size 1 with Adam optimizer [25].
Learning rate starts from 5 × 10 − 3 and decays exponentially at a rate of 0.8.
The loss function is the mean squared error (MSE) of coordinates and momenta, normalized by their standard deviations respectively.
We compare MDNet to EGNN [20] composed of 4 EGCL layers with 64 neurons per layer and Swish activation function [26].
Hyperparameters of EGNN are consist with the original paper.
One-step results: We present the one-step root mean squared errors (RMSE) obtained by the Verlet integrator, EGNN and MDNet on validation set in Table 1.
It is shown that MDNet reports comparable
RMSE with Verlet with a small time step (16 fs), and signiﬁcantly outperforms Verlet with a large time step.
As the time step increases, the RMSE of Verlet increases faster than MDNet, due to the contribution of the fourth order error.
The performance of EGNN is poor with all the time steps.
∆ t [ [Table] Roll-out performance: MD simulations can be performed by adopting one-step prediction iteratively, which is known as roll-out.
We use two metrics to evaluate the roll-out performance of MDNet: radial distribution function (RDF) [27] and mean-squared displacement (MSD) [28, 29].
where RDFs provide good descriptions of equilibrium structure and MSD is a measure of transport properties of simulation systems.
To compute RDFs, we conduct 40000 fs simulation and take 8 frames from the subsequent trajectory with a gap of 128 fs.
The ﬁnal RDFs are averaged over these 8 frames.
As shown in Figure 2 (left), RDFs obtained from MDNet with different time steps coincide with ground truth, which show correct equilibrium structures.
To compute MSD, the trajectory is saved with a resolution of 256 fs and calculate displacement against the ﬁrst frame.
As shown in Figure(right), MSDs obtained from MDNet are linear with time and are in good agreement with ground truth, despite that the slopes with large time steps are slightly smaller.
In summary, MDNet can reproduce the equilibrium structures and transport properties of the simulation system with large time steps.
We also compare the time cost of roll-out and show that MDNet enjoys faster roll-out speed compared to Verlet, thanks to the large time step.
The comparison of time cost is in the appendix B.
Conclusion and Discussion
We introduce MDNet, a GNN model that can predict the dynamics of many body system with large time steps.
We demonstrate that MDNet exhibites good precision on one-step prediction with a large time step, and is able to generate MD trajectories.
The generated trajectories are characterized by
RDF and MSD, which showed good agreement with the ground truth.
It is worth mentioning that
MDNet only takes local environments as feature, so it could be generalized to larger systems with the same species of atoms without further training and we plan to investigate this in our future work.
There are several future directions.
Firstly, the total energy is not guaranteed to be conserved during roll-out of MDNet.
Incorporating thermostat into MDNet is necessary to control the temperature and total energy.
Secondly, The Lennard-Jones system presented in this paper is the simplest case in MD applications.
With the introduction of chemical bonds, the system will exhibit multiple characteristic times and the dynamics will be much more difﬁcult to predict.
The extension of MDNet to complicated systems is worthy of further study.
A The Velocity Verlet Algorithm
The algorithm of the most commonly used integrator, velocity Verlet, is:
[Equation]
In practice, p i ( t + ∆ t ) may not need to be calculated explicitly.
Then, the coordinates and momenta are updated alternately, which is also known as leapfrog integration.
B Comparison of Time Cost
We demonstrate the time cost of roll-out of MDNet and Verlet algorithm here.
[Table]