BASH script to extract structure at stationary point from Gaussian09 scan log file.

I am using Gaussian 09 to do dihedral, bond and angle scan now. My lab does not have Gaussian View, and sometimes I need to show the scan procedure or analyze them. QMTool in VMD shows all the structure rather than the stationary structures. So I write this script with BASH to do this job. The script does not have high efficiency but enough for daily demand.

When I paste the script here, it lost the format ūüė¶ ¬† ¬†¬†But it works well.

1.Source ./extract_structure.sh.

2.Type the name of log file with the extension, eg Scan.log.

3.The extracted structures (xyz format) will be stored in a folder with the same name of the log file, eg Scan.

4.A VMD Tcl/Tk script will generate in the folder. The name is combine.tcl.

5.Open VMD and its Tk console and type source combine.tcl. Or simply type vmd -e combine.tcl. VMD will load all the structure as a trajectory. And you may analyze them now.

########################################################

read -p "Gaussian log file " log
((atom=`grep "NAtoms=" $log | head -1 |cut -f2 -d"N" | cut -f2- -d" "`))
head=`cat $log | head -3 | tail -1 | cut -f1 -d"." | cut -f2 -d"="`
((m=`grep "Stationary point found" $log | wc -l`)) #get the total number of stationary point step
((n=`grep "Z-Matrix orientation" $log | wc -l`)) #get the total number of scan step

for ((i=1;i<=$m;i++));do
    ((a=`grep "Stationary point found" $log -n | cut -f1 -d":" | head -"$i" | tail -1`));#echo a=$a
    for ((j=$n;j>=1;j--));do
    ((b=`grep "Z-Matrix orientation" $log -n | cut -f1 -d":" | head -"$j" | tail -1`))
        if (( $b < $a ));then
            (( c = b + 4 + $atom ));#echo b=$b c=$c
            echo $atom > "$head"_stationary_point"$i".xyz
            echo >> "$head"_stationary_point"$i".xyz
            cat $log | head -"$c" | tail -"$atom" | cut -c 15-20,31- >> "$head"_stationary_point"$i".xyz
            break
        fi
    done
done
mkdir "$head"_stationary_point
mv "$head"_stationary_point*.xyz ./"$head"_stationary_point
cd "$head"_stationary_point
for ((i=1;i<=$m;i++));do
    if (( $i == 1 ));then
        echo mol new "$head"_stationary_point"$i".xyz > combine.tcl
    else
        echo mol addfile "$head"_stationary_point"$i".xyz >> combine.tcl
    fi
done

########################################################

Advertisements

One thought on “BASH script to extract structure at stationary point from Gaussian09 scan log file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s