1 |
|
#!/usr/bin/env python |
2 |
|
"""Dump File Converter |
3 |
|
|
4 |
< |
Converts old-style OOPSE md and dump files into new-style |
4 |
> |
Converts old-style OOPSE md and dump files into new OpenMD style |
5 |
|
combined files |
6 |
|
|
7 |
|
Usage: dumpConverter |
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 (.oop) file |
13 |
> |
-o, --output-file=... use specified output (.opmd) file |
14 |
|
|
15 |
|
|
16 |
|
Example: |
17 |
< |
dumpConverter -m Ar.md -c Ar.dump -o Ar.oop |
17 |
> |
dumpConverter -m Ar.md -c Ar.dump -o Ar.opmd |
18 |
|
|
19 |
|
""" |
20 |
|
|
21 |
|
__author__ = "Dan Gezelter (gezelter@nd.edu)" |
22 |
< |
__version__ = "$Revision: 1.2 $" |
23 |
< |
__date__ = "$Date: 2006-07-27 20:36:54 $" |
22 |
> |
__version__ = "$Revision: 1.5 $" |
23 |
> |
__date__ = "$Date: 2009-11-25 20:01:59 $" |
24 |
|
__copyright__ = "Copyright (c) 2006 by the University of Notre Dame" |
25 |
< |
__license__ = "OOPSE" |
25 |
> |
__license__ = "OpenMD" |
26 |
|
|
27 |
|
import sys |
28 |
|
import getopt |
40 |
|
mdFile = open(mdFileName, 'r') |
41 |
|
outputFile = open(outputFileName, 'w') |
42 |
|
|
43 |
< |
outputFile.write("<OOPSE version=4>\n"); |
43 |
> |
outputFile.write("<OpenMD version=1>\n"); |
44 |
|
outputFile.write(" <MetaData>\n") |
45 |
|
|
46 |
|
mdLines = mdFile.readlines() |
104 |
|
vy = float(L[5]) |
105 |
|
vz = float(L[6]) |
106 |
|
sdFormat = 'pv' |
107 |
< |
if (len(L) == 14): |
107 |
> |
if (len(L) == 10): |
108 |
> |
sdFormat = 'pvf' |
109 |
> |
fx = float(L[7]) |
110 |
> |
fy = float(L[8]) |
111 |
> |
fz = float(L[9]) |
112 |
> |
if (len(L) >= 14): |
113 |
|
qw = float(L[7]) |
114 |
|
qx = float(L[8]) |
115 |
|
qy = float(L[9]) |
128 |
|
tx = float(L[17]) |
129 |
|
ty = float(L[18]) |
130 |
|
tz = float(L[19]) |
131 |
< |
sdFormat = 'pvqjft' |
131 |
> |
if (qw == 0.0 and qx == 0.0 and qy == 0.0 and qz == 0.0): |
132 |
> |
sdFormat = 'pvf' |
133 |
> |
else: |
134 |
> |
sdFormat = 'pvqjft' |
135 |
|
if (sdFormat == 'pv'): |
136 |
< |
outputFile.write("%d\t%s\t%18.10g\t%18.10g\t%18.10g\t%14.10g\t%14.10g\t%14.10g\n" % (whichSD-1, sdFormat, x, y, z, vx, vy, vz)) |
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("%d\t%s\t%18.10g\t%18.10g\t%18.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\n" % (whichSD-1, sdFormat, x, y, z, vx, vy, vz, qw, qx, qy, qz, jx, jy, jz)) |
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\t%s\t%18.10g\t%18.10g\t%18.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\t%14.10g\n" % (whichSD-1, sdFormat, x, y, z, vx, vy, vz, qw, qx, qy, qz, jx, jy, jz, fx, fy, fz, tx, ty, tz)) |
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") |
147 |
|
|
148 |
|
|
149 |
|
configFile.close() |
150 |
< |
outputFile.write("</OOPSE>\n") |
150 |
> |
outputFile.write("</OpenMD>\n") |
151 |
|
outputFile.close() |
152 |
|
|
153 |
|
|