-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmktrajectory
executable file
·44 lines (37 loc) · 1.05 KB
/
mktrajectory
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
#! /usr/bin/perl
# vasptrajectory
# Extracts the atoms positions from a VASP OUTCAR
open OUTCAR, "OUTCAR" or die "OUTCAR not found:";
open CONTCAR, "CONTCAR" or die "CONTCAR not found:";
my @outcar = <OUTCAR>;
my @contcar = <CONTCAR>;
@names = split /\s+/,@contcar[5];
@numbers = split /\s+/,@contcar[6];
@atoms = ();
while (@numbers) {
$this_number = shift(@numbers);
$this_label = shift(@names);
for ( $i=0; $i < $this_number; $i++ ) {
# print "$this_label\n";
push (@atoms, $this_label);
}
}
$nframes = 0;
while (@outcar) {
my @thisline = split /\s+/,shift(@outcar);
if ($thisline[1] =~ /POSITION/){
shift(@outcar);
@thisline = split /\s+/,shift(@outcar);
$frame_out = "";
$natoms = 0;
until ($thisline[1] =~ m/--/) {
$frame_out = "$frame_out$atoms[$natoms] $thisline[1] $thisline[2] $thisline[3]\n";
@thisline = split /\s+/,shift(@outcar);
$natoms++;
}
print "$natoms\n";
print "$nframes\n";
print "$frame_out";
$nframes++;
}
}