Created
          October 21, 2014 02:45 
        
      - 
      
 - 
        
Save langner/ac912b36122c367c5ab4 to your computer and use it in GitHub Desktop.  
    Example of how to calculate the nuclear repulsion energy from parsed cclib data
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import cclib | |
| import numpy | |
| import urllib | |
| def nuclear_repulsion_energy(data): | |
| nre = 0.0 | |
| for i in range(data.natom): | |
| ri = data.atomcoords[0][i] | |
| zi = data.atomnos[i] | |
| for j in range(i+1, data.natom): | |
| rj = data.atomcoords[0][j] | |
| zj = data.atomnos[j] | |
| d = numpy.linalg.norm(ri-rj) | |
| nre += zi*zj/d | |
| return nre | |
| if __name__ == "__main__": | |
| logurl = "https://raw.githubusercontent.com/cclib/cclib/master/data/QChem/basicQChem4.2/water_mp4sdq.out" | |
| logfile = cclib.parser.ccopen(urllib.urlopen(logurl)) | |
| data = logfile.parse() | |
| a2b = cclib.parser.utils.convertor(1.0, "Angstrom", "bohr") | |
| print "In hartrees:", nuclear_repulsion_energy(data) / a2b | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment