forked from zhenming-xu/VASP-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nebbarrier.pl
121 lines (106 loc) · 3.56 KB
/
nebbarrier.pl
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
#!/usr/bin/env perl
#;-*- Perl -*-
use FindBin qw($Bin);
use lib "$Bin";
use Vasp;
open NEB , ">neb.dat" ;
@args = @ARGV;
if (@args==0) {
opendir(DIR,".") or die "couldn't open . ($!)\n";
@list = readdir(DIR);
closedir(DIR);
@directories = grep {-d && /^[0-9][0-9]$/i} @list;
@directories = sort {$a<=>$b} @directories;
} else {
@directories = @args;
}
# check for ssneb
$ssneb_flag = `grep 'LNEBCELL' 01/OUTCAR|tail -1`;
@ssneb_flag = split(/\s+/,$ssneb_flag);
$ssneb_flag = $ssneb_flag[@ssneb_flag-1];
$nions = `grep 'NIONS' 01/OUTCAR|tail -1`;
@nions = split(/\s+/,$nions);
$nions = $nions[@nions-1];
if ($ssneb_flag =~ /T/){
open NEBSS , ">nebss.dat" ;
#print "$ssneb_flag \n";
}
# print "#Directories found: ".join(" ",@directories)."\n";
$dist_cum = 0;
for ($i=0; $i<@directories; $i++) {
(-e "$directories[$i]/OUTCAR") || die "No OUTCAR in $directories[$i]!\n";
$energy = `grep 'energy w' $directories[$i]/OUTCAR|tail -1`;
# $dist = `grep 'NEB: distance' $directories[$i]/OUTCAR|tail -1`;
$force = `grep 'NEB: projections' $directories[$i]/OUTCAR|tail -1`;
if ($ssneb_flag =~ /T/){
$force = `grep 'NEBCELL: projections' $directories[$i]/OUTCAR|tail -1`;
};
$energy =~ s/\s+$//g;
@energy = split(/\s+/,$energy);
$energy = $energy[@energy-1];
if ($i==0) { $energy0 = $energy; }
$energy -= $energy0;
if ($i>0) {
if (-e "$directories[$i]/CONTCAR") {
$file1 = "$directories[$i]/CONTCAR";
} else {
$file1 = "$directories[$i]/POSCAR";
}
if (-e "$directories[$i-1]/CONTCAR") {
$file2 = "$directories[$i-1]/CONTCAR";
} else {
$file2 = "$directories[$i-1]/POSCAR";
}
$dist = `$Bin/dist.pl $file1 $file2`;
if ($ssneb_flag =~ /T/){
if($i == @directories-1){
$dist = $dist1[@dist1-2];
} else{
$dist1 = `grep 'NEBCELL: distance' $directories[$i]/OUTCAR|tail -1`;
@dist1 = split(/\s+/,$dist1);
$dist = $dist1[@dist1-3];}
}
} else {
$dist = 0;
}
@force = split(/\s+/,$force);
$force = $force[@force-1];
$dist_cum += $dist;
if ($ssneb_flag !~ /T/){
# Get the coordinates to find the local tangent for the end images
if($i == 0) {
if (-e "$directories[$i]/CONTCAR") {
$file1 = "$directories[$i]/CONTCAR";
} else {
$file1 = "$directories[$i]/POSCAR";
}
if (-e "$directories[$i+1]/CONTCAR") {
$file2 = "$directories[$i+1]/CONTCAR";
} else {
$file2 = "$directories[$i+1]/POSCAR";
}
$ocar = "$directories[$i]/OUTCAR";
$force = `$Bin/nebforces.pl $file1 $file2 $ocar`;
} elsif($i == @directories-1) {
if (-e "$directories[$i]/CONTCAR") {
$file1 = "$directories[$i]/CONTCAR";
} else {
$file1 = "$directories[$i]/POSCAR";
}
if (-e "$directories[$i-1]/CONTCAR") {
$file2 = "$directories[$i-1]/CONTCAR";
} else {
$file2 = "$directories[$i-1]/POSCAR";
}
$ocar = "$directories[$i]/OUTCAR";
$force = `$Bin/nebforces.pl $file1 $file2 $ocar`;
}
}
printf NEB "%3i %12.6f %12.6f %12.6f %3i\n",$i,$dist_cum,$energy,$force,$directories[$i];
if ($ssneb_flag =~ /T/){
printf NEBSS "%3i %12.6f %12.6f %12.6f %3i\n",$i,$dist_cum/sqrt($nions),$energy/$nions,$force/sqrt($nions),$directories[$i];
}
}
#print "nebbarrier.pl done \n";
close NEB;
if ($ssneb_flag !~ /T/){close NEBSS;}