MatRIS

Model Introduction

MatRIS, short for Materials Representation and Interaction Simulation, is a foundation model for material representation and interaction simulation. It predicts the energy, forces, stress, and magnetic moments of crystal structures and supports structure relaxation using ASE Atoms and pymatgen Structure objects.

Model Description

MatRIS uses a graph neural network architecture trained on materials datasets such as OMat24 and MPTrj. It supports energy, force, stress, and magnetic-moment prediction and structure optimization for crystalline materials.

Use Cases

Use case Description
Crystal energy prediction Predict system energy from a CIF file, pymatgen Structure, or ASE Atoms object
Force and stress prediction Estimate forces and stress for structure relaxation, molecular dynamics, or downstream simulations
Magnetic-moment prediction Return structure-dependent magnetic moments for the efsm task
Structure-relaxation preprocessing Optimize atomic positions and unit cells of candidate crystals with StructOptimizer
Environment connectivity check Use cif_file/demo.cif and a lightweight MatRIS model to verify the OneScience MatChem environment

Usage

1. Using OneCode

Try intelligent, one-click AI4S programming in the OneCode online environment:

Try intelligent, one-click AI4S programming

2. Manual Installation and Usage

Hardware requirements

  • A GPU or DCU is recommended.
  • A CPU can be used for module checks and small forward-pass tests, but structure relaxation will be slow and is not recommended for production batch inference.
  • DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version matching the current cluster, is recommended.

Download the Model Package

hf download OneScience-Group/MatRIS 
cd matris

Install the Runtime Environment

DCU environment

# Activate DTK and conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU environment

# Activate conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

Trained Weights

Inference requires a pretrained model. MatRIS provides the following model keys:

Model key Description
matris_10m_omat Trained on the OMat24 dataset
matris_10m_oam Trained on OMat24 and fine-tuned on sAlex+MPtrj
matris_10m_mp Trained on the MPTrj dataset

The weight/ directory in this repository already contains pretrained weights. scripts/test_relaxation.py loads them from that directory.

Inference

Run the modularity check

python scripts/test_modularization.py

This script instantiates a lightweight MatRIS model with randomly initialized weights and runs one CPU forward pass to verify that the model modules work together.

Run structure-relaxation inference

python scripts/test_relaxation.py

This script reads cif_file/demo.cif and performs structure relaxation with StructOptimizer.

After inference, the log shows the relaxation process, while the energy, forces, stress, magnetic moments, and final structure object are available in memory.

Other inference examples

In addition to structure relaxation, you can use MatRISCalculator to predict the energy, forces, stress, and magnetic moments of a single structure:

import torch
from ase.build import bulk
from onescience.utils.matris import MatRISCalculator

device = "cuda" if torch.cuda.is_available() else "cpu"
calc = MatRISCalculator(
    model="matris_10m_oam",
    task="efsm",
    device=device,
)

atoms = bulk("Cu", a=5.43, cubic=True)
atoms.calc = calc

energy = atoms.get_potential_energy()   # Total energy (eV)
forces = atoms.get_forces()             # Forces (eV/Å)
stress = atoms.get_stress()             # Stress (eV/ų)
magmoms = atoms.get_magnetic_moments()  # Magnetic moments (μB)

Official OneScience Resources

Citation and License

  • The upstream MatRIS materials use the BSD 3-Clause License. This repository retains source attribution and has been organized for automated execution in the OneScience Hugging Face environment.
  • If you use MatRIS results in research, please cite the original MatRIS project and the relevant OneScience projects, as well as the materials datasets, structure-optimization tools, or downstream analysis tools used for your task.

中文说明

模型简介

MatRIS 是 Materials Representation and Interaction Simulation 的缩写,是用于材料表征与相互作用模拟的基础模型。它预测晶体结构的能量、力、应力和磁矩,并支持使用 ASE Atoms 和 pymatgen Structure 对象进行结构弛豫。

模型描述

MatRIS 采用图神经网络架构,在 OMat24 和 MPTrj 等材料数据集上训练,支持晶体材料的能量、力、应力和磁矩预测及结构优化。

使用场景

使用场景 说明
晶体能量预测 根据 CIF 文件、pymatgen Structure 或 ASE Atoms 对象预测体系能量
力和应力预测 估算用于结构弛豫、分子动力学或下游模拟的力和应力
磁矩预测 为 efsm 任务返回与结构相关的磁矩
结构弛豫预处理 使用 StructOptimizer 优化候选晶体的原子位置和晶胞
环境连通性检查 使用 cif_file/demo.cif 和轻量级 MatRIS 模型验证 OneScience MatChem 环境

使用方法

1. 使用 OneCode

在 OneCode 在线环境中体验智能一键 AI4S 编程。

体验智能一键 AI4S 编程

2. 手动安装与使用

硬件要求

  • 建议使用 GPU 或 DCU。
  • 可使用 CPU 检查模块并进行小规模前向传播测试,但结构弛豫速度较慢,不建议用于生产批量推理(inference)。
  • DCU 用户必须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的与当前集群匹配的版本。

下载模型包

hf download OneScience-Group/MatRIS 
cd matris

安装运行环境

DCU 环境

# Activate DTK and conda first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU 环境

# Activate conda first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is also supported
pip install onescience[matchem-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

训练权重

推理需要预训练模型。MatRIS 提供以下模型键。

模型键 说明
matris_10m_omat 在 OMat24 数据集上训练
matris_10m_oam 在 OMat24 上训练,并在 sAlex+MPtrj 上微调(fine-tuning)
matris_10m_mp 在 MPTrj 数据集上训练

本仓库的 weight/ 目录已包含预训练权重。scripts/test_relaxation.py 从该目录加载这些权重。

推理

运行模块检查

python scripts/test_modularization.py

此脚本用随机初始化的权重实例化一个轻量级 MatRIS 模型,并执行一次 CPU 前向传播以验证模型模块可协同运行。

运行结构弛豫推理

python scripts/test_relaxation.py

此脚本读取 cif_file/demo.cif,并使用 StructOptimizer 进行结构弛豫。

推理结束后,日志将显示弛豫过程,能量、力、应力、磁矩和最终结构对象可在内存中获取。

其他推理示例

除了结构弛豫,还可以使用 MatRISCalculator 预测单个结构的能量、力、应力和磁矩。

import torch
from ase.build import bulk
from onescience.utils.matris import MatRISCalculator

device = "cuda" if torch.cuda.is_available() else "cpu"
calc = MatRISCalculator(
    model="matris_10m_oam",
    task="efsm",
    device=device,
)

atoms = bulk("Cu", a=5.43, cubic=True)
atoms.calc = calc

energy = atoms.get_potential_energy()   # Total energy (eV)
forces = atoms.get_forces()             # Forces (eV/Å)
stress = atoms.get_stress()             # Stress (eV/ų)
magmoms = atoms.get_magnetic_moments()  # Magnetic moments (μB)

OneScience 官方资源

引用与许可证

  • 上游 MatRIS 材料采用 BSD 3-Clause 许可证。本仓库保留来源署名,并已组织为可在 OneScience Hugging Face 环境中自动运行的形式。
  • 如果在研究中使用 MatRIS 结果,请引用原始 MatRIS 项目及相关 OneScience 项目,以及任务所用材料数据集、结构优化工具或下游分析工具。
Downloads last month
12
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support