-
Notifications
You must be signed in to change notification settings - Fork 0
/
max_ind_dipole.py
executable file
·66 lines (64 loc) · 1.85 KB
/
max_ind_dipole.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python
# Arnfinn Hykkerud Steindal, Tromso July 2011
# Get the largest PE induced dipoles from an output file.
import re
import sys
import shutil
import string
import math
for i in sys.argv[1:]:
try:
file = open(i,'r')
except:
print 'Did not find file '+i
break
start = False
lines = file.readlines()
k = 0
dipoles=[]
cont=True
for line in lines:
if False:
# if '' in lines:
l=0
while (cont):
l=l+1
try:
a=int(line(k+l+3).split()[0])
except:
cont=False
if 'Final results from SIRIUS' in line:
fac=65
start = True
if 'FINAL RESULTS FROM SIRIUS' in line:
fac=56
start = True
if start:
try:
num= int(lines[k-fac].split()[0])
except:
try:
fac = fac + 2
num= int(lines[k-fac].split()[0])
except:
print 'Something wrong with line'
print lines[k-fac]
break
for j in range(num):
dipoles.append([])
site=lines[k-num-fac+j+1].split()
x2=float(site[1])*float(site[1])
y2=float(site[2])*float(site[2])
z2=float(site[3])*float(site[3])
dipoles[j].append(math.sqrt(x2+y2+z2))
dipoles[j].append(j+1)
# test = sorted(dipoles, key=lambda dip: dip[1])
dipoles.sort(reverse=True)
break
k = k + 1
print 'The ten highest induced dipole moments:'
for j in range(10):
site=str(dipoles[j][1])
a=7-len(site)
print site + a*' ' + str(dipoles[j][0])
file.close()