Monday, December 9, 2013

pulling useful information from G03/G09 calculations

A short while after I began grad school, which was years ago now, I realized that checking on the progress of a G03/G09 calculation often required sifting through massive amounts of detritus. Rather than use less and then search through the entire file, I began learning grep, sed, and awk. This post deals with the first command, grep, and how to make custom versions that can pull out specific information. Perhaps the example I use most often is checking on the progress of a geometry optimization. G03/G09 spit out the 4 convergence criteria after each iteration, as shown below.

$ grep -iA3 "maximum force" test.log
 Maximum Force            0.009759     0.000450     NO 
 RMS     Force            0.001640     0.000300     NO 
 Maximum Displacement     0.380695     0.001800     NO 
 RMS     Displacement     0.042164     0.001200     NO 
--
 Maximum Force            0.001122     0.000450     NO 
 RMS     Force            0.000200     0.000300     YES
 Maximum Displacement     0.117795     0.001800     NO 
 RMS     Displacement     0.034630     0.001200     NO 
--
 Maximum Force            0.000796     0.000450     NO 
 RMS     Force            0.000091     0.000300     YES
 Maximum Displacement     0.290041     0.001800     NO 
 RMS     Displacement     0.065495     0.001200     NO 
--
 Maximum Force            0.000462     0.000450     NO 
 RMS     Force            0.000095     0.000300     YES
 Maximum Displacement     0.245764     0.001800     NO 
 RMS     Displacement     0.018789     0.001200     NO 
--
 Maximum Force            0.000530     0.000450     NO 
 RMS     Force            0.000087     0.000300     YES
 Maximum Displacement     0.268022     0.001800     NO 
 RMS     Displacement     0.026751     0.001200     NO 
--
 Maximum Force            0.000268     0.000450     YES
 RMS     Force            0.000051     0.000300     YES
 Maximum Displacement     0.268678     0.001800     NO 
 RMS     Displacement     0.020944     0.001200     NO 

The above command grew tedious when I wanted to monitor more than a couple jobs, hence I made an alias in the .bashrc file in my home directory. This way I only had to type the alias and not the entire grep line.

# extracts geometry convergence criteria
alias grepmax='grep -A3 -i "maximum force"'

# extracts time stamps for each CCSD gradient calc
alias grepccsd='grep "Leave Link  106"'

# extracts the number of steps taken during a geometry opt, IRC, or PES scan
alias grepstep='grep "Step number"'

# extracts the rotational constants (in GHz)
alias greprot='grep "Rotational constants"'

# extracts the harmonic vibrational frequencies (3 columns)
alias grepfreq='grep "Frequencies"'

# extracts the G3 energy (at 0 K and at finite T, but not the enthalpy or free energy)
alias grepg3='grep "G3(0 K)"'

No comments:

Post a Comment