forked from Tonner-Zech-Group/VASP-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc-deformation-density.sh
executable file
·75 lines (65 loc) · 1.31 KB
/
calc-deformation-density.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Three arguments: AB folder, A folder, B folder
set -e
function split_convert() {
pwd
if [ -f "$1".cube ]; then
echo "$1.cube exists, skipping CHGCAR conversion!"
else
echo "Converting CHGCAR to $1.cube."
chgcar2cube.py CHGCAR -o "$1" -v --volume
echo "... done."
fi
}
#check number of args
if [ "$#" -ne 3 ]; then
echo "I need 3 arguments!"
exit 1
fi
#loop over args
for var in "$@"
do
if [ ! -d "$var" ]; then
echo "$var is not a directory"
exit 1
fi
done
root=${PWD}
one=${1##*/}
if [ -z "$one" ]; then
one="AB"
fi
echo "$one"
cd "$1"
pwd
split_convert "$one"
cd "$root"
two=${2##*/}
if [ -z "$two" ]; then
two="A"
fi
echo "$two"
cd "$2"
split_convert "$two"
cd "$root"
three=${3##*/}
if [ -z "$three" ]; then
three="B"
fi
echo "$three"
cd "$3"
split_convert "$three"
cd "$root"
echo "Calculating Total Deformation Density."
#A+B
sumCube.py -f "$2"/"$two".cube "$3"/"$three".cube -o tmp.cube
#AB-(A+B)
sumCube.py -f "$1"/"$one".cube tmp.cube -o deformation_density.cube --subtract
rm tmp.cube
echo "Calculating Magnetization Deformation Density."
#A+B
sumCube.py -f "$2"/"${two}"_mag.cube "$3"/"${three}"_mag.cube -o tmp.cube
#AB-(A+B)
sumCube.py -f "$1"/"${one}"_mag.cube tmp.cube -o deformation_density_mag.cube --subtract
rm tmp.cube
echo "Done!"