File: run_example

package info (click to toggle)
espresso 6.7-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 311,068 kB
  • sloc: f90: 447,429; ansic: 52,566; sh: 40,631; xml: 37,561; tcl: 20,077; lisp: 5,923; makefile: 4,503; python: 4,379; perl: 1,219; cpp: 761; fortran: 618; java: 568; awk: 128
file content (423 lines) | stat: -rwxr-xr-x 10,024 bytes parent folder | download | duplicates (4)
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
#!/bin/sh

# run from directory where this script is
cd `echo $0 | sed 's/\(.*\)\/.*/\1/'` # extract pathname
EXAMPLE_DIR=`pwd`

# check whether echo has the -e option
if test "`echo -e`" = "-e" ; then ECHO=echo ; else ECHO="echo -e" ; fi

$ECHO
$ECHO "$EXAMPLE_DIR : starting"
$ECHO
$ECHO "This example shows how to use PostProc codes to project the DOS on molecular orbitals."

# set the needed environment variables
. ../../../environment_variables

# required executables and pseudopotentials
BIN_LIST="pw.x projwfc.x molecularpdos.x"
PSEUDO_LIST="H_US.van"

$ECHO
$ECHO "  executables directory: $BIN_DIR"
$ECHO "  pseudo directory:      $PSEUDO_DIR"
$ECHO "  temporary directory:   $TMP_DIR"
$ECHO "  checking that needed directories and files exist...\c"

# check for directories
for DIR in "$BIN_DIR" "$PSEUDO_DIR" ; do
    if test ! -d $DIR ; then
        $ECHO
        $ECHO "ERROR: $DIR not existent or not a directory"
        $ECHO "Aborting"
        exit 1
    fi
done
for DIR in "$TMP_DIR" "$EXAMPLE_DIR/results" ; do
    if test ! -d $DIR ; then
        mkdir $DIR
    fi
done
cd $EXAMPLE_DIR/results

# check for executables
for FILE in $BIN_LIST ; do
    if test ! -x $BIN_DIR/$FILE ; then
        $ECHO
        $ECHO "ERROR: $BIN_DIR/$FILE not existent or not executable"
        $ECHO "Aborting"
        exit 1
    fi
done

# check for gnuplot
GP_COMMAND=`which gnuplot 2>/dev/null`
if [ "$GP_COMMAND" = "" ]; then
        $ECHO
        $ECHO "gnuplot not in PATH"
        $ECHO "Results will not be plotted"
fi
 
# check for pseudopotentials
for FILE in $PSEUDO_LIST ; do
    if test ! -r $PSEUDO_DIR/$FILE ; then
       $ECHO
       $ECHO "Downloading $FILE to $PSEUDO_DIR...\c"
            $WGET $PSEUDO_DIR/$FILE $NETWORK_PSEUDO/$FILE 2> /dev/null
    fi
    if test $? != 0; then
        $ECHO
        $ECHO "ERROR: $PSEUDO_DIR/$FILE not existent or not readable"
        $ECHO "Aborting"
        exit 1
    fi
done
$ECHO " done"

# how to run executables
PW_COMMAND="$PARA_PREFIX $BIN_DIR/pw.x $PARA_POSTFIX"
PROJWFC_COMMAND="$PARA_PREFIX $BIN_DIR/projwfc.x $PARA_POSTFIX"
MOLECULARPDOS_COMMAND="$PARA_PREFIX $BIN_DIR/molecularpdos.x $PARA_POSTFIX"
$ECHO
$ECHO "  running pw.x as:            $PW_COMMAND"
$ECHO "  running projwfc.x as:       $PROJWFC_COMMAND"
$ECHO "  running molecularpdos.x as: $MOLECULARPDOS_COMMAND"
$ECHO "  running gnuplot as:         $GP_COMMAND"
$ECHO

# to spin or not to spin?
nspin=1
#nspin="2, tot_magnetization=0"

# how many kpoints to test k-resolved DOS?
nk=20

# self-consistent calculation for H chain and H2 molecule
cat <<EOF > chainH2.scf.in
&CONTROL
  calculation  = "scf",
  prefix       = "chainH2",
  tstress      = .false.,
  tprnfor      = .false.,
  pseudo_dir = '$PSEUDO_DIR/',
  outdir='$TMP_DIR/'
/
&SYSTEM
  ibrav     = 6, 
  celldm(1) = 7.d0
  celldm(3) = 2.0d0
  nat       = 12,
  ntyp      = 1,
  ecutwfc   = 20.0,
  nbnd      = 20
  nspin     = $nspin
  occupations = 'smearing'
  smearing = 'mv'
  degauss = 0.01d0
/
&ELECTRONS
/
ATOMIC_SPECIES
H  1.00  H_US.van
ATOMIC_POSITIONS crystal
H   0.0  0.0  0.0
H   0.0  0.0  0.1
H   0.0  0.0  0.2
H   0.0  0.0  0.3
H   0.0  0.0  0.4
H   0.0  0.0  0.5
H   0.0  0.0  0.6
H   0.0  0.0  0.7
H   0.0  0.0  0.8
H   0.0  0.0  0.9
H   0.35 0.35 0.445
H   0.35 0.35 0.555
K_POINTS
4
  0.0000000   0.0000000   0.0312500   0.2500000
  0.0000000   0.0000000   0.0937500   0.2500000
  0.0000000   0.0000000   0.1562500   0.2500000
  0.0000000   0.0000000   0.2187500   0.2500000
EOF
$ECHO "  running the scf calculation for H-chain with H2-molecule...\c"
$PW_COMMAND < chainH2.scf.in > chainH2.scf.out
check_failure $?
$ECHO " done"

# self-consistent calculation for the H2 molecule
cat <<EOF > H2.scf.in
&CONTROL
  calculation  = "scf",
  prefix       = "H2",
  tstress      = .false.,
  tprnfor      = .false.,
  pseudo_dir = '$PSEUDO_DIR/',
  outdir='$TMP_DIR/'
/
&SYSTEM
  ibrav     = 6, 
  celldm(1) = 7.d0
  celldm(3) = 2.0d0
  nat       = 2,
  ntyp      = 1,
  ecutwfc   = 20.0,
  nspin     = $nspin
  occupations = 'smearing'
  smearing = 'mv'
  degauss = 0.01d0
/
&ELECTRONS
/
ATOMIC_SPECIES
H  1.00  H_US.van
ATOMIC_POSITIONS crystal
H   0.35 0.35 0.445
H   0.35 0.35 0.555
K_POINTS
4
  0.0000000   0.0000000   0.0312500   0.2500000
  0.0000000   0.0000000   0.0937500   0.2500000
  0.0000000   0.0000000   0.1562500   0.2500000
  0.0000000   0.0000000   0.2187500   0.2500000
EOF
$ECHO "  running the scf calculation for the H2 molecule ${l0}...\c"
$PW_COMMAND < H2.scf.in > H2.scf.out
check_failure $?
$ECHO " done"

# projwfc calculation for the H2 molecule with H-chain and alone
for prefix in chainH2 H2; do
cat <<EOF > $prefix.projwfc.in
&PROJWFC
  outdir='$TMP_DIR/'
  prefix       = '$prefix'
  ngauss       = 0
  degauss      = 0.01470
  deltae       = 0.05
/
EOF
$ECHO "  running the projwfc calculation for $prefix...\c"
$PROJWFC_COMMAND < $prefix.projwfc.in > $prefix.projwfc.out
check_failure $?
$ECHO " done"
$ECHO " copying atomic_proj.xml file to $prefix.atomic_proj.xml"
cp -p $TMP_DIR/$prefix.save/atomic_proj.xml $prefix.atomic_proj.xml
done

# project the DOS on the molecular orbitals of the H2 molecule
cat <<EOF > chainH2_onto_H2.in
&INPUTMOPDOS
xmlfile_full='chainH2.atomic_proj.xml'
i_atmwfc_beg_full=11,
i_atmwfc_end_full=12,
i_bnd_beg_full=1,
i_bnd_end_full=20,
xmlfile_part='H2.atomic_proj.xml'
i_atmwfc_beg_part=1,
i_atmwfc_end_part=2,
i_bnd_beg_part=1,
i_bnd_end_part=2,
fileout ='chainH2_onto_H2'
ngauss=0,
degauss=0.01470,
DeltaE=0.05,
kresolveddos=.false.
/
EOF
$ECHO "  running the molecular orbital projection of the DOS...\c"
$MOLECULARPDOS_COMMAND < chainH2_onto_H2.in > chainH2_onto_H2.out
check_failure $?
$ECHO " done"

# now with DOS k-resolved with nk+1 k-points

# bands calculation for H chain and H2 molecule
cat <<EOF > chainH2.bands.in
&CONTROL
  calculation  = "bands",
  prefix       = "chainH2",
  tstress      = .false.,
  tprnfor      = .false.,
  pseudo_dir = '$PSEUDO_DIR/',
  outdir='$TMP_DIR/'
/
&SYSTEM
  ibrav     = 6, 
  celldm(1) = 7.d0
  celldm(3) = 2.0d0
  nat       = 12,
  ntyp      = 1,
  ecutwfc   = 20.0,
  nbnd      = 20
  nspin     = $nspin
  occupations = 'smearing'
  smearing = 'mv'
  degauss = 0.01d0
/
&ELECTRONS
  conv_thr_init = 1.d-6
/
ATOMIC_SPECIES
H  1.00  H_US.van
ATOMIC_POSITIONS crystal
H   0.0  0.0  0.0
H   0.0  0.0  0.1
H   0.0  0.0  0.2
H   0.0  0.0  0.3
H   0.0  0.0  0.4
H   0.0  0.0  0.5
H   0.0  0.0  0.6
H   0.0  0.0  0.7
H   0.0  0.0  0.8
H   0.0  0.0  0.9
H   0.35 0.35 0.445
H   0.35 0.35 0.555
K_POINTS crystal_b
2
0.0 0.0 0.0 $nk
0.0 0.0 0.5 0
EOF
$ECHO "  running the bands calculation for H-chain with H2-molecule...\c"
$PW_COMMAND < chainH2.bands.in > chainH2.bands.out
check_failure $?
$ECHO " done"

# bands calculation for the H2 molecule
cat <<EOF > H2.bands.in
&CONTROL
  calculation  = "bands",
  prefix       = "H2",
  tstress      = .false.,
  tprnfor      = .false.,
  pseudo_dir = '$PSEUDO_DIR/',
  outdir='$TMP_DIR/'
/
&SYSTEM
  ibrav     = 6, 
  celldm(1) = 7.d0
  celldm(3) = 2.0d0
  nat       = 2,
  ntyp      = 1,
  ecutwfc   = 20.0,
  nspin     = $nspin
  occupations = 'smearing'
  smearing = 'mv'
  degauss = 0.01d0
/
&ELECTRONS
  conv_thr_init = 1.d-6
/
ATOMIC_SPECIES
H  1.00  H_US.van
ATOMIC_POSITIONS crystal
H   0.35 0.35 0.445
H   0.35 0.35 0.555
K_POINTS crystal_b
2
0.0 0.0 0.0 $nk
0.0 0.0 0.5 0
EOF
$ECHO "  running the bands calculation for the H2 molecule ${l0}...\c"
$PW_COMMAND < H2.bands.in > H2.bands.out
check_failure $?
$ECHO " done"

# projwfc calculation for the H2 molecule with H-chain and alone
for prefix in chainH2 H2; do
cat <<EOF > $prefix.k.projwfc.in
&PROJWFC
  outdir='$TMP_DIR/'
  prefix       = '$prefix'
  ngauss       = 0
  degauss      = 0.01470
  deltae       = 0.05
  kresolveddos = .true.
  filpdos      = '$prefix.k'
/
EOF
$ECHO "  running the k-resolved projwfc calculation for $prefix...\c"
$PROJWFC_COMMAND < $prefix.k.projwfc.in > $prefix.k.projwfc.out
check_failure $?
$ECHO " done"
$ECHO " copying atomic_proj.xml file to $prefix.k.atomic_proj.xml"
cp -p $TMP_DIR/$prefix.save/atomic_proj.xml $prefix.k.atomic_proj.xml
done

# project the DOS on the molecular orbitals of the H2 molecule
cat <<EOF > chainH2_onto_H2.k.in
&INPUTMOPDOS
xmlfile_full='chainH2.k.atomic_proj.xml'
i_atmwfc_beg_full=11,
i_atmwfc_end_full=12,
i_bnd_beg_full=1,
i_bnd_end_full=20,
xmlfile_part='H2.k.atomic_proj.xml'
i_atmwfc_beg_part=1,
i_atmwfc_end_part=2,
i_bnd_beg_part=1,
i_bnd_end_part=2,
fileout ='chainH2_onto_H2.k'
ngauss=0,
degauss=0.01470,
DeltaE=0.05,
kresolveddos=.true.
/
EOF
$ECHO "  running the molecular orbital projection of the DOS...\c"
$MOLECULARPDOS_COMMAND < chainH2_onto_H2.k.in > chainH2_onto_H2.k.out
check_failure $?
$ECHO " done"

#
#  if gnuplot was found, the results are plotted
#
if [ "$GP_COMMAND" = "" ]; then
    break
else
cat > gnuplot.tmp <<EOF
#!$GP_COMMAND
#
set term post color solid enh
set out 'project_chainH2_onto_H2.ps'
set xlabel "Energy (eV)"
set ylabel "DOS (states/eV)"
ef=`awk '/Fermi/{printf $(NF-1)}' chainH2.scf.out`
set xra [-15:5]
set yzeroaxis
set style data lines
set origin 0,0
set size 1,1
set multiplot

set origin 0,1./2
set size 0.5,1./2
plot 'chainH2_onto_H2.mopdos_tot' u (\$1-ef):2 lc 3 t "total H_2-projected DOS"

set origin 0,0./2
set size 0.5,1./2
plot "<awk '(\$1==1)' chainH2_onto_H2.mopdos" u (\$2-ef):3 t "bonding H_2 orbital",  "<awk '(\$1==2)' chainH2_onto_H2.mopdos" u (\$2-ef):3 t "anti-bonding H_2 orbital"

set origin 0.5,0
set size 0.5,1
#set ytics 0.5
set ylabel "k_z (crystal)"
scaledos=20
set key title "K-resolved"
plot "<awk '(\$2==1)' chainH2_onto_H2.k.mopdos" u (\$3-ef):((\$1-1)/$nk*0.5+\$4/scaledos) t "bonding H_2 orbital", "<awk '(\$2==2)' chainH2_onto_H2.k.mopdos" u (\$3-ef):((\$1-1)/$nk*0.5+\$4/scaledos) t "anti-bonding H_2 orbital"

unset multiplot
EOF

$ECHO
$ECHO "  plotting molecular orbital projected DOS ...\c"
$GP_COMMAND < gnuplot.tmp
$ECHO " done"
#rm gnuplot.tmp
fi

$ECHO "  cleaning $TMP_DIR...\c"
rm -rf $TMP_DIR/*H2.*

$ECHO
$ECHO "$EXAMPLE_DIR: done"