Source-linked AI summary
DeePMD-kit: A deep learning package for many-body potential energy representation and molecular dynamics
Han Wang, Linfeng Zhang, Jiequn Han, Weinan E
TL;DR
Molecular simulation faces a trade-off between accurate but costly ab initio methods and more efficient approaches. The paper presents DeePMD-kit, which connects DeePMD models with TensorFlow, LAMMPS, and i-PI for training and molecular dynamics. A liquid-water example shows accurate reproduction of structural information from the original model.
Problem
Molecular simulation requires addressing the accuracy-versus-efficiency dilemma in modeling potential energy surfaces, while interfaces between deep-learning models and molecular-dynamics tools remain valuable.
Method
DeePMD-kit implements DeePMD with TensorFlow integration and interfaces for LAMMPS and i-PI, supporting model training and classical or path-integral molecular dynamics.
Results
The package is illustrated on bulk liquid water, where the trained molecular-dynamics model accurately reproduces structural information from the original model.
Takeaways & Limitations
DeePMD-kit enables trained potential-energy and force-field models to be used for efficient molecular simulations across different purposes.
Abstract
from arXiv · showhide
Recent developments in many-body potential energy representation via deep learning have brought new hopes to addressing the accuracy-versus-efficiency dilemma in molecular simulations. Here we describe DeePMD-kit, a package written in Python/C++ that has been designed to minimize the effort required to build deep learning based representation of potential energy and force field and to perform molecular dynamics. Potential applications of DeePMD-kit span from finite molecules to extended systems and from metallic systems to chemically bonded systems. DeePMD-kit is interfaced with TensorFlow, one of the most popular deep learning frameworks, making the training process highly automatic and efficient. On the other end, DeePMD-kit is interfaced with high-performance classical molecular dynamics and quantum (path-integral) molecular dynamics packages, i.e., LAMMPS and the i-PI, respectively. Thus, upon training, the potential energy and force field models can be used to perform efficient molecular simulations for different purposes. As an example of the many potential applications of the package, we use DeePMD-kit to learn the interatomic potential energy and forces of a water model using data obtained from density functional theory. We demonstrate that the resulted molecular dynamics model reproduces accurately the structural information contained in the original model.
I. INTRODUCTION
DeePMD-kit addresses the accuracy-versus-efficiency dilemma in molecular simulation by providing an open-source interface between deep neural-network models and molecular-dynamics tools. It combines TensorFlow-based training with LAMMPS and i-PI simulation interfaces, and is demonstrated on liquid water.
- Motivation: The package targets the accuracy-versus-efficiency dilemma between ab initio molecular dynamics and empirical force fields.DFT-based simulations are accurate but computationally costly, whereas empirical force fields enable larger and longer simulations but may have questionable accuracy and transferability.
- Motivation: DeePMD and deep potential models have been reported to achieve DFT-comparable accuracy with efficiency competitive with empirical-potential molecular dynamics.These capabilities motivate machine-learning approaches for molecular systems.
- Contribution: DeePMD-kit implements the DeePMD method as a package for building deep-learning representations of potential energy and force fields.The implementation is written in Python/C++ and is intended to reduce the effort of training and using these models.
- Implementation: TensorFlow integration supplies optimized tensor operations for model training and simulations, while LAMMPS and i-PI provide classical and path-integral molecular-dynamics interfaces.LAMMPS support uses a pair style, and i-PI support uses a socket-based force client.
- Implementation: The package implements atomic-environment descriptors and force/virial chain-rule computations in C++ and exposes them as TensorFlow operators.The paper also describes constructing system energy and differentiating it with respect to atomic positions and the box tensor.
- Demonstration: A bulk liquid-water example trains a DeePMD model from AIMD data and compares its molecular-dynamics results with the original AIMD data.The example is used to demonstrate the package’s modeling performance and validate the resulting model.
II. THEORY
DeePMD represents system energy as a sum of local atomic contributions predicted from symmetry-preserving descriptors and uses a deep neural network to derive forces and virials.
- Energy representation: The system energy is decomposed into atomic energy contributions, with each contribution determined by an atom’s position and nearby neighbors.Neighbors are restricted to a cutoff radius Rc.
- Symmetry-preserving descriptors: Neighbor positions are transformed into descriptors that preserve translational, rotational, and permutational symmetries.Local frames preserve rotational symmetry, while sorting neighbors by species and inverse distance preserves permutation symmetry.
- Neural-network mapping: A feedforward DNN maps each atomic descriptor through fully connected hidden layers to the corresponding atomic energy.The activation function used here is the component-wise hyperbolic tangent.
- Forces and virial: Forces are computed as the negative gradient of system energy with respect to atomic positions, and the virial is derived from the same energy model.The force and virial formulas are given in Eqs. (16)–(17).
- Training: Training optimizes DNN parameters with a loss combining RMS errors in energy, force, and virial predictions.The corresponding prefactors can change during optimization, and the learning rate decays exponentially.
III. SOFTWARE
DeePMD-kit combines descriptor, force, and virial computation with TensorFlow-based training and interfaces for classical and path-integral molecular dynamics.
- Software architecture: The software includes a C++ library for descriptors, forces, and virials, with interfaces to TensorFlow and third-party molecular-dynamics packages.The package also provides Python-based training and testing programs through TensorFlow’s API.
- Simulation workflow: DeePMD-kit supports LAMMPS and i-PI for classical and path-integral molecular-dynamics simulations.Its typical workflow is preparing data, training, testing, and running simulations with the trained model.
A. Data preparation
Data preparation converts labeled molecular configurations into a consistent RAW-file protocol, then feeds the data through training and testing to molecular-dynamics support.
- Input data: Training and testing data consist of multiple systems and frames labeled with atomic coordinates, energy, forces, virial, box information, and atom types.Energy, force, or virial labels may be absent, with the corresponding loss prefactor set to zero.
- Workflow: The prepared energy, force, virial, box, and type data pass from the Data Generator to training/testing, after which the model is sent to molecular-dynamics support.The workflow is illustrated schematically in Fig. 1.
- Data conversion: Different molecular-simulation packages can generate labels, which must be converted to RAW format before training or testing.The protocol stores box, coordinates, and labels in separate text files.
- RAW format: DeePMD-kit defines RAW files for box tensors, coordinates, energy, force, virial, and atom types, with one line representing each frame.The documented units are Å for length, eV for energy, and eV/Å for force.
- Data consistency: Frames within a system must keep atom counts, atom types, and atom ordering consistent across RAW files, although different systems may differ.Frame order within a system is not relevant.
- Data efficiency: RAW files other than type.raw are converted to NumPy binaries to reduce hard-disk loading bottlenecks during training and testing.DeePMD-kit provides a Python script for this conversion.
B. Model training
DeePMD-kit constructs atomic energies through descriptor and neural-network mappings, then uses TensorFlow to train models that produce energies, forces, and virials. Training supports multiple systems, checkpointing, and configurable network and optimization settings.
- Model architecture: Atomic energy is computed through successive mappings from neighboring-atom positions to descriptors and from descriptors to atomic energy through a DNN.The descriptor portion is implemented in C++ and interfaced with TensorFlow as a custom operator.
- Model architecture: System energy is decomposed into atomic contributions, while forces and virials are obtained from energy derivatives with respect to positions and the box tensor.The chain rule is used for force and virial computation.
- Optimization: TensorFlow operators compute system energy, atomic forces, and virial, enabling forward loss evaluation and automatic backward derivatives with respect to model parameters.Optimization uses TensorFlow's Adam stochastic gradient descent method on batches of training data.
- Data and training procedure: Training data are organized as systems containing frames, and systems are trained successively in cycles using randomly selected batches without replacement.The batch size determines the number of frames used in each optimization step.
- Implementation: The dp_train program reads JSON settings, supports configurable network architecture and learning-rate schedules, and saves parameters to checkpoints that can be resumed or frozen.A frozen model is used for subsequent testing and molecular dynamics simulations.
C. Model testing
DeePMD-kit evaluates energy, force, and virial errors on training and testing data during and after training. Comparing these errors provides an overfitting diagnostic and suggests reducing model capacity or increasing training data when testing error is much larger.
- Testing procedure: During training, DeePMD-kit evaluates RMS energy, force, and virial errors and the loss function on training batches and testing data.For efficiency, on-the-fly testing may use only a subset of the testing data.
- Testing procedure: After freezing, the dp_test tool evaluates the model, with training and testing errors ideally remaining roughly similar.The same error measures are used for post-training testing.
- Overfitting diagnosis: A much lower training error than testing error signals overfitting because the model fits training data without matching testing data.The schematic in Fig. 2 illustrates this distinction between training and testing behavior.
- Overfitting diagnosis: When overfitting occurs, the package recommends reducing the number of layers or neurons, or increasing the size of the training data.These changes target model capacity and data coverage rather than the testing procedure itself.
D. Molecular dynamics
After freezing a DeePMD model, DeePMD-kit connects it to molecular-dynamics engines through interfaces that return energies, forces, and virials. The release supports LAMMPS and i-PI, with serial DeePMD simulations in the current LAMMPS integration.
- Model deployment: A frozen DeePMD model can run molecular dynamics by receiving atom types and positions and returning energy, forces, and virial.Interaction evaluation uses TensorFlow's C++ API and executes the frozen network operations.
- Package interfaces: DeePMD-kit provides interfaces for both LAMMPS classical molecular dynamics and i-PI path-integral molecular dynamics.The current release explicitly provides support for these two packages.
- LAMMPS support: The LAMMPS integration uses a DeePMD pair style referencing the frozen model file, with only two added input lines needed to enable the model.The pair_coeff field is left blank.
- LAMMPS support: The current release supports only serial molecular-dynamics simulations with the DeePMD model in LAMMPS.This is the stated scope boundary of the release's LAMMPS support.
- i-PI support: The i-PI interface uses a client-server model in which dp_ipi receives coordinates and returns DeePMD energies, forces, and virials through socket communication.Multiple clients allow interactions across multiple path-integral replicas to be parallelized.
IV. EXAMPLE
The example trains DeePMD on a 64-molecule liquid-water dataset generated from a PBE0+TS DFT model, then evaluates errors and structural properties. The trained model achieves low testing errors and satisfactory agreement with the DFT structure.
- Model and training: The network uses five hidden layers trained with Adam and an exponentially decreasing learning rate, with descriptors encoding radial and angular neighbor information.The input includes radial and angular information for selected nearby oxygen and hydrogen atoms, and radial information for remaining neighbors.
- Accuracy: 4.3% and 2.9% are the relative energy and force errors with respect to the data standard deviations.The energy and force standard deviations are 6.5 × 10^-1 eV and 8.1 × 10^-1 eV/Å, respectively.
- Structural validation: Radial distribution functions and tetrahedral packing-parameter distributions show satisfactory agreement between DeePMD and the DFT model in generating structure properties.The comparison uses trajectories from DeePMD and PBE0+TS AIMD simulations.
V. CONCLUSION AND FUTURE WORK
DeePMD-kit implements DeePMD with TensorFlow-based deep neural network representations and interfaces to LAMMPS and i-PI for molecular dynamics. The package is illustrated on bulk liquid water, while descriptor computation remains CPU-only and MD evaluation is not yet parallelized.
- DeePMD-kit implements a deep neural network representation for atomic interactions using TensorFlow.
- The package provides C++ descriptors and force/virial chain rules as TensorFlow operators for model training and potential-energy-surface evaluation.
- LAMMPS and i-PI support classical and path-integral molecular dynamics using DeePMD-modeled atomic interactions.
- The paper documents DeePMD descriptors, network architecture, force and virial formulas, loss function, RAW data format, and training, testing, and simulation workflows.
- The package’s accuracy and efficiency are illustrated with a bulk liquid water system.
- Descriptor computation is CPU-only, and energy, force, and virial evaluation during molecular dynamics is not parallelized; future work targets CPU multicore and GPU multithreading.
Appendix A: Deriviation of force and virial
The appendix derives the atomic force and system virial from the energy construction and its derivatives.
- The force of the i-th atom is obtained using the preceding energy-construction equations.
- The system virial is likewise derived from the same energy-construction equations.