Bohrium
robot
新建

空间站广场

论文
Notebooks
比赛
课程
Apps
我的主页
我的Notebooks
我的论文库
我的足迹

我的工作空间

任务
节点
文件
数据集
镜像
项目
数据库
公开
Pre-trained Model of Solid Electrolytes for Sulfide Compounds 硫族化合物固态电解质预训练模型
Deep Learning
notebook
AI4S
Deep LearningnotebookAI4S
shimengchao@dp.tech
ruoyu
SchrodingersCat
Piloteye
更新于 2024-06-27
推荐镜像 :chgnet-m3gnet:0.0.3
推荐机型 :c2_m4_cpu
赞 8
3
4
LAM-SSE(v1)

硫族化合物固态电解质预训练模型

Pre-trained Model of Solid Electrolytes for Sulfide Compounds

代码
文本

1. 背景 Background

代码
文本

固态电解质凭借其更高的能量密度、卓越的安全性和更长的使用寿命,有望替代传统的有机电解液,成为新一代电池技术的核心。然而,在固态电解质的研究和开发过程中,仍面临诸多挑战,例如材料的电化学稳定性、离子电导率较低、界面不稳定等。为克服这些挑战,科研人员需深入研究固态电解质的结构、缺陷和扩散机制等方面的规律,从而设计出性能更优越的固态电解质材料。


Solid electrolytes are expected to replace traditional organic electrolytes and become the core of the new generation of battery technology due to their higher energy density, excellent safety and longer service life. However, there are still many challenges in the research and development of solid electrolytes, such as the electrochemical stability of materials, low ionic conductivity, and unstable interfaces. To overcome these challenges, researchers need to conduct in-depth research on the structure, defects, and diffusion mechanisms of solid electrolytes in order to design solid electrolyte materials with better performance.

代码
文本

2. 模型整体介绍 Overview

代码
文本

模型的训练集包含了26种硫族化合物, 14种基础二元化合物, 1种Li单质
基础化合物:

  • 二价:
  • 三价:
  • 四价:
  • 五价:

三元硫族化合物:

  • 三价:
  • 四价:
  • 五价:

四元硫族化合物:

  • LGPS类:
  • LPSCl类:

The training set of the model 26 chalcogenides, 14 basic binary compounds, 1 Li single-element
Basic compounds:

  • Divalent:
  • Trivalent:
  • Tetravalent:
  • Pentavalent:

Ternary chalcogenides:

  • Trivalent:
  • Tetravalent:
  • Pentavalent:

Quaternary chalcogenides:

  • LGPS:
  • LPSCl:
代码
文本

代码
文本

3. 模型训练方法和流程 Training Method and Procedure

代码
文本

训练体系包含41种体系,采用主动学习的框架(DPGEN)来生产数据集,在DPGEN迭代过程中,训练过程采用DPA-1的方式进行训练,初始训练集采用dpgen init_bulk的方式产生,

  • 训练过程主要参数 00.train: atten_layer: 0, step: 60 W,Rcut = 6 Å
  • 探索过程主要参数 01.model_devi: NPT, 0~2GPa, T: 0~1200 K,实时调整 "model_devi_f_trust_lo": 0.15~0.25 eV/Å和 "model_devi_f_trust_hi": 0.35~0.40 eV/Å(不同体系的力误差存在差别)
  • 单点能主要参数 02.fp:基于PBE-sol泛函,Ecut=600 eV, kspacing:0.3 Å(经过k点测试,阈值小于 1 meV/atom)

The training system includes 41 systems, and the active learning framework (DPGEN) is used to produce the data set. During the DPGEN iteration process, the training process is trained using the DPA-1 method, and the initial training set is generated using the dpgen init_bulk method.

  • Main parameters of the training process 00.train: atten_layer: 0, step: 600,000; Rcut = 6 Å
  • Main parameters of the exploration process 01.model_devi: NPT, 0~2GPa, T: 0~1200 K, real-time adjustment "model_devi_f_trust_lo": 0.15~0.25 eV/Å and "model_devi_f_trust_hi": 0.35~0.40 eV/Å (different systems have different force errors)
  • Main parameters of single point energy 02.fp: based on PBE-sol functional, ecut=600 eV, kspacing: 0.3 Å (After k-point testing, the threshold is less than 1 meV/atom)
代码
文本
[7]
## show all training set
!cd /bohr && ls
import os
os.chdir("/bohr/LAM-SSE-7xfp/v1/20240412-SSE")
import dpdata
k = dpdata.MultiSystems().load_systems_from_file('00.data/train-data', fmt="deepmd/npy")
print(k)
print(k[0])
LAM-SSE-7xfp
MultiSystems (41 systems containing 54771 frames)
Data Summary
Labeled System
-------------------
Frame Numbers      : 3399
Atom Numbers       : 50
Including Virials  : Yes
Element List       :
-------------------
Ge  Li  O  P  S  Si  Sn  Cl  Br  I  B  Al  Ga  As  Sb
0  20  0  4  24  0  2  0  0  0  0  0  0  0  0
代码
文本

4. 模型精度评测 Model Evaluation

代码
文本

对于模型的精度验证,我们可以直接对比DFT和DP势函数的能量、受力、维里,基于dp test功能直接进行预测。这里,我们从三个维度进行分析展开:

  • DP模型在训练集的精度表现
  • DP模型在测试集的精度表现
  • DP模型和通用力场的精度对比

To verify the accuracy of the model, we can compare the directly inferenced energies, forces, and virials of DFT and DP models, and make predictions based on the dp test function. Here, we analyze and expand from the following three aspects:

  • Accuracy performance of the DP model in the training set
  • Accuracy performance of the DP model in the test set
  • Comparison of the accuracy of the DP model and the general force field
代码
文本

4.1 训练集表现 Performance in Training Systems

代码
文本

所有训练集:共计82个system,样本数54771帧, 采用DP模型分别进行dptest,82个system的总体能量、受力和维里精度表现

  • DPA-2: 训练步数200万,截断半径为9 Å, 训练耗时 5 days (2.5 days/100万步)
  • DPA-1: 训练步数1200万, 截断半径为8 Å, atten_layer=2, 训练总耗时 674355 second = 7.8 days (0.6 days/100万步)
  • DPA-1: 训练步数1200万, 截断半径为8 Å, atten_layer=0, 训练总耗时 113110.810 second = 31.4 h = 1.3 days (0.1 days/100万步)

All training sets: 82 systems in total, 54771 frames of samples, Using the DP model to perform dptest, the overall energy, force and virial accuracy performance of the 82 systems

  • DPA-2: 2 million training steps, 9 Å cutoff radius, 5 days of training time (2.5 days/1 million steps)
  • DPA-1: 12 million training steps, 8 Å cutoff radius, atten_layer=2, total training time 674355 second = 7.8 days (0.6 days/1 million steps)
  • DPA-1: 12 million training steps, 8 Å cutoff radius, atten_layer=0, total training time 113110.810 second = 31.4 h = 1.3 days (0.1 days/1 million steps)
代码
文本
[14]
import os
os.chdir("/bohr/LAM-SSE-7xfp/v1/20240412-SSE/01.model/")
os.system("tree")
os.system("ls ./*/*.pb")
.
├── dpa1
│   ├── L0-r8
│   │   ├── com.pb
│   │   ├── frozen_model.pb
│   │   ├── input.json
│   │   └── job_dp.json
│   └── L2-r8
│       ├── frozen_model.pb
│       ├── input.json
│       └── job_dp.json
├── dpa2
│   ├── frozen_model.pth
│   ├── input.json
│   └── job_dp.json
└── nvnmd
    ├── job_dp.json
    ├── model.pb
    ├── train_cnn.json
    └── train_qnn.json

5 directories, 14 files
./nvnmd/model.pb
0
代码
文本

通过dp test直接推理的结果如下表所示。


The results of direct inference via dp test are listed in the following table.

property DPA-1 (atten_layer=0, rcut=8Å, 1200w) DPA-1 (atten_layer=2, rcut=8Å, 1200w) DPA-2 (200w)
Energy MAE(meV/atom) 3.1 2.3 2.4
Energy RMSE(meV/atom) 5.3 6.1 4.8
Force MAE(meV/Å) 56.0 42.5 37.5
Force RMSE(meV/Å) 89.6 69.4 58.5
Virial MAE(meV/atom) 12.3 9.8 9.3
Virial RMSE(meV/atom) 20.9 17.2 15.9
代码
文本

4.2 测试集表现 Performance in Validation Sets

代码
文本

在DPMD的轨迹上采点(150~1150K的升温模拟,在10 ps轨迹中抽取100帧),分别计算单点能得到测试数据集(所有样本均不在训练集中),测试结果如下图。


We sampled points on the DPMD heating trajectory (150~1150 K , 10 ps, averaged sampled 100 frames), and calculated the single point energy to obtain the test data set (all samples were not explicitly contained by the training set). The test results are as follows。

代码
文本

代码
文本

4.3 通用力场精度对比 Comparison to Universal Force Field

代码
文本

通用力场精度 文献报道:

  • CHGNET (文献结果报道https://doi.org/10.1038/s42256-023-00716-3)
    • 不考虑磁性: 能量MAE 33 meV/atom, 受力MAE 79 meV/Å, 维里MAE 0.351 GPa
    • 考虑磁性: 能量MAE 30 meV/atom, 受力MAE 77 meV/Å, 维里MAE 0.348 GPa, 磁矩MAE 0.032 μB
  • M3GNET (文献结果报道 arXiv:2401.04070v1) 能量MAE 29.9 meV/atom, 受力MAE 72.1 meV/Å, 维里MAE 0.40 GPa 采用相同的结构(DPMD轨迹) 计算单点能分别采用DPA-2,CHGNET和M3GNET测试 DPMD相比于通用力场,能量精度高 1~2个数量级,力精度高2~5倍 为了保证测试的公开公正 (增加了平衡态构型作为测试集进行比较,见4.3.2)

通用力场的相关测试:https://bohrium.dp.tech/notebooks/49748212168


Universal force field accuracy Reference report:

  • CHGNET (refer to: https://doi.org/10.1038/s42256-023-00716-3)

  • Without considering magnetism: Energy MAE 33 meV/atom, Force MAE 79 meV/Å, Virial MAE 0.351 GPa

  • Considering magnetism: Energy MAE 30 meV/atom, Force MAE 77 meV/Å, Virial MAE 0.348 GPa, Magnetic moment MAE 0.032 μB

  • M3GNET (refer to arXiv: 2401.04070v1) Energy MAE 29.9 meV/atom, Force MAE 72.1 meV/Å, Virial MAE 0.40 GPa Using the same structure (DPMD trajectory) The single point energy is calculated using DPA-2, CHGNET and M3GNET tests Compared with the general force field, DPMD has an energy accuracy of 1~2 orders of magnitude higher and a force accuracy of 2~5 times higher In order to ensure the openness and fairness of the test (equilibrium configurations are added as test sets for comparison, see 4.3.2)

For more detailed information of benchmarking general force fields: https://bohrium.dp.tech/notebooks/49748212168

代码
文本

4.3.1 平衡态数据集 Datasets of near-equilibrium motion

代码
文本

由于通用力场往往只有平衡态附近的结构作为初始训练集,为了保证测试的公开公正,增加了平衡态构型作为测试集进行比较。 直接采用MP的结构,采用PBE/PBEsol分别run 10 步AIMD (50 K) 得到6个体系(LXPS,LPSX)的测试集,分别采用DPA-2,CHGNET和M3GNET测试 DPMD相比于通用力场,能量精度高1~2个数量级,力精度高2~5倍


Since general force fields often only have structures near equilibrium as initial training sets, in order to ensure the openness and fairness of the test, equilibrium configurations are added as test sets for comparison. Directly use the structure of MP, use PBE/PBEsol to run 10 steps of AIMD (50 K) Get the test sets of 6 systems (LXPS, LPSX), use DPA-2, CHGNET and M3GNET to test Compared with general force fields, DPMD has 1~2 orders of magnitude higher energy accuracy and 2~5 times higher force accuracy

CHGNET LGPS LPSBr LPSCl LPSI LSiPS LSnPS
Energy MAE (meV/atom) 0.71 14.4 7.6 21.5 9.3 3.3
Force MAE (meV/Å) 27.9 31.9 29.8 39.4 26.1 35.8
M3GNET LGPS LPSBr LPSCl LPSI LSiPS LSnPS
Energy MAE (meV/atom) 4.9 2.5 14.5 0.6 7.9 3.5
Force MAE (meV/Å) 18.6 18.7 19.8 22.9 34.7 37
DPA-2 LGPS LPSBr LPSCl LPSI LSiPS LSnPS
Energy MAE (meV/atom) 1.0 0.6 0.1 1.1 1.0 1.5
Force MAE (meV/Å) 5.8 4.9 4.1 5.3 6.9 9.2
代码
文本

4.3.2 DPMD轨迹数据集 Datasets of DPMD trajectories

代码
文本

在DPMD的升温轨迹(150~1150 K)中挑选100帧结构,进行单点计算(PBE-sol/PBE),得到6个体系(LXPS,LPSX)的测试集,进行测试


100 frames were selected from the DPMD heating trajectory (150~1150 K) and single-point calculations (PBE-sol/PBE) were performed to obtain a test set of 6 systems (LXPS, LPSX) for testing.

CHGNET LGPS LPSBr LPSCl LPSI LSiPS LSnPS
Energy MAE (meV/atom) 47.5 28.0 30.8 20.5 36.6 47.8
Force MAE (meV/Å) 118.6 105.3 23.8 119.3 44.6 53.3
M3GNET LGPS LPSBr LPSCl LPSI LSiPS LSnPS
Energy MAE (meV/atom) 48.6 34.7 33.9 30.4 40.4 52.7
Force MAE (meV/Å) 83.1 109.4 44.5 115.7 38.4 65.9
DPA-2 LGPS LPSBr LPSCl LPSI LSiPS LSnPS
Energy MAE (meV/atom) 1.6 0.9 1.6 0.7 1.4 2.7
Force MAE (meV/Å) 27.8 27.9 30.3 24.2 27.1 32.2
代码
文本

可以看到:

  • 在与CHGNET和M3GNET的比较中,DPA-2的能量平均绝对误差(MAE)明显低于通用力场,而受力的MAE则相较之下提高了约3~10倍, 如图(a-b)。
  • 其次,我们观察了在较高温度范围(150~1150 K)下的一些构型表现:DPA-2的能量的拟合精度提升1~2个数量级, 受力精度方面具有明显优势, 如图(c-d).

It can be observed that:

  • In comparison with CHGNET and M3GNET, the mean absolute error (MAE) of DPA-2 energy is significantly lower than that of the general force field, while the MAE of force is increased by about 3~10 times, as shown in Figure (a-b).
  • Secondly, we observed the performance of some configurations in the higher temperature range (150~1150 K): the fitting accuracy of DPA-2 energy is improved by 1~2 orders of magnitude, and it has a clear advantage in force accuracy, as shown in Figure (c-d).
代码
文本

alt

代码
文本

5. 性质计算 Property Calculations

代码
文本

5.1 晶格常数 Lattice Paramters

这里,我们基于DP势函数开展晶格常数的计算。

Here, we carry out calculations of lattice parameters.


5.1.1 计算流程 Calculation procedure

基于APEX的框架,我们可以采用DP势函数快速进行晶格常数的计算,可参考链接https://bohrium.dp.tech/notebooks/1814148167

Based on the APEX framework, we can use DP potential functions to quickly calculate lattice constants. Please refer to the link https://bohrium.dp.tech/notebooks/1814148167


5.1.2 计算结果 Calculation results

按照APEX中的方法,我们采用DPA-1/DPA-2的模型分别计算了41种训练体系的晶格常数如下图,整体计算结果和DFT非常接近,说明了势函数在基态结构性质具有较高的计算精度。

According to the method in APEX, we use the DPA-1/DPA-2 model to calculate the lattice constants of 41 training systems as shown in the figure below. The overall calculation results are very close to DFT, which shows that the potential function has a high calculation accuracy in the ground state structural properties.


代码
文本

代码
文本

5.2 动力学表现 Dynamics Performance

代码
文本

5.2.1 计算基本原理和流程 Calculation principles and procedures

(1) 均方根位移MSD:计算t时间内Li离子移动距离平方的平均 (2) 扩散系数D:求解t时间内的MSD在每个维度上的平均 (3) 离子电导率:根据Nernst-Einstein Equation计算 (4) 扩散系数和温度之间满足阿伦尼乌斯关系: (5) 因此,离子电导率和温度之间满足:

考虑到实际计算过程中,需要在较大的模拟体系(原子数:~),较长的时间尺度(1~100 ns)下进行,整个计算时间会较长(例如,2068个原子的体系,模拟10 ns,需要在V100上运行46 h),不便在Notebook中演示,这里我们缩短模拟步数,演示操作流程(实际计算时,根据大家的体系选择合适的模拟时长)


(1) Root mean square displacement MSD: calculate the average of the square of the distance moved by Li ions in time t (2) Diffusion coefficient D: solve the average of MSD in each dimension in time t (3) Ionic conductivity : calculated according to Nernst-Einstein Equation (4) The diffusion coefficient and temperature satisfy the Arrhenius relationship: (5) Therefore, the relationship between ionic conductivity and temperature satisfies:

Considering that the actual calculation process needs to be carried out in a larger simulation system (number of atoms: ~) and a longer time scale (1~100 ns), the entire calculation time will be longer (for example, a system with 2068 atoms, simulating 10 ns, needs to run 46 hours on V100), which is not convenient for demonstration in Notebook. Here we shorten the number of simulation steps and demonstrate the operation process (in actual calculation, choose the appropriate simulation time according to your system)

代码
文本

5.2.2 离子扩散系数 Ionic Diffusion Coefficient

利用DPA势函数,采用分子动力学模拟来计算26种硫族化合物在不同温度(300~900K)下的扩散系数. 这里展示一个LGPS的计算案例:

  • 准备LAMMPS运行的输入文件in.lmp
  • DP势函数模型com.pb
  • 模拟体系的结构文件conf.lmp

Using the DPA potential function, molecular dynamics simulation is used to calculate the diffusion coefficients of 26 chalcogenides at different temperatures (300~900K). Here is a calculation example of LGPS:

  • Prepare the input file in.lmp for LAMMPS operation
  • DP potential function model com.pb
  • Simulation system structure file conf.lmp
代码
文本
[9]
import os
os.chdir("/bohr/LAM-SSE-7xfp/v1/20240412-SSE/02.DPMD/LGPS-900K")
os.system("ls")
os.system("cat in.lmp")
com.pb
conf.lmp
finish
in.lmp

## 
units 	metal
dimension	3
boundary	p p p
atom_style	atomic
box         tilt large
read_data   conf.lmp

mass            1 6.941000
mass            2 10.811000
mass            3 15.999400
mass            4 26.981000
mass            5 28.085500
mass            6 30.973800
mass            7 32.065000
mass            8 35.453000
mass            9 69.723000
mass            10 72.640000
mass            11 74.921000
mass            12 79.904000
mass            13 118.710000
mass            14 121.760000
mass            15 126.904000

neigh_modify    every 1 delay 0 check no

pair_style      deepmd ./com.pb
pair_coeff      * *

##################################################################################

variable        temp            equal 900
variable        eql_step        equal 10000000
variable        rd_seed         equal 666666

variable        temp_damp       equal 0.2 # tau_NVT = timestep * 100 
variable        t_step          equal 0.002
variable        rlx_step        equal 50000

variable        thermo_freq     equal 1000
variable        dump_freq       equal 10000


group                   Li type 1
group                   Ge type 10
group                   P  type 6
group                   S  type 7


thermo_style    custom step pe ke etotal press lx ly lz vol density
thermo          100

velocity        all create ${temp} 666666

fix             1 all npt temp ${temp} ${temp} 0.2 iso 1 1 2
timestep        ${t_step}
run             ${rlx_step}
unfix           1
write_restart   npt.restart

reset_timestep  0

##################################################################################

## nvt-equal
fix             equil all nvt temp ${temp} ${temp} 0.2
timestep        ${t_step}
#fix             com all recenter INIT INIT INIT

# rdf calculation
#compute         rdf all rdf 100 6 2 2 2 2 3 2 4
#fix                            1 all ave/time 100 1 100 c_rdf[*] file target.rdf mode vector

# msd calculation
compute                 msd1 Li msd
compute                 msd2 Ge  msd
compute                 msd3 P  msd
compute                 msd4 S  msd
fix             2 all ave/time 100 1 100 c_msd1[4] c_msd2[4] c_msd3[4] c_msd4[4]  file target.msd

## thermo_style
thermo_style    custom step time temp ke etotal press density
thermo          ${thermo_freq}
thermo_modify   flush yes
dump            3 all custom ${dump_freq} dump.lammpstraj id type x y z
run             ${eql_step}

write_restart   msd.restart

0
代码
文本

在bohrium平台可通过lbg的方式进行命令提交,指令为:

lbg job submit -i job.json -p . -r . \

如果大家使用本地集群/超算, 可参考LAMMPS任务提交的脚本进行计算.任务完成以后,会产生target.msd的文件,对该文件做后处理,即可获得扩散系数.可参考一些notebook (https://bohrium.dp.tech/notebooks/7317436745, https://bohrium.dp.tech/notebooks/7014740428)

分别计算每个体系在不同温度下的扩散系数,收集计算结果,汇总如下图:

  • 有18种体系在室温下Li离子的扩散系数都很低(达以下),基本可以认为此时Li离子的扩散都非常弱,对应的Li离子电导率将非常低.
  • 有8种固态电解质材料在室温下都保持很高的Li离子扩散系数(达以上),这也是实验上发现的常见高电导率的材料,分别是:

进一步,我们探讨LXPS类体系的扩散系数同通用力场和AIMD的结果进行对比,我们发现DPA势函数计算的扩散系数和AIMD具有很好的一致性,在室温下,实验测量的Li离子的扩散系数一般在量级,很明显,通用力场会高估Li离子的扩散系数2~3个数量级,无法实现准确预测。


On the Bohrium platform, you can submit commands through lbg, the command is:

lbg job submit -i job.json -p . -r . \

If you use a local cluster/supercomputer, you can refer to the script submitted by the LAMMPS task for calculation. After the task is completed, a target.msd file will be generated. After post-processing the file, you can get the diffusion coefficient. You can refer to some notebooks (https://bohrium.dp.tech/notebooks/7317436745, https://bohrium.dp.tech/notebooks/7014740428)

Calculate the diffusion coefficient of each system at different temperatures, collect the calculation results, and summarize them as shown in the following figure:

  • There are 18 systems with very low Li ion diffusion coefficients at room temperature (below ). It can be basically considered that the diffusion of Li ions is very weak at this time, and the corresponding Li ion conductivity will be very low.

  • There are 8 solid electrolyte materials that maintain a very high Li ion diffusion coefficient at room temperature (up to ), which are also common high conductivity materials found in experiments, namely:

Further, we explored the diffusion coefficient of LXPS-type systems and compared it with the results of general force field and AIMD. We found that the diffusion coefficient calculated by DPA potential function is very consistent with AIMD. At room temperature, the experimentally measured diffusion coefficient of Li ions is generally in the order of magnitude. Obviously, the general force field will overestimate the diffusion coefficient of Li ions by 2~3 orders of magnitude and cannot achieve accurate prediction.

代码
文本

代码
文本

5.2.3 离子电导率 Ionic Conductivity

基于扩散系数和离子电导之间的关系,我们采用不同的力场分别提取了经典硫族化合物的离子电导率,结果展示在下图,可以看到DP势函数能够较为准确地预测Li离子电导率(接近于实验结果)。


Based on the relationship between diffusion coefficient and ionic conductivity, we used different force fields to extract the ionic conductivity of classic chalcogenides. The results are shown in the figure below. It can be seen that the DP potential function can predict Li ion conductivity more accurately (close to the experimental results).

代码
文本

代码
文本

5.2.4 离子迁移势垒 Ionic Migration Barrier

采用扩散系数和温度倒数之间的关系,进行线性拟合,求解迁移势垒(激活能),并将计算结果记录在下图,基本上DP势函数的精度接近于实验值


The relationship between the diffusion coefficient and the inverse of the temperature is used for linear fitting to solve the migration barrier (activation energy), and the calculation results are recorded in the figure below. Basically, the accuracy of the DP potential function is close to the experimental value.

代码
文本

代码
文本

6. 非冯·诺依曼架构分子动力学 NVNMD

湖南大学电气与信息工程学院的刘杰教授团队基于自主研制的非冯·诺依曼(non von Neumann, NVN)芯片架构,提出了一种新型分子动力学方法NVNMD。NVNMD利用深度神经网络模型可以高精度拟合高维势能面的优势,保障了分子动力学的计算精度;并利用新型非冯·诺依曼架构的高效率优势,保障了分子动力学的计算速度。 因此,NVNMD兼具AIMD级别的高精度、CMD级别的高速度——实现了“鱼与熊掌可以兼得”。将DPMD训练的数据集用于训练nvnmd的模型,可以进一步加速MD模拟的速度(提升效率),这里将演示如何采用nvnmd的方法来训练模型和实现分子模拟。 详细使用方法可查阅https://github.com/LiuGroupHNU/nvnmd


Professor Liu Jie's team from the School of Electrical and Information Engineering at Hunan University proposed a new molecular dynamics method NVNMD based on the self-developed non-von Neumann (NVN) chip architecture. NVNMD takes advantage of the deep neural network model to fit high-dimensional potential energy surfaces with high precision, ensuring the calculation accuracy of molecular dynamics; and takes advantage of the high efficiency of the new non-von Neumann architecture to ensure the calculation speed of molecular dynamics. Therefore, NVNMD has both AIMD-level high precision and CMD-level high speed - achieving "having your cake and eating it too". Using the DPMD training data set to train the nvnmd model can further accelerate the speed of MD simulation (improve efficiency). Here we will demonstrate how to use the nvnmd method to train the model and implement molecular simulation. Detailed usage methods can be found at https://github.com/LiuGroupHNU/nvnmd

代码
文本

6.1 训练 Training

代码
文本
[16]
import os
os.chdir("/bohr/LAM-SSE-7xfp/v1/20240412-SSE/01.model/nvnmd/")
os.system("ls")
os.system("cat *cnn.json")
job_dp.json
model.pb
train_cnn.json
train_qnn.json
{
  "nvnmd": {
    "version": 1,
    "net_size": 128,
    "sel": 256,
    "rcut": 8.0,
    "rcut_smth": 0.5,
    "type_map" : [    "Li",   "B",    "O",       "Al",   "Si",    "P",     "S",    "Cl",     "Ga",   "Ge",  "As",   "Br",     "Sn",   "Sb",    "I"    ]
  },
  "learning_rate": {
    "type": "exp",
    "start_lr": 1e-3,
    "stop_lr": 3e-8,
    "decay_steps": 60000
  },
  "loss": {
    "start_pref_e": 0.02,
    "limit_pref_e": 1,
    "start_pref_f": 1000,
    "limit_pref_f": 1,
    "start_pref_v": 0.2,
    "limit_pref_v": 1
  },
  "training": {
    "seed": 1,
    "stop_batch": 12000000,
    "numb_test": 1,
    "disp_file": "lcurve.out",
    "disp_freq": 2000,
    "save_ckpt": "model.ckpt",
    "save_freq": 20000,
    "training_data": {
      "systems": [ 
	      
 "./data/init.000",  "./data/init.001",  "./data/init.002",  "./data/init.003",  "./data/init.004",
 "./data/init.005",  "./data/init.006",  "./data/init.007",  "./data/init.008",  "./data/init.009",
 "./data/init.010",  "./data/init.011",  "./data/init.012",  "./data/init.013",  "./data/init.014",	              "./data/init.015",  "./data/init.016",  "./data/init.017",  "./data/init.018",  "./data/init.019",
 "./data/init.020",  "./data/init.021",  "./data/init.022",  "./data/init.023",  "./data/init.024",
 "./data/init.025",  "./data/init.026",  "./data/init.027",  "./data/init.028",  "./data/init.029",
 "./data/init.030",  "./data/init.031",  "./data/init.032",  "./data/init.033",  "./data/init.034",
                "./data/init.035",  "./data/init.036",  "./data/init.037",  "./data/init.038",  "./data/init.039",
                "./data/init.040",  "./data/init.041",  "./data/init.042",  "./data/init.043",  "./data/init.044",
                "./data/init.045",  "./data/init.046",  "./data/init.047",  "./data/init.048",

                "./data/sys.000",   "./data/sys.001",   "./data/sys.002",   "./data/sys.003",   "./data/sys.004",
                "./data/sys.005",   "./data/sys.006",   "./data/sys.007",   "./data/sys.008",   "./data/sys.009",
                "./data/sys.010",   "./data/sys.011",   "./data/sys.012",   "./data/sys.013",
                "./data/sys.015",   "./data/sys.016",   "./data/sys.017",   "./data/sys.018",   "./data/sys.019",
                "./data/sys.020",   "./data/sys.021",   "./data/sys.022",   "./data/sys.023",   "./data/sys.024",
                "./data/sys.025",   "./data/sys.026",   "./data/sys.027",   "./data/sys.028",   "./data/sys.029",
                "./data/sys.030",   "./data/sys.031",   "./data/sys.032",   "./data/sys.033"

     
                 ],
      "batch_size": "auto"
    }
  }
}
0
代码
文本
[17]
os.system("cat job_dp.json")
{
    "job_name": "train",
    "command": "dp train-nvnmd train_cnn.json -s s1 && dp train-nvnmd train_qnn.json -s s2",
    "log_file": "*",
    "backward_files": [],
    "project_id": 18739,
    "platform": "ali",
    "machine_type": "c8_m32_1 * NVIDIA V100",
    "job_type": "container",
    "image_address": "registry.dp.tech/dptech/dpmd:2.2.8-cuda12.0"
}
0
代码
文本

根据job_dp.json的方式可以提交模型的训练方式,最后在nvnmd_qnn中得到model.pb文件,将可以直接用于FPGA上运行分子动力学模拟.


The training method of the model can be submitted according to the job_dp.json method, and finally the model.pb file is obtained in nvnmd_qnn, which can be directly used to run molecular dynamics simulation on FPGA.

6.2 推理 Inference

代码
文本
[18]
import os
os.chdir("/bohr/LAM-SSE-7xfp/v1/20240412-SSE/03.NVNMD/Li7P3S11-900K/")
os.system("ls")

conf.lmp
finish
in.lmp
model.pb
0
代码
文本

NVNMD的LAMMPS输入文件和常规的DPMD任务类似,只不过将in.lammps中的势函数类型由"deepmd"改为"nvnmd",输入模型是上述过程训练好的. 即:
pair_style deepmd ./com.pb \

pair_style nvnmd ./model.pb


The LAMMPS input file for NVNMD is similar to the regular DPMD task, except that the potential function type in in.lammps is changed from "deepmd" to "nvnmd", and the input model is trained by the above process. That is:
pair_style deepmd ./com.pb \

pair_style nvnmd ./model.pb

代码
文本

7. 计算效率 Efficiency

为了展示不同力场的计算精度,我们在V100和FPGA上统计了MD过程的效率,如下图

  • DPMD (smooth版本)比通用力场提升1个数量级,专用硬件FPGA提升2个数量级
  • CHGNET对计算显卡的性能要求高,容易OOM(out-of-memory)
代码
文本

代码
文本

8. 蒸馏 Distillation

代码
文本

"DPA-2模型通过在多个任务上进行预训练,学习到了广泛的化学和结构空间知识,这使得它在多种化学系统中具有出色的泛化能力。然而,这种强大的泛化能力归因于DPA-2模型大量的参数,这些参数的计算和存储需求对于实际应用来说是一个巨大的挑战。特别是在需要进行大规模或长时间分子动力学模拟的情况下,原始的DPA-2模型可能会因为计算效率低下而变得不实用。

为了解决这个问题,我们采用了模型蒸馏技术,这是一种知识迁移的方法,它允许我们将大模型中的知识和能力转移到一个更小、更高效的模型中(例如atten_layer = 0的DPA-1模型)。在这个过程中,我们首先使用DPA-2模型作为教师模型,在DFT标注的数据集上重新标签(relabel),然后用重新标注的数据集开启训练、构型探索、采样、训练的循环。这样的循环收敛得到的学生模型,具有更少的参数和更简单的结构,但它能够捕捉到教师模型的精髓,从而在保持高精度的同时显著提高计算效率。

通过模型蒸馏,我们能够充分利用DPA-2模型的强大预训练能力,同时克服了其在实际应用中的局限性。这种结合了预训练大模型在实际分子和材料模拟研究提供了一个高效且可行的方法,为未来的科学研究和工业应用开辟了新的可能性。

蒸馏技术的详细介绍也可参考:


"The DPA-2 model has learned extensive knowledge of chemical and structural space by pre-training on multiple tasks, which enables it to generalize well to a variety of chemical systems. However, this strong generalization ability is attributed to the large number of parameters of the DPA-2 model, whose computational and storage requirements are a huge challenge for practical applications. In particular, in cases where large-scale or long molecular dynamics simulations are required, the original DPA-2 model may become impractical due to its low computational efficiency.

To address this issue, we use model distillation, a method of knowledge transfer that allows us to transfer knowledge and capabilities from a large model to a smaller, more efficient model (e.g. atten_layer = 0 of DPA-1 model). In this process, we first use the DPA-2 model as the teacher model, relabel the DFT-labeled dataset, and then use the relabeled dataset to start the cycle of training, configuration exploration, sampling, and training. The student model obtained by such a cycle convergence has fewer parameters and a simpler structure, but it can capture the essence of the teacher model, thereby significantly improving the computational efficiency while maintaining high accuracy.

Through model distillation, we can fully utilize the powerful pre-training capabilities of the DPA-2 model while overcoming its limitations in practical applications. This combination of pre-trained large models provides an efficient and feasible method for practical molecular and material simulation research, opening up new possibilities for future scientific research and industrial applications.

A detailed introduction to distillation technology can also be found at:

代码
文本
[6]
import os
os.chdir("/bohr/LAM-SSE-7xfp/v1/20240412-SSE/04.Distillation/input")
os.system("tree -L 1")

.
├── 1_label.py
├── 2_random_pick.py
├── frozen_model.pth
├── init
├── input.json
├── template.lammps
├── train
├── train.json
└── train_predict

3 directories, 6 files
0
代码
文本

首先我们需要对数据集用DPA-2教师模型进行标记,注意此步的本质是DPA-2模型进行推理,因此推荐用GPU节点完成.


Firstly, we need to relabel the datasets via DPA-2 model (or "teacher model"). This step involves direct inference by DPA-2, so it is highly recommended to be conducted in GPU nodes.

代码
文本
[ ]
## 1_label.py

import dpdata
import numpy as np
import os
import glob
from deepmd.infer.deep_eval import DeepEval
from pathlib import Path
from tqdm import tqdm
from typing import List, Optional, Tuple

all_type_map = [
"Li", "B", "O", "Al", "Si", "P", "S", "Cl", "Ga", "Ge", "As", "Br", "Sn", "Sb", "I"
]

class DPPTPredict:
def load_model(self, model: Path):
self.dp = DeepEval(model)

def evaluate(self,
coord: np.ndarray,
cell: Optional[np.ndarray],
atype: List[int]
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
coord = coord.reshape([1, -1, 3])
if cell is not None:
cell = cell.reshape([1, 3, 3])
atype = atype.reshape([1, -1])
e, f, v = self.dp.eval(coord, cell, atype, infer_batch_size=1)
return e.reshape([1])[0], f.reshape([-1, 3]), v.reshape([3, 3])

def predict(self, input_path="input", output_path="output"):
for f in Path(input_path).rglob("type.raw"):
sys = f.parent
d = dpdata.MultiSystems()
mixed_type = len(list(sys.glob("*/real_atom_types.npy"))) > 0
if mixed_type:
d.load_systems_from_file(sys, fmt="deepmd/npy/mixed")
else:
k = dpdata.LabeledSystem(sys, fmt="deepmd/npy")
d.append(k)
for k in d:
for i in tqdm(range(len(k))):
cell = k["cells"][i]
if k.nopbc:
cell = None
coord = k["coords"][i]
ori_atype = k["atom_types"]
anames = k["atom_names"]
atype = np.array([all_type_map.index(anames[j]) for j in ori_atype])
e, f, v = self.evaluate(coord, cell, atype)
k.data["energies"][i] = e
k.data["forces"][i] = f
k.data["virials"][i] = v
# For configurations in DP-Gen2 only accept 1-level dir
out_dir = os.path.join(output_path, str(sys.relative_to(input_path)).replace("/", "_"))
if len(d) == 1:
d[0].to_deepmd_npy_mixed(out_dir)
else:
# The multisystem is loaded from one dir, thus we can safely keep one dir
d.to_deepmd_npy_mixed(out_dir + ".tmp")
fs = os.listdir(out_dir + ".tmp")
assert len(fs) == 1
os.rename(os.path.join(out_dir + ".tmp", fs[0]), out_dir)
os.rmdir(out_dir + ".tmp")

d = DPPTPredict()
d.load_model('frozen_model.pth')
training_data = glob.glob('train_*')
for sys in training_data:
sys_name = sys.split('_')[1]
print(sys_name)
d.predict(f'train_{sys_name}/', f'train_{sys_name}_predict')
代码
文本

接下来,我们在用教师模型标注好的数据中,随机挑选100个结构作为MD探索的初始构型


Next, we randomly pick 100 frames among relabeled datasets for initial MD exploration.

代码
文本
[ ]
## 2_random_pick.py

import random
import dpdata
import glob

n_select = 100
m = dpdata.MultiSystems()
datasets = glob.glob('train_*_predict')
for dataset in datasets:
sys_name = dataset.split('_',3)[1]
m.load_systems_from_file(dataset, fmt="deepmd/npy/mixed")
if m.get_nframes() <= n_select:
os.symlink(dataset, f"init_{sys_name}")
else:
ratio = n_select / m.get_nframes()
new = dpdata.MultiSystems()
for s in m:
n = int(len(s)*ratio)
if random.random() < len(s)*ratio - n:
n += 1
if n > 0:
new.append(s.sub_system(random.sample(range(len(s)), n)))
new.to_deepmd_npy_mixed(f"init_{sys_name}")
代码
文本

可以看到当前目录下还准备了两个json文件和一个lammps的模板文件,受篇幅所限未在代码块中直接展示。

  • input.json是DPGEN2直接的输入文件

  • train.json则是训练的模板文件。必须注意的是,在iter-0训练时,训练参数由train.json控制,而iter-1及后续的循环则由input.json中设置的训练参数所控制

  • template.lammpsMD构型探索的模板文件

在使用dpgen2命令提交蒸馏工作流时,为了便于后续的管理和回溯,建议将任务的ID和UID信息输出到一个日志文件中,例如dpgen2.log。此处为了保持Notebook的整洁性,采用直接输出的方式展示。


You can see that two json files and a lammps template file are prepared in the current directory. Due to space limitations, they are not directly displayed in the code block.

  • input.json is the direct input file of DPGEN2

  • train.json is the template file for training. It must be noted that during iter-0 training, the training parameters are controlled by train.json, while iter-1 and subsequent cycles are controlled by the training parameters set in input.json

  • template.lammps is the template file for MD configuration exploration

代码
文本
[ ]
# !dpgen2 submit input.json
代码
文本

可以使用以下命令来监控dpgen2任务的执行状态: https://bohrium.dp.tech/notebooks/49748212168

请注意,对于不同状态的工作流,访问方式略有不同:

  • 对于已经被归档的工作流,您需要使用UID来访问。
  • 对于正在运行的工作流,您应该使用ID来访问。
  • 对于已经完成计算但尚未归档的工作流,您可以使用ID或UID中的任意一个来访问。

You can use the following command to monitor the execution status of the dpgen2 task: https://bohrium.dp.tech/notebooks/49748212168

Please note that the access method is slightly different for workflows in different states:

  • For workflows that have been archived, you need to use the UID to access.
  • For workflows that are running, you should use the ID to access.
  • For workflows that have completed calculations but have not been archived, you can use either the ID or the UID to access.
代码
文本
[ ]
# !dpgen2 status input.jsn <ID/UID>
代码
文本
[ ]
# !dpgen2 download input.json <ID/UID> -p downloads -i <iteration_num> -d prep-run-train/output/models
代码
文本

我们在先前已经完成的目录下展示用上述download命令得到的结果,可以看到此蒸馏任务在iter-000001就收敛了,iter-000001子目录下frozen_model.pb即为蒸馏得到的模型,可以用于压缩、后续的分子动力学模拟等任务


We show the results obtained by using the above download command in the previously completed directory. We can see that this distillation task converges in iter-000001. The frozen_model.pb in the iter-000001 subdirectory is the distilled model, which can be used for compression, subsequent molecular dynamics simulation and other tasks.

代码
文本
[4]
import os
os.chdir("/bohr/LAM-SSE-7xfp/v1/20240412-SSE/04.Distillation/finished")
os.system("tree ")

.
└── downloads
    ├── iter-000000
    │   └── prep-run-train
    │       └── output
    │           └── models
    │               ├── done
    │               ├── task.0000
    │               │   └── frozen_model.pb
    │               ├── task.0001
    │               │   └── frozen_model.pb
    │               ├── task.0002
    │               │   └── frozen_model.pb
    │               └── task.0003
    │                   └── frozen_model.pb
    └── iter-000001
        └── prep-run-train
            └── output
                └── models
                    ├── done
                    ├── task.0000
                    │   └── frozen_model.pb
                    ├── task.0001
                    │   └── frozen_model.pb
                    ├── task.0002
                    │   └── frozen_model.pb
                    └── task.0003
                        └── frozen_model.pb

17 directories, 10 files
0
代码
文本

9. 总结 Summary

基于硫族化合物固态电解质的基本物质组成,我们训练了一个DPA预训练模型.相比于通用力场(CHGNET、M3GNET),DPA模型对能量和受力的预测精度更高, 能更准确预测固态电解质的动力学性质(如扩散系数和离子电导率).

基于现有模型,可以研究固态电解质的更多性质.

  • 对于训练中覆盖的硫族化合物体系, 可以拿训练好的模型直接用于MD模拟,节省相关时间/算力成本

  • 对于新的固态体系,可基于当前的预训练模型进一步生产数据(续跑dpgen/dpgen2),可复用数据集中相关的DFT单点计算设置,可以节省采样周期和成本.

  • 如果想进一步调优(finetune),比如引用更高精度的泛函(HSE06, SCAN),可以参考dpa2 finetune相关功能, notebook: https://bohrium.dp.tech/notebooks/62585747598

目前大模型聚焦在块体材料上,未来我们将进一步拓展到块体材料的掺杂,界面体系等,丰富势函数模型. 同时,我们非常欢迎用户一起分享数据,共同打造固态电解质预训练大模型.感兴趣可以联系作者:石孟超(邮箱:mchao_shi@hnu.edu.cn, shimengchao@dp.tech

模型评测和相关数据模型信息汇总如下,供大家使用参考.


Based on the basic material composition of chalcogenide solid electrolytes, we trained a DPA pre-trained model. Compared with general force fields (CHGNET, M3GNET), the DPA model has higher prediction accuracy for energy and force, and can more accurately predict the kinetic properties of solid electrolytes (such as diffusion coefficient and ionic conductivity).

Based on the existing model, more properties of solid electrolytes can be studied.

  • For the chalcogenide systems covered in the training, the trained model can be directly used for MD simulation to save relevant time/computing cost

  • For new solid systems, data can be further produced based on the current pre-trained model (continue to run dpgen/dpgen2), and the relevant DFT single-point calculation settings in the data set can be reused, which can save sampling cycles and costs.

  • If you want to further tune (finetune), such as citing higher-precision functionals (HSE06, SCAN), you can refer to the dpa2 finetune related functions, notebook: https://bohrium.dp.tech/notebooks/62585747598

Currently, the large model focuses on bulk materials. In the future, we will further expand to the doping of bulk materials, interface systems, etc., and enrich the potential function model. At the same time, we welcome users to share data and jointly build a solid electrolyte pre-training large model. If interested, please contact the author: Shi Mengchao (email: mchao_shi@hnu.edu.cn, shimengchao@dp.tech)

The model evaluation and related data model information are summarized as follows for your reference.

代码
文本
双击即可修改
代码
文本
Deep Learning
notebook
AI4S
Deep LearningnotebookAI4S
已赞8
本文被以下合集收录
ML-PES
bohr4a0048
更新于 2024-09-10
6 篇0 人关注
DEEPMD
bohrb1cdbc
更新于 2024-08-25
12 篇0 人关注
推荐阅读
公开
AI+电芯 | 基于LSTM和GRU模型的SOH预测¶
AI+电芯中文锂电池
AI+电芯中文锂电池
JiaweiMiao
发布于 2023-09-14
2 赞2 转存文件
公开
DPMD培训-电池专题-有机电解液副本
DPMD
DPMD
微信用户2Bnk
更新于 2024-07-24
1 赞1 转存文件
评论
 ## 9. 总结 Summary 基于...

longkunxu

04-18 04:23
感谢分享,请问要复现该实验的模型训练部分,dp环境从哪里获得?之前尝试过deepmd-kit v3但是目前DPA-2好像还无法直接用。也参考过https://zenodo.org/doi/10.5281/zenodo.10428497,但是里面好像也没有详细的教程,谢谢

shimengchao@dp.tech

作者
05-01 23:00
回复 longkunxu 训练部分,会有bohrium镜像文件(job.json),大家可以直接在bohrium平台调用. 如果在本地,需要配置一下相关环境
评论