-
Notifications
You must be signed in to change notification settings - Fork 7
/
Electronic.sh
executable file
·274 lines (244 loc) · 8.31 KB
/
Electronic.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/usr/bin/env bash
function argparse {
while getopts ":d:mfn:" opt; do
case $opt in
d)
directory_name=$OPTARG
;;
m)
is_submit=true
;;
f)
is_override=true
test_tag='-f'
;;
n)
nband=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
}
function does_directory_exist {
if [[ -d "$directory_name" ]]; then
cd "$directory_name"
elif [[ "$current_directory" == "$directory_name"* ]]; then
echo "You are already in $current_directory/."
directory_name="$current_directory"
else
echo "$directory_name/ does not exist!"
exit 1
fi
}
function subdirectory_check {
if [[ -d "$subdir_name" && $(ls -A "$subdir_name") && -z $is_override ]]; then
echo "$directory_name/$subdir_name/ contains files. Escaping..."
exit 1
fi
}
directory_name=electronic
current_directory=${PWD##*/}
if [[ "$1" == */ ]]; then subdir_name=${1%/}; else subdir_name=$1; fi
test_type="${subdir_name%%_*}"
test_type2=$2
shift 1
if [[ "$test_type" == prepare ]]; then
argparse "$@"
mkdir $directory_name 2> /dev/null
cd $directory_name
if [[ -d INPUT && $(ls -A INPUT) ]]; then
echo -n "INPUT/ contains files. "
if [[ $is_override ]]; then
echo "Overriding..."
else
echo "Escaping..."
exit 1
fi
fi
cp -r ../INPUT .
# sed -i "/PREC/c PREC = Accurate" INPUT/INCAR
# sed -i "/NSW/c NSW = 0" INPUT/INCAR
sed -i "/LCHARG/c LCHARG = .TRUE." INPUT/INCAR
sed -i "/LMAXMIX/c LMAXMIX = 4" INPUT/INCAR
sed -i "/NPAR/c NPAR = 8" INPUT/INCAR
sed -i "/#PBS -l walltime/c #PBS -l walltime=03:00:00" INPUT/qsub.parallel
sed -i "/#PBS -l nodes/c #PBS -l nodes=1:ppn=8" INPUT/qsub.parallel
elif [[ "$test_type" == scrun ]]; then
argparse "$@"
does_directory_exist
subdirectory_check
Prepare.sh "$subdir_name" $test_tag
cd scrun
[[ $is_submit ]] && qsub qsub.parallel
elif [[ "$test_type" == dosrun ]]; then
argparse "$@"
does_directory_exist
subdirectory_check
Prepare.sh "$subdir_name" $test_tag
cd dosrun
if [[ -f CHGCAR ]]; then
echo "Found CHGCAR under $directory_name/$subdir_name/. Will use it."
sed -i "/ICHARG/c ICHARG = 11" INCAR
elif [[ -f ../scrun/CHGCAR && -f ../scrun/CONTCAR ]]; then
echo "Found CHGCAR and CONTCAR under $directory_name/scrun/. Will use them."
cp ../scrun/CONTCAR POSCAR
cp -l ../scrun/CHGCAR .
sed -i "/ICHARG/c ICHARG = 11" INCAR
fi
sed -i '4c 17 17 17' KPOINTS
sed -i "/NSW/c NSW = 0" INCAR
sed -i "/ISMEAR/c ISMEAR = -5" INCAR
sed -i "/NEDOS/c NEDOS = 1501" INCAR
if [[ $2 == rwigs ]]; then
rwigs=$(cd ../scrun; CellInfo.sh rwigs |awk '{print $4}')
sed -i "/RWIGS/c RWIGS = ${rwigs//,/ }" INCAR
sed -i "/NPAR/c NPAR = 1" INCAR
sed -i "/LORBIT/c LORBIT = 0" INCAR
else
sed -i "/NPAR/c NPAR = 8" INCAR
sed -i "/LORBIT/c LORBIT = 10" INCAR
fi
sed -i "/#PBS -l walltime/c #PBS -l walltime=04:00:00" qsub.parallel
sed -i "/#PBS -l nodes/c #PBS -l nodes=2:ppn=8" qsub.parallel
[[ $is_submit ]] && qsub qsub.parallel
elif [[ "$test_type" == bsrun ]]; then
argparse "$@"
does_directory_exist
subdirectory_check
Prepare.sh "$subdir_name" $test_tag
cd bsrun
if [[ ! -f ../scrun/CHGCAR ]]; then
echo "Didn't find $directory_name/scrun/CHGCAR. Aborted."
exit 1
fi
cp -l ../scrun/CHGCAR .
if [[ -f ../scrun/CONTCAR ]]; then
echo "Found CONTCAR under $directory_name/scrun/. Will use it."
cp ../scrun/CONTCAR POSCAR
fi
if [[ ! -f KPOINTS-bs ]]; then
echo "You must manually change the KPOINTS file before submitting job!"
exit 1
fi
mv KPOINTS-bs KPOINTS
sed -i "/NSW/c NSW = 0" INCAR
sed -i "/NEDOS/c NEDOS = 1501" INCAR
sed -i "/ICHARG/c ICHARG = 11" INCAR
sed -i "/LORBIT/c LORBIT = 10" INCAR
sed -i "/NPAR/c NPAR = 8" INCAR
sed -i "/#PBS -l walltime/c #PBS -l walltime=04:00:00" qsub.parallel
sed -i "/#PBS -l nodes/c #PBS -l nodes=2:ppn=8" qsub.parallel
[[ $is_submit ]] && qsub qsub.parallel
elif [[ "$test_type" == lobster && "$test_type2" == kp ]]; then
shift 1
argparse "$@"
does_directory_exist
if [[ -d "$subdir_name"-kp && $(ls -A "$subdir_name"-kp) && -z $is_override ]]; then
echo "$subdir_name-kp/ contains files. Escaping..."
exit 1
fi
Prepare.sh "$subdir_name"-kp $test_tag -a qlobster.kp.serial
cd "$subdir_name"-kp
if [[ -f ../scrun/CONTCAR ]]; then
echo "Found CONTCAR under $directory_name/scrun/. Will use it."
cp ../scrun/CONTCAR POSCAR
fi
# sed -i '4c 11 11 11' KPOINTS
sed -i "/NSW/c NSW = 0" INCAR
sed -i "/ISYM/c ISYM = 0" INCAR
sed -i "/LSORBIT/c LSORBIT = .TRUE." INCAR
sed -i "/ISMEAR/c ISMEAR = -5" INCAR
[[ $is_submit ]] && qsub qlobster.kp.serial
elif [[ "$test_type" == lobster && "$test_type2" == test ]]; then
shift 1
argparse "$@"
does_directory_exist
subdirectory_check
if [[ -z "$nband" ]]; then
echo "You must provide NBAND value for the lobster test by -n!"
exit 1
fi
Prepare.sh "$subdir_name" $test_tag -a qlobster.parallel
cd "$subdir_name"
if [[ -f KPOINTS-full ]]; then
echo "Found KPOINTS-full under $directory_name/$subdir_name/. Will use it."
mv KPOINTS-full KPOINTS
elif [[ -d lobster-kp ]]; then
echo "Found lobster-kp/ under $directory_name/$subdir_name/. Will use it."
cp lobster-kp/IBZKPT KPOINTS
elif [[ -d ../lobster-kp ]]; then
echo "Found lobster-kp/ under $directory_name/. Moving to $directory_name/$subdir_name/ for clarity..."
mv ../lobster-kp .
cp lobster-kp/IBZKPT KPOINTS
else
echo "Didn't find lobster-kp/ or KPOINTS-full. Did you have your own copied here?"
exit 1
fi
if [[ -f CHGCAR ]]; then
echo "Found CHGCAR under $directory_name/$subdir_name/. Will use it."
sed -i "/ICHARG/c ICHARG = 11" INCAR
elif [[ -f ../scrun/CHGCAR && -f ../scrun/CONTCAR ]]; then
echo "Found CHGCAR and CONTCAR under $directory_name/scrun/. Will use them."
cp ../scrun/CONTCAR POSCAR
cp -l ../scrun/CHGCAR .
sed -i "/ICHARG/c ICHARG = 11" INCAR
fi
sed -i "/NBANDS/c NBANDS = $nband" INCAR
sed -i "/NSW/c NSW = 0" INCAR
sed -i "/ISMEAR/c ISMEAR = -5" INCAR
sed -i "/NEDOS/c NEDOS = 1501" INCAR
sed -i "/LORBIT/c LORBIT = 10" INCAR
sed -i "/LWAVE/c LWAVE = .TRUE." INCAR
sed -i "/NPAR/c NPAR = 8" INCAR
sed -i "/#PBS -l walltime/c #PBS -l walltime=04:00:00" qsub.parallel
sed -i "/#PBS -l nodes/c #PBS -l nodes=2:ppn=8" qsub.parallel
[[ $is_submit ]] && qsub qsub.parallel
elif [[ "$test_type" == lobster && "$test_type2" == analysis ]]; then
shift 1
argparse "$@"
does_directory_exist
if [[ -d "$subdir_name" && $(ls -A "$subdir_name") ]]; then
cd "$subdir_name"
else
echo "$subdir_name/ does not exist!"
exit 1
fi
[[ $is_submit ]] && qsub qlobster.parallel
elif [[ "$test_type" == bader && "$test_type2" == test ]]; then
shift 1
argparse "$@"
does_directory_exist
subdirectory_check
Prepare.sh "$directory_name" $test_tag -a qbader.serial
cd "$directory_name"
sed -i '/LAECHG/c LAECHG = .TRUE.' INCAR
sed -i '/NGXF/c NGXF = 250' INCAR
sed -i '/NGYF/c NGYF = 250' INCAR
sed -i '/NGZF/c NGZF = 250' INCAR
# echo -e 'NGXF = 250\nNGYF = 250\nNGZF = 250' >> INCAR
sed -i '/LCHARG/c LCHARG = .TRUE.' INCAR
sed -i '/NSW/c NSW = 0' INCAR
[[ $is_submit ]] && qsub qsub.parallel
elif [[ "$test_type" == bader && "$test_type2" == analysis ]]; then
shift 1
argparse "$@"
does_directory_exist
if [[ -d "$subdir_name" && $(ls -A "$subdir_name") ]]; then
cd "$subdir_name"
else
echo "$subdir_name/ does not exist!"
exit 1
fi
[[ $is_submit ]] && qsub qbader.serial
else
echo "Specify what you are going to test!" >&2
exit 1
fi
exit 0