Editing
Xyz poscar.pl
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
go back to [[Main Page]], [[Computational Resources]], [[Scripts]], [[Scripts for VASP]] #!/usr/bin/perl -w ###############Edit this############### $title = "Single points"; $ncell = 25.832; ####################################### ###Parameters inicialization $i = $j = $k = $l = $J = $m = 0; $k = 1; ###### ###Enter the XYZ file chomp($arq_log = <STDIN>); #open file open(ARQ, "<$arq_log") or die "Check the file $arq_log: $!\n"; $arq_xyz = "$arq_log"; #replacing suffix: xyz=>vasp $arq_xyz =~ s/xyz/vasp/g; #regular expression, operations while (<ARQ>){ if (/^\s(\w+)\s+(\-?\d+\.\d+)\s+(\-?\d+\.\d+)\s+(\-?\d+\.\d+)/){ $atom[$i] = $1; $x[$i] = sprintf("%2.16f", $2/$ncell); $y[$i] = sprintf("%2.16f", $3/$ncell); $z[$i] = sprintf("%2.16f", $4/$ncell); $line[$i] = "$atom[$i] $x[$i] $y[$i] $z[$i]"; #print "$line[$i]\n"; $i++; } } #sorting the lines @sorted_lines = sort @line; #split sorted lines foreach (@sorted_lines){ if (/^(\w+)\s+(\-?\d+\.\d+)\s+(\-?\d+\.\d+)\s+(\-?\d+\.\d+)/){ $Atom[$j] = $1; $X[$j] = $2; $Y[$j] = $3; $Z[$j] = $4; #print "$j $Atom[$j] $X[$j], $Y[$j], $Z[$j]\n"; if ($j == 0){ $l++; $natoms[$l] = $k; #print "$l $k $Atom[$j] $natoms[$l]\n"; $k++; } else { if ($Atom[$j -1] eq $Atom[$j] ){ $natoms[$l] = $k; #print "$l $k $Atom[$j] $natoms[$l]\n"; $k++; } else { $k=1; $l++; $natoms[$l] = $k; #print "$l $k $Atom[$j] $natoms[$l]\n"; $k++ } } $j++; } } ################################## ###Generation of the VASP file ### ################################## #open new file.vasp open(XYZ, ">$arq_xyz" ) or die "Check the file $arq_xyz : $!\n"; ####################### ####Print preambulo#### ####################### #Cell's data print XYZ " $title \n"; printf XYZ " % 2.16f \n",$ncell; printf XYZ " % 2.16f % 2.16f % 2.16f \n",1.0, 0.0, 0.0; printf XYZ " % 2.16f % 2.16f % 2.16f \n",0.0, 1.0, 0.0; printf XYZ " % 2.16f % 2.16f % 2.16f \n",0.0, 0.0, 1.0; #Number of each atom's type N1 N2 N3 .... for($m = 1; $m <= $l; $m++){ print XYZ " $natoms[$m]"; } print XYZ "\n"; print XYZ "Selective dynamics\n"; print XYZ "Direct\n"; ####################### #print the cartesian to the new file.vasp for($J = 0; $J < $i; $J++){ printf XYZ " % 2.16f % 2.16f % 2.16f F F F \n",$X[$J], $Y[$J], $Z[$J]; } $J = 0; print XYZ "\n"; #Print the parameters to dinamics. (by now, only zeros) for($J = 0; $J < $i; $J++){ printf XYZ " % 2.16f % 2.16f % 2.16f \n",0.0, 0.0, 0.0; } print XYZ "\n"; ####Close the XYZ and VASP files close(ARQ); close(XYZ);
Summary:
Please note that all contributions to Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information