MLIP-3主动机器学习方法探索

INPUT文件

此文件中包含15个文件,逐个分析他们的功能

Cu_1620.data:LAMMPS的初始文件需要搭配in文件一起使用
README.md:解释文件,解释各个文件的功能以及操作流程
VASP/:文件夹
auto.sh:执行最主要的文件
coord.py
fill_with_vacuum.py
in.my:LAMMPS的初始文件需要搭配data文件一起使用
init.almtp
md_al_mtp.sh
pot_save/
pre_train.sh
run_lammps.sh
select.sh
train.sh
train_one.cfg

VASP/文件夹(里面的文件就是满足完成一个POSCAR的AIMD模拟)

 INCAR
 KPOINTS
 POTCAR
 README.md
 run_vasp.sh:提交任务的脚本文件
 sub.sh:提交脚本任务的脚本

auto.sh

#!/bin/bash  # 指定该脚本使用的解释器为 Bash。

cp init.almtp curr.almtp 
cp train_one.cfg train.cfg
cp Cu_1620.data dump.trj

is_training_finished=0

sbatch -J pre_train -o pre_train.out -e pre_train.err  -N 1 --exclusive -p high,MMM ./pre_train.sh --time=3:00:00 
#用于在Slurm作业调度系统中提交一个作业,并运行名为pre_train.sh的脚本。
#这个脚本的功能就是进行一次主动学习势能训练,用上面三个文件

while [ $is_training_finished -ne 1 ]
do
    sleep 5
    if [ -f is_training_finished.txt ]; then
        is_training_finished=1
        echo $is_training_finished
    else
        is_training_finished=0
        echo $is_training_finished
    fi
done
sleep 5
rm -f *.txt

#判断上面的训练是否完成,并重置


for p in $(seq 1621 3000)
do
        echo "# LAMMPS data file written by OVITO Basic 3.7.11" > Cu_${p}.data
        echo "${p} atoms" >> Cu_${p}.data
        prev=$((${p}-1))
        cat Cu_${prev}.data | tail -n +3 | head -n 11 >> Cu_${p}.data
        cat dump.trj | tail -n ${prev} >> Cu_${p}.data
        python coord.py $p
#更新原子坐标信息
        echo "active learning with ${p} atoms is starting"
        ./md_al_mtp.sh
#执行一系列操作
        cp dump.trj pot_save/
        cp train.cfg pot_save/
        cd pot_save
        mv dump.trj dump_${p}.trj
        mv train.cfg train_${p}.cfg
        cp curr.almtp curr_${p}.almtp
        cd ../
        cp pot_save/curr.almtp .
done

md_al_mtp.sh

#!/bin/bash
          
source ~/.bashrc
n_cores=$1
rm -f preselected.cfg.*
rm -f preselected.cfg
rm -f selected.cfg
rm -f nbh.cfg
rm -f *.txt
while [ 1 -gt 0 ]
do
cp curr.almtp pot_save/
touch preselected.cfg
is_lammps_finished=0
sbatch -J lammps -o lammps.out -e lammps.err  -N 1 -n 16 -p high,MMM ./run_lammps.sh
while [ $is_lammps_finished -ne 1 ]
do
    sleep 5
    if [ -f is_lammps_finished.txt ]; then
        is_lammps_finished=1
        echo $is_lammps_finished
    else
        is_lammps_finished=0
        echo $is_lammps_finished
    fi
done
sleep 5
cat preselected.cfg.* >> preselected.cfg
rm -f preselected.cfg.*
n_preselected=$(grep "BEGIN" preselected.cfg | wc -l)
is_selection_finished=0
if [ $n_preselected -gt 0 ]; then
    echo "selection"
    sbatch -J selection -o selection.out -e selection.err  -N 1 -n 1 -p bigmem ./select.sh
    while [ $is_selection_finished -ne 1 ]
    do
        sleep 5
        if [ -f is_selection_finished.txt ]; then
            is_selection_finished=1
            echo $is_selection_finished
        else
            is_selection_finished=0
            echo $is_selection_finished
        fi
    done
    sleep 5
    if test -f selected.cfg; then
        echo " selected.cfg exists"
    else
        echo "selected.cfg not exist"
        exit
    fi
    rm -f preselected.cfg
    ./mlp cut_extrapolative_nbh selected.cfg nbh.cfg --cutoff=8 
    ./mlp convert nbh.cfg POSCAR --output_format=poscar 
    rm -f selected.cfg
    n_poscar=$(grep "BEGIN" nbh.cfg | wc -l)
    n_poscar_prev=$((${n_poscar}-1))
    if [ $n_poscar -eq 1 ]; then
        mv POSCAR POSCAR0
    fi
    for p in $(seq 0 ${n_poscar_prev})
    do
        python fill_with_vacuum.py $p
    done
    for ((i=0; i<$n_poscar; i++))
    do
        cp POSCAR_output"$i" VASP/
        mkdir -p VASP/"$i"
        if [ $n_poscar -eq 1 ]; then
            mv VASP/POSCAR_output"$i" VASP/0/POSCAR
        elif [ $n_poscar -gt 1 ]; then
            mv VASP/POSCAR_output"$i" VASP/"$i"/POSCAR
        fi
        cp VASP/POTCAR VASP/"$i"/
        cp VASP/INCAR VASP/"$i"/
        cp VASP/KPOINTS VASP/"$i"/
        cp VASP/run_vasp.sh VASP/"$i"/
        cp VASP/sub.sh VASP/"$i"/
    done
    for ((i=0; i<$n_poscar; i++))
    do
        cd VASP/"$i"
        sbatch ./run_vasp.sh
	cd ../../
    done
    is_vasp_finished=0
    while [ $is_vasp_finished -ne 1 ]
    do
        sleep 5
        n_vasp_finished=$(grep -rH "1" VASP/*/is_vasp_finished.txt | wc -l)
        if [ $n_poscar -eq $n_vasp_finished ]; then
            is_vasp_finished=1
            echo $is_vasp_finished
        else
            is_vasp_finished=0
            echo $is_vasp_finished
        fi
    done
    sleep 5
    for ((i=0; i<$n_poscar; i++))
    do
        ./mlp convert VASP/"$i"/OUTCAR VASP/"$i"/calculated.cfg --input_format=outcar #--elements_order=29 --absolute_elements
	cat VASP/"$i"/calculated.cfg >> train.cfg
        rm -r VASP/"$i"/
    done
    is_training_finished=0
    sbatch -J train -o train.out -e train.err  -N 1 --exclusive -p high,MMM ./train.sh --time=3:00:00
    while [ $is_training_finished -ne 1 ]
    do
        sleep 5
        if [ -f is_training_finished.txt ]; then
            is_training_finished=1
            echo $is_training_finished
        else
            is_training_finished=0
            echo $is_training_finished
        fi
    done
    sleep 5
    rm -f nbh.cfg
    rm *.txt
    rm POSCAR*
    rm -f nbh_36.cfg    
elif [ $n_preselected -eq 0 ]; then
    exit
fi


done

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值