HyperAI

Using VASP for Machine Learning Force Field Training

Vienna Ab initio Simulation Package (The VASP Manual – VASP Wiki) is a computer program for atomic-scale material modeling from first principles, such as electronic structure calculations and quantum mechanical molecular dynamics.

Machine learning force fields used in conjunction with ab initio molecular dynamics (MD)Category:Machine-learned force fields – VASP Wiki), which can capture the underlying physical mechanisms from first principles while still enabling long simulations at a relatively low computational cost. Typically, a single ab initio molecular dynamics step is computationally expensive due to the need for quantum mechanical treatment of electrons, such as in the framework of density functional theory (DFT). In fully classical molecular dynamics calculations, force fields are used instead of DFT to calculate the forces acting on each atom. These interatomic potentials are traditionally based on experimental observations and incorporate known forces (such as van der Waals forces, electrostatic charge interactions, etc.) through empirical methods. Therefore, the quality of the force field depends on how well the interactions in a specific system are understood. VASP provides real-time machine learning force fields to address the above two issues.

Tutorial Content

In this tutorial, we will take silicon crystal as an example and demonstrate how to train the vasp machine learning force field through NpT ensemble molecular dynamics. Through this tutorial, you will learn the basic process of machine learning force field training:

  1. Preparing molecular dynamics input files
  2. Change molecular dynamics and machine learning parameters according to actual conditions
  3. Start training
  4. Simple verification of machine learning force fields by calculating phonon spectra

Input File

The input file contains

├── dft_phonon (DFT 参考声子谱文件)
│  
├── ml_phonon (机器学习力场计算声子谱)
|   ├── run.sh (计算脚本)
|   :     :     (其他文件省略)
|   :     :
|
├── mltrain_train (机器学习力场训练输入文件)
│   ├── INCAR (vasp 设置文件)
│   ├── KPOINTS (K 点文件)
│   ├── POSCAR (硅结构文件)
│   
|
└── t.py 声子谱绘制文件

Here we will only explain the input files for training machine learning force fields.

INCAR

SYSTEM = Si16
ISYM   = 0        ! 不考虑对称性

! ab initio
PREC   = Normal !正常精度
IVDW   = 11     !范德华修正

ISMEAR = 0     ! 费米占据
SIGMA  = 0.02  ! 费米展宽

ENCUT  = 300   !波函数截断
EDIFF  = 1e-5  !计算精度

LWAVE  = F    !不保留波函数
LCHARG = F    !不保留电荷文件
LREAL  = F    !不做实空间投影计算

! MD
IBRION = 0        ! 进行分子动力学计算
NSW    = 500    ! 分子动力学步数
POTIM  = 5.0      ! 分子动力学时间间隔 5fs

#NpT 系综分子动力学设置
MDALGO = 3                ! 郎之万温控方法
LANGEVIN_GAMMA   = 5      ! 原子扰动系数
LANGEVIN_GAMMA_L = 10     ! 晶格扰动系数
PMASS  = 10               ! 晶格质量
TEBEG  = 400              ! 初始温度为 400
ISIF   = 3        ! 

! machine learning
ML_LMLFF  = T
ML_ISTART = 0  !进行机器学习力场训练
ML_WTSIF  = 2

#随机数种子
RANDOM_SEED =         688344966                0                0

POSCAR

16 Atomic Supercell

Si16
1.0
-5.468728 -5.468728 0.000000
-5.468728 0.000000 -5.468728
-0.000000 -5.468728 -5.468728
Si
16
direct
0.125000 0.125000 0.125000 Si
0.125000 0.125000 0.625000 Si
0.125000 0.625000 0.125000 Si
0.125000 0.625000 0.625000 Si
0.625000 0.125000 0.125000 Si
0.625000 0.125000 0.625000 Si
0.625000 0.625000 0.125000 Si
0.625000 0.625000 0.625000 Si
0.250000 0.250000 0.250000 Si
0.250000 0.250000 0.750000 Si
0.250000 0.750000 0.250000 Si
0.250000 0.750000 0.750000 Si
0.750000 0.250000 0.250000 Si
0.750000 0.250000 0.750000 Si
0.750000 0.750000 0.250000 Si
0.750000 0.750000 0.750000 Si

KPOINTS

Not only Gamma point
 0
Gamma
 2 2 2
 0 0 0

POTCAR

The pseudopotential combination of the corresponding elements in the system, here is the pseudopotential of Si

Getting Started

1. Clone the container

Find the tutorial working directory and clone the container

2. Set up the container

Select 4090 — Pay as you go — vasp 6.3.0-cuda11.8 — Workspace

1

After loading, open the workspace

2

Open Terminal

3

Enter the directory

cd mltrain_train

Upload the prepared silicon pseudopotential, which can be usedOfficial website examplePut the pseudopotential POTCAR in the directory

4

3. Install the phonopy environment

conda install -c conda-forge phonopy

Then enter y and press Enter to agree to the installation

4. Training the Machine Learning Force Field

Run vasp directly

mpirun -n 1 vasp_std


After the run is completed, the trained machine learning force field file ML_FFN will appear on the left.

5

5. Simple verification of force field availability by calculating phonon spectrum

Copy the force field file and POTCAR to the phonon spectrum calculation folder.

cp ML_FFN  ../ml_phonon/ml/ML_FF
cp POTCAR ../ml_phonon/ml/
cd ../ml_phonon/

Activate the phonopy environment and run the script run.sh for calculation

chmod 777 *.sh
./run.sh

Return to the previous level and run the python script t.py to draw a phonon spectrum comparison chart

python t.py
8

It can be seen that since our molecular dynamics steps are only 500, the final phonon spectra of the two are quite different. Therefore, if you want to get better results, you can increase the number of molecular dynamics steps in INCAR and improve the calculation accuracy during training.