4Converts old-style OOPSE md and dump files into new OpenMD style
10 -h, --help show this help
11 -m, --meta-data=... use specified meta-data (.md) file
12 -c, --config-file=... use specified configuration (.in, .eor, .dump) file
13 -o, --output-file=... use specified output (.omd) file
17 dumpConverter -m Ar.md -c Ar.dump -o Ar.omd
21__author__ = "Dan Gezelter (gezelter@nd.edu)"
22__version__ = "$Revision$"
24__copyright__ = "Copyright (c) 2004-present The University of Notre Dame. All Rights Reserved."
33_haveOutputFileName = 0
39def convertFiles(mdFileName, configFileName, outputFileName):
40 mdFile = open(mdFileName, 'r')
41 outputFile = open(outputFileName, 'w')
43 outputFile.write("<OpenMD version=1>\n");
44 outputFile.write(" <MetaData>\n")
46 mdLines = mdFile.readlines()
48 if (l.find('initialConfig') == -1):
51 outputFile.write(" </MetaData>\n")
55 configFile = open(configFileName, 'r')
56 for line in configFile.readlines():
57 framePos = framePos + 1
60 nStuntDoubles = int(L[0])
62 outputFile.write(" <Snapshot>\n")
65 L = line.replace(';', ' ').split()
67 outputFile.write(" <FrameData>\n");
68 outputFile.write(" Time: %.10g\n" % (time))
78 outputFile.write(" Hmat: {{ %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }}\n" % (Hxx, Hxy, Hxz, Hyx, Hyy, Hyz, Hzx, Hzy, Hzz))
81 integChi = float(L[11])
82 outputFile.write(" Thermostat: %.10g , %.10g\n" % (chi, integChi))
93 outputFile.write(" Barostat: {{ %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }, { %.10g, %.10g, %.10g }}\n" % (Nxx, Nxy, Nxz, Nyx, Nyy, Nyz, Nzx, Nzy, Nzz))
95 outputFile.write(" </FrameData>\n")
96 outputFile.write(" <StuntDoubles>\n")
120 if (qw == 0.0 and qx == 0.0 and qy == 0.0 and qz == 0.0):
131 if (qw == 0.0 and qx == 0.0 and qy == 0.0 and qz == 0.0):
135 if (sdFormat == 'pv'):
136 outputFile.write("%10d %7s %18.10g %18.10g %18.10g %14e %13e %13e\n" % (whichSD-1, sdFormat, x, y, z, vx, vy, vz))
137 elif (sdFormat == 'pvf'):
138 outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e %13e %13e %13e\n" % (whichSD-1, sdFormat, x, y, z, vx, vy, vz, fx, fy, fz))
139 elif (sdFormat == 'pvqj'):
140 outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e\n" % (whichSD-1, sdFormat, x, y, z, vx, vy, vz, qw, qx, qy, qz, jx, jy, jz))
141 elif (sdFormat == 'pvqjft'):
142 outputFile.write("%d %s %18.10g %18.10g %18.10g %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e\n" % (whichSD-1, sdFormat, x, y, z, vx, vy, vz, qw, qx, qy, qz, jx, jy, jz, fx, fy, fz, tx, ty, tz))
143 if (whichSD == nStuntDoubles):
144 outputFile.write(" </StuntDoubles>\n")
145 outputFile.write(" </Snapshot>\n")
150 outputFile.write("</OpenMD>\n")
156 opts, args = getopt.getopt(argv, "hm:c:o:", ["help", "meta-data=", "config-file=", "output-file="])
157 except getopt.GetoptError:
160 for opt, arg in opts:
161 if opt in ("-h", "--help"):
164 elif opt in ("-m", "--meta-data"):
166 global _haveMDFileName
168 elif opt in ("-c", "--config-file"):
170 global _haveConfFileName
171 _haveConfFileName = 1
172 elif opt in ("-o", "--output-file"):
174 global _haveOutputFileName
175 _haveOutputFileName = 1
176 if (_haveMDFileName != 1):
178 print("No meta-data file was specified")
180 if (_haveConfFileName != 1):
182 print("No configuration file was specified")
184 if (_haveOutputFileName != 1):
186 print("No output file was specified")
188 convertFiles(mdFileName, configFileName, outputFileName);
190if __name__ == "__main__":
191 if len(sys.argv) == 1: