User Tools

Site Tools


scripts:v2xyz

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

scripts:v2xyz [2010/02/17 10:27]
prokop created
scripts:v2xyz [2011/02/18 13:13]
Line 1: Line 1:
  
-==== usage ==== 
-  * Copy v2xyz and xv2xyz to bin directory 
-  * make sure that you have particular POTCAR in the direscotry with your CONTCAR or XDATCAR 
-  * run v2xyz in the directory with CONTCAR and POTCAR to make CONTCAR.xyz 
-  * run xv2xyz in the directory with CONTCAR and XDATCAR to make answer.xyz movie 
- 
-==== warning ==== 
-the scripts copy, overwrite and delete some files 
-  * xv2xyz overide CONTCAR, it saves backup to CONTCAR.bak before 
-  * v2xyz and xv2xyz create and delate files *.temp ​ 
- 
- 
-==== v2xyz: ==== 
-<​code>​ 
-#!/bin/bash 
-input="​CONTCAR"​ 
-output="​CONTCAR.xyz"​ 
-jmena=`grep TITEL POTCAR | cut -b 15- | tr "​\n"​ " "​` ​   # chenicke znacky prvku z POTCAR 
-pocty=`head -n 6 CONTCAR | tail -n 1`                   # pocty prvku v CONTCAR 
-echo $jmena 
-echo $pocty 
- 
-i=0 
-for s in $jmena; ​ 
-do 
-str2ar[$i]=$s 
-let i=$i+1 
-done 
- 
-#prepare array of atom numbers per element 
-> elemcol.temp 
-i=0 
-for s in $pocty; 
-do 
-ii=0 
-while [ $ii -lt $s ] 
-do 
-echo ${str2ar[$i]} >> elemcol.temp ​   # temporary file with element names 
-let ii=$ii+1 
-done 
-let i=$i+1 
-done 
- 
-# Sum up pocet prvku 
-nprvku=`echo $pocty | tr " " "​+"​ | bc` 
-echo $nprvku 
- 
-# Extract geometry from vasp format 
-awk -v L=$nprvku 'BEGIN { 
-da=0.0 
-db=0.0 
-dc=0.0 
-} 
-NR==1 {name = $0} 
-NR==2 {k=$1} 
-NR==3 {ax=$1; ay=$2; az=$3} 
-NR==4 {bx=$1; by=$2; bz=$3} 
-NR==5 {cx=$1; cy=$2; cz=$3} 
-(NR>8) && (NR<​=8+L) { 
-  a=$1; b=$2; c=$3; 
-  ​ 
-  a=(a+da)%1 
-  b=(b+db)%1 
-  c=(c+dc)%1 
-  ​ 
-  #​a=(a+da)%1-da 
-  #​b=(b+db)%1-db 
-  #​c=(c+dc)%1-dc 
-  ​ 
- 
-  x=k*(ax*a+bx*b+cx*c) 
-  y=k*(ay*a+by*b+cy*c) 
-  z=k*(az*a+bz*b+cz*c) 
-printf "​%15.6f%15.6f%15.6f\n",​ x, y, z 
-}' $input > xyz.temp 
- 
-# assemble the whole .xyz file 
-echo $nprvku > $output 
-head -n 1 $input >> $output 
-paste elemcol.temp xyz.temp >> $output 
-echo ""​ >> ​ $output 
- 
-# delete temporary files 
-rm *.temp 
-</​code>​ 
- 
- 
- 
-==== v2xyz: ==== 
-  * uses v2xyz 
-<​code>​ 
-#! /bin/bash 
- 
-cp CONTCAR CONTCAR.bak 
- 
-lines=`cat XDATCAR | wc -l` 
-atoms=`awk -v L=$lines '​(NR==6){atoms=0;​ for(i=1;​i<​=NF;​i++){atoms+=$i};​print atoms}'​ CONTCAR` 
-records=`awk -v L=$lines -v a=$atoms ​ '​BEGIN{print (L-5)/​(a+1)}'​ CONTCAR` 
-echo $lines $atoms $records 
- 
-> answer-.xyz 
-for ir in `seq 1 $records`; do 
-echo "​image:​ " $ir 
-cat CONTCAR.bak | head -8 > CONTCAR 
-awk -v ir=$ir -v a=$atoms '​(NR>​(ir-1)*(a+1)+5+1)&&​(NR<​=ir*(a+1)+5){print $0}' XDATCAR >> CONTCAR 
- 
-v2xyz    # call v2xyz, you should have script "​v2xyz"​ in your /bin directory 
- 
-awk -v ir=$ir '​(NR>​NL-2){if(NR==2){print "image #: ",​ir}else{print $0}}' CONTCAR.xyz > temp 
- 
-cat temp >> answer-.xyz 
-done 
- 
-awk '​NR>​(-1) {if (!($0==""​)) print $0}' answer-.xyz > answer.xyz 
-echo ""​ >> answer.xyz 
-</​code>​ 
scripts/v2xyz.txt ยท Last modified: 2011/02/18 13:13 (external edit)