| 1 |
< |
#!/usr/bin/env python |
| 1 |
> |
#!@PYTHON_EXECUTABLE@ |
| 2 |
|
"""MetaData file remapper |
| 3 |
|
|
| 4 |
|
Takes a MetaData file and maps all StuntDoubles back to the periodic box. |
| 24 |
|
""" |
| 25 |
|
|
| 26 |
|
__author__ = "Dan Gezelter (gezelter@nd.edu)" |
| 27 |
< |
__version__ = "$Revision: 1.4 $" |
| 28 |
< |
__date__ = "$Date: 2009-10-22 19:12:14 $" |
| 27 |
> |
__version__ = "$Revision$" |
| 28 |
> |
__date__ = "$Date$" |
| 29 |
|
__copyright__ = "Copyright (c) 2009 by the University of Notre Dame" |
| 30 |
< |
__license__ = "OOPSE" |
| 30 |
> |
__license__ = "OpenMD" |
| 31 |
|
|
| 32 |
|
import sys |
| 33 |
|
import getopt |
| 52 |
|
|
| 53 |
|
def readFile(mdFileName): |
| 54 |
|
mdFile = open(mdFileName, 'r') |
| 55 |
< |
# Find OOPSE version info first |
| 55 |
> |
# Find OpenMD version info first |
| 56 |
|
line = mdFile.readline() |
| 57 |
|
while 1: |
| 58 |
< |
if '<OOPSE version=' in line: |
| 59 |
< |
OOPSEversion = line |
| 58 |
> |
if '<OOPSE version=' in line or '<OpenMD version=' in line: |
| 59 |
> |
OpenMDversion = line |
| 60 |
|
break |
| 61 |
|
line = mdFile.readline() |
| 62 |
|
|
| 119 |
|
myIndex = int(L[0]) |
| 120 |
|
indices.append(myIndex) |
| 121 |
|
pvqj.append(L[1]) |
| 122 |
< |
x = float(L[2]) |
| 123 |
< |
y = float(L[3]) |
| 124 |
< |
z = float(L[4]) |
| 125 |
< |
p.append([x, y, z]) |
| 126 |
< |
vx = float(L[5]) |
| 127 |
< |
vy = float(L[6]) |
| 128 |
< |
vz = float(L[7]) |
| 129 |
< |
v.append([vx, vy, vz]) |
| 130 |
< |
if 'pvqj' in L[1]: |
| 122 |
> |
if 'p' in L[1]: |
| 123 |
> |
x = float(L[2]) |
| 124 |
> |
y = float(L[3]) |
| 125 |
> |
z = float(L[4]) |
| 126 |
> |
p.append([x, y, z]) |
| 127 |
> |
else: |
| 128 |
> |
p.append([0.0, 0.0, 0.0]) |
| 129 |
> |
if 'v' in L[1]: |
| 130 |
> |
vx = float(L[5]) |
| 131 |
> |
vy = float(L[6]) |
| 132 |
> |
vz = float(L[7]) |
| 133 |
> |
v.append([vx, vy, vz]) |
| 134 |
> |
else: |
| 135 |
> |
v.append([0.0, 0.0, 0.0]) |
| 136 |
> |
if 'q' in L[1]: |
| 137 |
|
qw = float(L[8]) |
| 138 |
|
qx = float(L[9]) |
| 139 |
|
qy = float(L[10]) |
| 140 |
|
qz = float(L[11]) |
| 141 |
|
q.append([qw, qx, qy, qz]) |
| 142 |
+ |
else: |
| 143 |
+ |
q.append([0.0, 0.0, 0.0, 0.0]) |
| 144 |
+ |
if 'j' in L[1]: |
| 145 |
|
jx = float(L[12]) |
| 146 |
|
jy = float(L[13]) |
| 147 |
|
jz = float(L[14]) |
| 148 |
|
j.append([jx, jy, jz]) |
| 149 |
|
else: |
| 141 |
– |
q.append([0.0, 0.0, 0.0, 0.0]) |
| 150 |
|
j.append([0.0, 0.0, 0.0]) |
| 151 |
|
|
| 152 |
|
line = mdFile.readline() |
| 161 |
|
def writeFile(outputFileName,repeatX,repeatY,repeatZ): |
| 162 |
|
outputFile = open(outputFileName, 'w') |
| 163 |
|
|
| 164 |
< |
outputFile.write("<OOPSE version=4>\n"); |
| 164 |
> |
outputFile.write("<OpenMD version=1>\n"); |
| 165 |
|
|
| 166 |
|
print "writing MetaData" |
| 167 |
|
for metaline in metaData: |
| 195 |
|
deco = [ (index, i) for i, index in enumerate(indices) ] |
| 196 |
|
deco.sort() |
| 197 |
|
whichSD = 0 |
| 198 |
< |
for index in range(len(deco)): |
| 199 |
< |
(index,i) = deco[index] |
| 200 |
< |
print i |
| 201 |
< |
for ii in range(repeatX): |
| 202 |
< |
for jj in range(repeatY): |
| 203 |
< |
for kk in range(repeatZ): |
| 198 |
> |
for ii in range(repeatX): |
| 199 |
> |
for jj in range(repeatY): |
| 200 |
> |
for kk in range(repeatZ): |
| 201 |
> |
for index in range(len(deco)): |
| 202 |
> |
(index,i) = deco[index] |
| 203 |
> |
print i |
| 204 |
|
myP = [] |
| 205 |
|
myP.append(p[i][0] + ii*Hmat[0][0] + jj*Hmat[1][0] + kk*Hmat[2][0]) |
| 206 |
|
myP.append(p[i][1] + ii*Hmat[0][1] + jj*Hmat[1][1] + kk*Hmat[2][1]) |
| 207 |
|
myP.append(p[i][2] + ii*Hmat[0][2] + jj*Hmat[1][2] + kk*Hmat[2][2]) |
| 208 |
< |
|
| 209 |
< |
if (pvqj[i] == 'pv'): |
| 210 |
< |
outputFile.write("%10d %7s %18.10g %18.10g %18.10g %14e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], v[i][0], v[i][1], v[i][2])) |
| 208 |
> |
|
| 209 |
> |
if (pvqj[i] == 'p'): |
| 210 |
> |
outputFile.write("%10d %7s %18.10g %18.10g %18.10g\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2])) |
| 211 |
> |
|
| 212 |
> |
elif (pvqj[i] == 'pv'): |
| 213 |
> |
outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], v[i][0], v[i][1], v[i][2])) |
| 214 |
> |
elif (pvqj[i] == 'pq'): |
| 215 |
> |
outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], q[i][0], q[i][1], q[i][2], q[i][3])) |
| 216 |
|
elif (pvqj[i] == 'pvqj'): |
| 217 |
|
outputFile.write("%10d %7s %18.10g %18.10g %18.10g %13e %13e %13e %13e %13e %13e %13e %13e %13e %13e\n" % (whichSD, pvqj[i], myP[0], myP[1], myP[2], v[i][0], v[i][1], v[i][2], q[i][0], q[i][1], q[i][2], q[i][3], j[i][0], j[i][1], j[i][2])) |
| 218 |
|
whichSD = whichSD + 1 |
| 219 |
|
|
| 220 |
|
outputFile.write(" </StuntDoubles>\n") |
| 221 |
|
outputFile.write(" </Snapshot>\n") |
| 222 |
< |
outputFile.write("</OOPSE>\n") |
| 222 |
> |
outputFile.write("</OpenMD>\n") |
| 223 |
|
outputFile.close() |
| 224 |
|
|
| 225 |
|
def roundMe(x): |