-
Notifications
You must be signed in to change notification settings - Fork 0
/
writeQchemInpV
executable file
·76 lines (60 loc) · 1.83 KB
/
writeQchemInpV
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
#!/bin/bash
#####################################################################
# Program : #
# Extract the a series of structures and then write the #
# qchem input file #
# Input : #
# $1 = test.xyz ; store a series of structure #
# Output : #
# lots of *.inp #
# #
# History: #
# 2022/02/02. Grace, copy writeGauInpV and then rewrite this script.#
#####################################################################
function main(){
# 1. check input argument and extract necessary info.
checkInput $1
# 2. generate qchem option into a file
qchemOption # output: qchemOption.tmp
# 3. generate qchem input files
genqchemInp $1 qchemOption.tmp # output: *.inp
rm -f qchemOption.tmp
}
function checkInput(){
[ "$1" == "" ] && echo "file $1 is not exist, exit" && exit
natom=$(head -n 1 $1)
natom_2=$(($natom+2))
fileLine=$(wc -l $1 | awk '{print $1}')
nfile=$(( $fileLine/($natom+2) ))
read -p 'Please key-in the charge: ' charge
read -p 'Please key-in the multiplicity: ' multi
}
function genqchemInp(){
# $1 = geometry file
# $2 = qchemOption.tmp
for (( i=1;i<=$nfile;i++))
do
head -n $(( $natom_2*$i )) $1 | tail -n $natom_2 > tmp.tmp
name=$(sed -n '2,2 p' tmp.tmp)
if [ `echo $name | grep -c \-` = 1 ]
then
name=n$name
fi
name=$(echo $name | sed 's/ //g')
echo "${name}".inp
cat << EOF > "${name}".inp
\$molecule
$charge $multi
`tail -n $natom tmp.tmp`
\$end
EOF
cat $2 >> "${name}".inp
done
rm -f tmp.tmp
}
function qchemOption(){
cat << EOF > qchemOption.tmp
test
EOF
}
main $1