iosv.sh
Code:
#!/bin/bash
#The script is designed to iteratively optimize the structure for vasp
#lixin, University of science & technology Beijing
#s20180318@xs.ustb.edu.cn
#Copyright © 2019, lixin.fun. All rights reserved.
j=1
echo "running $j optimization."
mpirun -n $1 vasp > $2
while true
do
i=$(grep 'reached required accuracy' OUTCAR)
if [ "$i" = " reached required accuracy - stopping structural energy minimisation" ]
then
echo "Congratulation! your calculation has been finised!"
break
else
let j=j+1
echo "running $j optimizations."
mv CONTCAR POSCAR -f
rm -rf CHG CHGCAR CONTCAR DOSCAR EIGENVAL IBZKPT OSZICAR OUTCAR PCDAT REPORT vasprun.xml WAVECAR XDATCAR
mpirun -n $1 vasp > $2
fi
done
Instruction:
sh iosv.sh cores text
cores : the numbers of cores to calculate
text: the file to save the process of calculation
mem.sh
Code:
#!/bin/bash
#The script is designed to release memory for vasp
#lixin, University of science & technology Beijing
#s20180318@xs.ustb.edu.cn
#Copyright © 2019, lixin.fun. All rights reserved.
while true
do
i=$(grep 'reached required accuracy' OUTCAR)
if [ "$i" = " reached required accuracy - stopping structural energy minimisation" ]
then
echo "Calculation has been finished!"
break
else
mem=$(awk '/MemTotal/{total=$2}/MemFree/{free=$2}/Buffers/{buffers=$2}/^Cached/{cached=$2}END{print (total-free-buffers-cached)/1024/1024}' /proc/meminfo | cut -f1 -d".")
if [ "$mem" -gt "$1" ]
then
process_id=($(ps -ef | grep vasp | grep -v "grep" | awk '{print $2}'))
if [[ ! -z "$process_id" ]]
then
for proid in ${process_id[*]}
do
kill -9 $proid
done
sleep 10s
fi
fi
fi
sleep 2s
done
Instruction:
sh mem.sh max_rom
max_rom : maximum memory size (GB)
You should set a smaller value than the actual memory size.
Comments