[TOC]

系统设置:

  1. 修改 ~/.bashrc,末尾添加,每次登陆会自动运行:
1
2
source /home/apps/script/vasp.sh
source /home/apps/script/ase.sh
  1. 修改 ~/.bash_profile,末尾添加,把脚本文件添加到路径
1
export PATH=$PATH:/home/zhouzm/mysh
  1. mysh目录下脚本:
1
2
batch_vasp_normal  cl_vaspfile        _runvasp_mynpar   test.sh
batch_vasp_npar getmypbe _runvasp_mysmall getmyenergy batch_vasp_small _runvasp_mynormal test2.sh getmyfrenquency

各个脚本简介:

getmypbe

1
2
自动获取POSCAR第一行,添加POTCAR
# 必须是ase保存的,VESTA保存的POSCAR第一行不是元素符号

_runvasp_mynormal

1
2
3
4
5
6
使用方法:
_runvasp_mynormal jobname(自己随便写)
默认参数设置:
0 "IBRION != 777"
Enter VASP build 0 for standard
normal 节点

_runvasp_mysmall

1
2
3
4
5
6
使用方法:
_runvasp_mynormal jobname(自己随便写)
默认参数设置:
0 "IBRION != 777"
Enter VASP build 0 for standard
small 节点

_runvasp_mynpar

1
2
3
4
5
_runvasp_mynpar jobname(自己随便写)
默认参数设置:
0 for default
Enter VASP build 0 for standard
small 节点

批量提交:batch_vasp_normal,batch_vasp_small,batch_vasp_npar

1
2
3
4
5
6
7
8
batch_vasp_normal采用_runvasp_mynormal提交,其他类似
使用方法:
batch_vasp_normal opt-c111-ts2-h2coo opt-c111-ts4-h-h2co ...
# 任务名称使用文件夹名字
opt-c111-ts2-h2coo:目录下面可以没有POTCAR,会使用getmypbe自动获取。
normal:提交到normal节点
small:是提交到small节点
npar: 计算频率

cl_vaspfile

1
# 删除当前目录下文件,保留输入文件POSCAR INCAR KPOINTS POTCAR

getmyenergy

1
2
3
4
使用方法:
getmyenergy opt-c111-ts2-h2coo opt-c111-ts4-h-h2co ...
# 没有添加检测相关OUTCAR是否正确结束在获取能量,没有输出正常结束信息为异常结束
获取OUTCAR 的能量,并保存到 ENERGYFILE 文件中

getmyfrenquency

1
2
3
4
使用方法:
getmyfrenquency opt-c111-ts2-h2coo opt-c111-ts4-h-h2co ...
# 读取OUTCAR的频率信息,并保存到 FREQUENCYFILE 文件中,终端输出虚频和零点能
# FREQUENCYFILE 不保存虚频,频率按行输出,以逗号隔开

ase-gui

1
2
ase-gui CU.cif -o Cu.poscar
ase convert Cu.cif Cu.poscar

批量获取POTCAR, POSCAR,cif

1
2
3
4
5
6
7
8
9
#!/bin/env bash
FILENAMELIST=$@
for file in $FILENAMELIST
do
cd $file
getmypbe
# ase convert Cu.cif Cu.poscar #ase-gui POSCAR/CONTCAR -o Cu.cif
cd ../
done

直接修改源文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/env bash
FILENAMELIST=$@
for file in $FILENAMELIST
do
cd $file
cp POSCAR old_POSCAR
sed -i '$a 6.8920794341203466 8.2498237913018961 10.6854462174986473' POSCAR
# POSCAR 最后一行后添加新行‘6.8920794341203466 8.2498237913018961 10.6854462174986473’
# sed -i 's/\.$/\!/g' #.结尾的,换成!结尾
sed -i '/In/s/$/ H/' POSCAR # 行中有 In的 末尾插入 H
# sed -i '/32/s/$/ 1/' POSCAR # 行中有 32的 末尾插入 1
sed -i '6s/$/ 1/' POSCAR # 第六行末尾插入 1
sed -i '/NPAR/d' INCAR # 行中有NPAR 则删除 该行
cd ../
done
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/env python3.7
# Perceptron algorithm
import numpy as np


def perceptron(X, y, eta=1, max_step=100000):
"""
X : feature array contain intercept
y: lables 0 or 1
eta: step length
max_step: maximum iterations

"""


n, d = X.shape # array shape , n rows d columns
w = np.zeros(d) # initial weights assigned to the features
step = 0 # initial iteration step
row = 0 # initial from first row of X
while step < max_step: # 判断是否到达最大迭代次数
if np.sign(X[row, :].dot(w) * (y[row]-0.5)) <=0: # 判断第i行是否分类正确
step += 1 # step+1
w += eta * y[row] * X[row, :] # 更新weights
if row == n: # 检测是否到最后一行,是的话从第一行开始
row = 0
if np.sum((X.dot(w) == y)) == n: # 判断是否全部分类正确,是则终止循环
break
return w # 返回 weights

# decision tree
import matplotlib.pyplot as plt
import pandas as pd
from sklearn import tree
import numpy as np

data = pd.read_csv('classfication-regression.csv')
data_coloums_name = data.columns.tolist()

#!/bin/env python3.7
# DecisionTreeClassifier

def Tree_test():

data_x = data[['H-In', 'coord', 'O_v', 'bi-HCOO', 'H_2COO', 'CH_2O']]
data_y = data['ts2-c']
clf = tree.DecisionTreeClassifier(max_depth=1)
clf = clf.fit(data_x, data_y)

import graphviz
dot_data = tree.export_graphviz(clf, out_file=None,
feature_names=['H-In', 'coord', 'O_v', 'bi-HCOO', 'H_2COO', 'CH_2O'],
class_names=['TS3', 'TS2'],
filled=True, rounded=True,
special_characters=True)
graph = graphviz.Source(dot_data)
graph.render("ts2-c")
graph.view()