#!/bin/tcsh -f # ############################################################################################################# # The uv script is supplied by the Laboratory for Molecular Simulation (LMS) # # at Texas A&M University and is provided on an "as is" basis. # # # # http://www.chem.tamu.edu/LMS # # # # The uv script was specifically designed to run on the sc (http://sc.tamu.edu) and TAMU # # chemistry computers but may be modified to run on any machine that has synspec and gnuplot installed. # # # # Author: Lisa M. Perez, Manager of the LMS # # # # Last update: April 24, 2007 # # # ############################################################################################################# if ( -e /chem/synspec/synspec ) setenv SYNSPEC /chem/synspec if ( -e /usr/local/lms/synspec/synspec ) setenv SYNSPEC /usr/local/lms/synspec if ( -e $HOME/synspec ) setenv SYNSPEC $HOME # uncomment and change the following line to point to the install location of the synspec executable #setenv SYNSPEC /usr/local/lms/synspec if ( ! -e $SYNSPEC/synspec ) then echo 'The syspec program could not be found. Please contact Lisa Perez mouse@mail.chem.tamu.edu for assistance.' exit endif set test_gnuplot=`which gnuplot|grep "Command not found"|wc -l` if ( $test_gnuplot == 1 ) then echo 'The gnuplot program could not be found. Please contact Lisa Perez mouse@mail.chem.tamu.edu for assistance.' exit endif # default values set minx=100 set maxx=800 set maxy=0.01 set width=10 set plotall=0 set plotallonly=0 if ( $#argv == 0 ) goto help foreach i ( $* ) switch ($i) case -help : goto help breaksw case -minx[0-9]* : set minx=`echo $i|sed 's/-minx//'` breaksw case -maxx[1-9]* : set maxx=`echo $i|sed 's/-maxx//'` breaksw case -maxy[0-9]* : set maxy=`echo $i|sed 's/-maxy//'` breaksw case -w[0-9]* : set width=`echo $i|sed 's/-w//'` breaksw case -a : set plotall=1 breaksw case -ao : set plotallonly=1 breaksw case -* : echo unknown flag $i breaksw case * : if ( $?files ) then set files="$i $files" else set files=$i endif breaksw endsw end if ( $plotallonly == 0 ) then echo Settings: echo '--------------------------------------' echo width = $width echo Range of X = $minx to $maxx echo Range of Y = 0 to $maxy echo '--------------------------------------' echo '' echo 'The following files will be processed' $files foreach file ( $files ) if ( -f $file ) then set num=`grep 'nm f=' $file|wc -l` echo '' echo File being processed = $file with $num excitations echo '' echo $num > synspec.inp;grep 'nm f=' $file |awk '{print $7" "$9}'|sed 's/f=/ /' >> synspec.inp; \ set file=$file:r set file=$file:t cp synspec.inp $file.excitations #create .input file echo 1 > .synspec_input echo $width >> .synspec_input echo $minx >> .synspec_input echo $maxx >> .synspec_input echo 1 >> .synspec_input $SYNSPEC/synspec < .synspec_input >& /dev/null mv synspec.dat $file.gnuplot echo 'set xr ['$minx':'$maxx']'> $file.gnuplot_settings echo 'set yr [0:'$maxy']'>> $file.gnuplot_settings echo 'set title " Simulated UV spectra from '$file' calculation\\n Intensity vs. Energy (nm)" ' >> $file.gnuplot_settings echo 'set xlabel "nm" ' >> $file.gnuplot_settings echo 'set ylabel "Intensity" ' >> $file.gnuplot_settings echo 'show title' >> $file.gnuplot_settings echo 'show xlabel' >> $file.gnuplot_settings echo 'show ylabel' >> $file.gnuplot_settings #echo 'plot "'$file'.imp" with i lt 2 lw 1,"'$file'.gnuplot" with l lt 1 lw 2' >> $file.gnuplot_settings echo 'plot "'$file'.gnuplot" with l lt 1 lw 2' >> $file.gnuplot_settings #echo 'set output "'$file'.png"' >> $file.gnuplot_settings echo 'set output "'$file'.ps"' >> $file.gnuplot_settings #echo 'set term png color' >> $file.gnuplot_settings echo 'set term postscript color' >> $file.gnuplot_settings echo 'replot'>> $file.gnuplot_settings gnuplot -persist $file.gnuplot_settings >& /dev/null ps2pdf $file.ps rm $file.ps echo 'Files created:' echo ' '$file'.inp input file for synspec.' echo ' '$file'.excitations excitations from calculations.' echo ' '$file'.gnuplot x,y values generated from synspec program. May be imported for plotting in excel' echo ' '$file'.gnuplot_settings gnuplot commands for plotting.' echo ' '$file'.pdf pdf file of plot' echo '' echo 'excitations from excitation calculations' echo '' echo ' nm oscillator' echo ' strength' echo '---------------------------' tail -n $num $file.excitations echo '---------------------------' echo '' else echo 'The file '$file' does not exist and will therefore be skipped' echo '' endif end endif if ( $plotall == 1 || $plotallonly == 1 ) then echo '' echo Creating all.gnuplot_settings echo '' set linecolor=1 if ( -e all.gnuplot_settings ) \rm all.gnuplot_settings echo '' set test_cycle=0 foreach file ( $files ) set file=$file:r set file=$file:t if ( $test_cycle == 0 ) then cat $file.gnuplot_settings|egrep -v '^set output|^set term|^replot'|sed "s/lt 1/lt $linecolor/" >> all.gnuplot_settings set test_cycle=1 @ linecolor++ else cat $file.gnuplot_settings|egrep -v '^set output|^set term|^replot'|sed 's/^plot/replot/'|sed "s/lt 1/lt $linecolor/" >> all.gnuplot_settings @ linecolor++ endif end echo 'set title "Simulated UV spectra from calculations\\n Intensity vs. Energy (nm)"' >> all.gnuplot_settings echo 'replot' >> all.gnuplot_settings echo 'set output "all_uvvis.ps"' >> all.gnuplot_settings echo 'set term postscript color' >> all.gnuplot_settings echo 'replot' >> all.gnuplot_settings gnuplot -persist all.gnuplot_settings >& /dev/null echo '' echo 'Creating the all_uvvis.pdf file' echo '' ps2pdf all_uvvis.ps \rm all_uvvis.ps endif echo 'Please include the following citation in all publications:' echo 'Spectra were simulated using the Synspec program[1]' echo '' echo '[1] Karl K. Irikura National Institute of Standards and Technology, Gaithersburg, MD 20899, USA, 2005' echo '' exit ##########################################################################################################33 help: echo '' echo 'The uv script will take the output from a gaussian td or cis calculation and use the program synspec' echo ' to create a simulated uv/vis spectra and plot it using gnuplot' echo '' echo 'syntax: uv -minx[minx in nm] -maxx[maxx in nm] -maxy[maxy] -w[line width] -ao -a filenames' echo '' echo 'where: line width is the line width (default 10)' echo ' minx in nm is the lowest wavelenght to include in the plot (Default 100)' echo ' maxx in nm is the highest wavelenght to include in the plot (Default 800)' echo ' maxy is the highest y value to include in the plot which is proportional to the extinction coefficient (Default 0.01)' echo ' filename is the name of the output file with the extension (ie. test.out or test.log). ' echo ' You may put the path to the filename (ie. ~/test.out /lms/usr/smith/run1/file1.out) ' echo ' You may also use wildcards or a list of files to process multiple files (ie. ~/*td*.out /lms/usr/smith/run1/file?.out) ' echo '' echo ' -a will also plot the spectra from all listed filenames in one plot.' echo '' echo ' -ao will only plot the spectra from all listed filenames in one plot. The files must have already been processed with synspec ' echo ' and all other flags will be ignored. ' echo '' echo 'The uv script requires that gnuplot and syspec is installed on your system' echo '' echo 'Please include the following citation in all publications:' echo 'Spectra were simulated using the Synspec program[1]' echo '' echo '[1] Karl K. Irikura, National Institute of Standards and Technology, Gaithersburg, MD 20899, USA, 2005' echo ''