Statistics
| Branch: | Tag: | Revision:

dockonsurf / dockOnSurf.sh @ 3389cb7c

History | View | Annotate | Download (6.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

    
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
    -b|--coadsorption-box)
23
      coads_box=true;;
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
  -b, --coadsorption-box \t when the surface file already contains an
35
\t \t \t \t adsorbed molecule, it creates a box around it to
36
\t \t \t \t prevent the second adsorbate to overlap the first."
37
  exit
38
fi
39

    
40
file_path=/home/cmartial/dockonsurf/DockOnSurf_path
41

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

    
44
source ${file_path}
45

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

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

    
69
fi
70

    
71
### Paramètres initiaux
72

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

    
76
echo '' 
77

    
78
module load rdkit
79

    
80
if [ "$only_ads" = false ] && [ "$only_ref" = false ] ; then
81
	### Generation des conformeres
82

    
83
  ${DockOnSurf_path}/modules/generation_conformeres.py $molecule 5000
84
  echo ' -- CONFORMERS HAVE BEEN GENERATED --'
85
  
86
  ### Conversion des fichiers .mol en .xyz
87
  
88
  ${DockOnSurf_path}/modules/mol_to_xyz.sh $molecule
89
  
90
  ### Lancement des calculs pour les molecules seules
91
  
92
  ${DockOnSurf_path}/modules/launch_cp2k_molecule_seule.sh $molecule $max_qw
93
  
94
  echo ' -- ALL CALCULATIONS FOR MOLECULE ALONE HAVE BEEN DONE --'
95
  
96
  ### Suppression des fichiers inutiles
97
  
98
  rm -r ${Molecule_results_path}/${molecule}/*/*bak*
99
fi
100

    
101
echo ' '
102
echo ' -- RESULTS --'
103

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

    
115
if [ "$only_iso" = true ] ; then exit; fi
116

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

    
127
if [ "$only_ref" = false ] ; then
128

    
129
  read -a list_atom_1_mol -p 'List of atoms of the molecule to adsorb '
130
  read -a list_atom_2_mol -p 'List of neighboring atoms of the molecule (linked to the atoms to adsorb) '
131
  nombre_atom_mol=${#list_atom_1_mol[@]}
132
  if [ ${#list_atom_2_mol[@]} != ${nombre_atom_mol} ]
133
  then
134
  	echo "  Problem: number of atoms different in the two lists"
135
  	exit
136
  fi
137
  read -a list_atom_surf -p 'List of the atoms of the surface that can be adsorption sites '
138
	if [ "$coads_box" = true ] ; then
139
		read -a first_atom_ads1 -p 'Number of the adsorbate first atom in the surface file '
140
	fi
141
  echo '' 
142
  
143
  ### Adsorption de la molecule sur la surface
144
  
145
  ${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
146
  
147
  echo ' -- ADSORPTION SUTRUCTURES HAVE BEEN CALCULATED --'
148
  
149
  # 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) 
150
  
151
  ${DockOnSurf_path}/modules/fe_change.sh $molecule $surface ${MolOnSurf_results_path}/${molecule}
152
  
153
  ### Lancement des calculs pour les molecules adsorbees
154
  
155
  ${DockOnSurf_path}/modules/launch_script+diss.sh $molecule $max_qw
156
  
157
  echo ' -- ALL CALCULATIONS FOR ADSORPTION STRUCTURES HAVE BEEN DONE --'
158
  
159
  ### Suppression des fichiers inutiles
160
  
161
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*RESTART*
162
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*BFGS*
163
  rm -r ${MolOnSurf_results_path}/${molecule}/*/*.p*
164

    
165
fi
166
  
167
### Clustering et lancement des structures centres des clusters
168

    
169
nb_at_surf="$(awk 'NR==1{print}' ${Surface_path}/${surface}.xyz)"
170
num_center="$(expr ${nb_at_surf} + $center )"
171

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

    
174
echo ' -- ALL CLUSTER CENTERS CALCULATIONS HAVE BEEN DONE --'
175

    
176
echo " "
177
echo ' -- RESULTS --'
178

    
179
echo ' '
180
echo "Most stable structure for molecule alone: ${numero_mol_stable} with energy ${min_energy_molecule} Ha"
181

    
182
min_energy_global=0
183
for global_struct in ${MolOnSurf_results_path}/${molecule}/relaunched_calculations/* ; do
184
	if [[ "$global_struct" != *.inp ]]
185
	then
186
		if [[ "$global_struct" != *.j ]]
187
		then 
188
			energy_global="$(awk '/ENERGY/{E=$NF} END{print E}' ${global_struct}/*${molecule}.out)"
189
			if [[ "${energy_global}" > "${min_energy_global}" ]]
190
			then
191
				min_energy_global=${energy_global}
192
				numero_global_stable="$(echo ${global_struct} | awk -F'/' '{print $NF}')"
193
			fi
194
		fi
195
	fi
196
done
197

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

    
200