1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#! /usr/bin/python
import os
import sys
import re
cenpat = re.compile(" CENTER +[\d\.-]+ +[\d\.-]+ +[\d\.-]+ +([\d\.-]+)")
radpat = re.compile(" 1 CENTER +[\d\.-]+ +([\d\.-]+)")
engpat = re.compile(" FINAL U-B3LYP ENERGY IS +([\d\.-]+)")
Hartree = 4.3597482 # attoJoules
Bohr = 0.5291772083 # Angstroms
def findnext(f,pat):
while 1:
card = f.readline()
if not card: return None
m = pat.match(card)
if m: return m.group(1)
def ending(nam,suf):
if suf==nam[-len(suf):]: return nam
else: return nam+suf
def xeread(name):
f=open(ending(name,'.log'),"r")
x = float(findnext(f, cenpat))
r = float(findnext(f, radpat))
e = float(findnext(f, engpat))
f.close()
return x*Bohr, e*Hartree, r # already in Angstroms
namelist = sys.argv[1:]
for name in namelist:
x, e, r = xeread(name)
if e!=0.0:
print x, e, r
if x != 0.0:
print -x, e, r
|