1 | #!@PYTHON@
|
---|
2 | #
|
---|
3 | # crudely converts an espack config file to a mpqc config file
|
---|
4 |
|
---|
5 | import sys, string, re, math
|
---|
6 | wrerr = sys.stderr.write
|
---|
7 |
|
---|
8 | config = open(sys.argv[1]+".conf", "r")
|
---|
9 | input = open(sys.argv[1]+".in", "w")
|
---|
10 |
|
---|
11 |
|
---|
12 | BASIS = "STO-3G"
|
---|
13 |
|
---|
14 | # parse in atom coordinates & element symbols
|
---|
15 | n=0
|
---|
16 | atompos = []
|
---|
17 | elements = []
|
---|
18 | sys.stdout.write("Elemente: ")
|
---|
19 | for line in config:
|
---|
20 | if re.compile("Ion_Type[0-9]+[^_]+").match(line):
|
---|
21 | words = line.split("Type")
|
---|
22 | words2 = (words[0]+"Type_"+words[1]).split()
|
---|
23 | sys.stdout.write(words2[8]+" ")
|
---|
24 | elements.append(words2[8])
|
---|
25 | if re.compile("Ion_Type[0-9]+[_]+").match(line):
|
---|
26 | words = line.split()
|
---|
27 | iontype = words[0].split("_")
|
---|
28 | print words
|
---|
29 | atompos.append(iontype[1].lstrip("Type")+"_"+words[1]+"_"+words[2]+"_"+words[3])
|
---|
30 | n=n+1
|
---|
31 | sys.stdout.write("\n")
|
---|
32 | print "I found ",n," atoms."
|
---|
33 |
|
---|
34 | # general stuff
|
---|
35 | print >>input,"% espack2mpqc.sh"
|
---|
36 | print >>input,"mpqc: ("
|
---|
37 | print >>input,"\tsavestate = no"
|
---|
38 | print >>input,"\tdo_gradient = yes"
|
---|
39 | print >>input,"\tmole<CLHF>: ("
|
---|
40 | print >>input,"\t\tmolecule<Molecule>: ("
|
---|
41 | print >>input,"\t\t\tunit = angstrom"
|
---|
42 | print >>input,"\t\t\t{ atoms geometry } = {"
|
---|
43 | for i in range(n):
|
---|
44 | atome = atompos[i].split("_")
|
---|
45 | print >>input,"\t\t\t\t%s\t%s\t%s\t%s" % (elements[int(atome[0])-1], atome[1], atome[2], atome[3])
|
---|
46 | print >>input,"\t\t\t}"
|
---|
47 | print >>input,"\t\t)"
|
---|
48 | print >>input,"\t\tbasis<GaussianBasisSet>: ("
|
---|
49 | print >>input,"\t\t\tname = \"%s\"" % (BASIS)
|
---|
50 | print >>input,"\t\t\tmolecule = $:mpqc:mole:molecule"
|
---|
51 | print >>input,"\t\t)"
|
---|
52 | print >>input,"\t)"
|
---|
53 | print >>input,")"
|
---|