Statistics
| Branch: | Tag: | Revision:

dockonsurf / dockOnSurf.sh @ 3c26e233

History | View | Annotate | Download (7.5 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
rmsd_threshold=0.01
9

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

    
27
if $print_help ; then
28
  echo -e "Usage: dockonsurf [OPTION]=PATTERN
29
  -h, --help \t \t \t Display this help text and exit.
30
  -q=NUM, --max-qw=NUM \t \t Allows a maximum of NUM jobs on 'qw' status.
31
  -a, --only-ads \t \t Carry out only adsorption part.
32
  -i, --only-isolated \t \t Carry out only isolated molecules part.
33
  -r, --only-refinement \t Carry out only refinement of adsorbed structure.
34
  -t=NUM, --rmsd-threshold=NUM \t Sets the threshold for the RMSD check of 
35
\t \t \t \t different structures."
36
  exit
37
fi
38

    
39
file_path=DockOnSurf_path
40

    
41
### Mise en place de l'arborescence
42

    
43
source ${file_path}
44

    
45
if [ "$only_iso" = false ]; then
46

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

    
68
fi
69

    
70
### Paramètres initiaux
71

    
72
echo 'Name of the molecule (without .mol) '
73
read molecule
74

    
75
if [ "$only_iso" = true ]; then 
76
  (kill -STOP $$; kill -CONT $$) &
77
  disown
78
fi
79

    
80
echo '' 
81

    
82
module load rdkit
83

    
84
if [ "$only_ads" = false ] && [ "$only_ref" = false ] ; then
85
	### Generation des conformeres
86

    
87
  ${DockOnSurf_path}/modules/generation_conformeres.py $molecule 5000 $rmsd_threshold
88
  echo ' -- CONFORMERS HAVE BEEN GENERATED --'
89

    
90
  ### Conversion des fichiers .mol en .xyz
91
  
92
  ${DockOnSurf_path}/modules/mol_to_xyz.sh $molecule
93
  
94
  ### Lancement des calculs pour les molecules seules
95
  
96
  ${DockOnSurf_path}/modules/launch_cp2k_molecule_seule.sh $molecule $max_qw
97

    
98
  echo ' -- ALL CALCULATIONS FOR MOLECULE ALONE HAVE BEEN DONE --'
99
  
100
  ### Suppression des fichiers inutiles
101
  
102
  rm -r ${Molecule_results_path}/${molecule}/*/*bak*
103
fi
104

    
105
echo ' '
106
echo ' -- RESULTS --'
107

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

    
119
if [ "$only_iso" = true ] ; then exit; fi
120

    
121
echo ' '
122
echo ' -- ARGUMENTS FOR ADSORPTION -- '
123
echo ' '
124
echo 'Name of the file to use for the surface (without .xyz) '
125
read surface
126
echo 'Number of the central atom of the molecule'
127
read center
128
echo 'Value of cutoff energy for reoptimisation (eV)'
129
read cutoff
130

    
131
if [ "$only_ref" = false ] ; then
132

    
133
  read -a list_atom_1_mol -p 'List of atoms of the molecule to adsorb '
134
  read -a list_atom_2_mol -p 'List of neighboring atoms of the molecule (linked to the atoms to adsorb) '
135
  nombre_atom_mol=${#list_atom_1_mol[@]}
136
  if [ ${#list_atom_2_mol[@]} != ${nombre_atom_mol} ]
137
  then
138
  	echo "  Problem: number of atoms different in the two lists"
139
  	exit
140
  fi
141
  read -a list_atom_surf -p 'List of the atoms of the surface that can be adsorption sites '
142
  echo '' 
143
fi
144

    
145
# Check wether the analyse directory already exists.
146
if [ "$only_ref" = true ] ; then
147
  echo ${MolOnSurf_results_path}/${molecule}/analyse
148
  if [ -d ${MolOnSurf_results_path}/${molecule}/analyse ]; then
149
      echo "It already exists an \"analyse\" directory. Do you want to delete it together with \"relaunched_calculations\"?"
150
      read delete_answer
151
    case "$delete_answer" in
152
      [yY][eE][sS]|[yY])
153
          rm -r ${MolOnSurf_results_path}/${molecule}/analyse
154
                  if [ -d ${MolOnSurf_results_path}/${molecule}/relaunched_calculations ]; then rm -r ${MolOnSurf_results_path}/${molecule}/relaunched_calculations; fi
155
          ;;
156
      *)
157
          echo "Now exiting"
158
                  exit
159
          ;;
160
      esac
161
  fi
162
fi
163

    
164
(kill -STOP $$; kill -CONT $$) &
165
disown 
166

    
167
if [ "$only_ref" = false ] ; then  
168
  ### Adsorption de la molecule sur la surface
169
  
170
  ${DockOnSurf_path}/modules/script_add_adsorbate+diss.sh $molecule $surface "${list_atom_1_mol[*]}" "${list_atom_2_mol[*]}" "${list_atom_surf[*]}"
171
  
172
  echo ' -- ADSORPTION SUTRUCTURES HAVE BEEN CALCULATED --'
173
  
174
  # 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) 
175
  
176
  ${DockOnSurf_path}/modules/fe_change.sh $molecule $surface ${MolOnSurf_results_path}/${molecule}
177
  
178
  ### Lancement des calculs pour les molecules adsorbees
179
  
180
  ${DockOnSurf_path}/modules/launch_script+diss.sh $molecule $max_qw
181
  
182
  echo ' -- ALL CALCULATIONS FOR ADSORPTION STRUCTURES HAVE BEEN DONE --'
183
  
184
  ### Suppression des fichiers inutiles
185
  
186
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*RESTART*
187
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*BFGS*
188
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*.p*
189

    
190
fi
191
  
192
### Clustering et lancement des structures centres des clusters
193

    
194
nb_at_surf="$(awk 'NR==1{print}' ${Surface_path}/${surface}.xyz)"
195
num_center="$(expr ${nb_at_surf} + $center )"
196

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

    
199
echo ' -- ALL CLUSTER CENTERS CALCULATIONS HAVE BEEN DONE --'
200

    
201
echo " "
202
echo ' -- RESULTS --'
203

    
204
echo ' '
205
echo "Most stable structure for molecule alone: ${numero_mol_stable} with energy ${min_energy_molecule} Ha"
206

    
207
min_energy_global=0
208
for global_struct in ${MolOnSurf_results_path}/${molecule}/relaunched_calculations/* ; do
209
	if [[ "$global_struct" != *.inp ]]
210
	then
211
		if [[ "$global_struct" != *.j ]]
212
		then 
213
			energy_global="$(awk '/ENERGY/{E=$NF} END{print E}' ${global_struct}/*${molecule}.out)"
214
			if [[ "${energy_global}" > "${min_energy_global}" ]]
215
			then
216
				min_energy_global=${energy_global}
217
				numero_global_stable="$(echo ${global_struct} | awk -F'/' '{print $NF}')"
218
			fi
219
		fi
220
	fi
221
done
222

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

    
225