1 | #!@PYTHON@
|
---|
2 | #
|
---|
3 | # converts mpqc output files to pcp.energy.all, pcp.forces.all and pcp.speed for joiner/analyzer to work on
|
---|
4 |
|
---|
5 | import sys, string, re, math
|
---|
6 | wrerr = sys.stderr.write
|
---|
7 |
|
---|
8 | if len(sys.argv) < 3:
|
---|
9 | wrerr("Usage: "+sys.argv[0]+" <configbase> <prefix>\n")
|
---|
10 | sys.exit(1)
|
---|
11 |
|
---|
12 | output = open(sys.argv[1]+".conf.out", "r")
|
---|
13 | config = open(sys.argv[1]+".conf", "r")
|
---|
14 | energy = open(sys.argv[2]+".energy.all", "w")
|
---|
15 | forces = open(sys.argv[2]+".forces.all", "w")
|
---|
16 | speed = open(sys.argv[2]+".speed", "w")
|
---|
17 |
|
---|
18 | # prepare the headers
|
---|
19 | print >>energy,"Time\t\tTotal"
|
---|
20 | print >>forces,"Type\tNo\t\tPos0\t\tPos1\t\tPos2\t\tTotal0\t\tTotal1\t\tTotal2"
|
---|
21 | print >>speed,"\nMaxG[] = nA nA nA -> N[] = nA nA nA"
|
---|
22 | print >>speed,"LevNo MaxG RMaxG MaxN N[0] N[1] N[2] RLevSStep"
|
---|
23 | print >>speed,"0 5147691 10295381 25165824 384 256 256 0"
|
---|
24 | print >>speed,"1 643665 1287329 3145728 192 128 128 267"
|
---|
25 | print >>speed,"2 80442 160883 393216 96 64 64 267"
|
---|
26 | print >>speed,"3 10074 20147 49152 48 32 32 333"
|
---|
27 | print >>speed,"4 1264 2527 6144 24 16 16 862"
|
---|
28 | print >>speed,"procs proc[0] proc[1] PsiMax PsiDoub PsiUp PsiDown NRStep TotalIons"
|
---|
29 | print >>speed,"1 1 1 $Psi $Psi+0 0+0 0+0 1 $nr"
|
---|
30 |
|
---|
31 | # parse the config file
|
---|
32 | nr=0
|
---|
33 | limit=0
|
---|
34 | for line in config:
|
---|
35 | nr=nr+1
|
---|
36 | if "# ====== MD step" in line:
|
---|
37 | limit=nr
|
---|
38 | config.seek(0)
|
---|
39 | #print "Beginning with line %d ..." % (limit)
|
---|
40 | n=0
|
---|
41 | nr=0
|
---|
42 | atompos = []
|
---|
43 | for line in config:
|
---|
44 | nr=nr+1
|
---|
45 | #print "%d > %d ?" % (limit, nr)
|
---|
46 | if limit > nr:
|
---|
47 | continue
|
---|
48 | #print "%d: %s" % (nr,line)
|
---|
49 | if re.compile("Ion_Type[0-9]+[_]+").match(line):
|
---|
50 | words = line.split("Type")
|
---|
51 | words2 = (words[0]+"Type_"+words[1]).split()
|
---|
52 | #print words2
|
---|
53 | #print words
|
---|
54 | atompos.append(words2[0]+"_"+words2[1]+"_"+words2[2]+"_"+words2[3])
|
---|
55 | n=n+1
|
---|
56 | print "I found ",n," atoms."
|
---|
57 |
|
---|
58 | if n == 0:
|
---|
59 | wrerr("Quitting.\n")
|
---|
60 | sys.exit(1)
|
---|
61 |
|
---|
62 | # parse the output file for ...
|
---|
63 | line = output.readline()
|
---|
64 | EnergyWritten = 0
|
---|
65 | while (line != ''):
|
---|
66 | # energy
|
---|
67 | if "total scf energy" in line:
|
---|
68 | if EnergyWritten == 0:
|
---|
69 | words = line.split()
|
---|
70 | #print words
|
---|
71 | print >>energy,"0.000000e+00\t",words[4]
|
---|
72 | EnergyWritten = 1
|
---|
73 | # forces
|
---|
74 | if "Total Gradient:" in line:
|
---|
75 | #print "found gradient"
|
---|
76 | mean=0.
|
---|
77 | for i in range(n):
|
---|
78 | line = output.readline()
|
---|
79 | words = line.split()
|
---|
80 | atome = atompos[i].split("_")
|
---|
81 | #print atome
|
---|
82 | #print words
|
---|
83 | print >>forces,"%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s" % ( (int(atome[2])-1),(int(atome[3])-1),atome[4],atome[5],atome[6],words[2],words[3],words[4] )
|
---|
84 | mean += math.sqrt(math.pow(float(words[2]),2)+math.pow(float(words[3]),2)+math.pow(float(words[4]),2))
|
---|
85 | print >>forces,"MeanForce:\t",mean/n
|
---|
86 | # speed
|
---|
87 | if "mpqc:" in line:
|
---|
88 | types=["Types"]
|
---|
89 | cpu=["CPU"]
|
---|
90 | wall=["Wall"]
|
---|
91 | for i in range(25):
|
---|
92 | words = line.split(":")
|
---|
93 | times = words[1].split()
|
---|
94 | types.append(words[0])
|
---|
95 | cpu.append(times[0])
|
---|
96 | wall.append(times[1])
|
---|
97 | line = output.readline()
|
---|
98 | for j in range(25):
|
---|
99 | types[j] = types[j].replace('_', '') # TeX does not like underscores in non-math env
|
---|
100 | speed.write(types[j]+"\t")
|
---|
101 | speed.write("\n")
|
---|
102 | for j in range(25):
|
---|
103 | speed.write(cpu[j]+"\t")
|
---|
104 | speed.write("\n")
|
---|
105 | for j in range(25):
|
---|
106 | speed.write(wall[j]+"\t")
|
---|
107 | speed.write("\n")
|
---|
108 | line = output.readline()
|
---|