Skip to main content

MatGL (Materials Graph Library) is a framework for graph deep learning for materials science.

Project description

MatGL (Materials Graph Library)

GitHub license Linting Testing Downloads

Table of Contents

Introduction

MatGL (Materials Graph Library) is a graph deep learning library for materials science. Mathematical graphs are a natural representation for a collection of atoms (e.g., molecules or crystals). Graph deep learning models have been shown to consistently deliver exceptional performance as surrogate models for the prediction of materials properties.

In this repository, we have reimplemented the original Tensorflow MatErials 3-body Graph Network (m3gnet) and its predecessor, MEGNet, using the Deep Graph Library (DGL) and PyTorch. The goal is to improve the usability, extensibility and scalability of these models. Here are some key improvements over the TF implementations:

  • A more intuitive API and class structure based on DGL.
  • Multi-GPU support via PyTorch Lightning. A training utility module has been developed.

This effort is a collaboration between the Materials Virtual Lab and Intel Labs (Santiago Miret, Marcel Nassar, Carmelo Gonzales). Please refer to the official documentation for more details.

Status

Major milestones are summarized below. Please refer to change log for details.

  • v0.5.1 (Jun 9 2023): Model versioning implemented.
  • v0.5.0 (Jun 8 2023): Simplified saving and loading of models. Now models can be loaded with one line of code!
  • v0.4.0 (Jun 7 2023): Near feature parity with original TF implementations. Re-trained M3Gnet universal potential now available.
  • v0.1.0 (Feb 16 2023): Initial implementations of M3GNet and MEGNet architectures have been completed. Expect bugs!

Architectures

m3gnet_schematic

MEGNet

The MatErials Graph Network (MEGNet) is an implementation of DeepMind's graph networks for machine learning in materials science. We have demonstrated its success in achieving low prediction errors in a broad array of properties in both molecules and crystals. New releases have included our recent work on multi-fidelity materials property modeling. Figure 1 shows the sequential update steps of the graph network, whereby bonds, atoms, and global state attributes are updated using information from each other, generating an output graph.

M3GNet

M3GNet is a new materials graph neural network architecture that incorporates 3-body interactions in MEGNet. An additional difference is the addition of the coordinates for atoms and the 3×3 lattice matrix in crystals, which are necessary for obtaining tensorial quantities such as forces and stresses via auto-differentiation. As a framework, M3GNet has diverse applications, including:

  • Interatomic potential development. With the same training data, M3GNet performs similarly to state-of-the-art machine learning interatomic potentials (MLIPs). However, a key feature of a graph representation is its flexibility to scale to diverse chemical spaces. One of the key accomplishments of M3GNet is the development of a universal IP that can work across the entire periodic table of the elements by training on relaxations performed in the Materials Project.
  • Surrogate models for property predictions. Like the previous MEGNet architecture, M3GNet can be used to develop surrogate models for property predictions, achieving in many cases accuracies that are better or similar to other state-of-the-art ML models.

For detailed performance benchmarks, please refer to the publications in the References section.

Installation

Matgl can be installed via pip for the latest stable version:

pip install matgl

For the latest dev version, please clone this repo and install using:

python setup.py -e .

Usage

Pre-trained M3GNet universal potential and MEGNet models for the Materials Project formation energy and multi-fidelity band gap are now available. Users who just want to use the models out of the box should use the newly implemented convenience method:

import matgl
model = matgl.load_model("<model_name>")

The following is an example of a prediction of the formation energy for CsCl.

from pymatgen.core import Lattice, Structure
import matgl

model = matgl.load_model("MEGNet-MP-2018.6.1-Eform")

# This is the structure obtained from the Materials Project.
struct = Structure.from_spacegroup("Pm-3m", Lattice.cubic(4.1437), ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]])
eform = model.predict_structure(struct)
print(f"The predicted formation energy for CsCl is {float(eform.numpy()):.3f} eV/atom.")

Jupyter notebooks

We have written several Jupyter notebooks on the use of MatGL. These notebooks can be run on Google Colab. This will be the primary form of usage documentation.

API Docs

The Sphinx-generated API docs are available here.

Developer's Guide

A basic developer's guide has been written to outline the key design elements of matgl.

References

Please cite the following works:

MEGNet

Chen, C.; Ye, W.; Zuo, Y.; Zheng, C.; Ong, S. P. Graph Networks as a Universal Machine Learning Framework for Molecules and Crystals. Chem. Mater. 2019, 31 (9), 3564–3572. https://doi.org/10.1021/acs.chemmater.9b01294.

Multi-fidelity MEGNet

Chen, C.; Zuo, Y.; Ye, W.; Li, X.; Ong, S. P. Learning Properties of Ordered and Disordered Materials from Multi-Fidelity Data. Nature Computational Science 2021, 1, 46–53. https://doi.org/10.1038/s43588-020-00002-x.

M3GNet

Chen, C., Ong, S.P. A universal graph deep learning interatomic potential for the periodic table. Nat Comput Sci, 2, 718–728 (2022). https://doi.org/10.1038/s43588-022-00349-3.

Acknowledgments

This work was primarily supported by the Materials Project, funded by the U.S. Department of Energy, Office of Science, Office of Basic Energy Sciences, Materials Sciences and Engineering Division under contract no. DE-AC02-05-CH11231: Materials Project program KC23MP. This work used the Expanse supercomputing cluster at the Extreme Science and Engineering Discovery Environment (XSEDE), which is supported by National Science Foundation grant number ACI-1548562.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matgl-0.5.2.tar.gz (185.3 kB view details)

Uploaded Source

Built Distribution

matgl-0.5.2-py3-none-any.whl (197.1 kB view details)

Uploaded Python 3

File details

Details for the file matgl-0.5.2.tar.gz.

File metadata

  • Download URL: matgl-0.5.2.tar.gz
  • Upload date:
  • Size: 185.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for matgl-0.5.2.tar.gz
Algorithm Hash digest
SHA256 629d3717edf84d2d348680cd9e4ad107e5467d5c527b0e6f0c1baa6b1149492a
MD5 e87d98e64fe3f4fe396bd564f706dc51
BLAKE2b-256 1918dcd9c18413ca1c8d38a8bcdc47caa51cc49f48942b3d8aba750a57d70fca

See more details on using hashes here.

File details

Details for the file matgl-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: matgl-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 197.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for matgl-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 21e4beb1ce9e085dab75f1f0ba8e5953e33ad36daecfa82b2438e276aeef7839
MD5 791fe24c1035dc9a0c01a5e11368c80e
BLAKE2b-256 fa4a95ca5c56f741bfa0787949f443e1547c1d9e537eb397a75556f8a4ea081a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page