HyperAI

VASP Machine Learning Force Field Fine-tuning

Vienna Ab initio Simulation Package (VASP: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 FieldCategory:Machine-learned force fields – VASP Wiki) can be used in conjunction with ab initio molecular dynamics (MD) to capture the underlying physical mechanisms from first principles while 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 density functional theory (DFT) framework. 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 the degree of knowledge of the interactions in a specific system. VASP provides real-time machine learning force fields to address the above two issues.

Tutorial Content

In this tutorial, we will generate a series of corresponding phonon spectra by continuously changing the machine learning hyperparameters, and obtain the corresponding optimal machine learning force field parameter files. Through this tutorial, you will understand the following VASP machine learning hyperparameters:

ML_IWEIGHT # weight selection mode
ML_WTSIF # weight coefficient
ML_WTOTEN # total energy weight coefficient
ML_WIFOR # force weight coefficient
ML_SIGW0 # fitting step accuracy
ML_RCUT1 # Radial cutoff distance
ML_RCUT2 # angle cutoff distance
ML_EPS_LOW # fitting accuracy

By adjusting the parameters appropriately, we will eventually get results that are almost identical to those of the DFT.

12

Input File

├── dft_phonon
│ ├── band.yaml (DFT reference phonon spectrum)
├── ml_phonon (machine learning phonon spectrum calculation folder)
├── refit (fine-tune folder)
│ ├── INCAR
│ ├── KPOINTS
│ ├── ML_AB
│ ├── POSCAR
│ ├── POTCAR
│ ├── clean.sh
│ └── run.sh
├── t.py

This tutorial only focuses on the input files in the ~/refit folder

run.sh

#进行机器学习拟合
mpirun -n 1 vasp_std
#将力场参数文件转移到声子计算文件夹中
cp ML_FFN ../ml_phonon/ml/ML_FF
#进行声子机器学习计算
cd ../ml_phonon/
chmod 777 *.sh
./run.sh
cd ../
#绘制对比图
python t.py

INCAR machine learning fitting setup

SYSTEM = Si

IVDW   = 11     #范德华力
ISMEAR = 0      #费米展宽
SIGMA  = 0.02  #展宽

LWAVE  = F #不保留波函数
LCHARG = F #不保留电荷


IBRION = 0      #MD (treat ionic degrees of freedom)
NSW    = 1       #机器学习需要设置成 1
POTIM  = 1      #MD time step in fs
ISIF   = 3          #

# 机器学习
ML_LMLFF  = T        #启用机器学习力场
ML_ISTART  = 3       #重新拟合模式(微调模式)
ML_IWEIGHT = 3       #权重选取模式
ML_WTSIF  = 1        #权重系数
ML_WTOTEN = 1        #总能权重系数
ML_WIFOR =  1        #力权重系数
ML_SIGW0 = 1E-20   #拟合步长精度
ML_RCUT1 = 8.         #径向截断距离
ML_RCUT2 = 6.         #夹角截断距离
ML_EPS_LOW = 1E-20 #拟合精度
ML_MB = 5000      #运行内存设置

KPOINTS (not used when machine learning is enabled, just set one)

K-Spacing Value to Generate K-Mesh: 0.040
0
Gamma
   4   4   4
0.0  0.0  0.0

POSCAR

For the supercell size of machine learning training, please refer to the tutorial:Using VASP for machine learning force field training

POTCAR

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

ML_AB

This is the molecular dynamics data corresponding to the system calculated in advance. For the specific training process, please refer to the tutorial:Using VASP for machine learning force field training, then rename ML_ABN to ML_AB, where the molecular dynamics data of Si has been prepared in advance.

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

2

After loading, open the workspace

3

Open Terminal

4

Enter the refit folder

cd refit

Upload the prepared silicon pseudopotential, here you can use "Official website example"The pseudopotential POTCAR in this paper.

Put POTCAR in the directory and copy it to ml_phonon/ml

cp POTCAR ../ml_phonon/ml/
5

3. Install the phonopy environment

conda install -c conda-forge phonopy

Then enter y and press Enter to agree to the installation

6

4. Run the script

chmod 777 *.sh

./run.sh

5. Fine-tune parameters

View the file ml.png

7

Go back to the refit folder, change the weight mode to ML_IWEIGHT = 2, and run the script again to see the results.

8

You can see that the results are even worse. Go back and change the weight mode ML_IWEIGHT = 1 and observe the results again.

9

A comprehensive comparison shows that the results of 1 and 3 are similar, and 1 even has better details (optical support). Next, we will make improvements under the condition of ML_IWEIGHT = 1.

We try to increase the precision of the fitted force alone, by making ML_WIFOR smaller.

10

We find that the change is not significant, which suggests that we should try increasing the cutoff distance to allow more room for fitting.

11

As you can see, the result is worse (optical support), which means that the parameter space is too large and the extreme point found is not the minimum point. We should reduce the truncation distance instead.

12

After changing the parameters and rerunning, we finally obtained the machine learning force field parameters that can generate the same phonon spectrum as DFT.