Freq 2.s: Difference between revisions

From Wiki
Jump to navigation Jump to search
New page: go back to Main Page, Computational Resources, Scripts, Useful scripts Execute this script (freq.s OUTCAR) will generate a file called MOLCAR. This file is legible for MO...
 
No edit summary
Line 10: Line 10:
  #
  #


file=$1
file=$1
echo [MOLDEN FORMAT] > MOLCAR
echo [MOLDEN FORMAT] > MOLCAR
echo [FREQ] >> MOLCAR


echo [FREQ] >> MOLCAR
declare -a typ_freq
declare -a typ_freq
declare -a list_freq
declare -a list_freq
declare -a num_ions_type
declare -a num_ions_type


num_freq=$(grep cm-1 $file | awk '{print $1}' | tail -1)
num_freq=$(grep cm-1 $file | awk '{print $1}' | tail -1)
list_freq=($(grep cm-1 $file | cut -b 10- | awk '{print $5}' | tail -$num_freq))
list_freq=($(grep cm-1 $file | cut -b 10- | awk '{print $5}' | tail -$num_freq))
typ_freq=($(grep cm-1 $file |  awk '{print $2}' ))
typ_freq=($(grep cm-1 $file |  awk '{print $2}' ))


let k=$num_freq-1
let k=$num_freq-1
for i in $(seq 0 $k); do
for i in $(seq 0 $k); do
  <nowiki>if [[ ${typ_freq[$i]} = "f/i=" ]];then</nowiki>
    if [[ ${typ_freq[$i]} = "f/i=" ]];then
         list_freq[$i]=-${list_freq[$i]}
         list_freq[$i]=-${list_freq[$i]}
     fi
     fi
     echo ${list_freq[$i]} >> MOLCAR  
     echo ${list_freq[$i]} >> MOLCAR
done
 
num_ions_type=($(grep "ions per type" $file | cut -b 20- ))
let j=$(grep -c POTCAR $file)/2
for i in $(seq 1 $j); do
  let k=$i-1
  ions_type[$k]=$(grep POTCAR $file | awk '{print $3}' | head -$i | tail -1  )
done
num_ions=$(grep IONS $file | awk '{print $12}')
 
 
echo [FR-COORD] >> MOLCAR
let k=$num_ions
p=0
j=${num_ions_type[$p]}
cap=0
for i in $(seq 1 $k); do
    atom=${ions_type[$p]}
    if [[ $j = $i && $j != $k ]]; then
        let p=$p+1
        let j=$j+${num_ions_type[$p]}
    fi
    let cap=$i+1
    b=1.88973
    X=$(echo "sacale=5; $(grep -$cap cm-1 $file | tail -1 | awk '{print $1}')*$b " | bc)
    Y=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $2}')*$b " | bc)
    Z=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $3}')*$b " | bc)
    echo $atom $X $Y $Z >> MOLCAR
 
    Vx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $1}')*$b " | bc)
    X1=$(echo "sacale=5; $X+$Vx " | bc)
    Vy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $2}')*$b " | bc)
    Y1=$(echo "sacale=5; $Y+$Vy " | bc)
    Vz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $3}')*$b " | bc)
    Z1=$(echo "sacale=5; $Z+$Vz " | bc)
    echo $atom $X1 $Y1 $Z1 >> MOLCAR
    Vxx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $1}')*$b " | bc)
    X1=$(echo "sacale=5; $X+$Vxx " | bc)
    Vyy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $2}')*$b " | bc)
    Y1=$(echo "sacale=5; $Y+$Vyy " | bc)
    Vzz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $3}')*$b " | bc)
    Z1=$(echo "sacale=5; $Z+$Vzz " | bc)
    echo $atom $X1 $Y1 $Z1 >> MOLCAR
    X1=$(echo "sacale=5; $X+$Vx+$Vxx " | bc)
    Y1=$(echo "sacale=5; $Y+$Vy+$Vyy " | bc)
    Z1=$(echo "sacale=5; $Z+$Vz+$Vzz " | bc)
    echo $atom $X1 $Y1 $Z1 >> MOLCAR
done
echo [FR-NORM-COORD] >> MOLCAR
for i in $(seq 1 $num_freq); do
    echo vibration  $i >> MOLCAR
    cap=1
    txt=$i" f"
    for t in $(seq 1 $num_ions); do
        let cap=$cap+1
          b=1
          dX=$(echo "sacale=5; $(grep -$cap "$txt" $file | tail -1 | awk '{print $4}')*$b " | bc)
          dY=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $5}')*$b " | bc)
          dZ=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $6}')*$b " | bc)
          echo $dX $dY $dZ >> MOLCAR
          echo $dX $dY $dZ >> MOLCAR
          echo $dX $dY $dZ >> MOLCAR
          echo $dX $dY $dZ >> MOLCAR
    done
  done
  done


  num_ions_type=($(grep "ions per type" $file | cut -b 20- ))
molden MOLCAR
let j=$(grep -c POTCAR $file)/2
 
for i in $(seq 1 $j); do
#rm MOLCARfile=$1
    let k=$i-1
echo [MOLDEN FORMAT] > MOLCAR
    ions_type[$k]=$(grep POTCAR $file | awk '{print $3}' | head -$i | tail -1  )
echo [FREQ] >> MOLCAR
done
 
num_ions=$(grep IONS $file | awk '{print $12}')
declare -a typ_freq
declare -a list_freq
echo [FR-COORD] >> MOLCAR
declare -a num_ions_type
let k=$num_ions
 
p=0
num_freq=$(grep cm-1 $file | awk '{print $1}' | tail -1)
j=${num_ions_type[$p]}
list_freq=($(grep cm-1 $file | cut -b 10- | awk '{print $5}' | tail -$num_freq))
cap=0
typ_freq=($(grep cm-1 $file | awk '{print $2}' ))
for i in $(seq 1 $k); do
 
    atom=${ions_type[$p]}
let k=$num_freq-1
    <nowiki>if [[ $j = $i && $j != $k ]]; then</nowiki>
for i in $(seq 0 $k); do
    if [[ ${typ_freq[$i]} = "f/i=" ]];then
        list_freq[$i]=-${list_freq[$i]}
    fi
    echo ${list_freq[$i]} >> MOLCAR
done
 
num_ions_type=($(grep "ions per type" $file | cut -b 20- ))
let j=$(grep -c POTCAR $file)/2
for i in $(seq 1 $j); do
  let k=$i-1
  ions_type[$k]=$(grep POTCAR $file | awk '{print $3}' | head -$i | tail -1  )
done
num_ions=$(grep IONS $file | awk '{print $12}')
 
 
echo [FR-COORD] >> MOLCAR
let k=$num_ions
p=0
j=${num_ions_type[$p]}
cap=0
for i in $(seq 1 $k); do
    atom=${ions_type[$p]}
    if [[ $j = $i && $j != $k ]]; then
         let p=$p+1
         let p=$p+1
         let j=$j+${num_ions_type[$p]}
         let j=$j+${num_ions_type[$p]}
     fi
     fi
     let cap=$i+1
     let cap=$i+1
     b=1.8897
     b=1.88973
     X=$(echo "sacale=5; $(grep -$cap cm-1 $file | tail -1 | awk '{print $1}')*$b " | bc)
     X=$(echo "sacale=5; $(grep -$cap cm-1 $file | tail -1 | awk '{print $1}')*$b " | bc)
     Y=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $2}')*$b " | bc)
     Y=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $2}')*$b " | bc)
     Z=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $3}')*$b " | bc)
     Z=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $3}')*$b " | bc)
     echo $atom $X $Y $Z >> MOLCAR
     echo $atom $X $Y $Z >> MOLCAR
done


    Vx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $1}')*$b " | bc)
    X1=$(echo "sacale=5; $X+$Vx " | bc)
    Vy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $2}')*$b " | bc)
    Y1=$(echo "sacale=5; $Y+$Vy " | bc)
    Vz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $3}')*$b " | bc)
    Z1=$(echo "sacale=5; $Z+$Vz " | bc)
    echo $atom $X1 $Y1 $Z1 >> MOLCAR
    Vxx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $1}')*$b " | bc)
    X1=$(echo "sacale=5; $X+$Vxx " | bc)
    Vyy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $2}')*$b " | bc)
    Y1=$(echo "sacale=5; $Y+$Vyy " | bc)
    Vzz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $3}')*$b " | bc)
    Z1=$(echo "sacale=5; $Z+$Vzz " | bc)
    echo $atom $X1 $Y1 $Z1 >> MOLCAR
    X1=$(echo "sacale=5; $X+$Vx+$Vxx " | bc)
    Y1=$(echo "sacale=5; $Y+$Vy+$Vyy " | bc)
    Z1=$(echo "sacale=5; $Z+$Vz+$Vzz " | bc)
    echo $atom $X1 $Y1 $Z1 >> MOLCAR
done
  echo [FR-NORM-COORD] >> MOLCAR
  echo [FR-NORM-COORD] >> MOLCAR
 
  for i in $(seq 1 $num_freq); do
  for i in $(seq 1 $num_freq); do
    echo vibration  $i >> MOLCAR
    echo vibration  $i >> MOLCAR
    cap=1
    cap=1
    txt=$i" f"  
    txt=$i" f"  
    for t in $(seq 1 $num_ions); do
    for t in $(seq 1 $num_ions); do
        let cap=$cap+1
        let cap=$cap+1
        b=1.8897
          b=1
        dX=$(echo "sacale=5; $(grep -$cap "$txt" $file | tail -1 | awk '{print $4}')*$b " | bc)
          dX=$(echo "sacale=5; $(grep -$cap "$txt" $file | tail -1 | awk '{print $4}')*$b " | bc)
        dY=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $5}')*$b " | bc)
          dY=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $5}')*$b " | bc)
        dZ=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $6}')*$b " | bc)
          dZ=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $6}')*$b " | bc)
        echo $dX $dY $dZ >> MOLCAR
          echo $dX $dY $dZ >> MOLCAR
    done
          echo $dX $dY $dZ >> MOLCAR
          echo $dX $dY $dZ >> MOLCAR
          echo $dX $dY $dZ >> MOLCAR
    done
  done
  done


molden MOLCAR
molden MOLCAR
 
#rm MOLCAR
#rm MOLCAR

Revision as of 14:19, 14 May 2010

go back to Main Page, Computational Resources, Scripts, Useful scripts

Execute this script (freq.s OUTCAR) will generate a file called MOLCAR. This file is legible for MOLDEN, and includes all the vibrations.


#
# Gerard Novell Leruth
# Conversion archivos OUTCAR de frecuencias VASP 4.6 a molden format con duplicación de celda en XY
# Uso: freq_2.s OUTCAR
#

file=$1 echo [MOLDEN FORMAT] > MOLCAR echo [FREQ] >> MOLCAR

declare -a typ_freq declare -a list_freq declare -a num_ions_type

num_freq=$(grep cm-1 $file | awk '{print $1}' | tail -1) list_freq=($(grep cm-1 $file | cut -b 10- | awk '{print $5}' | tail -$num_freq)) typ_freq=($(grep cm-1 $file | awk '{print $2}' ))

let k=$num_freq-1 for i in $(seq 0 $k); do

   if [[ ${typ_freq[$i]} = "f/i=" ]];then
       list_freq[$i]=-${list_freq[$i]}
   fi
   echo ${list_freq[$i]} >> MOLCAR

done

num_ions_type=($(grep "ions per type" $file | cut -b 20- )) let j=$(grep -c POTCAR $file)/2 for i in $(seq 1 $j); do

  let k=$i-1
  ions_type[$k]=$(grep POTCAR $file | awk '{print $3}' | head -$i | tail -1  )

done num_ions=$(grep IONS $file | awk '{print $12}')


echo [FR-COORD] >> MOLCAR let k=$num_ions p=0 j=${num_ions_type[$p]} cap=0 for i in $(seq 1 $k); do

   atom=${ions_type[$p]}
   if $j = $i && $j != $k ; then
       let p=$p+1
       let j=$j+${num_ions_type[$p]}
   fi
   let cap=$i+1
   b=1.88973
   X=$(echo "sacale=5; $(grep -$cap cm-1 $file | tail -1 | awk '{print $1}')*$b " | bc)
   Y=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $2}')*$b " | bc)
   Z=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $3}')*$b " | bc)
   echo $atom $X $Y $Z >> MOLCAR
   Vx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $1}')*$b " | bc)
   X1=$(echo "sacale=5; $X+$Vx " | bc)
   Vy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $2}')*$b " | bc)
   Y1=$(echo "sacale=5; $Y+$Vy " | bc)
   Vz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $3}')*$b " | bc)
   Z1=$(echo "sacale=5; $Z+$Vz " | bc)

   echo $atom $X1 $Y1 $Z1 >> MOLCAR

   Vxx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $1}')*$b " | bc)
   X1=$(echo "sacale=5; $X+$Vxx " | bc)
   Vyy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $2}')*$b " | bc)
   Y1=$(echo "sacale=5; $Y+$Vyy " | bc)
   Vzz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $3}')*$b " | bc)
   Z1=$(echo "sacale=5; $Z+$Vzz " | bc)

   echo $atom $X1 $Y1 $Z1 >> MOLCAR


   X1=$(echo "sacale=5; $X+$Vx+$Vxx " | bc)
   Y1=$(echo "sacale=5; $Y+$Vy+$Vyy " | bc)
   Z1=$(echo "sacale=5; $Z+$Vz+$Vzz " | bc)

   echo $atom $X1 $Y1 $Z1 >> MOLCAR


done

echo [FR-NORM-COORD] >> MOLCAR

for i in $(seq 1 $num_freq); do
    echo vibration  $i >> MOLCAR
    cap=1
    txt=$i" f" 
    for t in $(seq 1 $num_ions); do
        let cap=$cap+1
         b=1
         dX=$(echo "sacale=5; $(grep -$cap "$txt" $file | tail -1 | awk '{print $4}')*$b " | bc)
         dY=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $5}')*$b " | bc)
         dZ=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $6}')*$b " | bc)
         echo $dX $dY $dZ >> MOLCAR
         echo $dX $dY $dZ >> MOLCAR
         echo $dX $dY $dZ >> MOLCAR
         echo $dX $dY $dZ >> MOLCAR

    done
done

molden MOLCAR

  1. rm MOLCARfile=$1

echo [MOLDEN FORMAT] > MOLCAR echo [FREQ] >> MOLCAR

declare -a typ_freq declare -a list_freq declare -a num_ions_type

num_freq=$(grep cm-1 $file | awk '{print $1}' | tail -1) list_freq=($(grep cm-1 $file | cut -b 10- | awk '{print $5}' | tail -$num_freq)) typ_freq=($(grep cm-1 $file | awk '{print $2}' ))

let k=$num_freq-1 for i in $(seq 0 $k); do

   if [[ ${typ_freq[$i]} = "f/i=" ]];then
       list_freq[$i]=-${list_freq[$i]}
   fi
   echo ${list_freq[$i]} >> MOLCAR

done

num_ions_type=($(grep "ions per type" $file | cut -b 20- )) let j=$(grep -c POTCAR $file)/2 for i in $(seq 1 $j); do

  let k=$i-1
  ions_type[$k]=$(grep POTCAR $file | awk '{print $3}' | head -$i | tail -1  )

done num_ions=$(grep IONS $file | awk '{print $12}')


echo [FR-COORD] >> MOLCAR let k=$num_ions p=0 j=${num_ions_type[$p]} cap=0 for i in $(seq 1 $k); do

   atom=${ions_type[$p]}
   if $j = $i && $j != $k ; then
       let p=$p+1
       let j=$j+${num_ions_type[$p]}
   fi
   let cap=$i+1
   b=1.88973
   X=$(echo "sacale=5; $(grep -$cap cm-1 $file | tail -1 | awk '{print $1}')*$b " | bc)
   Y=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $2}')*$b " | bc)
   Z=$(echo "sacale=5;  $(grep -$cap cm-1 $file | tail -1 | awk '{print $3}')*$b " | bc)
   echo $atom $X $Y $Z >> MOLCAR
   Vx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $1}')*$b " | bc)
   X1=$(echo "sacale=5; $X+$Vx " | bc)
   Vy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $2}')*$b " | bc)
   Y1=$(echo "sacale=5; $Y+$Vy " | bc)
   Vz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -3 | head -1 |awk '{print $3}')*$b " | bc)
   Z1=$(echo "sacale=5; $Z+$Vz " | bc)

   echo $atom $X1 $Y1 $Z1 >> MOLCAR

   Vxx=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $1}')*$b " | bc)
   X1=$(echo "sacale=5; $X+$Vxx " | bc)
   Vyy=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $2}')*$b " | bc)
   Y1=$(echo "sacale=5; $Y+$Vyy " | bc)
   Vzz=$(echo "sacale=5; $(grep "direct lattice" $file -3 | tail -2 | head -1 |awk '{print $3}')*$b " | bc)
   Z1=$(echo "sacale=5; $Z+$Vzz " | bc)

   echo $atom $X1 $Y1 $Z1 >> MOLCAR


   X1=$(echo "sacale=5; $X+$Vx+$Vxx " | bc)
   Y1=$(echo "sacale=5; $Y+$Vy+$Vyy " | bc)
   Z1=$(echo "sacale=5; $Z+$Vz+$Vzz " | bc)

   echo $atom $X1 $Y1 $Z1 >> MOLCAR


done

echo [FR-NORM-COORD] >> MOLCAR

for i in $(seq 1 $num_freq); do
    echo vibration  $i >> MOLCAR
    cap=1
    txt=$i" f" 
    for t in $(seq 1 $num_ions); do
        let cap=$cap+1
         b=1
         dX=$(echo "sacale=5; $(grep -$cap "$txt" $file | tail -1 | awk '{print $4}')*$b " | bc)
         dY=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $5}')*$b " | bc)
         dZ=$(echo "sacale=5;  $(grep -$cap "$txt" $file | tail -1 | awk '{print $6}')*$b " | bc)
         echo $dX $dY $dZ >> MOLCAR
         echo $dX $dY $dZ >> MOLCAR
         echo $dX $dY $dZ >> MOLCAR
         echo $dX $dY $dZ >> MOLCAR

    done
done

molden MOLCAR

  1. rm MOLCAR