Statistics
| Branch: | Tag: | Revision:

dockonsurf / dockOnSurf.sh @ 3ba3c134

History | View | Annotate | Download (7.9 kB)

1
#!/bin/bash
2

    
3
print_help=false
4
max_qw=9223372036854775807
5
only_ads=false
6
only_iso=false
7
only_ref=false
8
coads_box=false
9
rmsd_threshold=0.01
10

    
11
for i in $@; do
12
  case $i in
13
    -h|--help)
14
      print_help=true;;
15
    -q=*|--max-qw=*)
16
      max_qw="${i#*=}";;
17
    -a|--only-ads)
18
      only_ads=true;;
19
    -i|--only-isolated)
20
      only_iso=true;;
21
    -r|--only-refinement)
22
      only_ref=true;;
23
    -b|--coadsorption-box)
24
      coads_box=true;;
25
    -t=*|--rmsd-threshold=*)
26
      rmsd_threshold="${i#*=}";;
27
  esac
28
done
29

    
30
if $print_help ; then
31
  echo -e "Usage: dockonsurf [OPTION]=PATTERN
32
  -h, --help \t \t \t Display this help text and exit.
33
  -q=NUM, --max-qw=NUM \t \t Allows a maximum of NUM jobs on 'qw' status.
34
  -a, --only-ads \t \t Carry out only adsorption part.
35
  -i, --only-isolated \t \t Carry out only isolated molecules part.
36
  -r, --only-refinement \t Carry out only refinement of adsorbed structure.
37
  -b, --coadsorption-box \t When the surface file already contains an
38
\t \t \t \t adsorbed molecule, it creates a box around it to
39
\t \t \t \t prevent the second adsorbate to overlap the first.
40
  -t=NUM, --rmsd-threshold=NUM \t Sets the threshold for the RMSD check of 
41
\t \t \t \t different structures."
42
  exit
43
fi
44

    
45
file_path=DockOnSurf_path
46

    
47
### Mise en place de l'arborescence
48

    
49
source ${file_path}
50

    
51
if [ "$only_iso" = false ]; then
52

    
53
  ### Récupération des vecteurs de cellule
54
  
55
  a1="$(grep "A\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^A/ {print}' | awk '{print $2}')"
56
  if [[ $a1 =~ "E+00" ]]; then a1="$(echo $a1 | cut -d "E" -f1)"; fi ; export a1
57
  a2="$(grep "A\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^A/ {print}' | awk '{print $3}')"
58
  if [[ $a2 =~ "E+00" ]]; then a2="$(echo $a2 | cut -d "E" -f1)"; fi ; export a2
59
  a3="$(grep "A\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^A/ {print}' | awk '{print $4}')"
60
  if [[ $a3 =~ "E+00" ]]; then a3="$(echo $a3 | cut -d "E" -f1)"; fi ; export a3
61
  b1="$(grep "B\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^B/ {print}' | awk '{print $2}')"
62
  if [[ $b1 =~ "E+00" ]]; then b1="$(echo $b1 | cut -d "E" -f1)"; fi ; export b1
63
  b2="$(grep "B\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^B/ {print}' | awk '{print $3}')"
64
  if [[ $b2 =~ "E+00" ]]; then b2="$(echo $b2 | cut -d "E" -f1)"; fi ; export b2
65
  b3="$(grep "B\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^B/ {print}' | awk '{print $4}')"
66
  if [[ $b3 =~ "E+00" ]]; then b3="$(echo $b3 | cut -d "E" -f1)"; fi ; export b3
67
  c1="$(grep "C\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^C/ {print}' | awk '{print $2}')"
68
  if [[ $c1 =~ "E+00" ]]; then c1="$(echo $c1 | cut -d "E" -f1)"; fi ; export c1
69
  c2="$(grep "C\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^C/ {print}' | awk '{print $3}')"
70
  if [[ $c2 =~ "E+00" ]]; then c2="$(echo $c2 | cut -d "E" -f1)"; fi ; export c2
71
  c3="$(grep "C\ " ${CP2K_input_MolOnSurf} | awk '$1 ~/^C/ {print}' | awk '{print $4}')"
72
  if [[ $c3 =~ "E+00" ]]; then c3="$(echo $c3 | cut -d "E" -f1)"; fi ; export c3
73

    
74
fi
75

    
76
### Paramètres initiaux
77

    
78
echo 'Name of the molecule (without .mol) '
79
read molecule
80

    
81
if [ "$only_iso" = true ]; then 
82
  (kill -STOP $$; kill -CONT $$) &
83
  disown
84
fi
85

    
86
echo '' 
87

    
88
module load rdkit
89

    
90
if [ "$only_ads" = false ] && [ "$only_ref" = false ] ; then
91
	### Generation des conformeres
92

    
93
  ${DockOnSurf_path}/modules/generation_conformeres.py $molecule 5000 $rmsd_threshold
94
  echo ' -- CONFORMERS HAVE BEEN GENERATED --'
95

    
96
  ### Conversion des fichiers .mol en .xyz
97
  
98
  ${DockOnSurf_path}/modules/mol_to_xyz.sh $molecule
99
  
100
  ### Lancement des calculs pour les molecules seules
101
  
102
  ${DockOnSurf_path}/modules/launch_cp2k_molecule_seule.sh $molecule $max_qw
103

    
104
  echo ' -- ALL CALCULATIONS FOR MOLECULE ALONE HAVE BEEN DONE --'
105
  
106
  ### Suppression des fichiers inutiles
107
  
108
  rm -r ${Molecule_results_path}/${molecule}/*/*bak*
109
fi
110

    
111
echo ' '
112
echo ' -- RESULTS --'
113

    
114
min_energy_molecule=0
115
for struct in ${Molecule_results_path}/${molecule}/${molecule}*; do
116
	energy_molecule="$(awk '/ENERGY/{E=$NF} END{print E}' ${struct}/*${molecule}.out)"
117
	if [[ "${energy_molecule}" > "${min_energy_molecule}" ]]
118
	then 
119
		min_energy_molecule=${energy_molecule}
120
		numero_mol_stable="$(echo $struct | awk -F'/' '{print $NF}')"
121
	fi
122
done
123
echo "   Most stable structure for molecule alone: ${numero_mol_stable} with energy ${min_energy_molecule} Ha"
124

    
125
if [ "$only_iso" = true ] ; then exit; fi
126

    
127
echo ' '
128
echo ' -- ARGUMENTS FOR ADSORPTION -- '
129
echo ' '
130
echo 'Name of the file to use for the surface (without .xyz) '
131
read surface
132
echo 'Number of the central atom of the molecule'
133
read center
134
echo 'Value of cutoff energy for reoptimisation (eV)'
135
read cutoff
136

    
137
if [ "$only_ref" = false ] ; then
138

    
139
  read -a list_atom_1_mol -p 'List of atoms of the molecule to adsorb '
140
  read -a list_atom_2_mol -p 'List of neighboring atoms of the molecule (linked to the atoms to adsorb) '
141
  nombre_atom_mol=${#list_atom_1_mol[@]}
142
  if [ ${#list_atom_2_mol[@]} != ${nombre_atom_mol} ]
143
  then
144
  	echo "  Problem: number of atoms different in the two lists"
145
  	exit
146
  fi
147
  read -a list_atom_surf -p 'List of the atoms of the surface that can be adsorption sites '
148
	if [ "$coads_box" = true ] ; then
149
		read -a first_atom_ads1 -p 'Number of the adsorbate first atom in the surface file '
150
	fi
151
  echo '' 
152
fi
153

    
154
# Check wether the analyse directory already exists.
155
if [ "$only_ref" = true ] ; then
156
  echo ${MolOnSurf_results_path}/${molecule}/analyse
157
  if [ -d ${MolOnSurf_results_path}/${molecule}/analyse ]; then
158
      echo "It already exists an \"analyse\" directory. Do you want to delete it together with \"relaunched_calculations\"?"
159
      read delete_answer
160
    case "$delete_answer" in
161
      [yY][eE][sS]|[yY])
162
          rm -r ${MolOnSurf_results_path}/${molecule}/analyse
163
                  if [ -d ${MolOnSurf_results_path}/${molecule}/relaunched_calculations ]; then rm -r ${MolOnSurf_results_path}/${molecule}/relaunched_calculations; fi
164
          ;;
165
      *)
166
          echo "Now exiting"
167
                  exit
168
          ;;
169
      esac
170
  fi
171
fi
172

    
173
(kill -STOP $$; kill -CONT $$) &
174
disown 
175

    
176
if [ "$only_ref" = false ] ; then  
177
  ### Adsorption de la molecule sur la surface
178
  
179
  ${DockOnSurf_path}/modules/script_add_adsorbate+diss.sh $molecule $surface "${list_atom_1_mol[*]}" "${list_atom_2_mol[*]}" "${list_atom_surf[*]}" $coads_box $first_atom_ads1
180
  
181
  echo ' -- ADSORPTION SUTRUCTURES HAVE BEEN CALCULATED --'
182
  
183
  # Changes labels of elements to its original definition, thus allowing different kinds of same element (Fe1 Fe2) with different properties (e.g. spin state in compounds with magnetic coupling) 
184
  
185
  ${DockOnSurf_path}/modules/fe_change.sh $molecule $surface ${MolOnSurf_results_path}/${molecule}
186
  
187
  ### Lancement des calculs pour les molecules adsorbees
188
  
189
  ${DockOnSurf_path}/modules/launch_script+diss.sh $molecule $max_qw
190
  
191
  echo ' -- ALL CALCULATIONS FOR ADSORPTION STRUCTURES HAVE BEEN DONE --'
192
  
193
  ### Suppression des fichiers inutiles
194
  
195
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*RESTART*
196
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*BFGS*
197
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*.p*
198

    
199
fi
200
  
201
### Clustering et lancement des structures centres des clusters
202

    
203
nb_at_surf="$(awk 'NR==1{print}' ${Surface_path}/${surface}.xyz)"
204
num_center="$(expr ${nb_at_surf} + $center )"
205

    
206
${DockOnSurf_path}/modules/script_grandes_molecules+diss.sh $molecule $num_center ${nb_at_surf} ${cutoff} $max_qw
207

    
208
echo ' -- ALL CLUSTER CENTERS CALCULATIONS HAVE BEEN DONE --'
209

    
210
echo " "
211
echo ' -- RESULTS --'
212

    
213
echo ' '
214
echo "Most stable structure for molecule alone: ${numero_mol_stable} with energy ${min_energy_molecule} Ha"
215

    
216
min_energy_global=0
217
for global_struct in ${MolOnSurf_results_path}/${molecule}/relaunched_calculations/* ; do
218
	if [[ "$global_struct" != *.inp ]]
219
	then
220
		if [[ "$global_struct" != *.j ]]
221
		then 
222
			energy_global="$(awk '/ENERGY/{E=$NF} END{print E}' ${global_struct}/*${molecule}.out)"
223
			if [[ "${energy_global}" > "${min_energy_global}" ]]
224
			then
225
				min_energy_global=${energy_global}
226
				numero_global_stable="$(echo ${global_struct} | awk -F'/' '{print $NF}')"
227
			fi
228
		fi
229
	fi
230
done
231

    
232
echo "Most stable structure for adsorption: ${numero_global_stable} with energy ${min_energy_global} Ha"
233

    
234